Go to the documentation of this file.
5 #include "TClonesArray.h"
10 #include "TMCProcess.h"
24 #include "CbmRichUtil.h"
26 #include "FairMCPoint.h"
27 #include "FairTrackParam.h"
34 #include <boost/assign/list_of.hpp>
40 using boost::assign::list_of;
43 : FairTask(
"CbmRichRecoQa")
48 , fRichPoints(nullptr)
51 , fRichRingMatches(nullptr)
52 , fGlobalTracks(nullptr)
54 , fStsTrackMatches(nullptr)
55 , fRichProjections(nullptr)
62 cout <<
"CbmRichRecoQa::Init" << endl;
63 FairRootManager* ioman = FairRootManager::Instance();
64 if (
nullptr == ioman) {
65 Fatal(
"CbmRichRecoQa::Init",
"RootManager not instantised!");
68 fMCTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
69 if (
nullptr ==
fMCTracks) { Fatal(
"CbmRichRecoQa::Init",
"No MC Tracks!"); }
71 fRichPoints = (TClonesArray*) ioman->GetObject(
"RichPoint");
73 Fatal(
"CbmRichRecoQa::Init",
"No Rich Points!");
79 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
80 if (
nullptr ==
fRichHits) { Fatal(
"CbmRichRecoQa::Init",
"No RichHits!"); }
82 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
83 if (
nullptr ==
fRichRings) { Fatal(
"CbmRichRecoQa::Init",
"No RichRings!"); }
87 Fatal(
"CbmRichRecoQa::Init",
"No RichRingMatch array!");
90 fGlobalTracks = (TClonesArray*) ioman->GetObject(
"GlobalTrack");
92 Fatal(
"CbmRichRecoQa::Init",
"No GlobalTrack array!");
95 fStsTracks = (TClonesArray*) ioman->GetObject(
"StsTrack");
97 Fatal(
"CbmRichRecoQa::Init",
": No StsTrack array!");
102 Fatal(
"CbmRichRecoQa::Init",
": No StsTrackMatch array!");
107 Fatal(
"CbmRichUrqmdTest::Init",
"No fRichProjections array!");
113 cout <<
"CbmRichRecoQa::Init finished" << endl;
137 for (Int_t
i = 0;
i < 4;
i++) {
139 if (
i == 0) s =
"Primel";
140 if (
i == 1) s =
"Pi";
141 if (
i == 2) s =
"PrimelPlus";
142 if (
i == 3) s =
"PrimelMinus";
144 fHM->
Create2<TH2D>(
"fhRingTrackDistVsMomTruematch" + s,
145 "fhRingTrackDistVsMomTruematch" + s
146 +
";P [GeV/c];Ring-track distance [cm];Yield (a.u.)",
153 fHM->
Create2<TH2D>(
"fhRingTrackDistVsMomWrongmatch" + s,
154 "fhRingTrackDistVsMomWrongmatch" + s
155 +
";P [GeV/c];Ring-track distance [cm];Yield (a.u.)",
164 "fhRingTrackDistVsNofHitsTruematch" + s,
165 "fhRingTrackDistVsNofHitsTruematch" + s
166 +
";Nof hits in found ring;Ring-track distance [cm];Yield (a.u.)",
173 fHM->
Create3<TH3D>(
"fhRingTrackDistVsXYTruematch" + s,
174 "fhRingTrackDistVsXYTruematch" + s
175 +
";X [cm];Y [cm];Ring-track distance [cm]",
185 fHM->
Create2<TH2D>(
"fhRingTrackDistVsXTruematch" + s,
186 "fhRingTrackDistVsXTruematch" + s
187 +
";X [cm];Ring-track distance [cm]",
194 fHM->
Create2<TH2D>(
"fhRingTrackDistVsYTruematch" + s,
195 "fhRingTrackDistVsYTruematch" + s
196 +
";Abs(Y) [cm];Ring-track distance [cm]",
206 fHM->
Create2<TH2D>(
"fhRingTrackDistVsMomTruematchElId",
207 "fhRingTrackDistVsMomTruematchElId;P [GeV/c];Ring-track "
208 "distance [cm];Yield (a.u.)",
217 "fhMismatchSource;Global track category;% from MC",
223 "fhMismatchSourceMomMc;Momentum [GeV/c];Yield",
228 "fhMismatchSourceMomSts;Momentum [GeV/c];Yield",
232 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsAccRich",
233 "fhMismatchSourceMomStsAccRich;Momentum [GeV/c];Yield",
237 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsRich",
238 "fhMismatchSourceMomStsRich;Momentum [GeV/c];Yield",
242 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsRichTrue",
243 "fhMismatchSourceMomStsRichTrue;Momentum [GeV/c];Yield",
247 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsNoRich",
248 "fhMismatchSourceMomStsNoRich;Momentum [GeV/c];Yield",
252 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsNoRichRF",
253 "fhMismatchSourceMomStsNoRichRF;Momentum [GeV/c];Yield",
257 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsNoRichRM",
258 "fhMismatchSourceMomStsNoRichRM;Momentum [GeV/c];Yield",
262 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsNoRichNoRF",
263 "fhMismatchSourceMomStsNoRichNoRF;Momentum [GeV/c];Yield",
268 "fhMismatchSourceMomStsNoRichNoProj",
269 "fhMismatchSourceMomStsNoRichNoProj;Momentum [GeV/c];Yield",
273 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsRichWrong",
274 "fhMismatchSourceMomStsRichWrong;Momentum [GeV/c];Yield",
278 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsRichWrongRF",
279 "fhMismatchSourceMomStsRichWrongRF;Momentum [GeV/c];Yield",
283 fHM->
Create1<TH1D>(
"fhMismatchSourceMomStsRichWrongRM",
284 "fhMismatchSourceMomStsRichWrongRM;Momentum [GeV/c];Yield",
292 cout <<
"CbmRichRecoQa, event No. " <<
fEventNum << endl;
301 Int_t nofRichHits =
fRichHits->GetEntriesFast();
302 for (Int_t iHit = 0; iHit < nofRichHits; iHit++) {
304 if (
nullptr == hit)
continue;
308 for (UInt_t
i = 0;
i < motherIds.size();
i++) {
315 Int_t nofMcTracks =
fMCTracks->GetEntriesFast();
316 for (Int_t iTrack = 0; iTrack < nofMcTracks; iTrack++) {
319 if (mcTrack ==
nullptr)
continue;
323 fHM->
H1(
"fhMismatchSource")->Fill(0);
324 fHM->
H1(
"fhMismatchSourceMomMc")->Fill(mcTrack->
GetP());
330 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
335 if (stsId < 0)
continue;
338 if (stsTrackMatch ==
nullptr)
continue;
342 if (mctrack ==
nullptr)
continue;
343 Double_t mom = mctrack->
GetP();
349 fHM->
H1(
"fhMismatchSource")->Fill(1);
350 fHM->
H1(
"fhMismatchSourceMomSts")->Fill(mom);
354 fHM->
H1(
"fhMismatchSource")->Fill(2);
355 fHM->
H1(
"fhMismatchSourceMomStsAccRich")->Fill(mctrack->
GetP());
363 fHM->
H1(
"fhMismatchSource")->Fill(5);
364 fHM->
H1(
"fhMismatchSourceMomStsNoRich")->Fill(mom);
370 fHM->
H1(
"fhMismatchSource")->Fill(6);
371 fHM->
H1(
"fhMismatchSourceMomStsNoRichRF")->Fill(mom);
374 fHM->
H1(
"fhMismatchSource")->Fill(8);
375 fHM->
H1(
"fhMismatchSourceMomStsNoRichNoRF")->Fill(mom);
380 fHM->
H1(
"fhMismatchSource")->Fill(7);
381 fHM->
H1(
"fhMismatchSourceMomStsNoRichRM")->Fill(mom);
386 fHM->
H1(
"fhMismatchSource")->Fill(9);
387 fHM->
H1(
"fhMismatchSourceMomStsNoRichNoProj")->Fill(mom);
394 fHM->
H1(
"fhMismatchSource")->Fill(3);
395 fHM->
H1(
"fhMismatchSourceMomStsRich")->Fill(mom);
399 if (richRingMatch ==
nullptr)
continue;
403 if (
nullptr == ring)
continue;
405 if (stsMcTrackId == richMcTrackId) {
407 fHM->
H1(
"fhMismatchSource")->Fill(4);
408 fHM->
H1(
"fhMismatchSourceMomStsRichTrue")->Fill(mom);
411 fHM->
H1(
"fhMismatchSource")->Fill(10);
412 fHM->
H1(
"fhMismatchSourceMomStsRichWrong")->Fill(mom);
415 fHM->
H1(
"fhMismatchSource")->Fill(11);
416 fHM->
H1(
"fhMismatchSourceMomStsRichWrongRF")->Fill(mom);
421 fHM->
H1(
"fhMismatchSource")->Fill(12);
422 fHM->
H1(
"fhMismatchSourceMomStsRichWrongRM")->Fill(mom);
429 Int_t nofRings =
fRichRings->GetEntriesFast();
430 for (Int_t iR = 0; iR < nofRings; iR++) {
433 if (ring ==
nullptr)
continue;
436 if (richRingMatch ==
nullptr)
continue;
438 if (richMcTrackId == mcTrackId)
return true;
445 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
450 if (richId < 0)
continue;
453 if (richRingMatch ==
nullptr)
continue;
455 if (richMcTrackId == mcTrackId) {
return true; }
463 if (stsTrackId < 0) {
return false; }
464 FairTrackParam* pTrack = (FairTrackParam*)
fRichProjections->At(stsTrackId);
465 if (pTrack ==
nullptr) {
return false; }
467 if (pTrack->GetX() == 0. && pTrack->GetY() == 0.) {
476 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
482 if (stsId < 0 || richId < 0)
continue;
486 if (stsTrackMatch ==
nullptr)
continue;
491 if (richRingMatch ==
nullptr)
continue;
495 if (
nullptr == ring)
continue;
503 if (mctrack ==
nullptr)
continue;
504 double mom = mctrack->
GetP();
510 if (!isEl && !isPi)
continue;
514 for (
int i = 0;
i < 2;
i++) {
527 }
else if (charge < 0) {
537 if (stsMcTrackId == richMcTrackId) {
538 fHM->
H2(
"fhRingTrackDistVsMomTruematch" + s)->Fill(mom, rtDistance);
539 fHM->
H3(
"fhRingTrackDistVsXYTruematch" + s)->Fill(xc, yc, rtDistance);
540 fHM->
H2(
"fhRingTrackDistVsXTruematch" + s)->Fill(xc, rtDistance);
541 fHM->
H2(
"fhRingTrackDistVsYTruematch" + s)->Fill(abs(yc), rtDistance);
542 fHM->
H2(
"fhRingTrackDistVsNofHitsTruematch" + s)
543 ->Fill(nofHits, rtDistance);
545 if (
i == 0 && isEl) {
547 fHM->
H2(
"fhRingTrackDistVsMomTruematchElId")->Fill(mom, rtDistance);
552 fHM->
H2(
"fhRingTrackDistVsMomWrongmatch" + s)->Fill(mom, rtDistance);
567 fHM->
CreateCanvas(
"fh_ring_track_distance_truematch_comparison_primel",
568 "fh_ring_track_distance_truematch_comparison_primel",
572 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimelMinus")
573 ->ProjectionY(
"fhRingTrackDistVsMomTruematchPrimelMinus_py")
575 py_minus->Scale(1. / py_minus->Integral());
577 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimelPlus")
578 ->ProjectionY(
"fhRingTrackDistVsMomTruematchPrimelPlus_py")
580 py_plus->Scale(1. / py_plus->Integral());
596 "fh_ring_track_distance_truematch_comparison_elpi",
600 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimel")
601 ->ProjectionY(
"fhRingTrackDistVsMomTruematchPrimel_py")
603 py_el->Scale(1. / py_el->Integral());
604 TH1D* py_pi = (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchPi")
605 ->ProjectionY(
"fhRingTrackDistVsMomTruematchPi_py")
607 py_pi->Scale(1. / py_pi->Integral());
622 gStyle->SetPaintTextFormat(
"4.1f");
623 fHM->
CreateCanvas(
"fh_mismatch_source",
"fh_mismatch_source", 1000, 800);
624 Double_t nofMcEl =
fHM->
H1(
"fhMismatchSource")->GetBinContent(1);
625 cout <<
"nofMcEl = " << nofMcEl << endl;
626 fHM->
H1(
"fhMismatchSource")->Scale(100. / nofMcEl);
628 fHM->
H1(
"fhMismatchSource")->SetMarkerSize(1.9);
630 vector<string> labels = {
"MC",
642 "STS-RICH wrong RM"};
643 for (
unsigned int i = 0;
i < labels.size();
i++) {
644 fHM->
H1(
"fhMismatchSource")
646 ->SetBinLabel(
i + 1, labels[
i].c_str());
648 fHM->
H1(
"fhMismatchSource")->GetXaxis()->SetLabelSize(0.03);
653 "fh_mismatch_source_mom",
"fh_mismatch_source_mom", 1000, 800);
654 vector<string> labels = {
"MC",
666 "STS-RICH wrong RM"};
667 vector<TH1*> hists = {
fHM->
H1(
"fhMismatchSourceMomMc"),
668 fHM->
H1(
"fhMismatchSourceMomSts"),
669 fHM->
H1(
"fhMismatchSourceMomStsAccRich"),
670 fHM->
H1(
"fhMismatchSourceMomStsRich"),
671 fHM->
H1(
"fhMismatchSourceMomStsRichTrue"),
672 fHM->
H1(
"fhMismatchSourceMomStsNoRich"),
673 fHM->
H1(
"fhMismatchSourceMomStsNoRichRF"),
674 fHM->
H1(
"fhMismatchSourceMomStsNoRichRM"),
675 fHM->
H1(
"fhMismatchSourceMomStsNoRichNoRF"),
676 fHM->
H1(
"fhMismatchSourceMomStsNoRichNoProj"),
677 fHM->
H1(
"fhMismatchSourceMomStsRichWrong"),
678 fHM->
H1(
"fhMismatchSourceMomStsRichWrongRF"),
679 fHM->
H1(
"fhMismatchSourceMomStsRichWrongRM")};
682 fHM->
H1(
"fhMismatchSourceMomMc")->SetMinimum(0.9);
692 TCanvas* c =
fHM->
CreateCanvas(
"fh_ring_track_distance_truematch_elid",
693 "fh_ring_track_distance_truematch_elid",
699 fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimel"),
false,
true);
702 fHM->
H2(
"fhRingTrackDistVsMomTruematchElId"),
false,
true);
705 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimel")
707 string(
"fhRingTrackDistVsMomTruematchPrimel_py2").c_str())
710 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematchElId")
712 string(
"fhRingTrackDistVsMomTruematchElId_py").c_str())
725 fHM->
H2(
"fhRingTrackDistVsMomTruematchPrimel")
727 ->SetRangeUser(0., 2.);
728 fHM->
H2(
"fhRingTrackDistVsMomTruematchElId")
730 ->SetRangeUser(0., 2.);
736 double overflow =
h->GetBinContent(
h->GetNbinsX() + 1);
737 return Cbm::NumberToString<Double_t>(
h->GetMean(), 2) +
" / "
738 + Cbm::NumberToString<Double_t>(
h->GetRMS(), 2) +
" / "
739 + Cbm::NumberToString<Double_t>(
740 100. * overflow /
h->Integral(0,
h->GetNbinsX() + 1), 2)
743 return Cbm::NumberToString<Double_t>(
h->GetMean(), 2) +
" / "
744 + Cbm::NumberToString<Double_t>(
h->GetRMS(), 2);
751 TCanvas* c =
fHM->
CreateCanvas(
"fh_ring_track_distance_truematch_" + s,
752 "fh_ring_track_distance_truematch_" + s,
758 fHM->
H2(
"fhRingTrackDistVsMomTruematch" + s),
false,
true);
761 fHM->
H2(
"fhRingTrackDistVsNofHitsTruematch" + s),
false,
true);
764 (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomTruematch" + s)
765 ->ProjectionY((
"fhRingTrackDistVsMomTruematch_py" + s).c_str())
771 fHM->
H2(
"fhRingTrackDistVsMomTruematch" + s)
773 ->SetRangeUser(0., 2.);
774 fHM->
H2(
"fhRingTrackDistVsNofHitsTruematch" + s)
776 ->SetRangeUser(0., 2.);
781 "fh_ring_track_distance_wrongmatch" + s,
784 TH1D* py = (TH1D*) (
fHM->
H2(
"fhRingTrackDistVsMomWrongmatch" + s)
786 (
"fhRingTrackDistVsMomWrongmatch_py" + s).c_str())
794 TCanvas* c =
fHM->
CreateCanvas(
"fh_ring_track_distance_vs_xy_truematch" + s,
795 "fh_ring_track_distance_vs_xy_truematch" + s,
801 fHM->
H3(
"fhRingTrackDistVsXYTruematch" + s),
true,
false, 0., .4);
804 fHM->
H2(
"fhRingTrackDistVsXTruematch" + s)
806 ->SetRangeUser(0., 2.);
809 fHM->
H2(
"fhRingTrackDistVsYTruematch" + s)
811 ->SetRangeUser(0., 2.);
816 if (mctrack ==
nullptr)
return false;
823 if (mctrack ==
nullptr)
return false;
825 if (pdg == 211)
return true;
833 TDirectory* oldir = gDirectory;
834 TFile* outFile = FairRootManager::Instance()->GetOutFile();
835 if (outFile != NULL) {
839 gDirectory->cd(oldir->GetPath());
843 const string& outputDir) {
846 if (
fHM !=
nullptr)
delete fHM;
849 TFile* file =
new TFile(fileName.c_str());
bool WasRingMatched(Int_t mcTrackId)
const CbmLink & GetMatchedLink() const
Generates beam ions for transport simulation.
TClonesArray * fGlobalTracks
void WriteToFile()
Write all histograms to current opened file.
TClonesArray * fStsTracks
void Create3(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY, Int_t nofBinsZ, Double_t minBinZ, Double_t maxBinZ)
Helper function for creation of 3-dimensional histograms and profiles. Template argument is a real ob...
void ReadFromFile(TFile *file)
Read histograms from file.
TH2D * DrawH3Profile(TH3 *h, Bool_t drawMean, Bool_t doGaussFit, Double_t zMin, Double_t zMax)
static Bool_t IsMcPion(const CbmMCTrack *mctrack)
InitStatus Init()
Initialisation.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
Int_t GetRichRingIndex() const
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void FillRichRingNofHits()
Fill map mcTrackId -> nof RICH hits.
Helper functions for drawing 1D and 2D histograms and graphs.
FairTask for matching RECO data to MC.
TH3 * H3(const std::string &name) const
Return pointer to TH3 histogram.
static CbmDigiManager * Instance()
Static instance.
Double_t GetCharge() const
Charge of the associated particle.
TClonesArray * fRichRings
static Double_t GetRingTrackDistance(Int_t globalTrackId)
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
Int_t GetStsTrackIndex() const
void DrawFromFile(const string &fileName, const string &outputDir)
Draw histogram from file.
bool WasRingFound(Int_t mcTrackId)
string GetMeanRmsOverflowString(TH1 *h, Bool_t withOverflow=true)
Return string with mean, RMS and overflow percent for input TH1.
static std::vector< std::pair< Int_t, Int_t > > GetMcTrackMotherIdsForRichHit(CbmDigiManager *digiMan, const CbmRichHit *hit, CbmMCDataArray *richPoints, CbmMCDataArray *mcTracks, Int_t eventNumber)
Return McTrack Ids for RICH hit C++11 efficient way to return vector.
virtual void Finish()
Inherited from FairTask.
void DrawH2WithProfile(TH2 *hist, Bool_t doGaussFit, Bool_t drawOnlyMean, const string &drawOpt2D, Int_t profileColor, Int_t profileLineWidth)
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TClonesArray * fStsTrackMatches
void DrawHist()
Draw histograms.
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
UInt_t GetGeantProcessId() const
CbmRichRecoQa()
Standard constructor.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
void InitHistograms()
Initialize histograms.
void FillRingTrackDistance()
Fill histogramms related to ring track distance.
CbmDigiManager * fDigiMan
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
void RingTrackMismatchSource()
Fill histograms related to study of the source of ring-track mismatch.
virtual InitStatus Init()
Inherited from FairTask.
static Bool_t IsMcPrimaryElectron(const CbmMCTrack *mctrack)
void DrawRingTrackDistHistWithSuffix(const string &suffix)
Draw histograms related to ring-track distance for pions or electrons (+/-).
virtual void Exec(Option_t *option)
Inherited from FairTask.
TClonesArray * fRichProjections
Float_t GetCenterY() const
TClonesArray * fRichPoints
void SetDefaultDrawStyle()
CbmDigiManager * fDigiMan
TClonesArray * fRichRingMatches
std::map< Int_t, Int_t > fNofHitsInRingMap
Float_t GetCenterX() const
bool HasRichProjection(Int_t stsTrackId)