CbmRoot
Loading...
Searching...
No Matches
CbmMvdHitfinderTB.cxx
Go to the documentation of this file.
1/* Copyright (C) 2017-2019 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdHitfinderTB source file -----
7// -------------------------------------------------------------------------
8
9// Includes from MVD
10#include "CbmMvdHitfinderTB.h"
11
12#include "CbmMvdGeoHandler.h"
13#include "CbmMvdPoint.h"
16
17
18// Includes from FAIR
19#include "FairModule.h"
20#include "FairRootManager.h"
21
22// Includes from ROOT
23#include "TClonesArray.h"
24
25
26// Includes from C++
27#include <iomanip>
28#include <iostream>
29
30using std::endl;
31using std::fixed;
32using std::ios_base;
33using std::setprecision;
34using std::setw;
35
36// ----- Default constructor ------------------------------------------
38 : FairTask("MVDHitfinder")
39 , fDetector(nullptr)
40 , fInputDigis(nullptr)
41 , fInputCluster(nullptr)
42 , fHits(nullptr)
43 , fHitfinderPluginNr(0)
44 , useClusterfinder(kFALSE)
45 , fShowDebugHistos(kFALSE)
46 , fTimer()
47 , fmode(-1)
48{
49}
50// -------------------------------------------------------------------------
51
52// ----- Standard constructor ------------------------------------------
53CbmMvdHitfinderTB::CbmMvdHitfinderTB(const char* name, Int_t iVerbose)
54 : FairTask(name, iVerbose)
55 , fDetector(nullptr)
56 , fInputDigis(nullptr)
57 , fInputCluster(nullptr)
58 , fHits(nullptr)
59 , fHitfinderPluginNr(0)
60 , useClusterfinder(kFALSE)
61 , fShowDebugHistos(kFALSE)
62 , fTimer()
63 , fmode(-1)
64{
65}
66// -------------------------------------------------------------------------
67
68// ----- Standard constructor ------------------------------------------
69CbmMvdHitfinderTB::CbmMvdHitfinderTB(const char* name, Int_t mode, Int_t iVerbose)
70 : FairTask(name, iVerbose)
71 , fDetector(nullptr)
72 , fInputDigis(nullptr)
73 , fInputCluster(nullptr)
74 , fHits(nullptr)
75 , fHitfinderPluginNr(0)
76 , useClusterfinder(kFALSE)
77 , fShowDebugHistos(kFALSE)
78 , fTimer()
79 , fmode(mode)
80{
81 // fmode = mode;
82}
83// -------------------------------------------------------------------------
84
85// ----- Destructor ----------------------------------------------------
87{
88
89 if (fHits) {
90 fHits->Delete();
91 delete fHits;
92 }
93}
94// -----------------------------------------------------------------------------
95
96// ----- Exec --------------------------------------------------------------
97void CbmMvdHitfinderTB::Exec(Option_t* /*opt*/)
98{
99
100 using namespace std;
101
102 fHits->Clear();
103 fTimer.Start();
104
105 LOG(debug) << endl << "//----------------------------------------//";
106 fDetector->SendInputCluster(fInputCluster);
107 LOG(debug) << "Execute HitfinderPlugin Nr. " << fHitfinderPluginNr;
109 LOG(debug) << "End Chain";
110 LOG(debug) << "Start writing Hits";
111 fHits->AbsorbObjects(fDetector->GetOutputHits(), 0, fDetector->GetOutputHits()->GetEntriesFast() - 1);
112 LOG(debug) << "Total of " << fHits->GetEntriesFast() << " hits found";
113 LOG(debug) << "Finished writing Hits";
114 LOG(debug) << "//----------------------------------------//";
115 LOG(info) << "+ " << setw(20) << GetName() << ": Created: " << fHits->GetEntriesFast() << " hits in " << fixed
116 << setprecision(6) << fTimer.RealTime() << " s";
117 fTimer.Stop();
118}
119// -----------------------------------------------------------------------------
120
121// ----- Init --------------------------------------------------------------
123{
124
125 using namespace std;
126
127 LOG(info) << GetName() << ": Initialisation...";
128
129 // ********** RootManager
130 FairRootManager* ioman = FairRootManager::Instance();
131 if (!ioman) {
132 LOG(error) << GetName() << "::Init: No FairRootManager!";
133 return kFATAL;
134 }
135
136 // ********** Get input arrays
137
138 fInputCluster = (TClonesArray*) ioman->GetObject("MvdCluster");
139 if (!fInputCluster) {
140 LOG(error) << "No MvdCluster branch found. There was no MVD in the "
141 "simulation. Switch this task off";
142 return kERROR;
143 }
144
145 // ********** Register output array
146 fHits = new TClonesArray("CbmMvdHit", 10000);
147 ioman->Register("MvdHit", "Mvd Hits", fHits, IsOutputBranchPersistent("MvdHit"));
148
150
151
152 // Add the hit finder plugin to all sensors
153 std::map<int, CbmMvdSensor*>& sensorMap = fDetector->GetSensorMap();
154 UInt_t plugincount = fDetector->GetPluginCount();
155
156 for (auto itr = sensorMap.begin(); itr != sensorMap.end(); itr++) {
158
159 itr->second->AddPlugin(hitfinderTask);
160 itr->second->SetHitPlugin(plugincount);
161 }
163 fDetector->SetPluginCount(plugincount + 1);
165
167 fDetector->Init();
168
169 // Screen output
170 LOG(info) << GetName() << " initialised with parameters: ";
171 //PrintParameters();
172
173
174 return kSUCCESS;
175}
176
177// ----- Virtual public method Reinit ----------------------------------
178InitStatus CbmMvdHitfinderTB::ReInit() { return kSUCCESS; }
179// -------------------------------------------------------------------------
180
181
182// ----- Virtual method Finish -----------------------------------------
184// -------------------------------------------------------------------------
185
186
187// ----- Private method Reset ------------------------------------------
188void CbmMvdHitfinderTB::Reset() { fHits->Delete(); }
189// -------------------------------------------------------------------------
190
191// ----- Private method GetMvdGeometry ---------------------------------
193// -------------------------------------------------------------------------
194
196
197// ----- Private method PrintParameters --------------------------------
199{
200
201 std::stringstream ss;
202 ss.setf(std::ios_base::fixed, std::ios_base::floatfield);
203 ss << "============================================================" << endl;
204 ss << "============== Parameters MvdHitfinder =====================" << endl;
205 ss << "============================================================" << endl;
206 ss << "=============== End Task ===================================" << endl;
207 return ss.str();
208}
209// -------------------------------------------------------------------------
210
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
ClassImp(CbmMvdHitfinderTB)
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)
void Exec(UInt_t nLevel)
TStopwatch fTimer
ROOT timer.
CbmMvdDetector * fDetector
TClonesArray * fHits
std::string ParametersToString() const
TClonesArray * fInputCluster
virtual InitStatus Init()
void Exec(Option_t *opt)
virtual InitStatus ReInit()
Hash for CbmL1LinkKey.