Go to the documentation of this file.
4 #include "TClonesArray.h"
8 #include "TGeoManager.h"
26 #include "CbmTofHit.h"
30 #include "FairMCPoint.h"
31 #include "FairTrackParam.h"
36 #include <boost/assign/list_of.hpp>
42 using boost::assign::list_of;
45 : FairTask(
"CbmRichMCbmQa")
54 , fRichRingMatches(NULL)
55 , fRefPlanePoints(NULL)
60 , fTofHitMatches(NULL) {}
63 cout <<
"CbmRichMCbmQa::Init" << endl;
65 FairRootManager* ioman = FairRootManager::Instance();
67 Fatal(
"CbmRichMCbmQa::Init",
"RootManager not instantised!");
70 fMCTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
71 if (NULL ==
fMCTracks) { Fatal(
"CbmRichMCbmQa::Init",
"No MC Tracks!"); }
73 fRichPoints = (TClonesArray*) ioman->GetObject(
"RichPoint");
74 if (NULL ==
fRichPoints) { Fatal(
"CbmRichMCbmQa::Init",
"No Rich Points!"); }
76 fRichDigis = (TClonesArray*) ioman->GetObject(
"RichDigi");
77 if (NULL ==
fRichDigis) { Fatal(
"CbmRichMCbmQa::Init",
"No Rich Digis!"); }
79 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
80 if (NULL ==
fRichHits) { Fatal(
"CbmRichMCbmQa::Init",
"No RichHits!"); }
82 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
83 if (NULL ==
fRichRings) { Fatal(
"CbmRichMCbmQa::Init",
"No RichRings!"); }
85 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
86 if (NULL ==
fTofHits) { Fatal(
"CbmRichMCbmQa::Init",
"No TofHits!"); }
90 Fatal(
"CbmRichMCbmQa::Init",
"No RichRingMatch array!");
95 Fatal(
"CbmRichMCbmQa::Init",
"No TofHitMatch array!");
98 fTofPoints = (TClonesArray*) ioman->GetObject(
"TofPoint");
99 if (NULL ==
fTofPoints) { Fatal(
"CbmRichMCbmQa::Init",
"No Tof Points!"); }
103 Fatal(
"CbmRichMCbmQa::Init",
"No RefPlanePoints!");
154 cout <<
"CbmRichMCbmQa::InitHistograms" << endl;
161 "fh_nof_rich_points",
162 "fh_nof_rich_points;Nof RICH Points per event;Yield (a.u.)",
167 "fh_nof_rich_hits;Nof RICH hits per event;Yield (a.u.)",
172 "fh_nof_rich_rings;Nof RICH rings;# per event",
177 "fh_rich_ring_radius;Ring radius [cm];Yield (a.u.)",
188 const Double_t xMin = -35.5;
189 const Double_t xMax = 35.5;
190 const Double_t yMin = -40.5;
191 const Double_t yMax = 40.5;
196 "fh_rich_hits_xy;X [cm];Y [cm];Yield",
204 "fh_rich_points_xy;X [cm];Y [cm];Yield (a.u.)",
213 "fh_hits_per_ring",
"fh_hits_per_ring;Hits per Ring;Yield", 18, 2.5, 20.5);
214 fHM->
Create1<TH1D>(
"fh_dR",
"fh_dR;dR [cm];Yield (a.u.)", 80, -0.8, 0.8);
216 "fh_photon_energy",
"fh_photon_energy;Momentum [eV]", 100, 0., 10.);
218 "fh_radius_momentum; Momentum [GeV];Radius [cm]; Yield",
226 "fh_ring_center_xy;X [cm];Y [cm];Yield (a.u.)",
233 fHM->
Create2<TH2D>(
"fh_nonphoton_pmt_points_xy",
234 "fh_nonphoton_pmt_points_xy;X [cm]; Y [cm];Yield",
242 "fh_radius_beta; beta; Radius [cm]; Yield",
250 "fh_beta_dis_all",
"fh_beta_dis_all;beta;Yield; ", 300, 0.7, 1.);
252 "fh_beta_dis_ring",
"fh_beta_dis_ring;beta;Yield;", 300, 0.7, 1.);
260 "fh_eloss_tof; time of flight [ns]; energy loss; Yield",
268 "fh_radius_mass2; mass^2 [GeV^2]; Radius [cm]; Yield",
277 "number_of_events",
"number_of_events; something", 1, 0.5, 1.5);
282 fHM->
H1(
"number_of_events")->Fill(1);
284 cout <<
"CbmRichMCbmQa, event No. " <<
fEventNum << endl;
288 Int_t nofRichPoints =
fRichPoints->GetEntriesFast();
290 Int_t nofRichHits =
fRichHits->GetEntriesFast();
291 Int_t nofRichRings =
fRichRings->GetEntriesFast();
293 Int_t nofTofHits =
fTofHits->GetEntriesFast();
296 fHM->
H1(
"fh_nof_rich_points")->Fill(nofRichPoints);
297 fHM->
H1(
"fh_nof_rich_hits")->Fill(nofRichHits);
298 fHM->
H1(
"fh_nof_rich_rings")->Fill(nofRichRings);
300 for (
int i = 0;
i < nofRichHits;
i++) {
302 if (hit == NULL)
continue;
309 for (
int iT = 0; iT < nofTofHits; iT++) {
311 if (NULL == tofHit)
continue;
313 if (NULL == tofHitMatch)
continue;
317 if (NULL == tofPoint)
continue;
318 Int_t mcTrackIdTofHit = tofPoint->GetTrackID();
319 if (mcTrackIdTofHit < 0)
continue;
321 if (NULL == mcTrackTof)
continue;
326 Double_t momTotal =
sqrt(vec.Px() * vec.Px() + vec.Py() * vec.Py()
327 + vec.Pz() * vec.Pz());
328 Double_t time = tofHit->
GetTime();
329 Double_t timect = 0.2998 * time;
330 Double_t trackLength = tofHit->
GetR() / 100;
331 Double_t beta = trackLength / timect;
332 Double_t mass2 = TMath::Power(momTotal, 2.)
333 * (TMath::Power(1 / beta, 2) - 1);
336 for (
int i = 0;
i < nofRichPoints;
i++) {
338 if (point == NULL)
continue;
340 Int_t mcTrackIdPoint = point->GetTrackID();
341 if (mcTrackIdPoint < 0)
continue;
343 if (mcTrack == NULL)
continue;
348 if (mcTrackIdPoint == mcTrackIdTofHit) {
349 fHM->
H1(
"fh_beta_dis_all")->Fill(beta);
357 if (mcTrackMother == NULL)
continue;
359 if (motherId == mcTrackIdTofHit) {
360 fHM->
H1(
"fh_beta_dis_all")->Fill(beta);
366 for (
int iRing = 0; iRing < nofRichRings; iRing++) {
368 if (NULL == ring)
continue;
371 if (NULL == ringMatch)
continue;
373 if (mcTrackIdRing < 0)
continue;
376 if (mcTrackRing == NULL)
continue;
379 if (mcTrackIdTofHit == mcTrackIdRing) {
380 fHM->
H2(
"fh_radius_mass2")->Fill(mass2, radius);
381 fHM->
H2(
"fh_radius_beta")->Fill(beta, radius);
382 fHM->
H1(
"fh_beta_dis_ring")->Fill(beta);
383 fHM->
H2(
"fh_radius_momentum")->Fill(momTotal, radius);
560 int numberOfEvents =
fHM->
H1(
"number_of_events")->GetEntries();
571 "richsp_radius_momentum",
"richsp_radius_momentum", 1200, 600);
576 fHM->
CreateCanvas(
"richsp_radius_mass2",
"richsp_radius_mass2", 1200, 600);
581 fHM->
CreateCanvas(
"richsp_radius_beta",
"richsp_radius_beta", 1200, 600);
586 fHM->
CreateCanvas(
"richsp_beta_dis_all",
"richsp_beta_dis_all", 1200, 600);
592 "richsp_beta_dis_ring",
"richsp_beta_dis_ring", 1200, 600);
597 fHM->
CreateCanvas(
"fh_nof_rich_rings",
"fh_nof_rich_rings", 1200, 600);
609 "richsp_nof_rich_hits_points",
"richsp_nof_rich_hits_points", 1800, 600);
621 "richsp_rich_points_hits_xy",
"richsp_rich_points_hits_xy", 1200, 600);
631 "richsp_rich_ring_radius",
"richsp_rich_ring_radius", 600, 600);
633 fHM->
H1(
"fh_rich_ring_radius")->SetTitle(
"Ring Radius");
640 fHM->
H1(
"fh_dR")->SetTitle(
"dR");
645 "richsp_ring_center_xy",
"richsp_ring_center_xy", 600, 600);
648 fHM->
H1(
"fh_ring_center_xy")->SetTitle(
"Ring center");
653 "richsp_nonphoton_pmt_points_xy",
658 fHM->
H2(
"fh_nonphoton_pmt_points_xy")->SetTitle(
"Non photons on PMT plane");
663 cout <<
"CbmRichMCbmQa::DrawEvent" << endl;
666 ss <<
"richsp_event_display_event_" <<
fEventNum;
670 new TH2D(
"event_display_pad",
";X [cm];Y [cm]", 1, -65., 5., 1, -40., 40.);
673 pad->GetYaxis()->SetTitleOffset(0.9);
674 gPad->SetLeftMargin(0.13);
675 gPad->SetRightMargin(0.05);
678 int nofHits =
fRichHits->GetEntriesFast();
679 for (
int iH = 0; iH < nofHits; iH++) {
681 if (NULL == hit)
continue;
682 TEllipse* hitDr =
new TEllipse(hit->
GetX(), hit->
GetY(), 0.25);
683 hitDr->SetFillColor(kRed);
684 hitDr->SetLineColor(kRed);
690 for (
int iP = 0; iP < nofPoints; iP++) {
692 if (NULL == point)
continue;
693 TEllipse* pointDr =
new TEllipse(point->GetX(), point->GetY(), 0.15);
694 pointDr->SetFillColor(kBlue);
695 pointDr->SetLineColor(kBlue);
717 for (
int iR = 0; iR < nofRings; iR++) {
719 if (NULL == ring)
continue;
727 circle->SetFillStyle(0);
728 circle->SetLineWidth(4);
729 circle->SetLineColor(kBlack);
733 center->SetFillColor(kBlack);
734 center->SetLineColor(kBlack);
746 const string& outputDir) {
749 if (
fHM !=
nullptr)
delete fHM;
752 TFile* file =
new TFile(fileName.c_str());
Int_t GetMotherId() const
const CbmLink & GetMatchedLink() const
void GetMomentum(TVector3 &momentum) const
void DrawHist()
Draw histograms.
void WriteToFile()
Write all histograms to current opened file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void DrawFromFile(const string &fileName, const string &outputDir)
Draw histogram from file.
TClonesArray * fRichDigis
friend F32vec4 sqrt(const F32vec4 &a)
void ReadFromFile(TFile *file)
Read histograms from file.
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...
TClonesArray * fRefPlanePoints
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
CbmRichMCbmQa()
Standard constructor.
Helper functions for drawing 1D and 2D histograms and graphs.
TClonesArray * fTofHitMatches
FairTask for matching RECO data to MC.
virtual void Finish()
Inherited from FairTask.
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)
void InitHistograms()
Initialize histograms.
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...
virtual void Exec(Option_t *option)
Inherited from FairTask.
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
virtual InitStatus Init()
Inherited from FairTask.
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.
TClonesArray * fRichRingMatches
void DrawCircle(CbmRichRing *ring)
Float_t GetRadius() const
Float_t GetCenterY() const
Geometric intersection of a MC track with a TOFb detector.
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
void SetDefaultDrawStyle()
TClonesArray * fRichPoints
TClonesArray * fTofPoints
Float_t GetCenterX() const
TClonesArray * fRichRings
void DrawH1andFitGauss(TH1 *hist, Bool_t drawResults, Bool_t doScale, Double_t userRangeMin, Double_t userRangeMax)