BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnResultsZDC.C
Go to the documentation of this file.
1
2
using namespace
std
;
3
4
void
BmnResultsZDC
(
char
* fname =
"../raw/bmn_run0871_digi.root"
)
5
{
6
gROOT
->LoadMacro(
"$VMCWORKDIR/macro/run/bmnloadlibs.C"
);
7
bmnloadlibs();
8
/////////////////////////////////////////////////////////////////////////////////////
9
TChain
* bmnTree =
new
TChain
(
"cbmsim"
);
10
bmnTree->
Add
(fname);
11
12
TClonesArray
* zdcDigits;
13
bmnTree->
SetBranchAddress
(
"ZDC"
, &zdcDigits);
14
15
Int_t
startEvent = 0;
16
Int_t
nEvents = bmnTree->
GetEntries
();
17
18
gStyle
->SetOptFit(111);
19
20
char
name[64], title[64];
21
TH1F
* hamp = 0;
22
sprintf(name,
"hamp"
);
23
sprintf(title,
"Module amplitude"
);
24
hamp =
new
TH1F
(name, title, 500, 0, 1000);
25
TH1F
* hsum =
new
TH1F
(
"hsum"
,
"Sum of amplitudes"
, 1000, 0, 5000);
26
TH2F
* hpro =
new
TH2F
(
"hpro"
,
"Cluster profile"
, 22, -76 * 11, 76 * 11, 14, -76 * 7, 76 * 7);
27
/////////////////////////////////////////////////////////////////////////////////////
28
29
for
(
Int_t
iEv = startEvent; iEv < startEvent + nEvents; iEv++) {
30
bmnTree->
GetEntry
(iEv);
31
32
if
(iEv % 10000 == 0)
33
cout <<
"Event: "
<< iEv <<
"/"
<< startEvent + nEvents << endl;
34
35
Float_t
sum = 0.;
36
37
int
xbin = 0;
38
for
(
Int_t
iDig = 0; iDig < zdcDigits->
GetEntriesFast
(); ++iDig) {
39
BmnZDCDigit
* digit = (
BmnZDCDigit
*)zdcDigits->
At
(iDig);
40
if
(digit == NULL)
41
continue
;
42
Short_t
chan = digit->
GetChannel
();
43
Float_t
ampl = digit->
GetAmp
();
44
Float_t
x = digit->
GetX
();
45
Float_t
y = digit->
GetY
();
46
if
(ampl > 0.)
47
hamp->
Fill
(ampl);
48
if
(digit->
GetSize
() == 1)
49
hpro->
Fill
(x, y, ampl);
50
else
// equalization for BIG modules
51
{
52
xbin = hpro->
FindBin
(x + 5., y + 5.);
53
hpro->
SetBinContent
(xbin, ampl / 4.);
54
xbin = hpro->
FindBin
(x + 5., y - 5.);
55
hpro->
SetBinContent
(xbin, ampl / 4.);
56
xbin = hpro->
FindBin
(x - 5., y + 5.);
57
hpro->
SetBinContent
(xbin, ampl / 4.);
58
xbin = hpro->
FindBin
(x - 5., y - 5.);
59
hpro->
SetBinContent
(xbin, ampl / 4.);
60
}
61
sum += ampl;
62
}
63
if
(sum > 0.)
64
hsum->
Fill
(sum);
65
}
66
/////////////////////////////////////////////////////////////////////////////////////
67
TCanvas
* c =
new
TCanvas
(
"c"
,
"Channel Amplitudes"
, 700, 900);
68
c->
cd
();
69
c->
Divide
(1, 1);
70
c->
cd
(1);
71
hamp->
Draw
();
72
gPad
->AddExec(
"exsel"
,
"select_hist()"
);
73
74
TCanvas
* c1 =
new
TCanvas
(
"c1"
,
"Sum of Channel Amplitudes"
, 700, 900);
75
c1->
cd
();
76
c1->
Divide
(1, 1);
77
c1->
cd
(1);
78
hsum->
Draw
();
79
80
TCanvas
* c2 =
new
TCanvas
(
"c2"
,
"Average Shape"
, 700, 900);
81
c2->
cd
();
82
c2->
Divide
(1, 1);
83
c2->
cd
(1);
84
hpro->
Draw
();
85
}
86
87
void
select_hist
()
88
{
89
// example of macro called when a mouse event occurs in a pad.
90
// Example:
91
// Root > TFile f("hsimple.root");
92
// Root > hpxpy.Draw();
93
// Root > c1.AddExec("exsel","select_hist()");
94
// When moving the mouse in the canvas, a second canvas shows the
95
// projection along X of the bin corresponding to the Y position
96
// of the mouse. The resulting histogram is fitted with a gaussian.
97
// A "dynamic" line shows the current bin position in Y.
98
// This more elaborated example can be used as a starting point
99
// to develop more powerful interactive applications exploiting CINT
100
// as a development engine.
101
// Author: Rene Brun
102
103
int
event
=
gPad
->GetEvent();
104
if
(event != 11)
105
return
;
106
107
TObject
* select =
gPad
->GetSelected();
108
if
(!select)
109
return
;
110
if
(!(select->InheritsFrom(
"TH1"
)))
111
return
;
112
113
// create or set the new canvas c2
114
TCanvas
* csingle = 0;
115
if
((csingle = (
TCanvas
*)
gROOT
->GetListOfCanvases()->FindObject(
"csingle"
)))
116
;
117
else
118
csingle =
new
TCanvas
(
"csingle"
);
119
csingle->
cd
();
120
121
// draw slice corresponding to mouse position
122
if
(!(select->InheritsFrom(
"TH1F"
))) {
123
TH1F
* h = (
TH1F
*)select;
124
h->
Draw
();
125
}
else
if
(!(select->InheritsFrom(
"TH2F"
))) {
126
TH2F
* h = (
TH2F
*)select;
127
h->
Draw
();
128
}
else
if
(!(select->InheritsFrom(
"TProfile"
))) {
129
TProfile
* h = (
TProfile
*)select;
130
h->
Draw
();
131
}
else
if
(!(select->InheritsFrom(
"TH1D"
))) {
132
TH1D
* h = (
TH1D
*)select;
133
h->
Draw
();
134
}
else
if
(!(select->InheritsFrom(
"TH2D"
))) {
135
TH2D
* h = (
TH2D
*)select;
136
h->
Draw
();
137
}
else
if
(!(select->InheritsFrom(
"TProfile2D"
))) {
138
TProfile2D
* h = (
TProfile2D
*)select;
139
h->
Draw
();
140
}
else
141
return
;
142
csingle->
Update
();
143
}
Int_t
int Int_t
Float_t
float Float_t
Short_t
short Short_t
gROOT
#define gROOT
gStyle
R__EXTERN TStyle * gStyle
gPad
#define gPad
BmnCaloDigit::GetX
Float_t GetX() const
Definition
BmnCaloDigit.h:31
BmnCaloDigit::GetChannel
UShort_t GetChannel() const
Definition
BmnCaloDigit.h:33
BmnCaloDigit::GetY
Float_t GetY() const
Definition
BmnCaloDigit.h:32
BmnCaloDigit::GetAmp
Float_t GetAmp() const
Definition
BmnCaloDigit.h:34
BmnZDCDigit
Definition
BmnZDCDigit.h:7
BmnZDCDigit::GetSize
UChar_t GetSize() const
Definition
BmnZDCDigit.h:38
TCanvas
TCanvas::cd
TVirtualPad * cd(Int_t subpadnumber=0) override
TCanvas::Update
void Update() override
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
TH1D
TH1F
TH1::Draw
void Draw(Option_t *option="") override
TH1::Fill
virtual Int_t Fill(const char *name, Double_t w)
TH1::FindBin
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
TH2D
TH2F
TH2::Fill
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
TH2::SetBinContent
void SetBinContent(Int_t bin, Double_t content) override
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObject
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
TProfile2D
TProfile
BmnResultsZDC
void BmnResultsZDC(char *fname="../raw/bmn_run0871_digi.root")
Definition
BmnResultsZDC.C:4
select_hist
void select_hist()
Definition
BmnResultsZDC.C:87
std
Definition
json.hpp:4446
install
macro
detectors
zdc
BmnResultsZDC.C
Generated on
for BmnRoot by
1.17.0