BmnRoot
Loading...
Searching...
No Matches
BmnTof400Qa.cxx
Go to the documentation of this file.
1#include "BmnTof400Qa.h"
2#include <TStopwatch.h>
3#include "BmnGlobalTrack.h"
4#include <TFile.h>
5
6static Double_t fWorkTime = 0.0;
7
9 fStsTracks = nullptr;
10 fGlobalTracks = nullptr;
11 fKalman = nullptr;
12 fTof400Hits = nullptr;
13 fHistoManager = new BmnQaHistoManager();
14}
15
16InitStatus BmnTof400Qa::Init() {
17
18 TStopwatch sw;
19 sw.Start();
20 fKalman = new BmnKalmanFilter();
21
22 FairRootManager* ioman = FairRootManager::Instance();
23 if (!ioman)
24 Fatal("Init", "FairRootManager is not instantiated");
25
26 fTof400Hits = (TClonesArray*)ioman->GetObject("BmnTof400Hit");
27 fStsTracks = (TClonesArray*)ioman->GetObject("StsVector");
28 fGlobalTracks = (TClonesArray*)ioman->GetObject("BmnGlobalTrack");
29
30 fHistoManager->Create1 <TH1F>("TOF400_ResidX_total", "Total residuals in X coordinate; dX, cm; N", 100, -5.0, 5.0);
31 fHistoManager->Create1 <TH1F>("TOF400_ResidY_total", "Total residuals in Y coordinate; dY, cm; N", 100, -5.0, 5.0);
32 fHistoManager->Create2 <TH2F>("TOF400_Banan_total", "Total #beta vs rigidity; rigidity, GeV/c/Q; #beta", 400, -5.0, 10.0, 400, 0.2, 1.1);
33 fHistoManager->Create2 <TH2F>("TOF400_Mass2_total", "Total m^{2} vs rigidity; rigidity, GeV/c/Q; m^{2}", 400, -5.0, 10.0, 400, -0.5, 10.0);
34
35 for (Int_t i = 0; i < nModules; ++i) {
36 fHistoManager->Create1 <TH1F>(Form("TOF400_ResidX_%d", i), Form("Residuals in X coordinate for module %d; dX, cm; N", i), 100, -5.0, 5.0);
37 fHistoManager->Create1 <TH1F>(Form("TOF400_ResidY_%d", i), Form("Residuals in Y coordinate for module %d; dY, cm; N", i), 100, -5.0, 5.0);
38 }
39
40 tof400Dir = gFile->mkdir("TOF400");
41
42 sw.Stop();
43 fWorkTime += sw.RealTime();
44
45 return kSUCCESS;
46}
47
48void BmnTof400Qa::Exec(Option_t* opt) {
49
50 TStopwatch sw;
51 sw.Start();
52
53 if (!IsActive()) return;
54 for (Int_t iTr = 0; iTr < fGlobalTracks->GetEntriesFast(); ++iTr) {
55 BmnGlobalTrack* track = (BmnGlobalTrack*)fGlobalTracks->At(iTr);
56 if (track->GetTof1HitIndex() == -1) continue;
57 BmnTofHit* hit = (BmnTofHit*)fTof400Hits->At(track->GetTof1HitIndex());
58 fHistoManager->H1("TOF400_ResidX_total")->Fill(hit->GetResX());
59 fHistoManager->H1("TOF400_ResidY_total")->Fill(hit->GetResY());
60 Int_t mod = ((hit->GetDetectorID() & 0x0000FF00) >> 8) - 1;
61 fHistoManager->H1(Form("TOF400_ResidX_%d", mod))->Fill(hit->GetResX());
62 fHistoManager->H1(Form("TOF400_ResidY_%d", mod))->Fill(hit->GetResY());
63 fHistoManager->H2("TOF400_Banan_total")->Fill(track->GetP(), track->GetBeta(1));
64 fHistoManager->H2("TOF400_Mass2_total")->Fill(track->GetP(), track->GetMass2(1));
65 }
66
67 sw.Stop();
68 fWorkTime += sw.RealTime();
69
70}
71
73
74 TStopwatch sw;
75 sw.Start();
76
77 for (Int_t i = 0; i < nModules; ++i) {
78 fHistoManager->H1(Form("TOF400_ResidX_%d", i))->Fit("gaus", "QSR", "", -2, 2);
79 fHistoManager->H1(Form("TOF400_ResidY_%d", i))->Fit("gaus", "QSR", "", -2, 2);
80 }
81
82 tof400Dir->cd();
83 fHistoManager->WriteToFile();
84
85 sw.Stop();
86 fWorkTime += sw.RealTime();
87
88 printf("Work time of BmnTof400Qa: %4.2f sec.\n", fWorkTime);
89}
int i
Definition P4_F32vec4.h:22
Double_t GetMass2(Int_t tofID)
Double_t GetBeta(Int_t tofID) const
Int_t GetTof1HitIndex() const
TH2 * H2(const TString &name) const
Return pointer to TH2 histogram.
void WriteToFile()
Write all histograms to current opened file.
void Create2(const TString &name, const TString &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 Create1(const TString &name, const TString &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 TString &name) const
Return pointer to TH1 histogram.
Double_t GetResX()
Definition BmnHit.h:98
Double_t GetResY()
Definition BmnHit.h:102
virtual InitStatus Init()
virtual void Finish()
virtual void Exec(Option_t *opt)
Double_t GetP()
Definition BmnTrack.h:80