CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
popcon::EcalTPGFineGrainEBGroupHandler Class Reference

#include <EcalTPGFineGrainEBGroupHandler.h>

Inheritance diagram for popcon::EcalTPGFineGrainEBGroupHandler:
popcon::PopConSourceHandler< EcalTPGFineGrainEBGroup >

Public Member Functions

 EcalTPGFineGrainEBGroupHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
std::map< std::string, int > makeTTEBDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGFineGrainEBGroupHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainEBGroup >
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_fgrGroup
 
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 > mapDetEBId
 

Additional Inherited Members

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

Detailed Description

Definition at line 44 of file EcalTPGFineGrainEBGroupHandler.h.

Constructor & Destructor Documentation

◆ EcalTPGFineGrainEBGroupHandler()

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

Definition at line 22 of file EcalTPGFineGrainEBGroupHandler.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.

23  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGFineGrainEBGroupHandler")) {
24  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "EcalTPGFineGrainEBGroup Source handler constructor.";
25  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
26  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
27  m_sid = ps.getParameter<std::string>("OnlineDBSID");
28  m_user = ps.getParameter<std::string>("OnlineDBUser");
29  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
30  m_locationsource = ps.getParameter<std::string>("LocationSource");
31  m_location = ps.getParameter<std::string>("Location");
32  m_gentag = ps.getParameter<std::string>("GenTag");
33  m_runtype = ps.getParameter<std::string>("RunType");
34 
35  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << m_sid << "/" << m_user << "/" << m_location << "/" << m_gentag;
36 }
Log< level::Info, false > LogInfo

◆ ~EcalTPGFineGrainEBGroupHandler()

popcon::EcalTPGFineGrainEBGroupHandler::~EcalTPGFineGrainEBGroupHandler ( )
override

Definition at line 38 of file EcalTPGFineGrainEBGroupHandler.cc.

38 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainEBGroup >.

Definition at line 40 of file EcalTPGFineGrainEBGroupHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), FEConfigFgrDat::getFgrGroupId(), FEConfigMainInfo::getFgrId(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), l1ctLayer2EG_cff::id, test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigFgrInfo::setId(), RunTag::setLocationDef(), RunTag::setRunTypeDef(), EcalTPGGroups::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, EBDetId::SMCRYSTALMODE, mps_setup::stdout, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

