CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
popcon::EcalTPGFineGrainTowerEEHandler Class Reference

#include <EcalTPGFineGrainTowerEEHandler.h>

Inheritance diagram for popcon::EcalTPGFineGrainTowerEEHandler:
popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >

Public Member Functions

 EcalTPGFineGrainTowerEEHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
std::map< std::string, int > makeTTEEDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGFineGrainTowerEEHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Member Functions

std::string to_string (char value[])
 

Private Attributes

unsigned int m_firstRun
 
std::string m_gentag
 
int m_i_fgrTTEE
 
unsigned int m_i_run_number
 
std::string m_i_tag
 
int m_i_version
 
unsigned int m_lastRun
 
std::string m_location
 
std::string m_locationsource
 
std::string m_name
 
std::string m_pass
 
unsigned int m_runnr
 
std::string m_runtype
 
std::string m_sid
 
std::string m_user
 
std::map< std::string, int > mapDetEEId
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
typedef std::map< Time_t,
std::shared_ptr
< EcalTPGFineGrainTowerEE > > 
Container
 
typedef std::unique_ptr
< EcalTPGFineGrainTowerEE
Ref
 
typedef PopConSourceHandler
< EcalTPGFineGrainTowerEE
self
 
typedef cond::Time_t Time_t
 
typedef EcalTPGFineGrainTowerEE value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
Container m_iovs
 
std::vector< std::pair
< EcalTPGFineGrainTowerEE
*, Time_t > > 
m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 44 of file EcalTPGFineGrainTowerEEHandler.h.

Constructor & Destructor Documentation

popcon::EcalTPGFineGrainTowerEEHandler::EcalTPGFineGrainTowerEEHandler ( edm::ParameterSet const &  ps)

Definition at line 13 of file EcalTPGFineGrainTowerEEHandler.cc.

References edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_runtype, m_sid, m_user, and AlCaHLTBitMon_QueryRunRegistry::string.

14  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGFineGrainTowerEEHandler")) {
15  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "EcalTPGFineGrainTowerEE Source handler constructor.";
16  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
17  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
18  m_sid = ps.getParameter<std::string>("OnlineDBSID");
19  m_user = ps.getParameter<std::string>("OnlineDBUser");
20  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
21  m_locationsource = ps.getParameter<std::string>("LocationSource");
22  m_location = ps.getParameter<std::string>("Location");
23  m_gentag = ps.getParameter<std::string>("GenTag");
24  m_runtype = ps.getParameter<std::string>("RunType");
25 
26  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << m_sid << "/" << m_user << "/" << m_location << "/" << m_gentag;
27 }
Log< level::Info, false > LogInfo
popcon::EcalTPGFineGrainTowerEEHandler::~EcalTPGFineGrainTowerEEHandler ( )
override

Definition at line 29 of file EcalTPGFineGrainTowerEEHandler.cc.

29 {}

Member Function Documentation

void popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >.

Definition at line 31 of file EcalTPGFineGrainTowerEEHandler.cc.

