CbmRoot
Loading...
Searching...
No Matches
CbmMvdDigitizerTB.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// ----- CbmMvdDigitizerTB source file -----
7// -------------------------------------------------------------------------
8
9// Includes from MVD
10#include "CbmMvdDigitizerTB.h"
11
12#include "CbmDaqBuffer.h"
13#include "CbmMvdDetector.h"
14#include "CbmMvdGeoHandler.h"
15#include "CbmMvdPoint.h"
17
18#include "FairModule.h"
19#include "FairRootManager.h"
20#include <Logger.h>
21
22// Includes from ROOT
23#include "TClonesArray.h"
24#include "TStopwatch.h"
25
26#include <iomanip>
27#include <iostream>
28#include <vector>
29
30
31using namespace ::std;
32
33// ----- Default constructor ------------------------------------------
35// -------------------------------------------------------------------------
36
37// ----- Standard constructor ------------------------------------------
38CbmMvdDigitizerTB::CbmMvdDigitizerTB(const char* name, Int_t iMode, Int_t iVerbose)
39 : FairTask(name, iVerbose)
40 , fMode(iMode)
41 , eventNumber(0)
42 , fShowDebugHistos(kFALSE)
43 , fNoiseSensors(kFALSE)
44 , fDetector(nullptr)
45 , fInputPoints(nullptr)
46 , fTracks(nullptr)
47 , fDigis(nullptr)
48 , fDigiMatch(nullptr)
49 , fPerformanceDigi()
50 , fDigiPluginNr(0)
51 , fFakeRate(-1.)
52 , epsilon()
53 , fBranchName("MvdPoint")
54 , fTimer()
55{
56}
57// -------------------------------------------------------------------------
58
59// ----- Destructor ----------------------------------------------------
61{
62
63 if (fDigis) {
64 fDigis->Delete();
65 delete fDigis;
66 }
67}
68// -----------------------------------------------------------------------------
69
70// ----- Exec --------------------------------------------------------------
71void CbmMvdDigitizerTB::Exec(Option_t* /*opt*/)
72{
73
74 fTimer.Start();
75
76 fDigis->Clear();
77
78 if (fInputPoints->GetEntriesFast() > 0) {
79
80 LOG(debug) << "Send Input";
81 fDetector->SendInput(fInputPoints);
82 LOG(debug) << "Execute DigitizerPlugin Nr. " << fDigiPluginNr;
84 LOG(debug) << "End Chain";
85 LOG(debug) << "Start writing Digis";
86 fDigis->AbsorbObjects(fDetector->GetOutputDigis());
87 LOG(debug) << "Total of " << fDigis->GetEntriesFast() << " digis in this Event";
88 for (Int_t i = 0; i < fDigis->GetEntriesFast(); ++i) {
89 CbmMvdDigi* digi = static_cast<CbmMvdDigi*>(fDigis->At(i)->Clone());
90 CbmDaqBuffer::Instance()->InsertData(digi);
91 }
92 }
93 // --- Event log
94 LOG(info) << "+ " << setw(20) << GetName() << ": Event " << setw(6) << right << eventNumber << ", real time " << fixed
95 << setprecision(6) << fTimer.RealTime() << " s, digis: " << fDigis->GetEntriesFast();
96 fTimer.Stop();
97
99}
100// -----------------------------------------------------------------------------
101
102// ----- Init --------------------------------------------------------------
104{
105 LOG(info) << GetName() << ": Initialisation...";
106
107 eventNumber = 0;
108
109 // ********** RootManager
110 FairRootManager* ioman = FairRootManager::Instance();
111 if (!ioman) {
112 LOG(error)
113 " << GetName() << " ::Init :
114 No FairRootManager !";
115 return kFATAL;
116 }
117
118 // ********** Get input arrays
119 fInputPoints = (TClonesArray*) ioman->GetObject(fBranchName);
120 fTracks = (TClonesArray*) ioman->GetObject("MCTrack");
121
122 if (!fInputPoints) {
123 LOG(error) << "No MvdPoint branch found. There was no MVD in the "
124 "simulation. Switch this task off";
125 return kERROR;
126 }
127
128
129 // ********** Register output array
130 fDigis = new TClonesArray("CbmMvdDigi", 10000);
131 // ioman->Register("MvdDigi", "Mvd Digis", fDigis, IsOutputBranchPersistent("MvdDigi"));
132
133 fDigiMatch = new TClonesArray("CbmMatch", 100000);
134 //ioman->Register("MvdDigiMatch", "Mvd DigiMatches", fDigiMatch, IsOutputBranchPersistent("MvdDigiMatch"));
135
136 fDetector = CbmMvdDetector::Instance();
137
138 // Add the digitizer plugin to all sensors
139 std::map<int, CbmMvdSensor*>& sensorMap = fDetector->GetSensorMap();
140 UInt_t plugincount = fDetector->GetPluginCount();
141
142 for (auto itr = sensorMap.begin(); itr != sensorMap.end(); itr++) {
143 CbmMvdSensorDigitizerTBTask* digiTask = new CbmMvdSensorDigitizerTBTask();
144
145 itr->second->AddPlugin(digiTask);
146 itr->second->SetDigiPlugin(plugincount);
147 }
148 fDetector->SetSensorArrayFilled(kTRUE);
149 fDetector->SetPluginCount(plugincount + 1);
150 fDigiPluginNr = (UInt_t)(fDetector->GetPluginArraySize());
151
152 fDetector->Init();
153
154 // Screen output
155 LOG(info) << GetName() << " initialised with parameters: ";
156 //PrintParameters();
157
158
159 return kSUCCESS;
160}
161
162// ----- Virtual public method Reinit ----------------------------------
163InitStatus CbmMvdDigitizerTB::ReInit() { return kSUCCESS; }
164// -------------------------------------------------------------------------
165
166
167// ----- Virtual method Finish -----------------------------------------
168void CbmMvdDigitizerTB::Finish()
169{
170 // LOG(debug) << "finishing";
171 fDetector->Finish();
172 PrintParameters();
173}
174// -------------------------------------------------------------------------
175
176
177// ----- Private method Reset ------------------------------------------
178void CbmMvdDigitizerTB::Reset() { fDigis->Delete(); }
179// -------------------------------------------------------------------------
180
181// ----- Private method GetMvdGeometry ---------------------------------
182void CbmMvdDigitizerTB::GetMvdGeometry() {}
183// -------------------------------------------------------------------------
184
185void CbmMvdDigitizerTB::PrintParameters() const { LOG(info) << ParametersToString(); }
186
187// ----- Private method PrintParameters --------------------------------
188void CbmMvdDigitizerTB::ParametersToString() const
189{
190
191 std::stringstream ss;
192 ss.setf(std::ios_base::fixed, std::ios_base::floatfield);
193 ss << "============================================================" << endl;
194 ss << "============== Parameters MvdDigitizer =====================" << endl;
195 ss << "============================================================" << endl;
196 ss << "=============== End Task ===================================" << endl;
197 return ss.str();
198}
199// -------------------------------------------------------------------------
200
201ClassImp(CbmMvdDigitizerTB);
Helper class to extract information from the GeoManager. Addapted from TrdGeoHandler byFlorian Uhlig ...
void Exec(UInt_t nLevel)
CbmMvdDetector * fDetector
TClonesArray * fInputPoints
TClonesArray * fDigis
void Exec(Option_t *opt)
TStopwatch fTimer
ROOT timer.
virtual InitStatus Init()
Hash for CbmL1LinkKey.