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") {
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;
122 peds->
insert(std::make_pair(eedetidpos.
rawId(),item));
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
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") {
307 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
313 EEDetId eedetid(xt_num,yt_num,sm_num);
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;
369 pedtemp->
insert(std::make_pair(ebdetid.
rawId(),item));
370 if((iEta==-1 || iEta==1) && iPhi==20){
372 std::cout<<
"channel:" <<iEta<<
"/"<<iPhi<<
"/" << hiee <<
" ped mean 12="<< x << std::endl;
395 pedtemp->
insert(std::make_pair(eedetid.
rawId(),item));
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) {
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;
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));
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));
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
void setRunTypeDef(const RunTypeDef &runTypeDef)
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 &)
void setGeneralTag(std::string tag)
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
std::string getName() const
float getPedMeanG12() const
float getPedRMSG12() const
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
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)
float getPedMeanG1() const
void setMonitoringVersion(std::string ver)
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