40 std::srand(std::time(0));
42 auto run = FairRunOnline::Instance();
43 if (run !=
nullptr && run->GetHttpServer() !=
nullptr)
50 run->GetHttpServer()->Register(
"/Tasks",
this);
51 run->GetHttpServer()->RegisterCommand(
"Reset_Neuland", Form(
"/Tasks/%s/->ResetHistos()", GetName()));
52 run->GetHttpServer()->RegisterCommand(
"Reset_Neuland_Mapped",
53 Form(
"/Tasks/%s/->ResetHistosMapped()", GetName()));
56 auto ioman = FairRootManager::Instance();
59 throw std::runtime_error(
"R3BNeulandOnlineSpectra: No FairRootManager");
62 fEventHeader =
dynamic_cast<R3BEventHeader*
>(ioman->GetObject(
"EventHeader."));
63 if (fEventHeader ==
nullptr)
65 throw std::runtime_error(
"R3BNeulandOnlineSpectra: No R3BEventHeader");
68 fNeulandMappedData.Init();
69 fNeulandCalData.Init();
72 auto canvasMapped =
new TCanvas(
"NeulandMapped",
"NeulandMapped", 10, 10, 850, 850);
73 canvasMapped->Divide(1, 2);
76 ahMappedBar1[0] =
R3B::root_owned<TH1D>(
"hMappedBar1fLE",
"Mapped: Bars fine 1LE", fNBars, 0.5, fNBars + 0.5);
77 ahMappedBar1[0]->Draw();
78 ahMappedBar1[1] =
R3B::root_owned<TH1D>(
"hMappedBar1fTE",
"Mapped: Bars fine 1TE", fNBars, 0.5, fNBars + 0.5);
79 ahMappedBar1[1]->SetLineColor(1);
80 ahMappedBar1[1]->Draw(
"same");
81 ahMappedBar1[2] =
R3B::root_owned<TH1D>(
"hMappedBar1cLE",
"Mapped: Bars coarse 1LE", fNBars, 0.5, fNBars + 0.5);
82 ahMappedBar1[2]->SetLineColor(2);
83 ahMappedBar1[2]->Draw(
"same");
84 ahMappedBar1[3] =
R3B::root_owned<TH1D>(
"hMappedBar1cTE",
"Mapped: Bars coarse 1TE", fNBars, 0.5, fNBars + 0.5);
85 ahMappedBar1[3]->SetLineColor(6);
86 ahMappedBar1[3]->Draw(
"same");
89 ahMappedBar2[0] =
R3B::root_owned<TH1D>(
"hMappedBar2fLE",
"Mapped: Bars fine 2LE", fNBars, 0.5, fNBars + 0.5);
90 ahMappedBar2[0]->Draw();
91 ahMappedBar2[1] =
R3B::root_owned<TH1D>(
"hMappedBar2fTE",
"Mapped: Bars fine 2TE", fNBars, 0.5, fNBars + 0.5);
92 ahMappedBar2[1]->SetLineColor(1);
93 ahMappedBar2[1]->Draw(
"same");
94 ahMappedBar2[2] =
R3B::root_owned<TH1D>(
"hMappedBar2cLE",
"Mapped: Bars coarse 2LE", fNBars, 0.5, fNBars + 0.5);
95 ahMappedBar2[2]->SetLineColor(2);
96 ahMappedBar2[2]->Draw(
"same");
97 ahMappedBar2[3] =
R3B::root_owned<TH1D>(
"hMappedBar2cTE",
"Mapped: Bars coarse 2TE", fNBars, 0.5, fNBars + 0.5);
98 ahMappedBar2[3]->SetLineColor(6);
99 ahMappedBar2[3]->Draw(
"same");
104 run->AddObject(canvasMapped);
107 auto canvasJump =
new TCanvas(
"NeulandJumps",
"NeulandJumps", 10, 10, 850, 850);
108 canvasJump->Divide(1, 2);
110 hJumpsvsEvnt =
R3B::root_owned<TH2D>(
"hJumpsvsEvnt",
"Jumps vs Evnt", 1000, 0, 10000000, 1000, -11000, 11000);
113 hJumpsvsEvnt->Draw(
"colz");
116 R3B::root_owned<TH2D>(
"hJumpsvsEvntzoom",
"Jumps vs Evnt zoomed", 1000, 0, 10000000, 1000, -200, 200);
119 hJumpsvsEvntzoom->Draw(
"colz");
124 run->AddObject(canvasJump);
127 auto canvasCal =
new TCanvas(
"NeulandCal",
"NeulandCal", 10, 10, 850, 850);
128 canvasCal->Divide(2, 3);
135 hTestJump =
R3B::root_owned<TH2D>(
"hTestJump",
"Test Jump", fNBars, 0.5, fNBars + 0.5, 1000, -11000., 11000.);
139 hTestJump->Draw(
"colz");
142 "hCalT1vsBar",
"CalLevel: Time1 vs Bars ", fNBars, 0.5, fNBars + 0.5, 2000, -5000, 15000);
144 ahCalTvsBar[0]->Draw(
"colz");
147 "hCalT2vsBar",
"CalLevel: Time2 vs Bars ", fNBars, 0.5, fNBars + 0.5, 2000, -5000, 15000);
149 ahCalTvsBar[1]->Draw(
"colz");
152 R3B::root_owned<TH2D>(
"hCalE1vsBar",
"CalLevel: Energy1 vs Bars", fNBars, 0.5, fNBars + 0.5, 600, 0, 600);
154 ahCalEvsBar[0]->Draw(
"colz");
157 R3B::root_owned<TH2D>(
"hCalE2vsBar",
"CalLevel: Energy2 vs Bars", fNBars, 0.5, fNBars + 0.5, 600, 0, 600);
159 ahCalEvsBar[1]->Draw(
"colz");
164 run->AddObject(canvasCal);
167 auto canvasHit =
new TCanvas(
"NeulandHit",
"NeulandHit", 10, 10, 850, 850);
168 canvasHit->Divide(2, 2);
171 R3B::root_owned<TH2D>(
"hHitEvsBar",
"HitLevel: Energy vs Bars ", fNBars, 0.5, fNBars + 0.5, 1000, 0, 60);
173 hHitEvsBar->Draw(
"colz");
175 hTdiffvsBar =
R3B::root_owned<TH2D>(
"hTdiffvsBar",
"Tdiff vs Bars", fNBars, 0.5, fNBars + 0.5, 1000, -60, 60);
177 hTdiffvsBar->Draw(
"colz");
179 hToFvsBar =
R3B::root_owned<TH2D>(
"hTofvsBar",
"Tof vs Bars", fNBars, 0.5, fNBars + 0.5, 6000, -100, 400);
180 hToFcvsBar =
R3B::root_owned<TH2D>(
"hTofcvsBar",
"Tofc vs Bars", fNBars, 0.5, fNBars + 0.5, 6000, -100, 400);
183 hToFvsBar->Draw(
"colz");
189 hTofvsEhit->Draw(
"colz");
194 run->AddObject(canvasHit);
197 auto canvasHitCosmics =
new TCanvas(
"NeulandHitCosmics",
"NeulandHitCosmics", 10, 10, 850, 850);
198 canvasHitCosmics->Divide(2, 2);
201 "hHitEvsBarCosmics",
"HitLevel: Energy vs Bars cosmics", fNBars, 0.5, fNBars + 0.5, 1000, 0, 60);
202 canvasHitCosmics->cd(1);
203 hHitEvsBarCosmics->Draw(
"colz");
206 R3B::root_owned<TH2D>(
"hTdiffvsBarCosmics",
"Tdiff vs Bars cosmics", fNBars, 0.5, fNBars + 0.5, 1000, -60, 60);
207 canvasHitCosmics->cd(2);
208 hTdiffvsBarCosmics->Draw(
"colz");
211 R3B::root_owned<TH2D>(
"hDT675",
"Thit - Thit675 vs Bars cosmics", fNBars, 0.5, fNBars + 0.5, 1000, -20, 20);
212 canvasHitCosmics->cd(3);
213 hDT675->Draw(
"colz");
216 "hDT675c",
"Thit - Thit675 vs Bars cosmics corrected", fNBars, 0.5, fNBars + 0.5, 1000, -20, 20);
219 R3B::root_owned<TH2D>(
"hDT625",
"Thit - Thit625 vs Bars cosmics", fNBars, 0.5, fNBars + 0.5, 1000, -20, 20);
220 canvasHitCosmics->cd(4);
221 hDT625->Draw(
"colz");
224 "hDT625c",
"Thit - Thit625 vs Bars cosmics corrected", fNBars, 0.5, fNBars + 0.5, 1000, -20, 20);
226 canvasHitCosmics->cd(0);
229 run->AddObject(canvasHitCosmics);
232 auto canvasPlaneXY =
new TCanvas(
"NeulandPlaneXY",
"NeulandPlaneXY", 10, 10, 850, 850);
233 canvasPlaneXY->Divide(5, 6);
234 for (
unsigned int i = 0; i < fNPlanes; i++)
237 "Hit XY Plane" + TString::Itoa(i, 10),
244 canvasPlaneXY->cd(i + 1);
245 ahXYperPlane[i]->Draw(
"colz");
247 canvasPlaneXY->cd(0);
250 run->AddObject(canvasPlaneXY);
253 auto canvasPlaneSofia =
new TCanvas(
"Timing",
"Timing", 10, 10, 850, 850);
254 canvasPlaneSofia->Divide(2, 2);
267 R3B::root_owned<TH2D>(
"hNeuLANDvsStart",
"hNeuLANDvsStart", 3000, -10000, 40000, 1000, -10000, 10000);
268 canvasPlaneSofia->cd(1);
269 hNeuLANDvsStart->Draw(
"colz");
273 canvasPlaneSofia->cd(2);
279 canvasPlaneSofia->cd(3);
281 hTofcvsX->Draw(
"colz");
284 canvasPlaneSofia->cd(4);
287 hTofvsZ->Draw(
"colz");
289 canvasPlaneSofia->cd(0);
292 run->AddObject(canvasPlaneSofia);
300 const double clight = 29.9792458;
302 const double start = fEventHeader->GetTStart();
304 if (((UInt_t)fEventHeader->GetEventno() % 10000000) < 10000)
306 hJumpsvsEvnt->Reset();
307 hJumpsvsEvntzoom->Reset();
310 const auto mappedData = fNeulandMappedData.Retrieve();
311 const auto calData = fNeulandCalData.Retrieve();
312 const auto hits = fNeulandHits.Retrieve();
314 for (
const auto& mapped : mappedData)
316 const auto plane = mapped->GetPlaneId();
317 const auto barp = mapped->GetBarId();
318 const auto bar = (plane - 1) * 50 + barp;
320 if (mapped->GetFineTime1LE() > 0)
321 ahMappedBar1[0]->Fill(bar);
322 if (mapped->GetFineTime1TE() > 0)
323 ahMappedBar1[1]->Fill(bar);
324 if (mapped->GetCoarseTime1LE() > 0)
325 ahMappedBar1[2]->Fill(bar);
326 if (mapped->GetCoarseTime1TE() > 0)
327 ahMappedBar1[3]->Fill(bar);
328 if (mapped->GetFineTime2LE() > 0)
329 ahMappedBar2[0]->Fill(bar);
330 if (mapped->GetFineTime2TE() > 0)
331 ahMappedBar2[1]->Fill(bar);
332 if (mapped->GetCoarseTime2LE() > 0)
333 ahMappedBar2[2]->Fill(bar);
334 if (mapped->GetCoarseTime2TE() > 0)
335 ahMappedBar2[3]->Fill(bar);
338 for (
const auto& data : calData)
340 const auto side = data->GetSide() - 1;
341 const auto bar = data->GetBarId();
342 ahCalTvsBar[side]->Fill(bar, data->GetTime());
343 ahCalEvsBar[side]->Fill(bar, data->GetQdc());
344 if (std::isnan(data->GetTriggerTime()))
346 hNeuLANDvsStart->Fill(start, data->GetTime());
350 hNeuLANDvsStart->Fill(start, data->GetTime() - data->GetTriggerTime());
353 for (
const auto& datax : calData)
355 const auto sidex = datax->GetSide() - 1;
356 const auto barx = datax->GetBarId();
360 hTestJump->Fill(barx, data->GetTime() - datax->GetTime());
361 hJumpsvsEvnt->Fill((UInt_t)fEventHeader->GetEventno() % 10000000, data->GetTime() - datax->GetTime());
362 hJumpsvsEvntzoom->Fill((UInt_t)fEventHeader->GetEventno() % 10000000,
363 data->GetTime() - datax->GetTime());
370 for (
const auto& hit : hits)
372 const auto bar = hit->GetPaddle();
376 hTstart->Fill(start);
377 if (std::isnan(hit->GetT()))
379 hHitEvsBar->Fill(bar, hit->GetE());
380 hTdiffvsBar->Fill(bar, hit->GetTdcL() - hit->GetTdcR());
382 const Double_t tcorr = hit->GetT() - (hit->GetPosition().Mag() - fDistanceToTarget) / clight;
383 const Double_t tadj = hit->GetT();
385 if (hit->GetE() > 0.)
387 hToFvsBar->Fill(bar, tadj);
388 hToFcvsBar->Fill(bar, tcorr);
393 hTofvsEhit->Fill(hit->GetE(), tadj);
394 hTofcvsEhit->Fill(hit->GetE(), tcorr);
396 randx = (std::rand() / (float)RAND_MAX);
397 const int plane =
static_cast<const int>(std::floor((hit->GetPaddle() - 1) / 50));
398 ahXYperPlane[plane]->Fill(hit->GetPosition().X() + (plane % 2) * 5. * (randx - 0.5),
399 hit->GetPosition().Y() + ((plane + 1) % 2) * 5. * (randx - 0.5));
401 hTofvsX->Fill(hit->GetPosition().X() + (plane % 2) * 5. * (randx - 0.5), tadj);
402 hTofcvsX->Fill(hit->GetPosition().X() + (plane % 2) * 5. * (randx - 0.5), tcorr);
403 hTofvsY->Fill(hit->GetPosition().Y() + ((plane + 1) % 2) * 5. * (randx - 0.5), tadj);
404 hTofcvsY->Fill(hit->GetPosition().Y() + ((plane + 1) % 2) * 5. * (randx - 0.5), tcorr);
405 hTofvsZ->Fill(plane, tadj);
406 hTofcvsZ->Fill(plane, tcorr);
410 if ((fEventHeader->GetTpat() & fCosmicTpat) == fCosmicTpat)
412 hHitEvsBarCosmics->Fill(bar, hit->GetE());
413 hTdiffvsBarCosmics->Fill(bar, hit->GetTdcL() - hit->GetTdcR());
415 for (
const auto& hitref : hits)
417 if ((hitref->GetPaddle() == 675) && (bar != 675))
420 bar, (hit->GetTdcL() + hit->GetTdcR()) / 2. - (hitref->GetTdcL() + hitref->GetTdcR()) / 2.);
422 (hit->GetTdcL() + hit->GetTdcR()) / 2. -
423 (hitref->GetTdcL() + hitref->GetTdcR()) / 2. +
424 copysign(1., (hit->GetPosition() - hitref->GetPosition()).Y()) *
425 (hit->GetPosition() - hitref->GetPosition()).Mag() / clight);
427 if ((hitref->GetPaddle() == 625) && (bar != 625))
430 bar, (hit->GetTdcL() + hit->GetTdcR()) / 2. - (hitref->GetTdcL() + hitref->GetTdcR()) / 2.);
432 (hit->GetTdcL() + hit->GetTdcR()) / 2. -
433 (hitref->GetTdcL() + hitref->GetTdcR()) / 2. +
434 copysign(1., (hit->GetPosition() - hitref->GetPosition()).Y()) *
435 (hit->GetPosition() - hitref->GetPosition()).Mag() / clight);