CbmRoot
CbmMvdClusterfinder.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdClusterfinder source file -----
3 // -------------------------------------------------------------------------
4 
5 // Includes from MVD
6 #include "CbmMvdClusterfinder.h"
7 #include "CbmMvdDetector.h"
8 #include "CbmMvdPoint.h"
11 #include "tools/CbmMvdGeoHandler.h"
12 
13 #include "CbmDigiManager.h"
14 
15 // Includes from FAIR
16 #include "FairModule.h"
17 #include "FairRootManager.h"
18 
19 
20 // Includes from ROOT
21 #include "TClonesArray.h"
22 #include "TGeoManager.h"
23 
24 #include "TMath.h"
25 #include "TString.h"
26 
27 
28 // Includes from C++
29 #include <iomanip>
30 #include <iostream>
31 
32 using std::cout;
33 using std::endl;
34 using std::fixed;
35 using std::setprecision;
36 using std::setw;
37 
38 // ----- Default constructor ------------------------------------------
40  : FairTask("MVDClusterfinder")
41  , fMode(0)
42  , fShowDebugHistos(kFALSE)
43  , fDetector(NULL)
44  , fDigiMan(nullptr)
45  , fCluster(NULL)
46  , fClusterPluginNr()
47  , fBranchName("")
48  , fTimer() {}
49 // -------------------------------------------------------------------------
50 
51 // ----- Standard constructor ------------------------------------------
53  Int_t iMode,
54  Int_t iVerbose)
55  : FairTask(name, iVerbose)
56  , fMode(iMode)
57  , fShowDebugHistos(kFALSE)
58  , fDetector(NULL)
59  , fDigiMan(nullptr)
60  , fCluster(NULL)
61  , fClusterPluginNr(0)
62  , fBranchName("MvdDigi")
63  , fTimer() {}
64 // -------------------------------------------------------------------------
65 
66 // ----- Destructor ----------------------------------------------------
68 
69  if (fCluster) {
70  fCluster->Delete();
71  delete fCluster;
72  }
73 }
74 // -----------------------------------------------------------------------------
75 
76 // ----- Exec --------------------------------------------------------------
77 void CbmMvdClusterfinder::Exec(Option_t* /*opt*/) {
78  // --- Start timer
79  fTimer.Start();
80 
81  fCluster->Delete();
83  if (fVerbose) cout << "//----------------------------------------//";
84  if (fVerbose) cout << endl << "Send Input" << endl;
86  if (fVerbose)
87  cout << "Execute ClusterPlugin Nr. " << fClusterPluginNr << endl;
89  if (fVerbose) cout << "End Chain" << endl;
90  if (fVerbose) cout << "Start writing Cluster" << endl;
91  fCluster->AbsorbObjects(fDetector->GetOutputCluster(),
92  0,
93  fDetector->GetOutputCluster()->GetEntriesFast()
94  - 1);
95  if (fVerbose)
96  cout << "Total of " << fCluster->GetEntriesFast()
97  << " Cluster in this Event" << endl;
98  if (fVerbose)
99  cout << "//----------------------------------------//" << endl;
100  LOG(info) << "+ " << setw(20) << GetName()
101  << ": Created: " << fCluster->GetEntriesFast() << " cluster in "
102  << fixed << setprecision(6) << fTimer.RealTime() << " s";
103  }
104 
105  fTimer.Stop();
106 }
107 // -----------------------------------------------------------------------------
108 
109 // ----- Init --------------------------------------------------------------
111  cout << "-I- " << GetName() << ": Initialisation..." << endl;
112  cout << endl;
113  cout << "---------------------------------------------" << endl;
114  cout << "-I- Initialising " << GetName() << " ...." << endl;
115 
116  // ********** RootManager
117  FairRootManager* ioman = FairRootManager::Instance();
118  if (!ioman) {
119  cout << "-E- " << GetName() << "::Init: No FairRootManager!" << endl;
120  return kFATAL;
121  }
122 
123  // ********** Get input array
125  fDigiMan->Init();
127  LOG(error) << "No MvdDigi branch found. There was no MVD in the "
128  "simulation. Switch this task off";
129  return kERROR;
130  }
131 
132  // ********** Register output array
133  fCluster = new TClonesArray("CbmMvdCluster", 10000);
134  ioman->Register("MvdCluster",
135  "Mvd Clusters",
136  fCluster,
137  IsOutputBranchPersistent("MvdCluster"));
138 
140 
141  if (fDetector->GetSensorArraySize() > 1) {
142  if (fVerbose)
143  cout << endl << "-I- succesfully loaded Geometry from file -I-" << endl;
144  } else {
145  LOG(fatal)
146  << "Geometry couldn't be loaded from file. No MVD digitizer available.";
147  }
148 
149  CbmMvdSensorClusterfinderTask* clusterTask =
151 
152  fDetector->AddPlugin(clusterTask);
155  fDetector->Init();
156 
157 
158  // Screen output
159  cout << GetName() << " initialised with parameters: " << endl;
160  //PrintParameters();
161  cout << "---------------------------------------------" << endl;
162 
163 
164  return kSUCCESS;
165 }
166 
167 // ----- Virtual public method Reinit ----------------------------------
168 InitStatus CbmMvdClusterfinder::ReInit() { return kSUCCESS; }
169 // -------------------------------------------------------------------------
170 
171 
172 // ----- Virtual method Finish -----------------------------------------
174  fDetector->Finish();
175  PrintParameters();
176 }
177 // -------------------------------------------------------------------------
178 
179 
180 // ----- Private method Reset ------------------------------------------
182 // -------------------------------------------------------------------------
183 
184 // ----- Private method GetMvdGeometry ---------------------------------
186 // -------------------------------------------------------------------------
187 
188 
189 // ----- Private method PrintParameters --------------------------------
191 
192  cout << "============================================================"
193  << endl;
194  cout << "============== Parameters Clusterfinder ===================="
195  << endl;
196  cout << "============================================================"
197  << endl;
198  cout << "=============== End Task ==================================="
199  << endl;
200 }
201 // -------------------------------------------------------------------------
202 
203 
CbmMvdDetector::Instance
static CbmMvdDetector * Instance()
Definition: CbmMvdDetector.cxx:47
CbmMvdClusterfinder::Reset
void Reset()
Definition: CbmMvdClusterfinder.cxx:181
CbmMvdDetector.h
CbmMvdDetector::Exec
void Exec(UInt_t nLevel)
Definition: CbmMvdDetector.cxx:527
CbmMvdDetector::GetPluginArraySize
UInt_t GetPluginArraySize()
Definition: CbmMvdDetector.h:71
CbmMvdDetector::GetOutputCluster
TClonesArray * GetOutputCluster()
Definition: CbmMvdDetector.cxx:660
CbmMvdClusterfinder.h
CbmMvdSensorClusterfinderTask.h
CbmMvdClusterfinder::Exec
void Exec(Option_t *opt)
Definition: CbmMvdClusterfinder.cxx:77
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmMvdDetector::Init
void Init()
Definition: CbmMvdDetector.cxx:278
CbmMvdDetector::Finish
void Finish()
Definition: CbmMvdDetector.cxx:705
CbmMvdClusterfinder::~CbmMvdClusterfinder
~CbmMvdClusterfinder()
Definition: CbmMvdClusterfinder.cxx:67
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
CbmMvdClusterfinder
Definition: CbmMvdClusterfinder.h:21
CbmMvdSensorClusterfinderTask
Definition: CbmMvdSensorClusterfinderTask.h:38
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmMvdClusterfinder::GetMvdGeometry
void GetMvdGeometry()
Definition: CbmMvdClusterfinder.cxx:185
CbmMvdClusterfinder::fCluster
TClonesArray * fCluster
Definition: CbmMvdClusterfinder.h:49
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmMvdClusterfinder::PrintParameters
void PrintParameters()
Definition: CbmMvdClusterfinder.cxx:190
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
CbmMvdPoint.h
CbmMvdClusterfinder::Finish
virtual void Finish()
Definition: CbmMvdClusterfinder.cxx:173
CbmMvdClusterfinder::fDetector
CbmMvdDetector * fDetector
Definition: CbmMvdClusterfinder.h:46
CbmMvdDetector::SendInputDigis
void SendInputDigis(CbmDigiManager *digiMan)
Definition: CbmMvdDetector.cxx:373
CbmMvdClusterfinder::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMvdClusterfinder.h:47
fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofAnaTestbeam.cxx:88
ClassImp
ClassImp(CbmMvdClusterfinder)
CbmMvdClusterfinder::Init
virtual InitStatus Init()
Definition: CbmMvdClusterfinder.cxx:110
CbmMvdClusterfinder::fTimer
TStopwatch fTimer
ROOT timer.
Definition: CbmMvdClusterfinder.h:56
CbmMvdDetector::GetSensorArraySize
Int_t GetSensorArraySize()
Definition: CbmMvdDetector.h:70
CbmDigiManager.h
CbmMvdClusterfinder::ReInit
virtual InitStatus ReInit()
Definition: CbmMvdClusterfinder.cxx:168
CbmMvdClusterfinder::fShowDebugHistos
Bool_t fShowDebugHistos
Definition: CbmMvdClusterfinder.h:45
CbmMvdMimosa26AHR.h
CbmMvdDetector::AddPlugin
void AddPlugin(CbmMvdSensorPlugin *plugin)
Definition: CbmMvdDetector.cxx:186
CbmMvdClusterfinder::CbmMvdClusterfinder
CbmMvdClusterfinder()
Definition: CbmMvdClusterfinder.cxx:39
CbmMvdClusterfinder::fClusterPluginNr
UInt_t fClusterPluginNr
Definition: CbmMvdClusterfinder.h:51