3 #include "TClonesArray.h"
8 #include "TMCProcess.h"
26 #include "CbmRichUtil.h"
30 #include "FairMCPoint.h"
31 #include "FairTrackParam.h"
34 #include "FairEventHeader.h"
35 #include "FairLogger.h"
36 #include "FairRunAna.h"
37 #include "FairRunSim.h"
51 : FairTask(
"CbmRichRecoTbQa")
57 , fRichPoints(nullptr)
62 , fRichRingMatches(nullptr)
68 cout <<
"CbmRichRecoTbQa::Init" << endl;
69 FairRootManager* ioman = FairRootManager::Instance();
70 if (
nullptr == ioman) {
71 Fatal(
"CbmRichRecoTbQa::Init",
"RootManager not instantised!");
76 if (mcManager ==
nullptr)
78 <<
"CbmRichRecoTbQa::ReadAndCreateDataBranches() NULL MCDataManager.";
87 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
88 if (
nullptr ==
fRichHits) { Fatal(
"CbmRichRecoTbQa::Init",
"No Rich hits!"); }
90 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
92 Fatal(
"CbmRichRecoTbQa::Init",
"No Rich rings!");
97 Fatal(
"CbmRichRecoTbQa::Init",
"No RichRingMatch!");
102 Fatal(
"CbmRichRecoTbQa::Init",
"No MCEventList!");
113 Int_t nBinsLog = 20000;
114 Double_t minLog = 0.;
115 Double_t maxLog = 10000.;
119 "fhNofRichDigisPerTS;RICH digis per time slice;Yield",
124 "fhNofRichHitsPerTS;RICH hits per time slice;Yield",
129 "fhNofRichRingsPerTS;RICH rings per time slice;Yield",
135 "fhRichDigiTimeLog;RICH digi time [ns];Yield",
141 "fhRichRingTimeLog;RICH ring time [ns];Yield",
147 "fhRichPointTime;RICH MC point time [ns];Yield",
152 "fhRichPointTimeChPhoton;RICH MC point time [ns];Yield",
156 fHM->
Create1<TH1D>(
"fhRichPointTimeNotChPhoton",
157 "fhRichPointTimeNotChPhoton;RICH MC point time [ns];Yield",
162 "fhRichPointTimePrimEl;RICH MC point time [ns];Yield",
167 "fhRichPointTimeSecEl;RICH MC point time [ns];Yield",
172 "fhRichPointTimeOther;RICH MC point time [ns];Yield",
177 "fhRichPointTimePion;RICH MC point time [ns];Yield",
183 "fhStsPointTime;STS MC point time [ns];Yield",
190 string richDigiStr =
"fhRichDigiTimeLog_" + to_string(iEv);
192 richDigiStr, richDigiStr +
";Time [ns];Yield", nBinsLog, minLog, maxLog);
194 string richRingStr =
"fhRichRingTimeLog_" + to_string(iEv);
196 richRingStr, richRingStr +
";Time [ns];Yield", nBinsLog, minLog, maxLog);
198 string richStr =
"fhRichPointTimeLog_" + to_string(iEv);
200 richStr, richStr +
";Time [ns];Yield", nBinsLog, minLog, maxLog);
202 string stsStr =
"fhStsPointTimeLog_" + to_string(iEv);
204 stsStr, stsStr +
";Time [ns];Yield", nBinsLog, minLog, maxLog);
208 "fhTimeBetweenEvents;Time between events [ns];Yield",
215 fHM->
Create1<TH1D>(
"fhMomElAcc",
"fhMomElAcc;P [GeV/c];Yield", 10, 0., 10.);
216 fHM->
Create1<TH1D>(
"fhMomElRec",
"fhMomElRec;P [GeV/c];Yield", 10, 0., 10.);
218 "fhMomRefElAcc",
"fhMomRefElAcc;P [GeV/c];Yield", 10, 0., 10.);
220 "fhMomRefElRec",
"fhMomRefElRec;P [GeV/c];Yield", 10, 0., 10.);
224 "fhNofHitsElAcc",
"fhNofHitsElAcc;Nof hits in ring;Yield", 20, -.5, 39.5);
226 "fhNofHitsElRec",
"fhNofHitsElRec;Nof hits in ring;Yield", 20, -.5, 39.5);
228 "fhNofHitsRefElAcc;Nof hits in ring;Yield",
233 "fhNofHitsRefElRec;Nof hits in ring;Yield",
239 "fhEventMultElAcc",
"fhEventMultElAcc;Nof MC tracks;Yield", 10, 0., 2000);
241 "fhEventMultElRec",
"fhEventMultElRec;Nof MC tracks;Yield", 10, 0, 2000);
249 <<
" nofMcEvents:" << nofMcEvents << endl;
258 Int_t nofRichHits =
fRichHits->GetEntries();
259 Int_t nofRichRings =
fRichRings->GetEntries();
260 fHM->
H1(
"fhNofRichDigisPerTS")->Fill(nofRichDigis);
261 fHM->
H1(
"fhNofRichHitsPerTS")->Fill(nofRichHits);
262 fHM->
H1(
"fhNofRichRingsPerTS")->Fill(nofRichRings);
264 LOG(debug) <<
"nofRichDigis:" << nofRichDigis;
265 for (Int_t iDigi = 0; iDigi < nofRichDigis; iDigi++) {
270 Int_t eventNum = digiMatch->GetMatchedLink().GetEntry();
271 Int_t index = digiMatch->GetMatchedLink().GetIndex();
273 if (eventNum < 0 || index < 0) {
277 string hName =
"fhRichDigiTimeLog_" + to_string(eventNum);
283 for (Int_t iR = 0; iR < nofRichRings; iR++) {
287 if (ring ==
nullptr || ringMatch ==
nullptr)
continue;
294 if (eventNum < 0 || index < 0) {
298 string hName =
"fhRichRingTimeLog_" + to_string(eventNum);
313 fHM->
H1(
"fhTimeBetweenEvents")->Fill(dT);
318 for (Int_t iP = 0; iP < nofRichPoints; iP++) {
320 fHM->
H1(
"fhRichPointTime")->Fill(point->GetTime());
322 fHM->
H1(
"fhRichPointTimeChPhoton")->Fill(point->GetTime());
324 fHM->
H1(
"fhRichPointTimeNotChPhoton")->Fill(point->GetTime());
328 fHM->
H1(
"fhRichPointTimePrimEl")->Fill(point->GetTime());
330 fHM->
H1(
"fhRichPointTimePion")->Fill(point->GetTime());
333 fHM->
H1(
"fhRichPointTimeSecEl")->Fill(point->GetTime());
335 fHM->
H1(
"fhRichPointTimeOther")->Fill(point->GetTime());
339 string richStr =
"fhRichPointTimeLog_" + to_string(iEv);
341 fHM->
H1(richStr)->Fill(eventTime + point->GetTime());
349 for (Int_t j = 0; j < nofStsPoints; j++) {
351 fHM->
H1(
"fhStsPointTime")->Fill(point->GetTime());
353 string stsStr =
"fhStsPointTimeLog_" + to_string(iEv);
355 fHM->
H1(stsStr)->Fill(eventTime + point->GetTime());
365 for (Int_t j = 0; j < nofMcTracks; j++) {
374 map<pair<Int_t, Int_t>, Int_t> nofHitsInRing;
375 Int_t nofRichHits =
fRichHits->GetEntriesFast();
376 for (Int_t iHit = 0; iHit < nofRichHits; iHit++) {
378 if (
nullptr == hit)
continue;
379 vector<pair<Int_t, Int_t>> motherIds =
382 for (UInt_t
i = 0;
i < motherIds.size();
i++) {
383 nofHitsInRing[motherIds[
i]]++;
388 for (Int_t iEv = 0;
fMCTracks->
Size(fileId, iEv) >= 0; iEv++) {
391 for (Int_t j = 0; j < nofMcTracks; j++) {
394 pair<Int_t, Int_t> val = std::make_pair(iEv, j);
395 Int_t nofRichHitsInRing = nofHitsInRing[val];
396 Double_t mom = track->
GetP();
398 fHM->
H1(
"fhMomElAcc")->Fill(mom);
399 fHM->
H1(
"fhNofHitsElAcc")->Fill(nofRichHitsInRing);
400 fHM->
H1(
"fhEventMultElAcc")->Fill(nofPrimMcTracks);
401 if (nofRichHitsInRing >= 15) {
402 fHM->
H1(
"fhMomRefElAcc")->Fill(mom);
403 fHM->
H1(
"fhNofHitsRefElAcc")->Fill(nofRichHitsInRing);
409 Int_t nofRings =
fRichRings->GetEntriesFast();
410 for (Int_t iRing = 0; iRing < nofRings; iRing++) {
419 Int_t nofPrimMcTracks =
421 pair<Int_t, Int_t> val =
424 Int_t nofRichHitsInRing = nofHitsInRing[val];
425 Double_t mom = track->
GetP();
430 fHM->
H1(
"fhMomElRec")->Fill(mom);
431 fHM->
H1(
"fhNofHitsElRec")->Fill(nofRichHitsInRing);
432 fHM->
H1(
"fhEventMultElRec")->Fill(nofPrimMcTracks);
434 if (nofRichHitsInRing >= 15) {
435 fHM->
H1(
"fhMomRefElRec")->Fill(mom);
436 fHM->
H1(
"fhNofHitsRefElRec")->Fill(nofRichHitsInRing);
446 if (point ==
nullptr)
return false;
447 Int_t trackId = point->GetTrackID();
448 if (trackId < 0)
return false;
450 return (p !=
nullptr && TMath::Abs(p->
GetPdgCode()) == 50000050);
457 if (point ==
nullptr)
return false;
458 Int_t trackId = point->GetTrackID();
459 if (trackId < 0)
return false;
461 if (mcTrack ==
nullptr || TMath::Abs(mcTrack->
GetPdgCode()) != 50000050)
465 if (motherId < 0)
return false;
475 if (point ==
nullptr)
return false;
476 Int_t trackId = point->GetTrackID();
477 if (trackId < 0)
return false;
479 if (mcTrack ==
nullptr || TMath::Abs(mcTrack->
GetPdgCode()) != 50000050)
483 if (motherId < 0)
return false;
486 if (mcMotherTrack ==
nullptr)
return false;
487 int pdg = TMath::Abs(mcMotherTrack->
GetPdgCode());
494 if (mctrack ==
nullptr)
return false;
501 if (mctrack ==
nullptr)
return false;
503 if (pdg == 211)
return true;
510 if (point ==
nullptr)
return false;
511 Int_t trackId = point->GetTrackID();
512 if (trackId < 0)
return false;
514 if (mcTrack ==
nullptr || TMath::Abs(mcTrack->
GetPdgCode()) != 50000050)
518 if (motherId < 0)
return false;
530 "rich_tb_fhTimeBetweenEvents",
"rich_tb_fhTimeBetweenEvents", 800, 800);
534 Double_t partIntegral =
535 fHM->
H1(
"fhTimeBetweenEvents")
536 ->Integral(
fHM->
H1(
"fhTimeBetweenEvents")->FindBin(
min),
537 fHM->
H1(
"fhTimeBetweenEvents")->FindBin(
max));
538 Double_t allIntegral =
fHM->
H1(
"fhTimeBetweenEvents")->Integral();
539 Double_t ratio = 100. * partIntegral / allIntegral;
540 cout << ratio <<
"% of all time between events are in range (" <<
min
541 <<
" ," <<
max <<
") ns" << endl;
547 "rich_tb_fhRichPointTime",
"rich_tb_fhRichPointTime", 800, 800);
553 "rich_tb_fhRichPointTimeSources",
559 fHM->
H1(
"fhRichPointTimeNotChPhoton")},
560 {
"Ch. Photons",
"Not Ch. Photons"},
566 fHM->
H1(
"fhRichPointTimePrimEl"),
567 fHM->
H1(
"fhRichPointTimePion"),
568 fHM->
H1(
"fhRichPointTimeOther")},
569 {
"e^{#pm}_{sec}",
"e^{#pm}_{prim}",
"#pi^{#pm}",
"Other"},
577 "rich_tb_fhStsPointTime",
"rich_tb_fhStsPointTime", 800, 800);
583 "rich_tb_fhRichPointTimeLog",
"rich_tb_fhRichPointTimeLog", 1600, 600);
589 "rich_tb_fhStsPointTimeLog",
"rich_tb_fhStsPointTimeLog", 1600, 600);
595 "rich_tb_reco_fhRichDigiTimeLogAll",
599 gPad->SetLeftMargin(0.07);
600 gPad->SetRightMargin(0.05);
605 "rich_tb_reco_fhRichDigiTimeLog",
613 "rich_tb_reco_fhRichRingTimeLogAll",
617 gPad->SetLeftMargin(0.07);
618 gPad->SetRightMargin(0.05);
623 "rich_tb_reco_timelog_hits_rings",
628 gPad->SetLeftMargin(0.07);
629 gPad->SetRightMargin(0.05);
634 "rich_tb_reco_fhRichRingTimeLog",
641 TCanvas* c =
fHM->
CreateCanvas(
"rich_tb_reco_fhRichObectsPerTimeSlice",
642 "rich_tb_reco_fhRichObectsPerTimeSlice",
656 "rich_tb_reco_acc_rec",
"rich_tb_reco_acc_rec", 1600, 600);
659 Int_t nofAccMom =
fHM->
H1(
"fhMomElAcc")->GetEntries();
660 Int_t nofRecMom =
fHM->
H1(
"fhMomElRec")->GetEntries();
661 Int_t nofRefAccMom =
fHM->
H1(
"fhMomRefElAcc")->GetEntries();
662 Int_t nofRefRecMom =
fHM->
H1(
"fhMomRefElRec")->GetEntries();
663 Double_t effMom = 100. * (Double_t) nofRecMom / (Double_t) nofAccMom;
665 100. * (Double_t) nofRefRecMom / (Double_t) nofRefAccMom;
667 {
"Acc (" + to_string(nofAccMom) +
")",
668 "Rec (" + to_string(nofRecMom) +
")"});
670 Int_t nofAccNofHits =
fHM->
H1(
"fhNofHitsElAcc")->GetEntries();
671 Int_t nofRecNofHits =
fHM->
H1(
"fhNofHitsElRec")->GetEntries();
672 Int_t nofRefAccNofHits =
fHM->
H1(
"fhNofHitsRefElAcc")->GetEntries();
673 Int_t nofRefRecNofHits =
fHM->
H1(
"fhNofHitsRefElRec")->GetEntries();
674 Double_t effNofHits =
675 100. * (Double_t) nofRecNofHits / (Double_t) nofAccNofHits;
676 Double_t effRefNofHits =
677 100. * (Double_t) nofRefRecNofHits / (Double_t) nofRefAccNofHits;
679 {
"Acc (" + to_string(nofAccNofHits) +
")",
680 "Rec" + to_string(nofRecNofHits) +
")"});
682 fHM->
CreateCanvas(
"rich_tb_reco_eff_mom",
"rich_tb_reco_eff_mom", 800, 800);
686 DrawH1({hEffMom, hRefEffMom},
696 hEffMom->SetMinimum(0.);
697 hEffMom->SetMaximum(105.);
700 "rich_tb_reco_eff_nofHits",
"rich_tb_reco_eff_nofHits", 800, 800);
706 {hEffHits, hRefEffHits},
716 hEffHits->SetMinimum(0.);
717 hEffHits->SetMaximum(105.);
720 "rich_tb_reco_eff_eventMult",
"rich_tb_reco_eff_eventMult", 800, 800);
721 TH1D* hEffEventMult =
732 hEffHits->SetMinimum(0.);
733 hEffHits->SetMaximum(105.);
741 Int_t startInd = (withNoise) ? -1 : 0;
742 for (
int iEv = startInd; iEv < nofLogEvents; iEv++) {
743 string hName = hMainName +
"_" + to_string(iEv);
745 ((iEv == 0 && !withNoise) || (iEv == -1 && withNoise)) ?
"" :
"same";
747 int color = (ind == 0)
753 : (ind == 3) ? kMagenta + 2
754 : (ind == 4) ? kYellow + 2 : kOrange + 8;
755 if (ind == -1) color = kAzure + 6;
759 fHM->
H1(hMainName +
"_" + to_string(startInd))->SetMaximum(
max * 1.10);
760 gPad->SetLeftMargin(0.07);
761 gPad->SetRightMargin(0.05);
770 TDirectory* oldir = gDirectory;
771 TFile* outFile = FairRootManager::Instance()->GetOutFile();
772 if (outFile != NULL) {
776 gDirectory->cd(oldir->GetPath());