BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
EventView.C
Go to the documentation of this file.
1/**
2 * Macro for tracks versions comparison
3 */
4R__ADD_INCLUDE_PATH($VMCWORKDIR)
5
6#if !defined(__CLING__) || defined(__MAKECLING__)
7
8#include <FairTrackParam.h>
9#include <Fit/FitResult.h>
10#include <Rtypes.h>
11#include <TCanvas.h>
12#include <TChain.h>
13#include <TClass.h>
14#include <TClonesArray.h>
15#include <TDatime.h>
16#include <TF1.h>
17#include <TFile.h>
18#include <TH1.h>
19#include <TH2.h>
20#include <TMath.h>
21#include <TPad.h>
22#include <TROOT.h>
23#include <TString.h>
24#include <TStyle.h>
25#include <TTree.h>
26#include <TVirtualPad.h>
27#include <ncurses.h>
28#include <root/TVirtualPad.h>
29
30#else
31#include "bmnloadlibs.C"
32#include "gconfig/basiclibs.C"
33
34#endif
35
36#define PAD_WIDTH 640
37#define PAD_HEIGHT 360
38#define ROWS 2
39#define COLS 3
40#define EV_LIMIT 4
41using namespace std;
42using namespace TMath;
43
45{
46#if !(!defined(__CLING__) || defined(__MAKECLING__))
47 bmnloadlibs(); // load BmnRoot libraries
48#endif
49 gStyle->SetOptStat(0);
50 const Int_t nColors = 16;
51 Int_t ColorMap[nColors] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 49, 11, 12, 13, 14, 15, 16};
52 Int_t runID = 4649;
53 const Int_t boxWidth = 40;
54 TString inFileNameCbm = Form("/home/ilnur/nica/cbm/%04d_Ext_v5.root", runID);
55 TString inFileNameCbm2Bmn = "dst-emb.root"; // Form("cbmdst_%d.root", runID);
56 TString inFileNameBmn = "dst-emb.root"; // Form("dst_MK_%d.root", runID); //~/BMNDST_%d.root
57
58 TString fnames[COLS] = {inFileNameCbm, inFileNameCbm2Bmn, inFileNameBmn};
59 TString treeNames[COLS] = {"bmndata", "bmndata", "bmndata"}; //{"BMN_DIGIT", "cbmsim", "cbmsim"};
60 TString hitNames[COLS] = {"StsHit", "BmnInnerHits", "BmnInnerHits"};
61 TString trackNames[COLS] = {"StsTrack", "BmnGlobalTrack", "BmnGlobalTrack"};
62 TFile* files[COLS] = {NULL};
63 TTree* trees[COLS] = {NULL};
64 TClonesArray* hits[COLS] = {NULL};
65 TClonesArray* tracks[COLS] = {NULL};
66 TClonesArray* silTrack[COLS] = {NULL};
67 TClonesArray* gemTrack[COLS] = {NULL};
68 TClonesArray* silHits[COLS] = {NULL};
69 TClonesArray* gemHits[COLS] = {NULL};
70 TH2D* h[COLS][ROWS][nColors] = {NULL};
71 for (Int_t ic = 0; ic < nColors; ic++) {
72 h[0][0][ic] = new TH2D(Form("h0-0-%d", ic), "Hits XZ CBM", 400, -boxWidth, boxWidth, 400, 0, 200);
73 h[0][1][ic] = new TH2D(Form("h0-1-%d", ic), "Hits YZ CBM", 400, -boxWidth, boxWidth, 400, 0, 200);
74 // h[0][2] = new TH1I("h0-2", "Track 1st TX CBM", 200, -0.5, 0.5);
75 // h[0][3] = new TH1I("h0-3", "Track 1st TY CBM", 200, -0.5, 0.5);
76 h[1][0][ic] = new TH2D(Form("h1-0-%d", ic), "Hits XZ CBM2BMN", 400, -boxWidth, boxWidth, 400, 0, 200);
77 h[1][1][ic] = new TH2D(Form("h1-1-%d", ic), "Hits YZ CBM2BMN", 400, -boxWidth, boxWidth, 400, 0, 200);
78 // h[1][2] = new TH1I("h0-2", "Track 1st TX CBM2BMN", 200, -0.5, 0.5);
79 // h[1][3] = new TH1I("h0-3", "Track 1st TY CBM2BMN", 200, -0.5, 0.5);
80 h[2][0][ic] = new TH2D(Form("h2-0-%d", ic), "Hits XZ BMN", 400, -boxWidth, boxWidth, 400, 0, 200);
81 h[2][1][ic] = new TH2D(Form("h2-1-%d", ic), "Hits YZ BMN", 400, -boxWidth, boxWidth, 400, 0, 200);
82 // h[2][2] = new TH1I("h0-2", "Track 1st TX BMN", 200, -0.5, 0.5);
83 // h[2][3] = new TH1I("h0-3", "Track 1st TY BMN", 200, -0.5, 0.5);
84 }
85 TCanvas* can = new TCanvas("canHits", "", PAD_WIDTH * COLS, PAD_HEIGHT * ROWS);
86 can->Divide(COLS, ROWS);
87 // can->Size(PAD_WIDTH * 2, PAD_HEIGHT * 2);
88
89 for (Int_t i = 1; i < COLS; i++) {
90 files[i] = new TFile(fnames[i], "READ");
91 if (files[i]->IsOpen())
92 printf("file %s opened\n", fnames[i].Data());
93 else {
94 fprintf(stderr, "file %s open error\n", fnames[i].Data());
95 continue;
96 // return;
97 }
98 trees[i] = (TTree*)files[i]->Get(treeNames[i]);
99 trees[i]->SetBranchAddress(hitNames[i], &hits[i]);
100 trees[i]->SetBranchAddress(trackNames[i], &tracks[i]);
101 for (Int_t j = 0; j < ROWS; j++) {
102 for (Int_t ic = 0; ic < nColors; ic++) {
103 h[i][j][ic]->SetMarkerStyle(ic > 0 ? 43 : 2);
104 h[i][j][ic]->SetMarkerSize(ic > 0 ? 2 : 1);
105 h[i][j][ic]->SetMarkerColor(ColorMap[ic]);
106 }
107 }
108 }
109 if (trees[1]) {
110 trees[1]->SetBranchAddress("BmnSiliconTrack", &silTrack[1]);
111 trees[1]->SetBranchAddress("BmnGemTrack", &gemTrack[1]);
112 trees[1]->SetBranchAddress("BmnSiliconHit", &silHits[1]);
113 trees[1]->SetBranchAddress("BmnGemStripHit", &gemHits[1]);
114 }
115 if (trees[2]) {
116 trees[2]->SetBranchAddress("BmnSiliconTrack", &silTrack[2]);
117 trees[2]->SetBranchAddress("BmnGemTrack", &gemTrack[2]);
118 trees[2]->SetBranchAddress("BmnSiliconHit", &silHits[2]);
119 trees[2]->SetBranchAddress("BmnGemStripHit", &gemHits[2]);
120 }
121
122 const UInt_t nEvs = trees[1]->GetEntries();
123 cout << "#recorded entries = " << nEvs << " in file" << endl;
124 Int_t ch = 0;
125 Int_t iEv = 0;
126 do {
127 Int_t hitCount[COLS] = {0};
128 for (Int_t i = 1; i < COLS; i++) {
129 for (Int_t row = 0; row < ROWS; row++)
130 for (Int_t ic = 0; ic < nColors; ic++)
131 h[i][row][ic]->Reset();
132 trees[i]->GetEntry(iEv);
133 for (Int_t iHit = 1; iHit < hits[i]->GetEntriesFast(); iHit++) {
134 BmnHit* hit = (BmnHit*)hits[i]->UncheckedAt(iHit);
135 h[i][0][0]->Fill(hit->GetX(), hit->GetZ());
136 h[i][1][0]->Fill(hit->GetY(), hit->GetZ());
137 }
138 // hitCount[i] += hits[i]->GetEntriesFast();
139
140 if (tracks[1]->GetEntriesFast() < 2) {
141 iEv++;
142 continue;
143 }
144 if (i > 0) {
145 printf("%d branch %d tracks\n", i, tracks[i]->GetEntriesFast());
146 for (Int_t iTrack = 0; iTrack < tracks[i]->GetEntriesFast(); iTrack++) {
147 BmnGlobalTrack* track = (BmnGlobalTrack*)tracks[i]->UncheckedAt(iTrack);
148 if (track->GetSilTrackIndex() != -1) {
149 BmnTrack* silTr = (BmnTrack*)silTrack[i]->UncheckedAt(track->GetSilTrackIndex());
150 // if (silTr->GetNHits() < 4)
151 // continue;
152 hitCount[i] += silTr->GetNHits();
153 for (Int_t iHit = 0; iHit < silTr->GetNHits(); iHit++) {
154 BmnHit* hit = (BmnHit*)silHits[i]->UncheckedAt(silTr->GetHitIndex(iHit));
155 h[i][0][iTrack + 1]->Fill(hit->GetX(), hit->GetZ());
156 h[i][1][iTrack + 1]->Fill(hit->GetY(), hit->GetZ());
157 }
158 }
159 if (track->GetGemTrackIndex() != -1) {
160 BmnTrack* gemTr = (BmnTrack*)gemTrack[i]->UncheckedAt(track->GetGemTrackIndex());
161 // if (gemTr->GetNHits() < 4)
162 // continue;
163 hitCount[i] += gemTr->GetNHits();
164 for (Int_t iHit = 0; iHit < gemTr->GetNHits(); iHit++) {
165 BmnHit* hit = (BmnHit*)gemHits[i]->UncheckedAt(gemTr->GetHitIndex(iHit));
166 h[i][0][iTrack + 1]->Fill(hit->GetX(), hit->GetZ());
167 h[i][1][iTrack + 1]->Fill(hit->GetY(), hit->GetZ());
168 }
169 }
170 // FairTrackParam* first = track->GetParamFirst();
171 // h[i][2][iTrack]->Fill(first->GetTx());
172 // h[i][3][iTrack]->Fill(first->GetTy());
173 }
174 } else {
175 for (Int_t iTrack = 0; iTrack < tracks[i]->GetEntriesFast(); iTrack++) {
176 CbmStsTrack* track = (CbmStsTrack*)tracks[i]->UncheckedAt(iTrack);
177 // if (track->GetNStsHits() < 4)
178 // continue;
179 hitCount[i] += track->GetNStsHits();
180 for (Int_t iHit = 0; iHit < track->GetNStsHits(); iHit++) {
181 CbmStsHit* hit = (CbmStsHit*)hits[i]->UncheckedAt(track->GetStsHitIndex(iHit));
182 h[i][0][iTrack + 1]->Fill(hit->GetX(), hit->GetZ());
183 h[i][1][iTrack + 1]->Fill(hit->GetY(), hit->GetZ());
184 }
185 // FairTrackParam* first = track->GetParamFirst();
186 // h[i][2][iTrack]->Fill(first->GetTx());
187 // h[i][3][iTrack]->Fill(first->GetTy());
188 }
189 }
190 }
191 if (/*hitCount[0] < EV_LIMIT || */ hitCount[1] < EV_LIMIT || hitCount[2] < EV_LIMIT) {
192 iEv++;
193 continue;
194 }
195 if (ch != '\n')
196 for (Int_t col = 0; col < COLS; col++)
197 for (Int_t row = 0; row < ROWS; row++) {
198 TVirtualPad* pad = can->cd(row * 3 + col + 1);
199 pad->Clear();
200 // if (row > 2)
201 // h[col][row]->Draw();
202 // else
203 for (Int_t iTrack = 0; iTrack < nColors; iTrack++)
204 if (iTrack)
205 h[col][row][iTrack]->Draw("SAME");
206 else
207 h[col][row][iTrack]->Draw("");
208 }
209 can->Update();
210 can->Modified();
211 can->SaveAs(Form("can-%d.pdf", runID));
212 cout << " Ev# " << iEv << endl;
213 ch = getchar();
214 switch (ch) {
215 case 'a':
216 iEv = (iEv == 0) ? iEv : iEv - 1;
217 break;
218 case 'd':
219 iEv = (iEv < nEvs) ? iEv + 1 : iEv;
220 break;
221 default:
222 // iEv++;
223 break;
224 }
225 } while (ch != 'q');
226
227 for (Int_t i = 0; i < COLS; i++) {
228 for (Int_t j = 0; j < ROWS; j++) {
229 for (Int_t ic = 0; ic < nColors; ic++) {
230 delete h[i][j][ic];
231 }
232 }
233 }
234
235 return;
236}
#define PAD_WIDTH
Definition EventView.C:36
#define PAD_HEIGHT
Definition EventView.C:37
TCanvas * can(nullptr)
int i
Definition P4_F32vec4.h:22
int Int_t
unsigned int UInt_t
#define R__ADD_INCLUDE_PATH(PATH)
#define EV_LIMIT
Definition EventView.C:40
#define COLS
Definition EventView.C:39
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
BmnGlobalTrack.h.
Int_t GetGemTrackIndex() const
Accessors.
Int_t GetNHits() const
Accessors.
Definition BmnTrack.h:49
Int_t GetHitIndex(Int_t iHit) const
Definition BmnTrack.h:51
Int_t GetNStsHits() const
Accessors.
Definition CbmStsTrack.h:60
Int_t GetStsHitIndex(Int_t iHit) const
Definition CbmStsTrack.h:62
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
void Draw(Option_t *option="") override
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
Int_t GetEntriesFast() const
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 Clear(Option_t *option="") override=0
#define ROWS
Definition EventView.C:38
void EventView()
Definition EventView.C:44
Definition json.hpp:4446