18 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalPedestalsHandler")) {
19 edm::LogInfo(
"EcalPedestals Source handler constructor\n");
34 <<
"/" << m_location <<
"/" <<
m_gentag;
82 std::ostringstream
ss;
85 unsigned int max_since = 0;
141 EEDetId eedetidneg(iX, iY, -1);
163 edm::LogInfo(
"Retrieving run list from ONLINE DB ... ");
193 unsigned int min_run = 0;
195 min_run = max_since + 1;
203 std::vector<MonRunIOV> mon_run_vec = mon_list.
getRuns();
204 int mon_runs = mon_run_vec.size();
209 for (
int kr = 0; kr < krmax; kr++) {
212 unsigned int irun =
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
213 edm::LogInfo(
"retrieve the data for run number: ") << mon_run_vec[kr].getRunIOV().getRunNumber();
214 if (mon_run_vec[kr].getSubRunNumber() <= 1) {
216 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
218 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
220 edm::LogInfo(
"OMDS record for run ") << irun <<
" is made of " << dataset_mon.size();
221 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad = 0;
222 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
228 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
231 int sm_num = ecid_xt.
getID1();
232 int xt_num = ecid_xt.
getID2();
233 int yt_num = ecid_xt.
getID3();
246 if (ecid_xt.
getName() ==
"EB_crystal_number") {
261 std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/" << yt_num <<
"ped/rms " 289 if (nbad < (dataset_mon.size() * 0.05) && (nEB > 10200 || nEE > 2460)) {
290 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
293 int sm_num = ecid_xt.
getID1();
294 int xt_num = ecid_xt.
getID2();
295 int yt_num = ecid_xt.
getID3();
305 if (ecid_xt.
getName() ==
"EB_crystal_number") {
339 EEDetId eedetid(xt_num, yt_num, sm_num);
369 edm::LogInfo(
"Generating popcon record for run ") << irun <<
"..." << std::flush;
396 if ((iEta == -1 || iEta == 1) && iPhi == 20) {
398 edm::LogInfo(
"channel:") << iEta <<
"/" << iPhi <<
"/" << hiee <<
" ped mean 12=" <<
x;
443 ss <<
"Run=" << irun <<
"_WAS_GOOD_" << std::endl;
447 edm::LogInfo(
"Run ") << irun <<
" was BAD !!!! not sent to the DB";
448 if (nbad >= (dataset_mon.size() * 0.05))
454 ss <<
"Run=" << irun <<
"_WAS_BAD_" << std::endl;
463 edm::LogInfo(
"Ecal - > end of getNewObjects -----------\n");
469 unsigned int max_since = 0;
490 for (
int iX = ixmin; iX <= ixmax; ++iX) {
491 for (
int iY = iymin; iY <= iymax; ++iY) {
506 if (iX == ixmin && iY == iymin)
512 edm::LogInfo(
"We just retrieved the last valid record from DB ");
516 edm::LogInfo(
"Retrieving run list from ONLINE DB ... ");
551 unsigned int min_run = max_since + 1;
556 std::vector<MonRunIOV> mon_run_vec = mon_list.
getRuns();
557 size_t mon_runs = mon_run_vec.size();
561 for (
size_t kr = 0; kr < mon_runs; kr++) {
562 unsigned int irun =
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
564 edm::LogInfo(
"here is first sub run : ") << mon_run_vec[kr].getSubRunNumber();
565 edm::LogInfo(
"here is the run number: ") << mon_run_vec[kr].getRunIOV().getRunNumber();
569 if (mon_run_vec[kr].getSubRunNumber() <= 1) {
571 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
574 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
576 std::cout <<
"OMDS record for run " << irun <<
" is made of " << dataset_mon.size() << std::endl;
577 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
586 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
590 int xt_num = ecid_xt.
getID2();
595 ix = 95 - (xt_num - 1) / 20;
596 iy = 46 + (xt_num - 1) % 20;
613 if (ix == ixmin && iy == iymin)
617 edm::LogInfo(
"Generating popcon record for run ") << irun <<
"..." << std::flush;
626 for (
int iX = ixmin; iX <= ixmax; ++iX) {
627 for (
int iY = iymin; iY <= iymax; ++iY) {
642 if (iX == ixmin && iY == iymin)
652 edm::LogInfo(
"Ecal - > end of getNewObjectsH2 -----------\n");
663 std::ifstream fInput;
665 if (!fInput.is_open()) {
675 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
676 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel] >>
677 EBmean1[iChannel] >> EBrms1[iChannel];
678 if (hashedId != iChannel + 1) {
687 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
688 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel] >>
689 EEmean1[iChannel] >> EErms1[iChannel];
690 if (hashedId != iChannel + kEBChannels + 1) {
708 item.
rms_x1 = EBrms1[hieb];
710 item.
rms_x6 = EBrms6[hieb];
720 for (
int iz = -1; iz < 2; iz = iz + 2) {
729 item.
rms_x1 = EErms1[hiee];
731 item.
rms_x6 = EErms6[hiee];
745 edm::LogInfo(
"Ecal - > end of readPedestalFile -----------\n");
753 if (!fxml.is_open()) {
758 fout.open(
"Pedestal.check");
763 double RingMean[28][2][3], RingRMS[28][2][3];
766 for (
int side = 0; side < 2; side++) {
767 for (
int igain = 0; igain <
kGains; igain++) {
768 RingMean[
ring][side][igain] = 0.;
769 RingRMS[
ring][side][igain] = 0.;
770 NbVal[
ring][side][igain] = 0;
775 for (
int i = 0;
i < 9;
i++)
776 std::getline(fxml, dummyLine);
778 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
781 int ring = (
abs(ieta) - 1) / 5;
782 if (ring < 0 || ring > 16)
789 std::istringstream m12(stt);
790 m12 >> EBmean12[iEBChannel];
792 stt = bid.substr(9, 15);
793 std::istringstream r12(stt);
794 r12 >> EBrms12[iEBChannel];
795 if (EBrms12[iEBChannel] != 0. && EBrms12[iEBChannel] < 5.) {
796 RingMean[
ring][izz][0] += EBrms12[iEBChannel];
797 RingRMS[
ring][izz][0] += EBrms12[iEBChannel] * EBrms12[iEBChannel];
798 NbVal[
ring][izz][0]++;
801 stt = bid.substr(9, 15);
802 std::istringstream m6(stt);
803 m6 >> EBmean6[iEBChannel];
805 stt = bid.substr(8, 15);
806 std::istringstream r6(stt);
807 r6 >> EBrms6[iEBChannel];
808 if (EBrms6[iEBChannel] != 0. && EBrms6[iEBChannel] < 5.) {
809 RingMean[
ring][izz][1] += EBrms6[iEBChannel];
810 RingRMS[
ring][izz][1] += EBrms6[iEBChannel] * EBrms6[iEBChannel];
811 NbVal[
ring][izz][1]++;
814 stt = bid.substr(9, 15);
815 std::istringstream m1(stt);
816 m1 >> EBmean1[iEBChannel];
818 stt = bid.substr(8, 15);
819 std::istringstream
r1(stt);
820 r1 >> EBrms1[iEBChannel];
821 if (EBrms1[iEBChannel] != 0. && EBrms1[iEBChannel] < 5.) {
822 RingMean[
ring][izz][2] += EBrms1[iEBChannel];
823 RingRMS[
ring][izz][2] += EBrms1[iEBChannel] * EBrms1[iEBChannel];
824 NbVal[
ring][izz][2]++;
826 if (iEBChannel % 10000 == 0)
827 fout <<
" EB channel " << iEBChannel <<
" " << EBmean12[iEBChannel] <<
" " << EBrms12[iEBChannel] <<
" " 828 << EBmean6[iEBChannel] <<
" " << EBrms6[iEBChannel] <<
" " << EBmean1[iEBChannel] <<
" " 829 << EBrms1[iEBChannel] << std::endl;
830 for (
int i = 0;
i < 3;
i++)
831 std::getline(fxml, dummyLine);
835 std::ifstream fCrystal;
836 fCrystal.open(
"Crystal");
837 if (!fCrystal.is_open()) {
842 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
843 fCrystal >> ringEE[iChannel];
844 int ring =
abs(ringEE[iChannel]) - 1;
845 if (ring < 17 || ring > 27) {
846 edm::LogInfo(
" EE channel ") << iChannel <<
" ring " << ringEE[iChannel];
854 for (
int i = 0;
i < 6;
i++)
855 std::getline(fxml, dummyLine);
856 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
860 std::istringstream m12(stt);
861 m12 >> EEmean12[iEEChannel];
862 int ring =
abs(ringEE[iEEChannel]) - 1;
863 if (ring < 17 || ring > 27)
866 if (iEEChannel < 7324)
869 stt = bid.substr(9, 15);
870 std::istringstream r12(stt);
871 r12 >> EErms12[iEEChannel];
872 if (EErms12[iEEChannel] != 0. && EErms12[iEEChannel] < 5.) {
873 RingMean[
ring][izz][0] += EErms12[iEEChannel];
874 RingRMS[
ring][izz][0] += EErms12[iEEChannel] * EErms12[iEEChannel];
875 NbVal[
ring][izz][0]++;
878 stt = bid.substr(9, 15);
879 std::istringstream m6(stt);
880 m6 >> EEmean6[iEEChannel];
882 stt = bid.substr(8, 15);
883 std::istringstream r6(stt);
884 r6 >> EErms6[iEEChannel];
885 if (EErms6[iEEChannel] != 0. && EErms6[iEEChannel] < 5.) {
886 RingMean[
ring][izz][1] += EErms6[iEEChannel];
887 RingRMS[
ring][izz][1] += EErms6[iEEChannel] * EErms6[iEEChannel];
888 NbVal[
ring][izz][1]++;
891 stt = bid.substr(9, 15);
892 std::istringstream m1(stt);
893 m1 >> EEmean1[iEEChannel];
895 stt = bid.substr(8, 15);
896 std::istringstream
r1(stt);
897 r1 >> EErms1[iEEChannel];
898 if (EErms1[iEEChannel] != 0. && EErms1[iEEChannel] < 5.) {
899 RingMean[
ring][izz][2] += EErms1[iEEChannel];
900 RingRMS[
ring][izz][2] += EErms1[iEEChannel] * EErms1[iEEChannel];
901 NbVal[
ring][izz][2]++;
903 if (iEEChannel % 1000 == 0)
904 fout <<
" EE channel " << iEEChannel <<
" " << EEmean12[iEEChannel] <<
" " << EErms12[iEEChannel] <<
" " 905 << EEmean6[iEEChannel] <<
" " << EErms6[iEEChannel] <<
" " << EEmean1[iEEChannel] <<
" " 906 << EErms1[iEEChannel] << std::endl;
907 for (
int i = 0;
i < 3;
i++)
908 std::getline(fxml, dummyLine);
917 for (
int side = 0; side < 2; side++) {
927 fout <<
" ring " <<
ring + 1 <<
" mean " << x <<
" rms " << rms <<
" ";
931 fout <<
"***** End caps ***** EE- EE+" << std::endl;
951 int ring = (
abs(iEta) - 1) / 5;
952 if (ring < 0 || ring > 16)
957 if (EBrms1[hieb] == 0 || EBrms1[hieb] > RingMean[ring][side][2] + 3 * RingRMS[ring][side][2]) {
958 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
959 <<
" gain 1 rms " << EBrms1[hieb] <<
" replaced by " << RingMean[
ring][side][2] << std::endl;
962 item.
rms_x1 = EBrms1[hieb];
963 if (EBrms6[hieb] == 0 || EBrms6[hieb] > RingMean[ring][side][1] + 3 * RingRMS[ring][side][1]) {
964 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
965 <<
" gain 6 rms " << EBrms6[hieb] <<
" replaced by " << RingMean[
ring][side][1] << std::endl;
968 item.
rms_x6 = EBrms6[hieb];
969 if (EBrms12[hieb] == 0 || EBrms12[hieb] > RingMean[ring][side][0] + 3 * RingRMS[ring][side][0]) {
970 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
971 <<
" gain 12 rms " << EBrms12[hieb] <<
" replaced by " << RingMean[
ring][side][0] << std::endl;
975 if (hieb > 4534 && hieb < 4540)
976 edm::LogInfo(
" Channel ") << hieb <<
" ring " << ring <<
" 12 " << EBrms12[hieb] <<
" mean " 977 << RingMean[
ring][side][0] <<
" rms " << RingRMS[
ring][side][0] <<
" 6 " 978 << EBrms6[hieb] <<
" mean " << RingMean[
ring][side][1] <<
" rms " 979 << RingRMS[
ring][side][1] <<
" 1 " << EBrms1[hieb] <<
" mean " 980 << RingMean[
ring][side][2] <<
" rms " << RingRMS[
ring][side][2];
983 item.
rms_x1 = EBrms1[hieb];
984 item.
rms_x6 = EBrms6[hieb];
995 for (
int iz = -1; iz < 2; iz = iz + 2) {
1007 int ring =
abs(ringEE[hiee]) - 1;
1008 if (ring < 17 || ring > 27)
1010 if (EErms1[hiee] == 0 || EErms1[hiee] > RingMean[ring][iz][2] + 3 * RingRMS[ring][iz][2]) {
1011 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
1012 <<
" gain 1 rms " << EErms1[hiee] <<
" replaced by " << RingMean[
ring][iz][2] << std::endl;
1015 item.
rms_x1 = EErms1[hiee];
1016 if (EErms6[hiee] == 0 || EErms6[hiee] > RingMean[ring][iz][1] + 3 * RingRMS[ring][iz][1]) {
1017 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
1018 <<
" gain 6 rms " << EErms6[hiee] <<
" replaced by " << RingMean[
ring][iz][1] << std::endl;
1021 item.
rms_x6 = EErms6[hiee];
1022 if (EErms12[hiee] == 0 || EErms12[hiee] > RingMean[ring][iz][0] + 3 * RingRMS[ring][iz][0]) {
1023 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
1024 <<
" gain 12 rms " << EErms12[hiee] <<
" replaced by " << RingMean[
ring][iz][0] << std::endl;
1030 item.
rms_x1 = EErms1[hiee];
1031 item.
rms_x6 = EErms6[hiee];
1045 edm::LogInfo(
"Ecal - > end of readPedestalMC -----------\n");
1084 EEDetId eedetidpos(iX, iY, 1);
1098 EEDetId eedetidneg(iX, iY, -1);
1115 std::ifstream fInput;
1117 if (!fInput.is_open()) {
1127 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
1128 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel] >>
1129 EBmean1[iChannel] >> EBrms1[iChannel];
1130 if (hashedId != iChannel + 1) {
1139 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
1140 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel] >>
1141 EEmean1[iChannel] >> EErms1[iChannel];
1142 if (hashedId != iChannel + kEBChannels + 1) {
1160 if (debug & (EBmean12[hieb] == -999. || EBrms12[hieb] == -999. || EBmean6[hieb] == -999. ||
1161 EBrms6[hieb] == -999. || EBmean1[hieb] == -999. || EBrms1[hieb] == -999.))
1163 << iEta <<
" phi " << iPhi <<
" " << EBmean12[hieb] <<
" " << EBrms12[hieb] <<
" " << EBmean6[hieb] <<
" " 1164 << EBrms6[hieb] <<
" " << EBmean1[hieb] <<
" " << EBrms1[hieb];
1165 if (EBmean1[hieb] != -999.)
1169 if (EBrms1[hieb] != -999.)
1170 item.
rms_x1 = EBrms1[hieb];
1173 if (EBmean6[hieb] != -999.)
1177 if (EBrms6[hieb] != -999.)
1178 item.
rms_x6 = EBrms6[hieb];
1181 if (EBmean12[hieb] != -999.)
1185 if (EBrms12[hieb] != -999.)
1196 for (
int iz = -1; iz < 2; iz = iz + 2) {
1205 if (debug & (EEmean12[hiee] == -999. || EErms12[hiee] == -999. || EEmean6[hiee] == -999. ||
1206 EErms6[hiee] == -999. || EEmean1[hiee] == -999. || EErms1[hiee] == -999.))
1208 << iX <<
" y " << iY <<
" z" << iz <<
" " << EEmean12[hiee] <<
" " << EErms12[hiee] <<
" " 1209 << EEmean6[hiee] <<
" " << EErms6[hiee] <<
" " << EEmean1[hiee] <<
" " << EErms1[hiee];
1210 if (EEmean1[hiee] != -999.)
1214 if (EErms1[hiee] != -999.)
1215 item.
rms_x1 = EErms1[hiee];
1218 if (EEmean6[hiee] != -999.)
1222 if (EErms6[hiee] != -999.)
1223 item.
rms_x6 = EErms6[hiee];
1226 if (EEmean12[hiee] != -999.)
1230 if (EErms12[hiee] != -999.)
1245 edm::LogInfo(
"Ecal - > end of readPedestal2017 -----------\n");
1251 TFile* hfile =
new TFile(
m_filename.c_str());
1253 TTree* treeChan = (TTree*)hfile->Get(
"PedChan");
1254 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1255 treeChan->SetBranchAddress(
"Channels", &iChannel);
1256 treeChan->SetBranchAddress(
"x", &ix);
1257 treeChan->SetBranchAddress(
"y", &iy);
1258 treeChan->SetBranchAddress(
"z", &iz);
1259 int neventsChan = (
int)treeChan->GetEntries();
1263 treeChan->GetEntry(
entry);
1265 ringEB[iChannel] = (
abs(ix) - 1) / 5;
1266 sideEB[iChannel] = 1;
1268 sideEB[iChannel] = 0;
1269 if (
entry % 10000 == 0)
1270 edm::LogInfo(
" EB channel ") << iChannel <<
" eta " << ix <<
" phi " << iy <<
" side " << sideEB[iChannel]
1271 <<
" ring " << ringEB[iChannel];
1273 ixEE[iChannel] = ix;
1274 iyEE[iChannel] = iy;
1275 izEE[iChannel] = iz;
1276 if (
entry % 1000 == 0)
1277 edm::LogInfo(
" EE channel ") << iChannel <<
" x " << ixEE[iChannel] <<
" y " << iyEE[iChannel] <<
" z " 1366 Int_t run16Index = 0;
1368 Int_t fed[
kChannels],
chan[
kChannels],
id,
run, run_type, seq_id, las_id, fill_num, run_num_infill, run_time,
1369 run_time_stablebeam, nxt,
time[54];
1371 TTree*
tree = (TTree*)hfile->Get(
"T");
1373 tree->SetBranchAddress(
"id", &
id);
1374 tree->SetBranchAddress(
"run", &run);
1375 tree->SetBranchAddress(
"run_type", &run_type);
1376 tree->SetBranchAddress(
"seq_id", &seq_id);
1377 tree->SetBranchAddress(
"las_id", &las_id);
1378 tree->SetBranchAddress(
"fill_num", &fill_num);
1379 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1380 tree->SetBranchAddress(
"run_time", &run_time);
1381 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1382 tree->SetBranchAddress(
"lumi", &lumi);
1383 tree->SetBranchAddress(
"bfield", &bfield);
1384 tree->SetBranchAddress(
"nxt", &nxt);
1385 tree->SetBranchAddress(
"time", time);
1386 tree->SetBranchAddress(
"fed", fed);
1387 tree->SetBranchAddress(
"chan", chan);
1388 tree->SetBranchAddress(
"ped", ped);
1389 tree->SetBranchAddress(
"pedrms", pedrms);
1393 fout.open(
"copyTreePedestals.txt");
1394 if (!fout.is_open()) {
1395 edm::LogInfo(
"ERROR : cannot open file copyTreePedestals.txt");
1401 for (
int ich = 0; ich <
kChannels; ich++) {
1407 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type
1408 <<
" seq_id " << seq_id <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi " << lumi
1409 <<
" nb of Crystals " << nxt << std::endl;
1410 for (
int ich = 0; ich <
kChannels; ich++) {
1411 if (ped[ich] != 0.) {
1413 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich]
1414 <<
" RMS " << pedrms[ich] << std::endl;
1416 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " 1417 << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1425 int firsttimeFED = -1;
1428 tree->GetEntry(
entry);
1429 if (run < first_run_kept) {
1430 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1431 <<
" before first wanted " <<
m_firstRun << std::endl;
1435 if (run > last_run_kept) {
1436 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1437 <<
" after last wanted " <<
m_lastRun << std::endl;
1441 if (run_type != run_type_kept) {
1442 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time <<
" run type " 1443 << run_type << std::endl;
1446 if (nxt != kChannels) {
1447 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1448 <<
" *********** Number of channels " << nxt << std::endl;
1451 if (bfield < 3.79) {
1452 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1453 <<
" *********** bfield = " << bfield << std::endl;
1456 if (run_type_kept == 1) {
1458 for (
int ifed = 0; ifed < 54; ifed++) {
1459 if (time[ifed] < run_time_stablebeam) {
1461 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1462 <<
" *********** sequence before stable beam at " << run_time_stablebeam <<
" FED " << ifed <<
" : " 1465 fout <<
" FED " << ifed <<
" : " << time[ifed];
1469 if (time_seq != 0) {
1470 fout <<
" total nb " << time_seq << std::endl;
1478 if (run == runold) {
1480 for (
int ich = 0; ich <
kChannels; ich++) {
1481 if (ped[ich] < 300 && ped[ich] > 100) {
1482 EAmean12[ich] += ped[ich];
1483 EArms12[ich] += pedrms[ich];
1491 if (RunEntry == 0 || (run_type_kept == 2 && RunEntry < 6))
1492 fout <<
" skiped run " << runold <<
" not enough entries : " << RunEntry << std::endl;
1494 fout <<
" entry " <<
entry - 1 <<
" run " << runold <<
" nb of events " << RunEntry;
1495 firsttimeFED = time[0];
1496 for (
int ifed = 0; ifed < 54; ifed++) {
1497 fout <<
" " << time[ifed];
1498 if (firsttimeFED < time[ifed])
1499 firsttimeFED = time[ifed];
1504 bool foundNew =
false;
1506 if (runold > pedxml[
i]) {
1507 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1510 if (runold < pedxml[i + 1])
1515 int Indexxml = run16Index - 1;
1516 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1518 fxml.open(Form(
"Pedestals_%i.xml", pedxml[Indexxml]));
1519 if (!fxml.is_open()) {
1520 edm::LogInfo(
"ERROR : cannot open file Pedestals_") << pedxml[Indexxml] <<
".xml";
1524 for (
int i = 0;
i < 9;
i++)
1525 std::getline(fxml, dummyLine);
1527 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1528 fxml >> mean12 >> rms12 >> bid;
1538 std::istringstream m6(stt);
1539 m6 >> EAmean6[iEBChannel];
1541 stt = bid.substr(8, 15);
1542 std::istringstream r6(stt);
1543 r6 >> EArms6[iEBChannel];
1545 stt = bid.substr(9, 15);
1546 std::istringstream m1(stt);
1547 m1 >> EAmean1[iEBChannel];
1549 stt = bid.substr(8, 15);
1550 std::istringstream
r1(stt);
1551 r1 >> EArms1[iEBChannel];
1552 if (iEBChannel % 10000 == 0)
1553 fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12 <<
" " << EAmean6[iEBChannel] <<
" " 1554 << EArms6[iEBChannel] <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1555 for (
int i = 0;
i < 3;
i++)
1556 std::getline(fxml, dummyLine);
1558 for (
int i = 0;
i < 6;
i++)
1559 std::getline(fxml, dummyLine);
1560 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1562 fxml >> mean12 >> rms12 >> bid;
1564 std::istringstream m6(stt);
1567 stt = bid.substr(8, 15);
1568 std::istringstream r6(stt);
1571 stt = bid.substr(9, 15);
1572 std::istringstream m1(stt);
1575 stt = bid.substr(8, 15);
1576 std::istringstream
r1(stt);
1578 if (iEEChannel % 1000 == 0)
1579 fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12 <<
" " << EAmean6[ich] <<
" " 1580 << EArms6[ich] <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1581 for (
int i = 0;
i < 3;
i++)
1582 std::getline(fxml, dummyLine);
1591 for (
int ich = 0; ich <
kChannels; ich++) {
1592 if (EAentry[ich] != 0) {
1593 EAmean12[ich] /= EAentry[ich];
1594 EArms12[ich] /= EAentry[ich];
1596 EAmean12[ich] = 200.;
1599 if (ich % 10000 == 0)
1600 fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1603 item.
rms_x1 = EArms1[ich];
1605 item.
rms_x6 = EArms6[ich];
1625 for (
int ich = 0; ich <
kChannels; ich++) {
1626 if (ped[ich] < 300 && ped[ich] > 100) {
1627 EAmean12[ich] = ped[ich];
1628 EArms12[ich] = pedrms[ich];
1639 fout <<
" last entry fill " << fill_num <<
" run " << runold <<
" nb of events " << RunEntry <<
" time " << run_time
1640 <<
" " << run_time_stablebeam <<
" " << time[0] <<
" run type " << run_type << std::endl;
1641 for (
int ifed = 0; ifed < 54; ifed++)
1642 fout <<
" " << time[ifed];
1646 for (
int ich = 0; ich <
kChannels; ich++) {
1647 if (EAentry[ich] != 0) {
1648 EAmean12[ich] /= EAentry[ich];
1649 EArms12[ich] /= EAentry[ich];
1651 EAmean12[ich] = 200.;
1654 if (ich % 10000 == 0)
1655 fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1660 item.
rms_x1 = EArms1[ich];
1662 item.
rms_x6 = EArms6[ich];
1678 edm::LogInfo(
"Ecal - > end of readPedestalTree -----------\n");
1685 TFile* hfile =
new TFile(
m_filename.c_str());
1687 TTree* treeChan = (TTree*)hfile->Get(
"PedChan");
1688 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1689 treeChan->SetBranchAddress(
"Channels", &iChannel);
1690 treeChan->SetBranchAddress(
"x", &ix);
1691 treeChan->SetBranchAddress(
"y", &iy);
1692 treeChan->SetBranchAddress(
"z", &iz);
1693 int neventsChan = (
int)treeChan->GetEntries();
1697 treeChan->GetEntry(
entry);
1699 ringEB[iChannel] = (
abs(ix) - 1) / 5;
1700 sideEB[iChannel] = 1;
1702 sideEB[iChannel] = 0;
1703 if (debug &&
entry % 10000 == 0)
1704 edm::LogInfo(
" EB channel ") << iChannel <<
" eta " << ix <<
" phi " << iy <<
" side " << sideEB[iChannel]
1705 <<
" ring " << ringEB[iChannel];
1707 ixEE[iChannel] = ix;
1708 iyEE[iChannel] = iy;
1709 izEE[iChannel] = iz;
1710 if (debug &&
entry % 1000 == 0)
1711 edm::LogInfo(
" EE channel ") << iChannel <<
" x " << ixEE[iChannel] <<
" y " << iyEE[iChannel] <<
" z " 1800 Int_t run16Index = 0;
1802 Int_t fed[
kChannels],
chan[
kChannels],
id,
run, run_type, seq_id, las_id, fill_num, run_num_infill, run_time,
1803 run_time_stablebeam, nxt,
time[54];
1805 TTree*
tree = (TTree*)hfile->Get(
"T");
1807 tree->SetBranchAddress(
"id", &
id);
1808 tree->SetBranchAddress(
"run", &run);
1809 tree->SetBranchAddress(
"run_type", &run_type);
1810 tree->SetBranchAddress(
"seq_id", &seq_id);
1811 tree->SetBranchAddress(
"las_id", &las_id);
1812 tree->SetBranchAddress(
"fill_num", &fill_num);
1813 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1814 tree->SetBranchAddress(
"run_time", &run_time);
1815 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1816 tree->SetBranchAddress(
"lumi", &lumi);
1817 tree->SetBranchAddress(
"bfield", &bfield);
1818 tree->SetBranchAddress(
"nxt", &nxt);
1819 tree->SetBranchAddress(
"time", time);
1820 tree->SetBranchAddress(
"fed", fed);
1821 tree->SetBranchAddress(
"chan", chan);
1822 tree->SetBranchAddress(
"ped", ped);
1823 tree->SetBranchAddress(
"pedrms", pedrms);
1827 fout.open(
"copyTimestampPedestals.txt");
1828 if (!fout.is_open()) {
1829 edm::LogInfo(
"ERROR : cannot open file copyTimestampPedestals.txt");
1834 for (
int ich = 0; ich <
kChannels; ich++) {
1835 EAmean12[ich] = 200.;
1839 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type
1840 <<
" seq_id " << seq_id <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi " << lumi
1841 <<
" nb of Crystals " << nxt << std::endl;
1843 for (
int ich = 0; ich <
kChannels; ich++) {
1844 if (ped[ich] != 0.) {
1846 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich]
1847 <<
" RMS " << pedrms[ich] << std::endl;
1849 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " 1850 << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1855 int runold = -1, fillold = -1, firsttimeFEDold = -1;
1856 int firsttimeFED = -1, firstFillSequence = 0;
1857 bool firstSeqBeforeStable =
false;
1862 tree->GetEntry(
entry);
1863 if (nxt != kChannels) {
1865 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1866 <<
" *********** Number of channels " << nxt;
1868 fout <<
" rejected" << std::endl;
1873 if (run_type != 1) {
1874 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1875 <<
" *********** run_type ( 1 coll, 2 cosm, 3 circ, 4 test ) = " << run_type << std::endl;
1878 if (las_id != 447) {
1879 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1880 <<
" *********** laser wave length = " << las_id << std::endl;
1888 if (bfield < 3.79) {
1889 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" *********** bfield = " << bfield
1893 fout <<
" entry " <<
entry <<
" run " <<
run;
1895 fout <<
" fill " << fill_num;
1896 fout <<
" sequence " << seq_id;
1897 if (run_type == 1) {
1898 fout <<
" stable " << run_time_stablebeam;
1899 if (run_time_stablebeam < first_run_kept) {
1900 fout <<
" before first wanted " <<
m_firstRun << std::endl;
1904 firsttimeFED = time[0];
1905 for (
int ifed = 0; ifed < 54; ifed++) {
1906 if (time[ifed] > firsttimeFEDold && time[ifed] < firsttimeFED)
1907 firsttimeFED = time[ifed];
1909 if (firsttimeFED < first_run_kept) {
1910 fout <<
" time " << firsttimeFED <<
" before first wanted " <<
m_firstRun << std::endl;
1913 if (firsttimeFED > last_run_kept) {
1914 fout <<
" entry " <<
entry <<
" time " << firsttimeFED <<
" after last wanted " <<
m_lastRun << std::endl;
1917 fout <<
" time " << firsttimeFED << std::endl;
1918 if (firsttimeFED <= firsttimeFEDold) {
1919 edm::LogInfo(
" Problem finding the IOV : old one ") << firsttimeFEDold <<
" new one " << firsttimeFED;
1920 for (
int ifed = 0; ifed < 54; ifed++)
1921 edm::LogInfo(
"Time ") << time[ifed] <<
" ignore this entry ";
1924 firsttimeFEDold = firsttimeFED;
1927 if (fill_num != fillold) {
1928 firstSeqBeforeStable =
false;
1929 firstFillSequence = 0;
1931 firstFillSequence++;
1932 if (run_type == 1) {
1933 if (run_time_stablebeam > 0) {
1934 if (firsttimeFED < run_time_stablebeam) {
1935 fout <<
" data taken before stable beam, skip it" << std::endl;
1936 firstSeqBeforeStable =
true;
1942 fout <<
" *** entry " <<
entry <<
" run_time_stablebeam " << run_time_stablebeam << std::endl;
1943 if (firstSeqBeforeStable) {
1944 firstSeqBeforeStable =
false;
1945 firsttimeFED = run_time_stablebeam;
1946 fout <<
" first full sequence after stable; change the IOV " << firsttimeFED << std::endl;
1948 if (firstFillSequence == 0) {
1949 if (firsttimeFED > run_time_stablebeam) {
1950 fout <<
" first full sequence " << firsttimeFED <<
" after stable " << run_time_stablebeam
1951 <<
"; change the IOV " << std::endl;
1952 firsttimeFED = run_time_stablebeam;
1957 for (
int ich = 0; ich <
kChannels; ich++) {
1958 if (ped[ich] < 300 && ped[ich] > 100) {
1959 EAmean12[ich] = ped[ich];
1960 EArms12[ich] = pedrms[ich];
1964 bool foundNew =
false;
1965 if (run != runold) {
1967 if (run > pedxml[
i]) {
1968 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1972 if (run < pedxml[i + 1])
1977 int Indexxml = run16Index - 1;
1978 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1980 fxml.open(Form(
"Pedestals_%i.xml", pedxml[Indexxml]));
1981 if (!fxml.is_open()) {
1982 edm::LogInfo(
"ERROR : cannot open file Pedestals_") << pedxml[Indexxml] <<
".xml";
1986 for (
int i = 0;
i < 9;
i++)
1987 std::getline(fxml, dummyLine);
1989 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1990 fxml >> mean12 >> rms12 >> bid;
1992 std::istringstream m6(stt);
1993 m6 >> EAmean6[iEBChannel];
1995 stt = bid.substr(8, 15);
1996 std::istringstream r6(stt);
1997 r6 >> EArms6[iEBChannel];
1999 stt = bid.substr(9, 15);
2000 std::istringstream m1(stt);
2001 m1 >> EAmean1[iEBChannel];
2003 stt = bid.substr(8, 15);
2004 std::istringstream
r1(stt);
2005 r1 >> EArms1[iEBChannel];
2006 if (debug && iEBChannel % 10000 == 0)
2007 fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12 <<
" " << EAmean6[iEBChannel] <<
" " 2008 << EArms6[iEBChannel] <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
2009 for (
int i = 0;
i < 3;
i++)
2010 std::getline(fxml, dummyLine);
2012 for (
int i = 0;
i < 6;
i++)
2013 std::getline(fxml, dummyLine);
2014 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
2016 fxml >> mean12 >> rms12 >> bid;
2018 std::istringstream m6(stt);
2021 stt = bid.substr(8, 15);
2022 std::istringstream r6(stt);
2025 stt = bid.substr(9, 15);
2026 std::istringstream m1(stt);
2029 stt = bid.substr(8, 15);
2030 std::istringstream
r1(stt);
2032 if (debug && iEEChannel % 1000 == 0)
2033 fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12 <<
" " << EAmean6[ich] <<
" " 2034 << EArms6[ich] <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
2035 for (
int i = 0;
i < 3;
i++)
2036 std::getline(fxml, dummyLine);
2044 for (
int ich = 0; ich <
kChannels; ich++) {
2045 if (debug && ich % 10000 == 0)
2046 fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
2049 item.
rms_x1 = EArms1[ich];
2051 item.
rms_x6 = EArms6[ich];
2068 fout <<
" entry " <<
entry <<
" transfer " << transfer <<
" iov " << iov << std::endl;
2070 fout <<
" m_to_transfer " << firsttimeFED << std::endl;
2075 edm::LogInfo(
"Ecal - > end of readPedestalTimestamp -----------\n");
bool checkPedestal(EcalPedestals::Item *item)
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
T getUntrackedParameter(std::string const &, T const &) const
std::string m_userTextLog
int hashedIndex() const
get a compact index for arrays
static const int MIN_IPHI
edm::Ref< Container > Ref
std::string id() const override
float getPedRMSG1() const
constexpr uint32_t rawId() const
get the raw id
EcalPedestalsHandler(edm::ParameterSet const &)
MonRunList fetchMonRunList(const RunTag &tag, const MonRunTag &monruntag) noexcept(false)
static EEDetId unhashIndex(int hi)
void setGeneralTag(std::string tag)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
OldContainer m_to_transfer
const Int_t gainValues[kGains]
static bool validDetId(int i, int j)
check if a valid index combination
void setRunTag(const RunTag &tag)
cond::ValidityInterval lastInterval
std::string getName() const
float getPedMeanG12() const
void getNewObjects() override
EcalCondDBInterface * econn
float getPedRMSG12() const
void readPedestalTimestamp()
Abs< T >::type abs(const T &t)
int ieta() const
get the crystal ieta
void setMonVersionDef(const MonVersionDef &ver)
static const int ETAPHIMODE
std::string m_locationsource
void setLocationDef(const LocationDef &locDef)
void insert(std::pair< uint32_t, Item > const &a)
std::vector< MonRunIOV > getRuns()
EcalPedestalsMap EcalPedestals
static const int MAX_IPHI
unsigned long long uint64_t
~EcalPedestalsHandler() override
void setRunType(std::string runtype)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
std::vector< Item >::const_iterator const_iterator
static const int MAX_IETA
void setMonRunTag(const MonRunTag &tag)
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
float getPedMeanG6() const
void setLocation(std::string loc)
const Item & barrel(size_t hashedIndex) const
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
const Item & endcap(size_t hashedIndex) const
float getPedRMSG6() const
cond::TagInfo_t const & tagInfo() const