22#include "FairMCPoint.h"
23#include "FairTrackParam.h"
25#include "TClonesArray.h"
29#include "TGeoManager.h"
38#include <boost/assign/list_of.hpp>
45using boost::assign::list_of;
48 : FairTask(
"CbmRichMCbmQa")
57 , fRichRingMatches(NULL)
58 , fRefPlanePoints(NULL)
63 , fTofHitMatches(NULL)
69 cout <<
"CbmRichMCbmQa::Init" << endl;
71 FairRootManager* ioman = FairRootManager::Instance();
73 Fatal(
"CbmRichMCbmQa::Init",
"RootManager not instantised!");
76 fMCTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
78 Fatal(
"CbmRichMCbmQa::Init",
"No MC Tracks!");
81 fRichPoints = (TClonesArray*) ioman->GetObject(
"RichPoint");
83 Fatal(
"CbmRichMCbmQa::Init",
"No Rich Points!");
86 fRichDigis = (TClonesArray*) ioman->GetObject(
"RichDigi");
88 Fatal(
"CbmRichMCbmQa::Init",
"No Rich Digis!");
91 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
93 Fatal(
"CbmRichMCbmQa::Init",
"No RichHits!");
96 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
98 Fatal(
"CbmRichMCbmQa::Init",
"No RichRings!");
101 fTofHits = (TClonesArray*) ioman->GetObject(
"TofHit");
103 Fatal(
"CbmRichMCbmQa::Init",
"No TofHits!");
108 Fatal(
"CbmRichMCbmQa::Init",
"No RichRingMatch array!");
113 Fatal(
"CbmRichMCbmQa::Init",
"No TofHitMatch array!");
116 fTofPoints = (TClonesArray*) ioman->GetObject(
"TofPoint");
118 Fatal(
"CbmRichMCbmQa::Init",
"No Tof Points!");
123 Fatal(
"CbmRichMCbmQa::Init",
"No RefPlanePoints!");
175 cout <<
"CbmRichMCbmQa::InitHistograms" << endl;
181 fHM->
Create1<TH1D>(
"fh_nof_rich_points",
"fh_nof_rich_points;Nof RICH Points per event;Yield (a.u.)", 1000, -.5,
183 fHM->
Create1<TH1D>(
"fh_nof_rich_hits",
"fh_nof_rich_hits;Nof RICH hits per event;Yield (a.u.)", 100, -.5, 99.5);
184 fHM->
Create1<TH1D>(
"fh_nof_rich_rings",
"fh_nof_rich_rings;Nof RICH rings;# per event", 20, -0.5, 19.5);
185 fHM->
Create1<TH1D>(
"fh_rich_ring_radius",
"fh_rich_ring_radius;Ring radius [cm];Yield (a.u.)", 200, 1., 8.);
193 const Double_t xMin = -35.5;
194 const Double_t xMax = 35.5;
195 const Double_t yMin = -40.5;
196 const Double_t yMax = 40.5;
200 fHM->
Create2<TH2D>(
"fh_rich_hits_xy",
"fh_rich_hits_xy;X [cm];Y [cm];Yield", 71, xMin, xMax, 81, yMin, yMax);
201 fHM->
Create2<TH2D>(
"fh_rich_points_xy",
"fh_rich_points_xy;X [cm];Y [cm];Yield (a.u.)", 250, xMin, xMax, 250, yMin,
204 fHM->
Create1<TH1D>(
"fh_hits_per_ring",
"fh_hits_per_ring;Hits per Ring;Yield", 18, 2.5, 20.5);
205 fHM->
Create1<TH1D>(
"fh_dR",
"fh_dR;dR [cm];Yield (a.u.)", 80, -0.8, 0.8);
206 fHM->
Create1<TH1D>(
"fh_photon_energy",
"fh_photon_energy;Momentum [eV]", 100, 0., 10.);
207 fHM->
Create2<TH2D>(
"fh_radius_momentum",
"fh_radius_momentum; Momentum [GeV];Radius [cm]; Yield", 500, 0., 5., 500,
209 fHM->
Create2<TH2D>(
"fh_ring_center_xy",
"fh_ring_center_xy;X [cm];Y [cm];Yield (a.u.)", 100, xMin, xMax, 100, yMin,
211 fHM->
Create2<TH2D>(
"fh_nonphoton_pmt_points_xy",
"fh_nonphoton_pmt_points_xy;X [cm]; Y [cm];Yield", 250., xMin, xMax,
213 fHM->
Create2<TH2D>(
"fh_radius_beta",
"fh_radius_beta; beta; Radius [cm]; Yield", 400, 0.7, 1.1, 500, 0., 5.);
214 fHM->
Create1<TH1D>(
"fh_beta_dis_all",
"fh_beta_dis_all;beta;Yield; ", 300, 0.7, 1.);
215 fHM->
Create1<TH1D>(
"fh_beta_dis_ring",
"fh_beta_dis_ring;beta;Yield;", 300, 0.7, 1.);
222 fHM->
Create2<TH2D>(
"fh_eloss_tof",
"fh_eloss_tof; time of flight [ns]; energy loss; Yield", 500, 0., 5., 500, 0., 5.);
223 fHM->
Create2<TH2D>(
"fh_radius_mass2",
"fh_radius_mass2; mass^2 [GeV^2]; Radius [cm]; Yield", 450, -0.3, 1.2, 500, 0.,
226 fHM->
Create1<TH1D>(
"number_of_events",
"number_of_events; something", 1, 0.5, 1.5);
232 fHM->
H1(
"number_of_events")->Fill(1);
234 cout <<
"CbmRichMCbmQa, event No. " <<
fEventNum << endl;
238 Int_t nofRichPoints =
fRichPoints->GetEntriesFast();
240 Int_t nofRichHits =
fRichHits->GetEntriesFast();
241 Int_t nofRichRings =
fRichRings->GetEntriesFast();
243 Int_t nofTofHits =
fTofHits->GetEntriesFast();
246 fHM->
H1(
"fh_nof_rich_points")->Fill(nofRichPoints);
247 fHM->
H1(
"fh_nof_rich_hits")->Fill(nofRichHits);
248 fHM->
H1(
"fh_nof_rich_rings")->Fill(nofRichRings);
250 for (
int i = 0; i < nofRichHits; i++) {
252 if (hit == NULL)
continue;
259 for (
int iT = 0; iT < nofTofHits; iT++) {
261 if (NULL == tofHit)
continue;
263 if (NULL == tofHitMatch)
continue;
266 if (NULL == tofPoint)
continue;
267 Int_t mcTrackIdTofHit = tofPoint->GetTrackID();
268 if (mcTrackIdTofHit < 0)
continue;
270 if (NULL == mcTrackTof)
continue;
275 Double_t momTotal =
sqrt(vec.Px() * vec.Px() + vec.Py() * vec.Py() + vec.Pz() * vec.Pz());
276 Double_t time = tofHit->
GetTime();
277 Double_t timect = 0.2998 * time;
278 Double_t trackLength = tofHit->
GetR() / 100;
279 Double_t beta = trackLength / timect;
280 Double_t mass2 = TMath::Power(momTotal, 2.) * (TMath::Power(1 / beta, 2) - 1);
283 for (
int i = 0; i < nofRichPoints; i++) {
285 if (point == NULL)
continue;
287 Int_t mcTrackIdPoint = point->GetTrackID();
288 if (mcTrackIdPoint < 0)
continue;
290 if (mcTrack == NULL)
continue;
295 if (mcTrackIdPoint == mcTrackIdTofHit) {
296 fHM->
H1(
"fh_beta_dis_all")->Fill(beta);
303 if (mcTrackMother == NULL)
continue;
305 if (motherId == mcTrackIdTofHit) {
306 fHM->
H1(
"fh_beta_dis_all")->Fill(beta);
312 for (
int iRing = 0; iRing < nofRichRings; iRing++) {
314 if (NULL == ring)
continue;
316 if (NULL == ringMatch)
continue;
318 if (mcTrackIdRing < 0)
continue;
321 if (mcTrackRing == NULL)
continue;
324 if (mcTrackIdTofHit == mcTrackIdRing) {
325 fHM->
H2(
"fh_radius_mass2")->Fill(mass2, radius);
326 fHM->
H2(
"fh_radius_beta")->Fill(beta, radius);
327 fHM->
H1(
"fh_beta_dis_ring")->Fill(beta);
328 fHM->
H2(
"fh_radius_momentum")->Fill(momTotal, radius);
506 int numberOfEvents =
fHM->
H1(
"number_of_events")->GetEntries();
516 fHM->
CreateCanvas(
"richsp_radius_momentum",
"richsp_radius_momentum", 1200, 600);
521 fHM->
CreateCanvas(
"richsp_radius_mass2",
"richsp_radius_mass2", 1200, 600);
526 fHM->
CreateCanvas(
"richsp_radius_beta",
"richsp_radius_beta", 1200, 600);
531 fHM->
CreateCanvas(
"richsp_beta_dis_all",
"richsp_beta_dis_all", 1200, 600);
536 fHM->
CreateCanvas(
"richsp_beta_dis_ring",
"richsp_beta_dis_ring", 1200, 600);
541 fHM->
CreateCanvas(
"fh_nof_rich_rings",
"fh_nof_rich_rings", 1200, 600);
552 TCanvas* c =
fHM->
CreateCanvas(
"richsp_nof_rich_hits_points",
"richsp_nof_rich_hits_points", 1800, 600);
563 TCanvas* c =
fHM->
CreateCanvas(
"richsp_rich_points_hits_xy",
"richsp_rich_points_hits_xy", 1200, 600);
572 fHM->
CreateCanvas(
"richsp_rich_ring_radius",
"richsp_rich_ring_radius", 600, 600);
574 fHM->
H1(
"fh_rich_ring_radius")->SetTitle(
"Ring Radius");
581 fHM->
H1(
"fh_dR")->SetTitle(
"dR");
585 TCanvas* c =
fHM->
CreateCanvas(
"richsp_ring_center_xy",
"richsp_ring_center_xy", 600, 600);
588 fHM->
H1(
"fh_ring_center_xy")->SetTitle(
"Ring center");
592 TCanvas* c =
fHM->
CreateCanvas(
"richsp_nonphoton_pmt_points_xy",
"richsp_nonphoton_pmt_points_xy", 600, 600);
595 fHM->
H2(
"fh_nonphoton_pmt_points_xy")->SetTitle(
"Non photons on PMT plane");
601 cout <<
"CbmRichMCbmQa::DrawEvent" << endl;
604 ss <<
"richsp_event_display_event_" <<
fEventNum;
607 TH2D* pad =
new TH2D(
"event_display_pad",
";X [cm];Y [cm]", 1, -65., 5., 1, -40., 40.);
610 pad->GetYaxis()->SetTitleOffset(0.9);
611 gPad->SetLeftMargin(0.13);
612 gPad->SetRightMargin(0.05);
615 int nofHits =
fRichHits->GetEntriesFast();
616 for (
int iH = 0; iH < nofHits; iH++) {
618 if (NULL == hit)
continue;
619 TEllipse* hitDr =
new TEllipse(hit->
GetX(), hit->
GetY(), 0.25);
620 hitDr->SetFillColor(kRed);
621 hitDr->SetLineColor(kRed);
627 for (
int iP = 0; iP < nofPoints; iP++) {
629 if (NULL == point)
continue;
630 TEllipse* pointDr =
new TEllipse(point->GetX(), point->GetY(), 0.15);
631 pointDr->SetFillColor(kBlue);
632 pointDr->SetLineColor(kBlue);
654 for (
int iR = 0; iR < nofRings; iR++) {
656 if (NULL == ring)
continue;
664 circle->SetFillStyle(0);
665 circle->SetLineWidth(4);
666 circle->SetLineColor(kBlack);
670 center->SetFillColor(kBlack);
671 center->SetLineColor(kBlack);
688 TFile* oldFile = gFile;
689 TDirectory* oldDir = gDirectory;
691 if (
fHM !=
nullptr)
delete fHM;
694 TFile* file =
new TFile(fileName.c_str());
ClassImp(CbmConverterManager)
void DrawH1andFitGauss(TH1 *hist, Bool_t drawResults, Bool_t doScale, Double_t userRangeMin, Double_t userRangeMax)
void SetDefaultDrawStyle()
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 DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
FairTask for matching RECO data to MC.
friend fvec sqrt(const fvec &a)
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.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
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...
void ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void WriteToFile()
Write all objects to current opened file.
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...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
void GetMomentum(TVector3 &momentum) const
int32_t GetMotherId() const
int32_t GetPdgCode() const
const CbmLink & GetMatchedLink() const
TClonesArray * fRichPoints
TClonesArray * fTofPoints
void DrawCircle(CbmRichRing *ring)
virtual void Finish()
Inherited from FairTask.
void InitHistograms()
Initialize histograms.
virtual InitStatus Init()
Inherited from FairTask.
void DrawFromFile(const string &fileName, const string &outputDir)
Draw histogram from file.
virtual void Exec(Option_t *option)
Inherited from FairTask.
void DrawHist()
Draw histograms.
TClonesArray * fRichDigis
TClonesArray * fRefPlanePoints
TClonesArray * fRichRings
CbmRichMCbmQa()
Standard constructor.
TClonesArray * fTofHitMatches
TClonesArray * fRichRingMatches
Geometric intersection of a MC track with a TOFb detector.