17 : fRefPedestals(nullptr),
18 fRefPedestalWidths(nullptr),
19 fRawPedestals(nullptr),
20 fRawPedestalWidths(nullptr),
21 fValPedestals(nullptr),
22 fValPedestalWidths(nullptr),
30 for (
int i = 0;
i < 4;
i++)
32 for (
int k = 0;
k < 4;
k++)
33 state.push_back(
true);
60 cout <<
"Setting pedValflag = 0" << endl;
72 hbHists.ALLPEDS =
new TH1F(
"HBHE All Pedestals",
"HBHE All Peds", 10, 0, 9);
73 hbHists.PEDRMS =
new TH1F(
"HBHE All Pedestal Widths",
"HBHE All Pedestal RMS", 100, 0, 3);
74 hbHists.PEDMEAN =
new TH1F(
"HBHE All Pedestal Means",
"HBHE All Pedestal Means", 100, 0, 9);
75 hbHists.CHI2 =
new TH1F(
"HBHE Chi2/ndf for whole range Gauss fit",
"HBHE Chi2/ndf Gauss", 200, 0., 50.);
77 hoHists.ALLPEDS =
new TH1F(
"HO All Pedestals",
"HO All Peds", 10, 0, 9);
78 hoHists.PEDRMS =
new TH1F(
"HO All Pedestal Widths",
"HO All Pedestal RMS", 100, 0, 3);
79 hoHists.PEDMEAN =
new TH1F(
"HO All Pedestal Means",
"HO All Pedestal Means", 100, 0, 9);
80 hoHists.CHI2 =
new TH1F(
"HO Chi2/ndf for whole range Gauss fit",
"HO Chi2/ndf Gauss", 200, 0., 50.);
82 hfHists.ALLPEDS =
new TH1F(
"HF All Pedestals",
"HF All Peds", 10, 0, 9);
83 hfHists.PEDRMS =
new TH1F(
"HF All Pedestal Widths",
"HF All Pedestal RMS", 100, 0, 3);
84 hfHists.PEDMEAN =
new TH1F(
"HF All Pedestal Means",
"HF All Pedestal Means", 100, 0, 9);
85 hfHists.CHI2 =
new TH1F(
"HF Chi2/ndf for whole range Gauss fit",
"HF Chi2/ndf Gauss", 200, 0., 50.);
91 for (
int i = 0;
i < 16;
i++)
92 _meot->second[
i].first->Delete();
95 for (
int i = 0;
i < 16;
i++)
96 _meot->second[
i].first->Delete();
99 for (
int i = 0;
i < 16;
i++)
100 _meot->second[
i].first->Delete();
149 throw(
int)
hbhe.size();
182 throw(
int)
ho.size();
210 throw(
int)
hf.size();
253 static const int bins = 10;
254 static const int bins2 = 100;
257 map<int, PEDBUNCH> _mei;
258 static map<HcalDetId, map<int, float> > QieCalibMap;
259 string type =
"HBHE";
262 if (detid.
ieta() < 16)
264 if (detid.
ieta() > 16)
266 if (detid.
ieta() == 16) {
267 if (detid.
depth() < 3)
269 if (detid.
depth() == 3)
277 _meot = toolT.find(detid);
280 if (
_meot == toolT.end()) {
281 map<int, PEDBUNCH>
insert;
282 map<int, float> qiecalib;
284 for (
int i = 0;
i < 4;
i++) {
293 name,
"%s Pedestal, eta=%d phi=%d d=%d cap=%d",
type.c_str(), detid.
ieta(), detid.
iphi(), detid.
depth(),
i);
296 "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
305 "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
314 "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
323 sprintf(
name,
"%s Signal in TS 4+5, eta=%d phi=%d d=%d",
type.c_str(), detid.
ieta(), detid.
iphi(), detid.
depth());
326 name,
"%s Signal in TS 4+5-2-3, eta=%d phi=%d d=%d",
type.c_str(), detid.
ieta(), detid.
iphi(), detid.
depth());
329 "%s Signal in TS 4+5-(0+1+2+3)/2., eta=%d phi=%d d=%d",
336 _meot = toolT.find(detid);
338 QieCalibMap[detid] = qiecalib;
341 _mei =
_meot->second;
353 _mei[qie1.
capid()].first->Reset();
354 _mei[qie1.
capid() + 4].first->Reset();
355 _mei[qie1.
capid() + 8].first->Reset();
356 _mei[qie1.
capid() + 12].first->Reset();
361 _mei[qie1.
capid()].first->Fill(qie1.
adc());
363 _mei[qie1.
capid()].first->Fill(charge1);
364 }
else if (qie1.
adc() >=
bins) {
365 _mei[qie1.
capid()].first->AddBinContent(
bins + 1, 1);
371 map<int, float> qiecalib = QieCalibMap[detid];
374 if (charge1 * charge2 < bins2) {
375 _mei[qie1.
capid() + 4 *
flag].first->Fill(charge1 * charge2);
377 _mei[qie1.
capid() + 4 *
flag].first->Fill(bins2);
402 _meot = toolT.find(detid);
403 map<int, PEDBUNCH> _mei =
_meot->second;
404 _mei[16].first->Fill(qie4.
adc() + qie5.
adc() - 1.);
405 _mei[17].first->Fill(qie4.
adc() + qie5.
adc() - qie2.
adc() - qie3.
adc());
406 _mei[18].first->Fill(qie4.
adc() + qie5.
adc() - (qie0.
adc() + qie1.
adc() + qie2.
adc() + qie3.
adc()) / 2.);
412 char PedSampleNum[20];
415 sprintf(PedSampleNum,
"HB_Sample%d",
sample);
417 m_file->mkdir(PedSampleNum);
420 sprintf(PedSampleNum,
"HO_Sample%d",
sample);
422 m_file->mkdir(PedSampleNum);
425 sprintf(PedSampleNum,
"HF_Sample%d",
sample);
427 m_file->mkdir(PedSampleNum);
447 for (
int i = 0;
i < 4;
i++) {
450 if (
fit->GetNDF() != 0)
453 sig[
i][
i] =
fit->GetParameter(2);
454 dcap[
i] =
fit->GetParError(1);
455 dsig[
i][
i] =
fit->GetParError(2);
458 for (
int i = 0;
i < 4;
i++) {
460 sig[
i][
i] =
_meot->second[
i].first->GetRMS();
473 for (
int i = 0;
i < 4;
i++) {
476 _meot->second[
i].first->GetXaxis()->SetTitle(
"ADC");
478 _meot->second[
i].first->GetXaxis()->SetTitle(
"Charge, fC");
479 _meot->second[
i].first->GetYaxis()->SetTitle(
"CapID samplings");
480 _meot->second[
i].first->Write();
483 _meot->second[
i].second.first[0].push_back(
cap[
i]);
484 _meot->second[
i].second.first[1].push_back(dcap[
i]);
485 _meot->second[
i].second.first[2].push_back(sig[
i][
i]);
486 _meot->second[
i].second.first[3].push_back(dsig[
i][
i]);
487 _meot->second[
i].second.first[4].push_back(
chi2[
i]);
489 PedMeans->Fill(
cap[
i]);
490 PedWidths->Fill(sig[
i][
i]);
495 for (
int i = 16;
i < 19;
i++) {
497 _meot->second[
i].first->GetXaxis()->SetTitle(
"ADC");
499 _meot->second[
i].first->GetXaxis()->SetTitle(
"Charge, fC");
500 _meot->second[
i].first->GetYaxis()->SetTitle(
"Events");
501 _meot->second[
i].first->Write();
506 sig[0][0] = sig[0][0] * sig[0][0];
507 sig[1][1] = sig[1][1] * sig[1][1];
508 sig[2][2] = sig[2][2] * sig[2][2];
509 sig[3][3] = sig[3][3] * sig[3][3];
513 sig[0][1] =
_meot->second[4].first->GetMean() -
cap[0] *
cap[1];
514 sig[0][2] =
_meot->second[8].first->GetMean() -
cap[0] *
cap[2];
515 sig[1][2] =
_meot->second[5].first->GetMean() -
cap[1] *
cap[2];
516 sig[1][3] =
_meot->second[9].first->GetMean() -
cap[1] *
cap[3];
517 sig[2][3] =
_meot->second[6].first->GetMean() -
cap[2] *
cap[3];
518 sig[0][3] =
_meot->second[12].first->GetMean() -
cap[0] *
cap[3];
519 sig[1][0] =
_meot->second[13].first->GetMean() -
cap[1] *
cap[0];
520 sig[2][0] =
_meot->second[10].first->GetMean() -
cap[2] *
cap[0];
521 sig[2][1] =
_meot->second[14].first->GetMean() -
cap[2] *
cap[1];
522 sig[3][1] =
_meot->second[11].first->GetMean() -
cap[3] *
cap[1];
523 sig[3][2] =
_meot->second[15].first->GetMean() -
cap[3] *
cap[2];
524 sig[3][0] =
_meot->second[7].first->GetMean() -
cap[3] *
cap[0];
527 for (
int i = 0;
i < 4;
i++) {
529 _meot->second[
i].second.first[5].push_back(sig[
i][(
i + 1) % 4]);
530 _meot->second[
i].second.first[6].push_back(2 * sig[
i][
i] * dsig[
i][
i]);
531 _meot->second[
i].second.first[7].push_back(sig[
i][(
i + 2) % 4]);
532 _meot->second[
i].second.first[8].push_back(2 * sig[
i][
i] * dsig[
i][
i]);
533 _meot->second[
i].second.first[9].push_back(sig[
i][(
i + 3) % 4]);
534 _meot->second[
i].second.first[10].push_back(2 * sig[
i][
i] * dsig[
i][
i]);
539 _meot->second[
i + 4].first->GetXaxis()->SetTitle(
"ADC^2");
541 _meot->second[
i + 4].first->GetXaxis()->SetTitle(
"Charge^2, fC^2");
542 _meot->second[
i + 4].first->GetYaxis()->SetTitle(
"2-CapID samplings");
543 _meot->second[
i + 4].first->Write();
545 _meot->second[
i + 8].first->GetXaxis()->SetTitle(
"ADC^2");
547 _meot->second[
i + 8].first->GetXaxis()->SetTitle(
"Charge^2, fC^2");
548 _meot->second[
i + 8].first->GetYaxis()->SetTitle(
"2-CapID samplings");
549 _meot->second[
i + 8].first->Write();
551 _meot->second[
i + 12].first->GetXaxis()->SetTitle(
"ADC^2");
553 _meot->second[
i + 12].first->GetXaxis()->SetTitle(
"Charge^2, fC^2");
554 _meot->second[
i + 12].first->GetYaxis()->SetTitle(
"2-CapID samplings");
555 _meot->second[
i + 12].first->Write();
562 sig[1][0] = sig[0][1];
563 sig[2][0] = sig[0][2];
564 sig[2][1] = sig[1][2];
565 sig[3][1] = sig[1][3];
566 sig[3][2] = sig[2][3];
567 sig[0][3] = sig[3][0];
643 for (
int i = 0;
i < 4;
i++)
692 map<int, std::vector<double> > AverageValues;
695 for (
int i = 0;
i < 4;
i++) {
698 sprintf(
name,
"Pedestal trend, eta=%d phi=%d d=%d cap=%d", detid.
ieta(), detid.
iphi(), detid.
depth(),
i);
699 int bins =
_meot->second[
i].second.first[0].size();
703 sprintf(
name,
"Width trend, eta=%d phi=%d d=%d cap=%d", detid.
ieta(), detid.
iphi(), detid.
depth(),
i);
704 bins =
_meot->second[
i].second.first[2].size();
708 "Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",
714 bins =
_meot->second[
i].second.first[5].size();
726 std::vector<double>::iterator sample_it;
729 for (sample_it =
_meot->second[
i].second.first[0].begin(); sample_it !=
_meot->second[
i].second.first[0].end();
731 _meot->second[
i].second.second[0]->SetBinContent(++
j, *sample_it);
734 for (sample_it =
_meot->second[
i].second.first[1].begin(); sample_it !=
_meot->second[
i].second.first[1].end();
736 _meot->second[
i].second.second[0]->SetBinError(++
j, *sample_it);
739 _meot->second[
i].second.second[0]->Fit(
"pol0",
"Q");
740 TF1*
fit =
_meot->second[
i].second.second[0]->GetFunction(
"pol0");
741 AverageValues[0].push_back(
fit->GetParameter(0));
742 AverageValues[1].push_back(
fit->GetParError(0));
744 AverageValues[2].push_back(
fit->GetChisquare() /
fit->GetNDF());
746 AverageValues[2].push_back(
fit->GetChisquare());
748 _meot->second[
i].second.second[0]->GetXaxis()->SetTitle(
name);
749 _meot->second[
i].second.second[0]->GetYaxis()->SetTitle(
"Pedestal value");
750 _meot->second[
i].second.second[0]->Write();
753 for (sample_it =
_meot->second[
i].second.first[2].begin(); sample_it !=
_meot->second[
i].second.first[2].end();
755 _meot->second[
i].second.second[1]->SetBinContent(++
j, *sample_it);
758 for (sample_it =
_meot->second[
i].second.first[3].begin(); sample_it !=
_meot->second[
i].second.first[3].end();
760 _meot->second[
i].second.second[1]->SetBinError(++
j, *sample_it);
762 _meot->second[
i].second.second[1]->GetXaxis()->SetTitle(
name);
763 _meot->second[
i].second.second[1]->GetYaxis()->SetTitle(
"Pedestal width");
764 _meot->second[
i].second.second[1]->Write();
767 for (sample_it =
_meot->second[
i].second.first[5].begin(); sample_it !=
_meot->second[
i].second.first[5].end();
769 _meot->second[
i].second.second[2]->SetBinContent(++
j, *sample_it);
772 for (sample_it =
_meot->second[
i].second.first[6].begin(); sample_it !=
_meot->second[
i].second.first[6].end();
774 _meot->second[
i].second.second[2]->SetBinError(++
j, *sample_it);
776 _meot->second[
i].second.second[2]->GetXaxis()->SetTitle(
name);
777 _meot->second[
i].second.second[2]->GetYaxis()->SetTitle(
"Close correlation");
778 _meot->second[
i].second.second[2]->Write();
806 for (sample_it =
_meot->second[
i].second.first[4].begin(); sample_it !=
_meot->second[
i].second.first[4].end();
808 Chi2->Fill(*sample_it);
812 CapidAverage =
new TH1F(
"Constant fit: Pedestal Values",
813 "Constant fit: Pedestal Values",
814 AverageValues[0].
size(),
816 AverageValues[0].
size());
817 std::vector<double>::iterator sample_it;
819 for (sample_it = AverageValues[0].begin(); sample_it != AverageValues[0].end(); ++sample_it) {
820 CapidAverage->SetBinContent(++
j, *sample_it);
823 for (sample_it = AverageValues[1].begin(); sample_it != AverageValues[1].end(); ++sample_it) {
824 CapidAverage->SetBinError(++
j, *sample_it);
826 CapidChi2 =
new TH1F(
827 "Constant fit: Chi2/ndf",
"Constant fit: Chi2/ndf", AverageValues[2].
size(), 0., AverageValues[2].
size());
829 for (sample_it = AverageValues[2].begin(); sample_it != AverageValues[2].end(); ++sample_it) {
830 CapidChi2->SetBinContent(++
j, *sample_it);
833 Chi2->GetXaxis()->SetTitle(
"Chi2/ndf");
834 Chi2->GetYaxis()->SetTitle(
"50 x [(16+2) x 4 x 4] `events`");
836 CapidAverage->GetYaxis()->SetTitle(
"Pedestal value");
837 CapidAverage->GetXaxis()->SetTitle(
"(16+2) x 4 x 4 `events`");
838 CapidAverage->Write();
839 CapidChi2->GetYaxis()->SetTitle(
"Chi2/ndf");
840 CapidChi2->GetXaxis()->SetTitle(
"(16+2) x 4 x 4 `events`");
857 float RefPedSigs[4][4];
859 float RawPedSigs[4][4];
860 map<HcalDetId, bool> isinRaw;
861 map<HcalDetId, bool> isinRef;
864 std::ofstream PedValLog;
865 PedValLog.open(
"HcalPedVal.log");
867 if (nstat[0] + nstat[1] + nstat[2] + nstat[3] < 2500)
868 PedValLog <<
"HcalPedVal: warning - low statistics" << std::endl;
870 for (
int i = 0;
i < (
int)RawChanns.size();
i++) {
873 for (
int i = 0;
i < (
int)RefChanns.size();
i++) {
875 isinRaw[detid] =
false;
876 isinRef[detid] =
true;
878 for (
int i = 0;
i < (
int)RawChanns.size();
i++) {
880 isinRaw[detid] =
true;
881 if (isinRef[detid] ==
false) {
882 PedValLog <<
"HcalPedVal: channel " << detid <<
" not found in reference set" << std::endl;
883 std::cerr <<
"HcalPedVal: channel " << detid <<
" not found in reference set" << std::endl;
889 for (
int i = 0;
i < (
int)RefChanns.size();
i++) {
891 for (
int icap = 0; icap < 4; icap++) {
893 for (
int icap2 = icap; icap2 < 4; icap2++) {
896 RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
901 if (isinRaw[detid]) {
902 for (
int icap = 0; icap < 4; icap++) {
904 for (
int icap2 = icap; icap2 < 4; icap2++) {
907 RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
912 for (
int icap = 0; icap < 4; icap++) {
913 if (RawPedVals[icap] < 1. || RawPedSigs[icap][icap] < 0.01)
914 isinRaw[detid] =
false;
915 for (
int icap2 = icap; icap2 < 4; icap2++) {
916 if (fabs(RawPedSigs[icap][icap2] /
sqrt(RawPedSigs[icap][icap] * RawPedSigs[icap2][icap2])) > 1.)
917 isinRaw[detid] =
false;
923 if (isinRaw[detid]) {
924 for (
int icap = 0; icap < 4; icap++) {
925 int icap2 = (icap + 1) % 4;
926 float width =
sqrt(RawPedSigs[icap][icap]);
927 float erof1 =
width /
sqrt((
float)nstat[icap]);
928 float erof2 =
sqrt(erof1 * erof1 + RawPedSigs[icap][icap] / (
float)nstat[icap]);
929 float erofwidth =
width /
sqrt(2. * nstat[icap]);
930 float diffof1 = RawPedVals[icap] - RefPedVals[icap];
931 float diffof2 = RawPedVals[icap] + RawPedVals[icap2] - RefPedVals[icap] - RefPedVals[icap2];
932 float diffofw =
width -
sqrt(RefPedSigs[icap][icap]);
938 if (nTS == 1 && fabs(diffof1) > 0.5 + erof1) {
940 PedValLog <<
"HcalPedVal: drift in channel " << detid <<
" cap " << icap <<
": " << RawPedVals[icap] <<
" - "
941 << RefPedVals[icap] <<
" = " << diffof1 << std::endl;
943 if (nTS == 2 && fabs(diffof2) > 0.5 + erof2) {
945 PedValLog <<
"HcalPedVal: drift in channel " << detid <<
" caps " << icap <<
"+" << icap2 <<
": "
946 << RawPedVals[icap] <<
"+" << RawPedVals[icap2] <<
" - " << RefPedVals[icap] <<
"+"
947 << RefPedVals[icap2] <<
" = " << diffof2 << std::endl;
949 if (fabs(diffofw) > 0.15 *
width + erofwidth) {
951 PedValLog <<
"HcalPedVal: width changed in channel " << detid <<
" cap " << icap <<
": " <<
width <<
" - "
952 <<
sqrt(RefPedSigs[icap][icap]) <<
" = " << diffofw << std::endl;
959 PedValLog <<
"HcalPedVal: no valid data from channel " << detid << std::endl;
961 HcalPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
964 for (
int icap = 0; icap < 4; icap++) {
965 for (
int icap2 = icap; icap2 < 4; icap2++)
966 widthsp.
setSigma(icap2, icap, RefPedSigs[icap2][icap]);
975 PedValLog <<
"HcalPedVal: all pedestals checked OK" << std::endl;
979 if (erflag % 100000 == 0) {
980 for (
int i = 0;
i < (
int)RefChanns.size();
i++) {
982 if (isinRaw[detid]) {
984 for (
int icap = 0; icap < 4; icap++) {
986 for (
int icap2 = icap; icap2 < 4; icap2++) {
989 RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
990 widthsp.
setSigma(icap2, icap, RefPedSigs[icap2][icap]);
994 HcalPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
1002 for (
int i = 0;
i < (
int)RawChanns.size();
i++) {
1004 if (isinRaw[detid]) {
1006 for (
int icap = 0; icap < 4; icap++) {
1008 for (
int icap2 = icap; icap2 < 4; icap2++) {
1011 RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
1012 widthsp.
setSigma(icap2, icap, RawPedSigs[icap2][icap]);
1016 HcalPedestal item(detid, RawPedVals[0], RawPedVals[1], RawPedVals[2], RawPedVals[3]);