16 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalPedestalsHandler")) {
18 std::cout <<
"EcalPedestals Source handler constructor\n" << std::endl;
31 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;
940 Int_t pedxml[26] = {271948, 273634, 273931, 274705, 275403, 276108, 276510, 277169, 278123, 278183,
941 278246, 278389, 278499, 278693, 278858, 278888, 278931, 279728, 280129, 280263,
942 280941, 281753, 282631, 282833, 283199, 283766};
943 Int_t run16Index = 0;
945 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];
947 TTree *
tree = (TTree*)hfile->Get(
"T");
949 tree->SetBranchAddress(
"id", &
id);
950 tree->SetBranchAddress(
"run", &run);
951 tree->SetBranchAddress(
"run_type", &run_type);
952 tree->SetBranchAddress(
"seq_id", &seq_id);
953 tree->SetBranchAddress(
"las_id", &las_id);
954 tree->SetBranchAddress(
"fill_num", &fill_num);
955 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
956 tree->SetBranchAddress(
"run_time", &run_time);
957 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
958 tree->SetBranchAddress(
"lumi", &lumi);
959 tree->SetBranchAddress(
"bfield", &bfield);
960 tree->SetBranchAddress(
"nxt", &nxt);
961 tree->SetBranchAddress(
"time", time);
962 tree->SetBranchAddress(
"fed", fed);
963 tree->SetBranchAddress(
"chan", chan);
964 tree->SetBranchAddress(
"ped", ped);
965 tree->SetBranchAddress(
"pedrms", pedrms);
966 int nevents = (
int)tree->GetEntries();
967 std::cout <<
" nb entries " << nevents << std::endl;
969 fout.open(
"copyTreePedestals.txt");
970 if(!fout.is_open()) {
971 std::cout <<
"ERROR : cannot open file copyTreePedestals.txt" << std::endl;
976 for(
int ich = 0; ich <
kChannels; ich++) {
982 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
983 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
984 for(
int ich = 0; ich <
kChannels; ich++) {
987 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
989 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
990 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
997 int firsttimeFED = -1;
1000 tree->GetEntry(
entry);
1001 if(run < first_run_kept) {
1005 if(run_type != run_type_kept)
continue;
1006 if(nxt != kChannels) {
1007 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1008 <<
" *********** Number of channels " << nxt << std::endl;
1012 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1013 <<
" *********** bfield = " << bfield << std::endl;
1016 if(run_type_kept == 1) {
1018 for(
int ifed = 0; ifed < 54; ifed++) {
1019 if(time[ifed] < run_time_stablebeam) {
1021 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1022 <<
" *********** sequence before stable beam at " << run_time_stablebeam <<
" FED " << ifed <<
" : " << time[ifed];
1024 fout <<
" FED " << ifed <<
" : " << time[ifed];
1029 fout <<
" total nb " << time_seq << std::endl;
1039 for(
int ich = 0; ich <
kChannels; ich++) {
1040 if(ped[ich] < 300 && ped[ich] > 100) {
1041 EAmean12[ich] += ped[ich];
1042 EArms12[ich] += pedrms[ich];
1051 if(RunEntry == 0 || (run_type_kept == 2 && RunEntry < 6)) fout <<
" skiped run " << runold <<
" not enough entries : " << RunEntry << std::endl;
1053 fout <<
" entry "<<
entry -1 <<
" run " << runold <<
" nb of events " << RunEntry;
1054 firsttimeFED = time[0];
1055 for(
int ifed = 0; ifed < 54; ifed++) {
1056 fout <<
" " << time[ifed];
1057 if(firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1062 bool foundNew =
false;
1063 for(
int i = run16Index;
i < 26;
i++) {
1064 if(runold > pedxml[
i]) {
1065 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1068 if(runold < pedxml[i + 1])
break;
1072 int Indexxml = run16Index -1;
1073 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1075 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1076 if(!fxml.is_open()) {
1077 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1081 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1083 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1084 fxml >> mean12 >> rms12 >> bid;
1094 std::istringstream m6(stt);
1095 m6 >> EAmean6[iEBChannel];
1097 stt = bid.substr(8,15);
1098 std::istringstream r6(stt);
1099 r6 >> EArms6[iEBChannel];
1101 stt = bid.substr(9,15);
1102 std::istringstream m1(stt);
1103 m1 >> EAmean1[iEBChannel];
1105 stt = bid.substr(8,15);
1106 std::istringstream
r1(stt);
1107 r1 >> EArms1[iEBChannel];
1108 if(iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1109 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1110 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1111 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1113 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1114 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1116 fxml >> mean12 >> rms12 >> bid;
1118 std::istringstream m6(stt);
1121 stt = bid.substr(8,15);
1122 std::istringstream r6(stt);
1125 stt = bid.substr(9,15);
1126 std::istringstream m1(stt);
1129 stt = bid.substr(8,15);
1130 std::istringstream
r1(stt);
1132 if(iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1133 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1134 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1135 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1144 for(
int ich = 0; ich <
kChannels; ich++) {
1145 if(EAentry[ich] != 0) {
1146 EAmean12[ich] /= EAentry[ich];
1147 EArms12[ich] /= EAentry[ich];
1150 EAmean12[ich] = 200.;
1153 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1156 item.
rms_x1 = EArms1[ich];
1158 item.
rms_x6 = EArms6[ich];
1164 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1170 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1179 for(
int ich = 0; ich <
kChannels; ich++) {
1180 if(ped[ich] < 300 && ped[ich] > 100) {
1181 EAmean12[ich] = ped[ich];
1182 EArms12[ich] = pedrms[ich];
1194 fout <<
" last entry fill " << fill_num <<
" run " << runold <<
" nb of events " << RunEntry
1195 <<
" time " << run_time <<
" " << run_time_stablebeam <<
" " << time[0] <<
" run type " << run_type << std::endl;
1196 for(
int ifed = 0; ifed < 54; ifed++)
1197 fout <<
" " << time[ifed];
1201 for(
int ich = 0; ich <
kChannels; ich++) {
1202 if(EAentry[ich] != 0) {
1203 EAmean12[ich] /= EAentry[ich];
1204 EArms12[ich] /= EAentry[ich];
1207 EAmean12[ich] = 200.;
1210 if(ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1215 item.
rms_x1 = EArms1[ich];
1217 item.
rms_x6 = EArms6[ich];
1223 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1229 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1234 std::cout <<
"Ecal - > end of readPedestalTree -----------\n";
1240 TFile * hfile =
new TFile(
m_filename.c_str());
1242 TTree *treeChan = (TTree*)hfile->Get(
"PedChan");
1243 int iChannel = 0, ix = 0, iy = 0, iz = 0;
1244 treeChan->SetBranchAddress(
"Channels", &iChannel);
1245 treeChan->SetBranchAddress(
"x", &ix);
1246 treeChan->SetBranchAddress(
"y", &iy);
1247 treeChan->SetBranchAddress(
"z", &iz);
1248 int neventsChan = (
int)treeChan->GetEntries();
1249 std::cout <<
"PedChan nb entries " << neventsChan << std::endl;
1252 treeChan->GetEntry(
entry);
1254 ringEB[iChannel] = (
abs(ix) -1)/5;
1255 sideEB[iChannel] = 1;
1256 if(ix < 0) sideEB[iChannel] = 0;
1257 if(debug &&
entry%10000 == 0)
std::cout <<
" EB channel " << iChannel <<
" eta " << ix <<
" phi " << iy
1258 <<
" side " << sideEB[iChannel] <<
" ring " << ringEB[iChannel] << std::endl;
1261 ixEE[iChannel] = ix;
1262 iyEE[iChannel] = iy;
1263 izEE[iChannel] = iz;
1264 if(debug &&
entry%1000 == 0)
std::cout <<
" EE channel " << iChannel <<
" x " << ixEE[iChannel] <<
" y " 1265 << iyEE[iChannel] <<
" z " << izEE[iChannel] << std::endl;
1268 Int_t pedxml[26] = {271948, 273634, 273931, 274705, 275403, 276108, 276510, 277169, 278123, 278183,
1269 278246, 278389, 278499, 278693, 278858, 278888, 278931, 279728, 280129, 280263,
1270 280941, 281753, 282631, 282833, 283199, 283766};
1271 Int_t run16Index = 0;
1273 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];
1275 TTree *
tree = (TTree*)hfile->Get(
"T");
1277 tree->SetBranchAddress(
"id", &
id);
1278 tree->SetBranchAddress(
"run", &run);
1279 tree->SetBranchAddress(
"run_type", &run_type);
1280 tree->SetBranchAddress(
"seq_id", &seq_id);
1281 tree->SetBranchAddress(
"las_id", &las_id);
1282 tree->SetBranchAddress(
"fill_num", &fill_num);
1283 tree->SetBranchAddress(
"run_num_infill", &run_num_infill);
1284 tree->SetBranchAddress(
"run_time", &run_time);
1285 tree->SetBranchAddress(
"run_time_stablebeam", &run_time_stablebeam);
1286 tree->SetBranchAddress(
"lumi", &lumi);
1287 tree->SetBranchAddress(
"bfield", &bfield);
1288 tree->SetBranchAddress(
"nxt", &nxt);
1289 tree->SetBranchAddress(
"time", time);
1290 tree->SetBranchAddress(
"fed", fed);
1291 tree->SetBranchAddress(
"chan", chan);
1292 tree->SetBranchAddress(
"ped", ped);
1293 tree->SetBranchAddress(
"pedrms", pedrms);
1294 int nevents = (
int)tree->GetEntries();
1295 std::cout <<
" nb entries " << nevents << std::endl;
1297 fout.open(
"copyTimestampPedestals.txt");
1298 if(!fout.is_open()) {
1299 std::cout <<
"ERROR : cannot open file copyTimestampPedestals.txt" << std::endl;
1303 for(
int ich = 0; ich <
kChannels; ich++) {
1304 EAmean12[ich] = 200.;
1308 fout <<
" first run " << run <<
" fill " << fill_num <<
" B field " << bfield <<
" run type " << run_type <<
" seq_id " << seq_id
1309 <<
" las_id " << las_id <<
" run_num_infill " << run_num_infill <<
" lumi "<< lumi <<
" nb of Crystals " << nxt << std::endl;
1311 for(
int ich = 0; ich <
kChannels; ich++) {
1312 if(ped[ich] != 0.) {
1314 fout <<
" channel " << ich <<
" FED " << fed[ich] <<
" chan " << chan[ich] <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1316 fout <<
" channel " << ich <<
" EE channel " << ich -
kEBChannels <<
" FED " << fed[ich] <<
" chan " << chan[ich]
1317 <<
" pedestal " << ped[ich] <<
" RMS " << pedrms[ich] << std::endl;
1322 int runold = -1, fillold = -1, firsttimeFEDold = -1;
1323 int firsttimeFED = -1;
1324 bool firstSeqAfterStable =
false;
1326 tree->GetEntry(
entry);
1327 if(nxt != kChannels) {
1328 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1329 <<
" *********** Number of channels " << nxt;
1331 fout <<
" rejected" << std::endl;
1334 else fout << std::endl;
1337 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id
1338 <<
" *********** laser wave length = " << las_id << std::endl;
1342 fout <<
" entry " <<
entry <<
" run " << run <<
" sequence " << seq_id <<
" run_time " << run_time
1343 <<
" *********** bfield = " << bfield << std::endl;
1346 fout <<
" entry "<<
entry <<
" run " << run <<
" sequence " << seq_id;
1347 if(run_type == 1) fout <<
" stable " << run_time_stablebeam;
1348 firsttimeFED = time[0];
1349 for(
int ifed = 0; ifed < 54; ifed++) {
1351 if(time[ifed] > firsttimeFEDold && firsttimeFED < time[ifed]) firsttimeFED = time[ifed];
1353 fout <<
" time " << firsttimeFED << std::endl;
1354 if(firsttimeFED <= firsttimeFEDold) {
1355 std::cout <<
" Problem finding the IOV : old one " << firsttimeFEDold <<
" new one " << firsttimeFED << std::endl;
1356 for(
int ifed = 0; ifed < 54; ifed++)
1358 std::cout << std::endl <<
" ignore this entry " << std::endl;
1361 firsttimeFEDold = firsttimeFED;
1364 if(fill_num != fillold) firstSeqAfterStable =
false;
1366 if(firsttimeFED > run_time_stablebeam) {
1367 if(!firstSeqAfterStable) {
1368 firstSeqAfterStable =
true;
1369 firsttimeFED = run_time_stablebeam;
1370 fout <<
" first sequence after stable; change the IOV " << firsttimeFED << std::endl;
1375 for(
int ich = 0; ich <
kChannels; ich++) {
1376 if(ped[ich] < 300 && ped[ich] > 100) {
1377 EAmean12[ich] = ped[ich];
1378 EArms12[ich] = pedrms[ich];
1382 bool foundNew =
false;
1384 for(
int i = run16Index;
i < 26;
i++) {
1385 if(run > pedxml[
i]) {
1386 fout <<
" found a new gain 1, 6 file " << pedxml[
i] <<
" at index " << i << std::endl;
1389 if(runold < pedxml[i + 1])
break;
1393 int Indexxml = run16Index -1;
1394 fout <<
" opening Pedestals_" << pedxml[Indexxml] <<
".xml at index " << Indexxml << std::endl;
1396 fxml.open(Form(
"Pedestals_%i.xml",pedxml[Indexxml]));
1397 if(!fxml.is_open()) {
1398 std::cout <<
"ERROR : cannot open file Pedestals_" << pedxml[Indexxml] <<
".xml" << std::endl;
1402 for(
int i = 0;
i < 9;
i++) std::getline(fxml, dummyLine);
1404 for (
int iEBChannel = 0; iEBChannel <
kEBChannels; iEBChannel++) {
1405 fxml >> mean12 >> rms12 >> bid;
1407 std::istringstream m6(stt);
1408 m6 >> EAmean6[iEBChannel];
1410 stt = bid.substr(8,15);
1411 std::istringstream r6(stt);
1412 r6 >> EArms6[iEBChannel];
1414 stt = bid.substr(9,15);
1415 std::istringstream m1(stt);
1416 m1 >> EAmean1[iEBChannel];
1418 stt = bid.substr(8,15);
1419 std::istringstream
r1(stt);
1420 r1 >> EArms1[iEBChannel];
1421 if(debug && iEBChannel%10000 == 0) fout <<
" EB channel " << iEBChannel <<
" " << mean12 <<
" " << rms12
1422 <<
" " << EAmean6[iEBChannel] <<
" " << EArms6[iEBChannel]
1423 <<
" " << EAmean1[iEBChannel] <<
" " << EArms1[iEBChannel] << std::endl;
1424 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1426 for(
int i = 0;
i < 6;
i++) std::getline(fxml, dummyLine);
1427 for (
int iEEChannel = 0; iEEChannel <
kEEChannels; iEEChannel++) {
1429 fxml >> mean12 >> rms12 >> bid;
1431 std::istringstream m6(stt);
1434 stt = bid.substr(8,15);
1435 std::istringstream r6(stt);
1438 stt = bid.substr(9,15);
1439 std::istringstream m1(stt);
1442 stt = bid.substr(8,15);
1443 std::istringstream
r1(stt);
1445 if(debug && iEEChannel%1000 == 0) fout <<
" EE channel " << iEEChannel <<
" " << mean12 <<
" " << rms12
1446 <<
" " << EAmean6[ich] <<
" " << EArms6[ich]
1447 <<
" " << EAmean1[ich] <<
" " << EArms1[ich] << std::endl;
1448 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
1456 for(
int ich = 0; ich <
kChannels; ich++) {
1457 if(debug && ich%10000 == 0) fout <<
" channel " << ich <<
" ped " << EAmean12[ich] <<
" RMS " << EArms12[ich] << std::endl;
1460 item.
rms_x1 = EArms1[ich];
1462 item.
rms_x6 = EArms6[ich];
1468 pedestal->
insert(std::make_pair(ebdetid.
rawId(),item));
1474 pedestal->
insert(std::make_pair(eedetid.
rawId(),item));
1480 fout <<
" m_to_transfer " << firsttimeFED << std::endl;
1485 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
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
T x() const
Cartesian x coordinate.
cond::ValidityInterval lastInterval
std::string getName() const
float getPedMeanG12() const
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
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