CbmRoot
CbmMvdDigiToHitTB.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdDigiToHitTB source file -----
3 // -------------------------------------------------------------------------
4 
5 // Includes from MVD
6 #include "CbmMvdDigiToHitTB.h"
7 #include "CbmEvent.h"
8 #include "CbmMvdDetector.h"
9 #include "CbmMvdPoint.h"
11 #include "tools/CbmMvdGeoHandler.h"
12 
13 // Includes from FAIR
14 #include "FairModule.h"
15 #include "FairRootManager.h"
16 
17 
18 // Includes from ROOT
19 #include "TClonesArray.h"
20 #include "TGeoManager.h"
21 
22 #include "TMath.h"
23 #include "TString.h"
24 
25 
26 // Includes from C++
27 #include <iomanip>
28 #include <iostream>
29 
30 using std::cout;
31 using std::endl;
32 using std::fixed;
33 using std::setprecision;
34 using std::setw;
35 
36 // ----- Default constructor ------------------------------------------
38  : CbmMvdDigiToHitTB("MVDDigiToHitTB", 0, 0) {}
39 // -------------------------------------------------------------------------
40 
41 // ----- Standard constructor ------------------------------------------
43  Int_t iMode,
44  Int_t iVerbose)
45  : FairTask(name, iVerbose)
46  , fMode(iMode)
47  , fShowDebugHistos(kFALSE)
48  , fDetector(NULL)
49  , fEvents(NULL)
50  , fInputDigis(NULL)
51  , fEventDigis(NULL)
52  , fCluster(NULL)
53  , fClusterPluginNr(0)
54  , fBranchName("MvdDigi")
55  , fTimer() {}
56 // -------------------------------------------------------------------------
57 
58 // ----- Destructor ----------------------------------------------------
60 
61  if (fCluster) {
62  fCluster->Delete();
63  delete fCluster;
64  }
65 }
66 // -----------------------------------------------------------------------------
67 
68 // ----- Exec --------------------------------------------------------------
69 void CbmMvdDigiToHitTB::Exec(Option_t* /*opt*/) {
70  // --- Start timer
71  fTimer.Start();
72 
73  fCluster->Delete();
74 
75  Int_t nEvents = fEvents->GetEntriesFast();
76  for (Int_t iEv = 0; iEv < nEvents; ++iEv) {
77  LOG(debug) << "Getting data from CbmEvent";
78  CbmEvent* event = dynamic_cast<CbmEvent*>(fEvents->At(iEv));
79  Int_t nrOfDigis = event->GetNofData(ECbmDataType::kMvdDigi);
80  fEventDigis->Delete();
81  for (Int_t nDigi = 0; nDigi < nrOfDigis; ++nDigi) {
82  Int_t iDigi = event->GetIndex(ECbmDataType::kMvdDigi, nDigi);
83  fEventDigis->AddLast((CbmMvdDigi*) fInputDigis->At(iDigi));
84  }
85  LOG(debug) << "//----------------------------------------//";
86  LOG(debug) << endl << "Send Input";
87  fDetector->SendInputDigisToHits(fEventDigis); //Version for DigisToHits
88  LOG(debug) << "Execute HitPlugin Nr. " << fClusterPluginNr;
90  LOG(debug) << "End Chain";
91  LOG(debug) << "Start writing Hit";
92  fCluster->AbsorbObjects(fDetector->GetOutputHits(),
93  0,
94  fDetector->GetOutputHits()->GetEntriesFast() - 1);
95  LOG(debug) << "Total of " << fCluster->GetEntriesFast()
96  << " Hit in this Event";
97  LOG(debug) << "//----------------------------------------//";
98  LOG(info) << "+ " << setw(20) << GetName()
99  << ": Created: " << fCluster->GetEntriesFast() << " hit in "
100  << fixed << setprecision(6) << fTimer.RealTime() << " s";
101  }
102  fTimer.Stop();
103 }
104 // -----------------------------------------------------------------------------
105 
106 // ----- Init --------------------------------------------------------------
108  cout << "-I- " << GetName() << ": Initialisation..." << endl;
109  cout << endl;
110  cout << "---------------------------------------------" << endl;
111  cout << "-I- Initialising " << GetName() << " ...." << endl;
112 
113  // ********** RootManager
114  FairRootManager* ioman = FairRootManager::Instance();
115  if (!ioman) {
116  cout << "-E- " << GetName() << "::Init: No FairRootManager!" << endl;
117  return kFATAL;
118  }
119 
120  // ********** Get input arrays
121  fEvents = (TClonesArray*) ioman->GetObject("Event");
122 
123  fInputDigis = (TClonesArray*) ioman->GetObject("MvdDigi");
124  fEventDigis = new TClonesArray("CbmMvdDigi", 10000);
125  if (!fInputDigis) {
126  LOG(error) << "No MvdDigi branch found. There was no MVD in the "
127  "simulation. Switch this task off";
128  return kERROR;
129  }
130 
131  // ********** Register output array
132  fCluster = new TClonesArray("CbmMvdHit", 10000);
133  ioman->Register(
134  "MvdHit", "Mvd Hits", fCluster, IsOutputBranchPersistent("MvdHit"));
135 
137 
138  if (fDetector->GetSensorArraySize() > 1) {
139  LOG(debug) << "-I- succesfully loaded Geometry from file -I-";
140  } else {
141  LOG(fatal)
142  << "Geometry couldn't be loaded from file. No MVD digitizer available.";
143  }
144 
146 
147  fDetector->AddPlugin(clusterTask);
150  fDetector->Init();
151 
152 
153  // Screen output
154  LOG(info) << GetName() << " initialised";
155 
156  return kSUCCESS;
157 }
158 
159 // ----- Virtual public method Reinit ----------------------------------
160 InitStatus CbmMvdDigiToHitTB::ReInit() { return kSUCCESS; }
161 // -------------------------------------------------------------------------
162 
163 
164 // ----- Virtual method Finish -----------------------------------------
166  fDetector->Finish();
167  PrintParameters();
168 }
169 // -------------------------------------------------------------------------
170 
171 
172 // ----- Private method Reset ------------------------------------------
173 void CbmMvdDigiToHitTB::Reset() { fCluster->Delete(); }
174 // -------------------------------------------------------------------------
175 
176 // ----- Private method GetMvdGeometry ---------------------------------
178 // -------------------------------------------------------------------------
179 
180 
181 // ----- Private method PrintParameters --------------------------------
183 
184  cout << "============================================================"
185  << endl;
186  cout << "============== Parameters DigiToHit ====================" << endl;
187  cout << "============================================================"
188  << endl;
189  cout << "=============== End Task ==================================="
190  << endl;
191 }
192 // -------------------------------------------------------------------------
193 
194 
CbmMvdDetector::Instance
static CbmMvdDetector * Instance()
Definition: CbmMvdDetector.cxx:47
CbmMvdDetector.h
CbmMvdDetector::Exec
void Exec(UInt_t nLevel)
Definition: CbmMvdDetector.cxx:527
CbmMvdDetector::SendInputDigisToHits
void SendInputDigisToHits(TClonesArray *digis)
Definition: CbmMvdDetector.cxx:438
CbmMvdDigiToHitTB::Init
virtual InitStatus Init()
Definition: CbmMvdDigiToHitTB.cxx:107
CbmMvdDetector::GetPluginArraySize
UInt_t GetPluginArraySize()
Definition: CbmMvdDetector.h:71
CbmMvdDigiToHitTB::ReInit
virtual InitStatus ReInit()
Definition: CbmMvdDigiToHitTB.cxx:160
ECbmDataType::kMvdDigi
@ kMvdDigi
CbmMvdDigiToHitTB::~CbmMvdDigiToHitTB
~CbmMvdDigiToHitTB()
Definition: CbmMvdDigiToHitTB.cxx:59
CbmMvdDigiToHitTB::Reset
void Reset()
Definition: CbmMvdDigiToHitTB.cxx:173
CbmMvdDetector::Init
void Init()
Definition: CbmMvdDetector.cxx:278
CbmMvdDetector::Finish
void Finish()
Definition: CbmMvdDetector.cxx:705
CbmMvdDigiToHitTB
Definition: CbmMvdDigiToHitTB.h:20
CbmMvdDigiToHitTB::PrintParameters
void PrintParameters()
Definition: CbmMvdDigiToHitTB.cxx:182
CbmMvdDigiToHitTB::fDetector
CbmMvdDetector * fDetector
Definition: CbmMvdDigiToHitTB.h:45
CbmMvdDigiToHitTB::fShowDebugHistos
Bool_t fShowDebugHistos
Definition: CbmMvdDigiToHitTB.h:44
CbmMvdDigiToHitTB::fEvents
TClonesArray * fEvents
Definition: CbmMvdDigiToHitTB.h:47
CbmMvdDigiToHitTB::fTimer
TStopwatch fTimer
ROOT timer.
Definition: CbmMvdDigiToHitTB.h:58
CbmMvdGeoHandler.h
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
CbmMvdDetector::ShowDebugHistos
void ShowDebugHistos()
Definition: CbmMvdDetector.cxx:313
CbmMvdDigiToHitTB::fInputDigis
TClonesArray * fInputDigis
Definition: CbmMvdDigiToHitTB.h:48
CbmEvent.h
CbmMvdPoint.h
CbmMvdDetector::GetOutputHits
TClonesArray * GetOutputHits()
Definition: CbmMvdDetector.cxx:595
CbmMvdDigiToHitTB::fEventDigis
TClonesArray * fEventDigis
Definition: CbmMvdDigiToHitTB.h:49
CbmMvdDigiToHitTB::Exec
void Exec(Option_t *opt)
Definition: CbmMvdDigiToHitTB.cxx:69
CbmMvdDigiToHitTB::CbmMvdDigiToHitTB
CbmMvdDigiToHitTB()
Definition: CbmMvdDigiToHitTB.cxx:37
CbmMvdSensorDigiToHitTask
Definition: CbmMvdSensorDigiToHitTask.h:40
ClassImp
ClassImp(CbmMvdDigiToHitTB)
CbmMvdDigiToHitTB::GetMvdGeometry
void GetMvdGeometry()
Definition: CbmMvdDigiToHitTB.cxx:177
CbmEvent::GetNofData
Int_t GetNofData() const
Definition: CbmEvent.h:90
CbmMvdDigiToHitTB::Finish
virtual void Finish()
Definition: CbmMvdDigiToHitTB.cxx:165
CbmMvdDetector::GetSensorArraySize
Int_t GetSensorArraySize()
Definition: CbmMvdDetector.h:70
CbmMvdDigiToHitTB::fCluster
TClonesArray * fCluster
Definition: CbmMvdDigiToHitTB.h:50
CbmMvdDigiToHitTB.h
CbmMvdDigi
Definition: CbmMvdDigi.h:21
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
CbmMvdDetector::AddPlugin
void AddPlugin(CbmMvdSensorPlugin *plugin)
Definition: CbmMvdDetector.cxx:186
CbmMvdSensorDigiToHitTask.h
CbmMvdDigiToHitTB::fClusterPluginNr
UInt_t fClusterPluginNr
Definition: CbmMvdDigiToHitTB.h:53