CMS 3D CMS Logo

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

#include <EcalTPGSpikeThresholdHandler.h>

Inheritance diagram for popcon::EcalTPGSpikeThresholdHandler:
popcon::PopConSourceHandler< EcalTPGSpike >

Public Member Functions

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

const EcalElectronicsMappingecalMapping_
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_i_run_number
 
int m_i_spikeTh
 
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
 
std::map< std::string, int > mapDetEEId
 
const EcalTPGSpikemySpikeTh
 

Additional Inherited Members

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

Detailed Description

Definition at line 48 of file EcalTPGSpikeThresholdHandler.h.

Constructor & Destructor Documentation

◆ EcalTPGSpikeThresholdHandler()

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

Definition at line 37 of file EcalTPGSpikeThresholdHandler.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.

38  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGSpikeThresholdHandler")) {
39  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "EcalTPGSpike Source handler constructor";
40  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
41  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
42  m_sid = ps.getParameter<std::string>("OnlineDBSID");
43  m_user = ps.getParameter<std::string>("OnlineDBUser");
44  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
45  m_locationsource = ps.getParameter<std::string>("LocationSource");
46  m_location = ps.getParameter<std::string>("Location");
47  m_gentag = ps.getParameter<std::string>("GenTag");
48  m_runtype = ps.getParameter<std::string>("RunType");
49 
50  edm::LogInfo("EcalTPGSpikeThresholdHandler") << m_sid << "/" << m_user << "/" << m_location << "/" << m_gentag;
51 }
Log< level::Info, false > LogInfo

◆ ~EcalTPGSpikeThresholdHandler()

popcon::EcalTPGSpikeThresholdHandler::~EcalTPGSpikeThresholdHandler ( )
override

Definition at line 53 of file EcalTPGSpikeThresholdHandler.cc.

53 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGSpikeThresholdHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGSpike >.

Definition at line 55 of file EcalTPGSpikeThresholdHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getName(), RunList::getRuns(), FEConfigMainInfo::getSpiId(), FEConfigSpikeDat::getSpikeThreshold(), RunTPGConfigDat::getVersion(), l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigSpikeInfo::setId(), RunTag::setLocationDef(), RunTag::setRunTypeDef(), EcalTPGSpike::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, EBDetId::SMCRYSTALMODE, str, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

