CbmRoot
CbmMvdClusterfinderTB.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmMvdClusterfinderTB source file -----
3 // -------------------------------------------------------------------------
4 
5 // Includes from MVD
7 #include "CbmDigiManager.h"
8 #include "CbmEvent.h"
9 #include "CbmMvdDetector.h"
10 #include "CbmMvdPoint.h"
12 #include "tools/CbmMvdGeoHandler.h"
13 
14 // Includes from FAIR
15 #include "FairModule.h"
16 #include "FairRootManager.h"
17 
18 
19 // Includes from ROOT
20 #include "TClonesArray.h"
21 #include "TGeoManager.h"
22 
23 #include "TMath.h"
24 #include "TString.h"
25 
26 
27 // Includes from C++
28 #include <iomanip>
29 #include <iostream>
30 
31 using std::cout;
32 using std::endl;
33 using std::fixed;
34 using std::setprecision;
35 using std::setw;
36 
37 // ----- Default constructor ------------------------------------------
39  : CbmMvdClusterfinderTB("MVDCLusterfinderTB", 0, 0) {}
40 // -------------------------------------------------------------------------
41 
42 // ----- Standard constructor ------------------------------------------
44  Int_t iMode,
45  Int_t iVerbose)
46  : FairTask(name, iVerbose)
47  , fMode(iMode)
48  , fShowDebugHistos(kFALSE)
49  , fDetector(NULL)
50  , fEvents(NULL)
51  , fDigiMan(nullptr)
52  , fEventDigis(NULL)
53  , fCluster(NULL)
54  , fClusterPluginNr(0)
55  , fBranchName("MvdDigi")
56  , fTimer() {}
57 // -------------------------------------------------------------------------
58 
59 // ----- Destructor ----------------------------------------------------
61 
62  if (fCluster) {
63  fCluster->Delete();
64  delete fCluster;
65  }
66 }
67 // -----------------------------------------------------------------------------
68 
69 // ----- Exec --------------------------------------------------------------
70 void CbmMvdClusterfinderTB::Exec(Option_t* /*opt*/) {
71  // --- Start timer
72  fTimer.Start();
73 
74  fCluster->Delete();
75 
76  Int_t nEvents = fEvents->GetEntriesFast();
77  for (Int_t iEv = 0; iEv < nEvents; ++iEv) {
78  LOG(debug) << "Getting data from CbmEvent";
79  CbmEvent* event = dynamic_cast<CbmEvent*>(fEvents->At(iEv));
80  Int_t nrOfDigis = event->GetNofData(ECbmDataType::kMvdDigi);
81  fEventDigis->Delete();
82  for (Int_t nDigi = 0; nDigi < nrOfDigis; ++nDigi) {
83  Int_t iDigi = event->GetIndex(ECbmDataType::kMvdDigi, nDigi);
84  CbmMvdDigi* digi = new CbmMvdDigi(*(fDigiMan->Get<CbmMvdDigi>(iDigi)));
85  fEventDigis->AddLast(digi);
86  }
87  LOG(debug) << "//----------------------------------------//";
88  LOG(debug) << endl << "Send Input";
90  LOG(debug) << "Execute ClusterPlugin Nr. " << fClusterPluginNr;
92  LOG(debug) << "End Chain";
93  LOG(debug) << "Start writing Cluster";
94  fCluster->AbsorbObjects(fDetector->GetOutputCluster(),
95  0,
96  fDetector->GetOutputCluster()->GetEntriesFast()
97  - 1);
98  LOG(debug) << "Total of " << fCluster->GetEntriesFast()
99  << " Cluster in this Event";
100  LOG(debug) << "//----------------------------------------//";
101  LOG(info) << "+ " << setw(20) << GetName()
102  << ": Created: " << fCluster->GetEntriesFast() << " cluster in "
103  << fixed << setprecision(6) << fTimer.RealTime() << " s";
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 arrays
124  fEvents = (TClonesArray*) ioman->GetObject("Event");
125 
127  fDigiMan->Init();
128 
129  fEventDigis = new TClonesArray("CbmMvdDigi", 10000);
131  LOG(error) << "No MvdDigi branch found. There was no MVD in the "
132  "simulation. Switch this task off";
133  return kERROR;
134  }
135 
136  // ********** Register output array
137  fCluster = new TClonesArray("CbmMvdCluster", 10000);
138  ioman->Register("MvdCluster",
139  "Mvd Clusters",
140  fCluster,
141  IsOutputBranchPersistent("MvdCluster"));
142 
144 
145  if (fDetector->GetSensorArraySize() > 1) {
146  LOG(debug) << "-I- succesfully loaded Geometry from file -I-";
147  } else {
148  LOG(fatal)
149  << "Geometry couldn't be loaded from file. No MVD digitizer available.";
150  }
151 
152  CbmMvdSensorClusterfinderTask* clusterTask =
154 
155  fDetector->AddPlugin(clusterTask);
158  fDetector->Init();
159 
160 
161  // Screen output
162  LOG(info) << GetName() << " initialised";
163 
164  return kSUCCESS;
165 }
166 
167 // ----- Virtual public method Reinit ----------------------------------
168 InitStatus CbmMvdClusterfinderTB::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
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
CbmMvdClusterfinderTB::fEvents
TClonesArray * fEvents
Definition: CbmMvdClusterfinderTB.h:48
ECbmDataType::kMvdDigi
@ kMvdDigi
CbmMvdSensorClusterfinderTask.h
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
CbmMvdClusterfinderTB::GetMvdGeometry
void GetMvdGeometry()
Definition: CbmMvdClusterfinderTB.cxx:185
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
CbmMvdSensorClusterfinderTask
Definition: CbmMvdSensorClusterfinderTask.h:38
CbmMvdClusterfinderTB::fEventDigis
TClonesArray * fEventDigis
Definition: CbmMvdClusterfinderTB.h:50
CbmMvdClusterfinderTB::~CbmMvdClusterfinderTB
~CbmMvdClusterfinderTB()
Definition: CbmMvdClusterfinderTB.cxx:60
CbmMvdClusterfinderTB::ReInit
virtual InitStatus ReInit()
Definition: CbmMvdClusterfinderTB.cxx:168
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
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
CbmMvdClusterfinderTB
Definition: CbmMvdClusterfinderTB.h:21
CbmEvent.h
CbmMvdPoint.h
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmMvdClusterfinderTB::CbmMvdClusterfinderTB
CbmMvdClusterfinderTB()
Definition: CbmMvdClusterfinderTB.cxx:38
CbmMvdDetector::SendInputDigis
void SendInputDigis(CbmDigiManager *digiMan)
Definition: CbmMvdDetector.cxx:373
CbmMvdClusterfinderTB::PrintParameters
void PrintParameters()
Definition: CbmMvdClusterfinderTB.cxx:190
CbmMvdClusterfinderTB::Finish
virtual void Finish()
Definition: CbmMvdClusterfinderTB.cxx:173
CbmMvdClusterfinderTB::Exec
void Exec(Option_t *opt)
Definition: CbmMvdClusterfinderTB.cxx:70
fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofAnaTestbeam.cxx:88
CbmEvent::GetNofData
Int_t GetNofData() const
Definition: CbmEvent.h:90
CbmMvdClusterfinderTB::fShowDebugHistos
Bool_t fShowDebugHistos
Definition: CbmMvdClusterfinderTB.h:45
CbmMvdClusterfinderTB::Init
virtual InitStatus Init()
Definition: CbmMvdClusterfinderTB.cxx:110
CbmMvdDetector::GetSensorArraySize
Int_t GetSensorArraySize()
Definition: CbmMvdDetector.h:70
CbmDigiManager.h
CbmMvdClusterfinderTB::fTimer
TStopwatch fTimer
ROOT timer.
Definition: CbmMvdClusterfinderTB.h:59
CbmMvdClusterfinderTB.h
CbmMvdDigi
Definition: CbmMvdDigi.h:21
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
CbmMvdClusterfinderTB::fClusterPluginNr
UInt_t fClusterPluginNr
Definition: CbmMvdClusterfinderTB.h:54
CbmMvdClusterfinderTB::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMvdClusterfinderTB.h:49
CbmMvdDetector::AddPlugin
void AddPlugin(CbmMvdSensorPlugin *plugin)
Definition: CbmMvdDetector.cxx:186
CbmMvdClusterfinderTB::fCluster
TClonesArray * fCluster
Definition: CbmMvdClusterfinderTB.h:51
ClassImp
ClassImp(CbmMvdClusterfinderTB)
CbmMvdClusterfinderTB::fDetector
CbmMvdDetector * fDetector
Definition: CbmMvdClusterfinderTB.h:46
CbmMvdClusterfinderTB::Reset
void Reset()
Definition: CbmMvdClusterfinderTB.cxx:181