BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
Preparation_ZDC.C
Go to the documentation of this file.
1
2using namespace std;
3
4void Preparation_ZDC(char* fname = "../raw/bmn_run0871.root")
5{
6 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
7 bmnloadlibs();
8 /////////////////////////////////////////////////////////////////////////////////////
9 int RUN, n_notrig = 0, n_phys = 0, n_led = 0, n_bad = 0;
10 UInt_t TRIGWORD = 0;
11 sscanf(&fname[strlen(fname) - 8], "%d", &RUN);
12
13 const char* mapping;
14 mapping = "ZDC_map_period_5.txt";
15
16 BmnZDCRaw2Digit ZDC(mapping, fname, "zdc_muon_calibration.txt");
17 ZDC.print();
18
19 cout << "Process RUN: " << RUN << endl;
20
21 /////////////////////////////////////////////////////////////////////////////////////
22 TFile* _f_in = new TFile(fname, "READ");
23 TTree* _t_in = (TTree*)_f_in->Get("BMN_RAW");
24 TClonesArray* zdc_raw = new TClonesArray("BmnADCDigit");
25 _t_in->SetBranchAddress("bmn_zdc", &zdc_raw);
26 _t_in->SetBranchAddress("bmn_trigword", &TRIGWORD);
27 /////////////////////////////////////////////////////////////////////////////////////
28
29 for (int ev = 0; ev < _t_in->GetEntries(); ev++) {
30
31 if ((ev % 1000) == 0)
32 printf("Preparation ZDC, event %d, phys %d, led %d\n", ev, n_phys, n_led);
33
34 TRIGWORD = 0;
35 zdc_raw->Clear();
36
37 _t_in->GetEntry(ev);
38
39 if (TRIGWORD == 0) {
40 n_notrig++;
41 } else if ((TRIGWORD & 0x8) == 0) {
42 n_phys++;
43 ZDC.fillAmplitudes(zdc_raw);
44 ZDC.fillSampleProfilesAll(zdc_raw, 0., 0., 48.);
45 // ZDC.fillSampleProfiles(zdc_raw, 0., 0., 48., 3);
46 } else if ((TRIGWORD & 0x8) == 0x8) {
47 n_led++;
48 // ZDC.fillAmplitudes(zdc_raw);
49 // ZDC.fillSampleProfilesAll(zdc_raw, 0., 0., 48.);
50
51 // ZDC.fillSampleProfiles(zdc_raw, 0., 0., 48., 3);
52 // if ((ev % 1000) == 0 && ZDC.getLogChan(0) >= 0) printf(" Log channel 0 (Id = 0x%0x, Ch = %d)
53 // amplitude is %f\n", ZDC.getLogId(0), ZDC.getLogChan(0), ZDC.getLogAmp(0)); if ((ev % 1000) == 0 &&
54 // ZDC.getLogChan(1) >= 0) printf(" Log channel 1 (Id = 0x%0x, Ch = %d) amplitude is %f\n",
55 // ZDC.getLogId(1), ZDC.getLogChan(1), ZDC.getLogAmp(1));
56 } else {
57 n_bad++;
58 }
59 }
60 /////////////////////////////////////////////////////////////////////////////////////
61 ZDC.drawprof();
62 ZDC.drawtest();
63 /////////////////////////////////////////////////////////////////////////////////////
64
65 _f_in->Close();
66}
67
69{
70 // example of macro called when a mouse event occurs in a pad.
71 // Example:
72 // Root > TFile f("hsimple.root");
73 // Root > hpxpy.Draw();
74 // Root > c1.AddExec("exsel","select_hist()");
75 // When moving the mouse in the canvas, a second canvas shows the
76 // projection along X of the bin corresponding to the Y position
77 // of the mouse. The resulting histogram is fitted with a gaussian.
78 // A "dynamic" line shows the current bin position in Y.
79 // This more elaborated example can be used as a starting point
80 // to develop more powerful interactive applications exploiting CINT
81 // as a development engine.
82 // Author: Rene Brun
83
84 int event = gPad->GetEvent();
85 if (event != 11)
86 return;
87
88 TObject* select = gPad->GetSelected();
89 if (!select)
90 return;
91 if (!(select->InheritsFrom("TH1")))
92 return;
93
94 // create or set the new canvas c2
95 TCanvas* csingle = 0;
96 if ((csingle = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("csingle")))
97 ;
98 else
99 csingle = new TCanvas("csingle");
100 csingle->cd();
101
102 // draw slice corresponding to mouse position
103 if (!(select->InheritsFrom("TH1F"))) {
104 TH1F* h = (TH1F*)select;
105 h->Draw();
106 } else if (!(select->InheritsFrom("TH2F"))) {
107 TH2F* h = (TH2F*)select;
108 h->Draw();
109 } else if (!(select->InheritsFrom("TProfile"))) {
110 TProfile* h = (TProfile*)select;
111 h->Draw();
112 } else if (!(select->InheritsFrom("TH1D"))) {
113 TH1D* h = (TH1D*)select;
114 h->Draw();
115 } else if (!(select->InheritsFrom("TH2D"))) {
116 TH2D* h = (TH2D*)select;
117 h->Draw();
118 } else if (!(select->InheritsFrom("TProfile2D"))) {
119 TProfile2D* h = (TProfile2D*)select;
120 h->Draw();
121 } else
122 return;
123 csingle->Update();
124}
unsigned int UInt_t
#define gROOT
#define gPad
void fillSampleProfilesAll(TClonesArray *data, Float_t x, Float_t y, Float_t e)
void fillAmplitudes(TClonesArray *data)
TVirtualPad * cd(Int_t subpadnumber=0) override
void Update() override
void Clear(Option_t *option="") override
T * Get(const char *namecycle)
void Close(Option_t *option="") override
void Draw(Option_t *option="") override
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
void Preparation_ZDC(char *fname="../raw/bmn_run0871.root")
void select_hist()
Definition json.hpp:4446