17 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalPedestalsHandler")) {
19 std::cout <<
"EcalPedestals Source handler constructor\n" << std::endl;
32 std::cout <<
m_sid<<
"/"<<m_user<<
"/"<<m_pass<<
"/"<<m_location<<
"/"<<m_gentag << std::endl;
40 std::cout <<
"------- Ecal - > getNewObjects\n";
78 std::ostringstream ss;
81 unsigned int max_since=0;
83 std::cout <<
"max_since : " << max_since << std::endl;
88 std::cout <<
"retrieved last payload " << std::endl;
108 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
133 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
151 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
158 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
160 std::cout <<
"Connection done" << std::endl;
188 unsigned int min_run=0;
198 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
199 int mon_runs = mon_run_vec.size();
200 std::cout <<
"number of Mon runs is : "<< mon_runs<< std::endl;
204 for(
int kr = 0; kr < krmax; kr++){
205 std::cout <<
"-kr------: "<<kr<<std::endl;
207 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
208 std::cout <<
"retrieve the data for run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
209 if (mon_run_vec[kr].getSubRunNumber() <=1){
212 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
214 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
216 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
217 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
218 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
224 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
227 int sm_num=ecid_xt.
getID1();
228 int xt_num=ecid_xt.
getID2();
229 int yt_num=ecid_xt.
getID3();
242 if(ecid_xt.
getName()==
"EB_crystal_number") {
255 if(nbad < 10)
std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/"<< yt_num
283 if(nbad<(dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
285 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
288 int sm_num=ecid_xt.
getID1();
289 int xt_num=ecid_xt.
getID2();
290 int yt_num=ecid_xt.
getID3();
300 if(ecid_xt.
getName()==
"EB_crystal_number") {
323 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
329 EEDetId eedetid(xt_num,yt_num,sm_num);
349 peds->
insert(std::make_pair(eedetid.
rawId(),item));
354 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
362 if(iEta==0)
continue;
379 pedtemp->
insert(std::make_pair(ebdetid.
rawId(),item));
380 if((iEta==-1 || iEta==1) && iPhi==20){
382 std::cout<<
"channel:" <<iEta<<
"/"<<iPhi<<
"/" << hiee <<
" ped mean 12="<< x << std::endl;
404 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
419 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
427 ss <<
"Run=" << irun <<
"_WAS_GOOD_"<<std::endl;
431 std::cout <<
"Run " << irun <<
" was BAD !!!! not sent to the DB";
432 if(nbad >= (dataset_mon.size()*0.05))
433 std::cout <<
" number of bad channels = " << nbad;
435 std::cout <<
" number of EB channels = " << nEB;
437 std::cout <<
" number of EE channels = " << nEE;
439 ss <<
"Run=" << irun <<
"_WAS_BAD_"<<std::endl;
448 std::cout <<
"Ecal - > end of getNewObjects -----------\n";
453 unsigned int max_since=0;
455 std::cout <<
"max_since : " << max_since << std::endl;
458 std::cout <<
"retrieved last payload " << std::endl;
472 int ixmin=86;
int ixmax=95;
473 int iymin=46;
int iymax=55;
474 for(
int iX=ixmin; iX<=ixmax ;++iX) {
475 for(
int iY=iymin; iY<=iymax; ++iY) {
490 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
498 std::cout <<
"WOW: we just retrieved the last valid record from DB "<< std::endl;
503 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
505 std::cout <<
"Making connection..." << std::flush;
540 unsigned int min_run=max_since+1;
545 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
546 size_t mon_runs=mon_run_vec.size();
547 std::cout <<
"number of Mon runs is : "<< mon_runs<< std::endl;
551 for(
size_t kr=0; kr<mon_runs; kr++){
553 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
555 std::cout <<
"here is first sub run : "<< mon_run_vec[kr].getSubRunNumber() << std::endl;
556 std::cout <<
"here is the run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
558 std::cout <<
" retrieve the data for a given run"<< std::endl;
560 if (mon_run_vec[kr].getSubRunNumber() <=1){
564 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
567 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
569 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
570 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
579 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
583 int xt_num=ecid_xt.
getID2();
606 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
610 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
621 for(
int iX=ixmin; iX<=ixmax ;++iX) {
622 for(
int iY=iymin; iY<=iymax; ++iY) {
638 pedtemp->
insert(std::make_pair(eedetidpos.
rawId(),item));
650 std::cout <<
"Ecal - > end of getNewObjectsH2 -----------\n";
661 std::ifstream fInput;
663 if(!fInput.is_open()) {
672 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
673 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
674 >> EBmean1[iChannel] >> EBrms1[iChannel];
675 if(hashedId != iChannel + 1) {
676 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
683 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
684 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
685 >> EEmean1[iChannel] >> EErms1[iChannel];
686 if(hashedId != iChannel + kEBChannels + 1) {
687 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
696 if(iEta==0)
continue;
703 item.
rms_x1 = EBrms1[hieb];
705 item.
rms_x6 = EBrms6[hieb];
715 for(
int iz = -1; iz < 2; iz = iz + 2) {
724 item.
rms_x1 = EErms1[hiee];
726 item.
rms_x6 = EErms6[hiee];
740 std::cout <<
"Ecal - > end of readPedestalFile -----------\n";
750 std::cout <<
"retrieved last payload " << std::endl;
753 if(iEta==0)
continue;
768 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
787 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
801 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
807 std::ifstream fInput;
809 if(!fInput.is_open()) {
818 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
819 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
820 >> EBmean1[iChannel] >> EBrms1[iChannel];
821 if(hashedId != iChannel + 1) {
822 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
829 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
830 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
831 >> EEmean1[iChannel] >> EErms1[iChannel];
832 if(hashedId != iChannel + kEBChannels + 1) {
833 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
842 if(iEta==0)
continue;
849 if(debug & (EBmean12[hieb] == -999. || EBrms12[hieb] == -999. || EBmean6[hieb] == -999. || EBrms6[hieb] == -999. ||
850 EBmean1[hieb] == -999. || EBrms1[hieb] == -999.))
851 std::cout <<
" bad EB channel eta " << iEta <<
" phi " << iPhi <<
" " << EBmean12[hieb] <<
" " << EBrms12[hieb]
852 <<
" " << EBmean6[hieb] <<
" " << EBrms6[hieb] <<
" " << EBmean1[hieb] <<
" " << EBrms1[hieb] << std::endl;
853 if(EBmean1[hieb] != -999.) item.
mean_x1 = EBmean1[hieb];
855 if(EBrms1[hieb] != -999.) item.
rms_x1 = EBrms1[hieb];
857 if(EBmean6[hieb] != -999.) item.
mean_x6 = EBmean6[hieb];
859 if(EBrms6[hieb] != -999.) item.
rms_x6 = EBrms6[hieb];
861 if(EBmean12[hieb] != -999.) item.
mean_x12 = EBmean12[hieb];
863 if(EBrms12[hieb] != -999.) item.
rms_x12 = EBrms12[hieb];
872 for(
int iz = -1; iz < 2; iz = iz + 2) {
881 if(debug & (EEmean12[hiee] == -999. || EErms12[hiee] == -999. || EEmean6[hiee] == -999. || EErms6[hiee] == -999. ||
882 EEmean1[hiee] == -999. || EErms1[hiee] == -999.))
883 std::cout <<
" bad EE channel x " << iX <<
" y " << iY <<
" z" << iz <<
" " << EEmean12[hiee] <<
" " << EErms12[hiee]
884 <<
" " <<EEmean6[hiee] <<
" " << EErms6[hiee] <<
" " << EEmean1[hiee] <<
" " << EErms1[hiee] << std::endl;
885 if(EEmean1[hiee] != -999.) item.
mean_x1 = EEmean1[hiee];
887 if(EErms1[hiee] != -999.) item.
rms_x1 = EErms1[hiee];
889 if(EEmean6[hiee] != -999.) item.
mean_x6 = EEmean6[hiee];
891 if(EErms6[hiee] != -999.) item.
rms_x6 = EErms6[hiee];
893 if(EEmean12[hiee] != -999.) item.
mean_x12 = EEmean12[hiee];
895 if(EErms12[hiee] != -999.) item.
rms_x12 = EErms12[hiee];
908 std::cout <<
"Ecal - > end of readPedestalFile -----------\n";
913 TFile * hfile =
new TFile(
m_filename.c_str());
915 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
916 int iChannel = 0, ix = 0, iy = 0, iz = 0;
917 treeChan->SetBranchAddress(
"Channels", &iChannel);
918 treeChan->SetBranchAddress(
"x", &ix);
919 treeChan->SetBranchAddress(
"y", &iy);
920 treeChan->SetBranchAddress(
"z", &iz);
921 int neventsChan = (
int)treeChan->GetEntries();
922 std::cout <<
"PedChan nb entries " << neventsChan << std::endl;
925 treeChan->GetEntry(
entry);
927 ringEB[iChannel] = (
abs(ix) -1)/5;
928 sideEB[iChannel] = 1;
929 if(ix < 0) sideEB[iChannel] = 0;
930 if(
entry%10000 == 0)
std::cout <<
" EB channel " << iChannel <<
" eta " << ix <<
" phi " << iy
931 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel] << std::endl;
937 if(
entry%1000 == 0)
std::cout <<
" EE channel " << iChannel <<
" x " << ixEE[iChannel] <<
" y " << iyEE[iChannel] <<
" z " << izEE[iChannel] << std::endl;
946 Int_t pedxml[
Nbpedxml] = {286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
947 299279, 299710, 300186, 300581, 301191, 302006, 302293, 302605, 303436, 303848,
948 304211, 304680, 305117, 305848, 306176};
949 Int_t run16Index = 0;
951 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];
953 TTree *
tree = (TTree*)hfile->Get(
"T");
955 tree->SetBranchAddress(
"id", &
id);
956 tree->SetBranchAddress(
"run", &run);
957 tree->SetBranchAddress(
"run_type", &run_type);
958 tree->SetBranchAddress(
"seq_id", &seq_id);
959 tree->SetBranchAddress(
"las_id", &las_id);
960 tree->SetBranchAddress(
"fill_num", &fill_num);
961 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
962 tree->SetBranchAddress(
"run_time", &run_time);
963 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
964 tree->SetBranchAddress(
"lumi", &lumi);
965 tree->SetBranchAddress(
"bfield", &bfield);
966 tree->SetBranchAddress(
"nxt", &nxt);
967 tree->SetBranchAddress(
"time", time);
968 tree->SetBranchAddress(
"fed", fed);
969 tree->SetBranchAddress(
"chan", chan);
970 tree->SetBranchAddress(
"ped", ped);
971 tree->SetBranchAddress(
"pedrms", pedrms);
972 int nevents = (
int)tree->GetEntries();
973 std::cout <<
" nb entries " << nevents << std::endl;
975 fout.open(
"copyTreePedestals.txt");
976 if(!fout.is_open()) {
977 std::cout <<
"ERROR : cannot open file copyTreePedestals.txt" << std::endl;
982 for(
int ich = 0; ich <
kChannels; ich++) {
988 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
989 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
990 for(
int ich = 0; ich <
kChannels; ich++) {
993 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
995 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
996 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1003 int firsttimeFED = -1;
1006 tree->GetEntry(
entry);
1007 if(run < first_run_kept) {
1008 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1009 <<
" before first wanted " <<
m_firstRun << std::endl;
1013 if(run_type != run_type_kept) {
1014 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1015 <<
" run type " << run_type << std::endl;
1018 if(nxt != kChannels) {
1019 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1020 <<
" *********** Number of channels " << nxt << std::endl;
1024 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1025 <<
" *********** bfield = " << bfield << std::endl;
1028 if(run_type_kept == 1) {
1030 for(
int ifed = 0; ifed < 54; ifed++) {
1031 if(time[ifed] < run_time_stablebeam) {
1033 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1034 <<
" *********** sequence before stable beam at " << run_time_stablebeam <<
" FED " << ifed <<
" : " << time[ifed];
1036 fout <<
" FED " << ifed <<
" : " << time[ifed];
1041 fout <<
" total nb " << time_seq << std::endl;
1051 for(
int ich = 0; ich <
kChannels; ich++) {
1052 if(ped[ich] < 300 && ped[ich] > 100) {
1053 EAmean12[ich] += ped[ich];
1054 EArms12[ich] += pedrms[ich];
1063 if(RunEntry == 0 || (run_type_kept == 2 && RunEntry < 6)) fout <<
" skiped run " << runold <<
" not enough entries : " << RunEntry << std::endl;
1065 fout <<
" entry "<<
entry -1 <<
" run " << runold <<
" nb of events " << RunEntry;
1066 firsttimeFED = time[0];
1067 for(
int ifed = 0; ifed < 54; ifed++) {
1068 fout <<
" " << time[ifed];
1069 if(firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1074 bool foundNew =
false;
1076 if(runold > pedxml[
i]) {
1077 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1080 if(runold < pedxml[i + 1])
break;
1084 int Indexxml = run16Index -1;
1085 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1087 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1088 if(!fxml.is_open()) {
1089 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1093 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1095 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1096 fxml >> mean12 >> rms12 >> bid;
1106 std::istringstream m6(stt);
1107 m6 >> EAmean6[iEBChannel];
1109 stt = bid.substr(8,15);
1110 std::istringstream r6(stt);
1111 r6 >> EArms6[iEBChannel];
1113 stt = bid.substr(9,15);
1114 std::istringstream m1(stt);
1115 m1 >> EAmean1[iEBChannel];
1117 stt = bid.substr(8,15);
1118 std::istringstream
r1(stt);
1119 r1 >> EArms1[iEBChannel];
1120 if(iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1121 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1122 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1123 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1125 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1126 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1128 fxml >> mean12 >> rms12 >> bid;
1130 std::istringstream m6(stt);
1133 stt = bid.substr(8,15);
1134 std::istringstream r6(stt);
1137 stt = bid.substr(9,15);
1138 std::istringstream m1(stt);
1141 stt = bid.substr(8,15);
1142 std::istringstream
r1(stt);
1144 if(iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1145 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1146 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1147 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1156 for(
int ich = 0; ich <
kChannels; ich++) {
1157 if(EAentry[ich] != 0) {
1158 EAmean12[ich] /= EAentry[ich];
1159 EArms12[ich] /= EAentry[ich];
1162 EAmean12[ich] = 200.;
1165 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1168 item.
rms_x1 = EArms1[ich];
1170 item.
rms_x6 = EArms6[ich];
1176 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1182 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1191 for(
int ich = 0; ich <
kChannels; ich++) {
1192 if(ped[ich] < 300 && ped[ich] > 100) {
1193 EAmean12[ich] = ped[ich];
1194 EArms12[ich] = pedrms[ich];
1206 fout <<
" last entry fill " << fill_num <<
" run " << runold <<
" nb of events " << RunEntry
1207 <<
" time " << run_time <<
" " << run_time_stablebeam <<
" " << time[0] <<
" run type " << run_type << std::endl;
1208 for(
int ifed = 0; ifed < 54; ifed++)
1209 fout <<
" " << time[ifed];
1213 for(
int ich = 0; ich <
kChannels; ich++) {
1214 if(EAentry[ich] != 0) {
1215 EAmean12[ich] /= EAentry[ich];
1216 EArms12[ich] /= EAentry[ich];
1219 EAmean12[ich] = 200.;
1222 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1227 item.
rms_x1 = EArms1[ich];
1229 item.
rms_x6 = EArms6[ich];
1235 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1241 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1246 std::cout <<
"Ecal - > end of readPedestalTree -----------\n";
1252 TFile * hfile =
new TFile(
m_filename.c_str());
1254 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
1255 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1256 treeChan->SetBranchAddress(
"Channels", &iChannel);
1257 treeChan->SetBranchAddress(
"x", &ix);
1258 treeChan->SetBranchAddress(
"y", &iy);
1259 treeChan->SetBranchAddress(
"z", &iz);
1260 int neventsChan = (
int)treeChan->GetEntries();
1261 std::cout <<
"PedChan nb entries " << neventsChan << std::endl;
1264 treeChan->GetEntry(
entry);
1266 ringEB[iChannel] = (
abs(ix) -1)/5;
1267 sideEB[iChannel] = 1;
1268 if(ix < 0) sideEB[iChannel] = 0;
1269 if(debug &&
entry%10000 == 0)
std::cout <<
" EB channel " << iChannel <<
" eta " << ix <<
" phi " << iy
1270 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel] << std::endl;
1273 ixEE[iChannel] = ix;
1274 iyEE[iChannel] = iy;
1275 izEE[iChannel] = iz;
1276 if(debug &&
entry%1000 == 0)
std::cout <<
" EE channel " << iChannel <<
" x " << ixEE[iChannel] <<
" y " 1277 << iyEE[iChannel] <<
" z " << izEE[iChannel] << std::endl;
1286 Int_t pedxml[
Nbpedxml] = {286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
1287 299279, 299710, 300186, 300581, 301191, 302006, 302293, 302605, 303436, 303848,
1288 304211, 304680, 305117, 305848, 306176};
1289 Int_t run16Index = 0;
1291 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];
1293 TTree *
tree = (TTree*)hfile->Get(
"T");
1295 tree->SetBranchAddress(
"id", &
id);
1296 tree->SetBranchAddress(
"run", &run);
1297 tree->SetBranchAddress(
"run_type", &run_type);
1298 tree->SetBranchAddress(
"seq_id", &seq_id);
1299 tree->SetBranchAddress(
"las_id", &las_id);
1300 tree->SetBranchAddress(
"fill_num", &fill_num);
1301 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1302 tree->SetBranchAddress(
"run_time", &run_time);
1303 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1304 tree->SetBranchAddress(
"lumi", &lumi);
1305 tree->SetBranchAddress(
"bfield", &bfield);
1306 tree->SetBranchAddress(
"nxt", &nxt);
1307 tree->SetBranchAddress(
"time", time);
1308 tree->SetBranchAddress(
"fed", fed);
1309 tree->SetBranchAddress(
"chan", chan);
1310 tree->SetBranchAddress(
"ped", ped);
1311 tree->SetBranchAddress(
"pedrms", pedrms);
1312 int nevents = (
int)tree->GetEntries();
1313 std::cout <<
" nb entries " << nevents << std::endl;
1315 fout.open(
"copyTimestampPedestals.txt");
1316 if(!fout.is_open()) {
1317 std::cout <<
"ERROR : cannot open file copyTimestampPedestals.txt" << std::endl;
1321 for(
int ich = 0; ich <
kChannels; ich++) {
1322 EAmean12[ich] = 200.;
1326 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
1327 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
1329 for(
int ich = 0; ich <
kChannels; ich++) {
1330 if(ped[ich] != 0.) {
1332 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1334 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
1335 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1340 int runold = -1, fillold = -1, firsttimeFEDold = -1;
1341 int firsttimeFED = -1;
1342 bool firstSeqBeforeStable =
false;
1346 tree->GetEntry(
entry);
1347 if(nxt != kChannels) {
1349 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1350 <<
" *********** Number of channels " << nxt;
1352 fout <<
" rejected" << std::endl;
1358 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1359 <<
" *********** laser wave length = " << las_id << std::endl;
1363 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1364 <<
" *********** bfield = " << bfield << std::endl;
1367 fout <<
" entry "<<
entry <<
" run " <<
run;
1368 if(run_type == 1) fout <<
" fill " << fill_num;
1369 fout <<
" sequence " << seq_id;
1371 fout <<
" stable " << run_time_stablebeam;
1372 if(run_time_stablebeam < first_run_kept) {
1373 fout <<
" before first wanted " <<
m_firstRun << std::endl;
1377 firsttimeFED = time[0];
1378 for(
int ifed = 0; ifed < 54; ifed++) {
1379 if(time[ifed] > firsttimeFEDold && firsttimeFED < time[ifed]) time[ifed] = firsttimeFED;
1381 if(firsttimeFED < first_run_kept) {
1382 fout <<
" time " << firsttimeFED <<
" before first wanted " <<
m_firstRun << std::endl;
1385 fout <<
" time " << firsttimeFED << std::endl;
1386 if(firsttimeFED <= firsttimeFEDold) {
1387 std::cout <<
" Problem finding the IOV : old one " << firsttimeFEDold <<
" new one " << firsttimeFED << std::endl;
1388 for(
int ifed = 0; ifed < 54; ifed++)
1390 std::cout << std::endl <<
" ignore this entry " << std::endl;
1393 firsttimeFEDold = firsttimeFED;
1396 if(fill_num != fillold) firstSeqBeforeStable =
false;
1398 if(run_time_stablebeam > 0) {
1399 if(firsttimeFED < run_time_stablebeam) {
1400 fout <<
" data taken before stable beam, skip it" << std::endl;
1401 firstSeqBeforeStable =
true;
1408 fout <<
" *** entry " <<
entry <<
" run_time_stablebeam " << run_time_stablebeam << std::endl;
1409 if(firstSeqBeforeStable) {
1410 firstSeqBeforeStable =
false;
1411 firsttimeFED = run_time_stablebeam;
1412 fout <<
" first full sequence after stable; change the IOV " << firsttimeFED << std::endl;
1416 for(
int ich = 0; ich <
kChannels; ich++) {
1417 if(ped[ich] < 300 && ped[ich] > 100) {
1418 EAmean12[ich] = ped[ich];
1419 EArms12[ich] = pedrms[ich];
1423 bool foundNew =
false;
1426 if(run > pedxml[
i]) {
1427 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1431 if(run < pedxml[i + 1])
break;
1435 int Indexxml = run16Index -1;
1436 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1438 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1439 if(!fxml.is_open()) {
1440 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1444 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1446 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1447 fxml >> mean12 >> rms12 >> bid;
1449 std::istringstream m6(stt);
1450 m6 >> EAmean6[iEBChannel];
1452 stt = bid.substr(8,15);
1453 std::istringstream r6(stt);
1454 r6 >> EArms6[iEBChannel];
1456 stt = bid.substr(9,15);
1457 std::istringstream m1(stt);
1458 m1 >> EAmean1[iEBChannel];
1460 stt = bid.substr(8,15);
1461 std::istringstream
r1(stt);
1462 r1 >> EArms1[iEBChannel];
1463 if(debug && iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1464 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1465 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1466 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1468 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1469 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1471 fxml >> mean12 >> rms12 >> bid;
1473 std::istringstream m6(stt);
1476 stt = bid.substr(8,15);
1477 std::istringstream r6(stt);
1480 stt = bid.substr(9,15);
1481 std::istringstream m1(stt);
1484 stt = bid.substr(8,15);
1485 std::istringstream
r1(stt);
1487 if(debug && iEEChannel%1000 == 0)
1488 fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1489 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1490 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1491 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1499 for(
int ich = 0; ich <
kChannels; ich++) {
1500 if(debug && ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1503 item.
rms_x1 = EArms1[ich];
1505 item.
rms_x6 = EArms6[ich];
1511 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1517 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1523 fout <<
" entry " <<
entry <<
" transfer " << transfer <<
" iov " << iov << std::endl;
1525 fout <<
" m_to_transfer " << firsttimeFED << std::endl;
1530 std::cout <<
"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
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
static bool validDetId(int i, int j)
check if a valid index combination
void setRunTag(const RunTag &tag)
uint32_t rawId() const
get the raw id
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)
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