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