References gather_cfg::cout, dat, writedatasetfile::dataset, alignCSCRings::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), FEConfigMainInfo::getFgrId(), EcalLogicID::getID1(), EcalLogicID::getID2(), FEConfigFgrEETowerDat::getLUTValue(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), test_db_connect::my_locdef, test_db_connect::my_rundef, EcalLogicID::NULLID, AlCaHLTBitMon_ParallelJobs::p, l1tpf_impl::readFromFile(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigFgrInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGFineGrainTowerEE::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

31  {
32  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Started GetNewObjects!!!";
33 
34  //check whats already inside of database
35  if (tagInfo().size) {
36  //check whats already inside of database
37  std::cout << "got offlineInfo = " << std::endl;
38  std::cout << "tag name = " << tagInfo().name << std::endl;
39  std::cout << "size = " << tagInfo().size << std::endl;
40  } else {
41  std::cout << " First object for this tag " << std::endl;
42  }
43 
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();
48 
49  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "retrieved last payload ";
50 
51  // here we retrieve all the runs after the last from online DB
52  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Retrieving run list from ONLINE DB ... ";
53 
54  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Making connection...";
56  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Done.";
57 
58  if (!econn) {
59  std::cout << " connection parameters " << m_sid << "/" << m_user << std::endl;
60  // cerr << e.what() << std::endl;
61  throw cms::Exception("OMDS not available");
62  }
63 
65  my_locdef.setLocation(m_location);
66 
68  my_rundef.setRunType(m_runtype);
69 
70  RunTag my_runtag;
71  my_runtag.setLocationDef(my_locdef);
72  my_runtag.setRunTypeDef(my_rundef);
73  my_runtag.setGeneralTag(m_gentag);
74 
75  readFromFile("last_tpg_fgrTTEE_settings.txt");
76 
77  unsigned int min_run;
78 
79  if (m_firstRun < m_i_run_number) {
80  min_run = m_i_run_number + 1;
81  } else {
82  min_run = m_firstRun;
83  }
84  if (min_run < max_since) {
85  min_run = max_since + 1; // we have to add 1 to the last transferred one
86  }
87 
88  std::cout << "m_i_run_number" << m_i_run_number << "m_firstRun " << m_firstRun << "max_since " << max_since
89  << std::endl;
90 
91  unsigned int max_run = m_lastRun;
92  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "min_run= " << min_run << " max_run= " << max_run;
93 
94  RunList my_list;
95  my_list = econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
96  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
97 
98  std::vector<RunIOV> run_vec = my_list.getRuns();
99  size_t num_runs = run_vec.size();
100 
101  std::cout << "number of runs is : " << num_runs << std::endl;
102 
103  unsigned int irun;
104  if (num_runs > 0) {
105  // going to query the ecal logic id
106  std::vector<EcalLogicID> my_TTEcalLogicId_EE;
107  my_TTEcalLogicId_EE = econn->getEcalLogicIDSetOrdered(
108  "EE_trigger_tower", 1, 200, 1, 70, EcalLogicID::NULLID, EcalLogicID::NULLID, "EE_offline_towerid", 12);
109  std::cout << " GOT the logic ID for the EE trigger towers " << std::endl;
110 
111  for (size_t kr = 0; kr < run_vec.size(); kr++) {
112  irun = static_cast<unsigned int>(run_vec[kr].getRunNumber());
113 
114  std::cout << " **************** " << std::endl;
115  std::cout << " **************** " << std::endl;
116  std::cout << " run= " << irun << std::endl;
117 
118  // retrieve the data
119  std::map<EcalLogicID, RunTPGConfigDat> dataset;
120  econn->fetchDataSet(&dataset, &run_vec[kr]);
121 
122  std::string the_config_tag = "";
123  int the_config_version = 0;
124 
125  std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
126 
127  int nr = 0;
128  for (it = dataset.begin(); it != dataset.end(); it++) {
129  ++nr;
130  EcalLogicID ecalid = it->first;
131  RunTPGConfigDat dat = it->second;
132  the_config_tag = dat.getConfigTag();
133  the_config_version = dat.getVersion();
134  }
135 
136  // it is all the same for all SM... get the last one
137 
138  std::cout << " run= " << irun << " tag " << the_config_tag << " version=" << the_config_version << std::endl;
139 
140  // here we should check if it is the same as previous run.
141 
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"
144  << std::endl;
145 
146  FEConfigMainInfo fe_main_info;
147  fe_main_info.setConfigTag(the_config_tag);
148  fe_main_info.setVersion(the_config_version);
149 
150  try {
151  std::cout << " before fetch config set" << std::endl;
152  econn->fetchConfigSet(&fe_main_info);
153  std::cout << " after fetch config set" << std::endl;
154 
155  // now get TPGFineGrainTowerEE
156  int fgrId = fe_main_info.getFgrId();
157 
158  if (fgrId != m_i_fgrTTEE) {
159  FEConfigFgrInfo fe_fgr_info;
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);
165 
166  typedef std::map<EcalLogicID, FEConfigFgrEETowerDat>::const_iterator CIfefgr;
167  EcalLogicID ecid_xt;
168  FEConfigFgrEETowerDat rd_fgr;
169  int itowers = 0;
170 
171  for (CIfefgr p = dataset_TpgFineGrainEE.begin(); p != dataset_TpgFineGrainEE.end(); p++) {
172  ecid_xt = p->first;
173  rd_fgr = p->second;
174 
175  std::string ecid_name = ecid_xt.getName();
176 
177  if (ecid_name == "EE_trigger_tower") {
178  int tccid = ecid_xt.getID1();
179  // TT number
180  int towerid = ecid_xt.getID2();
181 
182  bool set_the_tower = false;
183  int towid;
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;
190  break;
191  }
192  }
193  }
194 
195  if (set_the_tower) {
196  fgrMap->setValue(towid, rd_fgr.getLUTValue());
197 
198  } else {
199  std::cout << " these may be the additional towers TCC/TT " << tccid << "/" << towerid << std::endl;
200  }
201 
202  ++itowers;
203  }
204  }
205 
206  Time_t snc = (Time_t)irun;
207 
208  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainTowerEE *)fgrMap, snc));
209 
210  m_i_run_number = irun;
211  m_i_tag = the_config_tag;
212  m_i_version = the_config_version;
213  m_i_fgrTTEE = fgrId;
214 
215  writeFile("last_tpg_fgrTTEE_settings.txt");
216 
217  } else {
218  m_i_run_number = irun;
219  m_i_tag = the_config_tag;
220  m_i_version = the_config_version;
221 
222  writeFile("last_tpg_fgrTTEE_settings.txt");
223 
224  std::cout << " even if the tag/version is not the same, the fgrTTEE id is the same -> no transfer needed "
225  << std::endl;
226  }
227 
228  } catch (std::exception &e) {
229  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
230  << std::endl;
231  std::cout << e.what() << std::endl;
232  m_i_run_number = irun;
233  }
234  std::cout << " **************** " << std::endl;
235 
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;
240  } else {
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");
247  }
248  }
249  }
250 
251  delete econn;
252  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Ecal - > end of getNewObjects -----------";
253 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:42
std::vector< RunIOV > getRuns()
Definition: RunList.cc:25
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
std::string getConfigTag() const
Iov_t lastInterval
Definition: Types.h:73
int getVersion() const
Definition: RunTag.h:13
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
void fetchConfigSet(ICONF *iconf) noexcept(false)
void setVersion(int id)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
std::string name
Definition: Types.h:72
int getID2() const
Definition: EcalLogicID.cc:32
std::string getName() const
Definition: EcalLogicID.cc:26
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
std::vector< std::pair< EcalTPGFineGrainTowerEE *, Time_t > > m_to_transfer
int getID1() const
Definition: EcalLogicID.cc:30
void setValue(const uint32_t &id, const uint32_t &lut)
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:33
void setId(int id)
Log< level::Info, false > LogInfo
int getFgrId() const
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:21
static std::vector< std::string > checklist dat
std::unique_ptr< EcalTPGFineGrainTowerEE > Ref
void setConfigTag(std::string x)
Definition: IODConfig.h:29
static const int NULLID
Definition: EcalLogicID.h:35
void setLocation(std::string loc)
Definition: LocationDef.cc:20
tuple cout
Definition: gather_cfg.py:144
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24
tuple size
Write out results.
std::string popcon::EcalTPGFineGrainTowerEEHandler::id ( ) const
inlineoverridevirtual
std::map<std::string, int> popcon::EcalTPGFineGrainTowerEEHandler::makeTTEEDetId ( )
void popcon::EcalTPGFineGrainTowerEEHandler::readFromFile ( const char *  inputFile)

