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::EcalTPGFineGrainTowerEEHandler Class Reference

#include <EcalTPGFineGrainTowerEEHandler.h>

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

Public Member Functions

 EcalTPGFineGrainTowerEEHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
std::map< std::string, int > makeTTEEDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGFineGrainTowerEEHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry 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

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::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGFineGrainTowerEE
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGFineGrainTowerEE
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGFineGrainTowerEE value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 49 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 
16  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "EcalTPGFineGrainTowerEE Source handler constructor.";
17  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
18  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
19  m_sid= ps.getParameter<std::string>("OnlineDBSID");
20  m_user= ps.getParameter<std::string>("OnlineDBUser");
21  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
22  m_locationsource= ps.getParameter<std::string>("LocationSource");
23  m_location=ps.getParameter<std::string>("Location");
24  m_gentag=ps.getParameter<std::string>("GenTag");
25  m_runtype=ps.getParameter<std::string>("RunType");
26 
27  edm::LogInfo("EcalTPGFineGrainTowerEEHandler")<< m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
28 
29 }
popcon::EcalTPGFineGrainTowerEEHandler::~EcalTPGFineGrainTowerEEHandler ( )

Definition at line 31 of file EcalTPGFineGrainTowerEEHandler.cc.

32 {
33 }

Member Function Documentation

void popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainTowerEE >.

Definition at line 35 of file EcalTPGFineGrainTowerEEHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), FEConfigMainInfo::getFgrId(), EcalLogicID::getID1(), EcalLogicID::getID2(), FEConfigFgrEETowerDat::getLUTValue(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), EcalLogicID::NULLID, AlCaHLTBitMon_ParallelJobs::p, 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.

