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

#include <EcalTPGFineGrainEBGroupHandler.h>

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

Public Member Functions

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

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

Detailed Description

Definition at line 49 of file EcalTPGFineGrainEBGroupHandler.h.

Constructor & Destructor Documentation

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

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

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

Definition at line 41 of file EcalTPGFineGrainEBGroupHandler.cc.

42 {
43 }

Member Function Documentation

void popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainEBGroup >.

Definition at line 45 of file EcalTPGFineGrainEBGroupHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), FEConfigFgrDat::getFgrGroupId(), FEConfigMainInfo::getFgrId(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigFgrInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGGroups::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, EBDetId::SMCRYSTALMODE, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

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

Definition at line 284 of file EcalTPGFineGrainEBGroupHandler.cc.

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

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

Definition at line 70 of file EcalTPGFineGrainEBGroupHandler.h.

References relativeConstraints::value.

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

Definition at line 323 of file EcalTPGFineGrainEBGroupHandler.cc.

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

323  {
324  //-------------------------------------------------------------
325 
326 
327  std::ofstream myfile;
328  myfile.open (inputFile);
329  myfile << m_i_tag <<std::endl;
330  myfile << m_i_version <<std::endl;
331  myfile << m_i_run_number <<std::endl;
332  myfile << m_i_fgrGroup <<std::endl;
333 
334  myfile.close();
335 
336 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGFineGrainEBGroupHandler::econn

Definition at line 66 of file EcalTPGFineGrainEBGroupHandler.h.

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_firstRun
private

Definition at line 76 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 81 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

int popcon::EcalTPGFineGrainEBGroupHandler::m_i_fgrGroup
private

Definition at line 92 of file EcalTPGFineGrainEBGroupHandler.h.

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGFineGrainEBGroupHandler.h.

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

Definition at line 89 of file EcalTPGFineGrainEBGroupHandler.h.

int popcon::EcalTPGFineGrainEBGroupHandler::m_i_version
private

Definition at line 90 of file EcalTPGFineGrainEBGroupHandler.h.

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_lastRun
private

Definition at line 77 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 80 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 85 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 86 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by id().

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

Definition at line 84 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

unsigned int popcon::EcalTPGFineGrainEBGroupHandler::m_runnr
private

Definition at line 87 of file EcalTPGFineGrainEBGroupHandler.h.

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

Definition at line 88 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 82 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 83 of file EcalTPGFineGrainEBGroupHandler.h.

Referenced by EcalTPGFineGrainEBGroupHandler().

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

Definition at line 78 of file EcalTPGFineGrainEBGroupHandler.h.