BmnRoot
Loading...
Searching...
No Matches
BmnHistNdet.cxx
Go to the documentation of this file.
1#include "BmnHistNdet.h"
2
3#include "TGaxis.h"
4
5BmnHistNdet::BmnHistNdet(TString title, TString path, Int_t PeriodID, BmnSetup stp)
6 : BmnHist(PeriodID, stp)
7{
8 fTitle = title;
9 fName = title + "_cl";
10 SetGeometry(Form("Ndet_geo_period%d.root", PeriodID));
11 TGaxis::SetMaxDigits(2);
13}
14
15void BmnHistNdet::SetGeometry(const std::string& path)
16{
17 LOG(debug) << "BmnHistNdet::SetGeometry " << path;
18 fGeoHandler = new BmnNdetGeo();
19 fGeoHandler->ReadGeometryFromFile(path);
20}
21
23{
24 TString name;
25 name = fTitle + "_h1d_ECells";
26 h1d_ECells = new TH1F(name, "Ndet signal in cells", 9, 1, 10);
27 h1d_ECells->GetXaxis()->SetTitle("Cell id");
28 h1d_ECells->GetXaxis()->SetTitleColor(kOrange + 10);
29 h1d_ECells->GetYaxis()->SetTitle("Average Signal");
30 h1d_ECells->GetYaxis()->SetTitleColor(kOrange + 10);
31
32 name = fTitle + "_h2_grid";
33 h2_grid = new TH2F(name, "Ndet_Grid", 3, 1, 4, 3, 1, 4);
34 h2_grid->GetXaxis()->SetTitle("X position");
35 h2_grid->GetXaxis()->SetTitleColor(kOrange + 10);
36 h2_grid->GetYaxis()->SetTitle("Y position");
37 h2_grid->GetYaxis()->SetTitleColor(kOrange + 10);
38 h2_grid->GetZaxis()->SetNoExponent(kFALSE);
39 h2_grid->SetStats(0);
40
41 name = fTitle + "_hProfCell";
42 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell) {
43 hProfCell.at(uCell) =
44 new TH1F(name + Form("_%02u", uCell), Form("Cell_%02u", uCell), kTOTAL_LAYRS, 1, kTOTAL_LAYRS + 1);
45 hProfCell.at(uCell)->GetXaxis()->SetTitle("Layer id");
46 hProfCell.at(uCell)->GetXaxis()->SetTitleColor(kOrange + 10);
47 hProfCell.at(uCell)->GetYaxis()->SetTitle("Average Signal");
48 hProfCell.at(uCell)->GetYaxis()->SetTitleColor(kOrange + 10);
49 }
50
51 name = fTitle + "_h1d_ProfileSlice";
52 h1d_ProfileSlice = new TH1F(name, "Energy in detector slice", kTOTAL_LAYRS, 1, kTOTAL_LAYRS + 1);
53 h1d_ProfileSlice->GetXaxis()->SetTitle("Layer id");
54 h1d_ProfileSlice->GetXaxis()->SetTitleColor(kOrange + 10);
55 h1d_ProfileSlice->GetYaxis()->SetTitle("Events");
56 h1d_ProfileSlice->GetYaxis()->SetTitleColor(kOrange + 10);
57
58 name = fTitle + "_h1d_timemin";
59 h1d_timemin = new TH1F(name, "Minimum timestamp in event", 1000, 0, 100);
60 h1d_timemin->GetXaxis()->SetTitle("time");
61 h1d_timemin->GetXaxis()->SetTitleColor(kOrange + 10);
62 h1d_timemin->GetYaxis()->SetTitle("Events");
63 h1d_timemin->GetYaxis()->SetTitleColor(kOrange + 10);
64
65 name = fTitle + "CanvasAmplitudes";
66 canAmps = new TCanvas(name, name, PAD_WIDTH * Ndet_ROWS, PAD_HEIGHT * Ndet_COLS);
67 canAmps->Divide(Ndet_ROWS, Ndet_COLS);
68 canAmpsPads.resize(Ndet_ROWS * Ndet_COLS);
69 NamesAmps.resize(Ndet_ROWS * Ndet_COLS);
70 PadInfo* p1 = new PadInfo();
71 p1->current = h2_grid;
72 p1->opt = "colz"; // p->SetLogz();
73 canAmpsPads.at(0) = p1;
74 // NamesAmps.at(0) = p1->current->GetName();
75 PadInfo* p2 = new PadInfo();
76 p2->current = h1d_ECells;
77 p2->opt = "hist";
78 canAmpsPads.at(1) = p2;
79 NamesAmps.at(1) = p2->current->GetName();
80
81 name = fTitle + "CanvasProfiles";
82 canv_hProfCell = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
83 canv_hProfCell->Divide(3, 3);
84 canv_hProfCellPads.resize(kTOTAL_CELLS);
85 NamesProfs.resize(kTOTAL_CELLS);
86 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell) {
87 PadInfo* p = new PadInfo();
88 canv_hProfCellPads.at(uCell - 1) = p;
89 p->current = hProfCell.at(uCell);
90 p->opt = "hist";
91 NamesProfs.at(uCell - 1) = p->current->GetName();
92 }
93
94 name = fTitle + "CanvasSlice";
95 canv_Slice = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
96 canv_Slice->Divide(2, 1);
97 canv_SlicePads.resize(2);
98 NamesSlice.resize(2);
99 PadInfo* pS1 = new PadInfo();
100 canv_SlicePads.at(0) = pS1;
101 pS1->current = h1d_ProfileSlice;
102 pS1->opt = "hist";
103 NamesSlice.at(0) = pS1->current->GetName();
104 PadInfo* pS2 = new PadInfo();
105 canv_SlicePads.at(1) = pS2;
106 pS2->current = h1d_timemin;
107 pS2->opt = "hist";
108 NamesSlice.at(1) = pS2->current->GetName();
109
110 name = fTitle + "_hChE";
111 hChE = new TH1F(name, name, 500, 0, 35000);
112
113 name = fTitle + "_wfmCh";
114 wfmCh = new TH1F(name, name, 200, 0, 200);
115 wfmCh->SetMarkerStyle(31);
116 wfmCh->SetMarkerSize(0.5);
117
118 name = fTitle + "CanvasSelection";
119 canSelect = new TCanvas(name, name, PAD_WIDTH * Ndet_ROWS, PAD_HEIGHT * Ndet_COLS);
120 canSelect->Divide(Ndet_ROWS, Ndet_COLS);
121 canSelectPads.resize(Ndet_ROWS * Ndet_COLS);
122 NamesSelect.resize(Ndet_ROWS * Ndet_COLS);
123 PadInfo* ps1 = new PadInfo();
124 ps1->current = hChE;
125 ps1->opt = "hist";
126 canSelectPads.at(0) = ps1;
127 NamesSelect.at(0) = ps1->current->GetName();
128 PadInfo* ps2 = new PadInfo();
129 ps2->current = wfmCh;
130 ps2->opt = "hist lp";
131 canSelectPads.at(1) = ps2;
132 NamesSelect.at(1) = ps2->current->GetName();
133
134 name = fTitle + "_h2_Layer_Cell";
135 h2_Layer_Cell =
136 new TH2F(name, "h2_Layer_Cell", kTOTAL_LAYRS + 2, 0, kTOTAL_LAYRS + 2, kTOTAL_CELLS + 2, 0, kTOTAL_CELLS + 2);
137 h2_Layer_Cell->GetXaxis()->SetTitle("Layer number");
138 h2_Layer_Cell->GetXaxis()->SetTitleColor(kOrange + 10);
139 h2_Layer_Cell->GetYaxis()->SetTitle("Cell number");
140 h2_Layer_Cell->GetYaxis()->SetTitleColor(kOrange + 10);
141 h2_Layer_Cell->GetZaxis()->SetNoExponent(kFALSE);
142 h2_Layer_Cell->SetOption("colz");
143 h2_Layer_Cell->SetStats(0);
144
145 name = fTitle + "_h1_Cells";
146 h1_Cells = new TH1F(name, "h1_Cells", 135, 1, 136);
147 h1_Cells->GetXaxis()->SetTitle("Cell number");
148 h1_Cells->GetXaxis()->SetTitleColor(kOrange + 10);
149 h1_Cells->GetYaxis()->SetTitle("Number of hits / event");
150 h1_Cells->GetYaxis()->SetTitleColor(kOrange + 10);
151 h1_Cells->SetOption("hist");
152
153 name = fTitle + "CanvasCells";
154 canv_Cells = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
155 canv_Cells->Divide(1, 2);
156 canv_CellsPads.resize(2);
157 NamesCells.resize(2);
158 PadInfo* pC1 = new PadInfo();
159 canv_CellsPads.at(0) = pC1;
160 pC1->current = h2_Layer_Cell;
161 pC1->opt = "colz";
162 PadInfo* pC2 = new PadInfo();
163 canv_CellsPads.at(1) = pC2;
164 pC2->current = h1_Cells;
165 pC2->opt = "hist";
166 NamesCells.at(1) = pC2->current->GetName();
167
168 name = fTitle + "_h2_Layers_Ampl";
169 h2_lrampl = new TH2F(name, "h2_Layers_Ampl", 59, 0, 59, 3, 0, 3);
170 h2_lrampl->GetXaxis()->SetTitle("X position");
171 h2_lrampl->GetXaxis()->SetTitleColor(kOrange + 10);
172 h2_lrampl->GetYaxis()->SetTitle("Y position");
173 h2_lrampl->GetYaxis()->SetTitleColor(kOrange + 10);
174 h2_lrampl->GetZaxis()->SetNoExponent(kFALSE);
175 h2_lrampl->SetOption("colz");
176 h2_lrampl->SetStats(0);
177
178 name = fTitle + "_h1_Cells_Ampl";
179 h1_CellsAmpl = new TH1F(name, "h1_Cells_Ampl", 135, 1, 136);
180 h1_CellsAmpl->GetXaxis()->SetTitle("Cell number");
181 h1_CellsAmpl->GetXaxis()->SetTitleColor(kOrange + 10);
182 h1_CellsAmpl->GetYaxis()->SetTitle("Average amplitude");
183 h1_CellsAmpl->GetYaxis()->SetTitleColor(kOrange + 10);
184 h1_CellsAmpl->SetOption("hist");
185
186 name = fTitle + "CanvasAmpl";
187 canv_Ampl = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT / 2);
188 canv_Ampl->Divide(1, 2);
189 canv_AmplPads.resize(2);
190 NamesAmpl.resize(2);
191 PadInfo* pA1 = new PadInfo();
192 canv_AmplPads.at(0) = pA1;
193 pA1->current = h2_lrampl;
194 pA1->opt = "colz";
195 PadInfo* pA2 = new PadInfo();
196 canv_AmplPads.at(1) = pA2;
197 pA2->current = h1_CellsAmpl;
198 pA2->opt = "hist";
199 NamesAmpl.at(1) = pA2->current->GetName();
200
201 name = fTitle + "_h2_Layers_Time";
202 h2_lrtime = new TH2F(name, "h2_Layers_Time", 59, 0, 59, 3, 0, 3);
203 h2_lrtime->GetXaxis()->SetTitle("X position");
204 h2_lrtime->GetXaxis()->SetTitleColor(kOrange + 10);
205 h2_lrtime->GetYaxis()->SetTitle("Y position");
206 h2_lrtime->GetYaxis()->SetTitleColor(kOrange + 10);
207 h2_lrtime->GetZaxis()->SetNoExponent(kFALSE);
208 h2_lrtime->SetOption("colz");
209 h2_lrtime->SetStats(0);
210
211 name = fTitle + "_h1_Cells_Time";
212 h1_CellsTime = new TH1F(name, "h1_Cells_Time", 135, 1, 136);
213 h1_CellsTime->GetXaxis()->SetTitle("Cell number");
214 h1_CellsTime->GetXaxis()->SetTitleColor(kOrange + 10);
215 h1_CellsTime->GetYaxis()->SetTitle("Average time");
216 h1_CellsTime->GetYaxis()->SetTitleColor(kOrange + 10);
217 h1_CellsTime->SetOption("hist");
218
219 name = fTitle + "CanvasTime";
220 canv_Time = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT / 2);
221 canv_Time->Divide(1, 2);
222 canv_TimePads.resize(2);
223 NamesTime.resize(2);
224 PadInfo* pT1 = new PadInfo();
225 canv_TimePads.at(0) = pT1;
226 pT1->current = h2_lrtime;
227 pT1->opt = "col0z";
228 PadInfo* pT2 = new PadInfo();
229 canv_TimePads.at(1) = pT2;
230 pT2->current = h1_CellsTime;
231 pT2->opt = "hist";
232 NamesTime.at(1) = pT2->current->GetName();
233
234 int itemp = 0;
235 int il = 1;
236 int ilch = 0;
237 name = fTitle + "_hCellAmpEM";
238
239 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell) {
240 itemp = ilch * 9 + il;
241 hCellAmpEM.at(uCell) = new TH1F(name + Form("_%02u", itemp), Form("Cell_%02u", itemp), 100, 0, 10);
242 hCellAmpEM.at(uCell)->GetXaxis()->SetTitle("Signal");
243 hCellAmpEM.at(uCell)->GetXaxis()->SetTitleColor(kOrange + 10);
244 ilch++;
245 if (uCell % 6 == 0) {
246 il++;
247 ilch = 0;
248 }
249 }
250
251 name = fTitle + "CanvasCellAmpEM";
252 canv_hCellAmpEM = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
253 canv_hCellAmpEM->Divide(6, 9, 0.0001, 0.0001);
254 canv_hCellAmpEMPads.resize(kEM_LAYRS * kTOTAL_CELLS);
255 NamesCellAmpEM.resize(kEM_LAYRS * kTOTAL_CELLS);
256 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell) {
257 PadInfo* paEM = new PadInfo();
258 canv_hCellAmpEMPads.at(uCell - 1) = paEM;
259 paEM->current = hCellAmpEM.at(uCell);
260 paEM->opt = "hist";
261 NamesCellAmpEM.at(uCell - 1) = paEM->current->GetName();
262 }
263
264 itemp = 0;
265 il = 1;
266 ilch = 0;
267 name = fTitle + "_hCellAmpH";
268 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell) {
269 itemp = ilch * 9 + il + kEM_LAYRS * kTOTAL_CELLS;
270 hCellAmpH.at(uCell) = new TH1F(name + Form("_%02u", itemp), Form("Cell_%02u", itemp), 100, 0, 10);
271 hCellAmpH.at(uCell)->GetXaxis()->SetTitle("Signal");
272 hCellAmpH.at(uCell)->GetXaxis()->SetTitleColor(kOrange + 10);
273 ilch++;
274 if (uCell % 9 == 0) {
275 il++;
276 ilch = 0;
277 }
278 }
279
280 name = fTitle + "CanvasCellAmpH";
281 canv_hCellAmpH = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
282 canv_hCellAmpH->Divide(9, 9, 0.0001, 0.0001);
283 canv_hCellAmpHPads.resize(kHAD_LAYRS * kTOTAL_CELLS);
284 NamesCellAmpH.resize(kHAD_LAYRS * kTOTAL_CELLS);
285 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell) {
286 PadInfo* paH = new PadInfo();
287 canv_hCellAmpHPads.at(uCell - 1) = paH;
288 paH->current = hCellAmpH.at(uCell);
289 paH->opt = "hist";
290 NamesCellAmpH.at(uCell - 1) = paH->current->GetName();
291 }
292
293 itemp = 0;
294 il = 1;
295 ilch = 0;
296 name = fTitle + "_hCellTimeEM";
297 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell) {
298 itemp = ilch * 9 + il;
299 hCellTimeEM.at(uCell) = new TH1F(name + Form("_%02u", itemp), Form("Cell_%02u", itemp), 1000, -300, 300);
300 hCellTimeEM.at(uCell)->GetXaxis()->SetTitle("Time");
301 hCellTimeEM.at(uCell)->GetXaxis()->SetTitleColor(kOrange + 10);
302 ilch++;
303 if (uCell % 6 == 0) {
304 il++;
305 ilch = 0;
306 }
307 }
308
309 name = fTitle + "CanvasCellTimeEM";
310 canv_hCellTimeEM = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
311 canv_hCellTimeEM->Divide(6, 9, 0.0001, 0.0001);
312 canv_hCellTimeEMPads.resize(kEM_LAYRS * kTOTAL_CELLS);
313 NamesCellTimeEM.resize(kEM_LAYRS * kTOTAL_CELLS);
314 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell) {
315 PadInfo* ptEM = new PadInfo();
316 canv_hCellTimeEMPads.at(uCell - 1) = ptEM;
317 ptEM->current = hCellTimeEM.at(uCell);
318 ptEM->opt = "hist";
319 NamesCellTimeEM.at(uCell - 1) = ptEM->current->GetName();
320 }
321
322 itemp = 0;
323 il = 1;
324 ilch = 0;
325 name = fTitle + "_hCellTimeH";
326 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell) {
327 itemp = ilch * 9 + il + kEM_LAYRS * kTOTAL_CELLS;
328 hCellTimeH.at(uCell) = new TH1F(name + Form("_%02u", itemp), Form("Cell_%02u", itemp), 1000, -300, 300);
329 hCellTimeH.at(uCell)->GetXaxis()->SetTitle("Time");
330 hCellTimeH.at(uCell)->GetXaxis()->SetTitleColor(kOrange + 10);
331 ilch++;
332 if (uCell % 9 == 0) {
333 il++;
334 ilch = 0;
335 }
336 }
337
338 name = fTitle + "CanvasCellTimeH";
339 canv_hCellTimeH = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
340 canv_hCellTimeH->Divide(9, 9, 0.0001, 0.0001);
341 canv_hCellTimeHPads.resize(kHAD_LAYRS * kTOTAL_CELLS);
342 NamesCellTimeH.resize(kHAD_LAYRS * kTOTAL_CELLS);
343 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell) {
344 PadInfo* ptH = new PadInfo();
345 canv_hCellTimeHPads.at(uCell - 1) = ptH;
346 ptH->current = hCellTimeH.at(uCell);
347 ptH->opt = "hist";
348 NamesCellTimeH.at(uCell - 1) = ptH->current->GetName();
349 }
350
351 name = fTitle + "_h2_hits";
352 h2_hits = new TH2F(name, "h2_hits", 9, 1, 10, 16, 0, 16);
353 h2_hits->GetXaxis()->SetTitle("module");
354 h2_hits->GetXaxis()->SetTitleColor(kOrange + 10);
355 h2_hits->GetYaxis()->SetTitle("Channel");
356 h2_hits->GetYaxis()->SetTitleColor(kOrange + 10);
357 h2_hits->GetZaxis()->SetNoExponent(kFALSE);
358 h2_hits->SetOption("colz");
359 h2_hits->SetStats(0);
360
361 name = fTitle + "_h2_mean_amp";
362 h2_mean_amp = new TH2F(name, "h2_mean_amp", 9, 1, 10, 16, 0, 16);
363 h2_mean_amp->GetXaxis()->SetTitle("module");
364 h2_mean_amp->GetXaxis()->SetTitleColor(kOrange + 10);
365 h2_mean_amp->GetYaxis()->SetTitle("Channel");
366 h2_mean_amp->GetYaxis()->SetTitleColor(kOrange + 10);
367 h2_mean_amp->GetZaxis()->SetNoExponent(kFALSE);
368 h2_mean_amp->SetOption("colz");
369 h2_mean_amp->SetStats(0);
370
371 name = fTitle + "CanvasHits";
372 canv_hits = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
373 canv_hits->Divide(1, 2);
374 canv_hitsPads.resize(2);
375 NamesHits.resize(2);
376 PadInfo* pB1 = new PadInfo();
377 canv_hitsPads.at(0) = pB1;
378 pB1->current = h2_hits;
379 pB1->opt = "colz";
380 PadInfo* pB2 = new PadInfo();
381 canv_hitsPads.at(1) = pB2;
382 pB2->current = h2_mean_amp;
383 pB2->opt = "colz";
384 NamesHits.at(1) = pB2->current->GetName();
385}
386
387void BmnHistNdet::Register(THttpServer* serv)
388{
389 fServer = serv;
390 fServer->Register("/", this);
391 TString path = "/" + fTitle + "/";
392 fServer->Register(path, canAmps);
393 fServer->Register(path, canv_hProfCell);
394 fServer->Register(path, canv_Slice);
395 fServer->Register(path, canv_Cells);
396 fServer->Register(path, canSelect);
397 // fServer->Register(path, h2_lrampl);
398 // fServer->Register(path, h1_CellsAmpl);
399 fServer->Register(path, canv_Ampl);
400 fServer->Register(path, canv_Time);
401 fServer->Register(path, canv_hCellAmpEM);
402 fServer->Register(path, canv_hCellAmpH);
403 fServer->Register(path, canv_hCellTimeEM);
404 fServer->Register(path, canv_hCellTimeH);
405 fServer->Register(path, canv_hits);
406
407 TString cmd = "/" + fName + "/->Reset()";
408 fServer->SetItemField(path.Data(), "_monitoring", "2000");
409 fServer->SetItemField(path.Data(), "_layout", "grid3x3");
410 TString cmdTitle = path + "Reset";
411 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
412 fServer->Restrict(cmdTitle, "visible=shift");
413 fServer->Restrict(cmdTitle, "allow=shift");
414 cmd = "/" + fName + "/->SetRefRun(%arg1%)";
415 cmdTitle = path + "SetRefRun";
416 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
417 cmdTitle = path + "ChangeSelection";
418 fServer->RegisterCommand(cmdTitle, TString("/") + fName.Data() + "/->SetSelection(%arg1%,%arg2%,%arg3%)",
419 "button;");
420 fServer->Restrict(cmdTitle, "visible=shift");
421 fServer->Restrict(cmdTitle, "allow=shift");
422 fServer->Restrict(cmdTitle.Data(), "deny=guest");
423}
424
425void BmnHistNdet::SetDir(TFile* outFile = NULL, TTree* recoTree = NULL)
426{
427 frecoTree = recoTree;
428 fDir = NULL;
429 if (outFile != NULL)
430 fDir = outFile->mkdir(fTitle + "_hists");
431 h1d_ECells->SetDirectory(fDir);
432 h2_grid->SetDirectory(fDir);
433 h1d_ProfileSlice->SetDirectory(fDir);
434 h1d_timemin->SetDirectory(fDir);
435 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell)
436 hProfCell.at(uCell)->SetDirectory(fDir);
437 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
438 hCellAmpEM.at(uCell)->SetDirectory(fDir);
439 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
440 hCellAmpH.at(uCell)->SetDirectory(fDir);
441 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
442 hCellTimeEM.at(uCell)->SetDirectory(fDir);
443 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
444 hCellTimeH.at(uCell)->SetDirectory(fDir);
445 h2_Layer_Cell->SetDirectory(fDir);
446 h1_Cells->SetDirectory(fDir);
447 hChE->SetDirectory(fDir);
448 wfmCh->SetDirectory(fDir);
449 h2_lrampl->SetDirectory(fDir);
450 h1_CellsAmpl->SetDirectory(fDir);
451 h2_lrtime->SetDirectory(fDir);
452 h1_CellsTime->SetDirectory(fDir);
453 h2_hits->SetDirectory(fDir);
454 h2_mean_amp->SetDirectory(fDir);
455}
456
457void BmnHistNdet::SetSelection(Int_t Cell, Int_t Layer, Int_t Trigger)
458{
459 fSelectedCell = Cell;
460 fSelectedLayer = Layer;
461 fSelectedTrigger = Trigger;
462 TString command = "(1)";
463 TString digiInTree = "NdetDigi";
464 if (fSelectedCell >= 0)
465 command = command + Form("&& %s.GetCellId() == %d", digiInTree.Data(), fSelectedCell);
466 if (fSelectedLayer >= 0)
467 command = command + Form("&& %s.GetLayerId() == %d", digiInTree.Data(), fSelectedLayer);
468 TString triggerCondition = "";
469 if (fSelectedTrigger >= 0)
470 triggerCondition = Form(" && %s trigger bit == %d (bitBT=2, bitBC1=3, bitMBT=6, bitNiT=4, bitCCT1=5, "
471 "bitCCT2=8, bitCCT3=12, bitFHCAL=9)",
472 digiInTree.Data(), fSelectedTrigger);
473 TString titleSignal = Form("#splitline{Signal %s}{%s}", command.Data(), triggerCondition.Data());
474 TString titleWfm = Form("#splitline{Wfm %s}{%s}", command.Data(), triggerCondition.Data());
475 hChE->Reset();
476 wfmCh->Reset();
477 if (frecoTree != NULL) {
478 hChE->SetTitle(titleSignal);
479 TString direction = Form("%s.fAmpl>>%s", digiInTree.Data(), hChE->GetName());
480 frecoTree->Draw(direction.Data(), command.Data(), "goff");
481 wfmCh->SetTitle(titleWfm);
482 }
483}
484
486{
487 BmnHist::DrawRef(canAmps, &canAmpsPads);
488 BmnHist::DrawRef(canv_hProfCell, &canv_hProfCellPads);
489 BmnHist::DrawRef(canv_hCellAmpEM, &canv_hCellAmpEMPads);
490 BmnHist::DrawRef(canv_hCellAmpH, &canv_hCellAmpHPads);
491 BmnHist::DrawRef(canv_hCellTimeEM, &canv_hCellTimeEMPads);
492 BmnHist::DrawRef(canv_hCellTimeH, &canv_hCellTimeHPads);
493 BmnHist::DrawRef(canv_Slice, &canv_SlicePads);
494 BmnHist::DrawRef(canv_Cells, &canv_CellsPads);
495 BmnHist::DrawRef(canSelect, &canSelectPads);
496 BmnHist::DrawRef(canv_Ampl, &canv_AmplPads);
497 BmnHist::DrawRef(canv_Time, &canv_TimePads);
498 BmnHist::DrawRef(canv_hits, &canv_hitsPads);
499 return;
500}
501
503{
504 BmnEventHeader* head = fDigiArrays->header;
505 TClonesArray* digits = fDigiArrays->ndet;
506 if (!digits)
507 return;
508
509 h1d_ECells->Scale(fEventCounter);
510 h2_grid->Scale(fEventCounter);
511 h1d_ProfileSlice->Scale(fEventCounter);
512 h2_Layer_Cell->Scale(fEventCounter);
513 h1_Cells->Scale(fEventCounter);
514 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell)
515 hProfCell.at(uCell)->Scale(fEventCounter);
516
517 double trigtimeshift = 0.0;
518 for (Int_t iDig = 0; iDig < digits->GetEntriesFast(); iDig++) {
519 BmnNdetDigi* digi = (BmnNdetDigi*)digits->At(iDig);
520 if (digi->GetLayerId() == 17 && digi->GetRowId() == 1 && digi->GetColumnId() == 1) {
521 trigtimeshift = digi->GetTime();
522 }
523 }
524
525 double mintime = std::numeric_limits<float>::max();
526 for (Int_t iDig = 0; iDig < digits->GetEntriesFast(); iDig++) {
527 BmnNdetDigi* digi = (BmnNdetDigi*)digits->At(iDig);
528 double signal = digi->GetSignal();
529 double time = 200 - trigtimeshift + digi->GetTime();
530 auto row = digi->GetRowId();
531 auto col = digi->GetColumnId();
532 auto cell = (row - 1) * 3 + col;
533 auto layer = digi->GetLayerId();
534 // cout<<row<<" "<<col<<" "<<layer<<endl;
535 // if (layer == 0)
536 // continue;
537 // const auto& positionMap = fGeoHandler->GetPositionMap();
538 // auto it = positionMap.find(digi->GetAddress());
539 // if (it == positionMap.end())
540 // continue;
541 // float realXpos = it->second.first.X();
542 // float realYpos = it->second.first.Y();
543 // float realZpos = position.Z();
544 if (time < mintime)
545 mintime = time;
546 // unsigned int channel = MapCell2Ch.at(cell);
547 unsigned int channel = cell;
548 h1d_ECells->Fill(channel, signal);
549 h2_grid->Fill(col, row, signal);
550 h2_Layer_Cell->Fill(layer, channel, signal);
551
552 int chan_adc = ((col - 1) * 3 + (3 - row)) + (layer - 1) * kTQDC_MAX_MODULES + 1;
553 int lr_adc = (chan_adc - 1) / kTQDC_MAX_CHAN + 1;
554 int cell_adc = (chan_adc - 1) % kTQDC_MAX_CHAN;
555 h2_hits->Fill(lr_adc, cell_adc);
556 // cout<<" adc mod:"<<lr_adc<<" chan: "<<cell_adc<<endl;
557
558 UInt_t TrigPattern = head->GetInputSignalsAR();
559 // auto bitBT = (TrigPattern >> 2) & 1; // BT
560 // auto bitBC1 = (TrigPattern >> 3) & 1; // BC1
561 // auto bitMBT = (TrigPattern >> 6) & 1; // MBT
562 // auto bitNiT = (TrigPattern >> 4) & 1; // NiT
563 // auto bitCCT1 = (TrigPattern >> 5) & 1; // CCT1
564 // auto bitCCT2 = (TrigPattern >> 8) & 1; // CCT2
565 // auto bitCCT3 = (TrigPattern >> 12) & 1; // CCT3
566 // auto bitFHCAL = (TrigPattern >> 9) & 1; // FHCAL
567
569 bool isSelected = ((Int_t)cell == fSelectedCell) && ((Int_t)digi->GetLayerId() == fSelectedLayer);
570 if (isSelected) {
571 if ((TrigPattern >> fSelectedTrigger) & 1) {
572 hChE->Fill(digi->fAmpl);
573 auto Wfm = digi->GetWfm();
574 std::vector<float> points(Wfm.size());
575 std::iota(std::begin(points), std::end(points), 0); // Fill with 0, 1, ..., wfm.back().
576 wfmCh->Reset();
577 wfmCh->GetXaxis()->SetRangeUser(0, Wfm.size());
578 for (UInt_t wfm_iter = 0; wfm_iter < Wfm.size(); wfm_iter++)
579 wfmCh->Fill(wfm_iter, Wfm.at(wfm_iter));
580 }
581 }
582
583 hProfCell.at(channel)->Fill(digi->GetLayerId(), signal);
584 h1d_ProfileSlice->Fill(digi->GetLayerId(), signal);
585
586 int ch_flat_idx = channel + (layer - 1) * kTOTAL_CELLS;
587 h1_Cells->Fill(ch_flat_idx, 1);
588 meanamp.at(ch_flat_idx - 1) = (meanamp.at(ch_flat_idx - 1) * ch_entries.at(ch_flat_idx - 1) + signal)
589 / (ch_entries.at(ch_flat_idx - 1) + 1);
590 meantime.at(ch_flat_idx - 1) = (meantime.at(ch_flat_idx - 1) * ch_entries.at(ch_flat_idx - 1) + time)
591 / (ch_entries.at(ch_flat_idx - 1) + 1);
592 meanamp_test.at(lr_adc - 1).at(cell_adc) =
593 (meanamp_test.at(lr_adc - 1).at(cell_adc) * ch_entries_test.at(lr_adc - 1).at(cell_adc) + signal)
594 / (ch_entries_test.at(lr_adc - 1).at(cell_adc) + 1);
595
596 ch_entries.at(ch_flat_idx - 1) += 1.0;
597 ch_entries_test.at(lr_adc - 1).at(cell_adc) += 1.0;
599 int ix = col + (layer - 1) * 3 + (layer - 1);
600 h2_lrampl->SetBinContent(ix, row, meanamp.at(ch_flat_idx - 1));
601 h1_CellsAmpl->SetBinContent(ch_flat_idx, meanamp.at(ch_flat_idx - 1));
602 h2_lrtime->SetBinContent(ix, row, meantime.at(ch_flat_idx - 1));
603 h1_CellsTime->SetBinContent(ch_flat_idx, meantime.at(ch_flat_idx - 1));
604 h2_mean_amp->SetBinContent(lr_adc, cell_adc + 1, meanamp_test.at(lr_adc - 1).at(cell_adc));
605
607 // printf("channel: %d realX:%f realY:%f LR:%d GetX:%d GetY:%d mean: %f \n", channel, realXpos, realYpos, layer,
608 // digi->GetX(), digi->GetY(), mean);
609 if (ch_flat_idx <= kEM_LAYRS * kTOTAL_CELLS) {
610 int itempEM = ((ch_flat_idx - 1) % 9) * 6 + layer;
611 hCellAmpEM.at(itempEM)->Fill(signal);
612 hCellTimeEM.at(itempEM)->Fill(time);
613 } else {
614 int itempH = ((ch_flat_idx - kEM_LAYRS * kTOTAL_CELLS - 1) % 9) * 9 + layer - 6;
615 hCellAmpH.at(itempH)->Fill(signal);
616 hCellTimeH.at(itempH)->Fill(time);
617 }
618 }
619 fEventCounter++;
620
621 h1d_ECells->Scale(1. / fEventCounter);
622 h2_grid->Scale(1. / fEventCounter);
623 h1d_ProfileSlice->Scale(1. / fEventCounter);
624 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell)
625 hProfCell.at(uCell)->Scale(1. / fEventCounter);
626 h2_Layer_Cell->Scale(1. / fEventCounter);
627 h1_Cells->Scale(1. / fEventCounter);
628
629 h1d_timemin->Fill(mintime);
630}
631
633{
634 TString FileName = Form("bmn_run%04d_hist.root", id);
635 printf("SetRefRun: %s\n", FileName.Data());
636 if (refRunName != FileName) {
637 refRunName = FileName;
638 refID = id;
639 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canAmpsPads, NamesAmps);
640 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hProfCellPads, NamesProfs);
641 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hCellAmpEMPads, NamesCellAmpEM);
642 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hCellAmpHPads, NamesCellAmpH);
643 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hCellTimeEMPads, NamesCellTimeEM);
644 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hCellTimeHPads, NamesCellTimeH);
645 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_SlicePads, NamesSlice);
646 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_CellsPads, NamesCells);
647 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_AmplPads, NamesAmpl);
648 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_TimePads, NamesTime);
649 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canv_hitsPads, NamesHits);
650 DrawBoth();
651 }
652 return kBMNSUCCESS;
653}
654
656{
657 for (auto pad : canAmpsPads) {
658 if (pad->ref)
659 delete pad->ref;
660 pad->ref = NULL;
661 }
662 for (auto pad : canv_hProfCellPads) {
663 if (pad->ref)
664 delete pad->ref;
665 pad->ref = NULL;
666 }
667 for (auto pad : canv_hCellAmpEMPads) {
668 if (pad->ref)
669 delete pad->ref;
670 pad->ref = NULL;
671 }
672 for (auto pad : canv_hCellAmpHPads) {
673 if (pad->ref)
674 delete pad->ref;
675 pad->ref = NULL;
676 }
677 for (auto pad : canv_hCellTimeEMPads) {
678 if (pad->ref)
679 delete pad->ref;
680 pad->ref = NULL;
681 }
682 for (auto pad : canv_hCellTimeHPads) {
683 if (pad->ref)
684 delete pad->ref;
685 pad->ref = NULL;
686 }
687 for (auto pad : canv_SlicePads) {
688 if (pad->ref)
689 delete pad->ref;
690 pad->ref = NULL;
691 }
692 for (auto pad : canv_CellsPads) {
693 if (pad->ref)
694 delete pad->ref;
695 pad->ref = NULL;
696 }
697 for (auto pad : canv_AmplPads) {
698 if (pad->ref)
699 delete pad->ref;
700 pad->ref = NULL;
701 }
702 for (auto pad : canv_TimePads) {
703 if (pad->ref)
704 delete pad->ref;
705 pad->ref = NULL;
706 }
707 for (auto pad : canv_hitsPads) {
708 if (pad->ref)
709 delete pad->ref;
710 pad->ref = NULL;
711 }
712 refID = 0;
713}
714
716{
717 printf("BmnHistNdet : Reset histos\n");
718 fEventCounter = 1;
719 h1d_ECells->Reset();
720 h2_grid->Reset();
721 h1d_ProfileSlice->Reset();
722 h1d_timemin->Reset();
723 hChE->Reset();
724 wfmCh->Reset();
725 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell)
726 hProfCell.at(uCell)->Reset();
727 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
728 hCellAmpEM.at(uCell)->Reset();
729 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
730 hCellAmpH.at(uCell)->Reset();
731 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
732 hCellTimeEM.at(uCell)->Reset();
733 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
734 hCellTimeH.at(uCell)->Reset();
735 h2_Layer_Cell->Reset();
736 h1_Cells->Reset();
737 h2_lrampl->Reset();
738 h1_CellsAmpl->Reset();
739 h2_lrtime->Reset();
740 h1_CellsTime->Reset();
741 h2_hits->Reset();
742 h2_mean_amp->Reset();
743
744 std::fill(std::begin(meanamp), std::end(meanamp), 0.0);
745 for (auto& row : meanamp_test)
746 std::fill(row.begin(), row.end(), 0.0);
747 std::fill(std::begin(meantime), std::end(meantime), 0.0);
748 std::fill(std::begin(ch_entries), std::end(ch_entries), 1.0);
749 for (auto& row : ch_entries_test)
750 std::fill(row.begin(), row.end(), 1.0);
751}
753{
754 if (fGeoHandler)
755 delete fGeoHandler;
756 delete canAmps;
757 delete canv_hProfCell;
758 delete canv_hCellAmpEM;
759 delete canv_hCellAmpH;
760 delete canv_hCellTimeEM;
761 delete canv_hCellTimeH;
762 delete canv_Slice;
763 delete canv_Cells;
764 delete canv_hits;
765 delete canSelect;
766 delete canv_Ampl;
767 delete canv_Time;
768 if (fDir != NULL)
769 return;
770 delete h1d_ECells;
771 delete h2_grid;
772 delete h1d_ProfileSlice;
773 delete h1d_timemin;
774 delete hChE;
775 delete wfmCh;
776 for (UInt_t uCell = 1; uCell <= kTOTAL_CELLS; ++uCell)
777 delete hProfCell.at(uCell);
778 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
779 delete hCellAmpEM.at(uCell);
780 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
781 delete hCellAmpH.at(uCell);
782 for (UInt_t uCell = 1; uCell <= kEM_LAYRS * kTOTAL_CELLS; ++uCell)
783 delete hCellTimeEM.at(uCell);
784 for (UInt_t uCell = 1; uCell <= kHAD_LAYRS * kTOTAL_CELLS; ++uCell)
785 delete hCellTimeH.at(uCell);
786 delete h2_Layer_Cell;
787 delete h2_hits;
788 delete h2_mean_amp;
789 delete h1_Cells;
790 delete h2_lrampl;
791 delete h1_CellsAmpl;
792 delete h2_lrtime;
793 delete h1_CellsTime;
794}
#define PAD_WIDTH
Definition BmnAdcQA.cxx:3
#define PAD_HEIGHT
Definition BmnAdcQA.cxx:4
BmnStatus
Definition BmnEnums.h:24
@ kBMNSUCCESS
Definition BmnEnums.h:25
BmnSetup
Definition BmnEnums.h:89
double GetTime() const
double GetSignal() const
std::vector< float > GetWfm() const
Waveform.
UInt_t GetInputSignalsAR()
BmnStatus ReadGeometryFromFile(const std::string &path, bool getGlobalPosition=true)
void SetGeometry(const std::string &path)
virtual ~BmnHistNdet()
BmnHistNdet(TString title="Ndet", TString path="", Int_t periodID=8, BmnSetup setup=kBMNSETUP)
void SetDir(TFile *outFile, TTree *recoTree)
void FillFromDigi(DigiArrays *fDigiArrays)
void CreateHistos()
void Register(THttpServer *serv)
BmnStatus SetRefRun(Int_t id)
void SetSelection(Int_t Cell, Int_t Layer, Int_t Trigger)
void ClearRefRun()
TTree * frecoTree
Definition BmnHist.h:88
Int_t refID
Definition BmnHist.h:92
TString refPath
Definition BmnHist.h:90
TDirectory * fDir
Definition BmnHist.h:89
static void DrawRef(unique_ptr< TCanvas > &canGemStrip, vector< PadInfo * > *canGemStripPads)
Definition BmnHist.cxx:15
TString refRunName
Definition BmnHist.h:91
static BmnStatus LoadRefRun(Int_t refID, TString FullName, TString fTitle, vector< PadInfo * > canPads, vector< TString > Names)
Definition BmnHist.cxx:100
THttpServer * fServer
Definition BmnHist.h:87
uint32_t GetColumnId() const
uint32_t GetRowId() const
uint32_t GetLayerId() const
Data class for Bmn Ndet digital signal processing.
Definition BmnNdetDigi.h:24
BmnEventHeader * header
Definition DigiArrays.h:146
TClonesArray * ndet
Definition DigiArrays.h:136
Storage for pad content and it's options.
Definition PadInfo.h:20
string opt
Definition PadInfo.h:88
TH1 * current
Definition PadInfo.h:78
#define Ndet_ROWS
Definition BmnHistNdet.h:19
#define Ndet_COLS
Definition BmnHistNdet.h:20