BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnResultsECAL.C
Go to the documentation of this file.
1
2using namespace std;
3
4void BmnResultsECAL(char* fname = "bmn_run4926_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* ecalDigits;
13 bmnTree->SetBranchAddress("ECAL", &ecalDigits);
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", 30, 0, 30 * 40, 12, 0, 12 * 40);
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 < ecalDigits->GetEntriesFast(); ++iDig) {
39 BmnECALDigit* digit = (BmnECALDigit*)ecalDigits->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 (ampl > 0.)
49 hpro->Fill(x, y, ampl);
50 sum += ampl;
51 }
52 if (sum > 0.)
53 hsum->Fill(sum);
54 }
55 /////////////////////////////////////////////////////////////////////////////////////
56 TCanvas* c = new TCanvas("c", "Channel Amplitudes", 700, 900);
57 c->cd();
58 c->Divide(1, 1);
59 c->cd(1);
60 hamp->Draw();
61 gPad->AddExec("exsel", "select_hist()");
62
63 TCanvas* c1 = new TCanvas("c1", "Sum of Channel Amplitudes", 700, 900);
64 c1->cd();
65 c1->Divide(1, 1);
66 c1->cd(1);
67 hsum->Draw();
68
69 TCanvas* c2 = new TCanvas("c2", "Average Shape", 700, 900);
70 c2->cd();
71 c2->Divide(1, 1);
72 c2->cd(1);
73 hpro->Draw();
74}
75
77{
78 // example of macro called when a mouse event occurs in a pad.
79 // Example:
80 // Root > TFile f("hsimple.root");
81 // Root > hpxpy.Draw();
82 // Root > c1.AddExec("exsel","select_hist()");
83 // When moving the mouse in the canvas, a second canvas shows the
84 // projection along X of the bin corresponding to the Y position
85 // of the mouse. The resulting histogram is fitted with a gaussian.
86 // A "dynamic" line shows the current bin position in Y.
87 // This more elaborated example can be used as a starting point
88 // to develop more powerful interactive applications exploiting CINT
89 // as a development engine.
90 // Author: Rene Brun
91
92 int event = gPad->GetEvent();
93 if (event != 11)
94 return;
95
96 TObject* select = gPad->GetSelected();
97 if (!select)
98 return;
99 if (!(select->InheritsFrom("TH1")))
100 return;
101
102 // create or set the new canvas c2
103 TCanvas* csingle = 0;
104 if ((csingle = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("csingle")))
105 ;
106 else
107 csingle = new TCanvas("csingle");
108 csingle->cd();
109
110 // draw slice corresponding to mouse position
111 if (!(select->InheritsFrom("TH1F"))) {
112 TH1F* h = (TH1F*)select;
113 h->Draw();
114 } else if (!(select->InheritsFrom("TH2F"))) {
115 TH2F* h = (TH2F*)select;
116 h->Draw();
117 } else if (!(select->InheritsFrom("TProfile"))) {
118 TProfile* h = (TProfile*)select;
119 h->Draw();
120 } else if (!(select->InheritsFrom("TH1D"))) {
121 TH1D* h = (TH1D*)select;
122 h->Draw();
123 } else if (!(select->InheritsFrom("TH2D"))) {
124 TH2D* h = (TH2D*)select;
125 h->Draw();
126 } else if (!(select->InheritsFrom("TProfile2D"))) {
127 TProfile2D* h = (TProfile2D*)select;
128 h->Draw();
129 } else
130 return;
131 csingle->Update();
132}
int Int_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
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 Fill(const char *namex, const char *namey, Double_t w)
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 BmnResultsECAL(char *fname="bmn_run4926_digi.root")
void select_hist()
Definition json.hpp:4446