9 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalPedestalsHandler")) {
11 std::cout <<
"EcalPedestals Source handler constructor\n" << std::endl;
21 std::cout <<
m_sid<<
"/"<<m_user<<
"/"<<m_pass<<
"/"<<m_location<<
"/"<<m_gentag << std::endl;
34 std::cout <<
"------- Ecal - > getNewObjects\n";
36 if(m_locationsource==
"H2") {
38 }
else if (m_locationsource==
"P5") {
47 if(item->rms_x12 >3 || item->rms_x12<=0) result=
false;
48 if(item->rms_x6 >2 || item->rms_x6<=0) result=
false;
49 if(item->rms_x1 >1 || item->rms_x1<=0) result=
false;
50 if(item->mean_x12>300 || item->mean_x12<=100) result=
false;
51 if(item->mean_x1>300 || item->mean_x1<=100) result=
false;
52 if(item->mean_x6>300 || item->mean_x6<=100) result=
false;
59 std::ostringstream ss;
62 unsigned int max_since=0;
63 max_since=
static_cast<unsigned int>(tagInfo().lastInterval.first);
64 std::cout <<
"max_since : " << max_since << std::endl;
65 Ref ped_db = lastPayload();
69 std::cout <<
"retrieved last payload " << std::endl;
87 item.mean_x1 = aped.mean_x1;
88 item.rms_x1 = aped.rms_x1;
89 item.mean_x6 = aped.mean_x6;
90 item.rms_x6 = aped.rms_x6;
91 item.mean_x12 = aped.mean_x12;
92 item.rms_x12 = aped.rms_x12;
116 item.mean_x1 = aped.mean_x1;
117 item.rms_x1 = aped.rms_x1;
118 item.mean_x6 = aped.mean_x6;
119 item.rms_x6 = aped.rms_x6;
120 item.mean_x12 = aped.mean_x12;
121 item.rms_x12 = aped.rms_x12;
122 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
136 item.mean_x1 = aped.mean_x1;
137 item.rms_x1 = aped.rms_x1;
138 item.mean_x6 = aped.mean_x6;
139 item.rms_x6 = aped.rms_x6;
140 item.mean_x12 = aped.mean_x12;
141 item.rms_x12 = aped.rms_x12;
142 peds->
insert(std::make_pair(eedetidneg.
rawId(),item));
150 std::cout <<
"Retrieving run list from ONLINE DB ... " << std::endl;
152 std::cout <<
"Connection done" << std::endl;
156 std::cout <<
" Problem with OMDS: connection parameters " <<m_sid <<
"/"<<m_user<<
"/"<<m_pass<<std::endl;
186 unsigned int min_run=0;
187 if(m_firstRun<max_since) {
193 unsigned int max_run=m_lastRun;
194 mon_list=econn->fetchMonRunList(my_runtag, mon_tag,min_run,max_run );
196 std::vector<MonRunIOV> mon_run_vec= mon_list.
getRuns();
197 int mon_runs = mon_run_vec.size();
198 std::cout <<
"number of Mon runs is : "<< mon_runs<< std::endl;
202 for(
int kr = 0; kr < krmax; kr++){
203 std::cout <<
"-kr------: "<<kr<<std::endl;
206 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;
210 if (mon_run_vec[kr].getSubRunNumber() <=1){
213 RunIOV runiov_prime = mon_run_vec[kr].getRunIOV();
216 std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
217 econn->fetchDataSet(&dataset_mon, &mon_run_vec[kr]);
218 std::cout <<
"OMDS record for run "<<irun <<
" is made of "<< dataset_mon.size() << std::endl;
219 int nEB = 0, nEE = 0, nEBbad = 0, nEEbad =0;
220 typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
227 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
230 int sm_num=ecid_xt.
getID1();
231 int xt_num=ecid_xt.
getID2();
232 int yt_num=ecid_xt.
getID3();
242 if(ecid_xt.
getName()==
"EB_crystal_number") {
244 if(!checkPedestal(&item) ) nEBbad++;
248 if(!checkPedestal(&item) ) nEEbad++;
253 if(!checkPedestal(&item) ){
255 if(nbad < 10)
std::cout <<
"BAD LIST: channel " << sm_num <<
"/" << xt_num <<
"/"<< yt_num
256 <<
"ped/rms "<<item.mean_x12<<
"/"<< item.rms_x12 << std::endl;
264 if(nbad<(dataset_mon.size()*0.05) && (nEB > 10200 || nEE > 2460)) {
266 for (CImon
p = dataset_mon.begin();
p != dataset_mon.end();
p++) {
269 int sm_num=ecid_xt.
getID1();
270 int xt_num=ecid_xt.
getID2();
271 int yt_num=ecid_xt.
getID3();
283 if(ecid_xt.
getName()==
"EB_crystal_number") {
288 if(item.mean_x1==-1 || item.rms_x1 ==-1 || item.mean_x6==-1 ||
289 item.rms_x6==-1 || item.mean_x12==-1 || item.rms_x12==-1 ||
290 item.mean_x1==0 || item.rms_x1 ==0 || item.mean_x6==0 ||
291 item.rms_x6==0 || item.mean_x12==0 || item.rms_x12==0 ) {
296 if(item.mean_x1==-1 || item.mean_x1==0) item.mean_x1 =previous_ped.mean_x1;
297 if(item.rms_x1==-1 || item.rms_x1==0) item.rms_x1 =previous_ped.rms_x1;
298 if(item.mean_x6==-1 || item.mean_x6==0) item.mean_x6 =previous_ped.mean_x6;
299 if(item.rms_x6==-1 || item.rms_x6==0) item.rms_x6 =previous_ped.rms_x6;
300 if(item.mean_x12==-1 || item.mean_x12==0)item.mean_x12=previous_ped.mean_x12;
301 if(item.rms_x12==-1 || item.rms_x12==0) item.rms_x12 =previous_ped.rms_x12;
307 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
313 EEDetId eedetid(xt_num,yt_num,sm_num);
316 if(item.mean_x1==-1 || item.rms_x1 ==-1 || item.mean_x6==-1 ||
317 item.rms_x6==-1 || item.mean_x12==-1 || item.rms_x12==-1 ||
318 item.mean_x1==0 || item.rms_x1 ==0 || item.mean_x6==0 ||
319 item.rms_x6==0 || item.mean_x12==0 || item.rms_x12==0 ) {
324 if(item.mean_x1==-1 || item.mean_x1==0) item.mean_x1 =previous_ped.mean_x1;
325 if(item.rms_x1==-1 || item.rms_x1==0) item.rms_x1 =previous_ped.rms_x1;
326 if(item.mean_x6==-1 || item.mean_x6==0) item.mean_x6 =previous_ped.mean_x6;
327 if(item.rms_x6==-1 || item.rms_x6==0) item.rms_x6 =previous_ped.rms_x6;
328 if(item.mean_x12==-1 || item.mean_x12==0)item.mean_x12=previous_ped.mean_x12;
329 if(item.rms_x12==-1 || item.rms_x12==0) item.rms_x12 =previous_ped.rms_x12;
334 peds->
insert(std::make_pair(eedetid.
rawId(),item));
341 std::cout <<
"Generating popcon record for run " << irun <<
"..." << std::flush;
351 if(iEta==0)
continue;
362 item.mean_x1 = aped.mean_x1;
363 item.rms_x1 = aped.rms_x1;
364 item.mean_x6 = aped.mean_x6;
365 item.rms_x6 = aped.rms_x6;
366 item.mean_x12 = aped.mean_x12;
367 item.rms_x12 = aped.rms_x12;
369 pedtemp->
insert(std::make_pair(ebdetid.
rawId(),item));
370 if((iEta==-1 || iEta==1) && iPhi==20){
371 float x=aped.mean_x12 ;
372 std::cout<<
"channel:" <<iEta<<
"/"<<iPhi<<
"/" << hiee <<
" ped mean 12="<< x << std::endl;
388 item.mean_x1 = aped.mean_x1;
389 item.rms_x1 = aped.rms_x1;
390 item.mean_x6 = aped.mean_x6;
391 item.rms_x6 = aped.rms_x6;
392 item.mean_x12 = aped.mean_x12;
393 item.rms_x12 = aped.rms_x12;
395 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
404 item.mean_x1 = aped.mean_x1;
405 item.rms_x1 = aped.rms_x1;
406 item.mean_x6 = aped.mean_x6;
407 item.rms_x6 = aped.rms_x6;
408 item.mean_x12 = aped.mean_x12;
409 item.rms_x12 = aped.rms_x12;
411 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
418 m_to_transfer.push_back(std::make_pair((
EcalPedestals*)pedtemp,snc));
421 ss <<
"Run=" << irun <<
"_WAS_GOOD_"<<std::endl;
422 m_userTextLog = ss.str()+
";";
426 std::cout <<
"Run " << irun <<
" was BAD !!!! not sent to the DB";
427 if(nbad >= (dataset_mon.size()*0.05))
428 std::cout <<
" number of bad channels = " << nbad;
430 std::cout <<
" number of EB channels = " << nEB;
432 std::cout <<
" number of EE channels = " << nEE;
434 ss <<
"Run=" << irun <<
"_WAS_BAD_"<<std::endl;
435 m_userTextLog = ss.str()+
";";
445 std::cout <<
"Ecal - > end of getNewObjects -----------\n";
453 unsigned int max_since=0;
454 max_since=
static_cast<unsigned int>(tagInfo().lastInterval.first);
455 std::cout <<
"max_since : " << max_since << std::endl;
456 Ref ped_db = lastPayload();
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) {
484 item.mean_x1 = aped.mean_x1;
485 item.rms_x1 = aped.rms_x1;
486 item.mean_x6 = aped.mean_x6;
487 item.rms_x6 = aped.rms_x6;
488 item.mean_x12 = aped.mean_x12;
489 item.rms_x12 = aped.rms_x12;
490 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
491 if(iX==ixmin && iY==iymin)
std::cout<<
"ped12 " << item.mean_x12<< std::endl;
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;
511 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<
"/"<<m_pass<<std::endl;
540 unsigned int min_run=max_since+1;
542 unsigned int max_run=m_lastRun;
543 mon_list=econn->fetchMonRunList(my_runtag, mon_tag,min_run,max_run );
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;
568 econn->fetchDataSet(&dataset_mon, &mon_run_vec[kr]);
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));
607 if(ix==ixmin && iy==iymin)
std::cout<<
"ped12 " << item.mean_x12<< std::endl;
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) {
631 item.mean_x1 = aped.mean_x1;
632 item.rms_x1 = aped.rms_x1;
633 item.mean_x6 = aped.mean_x6;
634 item.rms_x6 = aped.rms_x6;
635 item.mean_x12 = aped.mean_x12;
636 item.rms_x12 = aped.rms_x12;
638 pedtemp->
insert(std::make_pair(eedetidpos.
rawId(),item));
639 if(iX==ixmin && iY==iymin)
std::cout<<
"ped12 " << item.mean_x12<< std::endl;
648 m_to_transfer.push_back(std::make_pair((
EcalPedestals*)pedtemp,snc));
650 std::cout <<
"Ecal - > end of getNewObjectsH2 -----------\n";
bool checkPedestal(EcalPedestals::Item *item)
T getParameter(std::string const &) const
int hashedIndex() const
get a compact index for arrays
static const int MIN_IPHI
edm::Ref< Container > Ref
void setLocationDef(const LocationDef locDef)
float getPedRMSG1() const
EcalPedestalsHandler(edm::ParameterSet const &)
void setGeneralTag(std::string tag)
void setRunTag(RunTag tag)
static bool validDetId(int i, int j)
check if a valid index combination
uint32_t rawId() const
get the raw id
std::string getName() const
float getPedMeanG12() const
unsigned long long Time_t
float getPedRMSG12() const
void setRunTypeDef(const RunTypeDef runTypeDef)
void setMonVersionDef(MonVersionDef ver)
static const int ETAPHIMODE
std::string m_locationsource
void insert(std::pair< uint32_t, Item > const &a)
std::vector< MonRunIOV > getRuns()
EcalPedestalsMap EcalPedestals
static const int MAX_IPHI
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
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
void setMonRunTag(MonRunTag tag)
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