CbmRoot
CbmMvdHitfinder.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdHitfinder source file -----
3 // -------------------------------------------------------------------------
4 
5 // Includes from MVD
6 #include "CbmMvdHitfinder.h"
7 #include "CbmMvdPoint.h"
11 #include "tools/CbmMvdGeoHandler.h"
12 
13 #include "CbmDigiManager.h"
14 
15 
16 // Includes from FAIR
17 #include "FairModule.h"
18 #include "FairRootManager.h"
19 
20 // Includes from ROOT
21 #include "TClonesArray.h"
22 
23 
24 // Includes from C++
25 #include <iomanip>
26 #include <iostream>
27 
28 using std::cout;
29 using std::endl;
30 using std::fixed;
31 using std::ios_base;
32 using std::setprecision;
33 using std::setw;
34 
35 // ----- Default constructor ------------------------------------------
37  : FairTask("MVDHitfinder")
38  , fDetector(NULL)
39  , fDigiMan(nullptr)
40  , fInputCluster(NULL)
41  , fHits(NULL)
42  , fHitfinderPluginNr(0)
43  , useClusterfinder(kFALSE)
44  , fShowDebugHistos(kFALSE)
45  , fTimer()
46  , fmode(-1) {}
47 // -------------------------------------------------------------------------
48 
49 // ----- Standard constructor ------------------------------------------
50 CbmMvdHitfinder::CbmMvdHitfinder(const char* name, Int_t iVerbose)
51  : FairTask(name, iVerbose)
52  , fDetector(NULL)
53  , fDigiMan(nullptr)
54  , fInputCluster(NULL)
55  , fHits(NULL)
56  , fHitfinderPluginNr(0)
57  , useClusterfinder(kFALSE)
58  , fShowDebugHistos(kFALSE)
59  , fTimer()
60  , fmode(-1) {}
61 // -------------------------------------------------------------------------
62 
63 // ----- Standard constructor ------------------------------------------
64 CbmMvdHitfinder::CbmMvdHitfinder(const char* name, Int_t mode, Int_t iVerbose)
65  : FairTask(name, iVerbose)
66  , fDetector(NULL)
67  , fDigiMan(nullptr)
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 CbmMvdHitfinder::Exec(Option_t* /*opt*/) {
91 
92  using namespace std;
93 
94  fHits->Clear();
95  fTimer.Start();
97  if (fVerbose)
98  cout << endl << "//----------------------------------------//" << endl;
99  if (!useClusterfinder)
101  else
103  if (fVerbose)
104  cout << "Execute HitfinderPlugin Nr. " << fHitfinderPluginNr << endl;
106  if (fVerbose) cout << "End Chain" << endl;
107  if (fVerbose) cout << "Start writing Hits" << endl;
108  fHits->AbsorbObjects(fDetector->GetOutputHits(),
109  0,
110  fDetector->GetOutputHits()->GetEntriesFast() - 1);
111  if (fVerbose)
112  cout << "Total of " << fHits->GetEntriesFast() << " hits found" << endl;
113  if (fVerbose) cout << "Finished writing Hits" << endl;
114  if (fVerbose)
115  cout << "//----------------------------------------//" << endl << endl;
116  LOG(info) << "+ " << setw(20) << GetName()
117  << ": Created: " << fHits->GetEntriesFast() << " hits in "
118  << fixed << setprecision(6) << fTimer.RealTime() << " s";
119  }
120  fTimer.Stop();
121 }
122 // -----------------------------------------------------------------------------
123 
124 // ----- Init --------------------------------------------------------------
125 InitStatus CbmMvdHitfinder::Init() {
126 
127  using namespace std;
128 
129  cout << "-I- " << GetName() << ": Initialisation..." << endl;
130  cout << endl;
131  cout << "---------------------------------------------" << endl;
132  cout << "-I- Initialising " << GetName() << " ...." << endl;
133 
134  // ********** RootManager
135  FairRootManager* ioman = FairRootManager::Instance();
136  if (!ioman) {
137  cout << "-E- " << GetName() << "::Init: No FairRootManager!" << endl;
138  return kFATAL;
139  }
140 
141  // ********** Get input arrays
142  if (!useClusterfinder) {
144  fDigiMan->Init();
146  LOG(error) << "No MvdDigi branch found. There was no MVD in the "
147  "simulation. Switch this task off";
148  return kERROR;
149  }
150  } else {
151  fInputCluster = (TClonesArray*) ioman->GetObject("MvdCluster");
152  if (!fInputCluster) {
153  LOG(error) << "No MvdCluster branch found. There was no MVD in the "
154  "simulation. Switch this task off";
155  return kERROR;
156  }
157  }
158 
159 
160  // ********** Register output array
161  fHits = new TClonesArray("CbmMvdHit", 10000);
162  ioman->Register(
163  "MvdHit", "Mvd Hits", fHits, IsOutputBranchPersistent("MvdHit"));
164 
166 
167  // if(!useClusterfinder)
168  // {
169  // CbmMvdSensorFindHitTask* HitfinderTask = new CbmMvdSensorFindHitTask();
170  // fDetector->AddPlugin(HitfinderTask);
171  // }
172  // else
173  // {
175  fDetector->AddPlugin(HitfinderTask);
176  cout << endl << "running with external clusterfinder" << endl;
177  // }
178 
181  fDetector->Init();
182 
183 
184  // Screen output
185  cout << GetName() << " initialised with parameters: " << endl;
186  //PrintParameters();
187  cout << "---------------------------------------------" << endl;
188 
189 
190  return kSUCCESS;
191 }
192 
193 // ----- Virtual public method Reinit ----------------------------------
194 InitStatus CbmMvdHitfinder::ReInit() { return kSUCCESS; }
195 // -------------------------------------------------------------------------
196 
197 
198 // ----- Virtual method Finish -----------------------------------------
200 // -------------------------------------------------------------------------
201 
202 
203 // ----- Private method Reset ------------------------------------------
204 void CbmMvdHitfinder::Reset() { fHits->Delete(); }
205 // -------------------------------------------------------------------------
206 
207 // ----- Private method GetMvdGeometry ---------------------------------
209 // -------------------------------------------------------------------------
210 
211 
212 // ----- Private method PrintParameters --------------------------------
214 
215  using namespace std;
216 
217  cout.setf(ios_base::fixed, ios_base::floatfield);
218  cout << "============================================================"
219  << endl;
220  cout << "============== Parameters MvdHitfinder ====================="
221  << endl;
222  cout << "============================================================"
223  << endl;
224  cout << "=============== End Task ==================================="
225  << endl;
226 }
227 // -------------------------------------------------------------------------
228 
CbmMvdDetector::Instance
static CbmMvdDetector * Instance()
Definition: CbmMvdDetector.cxx:47
CbmMvdDetector::Exec
void Exec(UInt_t nLevel)
Definition: CbmMvdDetector.cxx:527
CbmMvdHitfinder::Exec
void Exec(Option_t *opt)
Definition: CbmMvdHitfinder.cxx:90
CbmMvdDetector::GetPluginArraySize
UInt_t GetPluginArraySize()
Definition: CbmMvdDetector.h:71
CbmMvdSensorHitfinderTask.h
CbmMvdHitfinder::ReInit
virtual InitStatus ReInit()
Definition: CbmMvdHitfinder.cxx:194
CbmMvdHitfinder
Definition: CbmMvdHitfinder.h:17
CbmMvdHitfinder.h
CbmMvdSensorFindHitTask.h
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmMvdDetector::Init
void Init()
Definition: CbmMvdDetector.cxx:278
CbmMvdHitfinder::useClusterfinder
Bool_t useClusterfinder
Definition: CbmMvdHitfinder.h:49
CbmMvdHitfinder::fTimer
TStopwatch fTimer
ROOT timer.
Definition: CbmMvdHitfinder.h:51
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmMvdHitfinder::CbmMvdHitfinder
CbmMvdHitfinder()
Definition: CbmMvdHitfinder.cxx:36
CbmMvdGeoHandler.h
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmMvdDetector::ShowDebugHistos
void ShowDebugHistos()
Definition: CbmMvdDetector.cxx:313
CbmMvdHitfinder::fHitfinderPluginNr
UInt_t fHitfinderPluginNr
Definition: CbmMvdHitfinder.h:48
CbmMvdPoint.h
CbmMvdHitfinder::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMvdHitfinder.h:43
CbmMvdDetector::GetOutputHits
TClonesArray * GetOutputHits()
Definition: CbmMvdDetector.cxx:595
ClassImp
ClassImp(CbmMvdHitfinder)
CbmMvdSensorHitfinderTask
Definition: CbmMvdSensorHitfinderTask.h:40
CbmMvdDetector::SendInputDigis
void SendInputDigis(CbmDigiManager *digiMan)
Definition: CbmMvdDetector.cxx:373
fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofAnaTestbeam.cxx:88
CbmMvdHitfinder::fInputCluster
TClonesArray * fInputCluster
Definition: CbmMvdHitfinder.h:45
CbmMvdHitfinder::fHits
TClonesArray * fHits
Definition: CbmMvdHitfinder.h:46
CbmMvdHitfinder::fShowDebugHistos
Bool_t fShowDebugHistos
Definition: CbmMvdHitfinder.h:50
CbmMvdHitfinder::fDetector
CbmMvdDetector * fDetector
Definition: CbmMvdHitfinder.h:42
CbmDigiManager.h
CbmMvdHitfinder::Reset
void Reset()
Definition: CbmMvdHitfinder.cxx:204
CbmMvdHitfinder::Finish
virtual void Finish()
Definition: CbmMvdHitfinder.cxx:199
CbmMvdHitfinder::GetMvdGeometry
void GetMvdGeometry()
Definition: CbmMvdHitfinder.cxx:208
CbmMvdMimosa26AHR.h
CbmMvdHitfinder::PrintParameters
void PrintParameters()
Definition: CbmMvdHitfinder.cxx:213
CbmMvdDetector::AddPlugin
void AddPlugin(CbmMvdSensorPlugin *plugin)
Definition: CbmMvdDetector.cxx:186
CbmMvdDetector::SendInputCluster
void SendInputCluster(TClonesArray *cluster)
Definition: CbmMvdDetector.cxx:469
CbmMvdHitfinder::Init
virtual InitStatus Init()
Definition: CbmMvdHitfinder.cxx:125
CbmMvdHitfinder::~CbmMvdHitfinder
virtual ~CbmMvdHitfinder()
Definition: CbmMvdHitfinder.cxx:80