CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
std::string id () const
 
std::map< std::string, int > makeTTEBDetId ()
 
std::map< std::string, int > makeTTEEDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGSpikeThresholdHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGSpike >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
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 ()
 
void sort ()
 
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::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGSpike *, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGSpike
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGSpike value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGSpike >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGSpike >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 52 of file EcalTPGSpikeThresholdHandler.h.

Constructor & Destructor Documentation

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

Definition at line 42 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.

43  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGSpikeThresholdHandler")) {
44 
45  edm::LogInfo("EcalTPGSpikeThresholdHandler") << "EcalTPGSpike Source handler constructor";
46  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
47  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
48  m_sid= ps.getParameter<std::string>("OnlineDBSID");
49  m_user= ps.getParameter<std::string>("OnlineDBUser");
50  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
51  m_locationsource= ps.getParameter<std::string>("LocationSource");
52  m_location=ps.getParameter<std::string>("Location");
53  m_gentag=ps.getParameter<std::string>("GenTag");
54  m_runtype=ps.getParameter<std::string>("RunType");
55 
56  edm::LogInfo("EcalTPGSpikeThresholdHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
57 }
popcon::EcalTPGSpikeThresholdHandler::~EcalTPGSpikeThresholdHandler ( )

Definition at line 59 of file EcalTPGSpikeThresholdHandler.cc.

60 {
61 }

Member Function Documentation

void popcon::EcalTPGSpikeThresholdHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGSpike >.

Definition at line 64 of file EcalTPGSpikeThresholdHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getName(), RunList::getRuns(), FEConfigMainInfo::getSpiId(), FEConfigSpikeDat::getSpikeThreshold(), RunTPGConfigDat::getVersion(), lumiPlot::lut, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), FEConfigSpikeInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), EcalTPGSpike::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, EBDetId::SMCRYSTALMODE, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

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

Definition at line 302 of file EcalTPGSpikeThresholdHandler.cc.

References analyzePatCleaning_cfg::inputFile, geometryCSVtoXML::line, and cond::to_string().

302  {
303  //-------------------------------------------------------------
304 
305  m_i_tag="";
306  m_i_version=0;
307  m_i_run_number=0;
308  m_i_spikeTh=0;
309 
310  FILE *inpFile; // input file
311  inpFile = fopen(inputFile,"r");
312  if(!inpFile) {
313  edm::LogError("EcalTPGSpikeThresholdHandler")<<"*** Can not open file: "<<inputFile;
314  }
315 
316  char line[256];
317 
318  std::ostringstream str;
319 
320  fgets(line,255,inpFile);
321  m_i_tag=to_string(line);
322  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
323 
324  fgets(line,255,inpFile);
325  m_i_version=atoi(line);
326  str << "version= " << m_i_version << std::endl ;
327 
328  fgets(line,255,inpFile);
329  m_i_run_number=atoi(line);
330  str << "run_number= " << m_i_run_number << std::endl ;
331 
332  fgets(line,255,inpFile);
333  m_i_spikeTh=atoi(line);
334  str << "spikeTh_config= " << m_i_spikeTh << std::endl ;
335 
336 
337  fclose(inpFile); // close inp. file
338 
339 }
std::string popcon::EcalTPGSpikeThresholdHandler::to_string ( char  value[])
inlineprivate

Definition at line 72 of file EcalTPGSpikeThresholdHandler.h.

References relativeConstraints::value.

72  {
73  std::ostringstream streamOut;
74  streamOut << value;
75  return streamOut.str();
76  }
void popcon::EcalTPGSpikeThresholdHandler::writeFile ( const char *  inputFile)

Definition at line 341 of file EcalTPGSpikeThresholdHandler.cc.

Referenced by Vispa.Main.TabController.TabController::save().

341  {
342  //-------------------------------------------------------------
343 
344 
345  std::ofstream myfile;
346  myfile.open (inputFile);
347  myfile << m_i_tag <<std::endl;
348  myfile << m_i_version <<std::endl;
349  myfile << m_i_run_number <<std::endl;
350  myfile << m_i_spikeTh <<std::endl;
351 
352  myfile.close();
353 
354 }

Member Data Documentation

const EcalElectronicsMapping* popcon::EcalTPGSpikeThresholdHandler::ecalMapping_
private

Definition at line 84 of file EcalTPGSpikeThresholdHandler.h.

EcalCondDBInterface* popcon::EcalTPGSpikeThresholdHandler::econn

Definition at line 69 of file EcalTPGSpikeThresholdHandler.h.

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_firstRun
private

Definition at line 79 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 87 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_i_run_number
private

Definition at line 97 of file EcalTPGSpikeThresholdHandler.h.

int popcon::EcalTPGSpikeThresholdHandler::m_i_spikeTh
private

Definition at line 98 of file EcalTPGSpikeThresholdHandler.h.

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

Definition at line 95 of file EcalTPGSpikeThresholdHandler.h.

int popcon::EcalTPGSpikeThresholdHandler::m_i_version
private

Definition at line 96 of file EcalTPGSpikeThresholdHandler.h.

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_lastRun
private

Definition at line 80 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 86 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 91 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 92 of file EcalTPGSpikeThresholdHandler.h.

Referenced by id().

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

Definition at line 90 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

unsigned int popcon::EcalTPGSpikeThresholdHandler::m_runnr
private

Definition at line 93 of file EcalTPGSpikeThresholdHandler.h.

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

Definition at line 94 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 88 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 89 of file EcalTPGSpikeThresholdHandler.h.

Referenced by EcalTPGSpikeThresholdHandler().

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

Definition at line 81 of file EcalTPGSpikeThresholdHandler.h.

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

Definition at line 82 of file EcalTPGSpikeThresholdHandler.h.

const EcalTPGSpike* popcon::EcalTPGSpikeThresholdHandler::mySpikeTh
private

Definition at line 78 of file EcalTPGSpikeThresholdHandler.h.