58 std::cout << std::endl << std::endl;
59 LOG(info) <<
"======= " << GetName() <<
": Init =====================";
65 FairRootManager* ioman = FairRootManager::Instance();
67 LOG(fatal) <<
"-W- CbmFsdHitProducer::Init: RootManager not instantised!";
72 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"Event"));
74 LOG(info) << GetName() <<
": found Event branch, run event-by-event";
76 fEvents =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
77 if (
fEvents) LOG(info) << GetName() <<
": found CbmEvent branch, run event-by-event";
80 LOG(info) << GetName() <<
": no event branch found; run in time-based mode";
81 LOG(warn) <<
"*** Note that the current FSD hit producer is not suited for time-based reconstruction!";
82 LOG(warn) <<
"*** Unless you have run the simulation event-by-event, it will not produce sensible results.";
89 LOG(error) << GetName() <<
": No FsdDigi input array present; "
90 <<
"task will be inactive.";
93 LOG(info) << GetName() <<
": found FsdDigi branch";
96 fHitArray =
new TClonesArray(
"CbmFsdHit", 1000);
97 ioman->Register(
"FsdHit",
"FSD",
fHitArray, IsOutputBranchPersistent(
"FsdHit"));
99 LOG(info) << GetName() <<
": registered branch FsdHit";
100 LOG(info) << GetName() <<
": intialisation successfull";
101 LOG(info) <<
"======================================================\n";
120 pair<Int_t, Int_t> result;
130 nDigis = result.first;
131 nHits = result.second;
137 nEvents =
fEvents->GetEntriesFast();
138 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
141 LOG(debug) << GetName() <<
": Event " << iEvent <<
" / " << nEvents <<
", digis " << result.first <<
", hits "
143 nDigis += result.first;
144 nHits += result.second;
151 logOut << setw(20) << left << GetName() <<
" [";
152 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
153 logOut <<
"TS " <<
fNofTs;
154 if (
fEvents) logOut <<
", events " << nEvents;
155 logOut <<
", digis " << nDigis <<
" / " << nDigisAll;
156 logOut <<
", hits " << nHits;
157 LOG(info) << logOut.str();
171 std::cout << std::endl;
172 LOG(info) <<
"=====================================";
173 LOG(info) << GetName() <<
": Run summary";
174 LOG(info) <<
"Time slices : " <<
fNofTs;
175 LOG(info) <<
"Digis / TS : " << fixed << setprecision(2) << Double_t(
fNofDigis) / Double_t(
fNofTs);
176 LOG(info) <<
"Hits / TS : " << fixed << setprecision(2) << Double_t(
fNofHits) / Double_t(
fNofTs);
177 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << 1000. *
fTimeTot / Double_t(
fNofTs) <<
" ms";
180 LOG(info) <<
"Events / TS : " << fixed << setprecision(2) << Double_t(
fNofEvents) / Double_t(
fNofTs);
181 LOG(info) <<
"Digis / event : " << fixed << setprecision(2) << Double_t(
fNofDigis) / Double_t(
fNofEvents);
182 LOG(info) <<
"Hits / event : " << fixed << setprecision(2) << Double_t(
fNofHits) / Double_t(
fNofEvents);
184 LOG(info) <<
"=====================================\n";
194 std::map<uint32_t, std::tuple<Double_t, Double_t, Int_t>>
201 Int_t digiIndex = -1;
202 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
209 Double_t eDep = (Double_t) digi->
GetEdep();
210 Double_t digiTime = (Double_t) digi->
GetTime();
211 auto insert_result = edeptimemap.insert(std::make_pair(address, std::make_tuple(eDep, digiTime, digiIndex)));
212 if (!insert_result.second) {
213 std::get<0>((*insert_result.first).second) = eDep + std::get<0>((*insert_result.first).second);
214 if (digiTime < std::get<1>((*insert_result.first).second)) {
215 std::get<1>((*insert_result.first).second) = digiTime;
216 std::get<2>((*insert_result.first).second) = digiIndex;
222 UInt_t hitIndex = -1;
223 for (
auto entry : edeptimemap) {
224 uint32_t address = entry.first;
225 Double_t sumEdep = std::get<0>(entry.second);
226 Double_t fastestDigiTime = std::get<1>(entry.second);
227 Int_t fastestDigiIndex = std::get<2>(entry.second);
231 LOG(warning) <<
"FSD module data for address: " << address <<
" (unitId: "
235 <<
" ) could not be found! => skip";
238 TVector3 moduleCenter;
239 moduleCenter.SetXYZ(fsdModSpecs->
fX, fsdModSpecs->
fY, fsdModSpecs->
fZ);
240 TVector3 moduleDimensions;
241 moduleDimensions.SetXYZ(fsdModSpecs->
dX, fsdModSpecs->
dY, fsdModSpecs->
dZ);
244 new ((*fHitArray)[hitIndex])
CbmFsdHit(
static_cast<int32_t
>(address), moduleCenter, moduleDimensions,
245 static_cast<int32_t
>(fastestDigiIndex), fastestDigiTime, sumEdep);
250 return std::make_pair(nDigis, nHits);