11 #include <svd/modules/svdCalibration/SVDLocalCalibrationsCheckModule.h>
12 #include <vxd/geometry/GeoCache.h>
13 #include <svd/geometry/SensorInfo.h>
17 #include <TPaveText.h>
35 setDescription(
"Module to produce a list of histograms showing the uploaded calibration constants");
38 addParam(
"outputPdfName", m_outputPdfName,
"output pdf filename", std::string(
"SVDLocalCalibrationsCheck.pdf"));
39 addParam(
"referenceID", m_idFileNameREF,
"ID of REFERENCE xml file.",
40 std::string(
"refID"));
41 addParam(
"checkID", m_idFileNameCHECK,
"ID of CHECK xml file.",
42 std::string(
"checkID"));
43 addParam(
"reference_root", m_rootFileNameREF,
"Name of REFERENCE root file.",
44 std::string(
"SVDLocalCalibrationsMonitor_ref.root"));
45 addParam(
"check_root", m_rootFileNameCHECK,
"Name of CHECK root file.",
46 std::string(
"SVDLocalCalibrationsMonitor_check.root"));
47 addParam(
"plotGoodAPVs", m_plotGoodAPVs,
"If true draw 1D plots also for good APVs",
bool(
false));
49 addParam(
"cutN_outliers", m_cutN_out,
"Max number of outliers allowed",
int(5));
50 addParam(
"cutNoise_average", m_cutNoise_ave,
"Max deviation of average noise per APV, in ADC",
float(0.1));
51 addParam(
"cutNoise_outliers", m_cutNoise_out,
"Max deviation of single strip, in ADC",
float(2));
52 addParam(
"cutCalPeakADC_average", m_cutCalpeakADC_ave,
"Max deviation of average CalPeakADC per APV, in ADC",
float(4));
53 addParam(
"cutCalPeakADC_outliers", m_cutCalpeakADC_out,
"Max deviation of single strip, in ADC",
float(10));
54 addParam(
"cutPedestal_average", m_cutPedestal_ave,
"Max deviation of average pedestal per APV, in ADC",
float(4));
55 addParam(
"cutPedestal_outliers", m_cutPedestal_out,
"Max deviation of single strip, in ADC",
float(10));
61 B2INFO(
"SVD Local Calibration Check Configuration");
62 B2INFO(
"-----------------------------------------");
64 B2INFO(
"- input files:");
67 B2INFO(
"- output file:");
70 B2INFO(
"- analysis parameters:");
71 B2INFO(
" outliers (Noise, Pedestal, CalPeakADC)");
72 B2INFO(
" max allowed outliers = " <<
m_cutN_out);
74 B2INFO(
" max difference on the APV averages = " <<
m_cutNoise_ave <<
" ADC");
75 B2INFO(
" max to mark a strip as outlier = " <<
m_cutNoise_out <<
" ADC");
76 B2INFO(
" CalPeakADC");
82 B2INFO(
"--------------------------------------------------------------");
91 gStyle->SetOptStat(0);
92 gStyle->SetLegendBorderSize(0);
93 gStyle->SetTextFont(42);
143 TH1F template_noise(
"noiseDIFF_L@layerL@ladderS@sensor@view@apv",
144 "Noise Deviation Distribution in @layer.@ladder.@sensor @view/@side",
148 template_noise.GetXaxis()->SetTitle(
"ref - check (ADC)");
160 TH1F template_calpeakTime(
"calpeakTimeDIFF_L@layerL@ladderS@sensor@view@apv",
162 "CalPeakTime Deviation Distribution in @layer.@ladder.@sensor @view/@side",
164 template_calpeakTime.GetXaxis()->SetTitle(
"( ref - check ) / ref");
168 "Number of problematic APV chips due to CalPeakTime for @view/@side Side for @view/@side Side");
174 TH1F template_calpeakADC(
"calpeakADCDIFF_L@layerL@ladderS@sensor@view@apv",
176 "CalPeakADC Deviation Distribution in @layer.@ladder.@sensor @view/@side",
178 template_calpeakADC.GetXaxis()->SetTitle(
"ref - check (ADC)");
182 "Number of problematic APV chips due to CalPeakADC for @view/@side Side");
189 TH1F template_pedestal(
"pedestalDIFF_L@layerL@ladderS@sensor@view@apv",
190 "Pedestal Deviation Distribution in @layer.@ladder.@sensor @view/@side",
194 template_pedestal.GetXaxis()->SetTitle(
"( ref - check) (ADC)");
198 "Number of problematic APV chips due to Pedestal for @view/@side Side");
207 Long64_t nentries =
m_treeREF->GetEntriesFast();
209 for (Long64_t jentry = 0; jentry < nentries; jentry++) {
233 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
235 while ((itSvdLayers != svdLayers.end()) && (itSvdLayers->getLayerNumber() != 7)) {
239 int layer = itSvdLayers->getLayerNumber();
245 std::set<Belle2::VxdID> svdLadders = aGeometry.
getLadders(*itSvdLayers);
246 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
248 while (itSvdLadders != svdLadders.end()) {
250 std::set<Belle2::VxdID> svdSensors = aGeometry.
getSensors(*itSvdLadders);
251 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
253 while (itSvdSensors != svdSensors.end()) {
254 B2DEBUG(1,
" svd sensor info " << *itSvdSensors);
257 int ladder = itSvdSensors->getLadderNumber();
258 int sensor = itSvdSensors->getSensorNumber();
262 TList* listEmpty =
new TList;
265 TList* listNoiseUBAD =
new TList;
266 TList* listNoiseUGOOD =
new TList;
267 TList* listNoiseVBAD =
new TList;
268 TList* listNoiseVGOOD =
new TList;
272 TList* listCalpeakADCUBAD =
new TList;
273 TList* listCalpeakADCUGOOD =
new TList;
274 TList* listCalpeakADCVBAD =
new TList;
275 TList* listCalpeakADCVGOOD =
new TList;
278 TList* listCalpeakTimeUGOOD =
new TList;
279 TList* listCalpeakTimeVGOOD =
new TList;
282 TList* listPedestalUBAD =
new TList;
283 TList* listPedestalUGOOD =
new TList;
284 TList* listPedestalVBAD =
new TList;
285 TList* listPedestalVGOOD =
new TList;
287 bool needPlot =
false;
288 for (
int side = 0; side < 2; side++) {
290 int Ncells = currentSensorInfo->
getUCells();
294 int Napv = Ncells / 128;
296 for (
int m_APV = 0; m_APV < Napv; m_APV++) {
305 B2INFO(
"WARNING, ONE APV has Noise problems in: L" << layer <<
"L" << ladder <<
"S" << sensor <<
" side = " << side <<
306 ", APV number = " << m_APV <<
", problem ID = " << problem);
309 listNoiseVBAD->Add(hNoise);
311 listNoiseUBAD->Add(hNoise);
314 listNoiseVGOOD->Add(hNoise);
316 listNoiseUGOOD->Add(hNoise);
326 B2INFO(
"WARNING, ONE APV has CalpeakADC problems in: L" << layer <<
"L" << ladder <<
"S" << sensor <<
" side = " << side <<
327 ", APV number = " << m_APV <<
" problem ID = " << problem);
330 listCalpeakADCVBAD->Add(hCalpeakADC);
332 listCalpeakADCUBAD->Add(hCalpeakADC);
335 listCalpeakADCVGOOD->Add(hCalpeakADC);
337 listCalpeakADCUGOOD->Add(hCalpeakADC);
343 listCalpeakTimeVGOOD->Add(hCalpeakTime);
345 listCalpeakTimeUGOOD->Add(hCalpeakTime);
353 B2INFO(
"WARNING, ONE APV has Pedestal problems in: L" << layer <<
"L" << ladder <<
"S" << sensor <<
" side = " << side <<
354 ", APV number = " << m_APV <<
" problem ID = " << problem);
357 listPedestalVBAD->Add(hPedestal);
359 listPedestalUBAD->Add(hPedestal);
362 listPedestalVGOOD->Add(hPedestal);
364 listPedestalUGOOD->Add(hPedestal);
372 printPage(theVxdID, listNoiseUBAD, listNoiseVBAD, listNoiseUGOOD, listNoiseVGOOD,
"Noise", isL3);
373 printPage(theVxdID, listCalpeakADCUBAD, listCalpeakADCVBAD, listCalpeakADCUGOOD, listCalpeakADCVGOOD,
"CalpeakADC", isL3);
374 printPage(theVxdID, listEmpty, listEmpty, listCalpeakTimeUGOOD, listCalpeakTimeVGOOD,
"CalpeakTime", isL3);
375 printPage(theVxdID, listPedestalUBAD, listPedestalVBAD, listPedestalUGOOD, listPedestalVGOOD,
"Pedestal", isL3);
392 TCanvas* empty =
new TCanvas();
394 empty->Print(pdf_open);
396 TCanvas* first =
new TCanvas(
"open_pag1",
"test first page");
398 TPaveText* pt_title =
new TPaveText(.05, .9, .95, 1,
"blNDC");
400 sprintf(name,
"Local Calibration Check Results");
401 pt_title->AddText(name);
402 pt_title->SetTextFont(42);
403 pt_title->SetTextColor(kBlack);
404 pt_title->SetShadowColor(0);
405 pt_title->SetFillColor(10);
406 pt_title->SetBorderSize(0);
407 pt_title->SetTextSize(0.08);
410 TPaveText* pt_input_title =
new TPaveText(.05, .8, .95, .85);
411 TPaveText* pt_input =
new TPaveText(.05, .72, .8, .8);
413 sprintf(input,
"%s",
"input files");
414 pt_input_title->AddText(input);
415 pt_input_title->SetShadowColor(0);
416 pt_input_title->SetBorderSize(0);
417 pt_input_title->SetTextSize(0.03);
422 pt_input->AddText(input);
423 ((TText*)pt_input->GetListOfLines()->Last())->SetTextColor(kRed);
428 pt_input->AddText(input);
429 ((TText*)pt_input->GetListOfLines()->Last())->SetTextColor(kBlue);
430 pt_input->SetTextSize(0.02);
431 pt_input->SetTextAlign(12);
432 pt_input->SetShadowColor(0);
433 pt_input->SetBorderSize(0);
434 pt_input->SetFillColor(10);
436 pt_input_title->Draw();
439 TPaveText* pt_cuts_title =
new TPaveText(.05, .65, .95, .7);
440 TPaveText* pt_cuts =
new TPaveText(.05, .15, .8, .60);
442 sprintf(cuts,
"%s",
"selection criteria");
443 pt_cuts_title->AddText(cuts);
444 pt_cuts_title->SetShadowColor(0);
445 pt_cuts_title->SetBorderSize(0);
446 pt_cuts_title->SetTextSize(0.03);
447 sprintf(cuts,
" An APV chip is selected as problematic if passes the criteria on Noise or CalPeakADC or Pedestal");
448 pt_cuts->AddText(cuts);
450 sprintf(cuts,
" Noise: an APV is problematic if 1. or 2. or 3.");
451 pt_cuts->AddText(cuts);
452 sprintf(cuts,
" 1. abs(ref_ave - check_ave) > %1.2f ADC",
m_cutNoise_ave);
453 pt_cuts->AddText(cuts);
454 sprintf(cuts,
" 2. more than %d strips with a value %1.2f ADC higher than the value of the ref calibration",
m_cutN_out,
456 pt_cuts->AddText(cuts);
457 sprintf(cuts,
" 3. more than %d strips with a value %1.2f ADC lower than the value of the ref calibration",
m_cutN_out,
459 pt_cuts->AddText(cuts);
461 sprintf(cuts,
" CalPeakADC: an APV is problematic if 1. or 2. or 3.");
462 pt_cuts->AddText(cuts);
464 pt_cuts->AddText(cuts);
465 sprintf(cuts,
" 2. more than %d strips with a value %1.1f ADC higher than the value of the ref calibration",
m_cutN_out,
467 pt_cuts->AddText(cuts);
468 sprintf(cuts,
" 3. more than %d strips with a value %1.1f ADC lower than the value of the ref calibration",
m_cutN_out,
470 pt_cuts->AddText(cuts);
472 sprintf(cuts,
" Pedestal: an APV is problematic if 1. or 2. or 3.");
473 pt_cuts->AddText(cuts);
475 pt_cuts->AddText(cuts);
476 sprintf(cuts,
" 2. more than %d strips with a value %1.1f ADC higher than the value of the ref calibration",
m_cutN_out,
478 pt_cuts->AddText(cuts);
479 sprintf(cuts,
" 3. more than %d strips with a value %1.1f ADC lower than the value of the ref calibration",
m_cutN_out,
481 pt_cuts->AddText(cuts);
484 pt_cuts->AddText(cuts);
486 " - {ref,check}_ave is the variable averaged on one APV chip of the reference or the check calibration");
487 pt_cuts->AddText(cuts);
489 " - 1 2 and 3 are the problem ID printed on screen while running the python script");
490 pt_cuts->AddText(cuts);
491 pt_cuts->SetTextSize(0.02);
492 pt_cuts->SetShadowColor(0);
493 pt_cuts->SetBorderSize(0);
494 pt_cuts->SetFillColor(10);
495 pt_cuts->SetTextAlign(12);
497 pt_cuts_title->Draw();
500 TPaveText* pt_tag_title =
new TPaveText(.05, .03, .95, .07);
502 sprintf(tag,
"analysis algorithm ID 1.0");
503 pt_tag_title->AddText(tag);
505 pt_tag_title->SetShadowColor(0);
506 pt_tag_title->SetFillColor(18);
507 pt_tag_title->SetBorderSize(0);
508 pt_tag_title->SetTextSize(0.02);
509 pt_tag_title->Draw();
516 TCanvas* cLayer =
new TCanvas();
518 TPaveText* pt_title =
new TPaveText(.05, .4, .95, 0.6,
"blNDC");
520 sprintf(name,
"Layer %d", layer);
521 pt_title->AddText(name);
522 pt_title->SetTextFont(42);
523 pt_title->SetTextColor(kBlack);
524 pt_title->SetShadowColor(0);
525 pt_title->SetFillColor(10);
526 pt_title->SetBorderSize(0);
527 pt_title->SetTextSize(0.08);
534 TList* listVGOOD, TString variable,
bool isL3)
537 TH2F* refU =
nullptr;
538 TH2F* refV =
nullptr;
539 TH2F* checkU =
nullptr;
540 TH2F* checkV =
nullptr;
545 Float_t leftLine = 0;
546 Float_t rightLine = 0;
549 if (variable ==
"Noise") {
561 }
else if (variable ==
"CalpeakADC") {
566 minY = refU->GetYaxis()->GetXmin();
567 maxY = refU->GetYaxis()->GetXmax();
571 }
else if (variable ==
"CalpeakTime") {
576 minY = refU->GetYaxis()->GetXmin();
577 maxY = refU->GetYaxis()->GetXmax();
578 }
else if (variable ==
"Pedestal") {
591 refU->GetYaxis()->SetRangeUser(minY, maxY);
592 refV->GetYaxis()->SetRangeUser(minY, maxY);
593 checkU->GetYaxis()->SetRangeUser(minY, maxY);
594 checkV->GetYaxis()->SetRangeUser(minY, maxY);
596 refU->SetMarkerColor(kRed);
597 refV->SetMarkerColor(kRed);
598 checkU->SetMarkerColor(kBlue);
599 checkV->SetMarkerColor(kBlue);
605 TLine lLeft(leftLine, 0, leftLine, topLine);
606 TLine lRight(rightLine, 0, rightLine, topLine);
607 lLeft.SetLineColor(15);
608 lRight.SetLineColor(15);
609 lLeft.SetLineStyle(kDashed);
610 lRight.SetLineStyle(kDashed);
613 TLine l1(128, min, 128, max);
614 TLine l2(128 * 2, min, 128 * 2, max);
615 TLine l3(128 * 3, min, 128 * 3, max);
616 TLine l4(128 * 4, min, 128 * 4, max);
617 TLine l5(128 * 5, min, 128 * 5, max);
623 TCanvas* c =
new TCanvas();
624 TPaveText* pt_sensorID =
new TPaveText(.495, 0.485, .505, 0.505,
"blNDC");
627 pt_sensorID->AddText(name);
628 pt_sensorID->SetTextFont(82);
629 pt_sensorID->SetTextColor(kBlack);
630 pt_sensorID->SetShadowColor(0);
631 pt_sensorID->SetFillColor(10);
632 pt_sensorID->SetBorderSize(0);
633 pt_sensorID->SetTextSize(0.08);
645 checkU->Draw(
"same");
652 TIter nextH_uGood(listUGOOD);
653 while ((objDiff = (TH1F*)nextH_uGood())) {
654 objDiff->SetFillStyle(3004);
658 objDiff->Draw(
"same");
662 TIter nextH_uBad(listUBAD);
663 while ((objDiff = (TH1F*)nextH_uBad())) {
664 objDiff->SetFillStyle(0);
668 objDiff->Draw(
"same");
688 checkV->Draw(
"same");
692 TIter nextH_vBad(listVBAD);
695 TIter nextH_vGood(listVGOOD);
696 while ((objDiff = (TH1F*)nextH_vGood())) {
697 objDiff->SetFillStyle(3004);
701 objDiff->Draw(
"same");
705 while ((objDiff = (TH1F*)nextH_vBad())) {
706 objDiff->SetFillStyle(0);
710 objDiff->Draw(
"same");
722 if (variable ==
"Noise")
723 pt_sensorID->Draw(
"same");
731 float average = h->GetMean();
732 if (abs(average) > cutAve)
735 TAxis* xaxis = h->GetXaxis();
736 Int_t bin1 = xaxis->FindBin(-cutCOUNT);
737 Int_t bin2 = xaxis->FindBin(cutCOUNT);
744 B2DEBUG(1, bin1 <<
" -> " << bin2 <<
" with " << xaxis->GetNbins() <<
" bins");
746 if (h->Integral(1, bin1) >
m_cutN_out - 1)
return 2;
748 if (h->Integral(bin2, xaxis->GetNbins()) >
m_cutN_out - 1)
return 3;
759 std::set<Belle2::VxdID>::iterator itSvdLayers = svdLayers.begin();
761 while ((itSvdLayers != svdLayers.end()) && (itSvdLayers->getLayerNumber() != 7)) {
763 std::set<Belle2::VxdID> svdLadders = aGeometry.
getLadders(*itSvdLayers);
764 std::set<Belle2::VxdID>::iterator itSvdLadders = svdLadders.begin();
766 while (itSvdLadders != svdLadders.end()) {
768 std::set<Belle2::VxdID> svdSensors = aGeometry.
getSensors(*itSvdLadders);
769 std::set<Belle2::VxdID>::iterator itSvdSensors = svdSensors.begin();
771 while (itSvdSensors != svdSensors.end()) {
773 int layer = itSvdSensors->getLayerNumber();
774 int ladder = itSvdSensors->getLadderNumber();
775 int sensor = itSvdSensors->getSensorNumber();
779 for (
int side = 0; side < 2; side++) {
781 int Ncells = currentSensorInfo->
getUCells();
785 int Napv = Ncells / 128;
787 for (
int m_APV = 0; m_APV < Napv; m_APV++) {
789 TH1F* h = m_APVhistos->
getHistogram(theVxdID, side, m_APV);
811 TPaveText* pt_cuts_title =
new TPaveText(.05, .6, .95, .65);
812 TPaveText* pt_cuts =
new TPaveText(.15, .5, .85, .55);
814 sprintf(cuts,
"%s",
"SUMMARY");
815 pt_cuts_title->SetShadowColor(0);
816 pt_cuts_title->SetBorderSize(0);
817 pt_cuts_title->SetTextSize(0.03);
818 pt_cuts_title->AddText(cuts);
819 sprintf(cuts,
"each bin of the plots in the next pages contains the number of problematic APV chips of the sensor");
820 pt_cuts->AddText(cuts);
821 sprintf(cuts,
"corresponding to the combination of column (ladder number) and row (layer and sensor number)");
822 pt_cuts->AddText(cuts);
823 pt_cuts->SetTextSize(0.02);
824 pt_cuts->SetShadowColor(0);
825 pt_cuts->SetBorderSize(0);
826 pt_cuts->SetFillColor(10);
827 pt_cuts->SetTextAlign(12);
829 TCanvas* explain =
new TCanvas();
830 pt_cuts_title->Draw();
834 TCanvas* noise =
new TCanvas();
843 TCanvas* calpeakADC =
new TCanvas();
844 calpeakADC->Divide(2, 2);
853 TCanvas* pedestal =
new TCanvas();
854 pedestal->Divide(2, 2);
867 TCanvas* empty =
new TCanvas();
869 empty->Print(pdf_close);
879 m_legU =
new TLegend(0.75, 0.55, 0.89, 0.89);
880 m_legV =
new TLegend(0.75, 0.65, 0.89, 0.89);
885 TH1F* hAPV1 =
new TH1F(
"apv1",
"apv 1", 1, 0, 1);
887 m_legU->AddEntry(hAPV1,
"apv 1",
"l");
888 m_legV->AddEntry(hAPV1,
"apv 1",
"l");
889 TH1F* hAPV2 =
new TH1F(
"apv2",
"apv 2", 2, 0, 2);
892 hAPV2->SetMarkerStyle(21);
893 hAPV2->SetMarkerSize(0.5);
894 m_legU->AddEntry(hAPV2,
"apv 2",
"l");
895 m_legV->AddEntry(hAPV2,
"apv 2",
"l");
896 TH1F* hAPV3 =
new TH1F(
"apv3",
"apv 3", 3, 0, 3);
898 m_legU->AddEntry(hAPV3,
"apv 3",
"l");
899 m_legV->AddEntry(hAPV3,
"apv 3",
"l");
900 TH1F* hAPV4 =
new TH1F(
"apv4",
"apv 4", 4, 0, 4);
903 hAPV4->SetMarkerStyle(21);
904 hAPV4->SetMarkerSize(0.5);
905 m_legU->AddEntry(hAPV4,
"apv 4",
"l");
906 m_legV->AddEntry(hAPV4,
"apv 4",
"l");
907 TH1F* hAPV5 =
new TH1F(
"apv5",
"apv 5", 5, 0, 5);
909 m_legU->AddEntry(hAPV5,
"apv 5",
"l");
910 TH1F* hAPV6 =
new TH1F(
"apv6",
"apv 6", 6, 0, 6);
912 m_legU->AddEntry(hAPV6,
"apv 6",
"l");
914 m_leg2D =
new TLegend(0.78, 0.75, 0.89, 0.89);
915 m_leg2D->AddEntry(hAPV2,
"ref",
"pl");
916 m_leg2D->AddEntry(hAPV4,
"check",
"pl");