18 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalPedestalsHandler")) {
19 edm::LogInfo(
"EcalPedestals Source handler constructor\n");
84 std::ostringstream ss;
87 unsigned int max_since=0;
114 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
139 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
157 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
164 edm::LogInfo(
"Retrieving run list from ONLINE DB ... ");
194 unsigned int min_run=0;
204 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
205 int mon_runs = mon_run_vec.size();
210 for(
int kr = 0; kr < krmax; kr++){
213 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
214 edm::LogInfo(
"retrieve the data for run number: ")<< mon_run_vec[kr].getRunIOV().getRunNumber();
215 if (mon_run_vec[kr].getSubRunNumber() <=1){
218 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
220 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
222 edm::LogInfo(
"OMDS record for run ")<<irun <<
" is made of "<< dataset_mon.size();
223 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
224 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
230 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
233 int sm_num=ecid_xt.
getID1();
234 int xt_num=ecid_xt.
getID2();
235 int yt_num=ecid_xt.
getID3();
248 if(ecid_xt.
getName()==
"EB_crystal_number") {
261 if(nbad < 10)
std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/"<< yt_num
289 if(nbad<(dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
291 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
294 int sm_num=ecid_xt.
getID1();
295 int xt_num=ecid_xt.
getID2();
296 int yt_num=ecid_xt.
getID3();
306 if(ecid_xt.
getName()==
"EB_crystal_number") {
329 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
335 EEDetId eedetid(xt_num,yt_num,sm_num);
355 peds->
insert(std::make_pair(eedetid.
rawId(),item));
360 edm::LogInfo(
"Generating popcon record for run ") << irun <<
"..." << std::flush;
368 if(iEta==0)
continue;
385 pedtemp->
insert(std::make_pair(ebdetid.
rawId(),item));
386 if((iEta==-1 || iEta==1) && iPhi==20){
388 edm::LogInfo(
"channel:") <<iEta<<
"/"<<iPhi<<
"/" << hiee <<
" ped mean 12="<< x;
410 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
425 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
433 ss <<
"Run=" << irun <<
"_WAS_GOOD_"<<std::endl;
437 edm::LogInfo(
"Run ") << irun <<
" was BAD !!!! not sent to the DB";
438 if(nbad >= (dataset_mon.size()*0.05))
444 ss <<
"Run=" << irun <<
"_WAS_BAD_"<<std::endl;
453 edm::LogInfo(
"Ecal - > end of getNewObjects -----------\n");
459 unsigned int max_since=0;
478 int ixmin=86;
int ixmax=95;
479 int iymin=46;
int iymax=55;
480 for(
int iX=ixmin; iX<=ixmax ;++iX) {
481 for(
int iY=iymin; iY<=iymax; ++iY) {
496 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
504 edm::LogInfo(
"We just retrieved the last valid record from DB ");
509 edm::LogInfo(
"Retrieving run list from ONLINE DB ... ");
546 unsigned int min_run=max_since+1;
551 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
552 size_t mon_runs=mon_run_vec.size();
557 for(
size_t kr=0; kr<mon_runs; kr++){
559 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
561 edm::LogInfo(
"here is first sub run : ") << mon_run_vec[kr].getSubRunNumber();
562 edm::LogInfo(
"here is the run number: ") << mon_run_vec[kr].getRunIOV().getRunNumber();
566 if (mon_run_vec[kr].getSubRunNumber() <=1){
570 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
573 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
575 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
576 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
585 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
589 int xt_num=ecid_xt.
getID2();
612 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
616 edm::LogInfo(
"Generating popcon record for run ") << irun <<
"..." << std::flush;
627 for(
int iX=ixmin; iX<=ixmax ;++iX) {
628 for(
int iY=iymin; iY<=iymax; ++iY) {
644 pedtemp->
insert(std::make_pair(eedetidpos.
rawId(),item));
656 edm::LogInfo(
"Ecal - > end of getNewObjectsH2 -----------\n");
668 std::ifstream fInput;
670 if(!fInput.is_open()) {
679 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
680 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
681 >> EBmean1[iChannel] >> EBrms1[iChannel];
682 if(hashedId != iChannel + 1) {
690 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
691 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
692 >> EEmean1[iChannel] >> EErms1[iChannel];
693 if(hashedId != iChannel + kEBChannels + 1) {
703 if(iEta==0)
continue;
710 item.
rms_x1 = EBrms1[hieb];
712 item.
rms_x6 = EBrms6[hieb];
722 for(
int iz = -1; iz < 2; iz = iz + 2) {
731 item.
rms_x1 = EErms1[hiee];
733 item.
rms_x6 = EErms6[hiee];
747 edm::LogInfo(
"Ecal - > end of readPedestalFile -----------\n");
756 if(!fxml.is_open()) {
761 fout.open(
"Pedestal.check");
765 double RingMean[28][2][3], RingRMS[28][2][3];
768 for (
int side = 0; side < 2; side++) {
769 for (
int igain = 0; igain <
kGains; igain++) {
770 RingMean[
ring][side][igain] = 0.;
771 RingRMS[
ring][side][igain] = 0.;
772 NbVal[
ring][side][igain] = 0;
777 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
779 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
781 int ieta = ebdetid.
ieta();
783 if(ring < 0 || ring > 16)
edm::LogInfo(
"EB channel ") << iEBChannel <<
" ring " <<
ring;
785 if(ieta > 0) izz = 1;
788 std::istringstream m12(stt);
789 m12 >> EBmean12[iEBChannel];
791 stt = bid.substr(9,15);
792 std::istringstream r12(stt);
793 r12 >> EBrms12[iEBChannel];
794 if(EBrms12[iEBChannel] != 0. && EBrms12[iEBChannel] < 5.) {
795 RingMean[
ring][izz][0] += EBrms12[iEBChannel];
796 RingRMS[
ring][izz][0] += EBrms12[iEBChannel] * EBrms12[iEBChannel];
797 NbVal[
ring][izz][0]++;
800 stt = bid.substr(9,15);
801 std::istringstream m6(stt);
802 m6 >> EBmean6[iEBChannel];
804 stt = bid.substr(8,15);
805 std::istringstream r6(stt);
806 r6 >> EBrms6[iEBChannel];
807 if(EBrms6[iEBChannel] != 0. && EBrms6[iEBChannel] < 5.) {
808 RingMean[
ring][izz][1] += EBrms6[iEBChannel];
809 RingRMS[
ring][izz][1] += EBrms6[iEBChannel] * EBrms6[iEBChannel];
810 NbVal[
ring][izz][1]++;
813 stt = bid.substr(9,15);
814 std::istringstream m1(stt);
815 m1 >> EBmean1[iEBChannel];
817 stt = bid.substr(8,15);
818 std::istringstream
r1(stt);
819 r1 >> EBrms1[iEBChannel];
820 if(EBrms1[iEBChannel] != 0. && EBrms1[iEBChannel] < 5.) {
821 RingMean[
ring][izz][2] += EBrms1[iEBChannel];
822 RingRMS[
ring][izz][2] += EBrms1[iEBChannel] * EBrms1[iEBChannel];
823 NbVal[
ring][izz][2]++;
825 if(iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel
826 <<
" " << EBmean12[iEBChannel] <<
" " << EBrms12[iEBChannel]
827 <<
" " << EBmean6[iEBChannel] <<
" " << EBrms6[iEBChannel]
828 <<
" " << EBmean1[iEBChannel] <<
" " << EBrms1[iEBChannel] << std::endl;
829 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
833 std::ifstream fCrystal;
834 fCrystal.open(
"Crystal");
835 if(!fCrystal.is_open()) {
840 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
841 fCrystal >> ringEE[iChannel];
842 int ring =
abs(ringEE[iChannel]) - 1;
843 if(ring < 17 || ring > 27) {
844 edm::LogInfo(
" EE channel ") << iChannel <<
" ring " << ringEE[iChannel];
851 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
852 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
856 std::istringstream m12(stt);
857 m12 >> EEmean12[iEEChannel];
858 int ring =
abs(ringEE[iEEChannel]) - 1;
859 if(ring < 17 || ring > 27)
edm::LogInfo(
"EE channel ") << iEEChannel <<
" ring " <<
ring;
861 if(iEEChannel < 7324) izz = 0;
863 stt = bid.substr(9,15);
864 std::istringstream r12(stt);
865 r12 >> EErms12[iEEChannel];
866 if(EErms12[iEEChannel] != 0. && EErms12[iEEChannel] < 5.) {
867 RingMean[
ring][izz][0] += EErms12[iEEChannel];
868 RingRMS[
ring][izz][0] += EErms12[iEEChannel] * EErms12[iEEChannel];
869 NbVal[
ring][izz][0]++;
872 stt = bid.substr(9,15);
873 std::istringstream m6(stt);
874 m6 >> EEmean6[iEEChannel];
876 stt = bid.substr(8,15);
877 std::istringstream r6(stt);
878 r6 >> EErms6[iEEChannel];
879 if(EErms6[iEEChannel] != 0. && EErms6[iEEChannel] < 5.) {
880 RingMean[
ring][izz][1] += EErms6[iEEChannel];
881 RingRMS[
ring][izz][1] += EErms6[iEEChannel] * EErms6[iEEChannel];
882 NbVal[
ring][izz][1]++;
885 stt = bid.substr(9,15);
886 std::istringstream m1(stt);
887 m1 >> EEmean1[iEEChannel];
889 stt = bid.substr(8,15);
890 std::istringstream
r1(stt);
891 r1 >> EErms1[iEEChannel];
892 if(EErms1[iEEChannel] != 0. && EErms1[iEEChannel] < 5.) {
893 RingMean[
ring][izz][2] += EErms1[iEEChannel];
894 RingRMS[
ring][izz][2] += EErms1[iEEChannel] * EErms1[iEEChannel];
895 NbVal[
ring][izz][2]++;
897 if(iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel
898 <<
" " << EEmean12[iEEChannel] <<
" " << EErms12[iEEChannel]
899 <<
" " << EEmean6[iEEChannel] <<
" " << EErms6[iEEChannel]
900 <<
" " << EEmean1[iEEChannel] <<
" " << EErms1[iEEChannel] << std::endl;
901 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
909 for (
int side = 0; side < 2; side++) {
915 double x = RingMean[
ring][side][
gain];
919 fout <<
" ring " <<
ring + 1 <<
" mean " << x <<
" rms " << rms <<
" ";
922 if(
ring == 16) fout <<
"***** End caps ***** EE- EE+" << std::endl;
931 if(iEta==0)
continue;
942 if(ring < 0 || ring > 16)
edm::LogInfo(
"EB channel ") << hieb <<
" ring " <<
ring;
944 if(iEta > 0) side = 1;
945 if(EBrms1[hieb] == 0 || EBrms1[hieb] > RingMean[ring][side][2] + 3 * RingRMS[ring][side][2]) {
946 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
947 <<
" gain 1 rms " << EBrms1[hieb] <<
" replaced by " << RingMean[
ring][side][2] << std::endl;
950 else item.
rms_x1 = EBrms1[hieb];
951 if(EBrms6[hieb] == 0 || EBrms6[hieb] > RingMean[ring][side][1] + 3 * RingRMS[ring][side][1]) {
952 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
953 <<
" gain 6 rms " << EBrms6[hieb] <<
" replaced by " << RingMean[
ring][side][1] << std::endl;
956 else item.
rms_x6 = EBrms6[hieb];
957 if(EBrms12[hieb] == 0 || EBrms12[hieb] > RingMean[ring][side][0] + 3 * RingRMS[ring][side][0]) {
958 fout <<
" EB channel " << hieb <<
" eta " << iEta <<
" phi " << iPhi <<
" ring " << ring + 1
959 <<
" gain 12 rms " << EBrms12[hieb] <<
" replaced by " << RingMean[
ring][side][0] << std::endl;
962 else item.
rms_x12 = EBrms12[hieb];
963 if(hieb > 4534 && hieb < 4540)
965 <<
" 12 " << EBrms12[hieb] <<
" mean " << RingMean[
ring][side][0] <<
" rms " << RingRMS[
ring][side][0]
966 <<
" 6 " << EBrms6[hieb] <<
" mean " << RingMean[
ring][side][1] <<
" rms " << RingRMS[
ring][side][1]
967 <<
" 1 " << EBrms1[hieb] <<
" mean " << RingMean[
ring][side][2] <<
" rms " << RingRMS[
ring][side][2];
970 item.
rms_x1 = EBrms1[hieb];
971 item.
rms_x6 = EBrms6[hieb];
982 for(
int iz = -1; iz < 2; iz = iz + 2) {
994 int ring =
abs(ringEE[hiee]) - 1;
995 if(ring < 17 || ring > 27)
edm::LogInfo(
"EE channel ") << hiee <<
" ring " <<
ring;
996 if(EErms1[hiee] == 0 || EErms1[hiee] > RingMean[ring][iz][2] + 3 * RingRMS[ring][iz][2]) {
997 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
998 <<
" gain 1 rms " << EErms1[hiee] <<
" replaced by " << RingMean[
ring][iz][2] << std::endl;
1001 else item.
rms_x1 = EErms1[hiee];
1002 if(EErms6[hiee] == 0 || EErms6[hiee] > RingMean[ring][iz][1] + 3 * RingRMS[ring][iz][1]) {
1003 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
1004 <<
" gain 6 rms " << EErms6[hiee] <<
" replaced by " << RingMean[
ring][iz][1] << std::endl;
1007 else item.
rms_x6 = EErms6[hiee];
1008 if(EErms12[hiee] == 0 || EErms12[hiee] > RingMean[ring][iz][0] + 3 * RingRMS[ring][iz][0]) {
1009 fout <<
" EE channel " << hiee <<
" x " << iX <<
" y " << iY <<
" z " << iz <<
" ring " << ring + 1
1010 <<
" gain 12 rms " << EErms12[hiee] <<
" replaced by " << RingMean[
ring][iz][0] << std::endl;
1013 else item.
rms_x12 = EErms12[hiee];
1016 item.
rms_x1 = EErms1[hiee];
1017 item.
rms_x6 = EErms6[hiee];
1020 ped->
insert(std::make_pair(eedetid.
rawId(),item));
1031 edm::LogInfo(
"Ecal - > end of readPedestalMC -----------\n");
1046 if(iEta==0)
continue;
1061 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
1080 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
1094 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
1100 std::ifstream fInput;
1102 if(!fInput.is_open()) {
1111 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
1112 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
1113 >> EBmean1[iChannel] >> EBrms1[iChannel];
1114 if(hashedId != iChannel + 1) {
1122 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
1123 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
1124 >> EEmean1[iChannel] >> EErms1[iChannel];
1125 if(hashedId != iChannel + kEBChannels + 1) {
1135 if(iEta==0)
continue;
1142 if(debug & (EBmean12[hieb] == -999. || EBrms12[hieb] == -999. || EBmean6[hieb] == -999. || EBrms6[hieb] == -999. ||
1143 EBmean1[hieb] == -999. || EBrms1[hieb] == -999.))
1144 edm::LogInfo(
" bad EB channel eta ") << iEta <<
" phi " << iPhi <<
" " << EBmean12[hieb] <<
" " << EBrms12[hieb]
1145 <<
" " << EBmean6[hieb] <<
" " << EBrms6[hieb] <<
" " << EBmean1[hieb] <<
" " << EBrms1[hieb];
1146 if(EBmean1[hieb] != -999.) item.
mean_x1 = EBmean1[hieb];
1148 if(EBrms1[hieb] != -999.) item.
rms_x1 = EBrms1[hieb];
1150 if(EBmean6[hieb] != -999.) item.
mean_x6 = EBmean6[hieb];
1152 if(EBrms6[hieb] != -999.) item.
rms_x6 = EBrms6[hieb];
1154 if(EBmean12[hieb] != -999.) item.
mean_x12 = EBmean12[hieb];
1156 if(EBrms12[hieb] != -999.) item.
rms_x12 = EBrms12[hieb];
1158 ped->
insert(std::make_pair(ebdetid.
rawId(),item));
1165 for(
int iz = -1; iz < 2; iz = iz + 2) {
1174 if(debug & (EEmean12[hiee] == -999. || EErms12[hiee] == -999. || EEmean6[hiee] == -999. || EErms6[hiee] == -999. ||
1175 EEmean1[hiee] == -999. || EErms1[hiee] == -999.))
1176 edm::LogInfo(
" bad EE channel x ") << iX <<
" y " << iY <<
" z" << iz <<
" " << EEmean12[hiee] <<
" " << EErms12[hiee]
1177 <<
" " <<EEmean6[hiee] <<
" " << EErms6[hiee] <<
" " << EEmean1[hiee] <<
" " << EErms1[hiee];
1178 if(EEmean1[hiee] != -999.) item.
mean_x1 = EEmean1[hiee];
1180 if(EErms1[hiee] != -999.) item.
rms_x1 = EErms1[hiee];
1182 if(EEmean6[hiee] != -999.) item.
mean_x6 = EEmean6[hiee];
1184 if(EErms6[hiee] != -999.) item.
rms_x6 = EErms6[hiee];
1186 if(EEmean12[hiee] != -999.) item.
mean_x12 = EEmean12[hiee];
1188 if(EErms12[hiee] != -999.) item.
rms_x12 = EErms12[hiee];
1190 ped->
insert(std::make_pair(eedetid.
rawId(),item));
1201 edm::LogInfo(
"Ecal - > end of readPedestal2017 -----------\n");
1207 TFile * hfile =
new TFile(
m_filename.c_str());
1209 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
1210 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1211 treeChan->SetBranchAddress(
"Channels", &iChannel);
1212 treeChan->SetBranchAddress(
"x", &ix);
1213 treeChan->SetBranchAddress(
"y", &iy);
1214 treeChan->SetBranchAddress(
"z", &iz);
1215 int neventsChan = (
int)treeChan->GetEntries();
1219 treeChan->GetEntry(
entry);
1221 ringEB[iChannel] = (
abs(ix) -1)/5;
1222 sideEB[iChannel] = 1;
1223 if(ix < 0) sideEB[iChannel] = 0;
1224 if(
entry%10000 == 0)
edm::LogInfo(
" EB channel ") << iChannel <<
" eta " << ix <<
" phi " << iy
1225 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel];
1228 ixEE[iChannel] = ix;
1229 iyEE[iChannel] = iy;
1230 izEE[iChannel] = iz;
1231 if(
entry%1000 == 0)
edm::LogInfo(
" EE channel ") << iChannel <<
" x " << ixEE[iChannel] <<
" y " << iyEE[iChannel] <<
" z " << izEE[iChannel];
1235 Int_t pedxml[
Nbpedxml] = {271948, 273634, 273931, 274705, 275403, 276108, 276510, 277169, 278123, 278183,
1236 278246, 278389, 278499, 278693, 278858, 278888, 278931, 279728, 280129, 280263,
1237 280941, 281753, 282631, 282833, 283199, 283766,
1239 286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
1240 299279, 299710, 300186, 300581, 301191, 302006, 302293, 302605, 303436, 303848,
1241 304211, 304680, 305117, 305848, 306176,
1243 313760, 315434, 315831, 316299, 316694, 316963, 317399, 317669, 318249, 318747,
1244 319111, 319365, 319700, 320098, 320515, 320905, 321184, 321480, 321855, 322151,
1245 322653, 323261, 323802, 324250, 324632, 325909, 326038, 326652, 326979, 327271};
1247 Int_t run16Index = 0;
1249 Int_t fed[
kChannels],
chan[
kChannels],
id,
run, run_type, seq_id, las_id, fill_num, run_num_infill, run_time, run_time_stablebeam, nxt,
time[54];
1251 TTree *
tree = (TTree*)hfile->Get(
"T");
1253 tree->SetBranchAddress(
"id", &
id);
1254 tree->SetBranchAddress(
"run", &run);
1255 tree->SetBranchAddress(
"run_type", &run_type);
1256 tree->SetBranchAddress(
"seq_id", &seq_id);
1257 tree->SetBranchAddress(
"las_id", &las_id);
1258 tree->SetBranchAddress(
"fill_num", &fill_num);
1259 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1260 tree->SetBranchAddress(
"run_time", &run_time);
1261 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1262 tree->SetBranchAddress(
"lumi", &lumi);
1263 tree->SetBranchAddress(
"bfield", &bfield);
1264 tree->SetBranchAddress(
"nxt", &nxt);
1265 tree->SetBranchAddress(
"time", time);
1266 tree->SetBranchAddress(
"fed", fed);
1267 tree->SetBranchAddress(
"chan", chan);
1268 tree->SetBranchAddress(
"ped", ped);
1269 tree->SetBranchAddress(
"pedrms", pedrms);
1270 int nevents = (
int)tree->GetEntries();
1273 fout.open(
"copyTreePedestals.txt");
1274 if(!fout.is_open()) {
1275 edm::LogInfo(
"ERROR : cannot open file copyTreePedestals.txt");
1280 for(
int ich = 0; ich <
kChannels; ich++) {
1286 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
1287 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
1288 for(
int ich = 0; ich <
kChannels; ich++) {
1289 if(ped[ich] != 0.) {
1291 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1293 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
1294 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1302 int firsttimeFED = -1;
1305 tree->GetEntry(
entry);
1306 if(run < first_run_kept) {
1307 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1308 <<
" before first wanted " <<
m_firstRun << std::endl;
1312 if(run > last_run_kept) {
1313 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1314 <<
" after last wanted " <<
m_lastRun << std::endl;
1318 if(run_type != run_type_kept) {
1319 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1320 <<
" run type " << run_type << std::endl;
1323 if(nxt != kChannels) {
1324 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1325 <<
" *********** Number of channels " << nxt << std::endl;
1329 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1330 <<
" *********** bfield = " << bfield << std::endl;
1333 if(run_type_kept == 1) {
1335 for(
int ifed = 0; ifed < 54; ifed++) {
1336 if(time[ifed] < run_time_stablebeam) {
1338 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1339 <<
" *********** sequence before stable beam at " << run_time_stablebeam <<
" FED " << ifed <<
" : " << time[ifed];
1341 fout <<
" FED " << ifed <<
" : " << time[ifed];
1346 fout <<
" total nb " << time_seq << std::endl;
1356 for(
int ich = 0; ich <
kChannels; ich++) {
1357 if(ped[ich] < 300 && ped[ich] > 100) {
1358 EAmean12[ich] += ped[ich];
1359 EArms12[ich] += pedrms[ich];
1368 if(RunEntry == 0 || (run_type_kept == 2 && RunEntry < 6)) fout <<
" skiped run " << runold <<
" not enough entries : " << RunEntry << std::endl;
1370 fout <<
" entry "<<
entry -1 <<
" run " << runold <<
" nb of events " << RunEntry;
1371 firsttimeFED = time[0];
1372 for(
int ifed = 0; ifed < 54; ifed++) {
1373 fout <<
" " << time[ifed];
1374 if(firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1379 bool foundNew =
false;
1381 if(runold > pedxml[
i]) {
1382 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1385 if(runold < pedxml[i + 1])
break;
1389 int Indexxml = run16Index -1;
1390 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1392 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1393 if(!fxml.is_open()) {
1394 edm::LogInfo(
"ERROR : cannot open file Pedestals_") << pedxml[Indexxml] <<
".xml";
1398 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1400 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1401 fxml >> mean12 >> rms12 >> bid;
1411 std::istringstream m6(stt);
1412 m6 >> EAmean6[iEBChannel];
1414 stt = bid.substr(8,15);
1415 std::istringstream r6(stt);
1416 r6 >> EArms6[iEBChannel];
1418 stt = bid.substr(9,15);
1419 std::istringstream m1(stt);
1420 m1 >> EAmean1[iEBChannel];
1422 stt = bid.substr(8,15);
1423 std::istringstream
r1(stt);
1424 r1 >> EArms1[iEBChannel];
1425 if(iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1426 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1427 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1428 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1430 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1431 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1433 fxml >> mean12 >> rms12 >> bid;
1435 std::istringstream m6(stt);
1438 stt = bid.substr(8,15);
1439 std::istringstream r6(stt);
1442 stt = bid.substr(9,15);
1443 std::istringstream m1(stt);
1446 stt = bid.substr(8,15);
1447 std::istringstream
r1(stt);
1449 if(iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1450 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1451 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1452 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1461 for(
int ich = 0; ich <
kChannels; ich++) {
1462 if(EAentry[ich] != 0) {
1463 EAmean12[ich] /= EAentry[ich];
1464 EArms12[ich] /= EAentry[ich];
1467 EAmean12[ich] = 200.;
1470 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1473 item.
rms_x1 = EArms1[ich];
1475 item.
rms_x6 = EArms6[ich];
1481 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1487 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1496 for(
int ich = 0; ich <
kChannels; ich++) {
1497 if(ped[ich] < 300 && ped[ich] > 100) {
1498 EAmean12[ich] = ped[ich];
1499 EArms12[ich] = pedrms[ich];
1511 fout <<
" last entry fill " << fill_num <<
" run " << runold <<
" nb of events " << RunEntry
1512 <<
" time " << run_time <<
" " << run_time_stablebeam <<
" " << time[0] <<
" run type " << run_type << std::endl;
1513 for(
int ifed = 0; ifed < 54; ifed++)
1514 fout <<
" " << time[ifed];
1518 for(
int ich = 0; ich <
kChannels; ich++) {
1519 if(EAentry[ich] != 0) {
1520 EAmean12[ich] /= EAentry[ich];
1521 EArms12[ich] /= EAentry[ich];
1524 EAmean12[ich] = 200.;
1527 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1532 item.
rms_x1 = EArms1[ich];
1534 item.
rms_x6 = EArms6[ich];
1540 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1546 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1551 edm::LogInfo(
"Ecal - > end of readPedestalTree -----------\n");
1558 TFile * hfile =
new TFile(
m_filename.c_str());
1560 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
1561 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1562 treeChan->SetBranchAddress(
"Channels", &iChannel);
1563 treeChan->SetBranchAddress(
"x", &ix);
1564 treeChan->SetBranchAddress(
"y", &iy);
1565 treeChan->SetBranchAddress(
"z", &iz);
1566 int neventsChan = (
int)treeChan->GetEntries();
1570 treeChan->GetEntry(
entry);
1572 ringEB[iChannel] = (
abs(ix) -1)/5;
1573 sideEB[iChannel] = 1;
1574 if(ix < 0) sideEB[iChannel] = 0;
1575 if(debug &&
entry%10000 == 0)
edm::LogInfo(
" EB channel ") << iChannel <<
" eta " << ix <<
" phi " << iy
1576 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel];
1579 ixEE[iChannel] = ix;
1580 iyEE[iChannel] = iy;
1581 izEE[iChannel] = iz;
1582 if(debug &&
entry%1000 == 0)
edm::LogInfo(
" EE channel ") << iChannel <<
" x " << ixEE[iChannel] <<
" y " 1583 << iyEE[iChannel] <<
" z " << izEE[iChannel];
1587 Int_t pedxml[
Nbpedxml] = {271948, 273634, 273931, 274705, 275403, 276108, 276510, 277169, 278123, 278183,
1588 278246, 278389, 278499, 278693, 278858, 278888, 278931, 279728, 280129, 280263,
1589 280941, 281753, 282631, 282833, 283199, 283766,
1591 286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
1592 299279, 299710, 300186, 300581, 301191, 302006, 302293, 302605, 303436, 303848,
1593 304211, 304680, 305117, 305848, 306176,
1595 313760, 315434, 315831, 316299, 316694, 316963, 317399, 317669, 318249, 318747,
1596 319111, 319365, 319700, 320098, 320515, 320905, 321184, 321480, 321855, 322151,
1597 322653, 323261, 323802, 324250, 324632, 325909, 326038, 326652, 326979, 327271};
1599 Int_t run16Index = 0;
1601 Int_t fed[
kChannels],
chan[
kChannels],
id,
run, run_type, seq_id, las_id, fill_num, run_num_infill, run_time, run_time_stablebeam, nxt,
time[54];
1603 TTree *
tree = (TTree*)hfile->Get(
"T");
1605 tree->SetBranchAddress(
"id", &
id);
1606 tree->SetBranchAddress(
"run", &run);
1607 tree->SetBranchAddress(
"run_type", &run_type);
1608 tree->SetBranchAddress(
"seq_id", &seq_id);
1609 tree->SetBranchAddress(
"las_id", &las_id);
1610 tree->SetBranchAddress(
"fill_num", &fill_num);
1611 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1612 tree->SetBranchAddress(
"run_time", &run_time);
1613 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1614 tree->SetBranchAddress(
"lumi", &lumi);
1615 tree->SetBranchAddress(
"bfield", &bfield);
1616 tree->SetBranchAddress(
"nxt", &nxt);
1617 tree->SetBranchAddress(
"time", time);
1618 tree->SetBranchAddress(
"fed", fed);
1619 tree->SetBranchAddress(
"chan", chan);
1620 tree->SetBranchAddress(
"ped", ped);
1621 tree->SetBranchAddress(
"pedrms", pedrms);
1622 int nevents = (
int)tree->GetEntries();
1625 fout.open(
"copyTimestampPedestals.txt");
1626 if(!fout.is_open()) {
1627 edm::LogInfo(
"ERROR : cannot open file copyTimestampPedestals.txt");
1631 for(
int ich = 0; ich <
kChannels; ich++) {
1632 EAmean12[ich] = 200.;
1636 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
1637 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
1639 for(
int ich = 0; ich <
kChannels; ich++) {
1640 if(ped[ich] != 0.) {
1642 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1644 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
1645 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1650 int runold = -1, fillold = -1, firsttimeFEDold = -1;
1651 int firsttimeFED = -1, firstFillSequence = 0;
1652 bool firstSeqBeforeStable =
false;
1657 tree->GetEntry(
entry);
1658 if(nxt != kChannels) {
1660 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1661 <<
" *********** Number of channels " << nxt;
1663 fout <<
" rejected" << std::endl;
1669 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1670 <<
" *********** run_type ( 1 coll, 2 cosm, 3 circ, 4 test ) = " << run_type << std::endl;
1674 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1675 <<
" *********** laser wave length = " << las_id << std::endl;
1684 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1685 <<
" *********** bfield = " << bfield << std::endl;
1688 fout <<
" entry "<<
entry <<
" run " <<
run;
1689 if(run_type == 1) fout <<
" fill " << fill_num;
1690 fout <<
" sequence " << seq_id;
1692 fout <<
" stable " << run_time_stablebeam;
1693 if(run_time_stablebeam < first_run_kept) {
1694 fout <<
" before first wanted " <<
m_firstRun << std::endl;
1698 firsttimeFED = time[0];
1699 for(
int ifed = 0; ifed < 54; ifed++) {
1700 if(time[ifed] > firsttimeFEDold && time[ifed] < firsttimeFED) firsttimeFED = time[ifed];
1702 if(firsttimeFED < first_run_kept) {
1703 fout <<
" time " << firsttimeFED <<
" before first wanted " <<
m_firstRun << std::endl;
1706 if(firsttimeFED > last_run_kept) {
1707 fout <<
" entry " <<
entry <<
" time " << firsttimeFED <<
" after last wanted " <<
m_lastRun << std::endl;
1710 fout <<
" time " << firsttimeFED << std::endl;
1711 if(firsttimeFED <= firsttimeFEDold) {
1712 edm::LogInfo(
" Problem finding the IOV : old one ") << firsttimeFEDold <<
" new one " << firsttimeFED;
1713 for(
int ifed = 0; ifed < 54; ifed++)
1714 edm::LogInfo(
"Time ") << time[ifed] <<
" ignore this entry ";
1717 firsttimeFEDold = firsttimeFED;
1720 if(fill_num != fillold) {
1721 firstSeqBeforeStable =
false;
1722 firstFillSequence = 0;
1724 else firstFillSequence++;
1726 if(run_time_stablebeam > 0) {
1727 if(firsttimeFED < run_time_stablebeam) {
1728 fout <<
" data taken before stable beam, skip it" << std::endl;
1729 firstSeqBeforeStable =
true;
1736 fout <<
" *** entry " <<
entry <<
" run_time_stablebeam " << run_time_stablebeam << std::endl;
1737 if(firstSeqBeforeStable) {
1738 firstSeqBeforeStable =
false;
1739 firsttimeFED = run_time_stablebeam;
1740 fout <<
" first full sequence after stable; change the IOV " << firsttimeFED << std::endl;
1742 if(firstFillSequence == 0) {
1743 if(firsttimeFED > run_time_stablebeam) {
1744 fout <<
" first full sequence " << firsttimeFED <<
" after stable " << run_time_stablebeam <<
"; change the IOV " << std::endl;
1745 firsttimeFED = run_time_stablebeam;
1750 for(
int ich = 0; ich <
kChannels; ich++) {
1751 if(ped[ich] < 300 && ped[ich] > 100) {
1752 EAmean12[ich] = ped[ich];
1753 EArms12[ich] = pedrms[ich];
1757 bool foundNew =
false;
1760 if(run > pedxml[
i]) {
1761 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1765 if(run < pedxml[i + 1])
break;
1769 int Indexxml = run16Index -1;
1770 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1772 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1773 if(!fxml.is_open()) {
1774 edm::LogInfo(
"ERROR : cannot open file Pedestals_") << pedxml[Indexxml] <<
".xml";
1778 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1780 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1781 fxml >> mean12 >> rms12 >> bid;
1783 std::istringstream m6(stt);
1784 m6 >> EAmean6[iEBChannel];
1786 stt = bid.substr(8,15);
1787 std::istringstream r6(stt);
1788 r6 >> EArms6[iEBChannel];
1790 stt = bid.substr(9,15);
1791 std::istringstream m1(stt);
1792 m1 >> EAmean1[iEBChannel];
1794 stt = bid.substr(8,15);
1795 std::istringstream
r1(stt);
1796 r1 >> EArms1[iEBChannel];
1797 if(debug && iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1798 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1799 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1800 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1802 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1803 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1805 fxml >> mean12 >> rms12 >> bid;
1807 std::istringstream m6(stt);
1810 stt = bid.substr(8,15);
1811 std::istringstream r6(stt);
1814 stt = bid.substr(9,15);
1815 std::istringstream m1(stt);
1818 stt = bid.substr(8,15);
1819 std::istringstream
r1(stt);
1821 if(debug && iEEChannel%1000 == 0)
1822 fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1823 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1824 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1825 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1833 for(
int ich = 0; ich <
kChannels; ich++) {
1834 if(debug && ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1837 item.
rms_x1 = EArms1[ich];
1839 item.
rms_x6 = EArms6[ich];
1845 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1851 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1857 fout <<
" entry " <<
entry <<
" transfer " << transfer <<
" iov " << iov << std::endl;
1859 fout <<
" m_to_transfer " << firsttimeFED << std::endl;
1864 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