14 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGFineGrainTowerEEHandler")) {
15 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"EcalTPGFineGrainTowerEE Source handler constructor.";
32 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"Started GetNewObjects!!!";
37 std::cout <<
"got offlineInfo = " << std::endl;
41 std::cout <<
" First object for this tag " << std::endl;
44 unsigned int max_since = 0;
45 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
46 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"max_since : " << max_since;
47 Ref fgrTTEE_db = lastPayload();
49 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"retrieved last payload ";
52 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"Retrieving run list from ONLINE DB ... ";
54 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"Making connection...";
56 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"Done.";
59 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
79 if (m_firstRun < m_i_run_number) {
80 min_run = m_i_run_number + 1;
84 if (min_run < max_since) {
85 min_run = max_since + 1;
88 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
91 unsigned int max_run = m_lastRun;
92 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
95 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
98 std::vector<RunIOV> run_vec = my_list.
getRuns();
99 size_t num_runs = run_vec.size();
101 std::cout <<
"number of runs is : " << num_runs << std::endl;
106 std::vector<EcalLogicID> my_TTEcalLogicId_EE;
107 my_TTEcalLogicId_EE =
econn->getEcalLogicIDSetOrdered(
109 std::cout <<
" GOT the logic ID for the EE trigger towers " << std::endl;
111 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
112 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
114 std::cout <<
" **************** " << std::endl;
115 std::cout <<
" **************** " << std::endl;
116 std::cout <<
" run= " << irun << std::endl;
119 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
123 int the_config_version = 0;
125 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
138 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
142 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
143 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 151 std::cout <<
" before fetch config set" << std::endl;
152 econn->fetchConfigSet(&fe_main_info);
153 std::cout <<
" after fetch config set" << std::endl;
156 int fgrId = fe_main_info.
getFgrId();
158 if (fgrId != m_i_fgrTTEE) {
160 fe_fgr_info.
setId(fgrId);
161 econn->fetchConfigSet(&fe_fgr_info);
162 std::map<EcalLogicID, FEConfigFgrEETowerDat> dataset_TpgFineGrainEE;
163 econn->fetchDataSet(&dataset_TpgFineGrainEE, &fe_fgr_info);
166 typedef std::map<EcalLogicID, FEConfigFgrEETowerDat>::const_iterator CIfefgr;
171 for (CIfefgr
p = dataset_TpgFineGrainEE.begin();
p != dataset_TpgFineGrainEE.end();
p++) {
177 if (ecid_name ==
"EE_trigger_tower") {
178 int tccid = ecid_xt.
getID1();
180 int towerid = ecid_xt.
getID2();
182 bool set_the_tower =
false;
184 for (
size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
185 if (!set_the_tower) {
186 if (my_TTEcalLogicId_EE[itower].getID1() == tccid &&
187 my_TTEcalLogicId_EE[itower].getID2() == towerid) {
188 towid = my_TTEcalLogicId_EE[itower].getLogicID();
189 set_the_tower =
true;
199 std::cout <<
" these may be the additional towers TCC/TT " << tccid <<
"/" << towerid << std::endl;
210 m_i_run_number = irun;
211 m_i_tag = the_config_tag;
212 m_i_version = the_config_version;
215 writeFile(
"last_tpg_fgrTTEE_settings.txt");
218 m_i_run_number = irun;
219 m_i_tag = the_config_tag;
220 m_i_version = the_config_version;
222 writeFile(
"last_tpg_fgrTTEE_settings.txt");
224 std::cout <<
" even if the tag/version is not the same, the fgrTTEE id is the same -> no transfer needed " 229 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
232 m_i_run_number = irun;
234 std::cout <<
" **************** " << std::endl;
236 }
else if (
nr == 0) {
237 m_i_run_number = irun;
238 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
239 std::cout <<
" **************** " << std::endl;
241 m_i_run_number = irun;
242 m_i_tag = the_config_tag;
243 m_i_version = the_config_version;
244 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
245 std::cout <<
" **************** " << std::endl;
246 writeFile(
"last_tpg_fgrTTEE_settings.txt");
252 edm::LogInfo(
"EcalTPGFineGrainTowerEEHandler") <<
"Ecal - > end of getNewObjects -----------";
272 std::ostringstream
str;
274 fgets(
line, 255, inpFile);
276 str <<
"gen tag " << m_i_tag << std::endl;
278 fgets(
line, 255, inpFile);
279 m_i_version = atoi(
line);
280 str <<
"version= " << m_i_version << std::endl;
282 fgets(
line, 255, inpFile);
283 m_i_run_number = atoi(
line);
284 str <<
"run_number= " << m_i_run_number << std::endl;
286 fgets(
line, 255, inpFile);
287 m_i_fgrTTEE = atoi(
line);
288 str <<
"fgrTTEE_config= " << m_i_fgrTTEE << std::endl;
296 std::ofstream myfile;
298 myfile << m_i_tag << std::endl;
299 myfile << m_i_version << std::endl;
300 myfile << m_i_run_number << std::endl;
301 myfile << m_i_fgrTTEE << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
void writeFile(const char *inputFile)
std::string getName() const
EcalTPGFineGrainTowerEEHandler(edm::ParameterSet const &)
void readFromFile(const char *inputFile)
std::string to_string(const V &value)
Log< level::Error, false > LogError
void readFromFile(CaloCluster &c, FILE *file)
~EcalTPGFineGrainTowerEEHandler() override
void setValue(const uint32_t &id, const uint32_t &lut)
void setLocationDef(const LocationDef &locDef)
std::string m_locationsource
Log< level::Info, false > LogInfo
void getNewObjects() override
std::string getConfigTag() const
std::unique_ptr< EcalTPGFineGrainTowerEE > Ref
void setConfigTag(std::string x)
void setGeneralTag(std::string tag)