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;
41 std::cout <<
"------- Ecal - > getNewObjects\n";
79 std::ostringstream ss;
82 unsigned int max_since=0;
84 std::cout <<
"max_since : " << max_since << std::endl;
89 std::cout <<
"retrieved last payload " << std::endl;
109 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
134 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
152 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
159 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
161 std::cout <<
"Connection done" << std::endl;
189 unsigned int min_run=0;
199 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
200 int mon_runs = mon_run_vec.size();
201 std::cout <<
"number of Mon runs is : "<< mon_runs<< std::endl;
205 for(
int kr = 0; kr < krmax; kr++){
206 std::cout <<
"-kr------: "<<kr<<std::endl;
208 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
209 std::cout <<
"retrieve the data for run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
210 if (mon_run_vec[kr].getSubRunNumber() <=1){
213 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
215 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
217 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
218 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
219 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
225 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
228 int sm_num=ecid_xt.
getID1();
229 int xt_num=ecid_xt.
getID2();
230 int yt_num=ecid_xt.
getID3();
243 if(ecid_xt.
getName()==
"EB_crystal_number") {
256 if(nbad < 10)
std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/"<< yt_num
284 if(nbad<(dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
286 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
289 int sm_num=ecid_xt.
getID1();
290 int xt_num=ecid_xt.
getID2();
291 int yt_num=ecid_xt.
getID3();
301 if(ecid_xt.
getName()==
"EB_crystal_number") {
324 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
330 EEDetId eedetid(xt_num,yt_num,sm_num);
350 peds->
insert(std::make_pair(eedetid.
rawId(),item));
355 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
363 if(iEta==0)
continue;
380 pedtemp->
insert(std::make_pair(ebdetid.
rawId(),item));
381 if((iEta==-1 || iEta==1) && iPhi==20){
383 std::cout<<
"channel:" <<iEta<<
"/"<<iPhi<<
"/" << hiee <<
" ped mean 12="<< x << std::endl;
405 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
420 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
428 ss <<
"Run=" << irun <<
"_WAS_GOOD_"<<std::endl;
432 std::cout <<
"Run " << irun <<
" was BAD !!!! not sent to the DB";
433 if(nbad >= (dataset_mon.size()*0.05))
434 std::cout <<
" number of bad channels = " << nbad;
436 std::cout <<
" number of EB channels = " << nEB;
438 std::cout <<
" number of EE channels = " << nEE;
440 ss <<
"Run=" << irun <<
"_WAS_BAD_"<<std::endl;
449 std::cout <<
"Ecal - > end of getNewObjects -----------\n";
454 unsigned int max_since=0;
456 std::cout <<
"max_since : " << max_since << std::endl;
459 std::cout <<
"retrieved last payload " << std::endl;
473 int ixmin=86;
int ixmax=95;
474 int iymin=46;
int iymax=55;
475 for(
int iX=ixmin; iX<=ixmax ;++iX) {
476 for(
int iY=iymin; iY<=iymax; ++iY) {
491 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
499 std::cout <<
"WOW: we just retrieved the last valid record from DB "<< std::endl;
504 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
506 std::cout <<
"Making connection..." << std::flush;
541 unsigned int min_run=max_since+1;
546 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
547 size_t mon_runs=mon_run_vec.size();
548 std::cout <<
"number of Mon runs is : "<< mon_runs<< std::endl;
552 for(
size_t kr=0; kr<mon_runs; kr++){
554 unsigned int irun=
static_cast<unsigned int>(mon_run_vec[kr].getRunIOV().getRunNumber());
556 std::cout <<
"here is first sub run : "<< mon_run_vec[kr].getSubRunNumber() << std::endl;
557 std::cout <<
"here is the run number: "<< mon_run_vec[kr].getRunIOV().getRunNumber() << std::endl;
559 std::cout <<
" retrieve the data for a given run"<< std::endl;
561 if (mon_run_vec[kr].getSubRunNumber() <=1){
565 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
568 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
570 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
571 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
580 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
584 int xt_num=ecid_xt.
getID2();
607 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
611 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
622 for(
int iX=ixmin; iX<=ixmax ;++iX) {
623 for(
int iY=iymin; iY<=iymax; ++iY) {
639 pedtemp->
insert(std::make_pair(eedetidpos.
rawId(),item));
651 std::cout <<
"Ecal - > end of getNewObjectsH2 -----------\n";
662 std::ifstream fInput;
664 if(!fInput.is_open()) {
673 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
674 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
675 >> EBmean1[iChannel] >> EBrms1[iChannel];
676 if(hashedId != iChannel + 1) {
677 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
684 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
685 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
686 >> EEmean1[iChannel] >> EErms1[iChannel];
687 if(hashedId != iChannel + kEBChannels + 1) {
688 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
697 if(iEta==0)
continue;
704 item.
rms_x1 = EBrms1[hieb];
706 item.
rms_x6 = EBrms6[hieb];
716 for(
int iz = -1; iz < 2; iz = iz + 2) {
725 item.
rms_x1 = EErms1[hiee];
727 item.
rms_x6 = EErms6[hiee];
741 std::cout <<
"Ecal - > end of readPedestalFile -----------\n";
751 std::cout <<
"retrieved last payload " << std::endl;
754 if(iEta==0)
continue;
769 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
788 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
802 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
808 std::ifstream fInput;
810 if(!fInput.is_open()) {
819 for (
int iChannel = 0; iChannel <
kEBChannels; iChannel++) {
820 fInput >> hashedId >> EBmean12[iChannel] >> EBrms12[iChannel] >> EBmean6[iChannel] >> EBrms6[iChannel]
821 >> EBmean1[iChannel] >> EBrms1[iChannel];
822 if(hashedId != iChannel + 1) {
823 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
830 for (
int iChannel = 0; iChannel <
kEEChannels; iChannel++) {
831 fInput >> hashedId >> EEmean12[iChannel] >> EErms12[iChannel] >> EEmean6[iChannel] >> EErms6[iChannel]
832 >> EEmean1[iChannel] >> EErms1[iChannel];
833 if(hashedId != iChannel + kEBChannels + 1) {
834 std::cout <<
m_filename <<
" strange hash " << hashedId <<
" while iChannel " << iChannel << std::endl;
843 if(iEta==0)
continue;
850 if(debug & (EBmean12[hieb] == -999. || EBrms12[hieb] == -999. || EBmean6[hieb] == -999. || EBrms6[hieb] == -999. ||
851 EBmean1[hieb] == -999. || EBrms1[hieb] == -999.))
852 std::cout <<
" bad EB channel eta " << iEta <<
" phi " << iPhi <<
" " << EBmean12[hieb] <<
" " << EBrms12[hieb]
853 <<
" " << EBmean6[hieb] <<
" " << EBrms6[hieb] <<
" " << EBmean1[hieb] <<
" " << EBrms1[hieb] << std::endl;
854 if(EBmean1[hieb] != -999.) item.
mean_x1 = EBmean1[hieb];
856 if(EBrms1[hieb] != -999.) item.
rms_x1 = EBrms1[hieb];
858 if(EBmean6[hieb] != -999.) item.
mean_x6 = EBmean6[hieb];
860 if(EBrms6[hieb] != -999.) item.
rms_x6 = EBrms6[hieb];
862 if(EBmean12[hieb] != -999.) item.
mean_x12 = EBmean12[hieb];
864 if(EBrms12[hieb] != -999.) item.
rms_x12 = EBrms12[hieb];
873 for(
int iz = -1; iz < 2; iz = iz + 2) {
882 if(debug & (EEmean12[hiee] == -999. || EErms12[hiee] == -999. || EEmean6[hiee] == -999. || EErms6[hiee] == -999. ||
883 EEmean1[hiee] == -999. || EErms1[hiee] == -999.))
884 std::cout <<
" bad EE channel x " << iX <<
" y " << iY <<
" z" << iz <<
" " << EEmean12[hiee] <<
" " << EErms12[hiee]
885 <<
" " <<EEmean6[hiee] <<
" " << EErms6[hiee] <<
" " << EEmean1[hiee] <<
" " << EErms1[hiee] << std::endl;
886 if(EEmean1[hiee] != -999.) item.
mean_x1 = EEmean1[hiee];
888 if(EErms1[hiee] != -999.) item.
rms_x1 = EErms1[hiee];
890 if(EEmean6[hiee] != -999.) item.
mean_x6 = EEmean6[hiee];
892 if(EErms6[hiee] != -999.) item.
rms_x6 = EErms6[hiee];
894 if(EEmean12[hiee] != -999.) item.
mean_x12 = EEmean12[hiee];
896 if(EErms12[hiee] != -999.) item.
rms_x12 = EErms12[hiee];
909 std::cout <<
"Ecal - > end of readPedestalFile -----------\n";
914 TFile * hfile =
new TFile(
m_filename.c_str());
916 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
917 int iChannel = 0, ix = 0, iy = 0, iz = 0;
918 treeChan->SetBranchAddress(
"Channels", &iChannel);
919 treeChan->SetBranchAddress(
"x", &ix);
920 treeChan->SetBranchAddress(
"y", &iy);
921 treeChan->SetBranchAddress(
"z", &iz);
922 int neventsChan = (
int)treeChan->GetEntries();
923 std::cout <<
"PedChan nb entries " << neventsChan << std::endl;
926 treeChan->GetEntry(
entry);
928 ringEB[iChannel] = (
abs(ix) -1)/5;
929 sideEB[iChannel] = 1;
930 if(ix < 0) sideEB[iChannel] = 0;
931 if(
entry%10000 == 0)
std::cout <<
" EB channel " << iChannel <<
" eta " << ix <<
" phi " << iy
932 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel] << std::endl;
938 if(
entry%1000 == 0)
std::cout <<
" EE channel " << iChannel <<
" x " << ixEE[iChannel] <<
" y " << iyEE[iChannel] <<
" z " << izEE[iChannel] << std::endl;
948 Int_t pedxml[
Nbpedxml] = {286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
949 299279, 299710, 300186, 300581, 301191, 302006, 302293};
950 Int_t run16Index = 0;
952 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];
954 TTree *
tree = (TTree*)hfile->Get(
"T");
956 tree->SetBranchAddress(
"id", &
id);
957 tree->SetBranchAddress(
"run", &run);
958 tree->SetBranchAddress(
"run_type", &run_type);
959 tree->SetBranchAddress(
"seq_id", &seq_id);
960 tree->SetBranchAddress(
"las_id", &las_id);
961 tree->SetBranchAddress(
"fill_num", &fill_num);
962 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
963 tree->SetBranchAddress(
"run_time", &run_time);
964 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
965 tree->SetBranchAddress(
"lumi", &lumi);
966 tree->SetBranchAddress(
"bfield", &bfield);
967 tree->SetBranchAddress(
"nxt", &nxt);
968 tree->SetBranchAddress(
"time", time);
969 tree->SetBranchAddress(
"fed", fed);
970 tree->SetBranchAddress(
"chan", chan);
971 tree->SetBranchAddress(
"ped", ped);
972 tree->SetBranchAddress(
"pedrms", pedrms);
973 int nevents = (
int)tree->GetEntries();
974 std::cout <<
" nb entries " << nevents << std::endl;
976 fout.open(
"copyTreePedestals.txt");
977 if(!fout.is_open()) {
978 std::cout <<
"ERROR : cannot open file copyTreePedestals.txt" << std::endl;
983 for(
int ich = 0; ich <
kChannels; ich++) {
989 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
990 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
991 for(
int ich = 0; ich <
kChannels; ich++) {
994 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
996 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
997 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1004 int firsttimeFED = -1;
1007 tree->GetEntry(
entry);
1008 if(run < first_run_kept) {
1009 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1010 <<
" before first wanted " <<
m_firstRun << std::endl;
1014 if(run_type != run_type_kept) {
1015 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1016 <<
" run type " << run_type << std::endl;
1019 if(nxt != kChannels) {
1020 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1021 <<
" *********** Number of channels " << nxt << std::endl;
1025 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1026 <<
" *********** bfield = " << bfield << std::endl;
1029 if(run_type_kept == 1) {
1031 for(
int ifed = 0; ifed < 54; ifed++) {
1032 if(time[ifed] < run_time_stablebeam) {
1034 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1035 <<
" *********** sequence before stable beam at " << run_time_stablebeam <<
" FED " << ifed <<
" : " << time[ifed];
1037 fout <<
" FED " << ifed <<
" : " << time[ifed];
1042 fout <<
" total nb " << time_seq << std::endl;
1052 for(
int ich = 0; ich <
kChannels; ich++) {
1053 if(ped[ich] < 300 && ped[ich] > 100) {
1054 EAmean12[ich] += ped[ich];
1055 EArms12[ich] += pedrms[ich];
1064 if(RunEntry == 0 || (run_type_kept == 2 && RunEntry < 6)) fout <<
" skiped run " << runold <<
" not enough entries : " << RunEntry << std::endl;
1066 fout <<
" entry "<<
entry -1 <<
" run " << runold <<
" nb of events " << RunEntry;
1067 firsttimeFED = time[0];
1068 for(
int ifed = 0; ifed < 54; ifed++) {
1069 fout <<
" " << time[ifed];
1070 if(firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1075 bool foundNew =
false;
1077 if(runold > pedxml[
i]) {
1078 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1081 if(runold < pedxml[i + 1])
break;
1085 int Indexxml = run16Index -1;
1086 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1088 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1089 if(!fxml.is_open()) {
1090 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1094 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1096 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1097 fxml >> mean12 >> rms12 >> bid;
1107 std::istringstream m6(stt);
1108 m6 >> EAmean6[iEBChannel];
1110 stt = bid.substr(8,15);
1111 std::istringstream r6(stt);
1112 r6 >> EArms6[iEBChannel];
1114 stt = bid.substr(9,15);
1115 std::istringstream m1(stt);
1116 m1 >> EAmean1[iEBChannel];
1118 stt = bid.substr(8,15);
1119 std::istringstream
r1(stt);
1120 r1 >> EArms1[iEBChannel];
1121 if(iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1122 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1123 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1124 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1126 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1127 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1129 fxml >> mean12 >> rms12 >> bid;
1131 std::istringstream m6(stt);
1134 stt = bid.substr(8,15);
1135 std::istringstream r6(stt);
1138 stt = bid.substr(9,15);
1139 std::istringstream m1(stt);
1142 stt = bid.substr(8,15);
1143 std::istringstream
r1(stt);
1145 if(iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1146 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1147 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1148 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1157 for(
int ich = 0; ich <
kChannels; ich++) {
1158 if(EAentry[ich] != 0) {
1159 EAmean12[ich] /= EAentry[ich];
1160 EArms12[ich] /= EAentry[ich];
1163 EAmean12[ich] = 200.;
1166 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1169 item.
rms_x1 = EArms1[ich];
1171 item.
rms_x6 = EArms6[ich];
1177 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1183 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1192 for(
int ich = 0; ich <
kChannels; ich++) {
1193 if(ped[ich] < 300 && ped[ich] > 100) {
1194 EAmean12[ich] = ped[ich];
1195 EArms12[ich] = pedrms[ich];
1207 fout <<
" last entry fill " << fill_num <<
" run " << runold <<
" nb of events " << RunEntry
1208 <<
" time " << run_time <<
" " << run_time_stablebeam <<
" " << time[0] <<
" run type " << run_type << std::endl;
1209 for(
int ifed = 0; ifed < 54; ifed++)
1210 fout <<
" " << time[ifed];
1214 for(
int ich = 0; ich <
kChannels; ich++) {
1215 if(EAentry[ich] != 0) {
1216 EAmean12[ich] /= EAentry[ich];
1217 EArms12[ich] /= EAentry[ich];
1220 EAmean12[ich] = 200.;
1223 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1228 item.
rms_x1 = EArms1[ich];
1230 item.
rms_x6 = EArms6[ich];
1236 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1242 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1247 std::cout <<
"Ecal - > end of readPedestalTree -----------\n";
1253 TFile * hfile =
new TFile(
m_filename.c_str());
1255 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
1256 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1257 treeChan->SetBranchAddress(
"Channels", &iChannel);
1258 treeChan->SetBranchAddress(
"x", &ix);
1259 treeChan->SetBranchAddress(
"y", &iy);
1260 treeChan->SetBranchAddress(
"z", &iz);
1261 int neventsChan = (
int)treeChan->GetEntries();
1262 std::cout <<
"PedChan nb entries " << neventsChan << std::endl;
1265 treeChan->GetEntry(
entry);
1267 ringEB[iChannel] = (
abs(ix) -1)/5;
1268 sideEB[iChannel] = 1;
1269 if(ix < 0) sideEB[iChannel] = 0;
1270 if(debug &&
entry%10000 == 0)
std::cout <<
" EB channel " << iChannel <<
" eta " << ix <<
" phi " << iy
1271 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel] << std::endl;
1274 ixEE[iChannel] = ix;
1275 iyEE[iChannel] = iy;
1276 izEE[iChannel] = iz;
1277 if(debug &&
entry%1000 == 0)
std::cout <<
" EE channel " << iChannel <<
" x " << ixEE[iChannel] <<
" y " 1278 << iyEE[iChannel] <<
" z " << izEE[iChannel] << std::endl;
1288 Int_t pedxml[
Nbpedxml] = {286535, 293513, 293632, 293732, 295507, 295672, 296391, 296917, 297388, 298481,
1289 299279, 299710, 300186, 300581, 301191, 302006, 302293};
1290 Int_t run16Index = 0;
1292 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];
1294 TTree *
tree = (TTree*)hfile->Get(
"T");
1296 tree->SetBranchAddress(
"id", &
id);
1297 tree->SetBranchAddress(
"run", &run);
1298 tree->SetBranchAddress(
"run_type", &run_type);
1299 tree->SetBranchAddress(
"seq_id", &seq_id);
1300 tree->SetBranchAddress(
"las_id", &las_id);
1301 tree->SetBranchAddress(
"fill_num", &fill_num);
1302 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1303 tree->SetBranchAddress(
"run_time", &run_time);
1304 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1305 tree->SetBranchAddress(
"lumi", &lumi);
1306 tree->SetBranchAddress(
"bfield", &bfield);
1307 tree->SetBranchAddress(
"nxt", &nxt);
1308 tree->SetBranchAddress(
"time", time);
1309 tree->SetBranchAddress(
"fed", fed);
1310 tree->SetBranchAddress(
"chan", chan);
1311 tree->SetBranchAddress(
"ped", ped);
1312 tree->SetBranchAddress(
"pedrms", pedrms);
1313 int nevents = (
int)tree->GetEntries();
1314 std::cout <<
" nb entries " << nevents << std::endl;
1316 fout.open(
"copyTimestampPedestals.txt");
1317 if(!fout.is_open()) {
1318 std::cout <<
"ERROR : cannot open file copyTimestampPedestals.txt" << std::endl;
1322 for(
int ich = 0; ich <
kChannels; ich++) {
1323 EAmean12[ich] = 200.;
1327 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
1328 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
1330 for(
int ich = 0; ich <
kChannels; ich++) {
1331 if(ped[ich] != 0.) {
1333 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1335 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
1336 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1341 int runold = -1, fillold = -1, firsttimeFEDold = -1;
1342 int firsttimeFED = -1;
1343 bool firstSeqAfterStable =
false;
1347 tree->GetEntry(
entry);
1348 if(nxt != kChannels) {
1350 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1351 <<
" *********** Number of channels " << nxt;
1353 fout <<
" rejected" << std::endl;
1359 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1360 <<
" *********** laser wave length = " << las_id << std::endl;
1365 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1366 <<
" *********** bfield = " << bfield << std::endl;
1369 fout <<
" entry "<<
entry <<
" run " << run <<
" 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++) {
1380 if(time[ifed] > firsttimeFEDold && firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1382 if(firsttimeFED < first_run_kept) {
1383 fout <<
" time " << firsttimeFED <<
" before first wanted " <<
m_firstRun << std::endl;
1386 fout <<
" time " << firsttimeFED << std::endl;
1387 if(firsttimeFED <= firsttimeFEDold) {
1388 std::cout <<
" Problem finding the IOV : old one " << firsttimeFEDold <<
" new one " << firsttimeFED << std::endl;
1389 for(
int ifed = 0; ifed < 54; ifed++)
1391 std::cout << std::endl <<
" ignore this entry " << std::endl;
1394 firsttimeFEDold = firsttimeFED;
1397 if(fill_num != fillold) firstSeqAfterStable =
false;
1399 if(run_time_stablebeam > 0) {
1400 if(firsttimeFED > run_time_stablebeam) {
1401 if(!firstSeqAfterStable) {
1402 firstSeqAfterStable =
true;
1403 firsttimeFED = run_time_stablebeam;
1404 fout <<
" first sequence after stable; change the IOV " << firsttimeFED << std::endl;
1409 fout <<
" *** entry " <<
entry <<
" run_time_stablebeam " << run_time_stablebeam << std::endl;
1412 for(
int ich = 0; ich <
kChannels; ich++) {
1413 if(ped[ich] < 300 && ped[ich] > 100) {
1414 EAmean12[ich] = ped[ich];
1415 EArms12[ich] = pedrms[ich];
1419 bool foundNew =
false;
1422 if(run > pedxml[
i]) {
1423 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1427 if(run < pedxml[i + 1])
break;
1431 int Indexxml = run16Index -1;
1432 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1434 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1435 if(!fxml.is_open()) {
1436 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1440 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1442 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1443 fxml >> mean12 >> rms12 >> bid;
1445 std::istringstream m6(stt);
1446 m6 >> EAmean6[iEBChannel];
1448 stt = bid.substr(8,15);
1449 std::istringstream r6(stt);
1450 r6 >> EArms6[iEBChannel];
1452 stt = bid.substr(9,15);
1453 std::istringstream m1(stt);
1454 m1 >> EAmean1[iEBChannel];
1456 stt = bid.substr(8,15);
1457 std::istringstream
r1(stt);
1458 r1 >> EArms1[iEBChannel];
1459 if(debug && iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1460 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1461 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1462 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1464 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1465 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1467 fxml >> mean12 >> rms12 >> bid;
1469 std::istringstream m6(stt);
1472 stt = bid.substr(8,15);
1473 std::istringstream r6(stt);
1476 stt = bid.substr(9,15);
1477 std::istringstream m1(stt);
1480 stt = bid.substr(8,15);
1481 std::istringstream
r1(stt);
1483 if(debug && iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1484 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1485 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1486 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1494 for(
int ich = 0; ich <
kChannels; ich++) {
1495 if(debug && ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1498 item.
rms_x1 = EArms1[ich];
1500 item.
rms_x6 = EArms6[ich];
1506 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1512 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1518 fout <<
" entry " <<
entry <<
" transfer " << transfer <<
" iov " << iov << std::endl;
1520 fout <<
" m_to_transfer " << firsttimeFED << std::endl;
1525 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