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