55  {
56  using namespace edm;
57  using namespace std;
58 
59  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "Started GetNewObjects!!!";
60 
61  //check whats already inside of database
62  if (tagInfo().size) {
63  //check whats already inside of database
64  std::cout << "got offlineInfo = " << std::endl;
65  std::cout << "tag name = " << tagInfo().name << std::endl;
66  std::cout << "size = " << tagInfo().size << std::endl;
67  } else {
68  std::cout << " First object for this tag " << std::endl;
69  }
70 
71  unsigned int max_since = 0;
72  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
73  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "max_since : " << max_since;
74  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "retrieved last payload ";
75 
76  // here we retrieve all the runs after the last from online DB
77  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "Retrieving run list from ONLINE DB ... ";
78 
79  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "Making connection...";
81  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "Done.";
82 
83  if (!econn) {
84  std::cout << " connection parameters " << m_sid << "/" << m_user << std::endl;
85  // cerr << e.what() << std::endl;
86  throw cms::Exception("OMDS not available");
87  }
88 
90  my_locdef.setLocation(m_location);
91 
93  my_rundef.setRunType(m_runtype);
94 
95  RunTag my_runtag;
96  my_runtag.setLocationDef(my_locdef);
97  my_runtag.setRunTypeDef(my_rundef);
98  my_runtag.setGeneralTag(m_gentag);
99 
100  readFromFile("last_tpg_spikeThreshold_settings.txt");
101 
102  unsigned int min_run;
103 
104  if (m_firstRun < m_i_run_number) {
105  min_run = m_i_run_number + 1;
106  } else {
107  min_run = m_firstRun;
108  }
109 
110  if (min_run < max_since) {
111  min_run = max_since + 1; // we have to add 1 to the last transferred one
112  }
113 
114  std::cout << "m_i_run_number" << m_i_run_number << "m_firstRun " << m_firstRun << "max_since " << max_since
115  << std::endl;
116 
117  unsigned int max_run = m_lastRun;
118  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "min_run= " << min_run << " max_run= " << max_run;
119 
120  RunList my_list;
121  my_list = econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
122  //my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
123 
124  std::vector<RunIOV> run_vec = my_list.getRuns();
125  size_t num_runs = run_vec.size();
126 
127  std::cout << "number of runs is : " << num_runs << std::endl;
128 
129  std::string str = "";
130 
131  unsigned int irun;
132  if (num_runs > 0) {
133  for (size_t kr = 0; kr < run_vec.size(); kr++) {
134  irun = static_cast<unsigned int>(run_vec[kr].getRunNumber());
135 
136  std::cout << " **************** " << std::endl;
137  std::cout << " run= " << irun << std::endl;
138 
139  // retrieve the data :
140  std::map<EcalLogicID, RunTPGConfigDat> dataset;
141  econn->fetchDataSet(&dataset, &run_vec[kr]);
142 
143  std::string the_config_tag = "";
144  int the_config_version = 0;
145 
146  std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
147 
148  int nr = 0;
149  for (it = dataset.begin(); it != dataset.end(); it++) {
150  ++nr;
151  //EcalLogicID ecalid = it->first;
152 
153  RunTPGConfigDat dat = it->second;
154  the_config_tag = dat.getConfigTag();
155  the_config_version = dat.getVersion();
156  }
157 
158  // it is all the same for all SM... get the last one
159 
160  std::cout << " run= " << irun << " tag " << the_config_tag << " version=" << the_config_version << std::endl;
161 
162  // here we should check if it is the same as previous run.
163 
164  if ((the_config_tag != m_i_tag || the_config_version != m_i_version) && nr > 0) {
165  std::cout << "the tag is different from last transferred run ... retrieving last config set from DB"
166  << std::endl;
167 
168  FEConfigMainInfo fe_main_info;
169  fe_main_info.setConfigTag(the_config_tag);
170  fe_main_info.setVersion(the_config_version);
171 
172  try {
173  std::cout << " before fetch config set" << std::endl;
174  econn->fetchConfigSet(&fe_main_info);
175  std::cout << " after fetch config set" << std::endl;
176 
177  // now get TPGSpikeThreshold
178  int spikeId = fe_main_info.getSpiId();
179 
180  if (spikeId != m_i_spikeTh) {
181  FEConfigSpikeInfo fe_spike_info;
182  fe_spike_info.setId(spikeId);
183  econn->fetchConfigSet(&fe_spike_info);
184  std::map<EcalLogicID, FEConfigSpikeDat> dataset_TpgSpike;
185  econn->fetchDataSet(&dataset_TpgSpike, &fe_spike_info);
186 
187  EcalTPGSpike *lut = new EcalTPGSpike();
188  typedef std::map<EcalLogicID, FEConfigSpikeDat>::const_iterator CIfelut;
189  EcalLogicID ecid_xt;
190  FEConfigSpikeDat rd_spike;
191  int itowers = 0;
192 
193  for (CIfelut p = dataset_TpgSpike.begin(); p != dataset_TpgSpike.end(); p++) {
194  ecid_xt = p->first;
195  rd_spike = p->second;
196 
197  std::string ecid_name = ecid_xt.getName();
198 
199  if (ecid_name == "EB_trigger_tower") {
200  // SM number
201  int smid = ecid_xt.getID1();
202  // TT number
203  int towerid = ecid_xt.getID2();
204 
205  int tow_eta = (towerid - 1) / 4;
206  int tow_phi = ((towerid - 1) - tow_eta * 4);
207 
208  int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
209 
210  EBDetId id(smid, axt, EBDetId::SMCRYSTALMODE);
211  const EcalTrigTowerDetId towid = id.tower();
212 
213  //std::cout << " TTid = " << towid.rawId() << " SpikeTh = " <<rd_spike.getSpikeThreshold() << std::endl;
214 
215  lut->setValue(towid.rawId(), rd_spike.getSpikeThreshold());
216  ++itowers;
217  }
218  ++itowers;
219  }
220 
221  std::cout << " The number of towers is = " << itowers << std::endl;
222 
223  Time_t snc = (Time_t)irun;
224 
225  m_to_transfer.push_back(std::make_pair((EcalTPGSpike *)lut, snc));
226 
227  m_i_run_number = irun;
228  m_i_tag = the_config_tag;
229  m_i_version = the_config_version;
230  m_i_spikeTh = spikeId;
231 
232  writeFile("last_tpg_spikeThreshold_settings.txt");
233 
234  } else {
235  m_i_run_number = irun;
236  m_i_tag = the_config_tag;
237  m_i_version = the_config_version;
238 
239  writeFile("last_tpg_spikeThreshold_settings.txt");
240 
241  std::cout << " even if the tag/version is not the same, the lutGroup id is the same -> no transfer needed "
242  << std::endl;
243  }
244 
245  }
246 
247  catch (std::exception &e) {
248  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
249  << std::endl;
250  std::cout << e.what() << std::endl;
251  m_i_run_number = irun;
252  }
253  std::cout << " **************** " << std::endl;
254 
255  } else if (nr == 0) {
256  m_i_run_number = irun;
257  std::cout << " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
258  std::cout << " **************** " << std::endl;
259  } else {
260  m_i_run_number = irun;
261  m_i_tag = the_config_tag;
262  m_i_version = the_config_version;
263  std::cout << " the tag/version is the same -> no transfer needed " << std::endl;
264  std::cout << " **************** " << std::endl;
265  writeFile("last_tpg_spikeThreshold_settings.txt");
266  }
267  }
268  }
269 
270  delete econn;
271 
272  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "Ecal - > end of getNewObjects -----------";
273 }
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)
int getID1() const
Definition: EcalLogicID.cc:30
Iov_t lastInterval
Definition: Types.h:73
std::string getName() const
Definition: EcalLogicID.cc:26
int getSpiId() const
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)
void setValue(const uint32_t &id, const uint16_t &val)
Definition: EcalTPGSpike.cc:7
std::string name
Definition: Types.h:72
cond::TagInfo_t const & tagInfo() const
std::vector< std::pair< EcalTPGSpike *, Time_t > > m_to_transfer
int getSpikeThreshold() const
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:33
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::string getConfigTag() const
void setConfigTag(std::string x)
Definition: IODConfig.h:29
HLT enums.
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)