36 {
37 
38  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Started GetNewObjects!!!";
39 
40  //check whats already inside of database
41  if (tagInfo().size){
42  //check whats already inside of database
43  std::cout << "got offlineInfo = " << std::endl;
44  std::cout << "tag name = " << tagInfo().name << std::endl;
45  std::cout << "size = " << tagInfo().size << std::endl;
46  } else {
47  std::cout << " First object for this tag " << std::endl;
48  }
49 
50  unsigned int max_since=0;
51  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
52  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "max_since : " << max_since;
53  Ref fgrTTEE_db = lastPayload();
54 
55  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "retrieved last payload ";
56 
57  // here we retrieve all the runs after the last from online DB
58  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Retrieving run list from ONLINE DB ... ";
59 
60  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Making connection...";
62  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Done.";
63 
64  if (!econn)
65  {
66  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
67  // cerr << e.what() << std::endl;
68  throw cms::Exception("OMDS not available");
69  }
70 
71 
72  LocationDef my_locdef;
73  my_locdef.setLocation(m_location);
74 
75  RunTypeDef my_rundef;
76  my_rundef.setRunType(m_runtype);
77 
78  RunTag my_runtag;
79  my_runtag.setLocationDef( my_locdef );
80  my_runtag.setRunTypeDef( my_rundef );
81  my_runtag.setGeneralTag(m_gentag);
82 
83  readFromFile("last_tpg_fgrTTEE_settings.txt");
84 
85 
86  unsigned int min_run=m_i_run_number+1;
87 
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<< std::endl;
98 
99  unsigned int max_run=m_lastRun;
100  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "min_run= " << min_run << " max_run= " << max_run;
101 
102  RunList my_list;
103  my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
104  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
105 
106  std::vector<RunIOV> run_vec= my_list.getRuns();
107  size_t num_runs=run_vec.size();
108 
109  std::cout <<"number of runs is : "<< num_runs<< std::endl;
110 
111  unsigned int irun;
112  if(num_runs>0){
113  // going to query the ecal logic id
114  std::vector<EcalLogicID> my_TTEcalLogicId_EE;
115  my_TTEcalLogicId_EE = econn->getEcalLogicIDSetOrdered( "EE_trigger_tower",
116  1, 200,
117  1, 70,
119  "EE_offline_towerid",12 );
120  std::cout <<" GOT the logic ID for the EE trigger towers "<< std::endl;
121 
122  for(size_t kr=0; kr<run_vec.size(); kr++){
123 
124  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
125 
126  std::cout<<" **************** "<<std::endl;
127  std::cout<<" **************** "<<std::endl;
128  std::cout<<" run= "<<irun<<std::endl;
129 
130  // retrieve the data
131  std::map<EcalLogicID, RunTPGConfigDat> dataset;
132  econn->fetchDataSet(&dataset, &run_vec[kr]);
133 
134  std::string the_config_tag="";
135  int the_config_version=0;
136 
137  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
138 
139  int nr=0;
140  for( it=dataset.begin(); it!=dataset.end(); it++ )
141  {
142  ++nr;
143  EcalLogicID ecalid = it->first;
144  RunTPGConfigDat dat = it->second;
145  the_config_tag=dat.getConfigTag();
146  the_config_version=dat.getVersion();
147  }
148 
149  // it is all the same for all SM... get the last one
150 
151  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
152 
153  // here we should check if it is the same as previous run.
154 
155 
156  if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
157  std::cout<<"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
158 
159  FEConfigMainInfo fe_main_info;
160  fe_main_info.setConfigTag(the_config_tag);
161  fe_main_info.setVersion(the_config_version);
162 
163  try{
164  std::cout << " before fetch config set" << std::endl;
165  econn-> fetchConfigSet(&fe_main_info);
166  std::cout << " after fetch config set" << std::endl;
167 
168  // now get TPGFineGrainTowerEE
169  int fgrId=fe_main_info.getFgrId();
170 
171  if( fgrId != m_i_fgrTTEE ) {
172 
173  FEConfigFgrInfo fe_fgr_info;
174  fe_fgr_info.setId(fgrId);
175  econn-> fetchConfigSet(&fe_fgr_info);
176  std::map<EcalLogicID, FEConfigFgrEETowerDat> dataset_TpgFineGrainEE;
177  econn->fetchDataSet(&dataset_TpgFineGrainEE, &fe_fgr_info);
179 
180  typedef std::map<EcalLogicID, FEConfigFgrEETowerDat>::const_iterator CIfefgr;
181  EcalLogicID ecid_xt;
182  FEConfigFgrEETowerDat rd_fgr;
183  int itowers=0;
184 
185  for (CIfefgr p = dataset_TpgFineGrainEE.begin(); p != dataset_TpgFineGrainEE.end(); p++) {
186  ecid_xt = p->first;
187  rd_fgr = p->second;
188 
189  std::string ecid_name=ecid_xt.getName();
190 
191  if (ecid_name=="EE_trigger_tower") {
192 
193  int tccid=ecid_xt.getID1();
194  // TT number
195  int towerid=ecid_xt.getID2();
196 
197  bool set_the_tower=false;
198  int towid;
199  for (size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
200 
201  if(!set_the_tower){
202 
203  if(my_TTEcalLogicId_EE[itower].getID1()==tccid && my_TTEcalLogicId_EE[itower].getID2()==towerid){
204  towid =my_TTEcalLogicId_EE[itower].getLogicID();
205  set_the_tower=true;
206  break;
207  }
208  }
209 
210  }
211 
212  if(set_the_tower){
213  fgrMap->setValue(towid, rd_fgr.getLUTValue());
214 
215  } else {
216  std::cout <<" these may be the additional towers TCC/TT "
217  << tccid<<"/"<<towerid<<std::endl;
218  }
219 
220  ++itowers;
221  }
222  }
223 
224  Time_t snc= (Time_t) irun ;
225 
226  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainTowerEE *)fgrMap,snc));
227 
228  m_i_run_number=irun;
229  m_i_tag=the_config_tag;
230  m_i_version=the_config_version;
231  m_i_fgrTTEE=fgrId;
232 
233  writeFile("last_tpg_fgrTTEE_settings.txt");
234 
235  } else {
236 
237  m_i_run_number=irun;
238  m_i_tag=the_config_tag;
239  m_i_version=the_config_version;
240 
241  writeFile("last_tpg_fgrTTEE_settings.txt");
242 
243  std::cout<< " even if the tag/version is not the same, the fgrTTEE id is the same -> no transfer needed "<< std::endl;
244 
245  }
246 
247  } catch (std::exception &e) {
248  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
249  <<" version="<<the_config_version<< std::endl;
250  std::cout << e.what() << std::endl;
251  m_i_run_number=irun;
252 
253  }
254  std::cout<<" **************** "<<std::endl;
255 
256  } else if(nr==0) {
257  m_i_run_number=irun;
258  std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
259  std::cout<<" **************** "<<std::endl;
260  } else {
261  m_i_run_number=irun;
262  m_i_tag=the_config_tag;
263  m_i_version=the_config_version;
264  std::cout<< " the tag/version is the same -> no transfer needed "<< std::endl;
265  std::cout<<" **************** "<<std::endl;
266  writeFile("last_tpg_fgrTTEE_settings.txt");
267  }
268 
269  }
270  }
271 
272  delete econn;
273  edm::LogInfo("EcalTPGFineGrainTowerEEHandler") << "Ecal - > end of getNewObjects -----------";
274 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
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)
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)
std::string name
Definition: Types.h:68
int getID2() const
Definition: EcalLogicID.cc:51
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 getID1() const
Definition: EcalLogicID.cc:46
void setValue(const uint32_t &id, const uint32_t &lut)
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void setId(int id)
int getFgrId() const
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:787
void setConfigTag(std::string x)
Definition: IODConfig.h:31
static const int NULLID
Definition: EcalLogicID.h:42
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
tuple size
Write out results.
std::string popcon::EcalTPGFineGrainTowerEEHandler::id ( void  ) const
inlinevirtual
std::map<std::string, int> popcon::EcalTPGFineGrainTowerEEHandler::makeTTEEDetId ( )
void popcon::EcalTPGFineGrainTowerEEHandler::readFromFile ( const char *  inputFile)