40  {
41  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "Started GetNewObjects!!!";
42 
43  //check whats already inside of database
44  if (tagInfo().size) {
45  //check whats already inside of database
46  std::cout << "got offlineInfo = " << std::endl;
47  std::cout << "tag name = " << tagInfo().name << std::endl;
48  std::cout << "size = " << tagInfo().size << std::endl;
49  } else {
50  std::cout << " First object for this tag " << std::endl;
51  }
52 
53  unsigned int max_since = 0;
54  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
55  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "max_since : " << max_since;
56  Ref fgrGroup_db = lastPayload();
57 
58  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "retrieved last payload ";
59 
60  // here we retrieve all the runs after the last from online DB
61  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "Retrieving run list from ONLINE DB ... ";
62 
63  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "Making connection...";
65  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "Done.";
66 
67  if (!econn) {
68  std::cout << " connection parameters " << m_sid << "/" << m_user << std::endl;
69  // cerr << e.what() << std::endl;
70  throw cms::Exception("OMDS not available");
71  }
72 
74  my_locdef.setLocation(m_location);
75 
77  my_rundef.setRunType(m_runtype);
78 
79  RunTag my_runtag;
80  my_runtag.setLocationDef(my_locdef);
81  my_runtag.setRunTypeDef(my_rundef);
82  my_runtag.setGeneralTag(m_gentag);
83 
84  readFromFile("last_tpg_fgrGroup_settings.txt");
85 
86  unsigned int min_run;
87 
88  if (m_firstRun < m_i_run_number) {
89  min_run = m_i_run_number + 1;
90  } else {
91  min_run = m_firstRun;
92  }
93  if (min_run < max_since) {
94  min_run = max_since + 1; // we have to add 1 to the last transferred one
95  }
96 
97  std::cout << "m_i_run_number" << m_i_run_number << "m_firstRun " << m_firstRun << "max_since " << max_since
98  << std::endl;
99 
100  unsigned int max_run = m_lastRun;
101  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "min_run= " << min_run << " max_run= " << max_run;
102 
103  RunList my_list;
104  my_list = econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
105  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
106  printf("after fetchRunList\n");
107  fflush(stdout);
108 
109  std::vector<RunIOV> run_vec = my_list.getRuns();
110  size_t num_runs = run_vec.size();
111 
112  std::cout << "number of runs is : " << num_runs << std::endl;
113 
114  unsigned int irun;
115  if (num_runs > 0) {
116  for (size_t kr = 0; kr < run_vec.size(); kr++) {
117  irun = static_cast<unsigned int>(run_vec[kr].getRunNumber());
118 
119  std::cout << " **************** " << std::endl;
120  std::cout << " **************** " << std::endl;
121  std::cout << " run= " << irun << std::endl;
122 
123  // retrieve the data
124  std::map<EcalLogicID, RunTPGConfigDat> dataset;
125  econn->fetchDataSet(&dataset, &run_vec[kr]);
126 
127  std::string the_config_tag = "";
128  int the_config_version = 0;
129 
130  std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
131 
132  int nr = 0;
133  for (it = dataset.begin(); it != dataset.end(); it++) {
134  ++nr;
135  //EcalLogicID ecalid = it->first;
136  RunTPGConfigDat dat = it->second;
137  the_config_tag = dat.getConfigTag();
138  the_config_version = dat.getVersion();
139  }
140 
141  // it is all the same for all SM... get the last one
142 
143  std::cout << " run= " << irun << " tag " << the_config_tag << " version=" << the_config_version << std::endl;
144 
145  // here we should check if it is the same as previous run.
146 
147  if ((the_config_tag != m_i_tag || the_config_version != m_i_version) && nr > 0) {
148  std::cout << "the tag is different from last transferred run ... retrieving last config set from DB"
149  << std::endl;
150 
151  FEConfigMainInfo fe_main_info;
152  fe_main_info.setConfigTag(the_config_tag);
153  fe_main_info.setVersion(the_config_version);
154 
155  try {
156  std::cout << " before fetch config set" << std::endl;
157  econn->fetchConfigSet(&fe_main_info);
158  std::cout << " after fetch config set" << std::endl;
159 
160  // now get TPGFineGrainEBGroup
161  int fgrId = fe_main_info.getFgrId();
162 
163  if (fgrId != m_i_fgrGroup) {
164  FEConfigFgrInfo fe_fgr_info;
165  fe_fgr_info.setId(fgrId);
166  econn->fetchConfigSet(&fe_fgr_info);
167  std::map<EcalLogicID, FEConfigFgrDat> dataset_TpgFineGrainEB;
168  econn->fetchDataSet(&dataset_TpgFineGrainEB, &fe_fgr_info);
169 
171  typedef std::map<EcalLogicID, FEConfigFgrDat>::const_iterator CIfefgr;
172  EcalLogicID ecid_xt;
173  FEConfigFgrDat rd_fgr;
174  int itowers = 0;
175 
176  for (CIfefgr p = dataset_TpgFineGrainEB.begin(); p != dataset_TpgFineGrainEB.end(); p++) {
177  ecid_xt = p->first;
178  rd_fgr = p->second;
179 
180  std::string ecid_name = ecid_xt.getName();
181 
182  if (ecid_name == "EB_trigger_tower") {
183  // SM number
184  int smid = ecid_xt.getID1();
185  // TT number
186  int towerid = ecid_xt.getID2();
187 
188  /*
189  char identTT[10];
190  sprintf(identTT,"%d%d", smid, towerid);
191 
192  std::string S="";
193  S.insert(0,identTT);
194 
195  unsigned int towerEBId = 0;
196  towerEBId = atoi(S.c_str());
197 
198  */
199 
200  int tow_eta = (towerid - 1) / 4;
201  int tow_phi = ((towerid - 1) - tow_eta * 4);
202 
203  int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
204 
205  EBDetId id(smid, axt, EBDetId::SMCRYSTALMODE);
206  const EcalTrigTowerDetId towid = id.tower();
207 
208  fgrMap->setValue(towid.rawId(), rd_fgr.getFgrGroupId());
209  ++itowers;
210  }
211  }
212 
213  Time_t snc = (Time_t)irun;
214 
215  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainEBGroup *)fgrMap, snc));
216 
217  m_i_run_number = irun;
218  m_i_tag = the_config_tag;
219  m_i_version = the_config_version;
220  m_i_fgrGroup = fgrId;
221 
222  writeFile("last_tpg_fgrGroup_settings.txt");
223 
224  } else {
225  m_i_run_number = irun;
226  m_i_tag = the_config_tag;
227  m_i_version = the_config_version;
228 
229  writeFile("last_tpg_fgrGroup_settings.txt");
230 
231  std::cout << " even if the tag/version is not the same, the fgrGroup id is the same -> no transfer needed "
232  << std::endl;
233  }
234 
235  }
236 
237  catch (std::exception &e) {
238  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
239  << std::endl;
240  std::cout << e.what() << std::endl;
241  m_i_run_number = irun;
242  }
243  std::cout << " **************** " << std::endl;
244 
245  } else if (nr == 0) {
246  m_i_run_number = irun;
247  std::cout << " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
248  std::cout << " **************** " << std::endl;
249  } else {
250  m_i_run_number = irun;
251  m_i_tag = the_config_tag;
252  m_i_version = the_config_version;
253  std::cout << " the tag/version is the same -> no transfer needed " << std::endl;
254  std::cout << " **************** " << std::endl;
255  writeFile("last_tpg_fgrGroup_settings.txt");
256  }
257  }
258  }
259 
260  delete econn;
261  edm::LogInfo("EcalTPGFineGrainEBGroupHandler") << "Ecal - > end of getNewObjects -----------";
262 }
size
Write out results.
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< std::pair< EcalTPGFineGrainEBGroup *, Time_t > > m_to_transfer
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
Definition: EcalTPGGroups.cc:7
int getFgrGroupId() const
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:33
void setId(int id)
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::string getConfigTag() const
std::unique_ptr< EcalTPGFineGrainEBGroup > Ref
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24
static const int SMCRYSTALMODE
Definition: EBDetId.h:159

