13#include "FairRootManager.h"
16#include "TClonesArray.h"
22#include "TProfile2D.h"
41 LOG(info) <<
"Trd Setup consist of " <<
fNofStation <<
" stations.";
50 FairRootManager* ioman = FairRootManager::Instance();
51 if (NULL == ioman) LOG(fatal) <<
"No FairRootManager!";
53 fTrdPoints =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"TrdPoint"));
54 if (NULL ==
fTrdPoints) LOG(error) <<
"No TrdPoint array!";
56 fMCTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack"));
57 if (NULL ==
fMCTracks) LOG(error) <<
"No MCTrack array!";
64 fHM->
Create1<TH1F>(
"h_trd_EventNo_MCQa",
"h_trd_EventNo_MCQa", 1, 0, 1.);
73 string name =
"h_trd_NofObjects_";
74 fHM->
Create1<TH1F>(name +
"Points", name +
"Points;Objects per event;Entries", nofBins, minX, maxX);
79 fHM->
Create1<TH1F>(name +
"Points_Station", name +
"Points_Station;Station number;Objects per event", nofBins, minX,
85 for (Int_t stationId = 0; stationId <
fNofStation; stationId++) {
89 fHM->
Create1<TH1F>(Form(
"h_trd_MultPoints_Station%i", stationId),
90 Form(
"Mult, Station %i;Objects per event;Entries", stationId), nofBins, minX, maxX);
92 fHM->
Create2<TH2F>(Form(
"h_trd_PointsMap_Station%i", stationId),
93 Form(
"TrdPoint, Station %i;x, cm;y, cm", stationId), 120, -60., 60., 120, -60., 60.);
94 fHM->
Create2<TH2F>(Form(
"h_trd_PointsMapEvent_Station%i", stationId),
95 Form(
"TrdPoint/cm^{2}, Station %i;x, cm;y, cm", stationId), 120, -60., 60., 120, -60., 60.);
96 fHM->
Create2<TH2F>(Form(
"h_trd_PointsMapRate_Station%i", stationId),
97 Form(
"TrdPoint/cm^{2}/s, Station %i;x, cm;y, cm", stationId), 120, -60., 60., 120, -60., 60.);
98 fHM->
Create1<TH1F>(Form(
"h_trd_XPos_Station%i", stationId),
"X position;x, cm; Entries", 1200, -60., 60.);
99 fHM->
Create1<TH1F>(Form(
"h_trd_YPos_Station%i", stationId),
"Y position;y, cm; Entries", 1200, -60., 60.);
101 fHM->
Create1<TH1F>(
"h_trd_XPos",
"X position;x, cm; Entries", 1200, -60., 60.);
102 fHM->
Create1<TH1F>(
"h_trd_YPos",
"Y position;y, cm; Entries", 1200, -60., 60.);
108 fHM->
H1(
"h_trd_EventNo_MCQa")->Fill(0.5);
114 fHM->
H1(
"h_trd_NofObjects_Points")->Fill(
points->GetEntriesFast());
116 Double_t pointX = 0.;
117 Double_t pointY = 0.;
120 std::map<Int_t, vector<Int_t>> used_map;
122 for (Int_t iPoint = 0; iPoint <
points->GetEntriesFast(); iPoint++) {
126 fHM->
H1(
"h_trd_NofObjects_Points_Station")->Fill(stationId);
128 pointX = trdPoint->
GetXIn();
129 pointY = trdPoint->
GetYIn();
132 fHM->
H1(Form(
"h_trd_XPos_Station%i", stationId))->Fill(pointX);
133 fHM->
H1(Form(
"h_trd_YPos_Station%i", stationId))->Fill(pointY);
135 fHM->
H2(Form(
"h_trd_PointsMap_Station%i", stationId))->Fill(pointX, pointY);
136 fHM->
H2(Form(
"h_trd_PointsMapEvent_Station%i", stationId))->Fill(pointX, pointY);
137 fHM->
H2(Form(
"h_trd_PointsMapRate_Station%i", stationId))->Fill(pointX, pointY);
138 fHM->
H1(
"h_trd_XPos")->Fill(pointX);
139 fHM->
H1(
"h_trd_YPos")->Fill(pointY);
141 Int_t mcTrackID = trdPoint->GetTrackID();
143 if (std::find(used_map[stationId].begin(), used_map[stationId].end(), mcTrackID) == used_map[stationId].end()) {
144 used_map[stationId].push_back(mcTrackID);
147 fHM->
H1(Form(
"h_trd_MultPoints_Station%i", 0))->Fill(used_map[0].
size());
148 fHM->
H1(Form(
"h_trd_MultPoints_Station%i", 1))->Fill(used_map[1].
size());
149 fHM->
H1(Form(
"h_trd_MultPoints_Station%i", 2))->Fill(used_map[2].
size());
150 fHM->
H1(Form(
"h_trd_MultPoints_Station%i", 3))->Fill(used_map[3].
size());
156 Int_t nofEvents =
fHM->
H1(
"h_trd_EventNo_MCQa")->GetEntries();
159 Int_t xbins = (
fHM->
H2(
"h_trd_PointsMap_Station0"))->GetXaxis()->GetNbins();
160 Float_t xmax =
fHM->
H2(
"h_trd_PointsMap_Station0")->GetXaxis()->GetXmax();
161 Float_t xmin =
fHM->
H2(
"h_trd_PointsMap_Station0")->GetXaxis()->GetXmin();
162 Float_t scaleX =
static_cast<Float_t
>(xbins) / (xmax - xmin);
164 Int_t ybins =
fHM->
H2(
"h_trd_PointsMap_Station0")->GetYaxis()->GetNbins();
165 Int_t ymax =
fHM->
H2(
"h_trd_PointsMap_Station0")->GetYaxis()->GetXmax();
166 Int_t ymin =
fHM->
H2(
"h_trd_PointsMap_Station0")->GetYaxis()->GetXmin();
167 Float_t scaleY =
static_cast<Float_t
>(ybins) / (ymax - ymin);
169 Float_t scale = scaleX * scaleY;
173 fHM->
Scale(Form(
"h_trd_PointsMapEvent_Station%i", i), scale / nofEvents);
174 fHM->
Scale(Form(
"h_trd_PointsMapRate_Station%i", i), 10000000. * scale / nofEvents);
177 gDirectory->mkdir(
"TrdMcQA");
178 gDirectory->cd(
"TrdMcQA");
180 gDirectory->cd(
"..");
Base class for simulation reports.
Helper class to convert unique channel ID back and forth.
static constexpr size_t size()
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 Scale(const std::string &histName, Double_t scale)
Scale histogram.
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.
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
void CreateNofObjectsHistograms()
TClonesArray * fTrdPoints
virtual void Exec(Option_t *)
virtual InitStatus Init()
void CreatePointHistograms()
void ProcessPoints(const TClonesArray *)
int32_t GetModuleAddress() const