17 #include "FairEventHeader.h"
18 #include "FairLogger.h"
19 #include "FairRunAna.h"
20 #include "FairRunSim.h"
21 #include "TClonesArray.h"
22 #include "TGeoManager.h"
24 #include "TStopwatch.h"
36 , fRichDigiMatches(nullptr)
42 , fCrossTalkProbability(0.02)
45 , fMaxNofHitsPerPmtCut(65)
48 , fDarkRatePerPixel(1000)
59 std::cout << std::endl;
60 LOG(info) <<
"==========================================================";
61 LOG(info) << GetName() <<
": Initialisation";
65 LOG(info) <<
"CbmRichDigitizer uses TimeBased mode.";
67 LOG(info) <<
"CbmRichDigitizer uses Events mode.";
70 FairRootManager* manager = FairRootManager::Instance();
77 fRichPoints = (TClonesArray*) manager->GetObject(
"RichPoint");
79 Fatal(
"CbmRichDigitizer::Init",
"No RichPoint array!");
82 fMcTracks = (TClonesArray*) manager->GetObject(
"MCTrack");
84 Fatal(
"CbmRichDigitizer::Init",
"No MCTrack array!");
90 LOG(info) << GetName() <<
": Initialisation successful";
102 LOG(debug) << fName <<
": Event " <<
fEventNum;
107 if (data.second.first)
delete data.second.first;
108 if (data.second.second)
delete data.second.second;
133 LOG(info) <<
"+ " << setw(15) << GetName() <<
": Event " << setw(6) << right
136 <<
", digis: " << nDigis <<
". Exec time " << setprecision(6)
137 << timer.RealTime() <<
" s.";
145 <<
" nofRichPoints:" << nofRichPoints;
147 for (Int_t j = 0; j < nofRichPoints; j++) {
155 return nofRichPoints;
159 Double_t newEventTime) {
162 Double_t dT = newEventTime - oldEventTime;
165 LOG(debug) <<
"CbmRichDigitizer::GenerateNoiseBetweenEvents deltaTime:" << dT
166 <<
" nofPixels:" << nofPixels
167 <<
" nofNoisePixels:" << nofNoisePixels;
169 for (Int_t j = 0; j < nofNoisePixels; j++) {
173 Double_t time = gRandom->Uniform(oldEventTime, newEventTime);
185 Double_t zNew = point->GetZ();
187 gGeoManager->FindNode(point->GetX(), point->GetY(), zNew);
188 string path(gGeoManager->GetPath());
192 Int_t trackId = point->GetTrackID();
193 if (trackId < 0)
return;
195 if (p == NULL)
return;
198 CbmLink link(1., pointId, eventNum, inputNum);
200 Bool_t isDetected =
false;
202 if (gcode == 50000050) {
204 point->Momentum(mom);
206 sqrt(mom.Px() * mom.Px() + mom.Py() * mom.Py() + mom.Pz() * mom.Pz());
217 if (isDetected) {
AddDigi(address, time, link); }
222 std::cout << std::endl;
223 LOG(info) <<
"=====================================";
224 LOG(info) << GetName() <<
": Run summary";
225 LOG(info) <<
"Events processed : " <<
fEventNum;
226 LOG(info) <<
"RichPoint / event : " << setprecision(1)
229 LOG(info) <<
"Digis per point : " << setprecision(6)
233 LOG(info) <<
"=====================================";
237 Bool_t crosstalkDigiDetected =
false;
238 vector<Int_t> directPixels =
241 vector<Int_t> diagonalPixels =
245 for (UInt_t
i = 0;
i < directPixels.size();
i++) {
248 crosstalkDigiDetected =
true;
253 if (!crosstalkDigiDetected) {
254 for (UInt_t
i = 0;
i < diagonalPixels.size();
i++) {
256 && !crosstalkDigiDetected) {
258 crosstalkDigiDetected =
true;
264 if (crosstalkDigiDetected) {
275 map<Int_t, Int_t> digisPerPmtMap;
279 dm.second.first->GetAddress());
280 if (
nullptr == pixelData)
continue;
281 Int_t pmtId = pixelData->
fPmtId;
282 digisPerPmtMap[pmtId]++;
285 Int_t nofSkippedPmts = 0;
286 for (
auto const& dm : digisPerPmtMap) {
290 Int_t nofSkippedDigis = 0;
294 dm.second.first->GetAddress());
295 if (
nullptr == pixelData)
continue;
302 digi->
SetAddress(dm.second.first->GetAddress());
304 digi->
SetTime(dm.second.first->GetTime());
313 LOG(debug) <<
"Number of RICH digis before skip: " <<
fDataMap.size();
314 LOG(debug) <<
"Nof skipped PMTs:" << nofSkippedPmts;
315 LOG(debug) <<
"Nof skipped digis:" << nofSkippedDigis;
316 LOG(debug) <<
"Number of RICH digis: " << nofDigis;
324 Double_t nofRichPoints =
fRichPoints->GetEntries();
325 Double_t nofNoiseDigis =
328 LOG(debug) <<
"CbmRichDigitizer::AddNoiseDigis NofAllPixels:" << nofPixels
329 <<
" nofNoiseDigis:" << nofNoiseDigis;
330 for (Int_t j = 0; j < nofNoiseDigis; j++) {
333 CbmLink link(1., -1, eventNum, inputNum);
343 Bool_t isDetected =
true;
346 Double_t dt =
std::fabs(time - lastFiredTime);
372 pair<CbmRichDigi*, CbmMatch*> value(digi, match);
374 pair<Int_t, pair<CbmRichDigi*, CbmMatch*>>(address, value));
376 CbmMatch* match = it->second.second;