◆ id()

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

◆ makeTTEBDetId()

std::map<std::string, int> popcon::EcalTPGFineGrainEBGroupHandler::makeTTEBDetId ( )

◆ readFromFile()

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

Definition at line 264 of file EcalTPGFineGrainEBGroupHandler.cc.

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

264  {
265  //-------------------------------------------------------------
266 
267  m_i_tag = "";
268  m_i_version = 0;
269  m_i_run_number = 0;
270  m_i_fgrGroup = 0;
271 
272  FILE *inpFile; // input file
273  inpFile = fopen(inputFile, "r");
274  if (!inpFile) {
275  edm::LogError("EcalTPGFineGrainEBGroupHandler") << "*** Can not open file: " << inputFile;
276  return;
277  }
278 
279  char line[256];
280 
281  std::ostringstream str;
282 
283  fgets(line, 255, inpFile);
285  str << "gen tag " << m_i_tag << std::endl; // should I use this?
286 
287  fgets(line, 255, inpFile);
288  m_i_version = atoi(line);
289  str << "version= " << m_i_version << std::endl;
290 
291  fgets(line, 255, inpFile);
292  m_i_run_number = atoi(line);
293  str << "run_number= " << m_i_run_number << std::endl;
294 
295  fgets(line, 255, inpFile);
296  m_i_fgrGroup = atoi(line);
297  str << "fgrGroup_config= " << m_i_fgrGroup << std::endl;
298 
299  fclose(inpFile); // close inp. file
300 }
Log< level::Error, false > LogError
#define str(s)

◆ to_string()

std::string popcon::EcalTPGFineGrainEBGroupHandler::to_string ( char  value[])
inlineprivate

Definition at line 61 of file EcalTPGFineGrainEBGroupHandler.h.

References relativeConstraints::value.

61  {
62  std::ostringstream streamOut;
63  streamOut << value;
64  return streamOut.str();
65  }

◆ writeFile()

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

Definition at line 302 of file EcalTPGFineGrainEBGroupHandler.cc.

References makeListRunsInFiles::inputFile.

302  {
303  //-------------------------------------------------------------
304 
305  std::ofstream myfile;
306  myfile.open(inputFile);
307  myfile << m_i_tag << std::endl;
308  myfile << m_i_version << std::endl;
309  myfile << m_i_run_number << std::endl;
310  myfile << m_i_fgrGroup << std::endl;
311 
312  myfile.close();
313 }

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalTPGFineGrainEBGroupHandler::econn

Definition at line 58 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_firstRun
private

Definition at line 67 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_gentag

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_gentag
private

Definition at line 72 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_i_fgrGroup

int popcon::EcalTPGFineGrainEBGroupHandler::m_i_fgrGroup
private

Definition at line 83 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_i_run_number

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_i_run_number
private

Definition at line 82 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_i_tag

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_i_tag
private

Definition at line 80 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_i_version

int popcon::EcalTPGFineGrainEBGroupHandler::m_i_version
private

Definition at line 81 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_lastRun
private

Definition at line 68 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_location

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_location
private

Definition at line 71 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_locationsource

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_locationsource
private

Definition at line 76 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_name

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_name
private

Definition at line 77 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by id().

◆ m_pass

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_pass
private

Definition at line 75 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_runnr

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_runnr
private

Definition at line 78 of file EcalTPGFineGrainEBGroupHandler.h.

◆ m_runtype

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_runtype
private

Definition at line 79 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_sid

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_sid
private

Definition at line 73 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ m_user

std::string popcon::EcalTPGFineGrainEBGroupHandler::m_user
private

Definition at line 74 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

◆ mapDetEBId

std::map<std::string, int> popcon::EcalTPGFineGrainEBGroupHandler::mapDetEBId
private

Definition at line 69 of file EcalTPGFineGrainEBGroupHandler.h.