27 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGPedestalsHandler")) {
29 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"EcalTPGPedestals Source handler constructor";
52 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Started getNewObjects";
57 std::cout <<
"got offlineInfo = " << std::endl;
61 std::cout <<
" First object for this tag " << std::endl;
64 unsigned int max_since =0;
65 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
66 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"max_since = " << max_since;
67 edm::LogInfo(
"EcalTPGPedestalsHandler")<<
"Retrieved last payload ";
70 edm::LogInfo(
"EcalTPGPedestalsHandler")<<
"Retrieving run list from ONLINE DB ... " << std::endl;
72 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Making connection..." << std::flush;
74 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Done." << std::endl;
78 std::cout <<
" Connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
94 readFromFile(
"last_tpg_ped_settings.txt");
97 unsigned int min_run=m_i_run_number+1;
99 if(m_firstRun < m_i_run_number) {
100 min_run=m_i_run_number+1;
104 if(min_run<max_since) {
105 min_run= max_since+1;
108 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
110 unsigned int max_run=m_lastRun;
111 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"min_run= " << min_run <<
" max_run = " << max_run;
113 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
116 std::vector<RunIOV> run_vec= my_list.
getRuns();
117 size_t num_runs=run_vec.size();
119 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
125 for(
size_t kr=0; kr<run_vec.size(); kr++){
126 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
128 std::cout<<
" **************** "<<std::endl;
129 std::cout<<
" **************** "<<std::endl;
134 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
135 econn->fetchDataSet(&dataset, &run_vec[kr]);
138 int the_config_version=0;
140 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
143 for ( it=dataset.begin(); it!=dataset.end(); it++ )
156 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
161 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
162 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
169 std::cout <<
" before fetch config set" << std::endl;
170 econn-> fetchConfigSet(&fe_main_info);
171 std::cout <<
" after fetch config set" << std::endl;
176 if( pedId != m_i_ped ) {
179 fe_ped_info.
setId(pedId);
180 econn-> fetchConfigSet(&fe_ped_info);
181 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
182 econn->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
186 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
190 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++)
198 if (ecid_name==
"EB_crystal_number") {
199 if(icells<10)
std::cout <<
" copy the EB data " <<
" icells = " << icells << std::endl;
200 int sm_num=ecid_xt.
getID1();
201 int xt_num=ecid_xt.
getID2();
209 peds->
insert(std::make_pair(ebdetid.
rawId(),item));
211 }
else if (ecid_name==
"EE_crystal_number"){
223 peds->
insert(std::make_pair(eedetid.
rawId(),item));
233 m_i_tag=the_config_tag;
234 m_i_version=the_config_version;
237 writeFile(
"last_tpg_ped_settings.txt");
242 m_i_tag=the_config_tag;
243 m_i_version=the_config_version;
245 writeFile(
"last_tpg_ped_settings.txt");
247 std::cout<<
" even if the tag/version is not the same, the pedestals 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_ped_settings.txt");
281 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Ecal - > end of getNewObjects -----------";
296 inpFile = fopen(inputFile,
"r");
304 std::ostringstream str;
306 fgets(line,255,inpFile);
308 str <<
"gen tag " << m_i_tag << std::endl ;
310 fgets(line,255,inpFile);
311 m_i_version=atoi(line);
312 str <<
"version= " << m_i_version << std::endl ;
314 fgets(line,255,inpFile);
315 m_i_run_number=atoi(line);
316 str <<
"run_number= " << m_i_run_number << std::endl ;
318 fgets(line,255,inpFile);
320 str <<
"ped_config= " << m_i_ped << std::endl ;
331 std::ofstream myfile;
332 myfile.open (inputFile);
333 myfile << m_i_tag <<std::endl;
334 myfile << m_i_version <<std::endl;
335 myfile << m_i_run_number <<std::endl;
336 myfile << m_i_ped <<std::endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
float getPedMeanG1() const
~EcalTPGPedestalsHandler()
uint32_t rawId() const
get the raw id
void writeFile(const char *inputFile)
std::string to_string(const T &t)
std::string m_locationsource
std::string getName() const
float getPedMeanG12() const
void setLocationDef(const LocationDef &locDef)
void insert(std::pair< uint32_t, Item > const &a)
void setRunType(std::string runtype)
void readFromFile(const char *inputFile)
float getPedMeanG6() const
void setConfigTag(std::string x)
EcalTPGPedestalsHandler(edm::ParameterSet const &)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
EcalTPGPedestalsMap EcalTPGPedestals
tuple size
Write out results.