Definition at line 255 of file EcalTPGFineGrainTowerEEHandler.cc.

References writeEcalDQMStatus::inputFile, geometryCSVtoXML::line, str, and cond::impl::to_string().

255  {
256  //-------------------------------------------------------------
257 
258  m_i_tag = "";
259  m_i_version = 0;
260  m_i_run_number = 0;
261  m_i_fgrTTEE = 0;
262 
263  FILE *inpFile; // input file
264  inpFile = fopen(inputFile, "r");
265  if (!inpFile) {
266  edm::LogError("EcalTPGFineGrainTowerEEHandler") << "*** Can not open file: " << inputFile;
267  return;
268  }
269 
270  char line[256];
271 
272  std::ostringstream str;
273 
274  fgets(line, 255, inpFile);
275  m_i_tag = to_string(line);
276  str << "gen tag " << m_i_tag << std::endl; // should I use this?
277 
278  fgets(line, 255, inpFile);
279  m_i_version = atoi(line);
280  str << "version= " << m_i_version << std::endl;
281 
282  fgets(line, 255, inpFile);
283  m_i_run_number = atoi(line);
284  str << "run_number= " << m_i_run_number << std::endl;
285 
286  fgets(line, 255, inpFile);
287  m_i_fgrTTEE = atoi(line);
288  str << "fgrTTEE_config= " << m_i_fgrTTEE << std::endl;
289 
290  fclose(inpFile); // close inp. file
291 }
Log< level::Error, false > LogError
#define str(s)
std::string popcon::EcalTPGFineGrainTowerEEHandler::to_string ( char  value[])
inlineprivate

Definition at line 63 of file EcalTPGFineGrainTowerEEHandler.h.

References relativeConstraints::value.

63  {
64  std::ostringstream streamOut;
65  streamOut << value;
66  return streamOut.str();
67  }
void popcon::EcalTPGFineGrainTowerEEHandler::writeFile ( const char *  inputFile)

Definition at line 293 of file EcalTPGFineGrainTowerEEHandler.cc.

293  {
294  //-------------------------------------------------------------
295 
296  std::ofstream myfile;
297  myfile.open(inputFile);
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;
302 
303  myfile.close();
304 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGFineGrainTowerEEHandler::econn

Definition at line 60 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_firstRun
private

Definition at line 69 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_gentag
private

Definition at line 74 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_fgrTTEE
private

Definition at line 85 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_i_run_number
private

Definition at line 84 of file EcalTPGFineGrainTowerEEHandler.h.

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_i_tag
private

Definition at line 82 of file EcalTPGFineGrainTowerEEHandler.h.

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_version
private

Definition at line 83 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_lastRun
private

Definition at line 70 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_location
private

Definition at line 73 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_locationsource
private

Definition at line 78 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_name
private

Definition at line 79 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by id().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_pass
private

Definition at line 77 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_runnr
private

Definition at line 80 of file EcalTPGFineGrainTowerEEHandler.h.

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_runtype
private

Definition at line 81 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_sid
private

Definition at line 75 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::string popcon::EcalTPGFineGrainTowerEEHandler::m_user
private

Definition at line 76 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

std::map<std::string, int> popcon::EcalTPGFineGrainTowerEEHandler::mapDetEEId
private

Definition at line 71 of file EcalTPGFineGrainTowerEEHandler.h.