27#include <FairRootManager.h>
32#include "TClonesArray.h"
33#include "TDatabasePDG.h"
39#include <TDirectory.h>
41#include <TParameter.h>
47#define BINS_STA fNstations, 0, fNstations
53 : FairTask(name, verbose)
54 , fOutFolder(
"MuchTransportQA",
"Much Transport QA")
55 , fNevents(
"nEvents", 0)
62 , fvMcPointPrimRatio()
135 TDirectory* oldDirectory = gDirectory;
136 fManager = FairRootManager::Instance();
139 LOG(error) <<
"No FairRootManager found";
146 if (!
fTimeSlice) { LOG(error) << GetName() <<
": No time slice found"; }
160 LOG(error) <<
"No MC tracks found";
164 LOG(error) <<
"No MC points found";
168 LOG(fatal) <<
"No CbmMuchGeoScheme found";
172 LOG(error) <<
"CbmMuchGeoScheme is not initialized";
178 LOG(fatal) <<
"Much station " << i <<
" doesn't exist";
191 gDirectory = oldDirectory;
209 for (uint i = 0; i <
fvUsNtra.size(); i++) {
212 h->GetXaxis()->SetTitle(
"Station");
232 for (uint i = 0; i <
fvFraction.size(); i++) {
235 h->GetXaxis()->SetTitle(
"Station");
236 if (i == 0) {
h->GetYaxis()->SetTitle(
"N tracks"); }
238 h->GetYaxis()->SetTitle(
"%");
251 gStyle->SetOptStat(0);
255 Double_t rMax = station->
GetRmax();
256 Double_t rMin = station->
GetRmin();
258 fvMcPointXY[i] =
new TH2F(Form(
"hMcPointXY%i", i + 1), Form(
"MC point XY : Station %i; X; Y", i + 1), 100,
259 -1.2 * rMax, 1.2 * rMax, 100, -1.2 * rMax, 1.2 * rMax);
260 fvMcPointPhiZ[i] =
new TH2F(Form(
"hMcPointPhiZ%i", i + 1), Form(
"MC point Phi vs Z : Station %i; Z; Phi", i + 1),
262 station->
GetZ() + station->
GetTubeDz() + 5., 100, -200., 200.);
264 float dR = rMax - rMin;
265 fvMcPointRZ[i] =
new TH2F(Form(
"hMcPointRZ%i", i + 1), Form(
"MC point R vs Z : Station %i; Z; R", i + 1), 100,
267 100, rMin - 0.1 * dR, rMax + 0.1 * dR);
282 new CbmQaPie(Form(
"fvMcPointPRatio%i", i + 1), Form(
"McPoint Particle Ratios: Station %i", i + 1), 5);
285 new CbmQaPie(Form(
"fvMcPointPrimRatio%i", i + 1), Form(
"McPoint Primary/Secondary Track: Station %i", i + 1), 2);
305 fCanvNtra =
new CbmQaCanvas(
"cNparticles",
"Much: Particle counts per event", 2 * 800, 2 * 400);
312 new CbmQaCanvas(
"cMcPointPrimRatios",
"Much: MC primary/secondary track ratios", 2 * 400, 2 * 400);
356 LOG(debug) <<
"Event: " <<
fNevents.GetVal();
360 for (
int iLink = 0; iLink < sliceMatch.
GetNofLinks(); iLink++) {
366 std::vector<UInt_t> trackStaCross(nMcTracks, 0);
368 for (Int_t ip = 0; ip < nMuchPoints; ip++) {
373 UInt_t stMask = (1 << stId);
374 Int_t trackId = point->GetTrackID();
376 LOG(fatal) <<
"Much point " << ip <<
" doesn't exist";
379 if (trackId < 0 || trackId >= nMcTracks) {
380 LOG(fatal) <<
"Much point " << ip <<
": trackId " << trackId <<
" doesn't belong to [0," << nMcTracks - 1
388 LOG(fatal) <<
"MC track " << trackId <<
" doesn't exist";
400 if (!(trackStaCross[trackId] & stMask)) {
FillCountingHistos(stId, motherId, pdgCode); }
401 trackStaCross[trackId] |= stMask;
415 switch (abs(pdgCode)) {
445 fvMcPointPhiZ[stId]->Fill(v1.Z(), v1.Phi() * TMath::RadToDeg());
446 fvMcPointPhiZ[stId]->Fill(v2.Z(), v2.Phi() * TMath::RadToDeg());
455 TDirectory* oldDirectory = gDirectory;
462 for (uint i = 1; i <
fvFraction.size(); i++) {
470 gDirectory = oldDirectory;
492 PRatioPieLeg->SetY1(.56);
493 PRatioPieLeg->SetY2(.86);
499 PrimRatioPieLeg->SetY1(.71);
500 PrimRatioPieLeg->SetY2(.86);
501 PrimRatioPieLeg->SetX1(.40);
502 PrimRatioPieLeg->SetX2(.90);
518 fhUsNtraPr->DrawCopy(
"colz",
"")->Scale(scale);
521 fhUsNtraPi->DrawCopy(
"colz",
"")->Scale(scale);
524 fhUsNtraEl->DrawCopy(
"colz",
"")->Scale(scale);
527 fhUsNtraMu->DrawCopy(
"colz",
"")->Scale(scale);
530 fhUsNtraKa->DrawCopy(
"colz",
"")->Scale(scale);
541 Int_t PRatiosColors[] = {4, 3, 2, 5, 6};
553 fvMcPointPRatio[i]->GetSlice(0)->SetTitle(Form(
"e: %.1f %%", PRatios[0]));
554 fvMcPointPRatio[i]->GetSlice(1)->SetTitle(Form(
"p: %.1f %%", PRatios[1]));
555 fvMcPointPRatio[i]->GetSlice(2)->SetTitle(Form(
"#pi: %.1f %%", PRatios[2]));
556 fvMcPointPRatio[i]->GetSlice(3)->SetTitle(Form(
"#mu: %.1f %%", PRatios[3]));
557 fvMcPointPRatio[i]->GetSlice(4)->SetTitle(Form(
"K: %.1f %%", PRatios[4]));
569 Int_t PrimRatiosColors[] = {6, 4};
575 fvMcPointPrimRatio[i]->GetSlice(0)->SetTitle(Form(
"Primary: %.1f %%", PrimRatios[0]));
576 fvMcPointPrimRatio[i]->GetSlice(1)->SetTitle(Form(
"Secondary: %.1f %%", PrimRatios[1]));
587 if (!FairRootManager::Instance() || !FairRootManager::Instance()->GetSink()) {
588 LOG(error) <<
"No sink found";
591 FairSink* sink = FairRootManager::Instance()->GetSink();
592 sink->WriteObject(&
GetQa(),
nullptr);
ClassImp(CbmMuchTransportQa)
Definition of the CbmMuchTransportQa class.
Definition of the CbmQaCanvas class.
Definition of the CbmQaPie class.
void SetIndex(int32_t index)
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataArray * InitBranch(const char *name)
int32_t GetMotherId() const
int32_t GetPdgCode() const
const CbmLink & GetLink(int32_t i) const
int32_t GetNofLinks() const
static int32_t GetStationIndex(int32_t address)
CbmMuchStation * GetStation(Int_t iStation) const
static CbmMuchGeoScheme * Instance()
Int_t GetNStations() const
void PositionIn(TVector3 &pos) const
void PositionOut(TVector3 &pos) const
Double_t GetTubeDz() const
TH1F * fhFractionPi
fraction of protons
std::vector< TH2F * > fvMcPointRZ
MC point Phi vs Z [N stations].
CbmMCDataArray * fMcTracks
void MakePrimRatioPieCharts()
CbmQaCanvas * fCanvStationRZ
TH1F * fhUsNtraMu
number of electrons
void Fill2dSpatialDistributionHistos(CbmMuchPoint *point, Int_t stId)
TParameter< int > fNevents
output folder with histos and canvases
void InitRatioPieCharts()
CbmMCDataArray * fPoints
containers
void FillCountingHistos(Int_t stId, Int_t motherId, Int_t pdgCode)
void InitFractionHistos()
void MakePRatioPieCharts()
TH1F * fhUsNtraPr
number of secondary tracks
CbmQaCanvas * fCanvStationPRatio
CbmQaCanvas * fCanvStationPhiZ
void Init2dSpatialDistributionHistos()
void Exec(Option_t *option)
TH1F * fhUsNtraKa
number of muons
virtual ~CbmMuchTransportQa()
Destructor.
TFolder fOutFolder
subfolder for histograms
std::vector< CbmQaPie * > fvMcPointPRatio
pointers to the above histos
std::vector< TH2F * > fvMcPointPhiZ
MC point Y vs X [N stations].
TH1F * fhFractionMu
fraction of electrons
FairRootManager * fManager
CbmQaCanvas * fCanvStationXY
MC point particle ratio pie charts [N stations].
std::vector< CbmQaPie * > fvMcPointPrimRatio
MC point particle ratio pie charts [N stations].
TH1F * fhFractionPr
fraction of secondary tracks
TH1F * fhUsNtraSec
number of primary tracks
TH1F * fhUsNtraAll
number of processed events
std::vector< TH1F * > fvUsNtra
number of kaons
TH1F * fhFractionSec
fraction of primary tracks
CbmMuchTransportQa(const char *name="MuchHitFinderQa", Int_t verbose=1)
Constructor.
void InitCountingHistos()
CbmMCDataManager * fMcManager
TH1F * fhFractionPrim
number of all tracks / event
TH1F * fhFractionKa
fraction of muons
TH1F * fhNtracks
MC point R vs Z [N stations].
TH1F * fhUsNtraPi
number of protons
void SetParContainers()
FairTask methods.
TH1F * fhUsNtraEl
number of pions
TH1F * fhUsNtraPrim
number of all tracks
std::vector< TH2F * > fvMcPointXY
pointers to the above fhUsNtra* histos
CbmQaCanvas * fCanvStationPrimRatio
TH1F * fhFractionEl
fraction of pions
std::vector< TH1F * > fvFraction
fraction of kaons
CbmTimeSlice * fTimeSlice
void Divide2D(int nPads)
Divide canvas into nPads in 2D in a nice way.
Data class with information on a STS local track.
Bookkeeping of time-slice content.
const CbmMatch & GetMatch() const