25 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGLinConstHandler")) {
27 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"EcalTPGLinConst Source handler constructor";
49 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Started getNewObjects";
53 std::cout <<
"got offlineInfo = " << std::endl;
57 std::cout <<
" First object for this tag " << std::endl;
60 unsigned int max_since =0;
61 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
62 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"max_since = " << max_since;
63 edm::LogInfo(
"EcalTPGLinConstHandler")<<
"Retrieved last payload ";
66 edm::LogInfo(
"EcalTPGLinConstHandler")<<
"Retrieving run list from ONLINE DB ... " << std::endl;
68 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Making connection..." << std::flush;
70 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Done." << std::endl;
74 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
91 readFromFile(
"last_tpg_lin_settings.txt");
94 unsigned int min_run=m_i_run_number+1;
96 if(m_firstRun<m_i_run_number) {
97 min_run=m_i_run_number+1;
102 if(min_run<max_since) {
103 min_run= max_since+1;
106 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
108 unsigned int max_run=m_lastRun;
109 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"min_run= " << min_run <<
"max_run = " << max_run;
112 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
115 std::vector<RunIOV> run_vec= my_list.
getRuns();
116 size_t num_runs=run_vec.size();
118 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
123 for(
size_t kr=0; kr<run_vec.size(); kr++){
125 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
126 std::cout<<
" **************** "<<std::endl;
127 std::cout<<
" **************** "<<std::endl;
131 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
132 econn->fetchDataSet(&dataset, &run_vec[kr]);
135 int the_config_version=0;
137 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
140 for( it=dataset.begin(); it!=dataset.end(); it++ )
154 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
159 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
160 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
167 std::cout <<
" before fetch config set" << std::endl;
168 econn-> fetchConfigSet(&fe_main_info);
169 std::cout <<
" after fetch config set" << std::endl;
175 if( linId != m_i_lin ) {
178 fe_lin_info.
setId(linId);
179 econn-> fetchConfigSet(&fe_lin_info);
180 std::map<EcalLogicID, FEConfigLinDat> dataset_TpgLin;
181 econn->fetchDataSet(&dataset_TpgLin, &fe_lin_info);
184 typedef std::map<EcalLogicID, FEConfigLinDat>::const_iterator CIfelin;
189 for (CIfelin
p = dataset_TpgLin.begin();
p != dataset_TpgLin.end();
p++) {
195 if (ecid_name==
"EB_crystal_number") {
196 int sm_num=ecid_xt.
getID1();
197 int xt_num=ecid_xt.
getID2();
208 linC->
insert(std::make_pair(ebdetid.
rawId(),item));
227 linC->
insert(std::make_pair(eedetid.
rawId(),item));
236 m_i_tag=the_config_tag;
237 m_i_version=the_config_version;
240 writeFile(
"last_tpg_lin_settings.txt");
245 m_i_tag=the_config_tag;
246 m_i_version=the_config_version;
248 writeFile(
"last_tpg_lin_settings.txt");
250 std::cout<<
" even if the tag/version is not the same, the linearization constants id is the same -> no transfer needed "<< std::endl;
254 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
255 <<
" version="<<the_config_version<< std::endl;
260 std::cout<<
" **************** "<<std::endl;
264 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
265 std::cout<<
" **************** "<<std::endl;
268 m_i_tag=the_config_tag;
269 m_i_version=the_config_version;
270 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
271 std::cout<<
" **************** "<<std::endl;
272 writeFile(
"last_tpg_lin_settings.txt");
280 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Ecal - > end of getNewObjects -----------";
292 inpFile = fopen(inputFile,
"r");
300 std::ostringstream str;
302 fgets(line,255,inpFile);
303 m_i_tag=to_string(line);
304 str <<
"gen tag " << m_i_tag << std::endl ;
306 fgets(line,255,inpFile);
307 m_i_version=atoi(line);
308 str <<
"version= " << m_i_version << std::endl ;
310 fgets(line,255,inpFile);
311 m_i_run_number=atoi(line);
312 str <<
"run_number= " << m_i_run_number << std::endl ;
314 fgets(line,255,inpFile);
316 str <<
"lin_config= " << m_i_lin << std::endl ;
327 std::ofstream myfile;
328 myfile.open (inputFile);
329 myfile << m_i_tag <<std::endl;
330 myfile << m_i_version <<std::endl;
331 myfile << m_i_run_number <<std::endl;
332 myfile << m_i_lin <<std::endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
uint32_t rawId() const
get the raw id
std::string getName() const
void setLocationDef(const LocationDef &locDef)
void insert(std::pair< uint32_t, Item > const &a)
void readFromFile(const char *inputFile)
EcalTPGLinConstHandler(edm::ParameterSet const &)
void setRunType(std::string runtype)
std::string m_locationsource
~EcalTPGLinConstHandler()
void setConfigTag(std::string x)
void writeFile(const char *inputFile)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
tuple size
Write out results.
EcalTPGLinearizationConstMap EcalTPGLinearizationConst