BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
drawResidualsBMN.C
Go to the documentation of this file.
1
2
#include <FairHit.h>
3
#include <
Rtypes.h
>
4
#include <
TCanvas.h
>
5
#include <
TChain.h
>
6
#include <
TClonesArray.h
>
7
#include <
TFitResultPtr.h
>
8
#include <
TGraph.h
>
9
#include <
TH2F.h
>
10
#include <
TLatex.h
>
11
#include <
TString.h
>
12
#include <
TStyle.h
>
13
14
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
15
#include "macro/run/bmnloadlibs.C"
16
//
17
void
drawResidualsBMN
(
TString
fileName =
"/home/merz/pavel/nfs/RUN7_res/BMNDST_4649.root"
,
Int_t
nEvents = 10000)
18
{
19
bmnloadlibs();
// load libraries
20
21
TChain
* out =
new
TChain
(
"bmndata"
);
22
out->
Add
(fileName.Data());
23
24
cout <<
"#recorded entries = "
<< out->
GetEntries
() << endl;
25
26
TClonesArray
* dchTracks =
nullptr
;
27
out->
SetBranchAddress
(
"BmnDchTrack"
, &dchTracks);
28
TClonesArray
* gemTracks =
nullptr
;
29
out->
SetBranchAddress
(
"BmnGemTrack"
, &gemTracks);
30
TClonesArray
* cscHits =
nullptr
;
31
out->
SetBranchAddress
(
"BmnCSCHit"
, &cscHits);
32
TClonesArray
* tof700Hits =
nullptr
;
33
out->
SetBranchAddress
(
"BmnTof700Hit"
, &tof700Hits);
34
TClonesArray
* tof400Hits =
nullptr
;
35
out->
SetBranchAddress
(
"BmnTof400Hit"
, &tof400Hits);
36
37
const
Int_t
nDet = 3;
38
const
Int_t
nRes = 2;
39
40
TString
namesDet[nDet] = {
"CSC"
,
"TOF-400"
,
"TOF-700"
};
41
TString
namesRes[nRes] = {
"X-residuals"
,
"Y-residuals"
};
42
43
gStyle
->SetOptStat(0);
44
gStyle
->SetPalette(53);
//(kGreyScale);
45
46
TH2F
* histByEv[nDet][nRes];
47
TH1F
* hist[nDet][nRes];
48
for
(
Int_t
iDet = 0; iDet < nDet; iDet++) {
49
for
(
Int_t
jRes = 0; jRes < nRes; jRes++) {
50
TString
histName = namesDet[iDet] + namesRes[jRes];
51
TString
histNameEv = namesDet[iDet] + namesRes[jRes] +
"Ev"
;
52
hist[iDet][jRes] =
new
TH1F
(histName,
""
, 100, -5, 5);
53
histByEv[iDet][jRes] =
new
TH2F
(histNameEv,
""
, nEvents, 0, nEvents, 100, -100, 100);
54
}
55
}
56
57
for
(
Int_t
iEv = 0; iEv < nEvents; iEv++) {
58
out->
GetEntry
(iEv);
59
if
(iEv % 1000 == 0)
60
printf(
"event: %d\n"
, iEv);
61
for
(
Int_t
iHit = 0; iHit < tof700Hits->
GetEntriesFast
(); iHit++) {
62
BmnHit
* hit = (
BmnHit
*)tof700Hits->
At
(iHit);
63
hist[2][0]->
Fill
(hit->
GetResX
());
64
hist[2][1]->
Fill
(hit->
GetResY
());
65
histByEv[2][0]->
Fill
(iEv, hit->
GetResX
());
66
histByEv[2][1]->
Fill
(iEv, hit->
GetResY
());
67
}
68
for
(
Int_t
iHit = 0; iHit < tof400Hits->
GetEntriesFast
(); iHit++) {
69
BmnHit
* hit = (
BmnHit
*)tof400Hits->
At
(iHit);
70
hist[1][0]->
Fill
(hit->
GetResX
());
71
hist[1][1]->
Fill
(hit->
GetResY
());
72
histByEv[1][0]->
Fill
(iEv, hit->
GetResX
());
73
histByEv[1][1]->
Fill
(iEv, hit->
GetResY
());
74
}
75
for
(
Int_t
iHit = 0; iHit < cscHits->
GetEntriesFast
(); iHit++) {
76
BmnHit
* hit = (
BmnHit
*)cscHits->
At
(iHit);
77
hist[0][0]->
Fill
(hit->
GetResX
());
78
hist[0][1]->
Fill
(hit->
GetResY
());
79
histByEv[0][0]->
Fill
(iEv, hit->
GetResX
());
80
histByEv[0][1]->
Fill
(iEv, hit->
GetResY
());
81
}
82
// for (Int_t iTrack = 0; iTrack < dchTracks->GetEntriesFast(); iTrack++) {
83
// BmnDchTrack* track = (BmnDchTrack*)dchTracks->At(iTrack);
84
// if (track->GetParamFirst()->GetZ() < 550.0) nDch1++;
85
// if (track->GetParamFirst()->GetZ() > 650.0) nDch2++;
86
// }
87
// Int_t nMwpc = 0;
88
// for (Int_t iTrack = 0; iTrack < MwpcTracks->GetEntriesFast(); iTrack++) {
89
// BmnMwpcTrack* track = (BmnMwpcTrack*)MwpcTracks->At(iTrack);
90
// if (track->GetParamFirst()->GetZ() > -300.0) nMwpc++;
91
// }
92
}
93
94
TCanvas
* res =
new
TCanvas
(
"res"
,
"res"
, 1000, 1000);
95
res->Divide(nDet, nRes, 0, 0);
96
for
(
Int_t
jRes = 0; jRes < nRes; jRes++) {
97
for
(
Int_t
iDet = 0; iDet < nDet; iDet++) {
98
Int_t
padId = iDet + nRes * jRes + 1;
99
TPad
* pad = (
TPad
*)res->cd(padId);
100
pad->
SetGrid
(0, 0);
101
hist[iDet][jRes]->
Fit
(
"gaus"
,
"WW"
);
102
hist[iDet][jRes]->
Draw
();
103
hist[iDet][jRes]->
GetXaxis
()->
SetLabelSize
(0.08);
104
TLatex
latexDet;
105
latexDet.
SetTextSize
(0.08);
106
latexDet.
DrawLatex
(-4.5, 0.9 * hist[iDet][jRes]->GetMaximum(), namesDet[iDet]);
107
TLatex
latexRes;
108
latexRes.
SetTextSize
(0.06);
109
latexRes.
DrawLatex
(-4.5, 0.8 * hist[iDet][jRes]->GetMaximum(), namesRes[jRes]);
110
}
111
}
112
res->SaveAs(
"ResidualsSRC.pdf"
);
113
114
TCanvas
* resEv =
new
TCanvas
(
"resEv"
,
"resEv"
, 1000, 1000);
115
resEv->
Divide
(nDet, nRes, 0, 0);
116
for
(
Int_t
jRes = 0; jRes < nRes; jRes++) {
117
for
(
Int_t
iDet = 0; iDet < nDet; iDet++) {
118
Int_t
padId = iDet + nRes * jRes + 1;
119
TPad
* pad = (
TPad
*)res->cd(padId);
120
pad->
SetGrid
(0, 0);
121
histByEv[iDet][jRes]->
Fit
(
"gaus"
,
"WW"
);
122
histByEv[iDet][jRes]->
Draw
();
123
histByEv[iDet][jRes]->
GetXaxis
()->
SetLabelSize
(0.08);
124
TLatex
latexDet;
125
latexDet.
SetTextSize
(0.08);
126
latexDet.
DrawLatex
(-4.5, 0.9 * hist[iDet][jRes]->GetMaximum(), namesDet[iDet]);
127
TLatex
latexRes;
128
latexRes.
SetTextSize
(0.06);
129
latexRes.
DrawLatex
(-4.5, 0.8 * hist[iDet][jRes]->GetMaximum(), namesRes[jRes]);
130
}
131
}
132
res->SaveAs(
"ResidualsSRCEv.pdf"
);
133
}
Int_t
int Int_t
Rtypes.h
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
TCanvas.h
TChain.h
TClonesArray.h
TFitResultPtr.h
TGraph.h
TH2F.h
TLatex.h
TString.h
TStyle.h
gStyle
R__EXTERN TStyle * gStyle
BmnHit
Definition
BmnHit.h:21
BmnHit::GetResX
Double_t GetResX()
Definition
BmnHit.h:40
BmnHit::GetResY
Double_t GetResY()
Definition
BmnHit.h:41
TAttAxis::SetLabelSize
virtual void SetLabelSize(Float_t size=0.04)
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
TCanvas
TChain
TChain::SetBranchAddress
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
TChain::Add
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
TChain::GetEntries
Long64_t GetEntries() const override
TChain::GetEntry
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
TClonesArray
TH1F
TH1::GetXaxis
TAxis * GetXaxis()
TH1::Fit
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
TH1::Draw
void Draw(Option_t *option="") override
TH1::Fill
virtual Int_t Fill(const char *name, Double_t w)
TH2F
TH2::Fill
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
TLatex
TLatex::DrawLatex
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TPad
TPad::SetGrid
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
TPad::Divide
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
TString
drawResidualsBMN
void drawResidualsBMN(TString fileName="/home/merz/pavel/nfs/RUN7_res/BMNDST_4649.root", Int_t nEvents=10000)
Definition
drawResidualsBMN.C:17
macro
miscellaneous
drawResidualsBMN.C
Generated on
for BmnRoot by
1.17.0