◆ id()

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

◆ makeTTEBDetId()

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

◆ makeTTEEDetId()

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

◆ readFromFile()

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

Definition at line 275 of file EcalTPGSpikeThresholdHandler.cc.

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

275  {
276  //-------------------------------------------------------------
277 
278  m_i_tag = "";
279  m_i_version = 0;
280  m_i_run_number = 0;
281  m_i_spikeTh = 0;
282 
283  FILE *inpFile; // input file
284  inpFile = fopen(inputFile, "r");
285  if (!inpFile) {
286  edm::LogError("EcalTPGSpikeThresholdHandler") << "*** Can not open file: " << inputFile;
287  return;
288  }
289 
290  char line[256];
291 
292  std::ostringstream str;
293 
294  fgets(line, 255, inpFile);
296  str << "gen tag " << m_i_tag << std::endl; // should I use this?
297 
298  fgets(line, 255, inpFile);
299  m_i_version = atoi(line);
300  str << "version= " << m_i_version << std::endl;
301 
302  fgets(line, 255, inpFile);
303  m_i_run_number = atoi(line);
304  str << "run_number= " << m_i_run_number << std::endl;
305 
306  fgets(line, 255, inpFile);
307  m_i_spikeTh = atoi(line);
308  str << "spikeTh_config= " << m_i_spikeTh << std::endl;
309 
310  fclose(inpFile); // close inp. file
311 }
Log< level::Error, false > LogError
#define str(s)

