CbmRoot
Loading...
Searching...
No Matches
CbmMvdClusterfinderTB.cxx
Go to the documentation of this file.
1@ /* Copyright (C) 2017-2020 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdClusterfinderTB source file -----
7// -------------------------------------------------------------------------
8
9// Includes from MVD
11
12#include "CbmDigiManager.h"
13#include "CbmEvent.h"
14#include "CbmMvdDetector.h"
15#include "CbmMvdGeoHandler.h"
16#include "CbmMvdPoint.h"
18
19// Includes from FAIR
20#include "FairModule.h"
21#include "FairRootManager.h"
22
23
24// Includes from ROOT
25#include "TClonesArray.h"
26#include "TGeoManager.h"
27#include "TMath.h"
28#include "TString.h"
29
30
31// Includes from C++
32#include <iomanip>
33#include <iostream>
34
35 using std::endl;
36using std::fixed;
37using std::setprecision;
38using std::setw;
39
40// ----- Default constructor ------------------------------------------
42// -------------------------------------------------------------------------
43
44// ----- Standard constructor ------------------------------------------
45CbmMvdClusterfinderTB::CbmMvdClusterfinderTB(const char* name, Int_t iMode, Int_t iVerbose)
46 : FairTask(name, iVerbose)
47 , fMode(iMode)
48 , fShowDebugHistos(kFALSE)
49 , fDetector(nullptr)
50 , fEvents(nullptr)
51 , fDigiMan(nullptr)
52 , fEventDigis(nullptr)
53 , fCluster(nullptr)
54 , fClusterPluginNr(0)
55 , fBranchName("MvdDigi")
56 , fTimer()
57{
58}
59// -------------------------------------------------------------------------
60
61// ----- Destructor ----------------------------------------------------
63{
64
65 if (fCluster) {
66 fCluster->Delete();
67 delete fCluster;
68 }
69}
70// -----------------------------------------------------------------------------
71
72// ----- Exec --------------------------------------------------------------
73void CbmMvdClusterfinderTB::Exec(Option_t* /*opt*/)
74{
75 // --- Start timer
76 fTimer.Start();
77
78 fCluster->Delete();
79
80 Int_t nEvents = fEvents->GetEntriesFast();
81 for (Int_t iEv = 0; iEv < nEvents; ++iEv) {
82 LOG(debug) << "Getting data from CbmEvent";
83 CbmEvent* event = dynamic_cast<CbmEvent*>(fEvents->At(iEv));
84 Int_t nrOfDigis = event->GetNofData(ECbmDataType::kMvdDigi);
85 fEventDigis->Delete();
86 for (Int_t nDigi = 0; nDigi < nrOfDigis; ++nDigi) {
87 Int_t iDigi = event->GetIndex(ECbmDataType::kMvdDigi, nDigi);
88 CbmMvdDigi* digi = new CbmMvdDigi(*(fDigiMan->Get<CbmMvdDigi>(iDigi)));
89 fEventDigis->AddLast(digi);
90 }
91 LOG(debug) << "//----------------------------------------//";
92 LOG(debug) << endl << "Send Input";
93 fDetector->SendInputDigis(fEventDigis);
94 LOG(debug) << "Execute ClusterPlugin Nr. " << fClusterPluginNr;
96 LOG(debug) << "End Chain";
97 LOG(debug) << "Start writing Cluster";
98 fCluster->AbsorbObjects(fDetector->GetOutputCluster(), 0, fDetector->GetOutputCluster()->GetEntriesFast() - 1);
99 LOG(debug) << "Total of " << fCluster->GetEntriesFast() << " Cluster in this Event";
100 LOG(debug) << "//----------------------------------------//";
101 LOG(info) << "+ " << setw(20) << GetName() << ": Created: " << fCluster->GetEntriesFast() << " cluster in " << fixed
102 << setprecision(6) << fTimer.RealTime() << " s";
103 }
104 fTimer.Stop();
105}
106// -----------------------------------------------------------------------------
107
108// ----- Init --------------------------------------------------------------
110{
111 LOG(info) << GetName() << ": Initialisation...";
112
113 // ********** RootManager
114 FairRootManager* ioman = FairRootManager::Instance();
115 if (!ioman) {
116 LOG(error) << GetName() << "::Init: No FairRootManager!";
117 return kFATAL;
118 }
119
120 // ********** Get input arrays
121 fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
122
124 fDigiMan->Init();
125
126 fEventDigis = new TClonesArray("CbmMvdDigi", 10000);
128 LOG(error) << "No MvdDigi branch found. There was no MVD in the "
129 "simulation. Switch this task off";
130 return kERROR;
131 }
132
133 // ********** Register output array
134 fCluster = new TClonesArray("CbmMvdCluster", 10000);
135 ioman->Register("MvdCluster", "Mvd Clusters", fCluster, IsOutputBranchPersistent("MvdCluster"));
136
138
139 if (fDetector->GetSensorArraySize() > 1) {
140 LOG(debug) << "-I- succesfully loaded Geometry from file -I-";
141 }
142 else {
143 LOG(fatal) << "Geometry couldn't be loaded from file. No MVD digitizer available.";
144 }
145
146 // Add the cluster finder plugin to all sensors
147 std::map<int, CbmMvdSensor*>& sensorMap = fDetector->GetSensorMap();
148 UInt_t plugincount = fDetector->GetPluginCount();
149
150 for (auto itr = sensorMap.begin(); itr != sensorMap.end(); itr++) {
152
153 itr->second->AddPlugin(clusterTask);
154 itr->second->SetClusterPlugin(plugincount);
155 }
157 fDetector->SetPluginCount(plugincount + 1);
159
161 fDetector->Init();
162
163 // Screen output
164 LOG(info) << GetName() << " initialised";
165
166 return kSUCCESS;
167}
168
169// ----- Virtual public method Reinit ----------------------------------
170InitStatus CbmMvdClusterfinderTB::ReInit() { return kSUCCESS; }
171// -------------------------------------------------------------------------
172
173
174// ----- Virtual method Finish -----------------------------------------
180// -------------------------------------------------------------------------
181
182
183// ----- Private method Reset ------------------------------------------
185// -------------------------------------------------------------------------
186
187// ----- Private method GetMvdGeometry ---------------------------------
189// -------------------------------------------------------------------------
190
191// ----- Private method PrintParameters --------------------------------
193
194// ----- Private method ParametersToString -----------------------------
196{
197 std::stringstream ss;
198 ss << "============================================================" << endl;
199 ss << "============== Parameters Clusterfinder ====================" << endl;
200 ss << "============================================================" << endl;
201 ss << "=============== End Task ===================================" << endl;
202 return ss.str();
203}
204// -------------------------------------------------------------------------
205
206
@ kMvd
Micro-Vertex Detector.
ClassImp(CbmMvdClusterfinderTB)
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
CbmDigiManager * fDigiMan
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:53
TStopwatch fTimer
ROOT timer.
std::string ParametersToString() const
std::map< int, CbmMvdSensor * > & GetSensorMap()
Int_t GetPluginArraySize()
static CbmMvdDetector * Instance()
void SetSensorArrayFilled(Bool_t value=kTRUE)
UInt_t GetPluginCount()
void SetPluginCount(UInt_t count)
Int_t GetSensorArraySize()
void Exec(UInt_t nLevel)