BmnRoot
Loading...
Searching...
No Matches
BmnHistFHCal.cxx
Go to the documentation of this file.
1#include "BmnHistFHCal.h"
2
3#include "TGaxis.h"
4
5BmnHistFHCal::BmnHistFHCal(TString title, TString path, Int_t PeriodID, BmnSetup stp)
6 : BmnHist(PeriodID, stp)
7{
8 fTitle = title;
9 fName = title + "_cl";
10 SetGeometry(Form("FHCal_geo_period%d.root", PeriodID));
11 TGaxis::SetMaxDigits(2);
13}
14
15void BmnHistFHCal::SetGeometry(const std::string& path)
16{
17 LOG(debug) << "BmnHistFHCal::SetGeometry " << path;
18 fGeoHandler = new BmnFHCalGeo();
19 fGeoHandler->ReadGeometryFromFile(path, false);
20}
21
23{
24 TString name;
25 name = fTitle + "_h1d_Emodules";
26 h1d_Emodules = new TH1F(name, "FHCal signal in modules", kTOTAL_MODULES, 1, kTOTAL_MODULES + 1);
27 h1d_Emodules->GetXaxis()->SetTitle("Module id");
28 h1d_Emodules->GetXaxis()->SetTitleColor(kOrange + 10);
29 h1d_Emodules->GetYaxis()->SetTitle("Average Signal [MIP]");
30 h1d_Emodules->GetYaxis()->SetTitleColor(kOrange + 10);
31 h1d_Emodules->SetStats(0);
32
33 name = fTitle + "_h2_calo";
34 h2_calo = new TH2F(name, "FHCal_Grid", 32, -80, 80, 25, -60, 60);
35 h2_calo->GetXaxis()->SetTitle("X position [mm]");
36 h2_calo->GetXaxis()->SetTitleColor(kOrange + 10);
37 h2_calo->GetYaxis()->SetTitle("Y position [mm]");
38 h2_calo->GetYaxis()->SetTitleColor(kOrange + 10);
39 h2_calo->GetZaxis()->SetNoExponent(kFALSE);
40 h2_calo->SetStats(0);
41
42 name = fTitle + "_h2_calo_text";
43 h2_calo_text = (TH2F*)h2_calo->Clone(name.Data());
44 h2_calo_text->SetMarkerColor(kBlack);
45 h2_calo_text->SetStats(0);
46
47 name = fTitle + "_hModuleProfile";
48 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
49 hModuleProfile.at(uMod) = new TH1F(fTitle + Form("_Profile_Mod_%02u", uMod), Form("Mod_%02u", uMod), 10, 1, 11);
50 hModuleProfile.at(uMod)->SetTitle(Form("Mod %03u", uMod));
51 hModuleProfile.at(uMod)->SetTitleSize(0.9, "t");
52 hModuleProfile.at(uMod)->GetXaxis()->SetTitle("Section id");
53 hModuleProfile.at(uMod)->GetXaxis()->SetTitleColor(kOrange + 10);
54 hModuleProfile.at(uMod)->GetYaxis()->SetTitle("Average Signal [MIP]");
55 hModuleProfile.at(uMod)->GetYaxis()->SetTitleColor(kOrange + 10);
56 hModuleProfile.at(uMod)->SetStats(0);
57 }
58
59 name = fTitle + "CanvasAmplitudes";
60 canAmps = new TCanvas(name, name, PAD_WIDTH * FHCal_ROWS, PAD_HEIGHT * FHCal_COLS);
61 canAmps->Divide(FHCal_ROWS, FHCal_COLS);
62 canAmpsPads.resize(FHCal_ROWS * FHCal_COLS);
63 NamesAmps.resize(FHCal_ROWS * FHCal_COLS);
64 PadInfo* p1 = new PadInfo();
65 p1->aux = {h2_calo, h2_calo_text};
66 p1->auxOpt = {"colz logz", "text"};
67 canAmpsPads.at(0) = p1;
68 PadInfo* p2 = new PadInfo();
69 p2->current = h1d_Emodules;
70 p2->opt = "hist";
71 canAmpsPads.at(1) = p2;
72 NamesAmps.at(1) = p2->current->GetName();
73
74 canProfsPads.resize(kTOTAL_MODULES + 1, nullptr); // pads vector. + 1 blank
75 NamesProfs.resize(kTOTAL_MODULES + 1, nullptr); // pads vector. + 1 blank
76
77 name = fTitle + "CanvasProfilesSmall";
78 canProfsSmall = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
79 canProfsSmall->Divide(5, 7);
80 // Hardcode modules positions. TODO it better!
81 int ModToPadSmall[35] = {
82 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1,
83 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}; // leaving blank pad for beamhole
84 for (UInt_t iPad = 0; iPad < 35; ++iPad) {
85 PadInfo* p = new PadInfo();
86 canProfsPads.at(iPad) = p;
87 if (ModToPadSmall[iPad] < 0)
88 continue;
89 UInt_t uMod = (UInt_t)ModToPadSmall[iPad];
90 hModuleProfile.at(uMod)->GetXaxis()->SetRangeUser(1, 8);
91 p->current = hModuleProfile.at(uMod);
92 p->opt = "hist";
93 NamesProfs.at(iPad) = p->current->GetName();
94 }
95
96 name = fTitle + "CanvasProfilesBig";
97 canProfsBig = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
98 canProfsBig->Divide(4, 5);
99 int ModToPadBig[20] = {35, 36, 45, 46, 37, 38, 47, 48, 39, 40, 49, 50, 41, 42, 51, 52, 43, 44, 53, 54};
100 for (UInt_t iPad = 0; iPad < 20; ++iPad) {
101 PadInfo* p = new PadInfo();
102 canProfsPads.at(iPad + 35) = p;
103 UInt_t uMod = (UInt_t)ModToPadBig[iPad];
104 p->current = hModuleProfile.at(uMod);
105 p->opt = "hist";
106 NamesProfs.at(iPad + 35) = p->current->GetName();
107 }
108
109 name = fTitle + "_hSecE";
110 hSecE = new TH1F(name, name, 300, 0, 35000);
111 hSecE->SetStats(0);
112 hSecE->GetYaxis()->SetTitle("Counts");
113 hSecE->GetXaxis()->SetTitle("Apml");
114
115 name = fTitle + "_wfmSec";
116 wfmSec = new TH1F(name, name, 200, 0, 200);
117 wfmSec->SetMarkerStyle(31);
118 wfmSec->SetMarkerSize(0.5);
119 wfmSec->SetStats(0);
120
121 name = fTitle + "CanvasSelection";
122 canSelect = new TCanvas(name, name, PAD_WIDTH * 1, PAD_HEIGHT * 2);
123 canSelect->Divide(1, 2);
124 canSelectPads.resize(1 * 2);
125 NamesSelect.resize(1 * 2);
126 PadInfo* ps1 = new PadInfo();
127 ps1->current = hSecE;
128 ps1->opt = "hist";
129 canSelectPads.at(0) = ps1;
130 NamesSelect.at(0) = ps1->current->GetName();
131 PadInfo* ps2 = new PadInfo();
132 ps2->current = wfmSec;
133 ps2->opt = "hist lp";
134 canSelectPads.at(1) = ps2;
135 NamesSelect.at(1) = ps2->current->GetName();
136
137 name = fTitle + "_h2_mod_sec";
138 h2_mod_sec = new TH2F(name, "FHCal - Module vs Section", 12, 0, 11, 55, 0, 55);
139 h2_mod_sec->GetXaxis()->SetTitle("Section Id");
140 h2_mod_sec->GetXaxis()->SetTitleColor(kOrange + 10);
141 h2_mod_sec->GetYaxis()->SetTitle("Module Id");
142 h2_mod_sec->GetYaxis()->SetTitleColor(kOrange + 10);
143 h2_mod_sec->GetZaxis()->SetNoExponent(kFALSE);
144 h2_mod_sec->SetStats(0);
145 name = fTitle + "Canvas_mod_sec";
146 can_mod_sec = new TCanvas(name, name, 1, 1);
147 can_mod_sec->Divide(1, 1);
148 can_mod_secPads.resize(1 * 1);
149 Names_mod_sec.resize(1 * 1);
150 PadInfo* pms = new PadInfo();
151 pms->current = h2_mod_sec;
152 pms->opt = "colz logz";
153 can_mod_secPads.at(0) = pms;
154
155 name = fTitle + "_h1_totalE";
156 h1_totalE = new TH1F(name, "FHCal total energy", 700, 0, 2100);
157 h1_totalE->GetXaxis()->SetTitle("Reconstructed energy [MIP]");
158 h1_totalE->GetXaxis()->SetTitleColor(kOrange + 10);
159 h1_totalE->GetYaxis()->SetTitle("Counts / events");
160 h1_totalE->GetYaxis()->SetTitleColor(kOrange + 10);
161 h1_totalE->SetStats(0);
162 name = fTitle + "Canvas_totalE";
163 can_totalE = new TCanvas(name, name, 1, 1);
164 can_totalE->Divide(1, 1);
165 can_totalEPads.resize(1 * 1);
166 Names_totalE.resize(1 * 1);
167 PadInfo* pte = new PadInfo();
168 pte->current = h1_totalE;
169 pte->opt = "hist";
170 can_totalEPads.at(0) = pte;
171
172 name = fTitle + "_h2_totalE_hodoZ2_BT";
173 h2_totalE_hodoZ2_BT = new TH2F(name, "FHCal total energy vs Hodo Z^2 BT", 70, 0, 2100000, 50, 0, 3000);
174 h2_totalE_hodoZ2_BT->GetXaxis()->SetTitle("fIntegral");
175 h2_totalE_hodoZ2_BT->GetXaxis()->SetTitleColor(kOrange + 10);
176 h2_totalE_hodoZ2_BT->GetYaxis()->SetTitle("Hodo Z^2");
177 h2_totalE_hodoZ2_BT->GetYaxis()->SetTitleColor(kOrange + 10);
178 h2_totalE_hodoZ2_BT->SetStats(0);
179 name = fTitle + "_h2_totalE_hodoZ2_CCT2";
180 h2_totalE_hodoZ2_CCT2 = new TH2F(name, "FHCal total energy vs Hodo Z^2 CCT2", 70, 0, 2100000, 50, 0, 3000);
181 h2_totalE_hodoZ2_CCT2->GetXaxis()->SetTitle("fIntegral");
182 h2_totalE_hodoZ2_CCT2->GetXaxis()->SetTitleColor(kOrange + 10);
183 h2_totalE_hodoZ2_CCT2->GetYaxis()->SetTitle("Hodo Z^2");
184 h2_totalE_hodoZ2_CCT2->GetYaxis()->SetTitleColor(kOrange + 10);
185 h2_totalE_hodoZ2_CCT2->SetStats(0);
186 name = fTitle + "Canvas_totalE_hodoZ2";
187 can_totalE_hodoZ2 = new TCanvas(name, name, PAD_WIDTH * 2, PAD_HEIGHT * 1);
188 can_totalE_hodoZ2->Divide(2, 1);
189 can_totalE_hodoZ2Pads.resize(2 * 1);
190 Names_totalE_hodoZ2.resize(2 * 1);
191 PadInfo* pfh1 = new PadInfo();
192 pfh1->current = h2_totalE_hodoZ2_BT;
193 pfh1->opt = "colz logz";
194 can_totalE_hodoZ2Pads.at(0) = pfh1;
195 Names_totalE_hodoZ2.at(0) = pfh1->current->GetName();
196 PadInfo* pfh2 = new PadInfo();
197 pfh2->current = h2_totalE_hodoZ2_CCT2;
198 pfh2->opt = "colz logz";
199 can_totalE_hodoZ2Pads.at(1) = pfh2;
200 Names_totalE_hodoZ2.at(1) = pfh2->current->GetName();
201
202 name = fTitle + "_h2_ZL_nEvent";
203 h2_ZL_nEvent = new TH2F(name, "FHCal - ZL - nEvent", 500, 0, 10000, 50, -50, 50);
204 h2_ZL_nEvent->GetYaxis()->SetTitle("fZL");
205 h2_ZL_nEvent->GetYaxis()->SetTitleColor(kOrange + 10);
206 h2_ZL_nEvent->GetXaxis()->SetTitle("nEvent");
207 h2_ZL_nEvent->GetXaxis()->SetTitleColor(kOrange + 10);
208 h2_ZL_nEvent->GetZaxis()->SetNoExponent(kFALSE);
209 h2_ZL_nEvent->SetStats(0);
210 name = fTitle + "Canvas_ZL_nEvent";
211 can_ZL_nEvent = new TCanvas(name, name, 1, 1);
212 can_ZL_nEvent->Divide(1, 1);
213 can_ZL_nEventPads.resize(1 * 1);
214 Names_ZL_nEvent.resize(1 * 1);
215 PadInfo* pzl = new PadInfo();
216 pzl->current = h2_ZL_nEvent;
217 pzl->opt = "colz logz";
218 can_ZL_nEventPads.at(0) = pzl;
219
220 name = fTitle + "_h2_mod_ZL_nEvent";
221 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
222 h2_mod_ZL_nEvent.at(uMod) =
223 new TH2F(fTitle + Form("_ZL_Mod_%02u", uMod), Form("ZL_Mod_%02u", uMod), 500, 0, 10000, 50, -50, 50);
224 h2_mod_ZL_nEvent.at(uMod)->SetTitle(Form("Mod %03u", uMod));
225 h2_mod_ZL_nEvent.at(uMod)->SetTitleSize(0.9, "t");
226 h2_mod_ZL_nEvent.at(uMod)->GetXaxis()->SetTitle("nEvent");
227 h2_mod_ZL_nEvent.at(uMod)->GetXaxis()->SetTitleColor(kOrange + 10);
228 h2_mod_ZL_nEvent.at(uMod)->GetYaxis()->SetTitle("fZL");
229 h2_mod_ZL_nEvent.at(uMod)->GetYaxis()->SetTitleColor(kOrange + 10);
230 h2_mod_ZL_nEvent.at(uMod)->GetZaxis()->SetNoExponent(kFALSE);
231 h2_mod_ZL_nEvent.at(uMod)->SetStats(0);
232 }
233
234 canZLPads.resize(kTOTAL_MODULES + 1, nullptr); // pads vector. + 1 blank
235 NamesZL.resize(kTOTAL_MODULES + 1, nullptr); // pads vector. + 1 blank
236
237 name = fTitle + "CanvasZLSmall";
238 canZLSmall = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
239 canZLSmall->Divide(5, 7);
240 for (UInt_t iPad = 0; iPad < 35; ++iPad) {
241 PadInfo* p = new PadInfo();
242 canZLPads.at(iPad) = p;
243 if (ModToPadSmall[iPad] < 0)
244 continue;
245 UInt_t uMod = (UInt_t)ModToPadSmall[iPad];
246 p->current = h2_mod_ZL_nEvent.at(uMod);
247 p->opt = "colz logz";
248 NamesZL.at(iPad) = p->current->GetName();
249 }
250
251 name = fTitle + "CanvasZLBig";
252 canZLBig = new TCanvas(name, name, PAD_WIDTH, PAD_HEIGHT);
253 canZLBig->Divide(4, 5);
254 for (UInt_t iPad = 0; iPad < 20; ++iPad) {
255 PadInfo* p = new PadInfo();
256 canZLPads.at(iPad + 35) = p;
257 UInt_t uMod = (UInt_t)ModToPadBig[iPad];
258 p->current = h2_mod_ZL_nEvent.at(uMod);
259 p->opt = "colz logz";
260 NamesZL.at(iPad + 35) = p->current->GetName();
261 }
262}
263
264void BmnHistFHCal::Register(THttpServer* serv)
265{
266 fServer = serv;
267 fServer->Register("/", this);
268 TString path = "/" + fTitle + "/";
269 fServer->Register(path, canAmps);
270 fServer->Register(path, canProfsSmall);
271 fServer->Register(path, canProfsBig);
272 fServer->Register(path, canSelect);
273 fServer->Register(path, can_mod_sec);
274 fServer->Register(path, can_totalE);
275 fServer->Register(path, can_totalE_hodoZ2);
276 fServer->Register(path, can_ZL_nEvent);
277 fServer->Register(path, canZLSmall);
278 fServer->Register(path, canZLBig);
279 TString cmd = "/" + fName + "/->Reset()";
280 fServer->SetItemField(path.Data(), "_monitoring", "2000");
281 fServer->SetItemField(path.Data(), "_layout", "grid3x3");
282 TString cmdTitle = path + "Reset";
283 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
284 fServer->Restrict(cmdTitle, "visible=shift");
285 fServer->Restrict(cmdTitle, "allow=shift");
286 cmd = "/" + fName + "/->SetRefRun(%arg1%)";
287 cmdTitle = path + "SetRefRun";
288 fServer->RegisterCommand(cmdTitle.Data(), cmd.Data(), "button;");
289 cmdTitle = path + "ChangeSelection";
290 fServer->RegisterCommand(cmdTitle, TString("/") + fName.Data() + "/->SetSelection(%arg1%,%arg2%,%arg3%)",
291 "button;");
292 fServer->Restrict(cmdTitle, "visible=shift");
293 fServer->Restrict(cmdTitle, "allow=shift");
294 fServer->Restrict(cmdTitle.Data(), "deny=guest");
295}
296
297void BmnHistFHCal::SetDir(TFile* outFile = NULL, TTree* recoTree = NULL)
298{
299 frecoTree = recoTree;
300 fDir = NULL;
301 if (outFile != NULL)
302 fDir = outFile->mkdir(fTitle + "_hists");
303 h1d_Emodules->SetDirectory(fDir);
304 h2_calo->SetDirectory(fDir);
305 h2_calo_text->SetDirectory(fDir);
306 hSecE->SetDirectory(fDir);
307 wfmSec->SetDirectory(fDir);
308 h2_mod_sec->SetDirectory(fDir);
309 h2_ZL_nEvent->SetDirectory(fDir);
310 h1_totalE->SetDirectory(fDir);
311 h2_totalE_hodoZ2_BT->SetDirectory(fDir);
312 h2_totalE_hodoZ2_CCT2->SetDirectory(fDir);
313 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
314 hModuleProfile.at(uMod)->SetDirectory(fDir);
315 h2_mod_ZL_nEvent.at(uMod)->SetDirectory(fDir);
316 }
317}
318
319void BmnHistFHCal::SetSelection(Int_t Module, Int_t Section, Int_t Trigger)
320{
321 fSelectedModule = Module;
322 fSelectedSection = Section;
323 fSelectedTrigger = Trigger;
324 TString command = "(1)";
325 TString digiInTree = "FHCalDigi";
326 if (fSelectedModule >= 0)
327 command = command + Form(" && %s.GetModuleId() == %d", digiInTree.Data(), fSelectedModule);
328 if (fSelectedSection >= 0)
329 command = command + Form(" && %s.GetSectionId() == %d", digiInTree.Data(), fSelectedSection);
330 TString triggerCondition = "";
331 if (fSelectedTrigger >= 0)
332 triggerCondition = Form(" && %s trigger bit == %d (bitBT=2, bitBC1=3, bitMBT=6, bitNiT=4, bitCCT1=5, "
333 "bitCCT2=8, bitCCT3=12, bitFHCAL=9)",
334 digiInTree.Data(), fSelectedTrigger);
335 TString titleSignal = Form("#splitline{Signal %s}{%s}", command.Data(), triggerCondition.Data());
336 hSecE->SetTitle(titleSignal);
337 TString titleWfm = Form("#splitline{Wfm %s}{%s}", command.Data(), triggerCondition.Data());
338 wfmSec->SetTitle(titleWfm);
339 hSecE->Reset();
340 wfmSec->Reset();
341 if (frecoTree != NULL) {
342 TString direction = Form("%s.fAmpl>>%s", digiInTree.Data(), hSecE->GetName());
343 frecoTree->Draw(direction.Data(), command.Data(), "goff");
344 wfmSec->SetTitle(titleWfm);
345 }
346}
347
349{
350 BmnHist::DrawRef(canAmps, &canAmpsPads);
351 std::vector<PadInfo*> hsubPadsSmall(&canProfsPads[0], &canProfsPads[35]);
352 BmnHist::DrawRef(canProfsSmall, &hsubPadsSmall);
353 std::vector<PadInfo*> hsubPadsBig(canProfsPads.begin() + 35, canProfsPads.end());
354 BmnHist::DrawRef(canProfsBig, &hsubPadsBig);
355 std::vector<PadInfo*> hsubPadsZLSmall(&canZLPads[0], &canZLPads[35]);
356 BmnHist::DrawRef(canZLSmall, &hsubPadsZLSmall);
357 std::vector<PadInfo*> hsubPadsZLBig(canZLPads.begin() + 35, canZLPads.end());
358 BmnHist::DrawRef(canZLBig, &hsubPadsZLBig);
359 BmnHist::DrawRef(canSelect, &canSelectPads);
360 BmnHist::DrawRef(can_mod_sec, &can_mod_secPads);
361 BmnHist::DrawRef(can_ZL_nEvent, &can_ZL_nEventPads);
362 BmnHist::DrawRef(can_totalE, &can_totalEPads);
363 BmnHist::DrawRef(can_totalE_hodoZ2, &can_totalE_hodoZ2Pads);
364 return;
365}
366
368{
369 BmnEventHeader* head = fDigiArrays->header;
370 TClonesArray* digits = fDigiArrays->fhcal;
371 if (!digits)
372 return;
373
374 // Hardcoded FHCal sampling factor. Taken from SRC 2022 run
375 // double beam_pos = 193; // beam position in mips
376 // double momentum = 3.5; // AGeV/c
377 // double m_parton = 0.939; // GeV
378 // double energ = sqrt(momentum * momentum + m_parton * m_parton);
379 // double kin_energ = 12 * (energ - m_parton);
380 // double Mip2GeV = kin_energ / beam_pos;
381 double sumE = 0;
382 double sumInt = 0;
383
384 h1d_Emodules->Scale(fEventCounter);
385 h2_calo->Scale(fEventCounter);
386 h2_mod_sec->Scale(fEventCounter);
387 h1_totalE->Scale(fEventCounter);
388 h2_totalE_hodoZ2_BT->Scale(fEventCounter);
389 h2_totalE_hodoZ2_CCT2->Scale(fEventCounter);
390 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod)
391 hModuleProfile.at(uMod)->Scale(fEventCounter);
392
393 for (Int_t iDig = 0; iDig < digits->GetEntriesFast(); iDig++) {
394 BmnFHCalDigi* digi = (BmnFHCalDigi*)digits->At(iDig);
395 double signal = digi->GetSignal(); // * Mip20GeV;
396 h1d_Emodules->Fill(digi->GetModuleId(), signal);
397
398 const auto& positionMap = fGeoHandler->GetPositionMap();
399 auto it = positionMap.find(digi->GetAddress());
400 if (it == positionMap.end())
401 continue;
402 float realXpos = it->second.first.X();
403 float realYpos = it->second.first.Y();
404 // float realZpos = position.Z();
405 h2_calo->Fill(realXpos, realYpos, signal);
406 h2_mod_sec->Fill(digi->GetSectionId(), digi->GetModuleId(), signal);
407 sumE += signal;
408 sumInt += digi->fIntegral;
409
410 h2_ZL_nEvent->Fill(fEventCounterZL, digi->fZL);
411 h2_mod_ZL_nEvent.at(digi->GetModuleId())->Fill(fEventCounterZL, digi->fZL);
412
413 // TODO it better! fill one time
414 int bin_x = h2_calo_text->GetXaxis()->FindBin(realXpos);
415 int bin_y = h2_calo_text->GetYaxis()->FindBin(realYpos);
416 int BC = h2_calo_text->GetBinContent(bin_x, bin_y);
417 if (BC == 0)
418 h2_calo_text->Fill(realXpos, realYpos, digi->GetModuleId());
419
420 UInt_t TrigPattern = head->GetInputSignalsAR();
421 // auto bitBT = (TrigPattern >> 2) & 1; // BT
422 // auto bitBC1 = (TrigPattern >> 3) & 1; // BC1
423 // auto bitMBT = (TrigPattern >> 6) & 1; // MBT
424 // auto bitNiT = (TrigPattern >> 4) & 1; // NiT
425 // auto bitCCT1 = (TrigPattern >> 5) & 1; // CCT1
426 // auto bitCCT2 = (TrigPattern >> 8) & 1; // CCT2
427 // auto bitCCT3 = (TrigPattern >> 12) & 1; // CCT3
428 // auto bitFHCAL = (TrigPattern >> 9) & 1; // FHCAL
429
430 bool isSelected =
431 ((Int_t)digi->GetModuleId() == fSelectedModule) && ((Int_t)digi->GetSectionId() == fSelectedSection);
432 if (isSelected) {
433 if ((TrigPattern >> fSelectedTrigger) & 1) {
434 hSecE->Fill(digi->fAmpl);
435 auto Wfm = digi->GetWfm();
436 std::vector<float> points(Wfm.size());
437 std::iota(std::begin(points), std::end(points), 0); // Fill with 0, 1, ..., wfm.back().
438 wfmSec->Reset();
439 wfmSec->GetXaxis()->SetRangeUser(0, Wfm.size());
440 for (UInt_t wfm_iter = 0; wfm_iter < Wfm.size(); wfm_iter++)
441 wfmSec->Fill(wfm_iter, Wfm.at(wfm_iter));
442 }
443 }
444
445 hModuleProfile.at(digi->GetModuleId())->Fill(digi->GetSectionId(), signal);
446 }
447 fEventCounter++;
448 fEventCounterZL++;
449 if (sumE > 0.5)
450 h1_totalE->Fill(sumE);
451 h1_totalE->Scale(1. / fEventCounter);
452 h1d_Emodules->Scale(1. / fEventCounter);
453 h2_calo->Scale(1. / fEventCounter);
454 h2_mod_sec->Scale(1. / fEventCounter);
455 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod)
456 hModuleProfile.at(uMod)->Scale(1. / fEventCounter);
457 if (fEventCounterZL >= 10000) {
458 h2_ZL_nEvent->Reset();
459 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
460 h2_mod_ZL_nEvent.at(uMod)->Reset();
461 }
462 fEventCounterZL = 0;
463 }
464 TClonesArray* digits_hodo = fDigiArrays->hodo;
465 if (!digits_hodo)
466 return;
467 double z2 = 0;
468 float responses[kNstrips + 1][kNsides];
469 memset(responses, 0, sizeof(responses[0][0]) * (kNstrips + 1) * kNsides);
470 for (Int_t iDig = 0; iDig < digits_hodo->GetEntriesFast(); iDig++) {
471 BmnHodoDigi* digi = (BmnHodoDigi*)digits_hodo->At(iDig);
472 double signal = digi->GetSignal();
473 auto strip = digi->GetStripId();
474 auto side = digi->GetStripSide();
475 // auto gain = digi->GetGain();
476 // if(gain != 1) continue;
477 responses[strip][side] = signal;
478 z2 += signal;
479 }
480 // for (int i = 1; i <= kNstrips; i++)
481 // if(responses[i][0] * responses[i][1] > 0.001)
482 // z2 = (responses[i][0] + responses[i][1])/2;
483 // if(responses[i][0] > 0.001)
484 // z2 = responses[i][0];
485 if (z2 > 0.5 && sumInt > 0.5) {
486 UInt_t TrigPattern = head->GetInputSignalsAR();
487 auto bitBT = (TrigPattern >> 2) & 1; // BT
488 // auto bitBC1 = (TrigPattern >> 3) & 1; //BC1
489 auto bitMBT = (TrigPattern >> 6) & 1; // MBT
490 // auto bitNiT = (TrigPattern >> 4) & 1; //NiT
491 auto bitCCT1 = (TrigPattern >> 5) & 1; // CCT1
492 auto bitCCT2 = (TrigPattern >> 8) & 1; // CCT2
493 auto bitCCT3 = (TrigPattern >> 12) & 1; // CCT3
494 auto bitFHCAL = (TrigPattern >> 9) & 1; // FHCAL
495 bool trigBT =
496 (bitBT == 1) && (bitMBT == 0) && (bitCCT1 == 0) && (bitCCT2 == 0) && (bitCCT3 == 0) && (bitFHCAL == 0);
497 // bool trigMBT = (bitMBT == 1) && (bitNiT == 0);
498 // bool trigCCT1 = (bitCCT1 == 1) && (bitMBT == 0) && (bitCCT2 == 0);
499 bool trigCCT2 = (bitCCT2 == 1);
500 if (trigBT)
501 h2_totalE_hodoZ2_BT->Fill(sumInt, z2);
502 if (trigCCT2)
503 h2_totalE_hodoZ2_CCT2->Fill(sumInt, z2);
504 }
505 h2_totalE_hodoZ2_BT->Scale(1. / fEventCounter);
506 h2_totalE_hodoZ2_CCT2->Scale(1. / fEventCounter);
507}
508
510{
511 TString FileName = Form("bmn_run%04d_hist.root", id);
512 printf("SetRefRun: %s\n", FileName.Data());
513 if (refRunName != FileName) {
514 refRunName = FileName;
515 refID = id;
516 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canAmpsPads, NamesAmps);
517 BmnHist::LoadRefRun(refID, refPath + FileName, fTitle, canProfsPads, NamesProfs);
518 DrawBoth();
519 }
520 return kBMNSUCCESS;
521}
522
524{
525 for (auto pad : canAmpsPads) {
526 if (pad->ref)
527 delete pad->ref;
528 pad->ref = NULL;
529 }
530 for (auto pad : canProfsPads) {
531 if (pad->ref)
532 delete pad->ref;
533 pad->ref = NULL;
534 }
535 refID = 0;
536}
537
539{
540 printf("BmnHistFHCal : Reset histos\n");
541 fEventCounter = 1;
542 h1d_Emodules->Reset();
543 h2_calo->Reset();
544 h2_calo_text->Reset();
545 wfmSec->Reset();
546 hSecE->Reset();
547 h2_mod_sec->Reset();
548 // h2_ZL_nEvent->Reset();
549 h1_totalE->Reset();
550 h2_totalE_hodoZ2_BT->Reset();
551 h2_totalE_hodoZ2_CCT2->Reset();
552 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
553 hModuleProfile.at(uMod)->Reset();
554 // h2_mod_ZL_nEvent.at(uMod)->Reset();
555 }
556}
558{
559 if (fGeoHandler)
560 delete fGeoHandler;
561 delete canAmps;
562 delete canProfsSmall;
563 delete canProfsBig;
564 delete canSelect;
565 delete can_mod_sec;
566 delete can_ZL_nEvent;
567 if (fDir != NULL)
568 return;
569 delete h1d_Emodules;
570 delete h2_calo;
571 delete h2_calo_text;
572 delete wfmSec;
573 delete hSecE;
574 delete h2_mod_sec;
575 delete h2_ZL_nEvent;
576 delete h1_totalE;
577 delete h2_totalE_hodoZ2_BT;
578 delete h2_totalE_hodoZ2_CCT2;
579 for (UInt_t uMod = 1; uMod <= kTOTAL_MODULES; ++uMod) {
580 delete hModuleProfile.at(uMod);
581 delete h2_mod_ZL_nEvent.at(uMod);
582 }
583}
#define PAD_WIDTH
Definition BmnAdcQA.cxx:3
#define PAD_HEIGHT
Definition BmnAdcQA.cxx:4
void memset(T *dest, T i, size_t num)
uses binary expansion of copied volume for speed up
Definition L1Grid.h:25
BmnStatus
Definition BmnEnums.h:24
@ kBMNSUCCESS
Definition BmnEnums.h:25
BmnSetup
Definition BmnEnums.h:89
double GetSignal() const
uint32_t GetAddress() const
int fZL
Amplitude from waveform [adc counts].
std::vector< float > GetWfm() const
Waveform.
int fIntegral
ZeroLevel from waveform [adc counts].
UInt_t GetInputSignalsAR()
Data class for Bmn FHCal digital signal processing.
uint32_t GetSectionId() const
uint32_t GetModuleId() const
BmnStatus ReadGeometryFromFile(const std::string &path, bool getGlobalPosition=true)
const auto & GetPositionMap() const
void FillFromDigi(DigiArrays *fDigiArrays)
void SetGeometry(const std::string &path)
BmnStatus SetRefRun(Int_t id)
void CreateHistos()
virtual ~BmnHistFHCal()
BmnHistFHCal(TString title="FHCal", TString path="", Int_t periodID=8, BmnSetup setup=kBMNSETUP)
void SetDir(TFile *outFile, TTree *recoTree)
void Register(THttpServer *serv)
void SetSelection(Int_t Module, Int_t Section, Int_t Trigger)
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
Data class for BmnHodo digital signal processing.
Definition BmnHodoDigi.h:25
uint32_t GetStripSide() const
Strip Side.
Definition BmnHodoDigi.h:65
uint32_t GetStripId() const
TClonesArray * fhcal
Definition DigiArrays.h:134
BmnEventHeader * header
Definition DigiArrays.h:146
TClonesArray * hodo
Definition DigiArrays.h:135
Storage for pad content and it's options.
Definition PadInfo.h:20
string opt
Definition PadInfo.h:88
vector< TH1 * > aux
Definition PadInfo.h:80
vector< TString > auxOpt
Definition PadInfo.h:81
TH1 * current
Definition PadInfo.h:78
#define FHCal_COLS
#define FHCal_ROWS