CbmRoot
CbmMvdHitfinderTB.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdHitfinderTB source file -----
3 // -------------------------------------------------------------------------
4 
5 // Includes from MVD
6 #include "CbmMvdHitfinderTB.h"
7 #include "CbmMvdPoint.h"
11 #include "tools/CbmMvdGeoHandler.h"
12 
13 
14 // Includes from FAIR
15 #include "FairModule.h"
16 #include "FairRootManager.h"
17 
18 // Includes from ROOT
19 #include "TClonesArray.h"
20 
21 
22 // Includes from C++
23 #include <iomanip>
24 #include <iostream>
25 
26 using std::cout;
27 using std::endl;
28 using std::fixed;
29 using std::ios_base;
30 using std::setprecision;
31 using std::setw;
32 
33 // ----- Default constructor ------------------------------------------
35  : FairTask("MVDHitfinder")
36  , fDetector(NULL)
37  , fInputDigis(NULL)
38  , fInputCluster(NULL)
39  , fHits(NULL)
40  , fHitfinderPluginNr(0)
41  , useClusterfinder(kFALSE)
42  , fShowDebugHistos(kFALSE)
43  , fTimer()
44  , fmode(-1) {}
45 // -------------------------------------------------------------------------
46 
47 // ----- Standard constructor ------------------------------------------
48 CbmMvdHitfinderTB::CbmMvdHitfinderTB(const char* name, Int_t iVerbose)
49  : FairTask(name, iVerbose)
50  , fDetector(NULL)
51  , fInputDigis(NULL)
52  , fInputCluster(NULL)
53  , fHits(NULL)
54  , fHitfinderPluginNr(0)
55  , useClusterfinder(kFALSE)
56  , fShowDebugHistos(kFALSE)
57  , fTimer()
58  , fmode(-1) {}
59 // -------------------------------------------------------------------------
60 
61 // ----- Standard constructor ------------------------------------------
63  Int_t mode,
64  Int_t iVerbose)
65  : FairTask(name, iVerbose)
66  , fDetector(NULL)
67  , fInputDigis(NULL)
68  , fInputCluster(NULL)
69  , fHits(NULL)
70  , fHitfinderPluginNr(0)
71  , useClusterfinder(kFALSE)
72  , fShowDebugHistos(kFALSE)
73  , fTimer()
74  , fmode(mode) {
75  // fmode = mode;
76 }
77 // -------------------------------------------------------------------------
78 
79 // ----- Destructor ----------------------------------------------------
81 
82  if (fHits) {
83  fHits->Delete();
84  delete fHits;
85  }
86 }
87 // -----------------------------------------------------------------------------
88 
89 // ----- Exec --------------------------------------------------------------
90 void CbmMvdHitfinderTB::Exec(Option_t* /*opt*/) {
91 
92  using namespace std;
93 
94  fHits->Clear();
95  fTimer.Start();
96 
97  LOG(debug) << endl << "//----------------------------------------//";
99  LOG(debug) << "Execute HitfinderPlugin Nr. " << fHitfinderPluginNr;
101  LOG(debug) << "End Chain";
102  LOG(debug) << "Start writing Hits";
103  fHits->AbsorbObjects(fDetector->GetOutputHits(),
104  0,
105  fDetector->GetOutputHits()->GetEntriesFast() - 1);
106  LOG(debug) << "Total of " << fHits->GetEntriesFast() << " hits found";
107  LOG(debug) << "Finished writing Hits";
108  LOG(debug) << "//----------------------------------------//";
109  LOG(info) << "+ " << setw(20) << GetName()
110  << ": Created: " << fHits->GetEntriesFast() << " hits in " << fixed
111  << setprecision(6) << fTimer.RealTime() << " s";
112  fTimer.Stop();
113 }
114 // -----------------------------------------------------------------------------
115 
116 // ----- Init --------------------------------------------------------------
118 
119  using namespace std;
120 
121  cout << "-I- " << GetName() << ": Initialisation..." << endl;
122  cout << endl;
123  cout << "---------------------------------------------" << endl;
124  cout << "-I- Initialising " << GetName() << " ...." << endl;
125 
126  // ********** RootManager
127  FairRootManager* ioman = FairRootManager::Instance();
128  if (!ioman) {
129  cout << "-E- " << GetName() << "::Init: No FairRootManager!" << endl;
130  return kFATAL;
131  }
132 
133  // ********** Get input arrays
134 
135  fInputCluster = (TClonesArray*) ioman->GetObject("MvdCluster");
136  if (!fInputCluster) {
137  LOG(error) << "No MvdCluster branch found. There was no MVD in the "
138  "simulation. Switch this task off";
139  return kERROR;
140  }
141 
142  // ********** Register output array
143  fHits = new TClonesArray("CbmMvdHit", 10000);
144  ioman->Register(
145  "MvdHit", "Mvd Hits", fHits, IsOutputBranchPersistent("MvdHit"));
146 
148 
150  fDetector->AddPlugin(HitfinderTask);
151 
154  fDetector->Init();
155 
156  // Screen output
157  cout << GetName() << " initialised with parameters: " << endl;
158  //PrintParameters();
159  cout << "---------------------------------------------" << endl;
160 
161 
162  return kSUCCESS;
163 }
164 
165 // ----- Virtual public method Reinit ----------------------------------
166 InitStatus CbmMvdHitfinderTB::ReInit() { return kSUCCESS; }
167 // -------------------------------------------------------------------------
168 
169 
170 // ----- Virtual method Finish -----------------------------------------
172 // -------------------------------------------------------------------------
173 
174 
175 // ----- Private method Reset ------------------------------------------
176 void CbmMvdHitfinderTB::Reset() { fHits->Delete(); }
177 // -------------------------------------------------------------------------
178 
179 // ----- Private method GetMvdGeometry ---------------------------------
181 // -------------------------------------------------------------------------
182 
183 
184 // ----- Private method PrintParameters --------------------------------
186 
187  using namespace std;
188 
189  cout.setf(ios_base::fixed, ios_base::floatfield);
190  cout << "============================================================"
191  << endl;
192  cout << "============== Parameters MvdHitfinder ====================="
193  << endl;
194  cout << "============================================================"
195  << endl;
196  cout << "=============== End Task ==================================="
197  << endl;
198 }
199 // -------------------------------------------------------------------------
200 
CbmMvdDetector::Instance
static CbmMvdDetector * Instance()
Definition: CbmMvdDetector.cxx:47
CbmMvdDetector::Exec
void Exec(UInt_t nLevel)
Definition: CbmMvdDetector.cxx:527
CbmMvdDetector::GetPluginArraySize
UInt_t GetPluginArraySize()
Definition: CbmMvdDetector.h:71
CbmMvdSensorHitfinderTask.h
CbmMvdHitfinderTB::fTimer
TStopwatch fTimer
ROOT timer.
Definition: CbmMvdHitfinderTB.h:50
CbmMvdHitfinderTB::ReInit
virtual InitStatus ReInit()
Definition: CbmMvdHitfinderTB.cxx:166
CbmMvdSensorFindHitTask.h
CbmMvdDetector::Init
void Init()
Definition: CbmMvdDetector.cxx:278
CbmMvdHitfinderTB::Exec
void Exec(Option_t *opt)
Definition: CbmMvdHitfinderTB.cxx:90
CbmMvdHitfinderTB::GetMvdGeometry
void GetMvdGeometry()
Definition: CbmMvdHitfinderTB.cxx:180
CbmMvdHitfinderTB::Reset
void Reset()
Definition: CbmMvdHitfinderTB.cxx:176
CbmMvdHitfinderTB::Finish
virtual void Finish()
Definition: CbmMvdHitfinderTB.cxx:171
CbmMvdGeoHandler.h
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
CbmMvdDetector::ShowDebugHistos
void ShowDebugHistos()
Definition: CbmMvdDetector.cxx:313
CbmMvdPoint.h
CbmMvdHitfinderTB::Init
virtual InitStatus Init()
Definition: CbmMvdHitfinderTB.cxx:117
CbmMvdDetector::GetOutputHits
TClonesArray * GetOutputHits()
Definition: CbmMvdDetector.cxx:595
CbmMvdHitfinderTB.h
CbmMvdSensorHitfinderTask
Definition: CbmMvdSensorHitfinderTask.h:40
CbmMvdHitfinderTB::CbmMvdHitfinderTB
CbmMvdHitfinderTB()
Definition: CbmMvdHitfinderTB.cxx:34
CbmMvdHitfinderTB
Definition: CbmMvdHitfinderTB.h:16
CbmMvdHitfinderTB::fInputCluster
TClonesArray * fInputCluster
Definition: CbmMvdHitfinderTB.h:44
CbmMvdHitfinderTB::PrintParameters
void PrintParameters()
Definition: CbmMvdHitfinderTB.cxx:185
CbmMvdHitfinderTB::~CbmMvdHitfinderTB
virtual ~CbmMvdHitfinderTB()
Definition: CbmMvdHitfinderTB.cxx:80
CbmMvdHitfinderTB::fDetector
CbmMvdDetector * fDetector
Definition: CbmMvdHitfinderTB.h:41
ClassImp
ClassImp(CbmMvdHitfinderTB)
CbmMvdMimosa26AHR.h
CbmMvdHitfinderTB::fHitfinderPluginNr
UInt_t fHitfinderPluginNr
Definition: CbmMvdHitfinderTB.h:47
CbmMvdHitfinderTB::fShowDebugHistos
Bool_t fShowDebugHistos
Definition: CbmMvdHitfinderTB.h:49
CbmMvdDetector::AddPlugin
void AddPlugin(CbmMvdSensorPlugin *plugin)
Definition: CbmMvdDetector.cxx:186
CbmMvdDetector::SendInputCluster
void SendInputCluster(TClonesArray *cluster)
Definition: CbmMvdDetector.cxx:469
CbmMvdHitfinderTB::fHits
TClonesArray * fHits
Definition: CbmMvdHitfinderTB.h:45