43 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGSpikeThresholdHandler")) {
45 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"EcalTPGSpike Source handler constructor";
71 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Started GetNewObjects!!!";
76 std::cout <<
"got offlineInfo = " << std::endl;
80 std::cout <<
" First object for this tag " << std::endl;
83 unsigned int max_since=0;
84 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
85 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"max_since : " << max_since;
86 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"retrieved last payload ";
89 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Retrieving run list from ONLINE DB ... ";
91 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Making connection...";
97 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
111 my_runtag.setRunTypeDef( my_rundef );
112 my_runtag.setGeneralTag(m_gentag);
115 readFromFile(
"last_tpg_spikeThreshold_settings.txt");
118 unsigned int min_run=m_i_run_number+1;
120 if(m_firstRun<m_i_run_number) {
121 min_run=m_i_run_number+1;
127 if(min_run<max_since) {
128 min_run= max_since+1;
131 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
133 unsigned int max_run=m_lastRun;
134 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
137 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
140 std::vector<RunIOV> run_vec= my_list.
getRuns();
141 size_t num_runs=run_vec.size();
143 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
150 for(
size_t kr=0; kr<run_vec.size(); kr++){
152 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
154 std::cout<<
" **************** "<<std::endl;
158 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
159 econn->fetchDataSet(&dataset, &run_vec[kr]);
162 int the_config_version=0;
164 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
167 for( it=dataset.begin(); it!=dataset.end(); it++ )
181 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
186 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
187 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
194 std::cout <<
" before fetch config set" << std::endl;
195 econn-> fetchConfigSet(&fe_main_info);
196 std::cout <<
" after fetch config set" << std::endl;
200 int spikeId=fe_main_info.
getSpiId();
202 if( spikeId != m_i_spikeTh ) {
205 fe_spike_info.
setId(spikeId);
206 econn-> fetchConfigSet(&fe_spike_info);
207 std::map<EcalLogicID, FEConfigSpikeDat> dataset_TpgSpike;
208 econn->fetchDataSet(&dataset_TpgSpike, &fe_spike_info);
211 typedef std::map<EcalLogicID, FEConfigSpikeDat>::const_iterator CIfelut;
216 for (CIfelut
p = dataset_TpgSpike.begin();
p != dataset_TpgSpike.end();
p++)
219 rd_spike =
p->second;
223 if(ecid_name==
"EB_trigger_tower") {
225 int smid=ecid_xt.
getID1();
227 int towerid=ecid_xt.
getID2();
230 int tow_eta=(towerid-1)/4;
231 int tow_phi=((towerid-1)-tow_eta*4);
233 int axt=(tow_eta*5)*20 + tow_phi*5 +1 ;
246 std::cout <<
" The number of towers is = " << itowers << std::endl;
250 m_to_transfer.push_back(std::make_pair((
EcalTPGSpike*)lut,snc));
253 m_i_tag=the_config_tag;
254 m_i_version=the_config_version;
257 writeFile(
"last_tpg_spikeThreshold_settings.txt");
262 m_i_tag=the_config_tag;
263 m_i_version=the_config_version;
265 writeFile(
"last_tpg_spikeThreshold_settings.txt");
267 std::cout<<
" even if the tag/version is not the same, the lutGroup id is the same -> no transfer needed "<< std::endl;
274 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
275 <<
" version="<<the_config_version<< std::endl;
280 std::cout<<
" **************** "<<std::endl;
284 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
285 std::cout<<
" **************** "<<std::endl;
288 m_i_tag=the_config_tag;
289 m_i_version=the_config_version;
290 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
291 std::cout<<
" **************** "<<std::endl;
292 writeFile(
"last_tpg_spikeThreshold_settings.txt");
299 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Ecal - > end of getNewObjects -----------";
311 inpFile = fopen(inputFile,
"r");
318 std::ostringstream str;
320 fgets(line,255,inpFile);
322 str <<
"gen tag " << m_i_tag << std::endl ;
324 fgets(line,255,inpFile);
325 m_i_version=atoi(line);
326 str <<
"version= " << m_i_version << std::endl ;
328 fgets(line,255,inpFile);
329 m_i_run_number=atoi(line);
330 str <<
"run_number= " << m_i_run_number << std::endl ;
332 fgets(line,255,inpFile);
333 m_i_spikeTh=atoi(line);
334 str <<
"spikeTh_config= " << m_i_spikeTh << std::endl ;
345 std::ofstream myfile;
346 myfile.open (inputFile);
347 myfile << m_i_tag <<std::endl;
348 myfile << m_i_version <<std::endl;
349 myfile << m_i_run_number <<std::endl;
350 myfile << m_i_spikeTh <<std::endl;
T getParameter(std::string const &) const
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
void readFromFile(const char *inputFile)
std::string m_locationsource
EcalTPGSpikeThresholdHandler(edm::ParameterSet const &)
void setValue(const uint32_t &id, const uint16_t &val)
uint32_t rawId() const
get the raw id
std::string to_string(const T &t)
std::string getName() const
~EcalTPGSpikeThresholdHandler()
void setLocationDef(const LocationDef &locDef)
void setRunType(std::string runtype)
void writeFile(const char *inputFile)
static std::vector< std::string > checklist dat
void setConfigTag(std::string x)
void setLocation(std::string loc)
int getSpikeThreshold() const
static const int SMCRYSTALMODE
tuple size
Write out results.