13#include "BmnDchTrack.h"
15#include "BmnGemStripHit.h"
16#include "BmnGlobalTrack.h"
17#include "BmnHistManager.h"
19#include "BmnSiBTHit.h"
20#include "BmnSiliconHit.h"
23#include "CbmBaseHit.h"
24#include "CbmStsTrack.h"
26#include "FairRunAna.h"
27#include "TClonesArray.h"
43 , fGlobalTracks(nullptr)
45 , fSiBTTracks(nullptr)
50 , fTof400Hits(nullptr)
51 , fTof700Hits(nullptr)
54 , fDstEventHeader(nullptr)
72 fTicksLastUpdate = chrono::system_clock::now();
91 printf(
"EventCnt: %8d EventId: %8d RunId: %6u\n",
fEventNo,
fEventId, fRunId);
97 chrono::time_point<chrono::system_clock> now = chrono::system_clock::now();
98 chrono::seconds time = chrono::duration_cast<chrono::seconds>(now - fTicksLastUpdate);
101 if ((time > fTimeToUpdate) || (fNItersSinceUpdate > fNItersToUpdate)) {
104 printf(
"Draw! iters %d\n", fNItersSinceUpdate);
105 fTicksLastUpdate = now;
106 fNItersSinceUpdate = 0;
124void BmnTrackingQaExp::ReadDataBranches()
126 FairRootManager* ioman = FairRootManager::Instance();
127 if (
nullptr == ioman)
128 Fatal(
"Init",
"BmnRootManager is not instantiated");
130 fGlobalTracks = (TClonesArray*)ioman->GetObject(
"BmnGlobalTrack");
131 fStsTracks = (TClonesArray*)ioman->GetObject(
"StsVector");
133 fStsHits = (TClonesArray*)ioman->GetObject(
"StsHit");
135 fTof400Hits = (TClonesArray*)ioman->GetObject(
"BmnTof400Hit");
136 fTof700Hits = (TClonesArray*)ioman->GetObject(
"BmnTof700Hit");
137 fDchTracks = (TClonesArray*)ioman->GetObject(
"BmnDchTrack");
138 fDstEventHeader =
static_cast<DstEventHeader*
>(ioman->GetObject(
"DstEventHeader."));
141 fSilHits = (TClonesArray*)ioman->GetObject(
"BmnSiliconHit");
147 if (fInnerTrackerSetup[
kGEM]) {
148 fGemHits = (TClonesArray*)ioman->GetObject(
"BmnGemStripHit");
154 if (fInnerTrackerSetup[
kCSC]) {
155 fCscHits = (TClonesArray*)ioman->GetObject(
"BmnCSCHit");
158 cout << fCscDetector->GetNStations() <<
" stations" << endl;
162 if (fInnerTrackerSetup[
kCSC]) {
163 fVspHits = (TClonesArray*)ioman->GetObject(
"BmnVSPHit");
166 cout << fVspDetector->GetNStations() <<
" stations" << endl;
170 fSiBTHits = (TClonesArray*)ioman->GetObject(
"BmnSiBTHit");
171 fSiBTTracks = (TClonesArray*)ioman->GetObject(
"BmnBeamTrack");
173 fVertexL1 = (
CbmVertex*)ioman->GetObject(
"PrimaryVertex.");
175 printf(
"\nBRANCHES READ\n\n");
178void BmnTrackingQaExp::CreateHistograms()
184 CreateH1(
"NGlobTr",
"Number of Global tracks",
"Counter", 20, 0, 20);
185 CreateH1(
"NInnTr",
"Number of Inner tracks",
"Counter", 20, 0, 20);
187 CreateH1(
"NGemHits",
"Number of GEM hits",
"Counter", 50, 0, 50);
188 CreateH1(
"NVspHits",
"Number of VSP hits",
"Counter", 50, 0, 50);
189 CreateH1(
"NSilHits",
"Number of Si hits",
"Counter", 50, 0, 50);
190 CreateH1(
"NTof400Hits",
"Number of Tof400 hits",
"Counter", 50, 0, 50);
191 CreateH1(
"NTof700Hits",
"Number of Tof700 hits",
"Counter", 200, 0, 200);
192 CreateH1(
"NsCSC1Hits",
"Number of hits in small CSC1",
"Counter", 50, 0, 50);
193 CreateH1(
"NsCSC2Hits",
"Number of hits in small CSC2",
"Counter", 50, 0, 50);
194 CreateH1(
"NsCSC3Hits",
"Number of hits in small CSC3",
"Counter", 50, 0, 50);
195 CreateH1(
"NsCSC4Hits",
"Number of hits in small CSC4",
"Counter", 50, 0, 50);
196 CreateH1(
"NlCSC5Hits",
"Number of hits in 1st large CSC",
"Counter", 50, 0, 50);
197 CreateH1(
"NlCSC6Hits",
"Number of hits in 2nd large CSC",
"Counter", 50, 0, 50);
198 CreateH1(
"NSiBTHits",
"Number of SiBT hits",
"Counter", 50, 0, 50);
200 CreateH1(
"VertX",
"V_{x}, cm",
"Counter", 200, -5.0, 5.0);
201 CreateH1(
"VertY",
"V_{y}, cm",
"Counter", 200, -5.0, 5.0);
202 CreateH1(
"VertZ",
"V_{z}, cm",
"Counter", 200, -10.0, 10.0);
203 CreateH2(
"VertXY",
"V_{x}, cm",
"V_{y}, cm",
"", 200, -5.0, 5.0, 200, -5.0, 5.0);
204 CreateH2(
"VertZX",
"V_{z}, cm",
"V_{x}, cm",
"", 200, -20.0, 20.0, 200, -5.0, 5.0);
205 CreateH2(
"VertZY",
"V_{z}, cm",
"V_{y}, cm",
"", 200, -20.0, 20.0, 200, -5.0, 5.0);
206 CreateH2(
"VertX_vs_Ntracks",
"Number of tracks",
"V_{x}, cm",
"", 20, 0, 20, 200, -5.0, 5.0);
207 CreateH2(
"VertY_vs_Ntracks",
"Number of tracks",
"V_{y}, cm",
"", 20, 0, 20, 200, -5.0, 5.0);
208 CreateH2(
"VertZ_vs_Ntracks",
"Number of tracks",
"V_{z}, cm",
"", 20, 0, 20, 200, -10.0, 10.0);
209 CreateH1(
"NtrInVertex",
"Number of tracks in vertex",
"Counter", 10, 0.0, 10.0);
211 CreateH1(
"Rigidity",
"P/Q, GeV/c/Q",
"", 200, -10.0, 10.0);
213 CreateH2(
"banana_tof400",
"P_{rec}/Q, GeV/c",
"#beta_{rec}",
"", 200, -4, 10, 200, 0.0, 1.1);
214 CreateH2(
"banana_tof700",
"P_{rec}/Q, GeV/c",
"#beta_{rec}",
"", 200, -4, 10, 200, 0.0, 1.1);
217 CreateH2(
"x_vs_y_SiBT_st0",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
218 CreateH2(
"x_vs_y_SiBT_st1",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
219 CreateH2(
"x_vs_y_SiBT_st2",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
221 CreateH2(
"x_vs_y_SiBT_st0_meanInEvent",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
222 CreateH2(
"x_vs_y_SiBT_st1_meanInEvent",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
223 CreateH2(
"x_vs_y_SiBT_st2_meanInEvent",
"x cm",
"y cm",
"", 250, -5, 5, 250, -5, 5);
225 CreateH1(
"NumberOfHitsInEvent_st0",
"NHits",
"", 20, 0, 20);
226 CreateH1(
"NumberOfHitsInEvent_st1",
"NHits",
"", 20, 0, 20);
227 CreateH1(
"NumberOfHitsInEvent_st2",
"NHits",
"", 20, 0, 20);
233 CreateH2(
"VertexX_vs_SiBTTracksX",
"vertex: x cm",
"sibt: x cm",
"", 200, -5, 5, 200, -5, 5);
234 CreateH2(
"VertexY_vs_SiBTTracksY",
"vertex: y cm",
"sibt: y cm",
"", 200, -5, 5, 200, -5, 5);
237 for (Int_t iSt = 0; iSt < 9; ++iSt) {
238 CreateH1(Form(
"ResX_%dst", iSt),
"ResX, cm",
"Counter", 100, -0.5, 0.5);
239 CreateH1(Form(
"ResY_%dst", iSt),
"ResY, cm",
"Counter", 100, -0.5, 0.5);
243 if (fInnerTrackerSetup[
kGEM])
245 if (fInnerTrackerSetup[
kCSC])
247 if (fInnerTrackerSetup[
kVSP])
252 printf(
"\nHISTOGRAMS CREATED!\n\n");
255void BmnTrackingQaExp::ProcessGlobal()
257 fRunId = fDstEventHeader->GetRunId();
260 printf(
"run id change %u -> %u\n",
fPrevRunId, fRunId);
264 if (fVertexL1 !=
nullptr) {
266 fHM->
H1(
"VertX")->Fill(fVertexL1->
GetX());
267 fHM->
H1(
"VertY")->Fill(fVertexL1->
GetY());
268 fHM->
H1(
"VertZ")->Fill(fVertexL1->
GetZ());
269 fHM->
H1(
"VertXY")->Fill(fVertexL1->
GetX(), fVertexL1->
GetY());
270 fHM->
H1(
"VertZX")->Fill(fVertexL1->
GetZ(), fVertexL1->
GetX());
271 fHM->
H1(
"VertZY")->Fill(fVertexL1->
GetZ(), fVertexL1->
GetY());
280 fHM->
H1(
"NGlobTr")->Fill(fGlobalTracks->GetEntriesFast());
282 for (Int_t iTrack = 0; iTrack < fGlobalTracks->GetEntriesFast(); iTrack++) {
289 fHM->
H1(
"Rigidity")->Fill(1.0 / pf->GetQp());
322 fHM->
H1(
"NSiBTHits")->Fill(fSiBTHits->GetEntriesFast());
325 Double_t AllEnergy[3] = {0};
326 Double_t TotalSignal = 0;
327 Int_t siBT_station = 0;
328 Int_t NumberOfHitsInStation[3] = {0};
329 for (Int_t iSiBTHit = 0; iSiBTHit < fSiBTHits->GetEntriesFast(); ++iSiBTHit) {
333 fHM->
H2(Form(
"x_vs_y_SiBT_st%d", siBT_station))->Fill(hit->GetX(), hit->GetY());
336 x[siBT_station] += hit->GetX() * TotalSignal;
337 y[siBT_station] += hit->GetY() * TotalSignal;
339 NumberOfHitsInStation[siBT_station]++;
341 AllEnergy[siBT_station] += TotalSignal;
343 if (NumberOfHitsInStation[0] != 0)
344 fHM->
H2(
"x_vs_y_SiBT_st0_meanInEvent")->Fill(x[0] / AllEnergy[0], y[0] / AllEnergy[0]);
345 if (NumberOfHitsInStation[1] != 0)
346 fHM->
H2(
"x_vs_y_SiBT_st1_meanInEvent")->Fill(x[1] / AllEnergy[1], y[1] / AllEnergy[1]);
347 if (NumberOfHitsInStation[2] != 0)
348 fHM->
H2(
"x_vs_y_SiBT_st2_meanInEvent")->Fill(x[2] / AllEnergy[2], y[2] / AllEnergy[2]);
350 fHM->
H1(
"NumberOfHitsInEvent_st0")->Fill(NumberOfHitsInStation[0]);
351 fHM->
H1(
"NumberOfHitsInEvent_st1")->Fill(NumberOfHitsInStation[1]);
352 fHM->
H1(
"NumberOfHitsInEvent_st2")->Fill(NumberOfHitsInStation[2]);
356 FairTrackParam* paramLast;
357 for (Int_t iSiBTTrack = 0; iSiBTTrack < fSiBTTracks->GetEntriesFast(); ++iSiBTTrack) {
365 if (fVertexL1 !=
nullptr) {
367 fHM->
H2(
"VertexX_vs_SiBTTracksX")->Fill(fVertexL1->
GetX(), paramLast->GetX());
368 fHM->
H2(
"VertexY_vs_SiBTTracksY")->Fill(fVertexL1->
GetY(), paramLast->GetY());
374 fHM->
H1(
"NSilHits")->Fill(fSilHits->GetEntriesFast());
378 fHM->
H1(
"NGemHits")->Fill(fGemHits->GetEntriesFast());
382 Int_t numberOfHits[6]{};
383 for (Int_t iHit = 0; iHit < fCscHits->GetEntriesFast(); ++iHit) {
384 BmnHit* cscHit =
dynamic_cast<BmnHit*
>(fCscHits->At(iHit));
387 fHM->
H1(
"NsCSC1Hits")->Fill(numberOfHits[0]);
388 fHM->
H1(
"NsCSC2Hits")->Fill(numberOfHits[1]);
389 fHM->
H1(
"NsCSC3Hits")->Fill(numberOfHits[2]);
390 fHM->
H1(
"NsCSC4Hits")->Fill(numberOfHits[3]);
391 fHM->
H1(
"NlCSC5Hits")->Fill(numberOfHits[4]);
392 fHM->
H1(
"NlCSC6Hits")->Fill(numberOfHits[5]);
397 fHM->
H1(
"NVspHits")->Fill(fVspHits->GetEntriesFast());
401 fHM->
H1(
"NTof400Hits")->Fill(fTof400Hits->GetEntriesFast());
405 fHM->
H1(
"NTof700Hits")->Fill(fTof700Hits->GetEntriesFast());
409 fHM->
H1(
"NInnTr")->Fill(fStsTracks->GetEntriesFast());
415 printf(
"ResetSiBT DST\n");
416 fHM->
H2(
"x_vs_y_SiBT_st0")->Reset();
417 fHM->
H2(
"x_vs_y_SiBT_st1")->Reset();
418 fHM->
H2(
"x_vs_y_SiBT_st2")->Reset();
419 fHM->
H2(
"x_vs_y_SiBT_st0_meanInEvent")->Reset();
420 fHM->
H2(
"x_vs_y_SiBT_st1_meanInEvent")->Reset();
421 fHM->
H2(
"x_vs_y_SiBT_st2_meanInEvent")->Reset();
426 fHM->
H2(
"VertexX_vs_SiBTTracksX")->Reset();
427 fHM->
H2(
"VertexY_vs_SiBTTracksY")->Reset();
428 fHM->
H2(
"NumberOfHitsInEvent_st0")->Reset();
429 fHM->
H2(
"NumberOfHitsInEvent_st1")->Reset();
430 fHM->
H2(
"NumberOfHitsInEvent_st2")->Reset();
437 string path = string(
"/") + fName.Data() +
"_cmd/";
438 string cmd = string(
"/") + fName.Data() +
"/->ResetSiBT()";
439 string cmdTitle = path +
"ResetSiBT";
440 fServer->RegisterCommand(cmdTitle.data(), cmd.data(),
"button;");
447 detName = detName +
"_X_Y";
455 detName = detName +
"_X_Y";
456 for (Int_t iHit = 0; iHit < tof_hits->GetEntriesFast(); ++iHit) {
458 fHM->
H2(detName)->Fill(hit->GetX(), hit->GetY());
Global function to define the track acceptance. Used in QA.
FairTask for tracking performance calculation.
static unique_ptr< BmnCSCStationSet > Create(Int_t period, Int_t stp=0)
static void GetSystemNameCaps(DetectorId det, TString &name)
static unique_ptr< BmnGemStripStationSet > Create(Int_t period, Int_t stp=0)
Int_t GetTof2HitIndex() const
Int_t GetDch2TrackIndex() const
Double_t GetBeta(Int_t tofID) const
Int_t GetTof1HitIndex() const
Int_t GetDch1TrackIndex() const
void ResetHists()
Reset all histograms.
TH2 * H2(const TString &name) const
Return pointer to TH2 histogram.
TH1 * H1(const TString &name) const
Return pointer to TH1 histogram.
Short_t GetStation() const
void CreateStripHits(SST &ss, DetectorId detId)
void CreateH1(const string &name, const string &xTitle, const string &yTitle, Int_t nofBins, Double_t minBin, Double_t maxBin)
BmnSimulationReport * fReport
void CreateH2(const string &name, const string &xTitle, const string &yTitle, const string &zTitle, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
void FillStripHits(DetectorId detId, TClonesArray *hits)
void SetMonitorMode(const Bool_t mm)
void SetObjServer(THttpServer *s)
void Register(string path)
Double_t GetStripTotalSignalInUpperLayer()
Double_t GetStripTotalSignalInLowerLayer()
static unique_ptr< BmnSiliconStationSet > Create(Int_t period, Int_t stp=0)
void SetHM(BmnHistManager *hm)
void Create(BmnHistManager *histManager, const string &outputDir)
Main function which creates report data.
void AddStationSet(DetectorId id, void *ss)
FairTrackParam * GetParamFirst()
FairTrackParam * GetParamLast()
Create report for tracking QA.
BmnTrackingQaExp()
Constructor.
virtual ~BmnTrackingQaExp()
Destructor.
void FillTofHits(TClonesArray *tof_hits, DetectorId detId)
virtual InitStatus Init()
Derived from FairTask.
virtual void Finish()
Derived from FairTask.
virtual void Exec(Option_t *opt)
Derived from FairTask.
void CreateTofHits(DetectorId detId)
static unique_ptr< BmnVSPStationSet > Create(Int_t period, Int_t stp=0)
void SetDefaultDrawStyle()
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
vector< string > Split(const string &name, char delimiter)