26 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGBadXTHandler")) {
28 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"EcalTPGBadXT Source handler constructor.";
51 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Started GetNewObjects!!!";
54 unsigned int max_since=0;
55 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
56 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"max_since : " << max_since;
57 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"retrieved last payload ";
60 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Retrieving run list from ONLINE DB ... ";
62 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Making connection...";
68 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
84 readFromFile(
"last_tpg_badXT_settings.txt");
87 unsigned int min_run=m_i_run_number+1;
89 if(m_firstRun<m_i_run_number) {
90 min_run=m_i_run_number+1;
94 if(min_run<max_since) {
98 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
101 unsigned int max_run=m_lastRun;
102 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
105 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
108 std::vector<RunIOV> run_vec= my_list.
getRuns();
109 size_t num_runs=run_vec.size();
111 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
113 std::vector<EcalLogicID> my_EcalLogicId;
114 std::vector<EcalLogicID> my_EcalLogicId_EE;
120 my_EcalLogicId = econn->getEcalLogicIDSetOrdered(
"ECAL_crystal_number_fedccuxt",
124 "EB_crystal_number",123 );
126 my_EcalLogicId_EE = econn->getEcalLogicIDSetOrdered(
"ECAL_crystal_number_fedccuxt",
130 "EE_crystal_number",123 );
134 for(
size_t kr=0; kr<run_vec.size(); kr++){
135 std::cout <<
"here we are in run "<<kr<<std::endl;
136 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
138 std::cout<<
" **************** "<<std::endl;
139 std::cout<<
" **************** "<<std::endl;
143 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
144 econn->fetchDataSet(&dataset, &run_vec[kr]);
147 int the_config_version=0;
149 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
152 for( it=dataset.begin(); it!=dataset.end(); it++ )
165 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
170 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
171 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
180 std::cout <<
" before fetch config set" << std::endl;
181 econn-> fetchConfigSet(&fe_main_info);
182 std::cout <<
" after fetch config set" << std::endl;
186 int badxtId=fe_main_info.
getBxtId();
188 if( badxtId != m_i_badXT && badxtId!=0) {
191 fe_badXt_info.
setId(badxtId);
192 econn-> fetchConfigSet(&fe_badXt_info);
193 std::vector<FEConfigBadXTDat> dataset_TpgBadXT;
194 econn->fetchConfigDataSet(&dataset_TpgBadXT, &fe_badXt_info);
199 badXt = produceEcalTrgChannelStatus();
202 typedef std::vector<FEConfigBadXTDat>::const_iterator CIfeped;
207 for (CIfeped
p = dataset_TpgBadXT.begin();
p != dataset_TpgBadXT.end();
p++) {
216 if (fed_id>=610 && fed_id<=645) {
221 if(fed_id<=627 ) sm_num=fed_id-609+18;
222 if(fed_id>627 ) sm_num=fed_id-627;
227 for(
size_t ixt=0; ixt<my_EcalLogicId.size(); ixt++){
229 if(my_EcalLogicId[ixt].getID1()==fed_id && my_EcalLogicId[ixt].getID2()==tt_id
230 && my_EcalLogicId[ixt].getID3()==xt_id ) {
232 int ecid= my_EcalLogicId[ixt].getLogicID();
233 xt_num=(ecid)-(101100+sm_num)*10000;
238 std::cout<<
" masking crystal "<<sm_num<<
"/"<<xt_num<<
" from fed/tt/xt"<<
239 fed_id<<
"/"<<tt_id<<
"/"<<xt_id<< std::endl;
240 if( sm_num==0 && xt_num==0 ) {
241 std::cout<<
" ERROR FOR crystal from fed/tt/xt"<<
242 fed_id<<
"/"<<tt_id<<
"/"<<xt_id<< std::endl;
255 for(
size_t ixt=0; ixt<my_EcalLogicId_EE.size(); ixt++){
257 if(my_EcalLogicId_EE[ixt].getID1()==fed_id && my_EcalLogicId_EE[ixt].getID2()==tt_id
258 && my_EcalLogicId_EE[ixt].getID3()==xt_id ) {
260 long ecid=(long) my_EcalLogicId_EE[ixt].getLogicID();
262 y=ecid-( (long)(ecid/1000) ) *1000;
263 x= ( ecid-
y) /1000 ;
264 x= x -( (long)(x/1000) ) *1000;
265 z= (ecid-y-x*1000 )/1000000 -2010;
271 if( x==0 && y==0 && z==0 ) {
272 std::cout<<
" ERROR FOR crystal from fed/tt/xt"<<
273 fed_id<<
"/"<<tt_id<<
"/"<<xt_id<< std::endl;
281 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Finished badXT reading";
287 m_i_tag=the_config_tag;
288 m_i_version=the_config_version;
291 writeFile(
"last_tpg_badXT_settings.txt");
296 m_i_tag=the_config_tag;
297 m_i_version=the_config_version;
299 writeFile(
"last_tpg_badXT_settings.txt");
301 std::cout<<
" even if the tag/version is not the same, the badXT id is the same -> no transfer needed "<< std::endl;
308 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
309 <<
" version="<<the_config_version<< std::endl;
314 std::cout<<
" **************** "<<std::endl;
318 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
319 std::cout<<
" **************** "<<std::endl;
322 m_i_tag=the_config_tag;
323 m_i_version=the_config_version;
324 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
325 std::cout<<
" **************** "<<std::endl;
326 writeFile(
"last_tpg_badXT_settings.txt");
335 edm::LogInfo(
"EcalTPGBadXTHandler")<<
"Ecal - > end of getNewObjects -----------";
347 inpFile = fopen(inputFile,
"r");
355 std::ostringstream str;
357 fgets(line,255,inpFile);
358 m_i_tag=to_string(line);
359 str <<
"gen tag " << m_i_tag << std::endl ;
361 fgets(line,255,inpFile);
362 m_i_version=atoi(line);
363 str <<
"version= " << m_i_version << std::endl ;
365 fgets(line,255,inpFile);
366 m_i_run_number=atoi(line);
367 str <<
"run_number= " << m_i_run_number << std::endl ;
369 fgets(line,255,inpFile);
370 m_i_badXT=atoi(line);
371 str <<
"badXT_config= " << m_i_badXT << std::endl ;
382 std::ofstream myfile;
383 myfile.open (inputFile);
384 myfile << m_i_tag <<std::endl;
385 myfile << m_i_version <<std::endl;
386 myfile << m_i_run_number <<std::endl;
387 myfile << m_i_badXT <<std::endl;
399 if(ieta==0)
continue;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
static const int MIN_IPHI
void writeFile(const char *inputFile)
std::string getConfigTag() const
static bool validDetId(int i, int j)
check if a valid index combination
uint32_t rawId() const
get the raw id
void setValue(const uint32_t id, const Item &item)
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
void setLocationDef(const LocationDef &locDef)
EcalTPGCrystalStatus * produceEcalTrgChannelStatus()
EcalTPGBadXTHandler(edm::ParameterSet const &)
static const int MAX_IPHI
void setRunType(std::string runtype)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
static const int MAX_IETA
void setConfigTag(std::string x)
std::string m_locationsource
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
void readFromFile(const char *inputFile)