Definition at line 277 of file EcalTPGFineGrainTowerEEHandler.cc.

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

277  {
278  //-------------------------------------------------------------
279 
280  m_i_tag="";
281  m_i_version=0;
282  m_i_run_number=0;
283  m_i_fgrTTEE=0;
284 
285  FILE *inpFile; // input file
286  inpFile = fopen(inputFile,"r");
287  if(!inpFile) {
288  edm::LogError("EcalTPGFineGrainTowerEEHandler")<<"*** Can not open file: "<<inputFile;
289  return;
290  }
291 
292  char line[256];
293 
294  std::ostringstream str;
295 
296  fgets(line,255,inpFile);
297  m_i_tag=to_string(line);
298  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
299 
300  fgets(line,255,inpFile);
301  m_i_version=atoi(line);
302  str << "version= " << m_i_version << std::endl ;
303 
304  fgets(line,255,inpFile);
305  m_i_run_number=atoi(line);
306  str << "run_number= " << m_i_run_number << std::endl ;
307 
308  fgets(line,255,inpFile);
309  m_i_fgrTTEE=atoi(line);
310  str << "fgrTTEE_config= " << m_i_fgrTTEE << std::endl ;
311 
312 
313  fclose(inpFile); // close inp. file
314 
315 }
std::string popcon::EcalTPGFineGrainTowerEEHandler::to_string ( char  value[])
inlineprivate

Definition at line 70 of file EcalTPGFineGrainTowerEEHandler.h.

References relativeConstraints::value.

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

Definition at line 317 of file EcalTPGFineGrainTowerEEHandler.cc.

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

317  {
318  //-------------------------------------------------------------
319 
320 
321  std::ofstream myfile;
322  myfile.open (inputFile);
323  myfile << m_i_tag <<std::endl;
324  myfile << m_i_version <<std::endl;
325  myfile << m_i_run_number <<std::endl;
326  myfile << m_i_fgrTTEE <<std::endl;
327 
328  myfile.close();
329 
330 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGFineGrainTowerEEHandler::econn

Definition at line 67 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_firstRun
private

Definition at line 76 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 81 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_fgrTTEE
private

Definition at line 92 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGFineGrainTowerEEHandler.h.

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

Definition at line 89 of file EcalTPGFineGrainTowerEEHandler.h.

int popcon::EcalTPGFineGrainTowerEEHandler::m_i_version
private

Definition at line 90 of file EcalTPGFineGrainTowerEEHandler.h.

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_lastRun
private

Definition at line 77 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 80 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 85 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 86 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by id().

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

Definition at line 84 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

unsigned int popcon::EcalTPGFineGrainTowerEEHandler::m_runnr
private

Definition at line 87 of file EcalTPGFineGrainTowerEEHandler.h.

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

Definition at line 88 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 82 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 83 of file EcalTPGFineGrainTowerEEHandler.h.

Referenced by EcalTPGFineGrainTowerEEHandler().

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

Definition at line 78 of file EcalTPGFineGrainTowerEEHandler.h.