◆ to_string()

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

Definition at line 66 of file EcalTPGSpikeThresholdHandler.h.

References relativeConstraints::value.

66  {
67  std::ostringstream streamOut;
68  streamOut << value;
69  return streamOut.str();
70  }

◆ writeFile()

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

Definition at line 313 of file EcalTPGSpikeThresholdHandler.cc.

References makeListRunsInFiles::inputFile.

313  {
314  //-------------------------------------------------------------
315 
316  std::ofstream myfile;
317  myfile.open(inputFile);
318  myfile << m_i_tag << std::endl;
319  myfile << m_i_version << std::endl;
320  myfile << m_i_run_number << std::endl;
321  myfile << m_i_spikeTh << std::endl;
322 
323  myfile.close();
324 }

Member Data Documentation

◆ ecalMapping_

const EcalElectronicsMapping* popcon::EcalTPGSpikeThresholdHandler::ecalMapping_
private

Definition at line 78 of file EcalTPGSpikeThresholdHandler.h.

◆ econn

EcalCondDBInterface* popcon::EcalTPGSpikeThresholdHandler::econn

Definition at line 63 of file EcalTPGSpikeThresholdHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_firstRun
private

Definition at line 73 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_gentag

std::string popcon::EcalTPGSpikeThresholdHandler::m_gentag
private

Definition at line 81 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_i_run_number

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGSpikeThresholdHandler.h.

◆ m_i_spikeTh

int popcon::EcalTPGSpikeThresholdHandler::m_i_spikeTh
private

Definition at line 92 of file EcalTPGSpikeThresholdHandler.h.

◆ m_i_tag

std::string popcon::EcalTPGSpikeThresholdHandler::m_i_tag
private

Definition at line 89 of file EcalTPGSpikeThresholdHandler.h.

◆ m_i_version

int popcon::EcalTPGSpikeThresholdHandler::m_i_version
private

Definition at line 90 of file EcalTPGSpikeThresholdHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_lastRun
private

Definition at line 74 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_location

std::string popcon::EcalTPGSpikeThresholdHandler::m_location
private

Definition at line 80 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_locationsource

std::string popcon::EcalTPGSpikeThresholdHandler::m_locationsource
private

Definition at line 85 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_name

std::string popcon::EcalTPGSpikeThresholdHandler::m_name
private

Definition at line 86 of file EcalTPGSpikeThresholdHandler.h.

Referenced by id().

◆ m_pass

std::string popcon::EcalTPGSpikeThresholdHandler::m_pass
private

Definition at line 84 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_runnr

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_runnr
private

Definition at line 87 of file EcalTPGSpikeThresholdHandler.h.

◆ m_runtype

std::string popcon::EcalTPGSpikeThresholdHandler::m_runtype
private

Definition at line 88 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_sid

std::string popcon::EcalTPGSpikeThresholdHandler::m_sid
private

Definition at line 82 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ m_user

std::string popcon::EcalTPGSpikeThresholdHandler::m_user
private

Definition at line 83 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

◆ mapDetEBId

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

Definition at line 75 of file EcalTPGSpikeThresholdHandler.h.

◆ mapDetEEId

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

Definition at line 76 of file EcalTPGSpikeThresholdHandler.h.

◆ mySpikeTh

const EcalTPGSpike* popcon::EcalTPGSpikeThresholdHandler::mySpikeTh
private

Definition at line 72 of file EcalTPGSpikeThresholdHandler.h.