CMS 3D CMS Logo

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< EcalTPGFineGrainTowerEERef
 
typedef PopConSourceHandler< EcalTPGFineGrainTowerEEself
 
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

◆ EcalTPGFineGrainTowerEEHandler()

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

◆ ~EcalTPGFineGrainTowerEEHandler()

popcon::EcalTPGFineGrainTowerEEHandler::~EcalTPGFineGrainTowerEEHandler ( )
override

Definition at line 29 of file EcalTPGFineGrainTowerEEHandler.cc.

29 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >.

Definition at line 31 of file EcalTPGFineGrainTowerEEHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), FEConfigMainInfo::getFgrId(), EcalLogicID::getID1(), EcalLogicID::getID2(), FEConfigFgrEETowerDat::getLUTValue(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, EcalLogicID::NULLID, AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigFgrInfo::setId(), RunTag::setLocationDef(), 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 
170  for (CIfefgr p = dataset_TpgFineGrainEE.begin(); p != dataset_TpgFineGrainEE.end(); p++) {
171  ecid_xt = p->first;
172  rd_fgr = p->second;
173 
174  std::string ecid_name = ecid_xt.getName();
175 
176  if (ecid_name == "EE_trigger_tower") {
177  int tccid = ecid_xt.getID1();
178  // TT number
179  int towerid = ecid_xt.getID2();
180 
181  bool set_the_tower = false;
182  int towid;
183  for (size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
184  if (!set_the_tower) {
185  if (my_TTEcalLogicId_EE[itower].getID1() == tccid &&
186  my_TTEcalLogicId_EE[itower].getID2() == towerid) {
187  towid = my_TTEcalLogicId_EE[itower].getLogicID();
188  set_the_tower = true;
189  break;
190  }
191  }
192  }
193 
194  if (set_the_tower) {
195  fgrMap->setValue(towid, rd_fgr.getLUTValue());
196 
197  } else {
198  std::cout << " these may be the additional towers TCC/TT " << tccid << "/" << towerid << std::endl;
199  }
200  }
201  }
202 
203  Time_t snc = (Time_t)irun;
204 
205  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainTowerEE *)fgrMap, snc));
206 
207  m_i_run_number = irun;
208  m_i_tag = the_config_tag;
209  m_i_version = the_config_version;
210  m_i_fgrTTEE = fgrId;
211 
212  writeFile("last_tpg_fgrTTEE_settings.txt");
213 
214  } else {
215  m_i_run_number = irun;
216  m_i_tag = the_config_tag;
217  m_i_version = the_config_version;
218 
219  writeFile("last_tpg_fgrTTEE_settings.txt");
220 
221  std::cout << " even if the tag/version is not the same, the fgrTTEE id is the same -> no transfer needed "
222  << std::endl;
223  }
224 
225  } catch (std::exception &e) {
226  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
227  << std::endl;
228  std::cout << e.what() << std::endl;
229  m_i_run_number = irun;
230  }
231  std::cout << " **************** " << std::endl;
232 
233  } else if (nr == 0) {
234  m_i_run_number = irun;
235  std::cout << " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
236  std::cout << " **************** " << std::endl;
237  } else {
238  m_i_run_number = irun;
239  m_i_tag = the_config_tag;
240  m_i_version = the_config_version;
241  std::cout << " the tag/version is the same -> no transfer needed " << std::endl;
242  std::cout << " **************** " << std::endl;
243  writeFile("last_tpg_fgrTTEE_settings.txt");
244  }
245  }
246  }
247 
248  delete econn;
249  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Ecal - > end of getNewObjects -----------";
250 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:42
std::vector< RunIOV > getRuns()
Definition: RunList.cc:25
int getFgrId() const
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
int getID1() const
Definition: EcalLogicID.cc:30
Iov_t lastInterval
Definition: Types.h:73
std::string getName() const
Definition: EcalLogicID.cc:26
Definition: RunTag.h:13
int getID2() const
Definition: EcalLogicID.cc:32
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
int getVersion() const
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
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
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
std::string getConfigTag() const
std::unique_ptr< EcalTPGFineGrainTowerEE > Ref
void setConfigTag(std::string x)
Definition: IODConfig.h:29
static const int NULLID
Definition: EcalLogicID.h:35
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24

◆ id()

std::string popcon::EcalTPGFineGrainTowerEEHandler::id ( ) const
inlineoverridevirtual

◆ makeTTEEDetId()

std::map<std::string, int> popcon::EcalTPGFineGrainTowerEEHandler::makeTTEEDetId ( )

◆ readFromFile()

void popcon::EcalTPGFineGrainTowerEEHandler::readFromFile ( const char *  inputFile)

Definition at line 252 of file EcalTPGFineGrainTowerEEHandler.cc.

References makeListRunsInFiles::inputFile, mps_splice::line, str, and to_string().

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

◆ to_string()

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  }

◆ writeFile()

void popcon::EcalTPGFineGrainTowerEEHandler::writeFile ( const char *  inputFile)

Definition at line 290 of file EcalTPGFineGrainTowerEEHandler.cc.

References makeListRunsInFiles::inputFile.

290  {
291  //-------------------------------------------------------------
292 
293  std::ofstream myfile;
294  myfile.open(inputFile);
295  myfile << m_i_tag << std::endl;
296  myfile << m_i_version << std::endl;
297  myfile << m_i_run_number << std::endl;
298  myfile << m_i_fgrTTEE << std::endl;
299 
300  myfile.close();
301 }

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalTPGFineGrainTowerEEHandler::econn

Definition at line 60 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_firstRun
private

Definition at line 69 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_gentag

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

Definition at line 74 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_i_fgrTTEE

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_fgrTTEE
private

Definition at line 85 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_i_run_number

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_i_run_number
private

Definition at line 84 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_i_tag

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

Definition at line 82 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_i_version

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_version
private

Definition at line 83 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_lastRun
private

Definition at line 70 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_location

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

Definition at line 73 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_locationsource

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

Definition at line 78 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_name

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

Definition at line 79 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by id().

◆ m_pass

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

Definition at line 77 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_runnr

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_runnr
private

Definition at line 80 of file EcalTPGFineGrainTowerEEHandler.h.

◆ m_runtype

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

Definition at line 81 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_sid

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

Definition at line 75 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ m_user

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

Definition at line 76 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

◆ mapDetEEId

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

Definition at line 71 of file EcalTPGFineGrainTowerEEHandler.h.