CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
EcalCondDBWriter Class Reference

#include <EcalCondDBWriter.h>

Inheritance diagram for EcalCondDBWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 EcalCondDBWriter (edm::ParameterSet const &)
 
 ~EcalCondDBWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  Tasks {
  Integrity = 0, Cosmic = 1, Laser = 2, Pedestal = 3,
  Presample = 4, TestPulse = 5, BeamCalo = 6, BeamHodo = 7,
  TriggerPrimitives = 8, Cluster = 9, Timing = 10, Led = 11,
  RawData = 12, Occupancy = 13, nTasks = 14
}
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &)
 

Private Attributes

EcalCondDBInterfacedb_
 
bool executed_
 
std::vector< std::string > inputRootFiles_
 
std::string location_
 
std::string monRunGeneralTag_
 
std::string runGeneralTag_
 
std::string runType_
 
ecaldqm::SummaryWriter summaryWriter_
 
int verbosity_
 
ecaldqm::DBWriterWorkerworkers_ [nTasks]
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 11 of file EcalCondDBWriter.h.

Member Enumeration Documentation

Enumerator
Integrity 
Cosmic 
Laser 
Pedestal 
Presample 
TestPulse 
BeamCalo 
BeamHodo 
TriggerPrimitives 
Cluster 
Timing 
Led 
RawData 
Occupancy 
nTasks 

Definition at line 20 of file EcalCondDBWriter.h.

Constructor & Destructor Documentation

EcalCondDBWriter::EcalCondDBWriter ( edm::ParameterSet const &  _ps)

Definition at line 26 of file EcalCondDBWriter.cc.

References BeamCalo, BeamHodo, Cluster, Cosmic, EcalCondDB::db, db_, edm::hlt::Exception, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), inputRootFiles_, Integrity, Laser, Led, nTasks, Occupancy, Pedestal, Presample, RawData, AlCaHLTBitMon_QueryRunRegistry::string, TestPulse, Timing, TriggerPrimitives, verbosity_, and workers_.

26  :
27  db_(0),
28  location_(_ps.getUntrackedParameter<std::string>("location")),
29  runType_(_ps.getUntrackedParameter<std::string>("runType")),
30  runGeneralTag_(_ps.getUntrackedParameter<std::string>("runGeneralTag")),
31  monRunGeneralTag_(_ps.getUntrackedParameter<std::string>("monRunGeneralTag")),
32  inputRootFiles_(_ps.getUntrackedParameter<std::vector<std::string> >("inputRootFiles")),
33  summaryWriter_(_ps.getUntrackedParameterSet("workerParams")),
34  verbosity_(_ps.getUntrackedParameter<int>("verbosity")),
35  executed_(false)
36 {
37  if(inputRootFiles_.size() == 0)
38  throw cms::Exception("Configuration") << "No input ROOT file given";
39 
40  std::string DBName(_ps.getUntrackedParameter<std::string>("DBName"));
41  std::string hostName(_ps.getUntrackedParameter<std::string>("hostName"));
42  int hostPort(_ps.getUntrackedParameter<int>("hostPort"));
43  std::string userName(_ps.getUntrackedParameter<std::string>("userName"));
44  std::string password(_ps.getUntrackedParameter<std::string>("password"));
45 
46  std::auto_ptr<EcalCondDBInterface> db(0);
47 
48  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Establishing DB connection";
49 
50  try{
51  db = std::auto_ptr<EcalCondDBInterface>(new EcalCondDBInterface(DBName, userName, password));
52  }
53  catch(std::runtime_error& re){
54  if(hostName != ""){
55  try{
56  db = std::auto_ptr<EcalCondDBInterface>(new EcalCondDBInterface(hostName, DBName, userName, password, hostPort));
57  }
58  catch(std::runtime_error& re2){
59  throw cms::Exception("DBError") << re2.what();
60  }
61  }
62  else
63  throw cms::Exception("DBError") << re.what();
64  }
65 
66  db_ = db.release();
67 
68  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
69 
70  edm::ParameterSet const& workerParams(_ps.getUntrackedParameterSet("workerParams"));
71 
72  workers_[Integrity] = new ecaldqm::IntegrityWriter(workerParams);
73  workers_[Cosmic] = 0;
74  workers_[Laser] = new ecaldqm::LaserWriter(workerParams);
75  workers_[Pedestal] = new ecaldqm::PedestalWriter(workerParams);
76  workers_[Presample] = new ecaldqm::PresampleWriter(workerParams);
77  workers_[TestPulse] = new ecaldqm::TestPulseWriter(workerParams);
78  workers_[BeamCalo] = 0;
79  workers_[BeamHodo] = 0;
80  workers_[TriggerPrimitives] = 0;
81  workers_[Cluster] = 0;
82  workers_[Timing] = new ecaldqm::TimingWriter(workerParams);
83  workers_[Led] = new ecaldqm::LedWriter(workerParams);
84  workers_[RawData] = 0;
85  workers_[Occupancy] = new ecaldqm::OccupancyWriter(workerParams);
86 
87  for(unsigned iC(0); iC < nTasks; ++iC)
88  if(workers_[iC]) workers_[iC]->setVerbosity(verbosity_);
89 }
std::string location_
std::string monRunGeneralTag_
tuple db
Definition: EcalCondDB.py:151
std::string runGeneralTag_
EcalCondDBInterface * db_
std::vector< std::string > inputRootFiles_
ecaldqm::DBWriterWorker * workers_[nTasks]
ecaldqm::SummaryWriter summaryWriter_
std::string runType_
EcalCondDBWriter::~EcalCondDBWriter ( )

Definition at line 91 of file EcalCondDBWriter.cc.

References db_, alignCSCRings::e, edm::hlt::Exception, nTasks, and workers_.

92 {
93  try{
94  delete db_;
95  }
96  catch(std::runtime_error& e){
97  throw cms::Exception("DBError") << e.what();
98  }
99 
100  for(unsigned iC(0); iC < nTasks; ++iC)
101  delete workers_[iC];
102 }
EcalCondDBInterface * db_
ecaldqm::DBWriterWorker * workers_[nTasks]

Member Function Documentation

void EcalCondDBWriter::analyze ( edm::Event const &  ,
edm::EventSetup const &   
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 105 of file EcalCondDBWriter.cc.

References DQMStore::cd(), dtNoiseDBValidation_cfg::cerr, db_, DQMStore::dirExists(), alignCSCRings::e, edm::hlt::Exception, executed_, EcalCondDBInterface::fetchMonRunIOV(), EcalCondDBInterface::fetchRunIOV(), convertXMLtoSQLite_cfg::fileName, DQMStore::get(), getBit(), MonitorElement::getIntValue(), ecaldqm::DBWriterWorker::getName(), RunIOV::getRunEnd(), RunIOV::getRunStart(), RunIOV::getRunTag(), DQMStore::getSubdirs(), inputRootFiles_, EcalCondDBInterface::insertMonRunIOV(), EcalCondDBInterface::insertRunIOV(), location_, monRunGeneralTag_, nTasks, DQMStore::open(), ecaldqm::DBWriterWorker::retrieveSource(), DTTTrigCorrFirst::run, ecaldqm::SummaryWriter::run(), runGeneralTag_, convertSQLiteXML::runNumber, runType_, seconds(), setBit(), RunTag::setGeneralTag(), MonRunTag::setGeneralTag(), LocationDef::setLocation(), RunTag::setLocationDef(), MonVersionDef::setMonitoringVersion(), MonRunIOV::setMonRunTag(), MonRunTag::setMonVersionDef(), ecaldqm::SummaryWriter::setOutcome(), ecaldqm::SummaryWriter::setProcessedEvents(), MonRunIOV::setRunIOV(), RunIOV::setRunNumber(), RunIOV::setRunStart(), RunIOV::setRunTag(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), MonRunIOV::setSubRunEnd(), MonRunIOV::setSubRunNumber(), MonRunIOV::setSubRunStart(), ecaldqm::SummaryWriter::setTaskList(), AlCaHLTBitMon_QueryRunRegistry::string, DQMStore::StripRunDirs, summaryWriter_, verbosity_, and workers_.

106 {
107  if(executed_) return;
108 
110 
111  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Initializing DQMStore from input ROOT files";
112 
113  DQMStore& dqmStore(*edm::Service<DQMStore>());
114 
115  int runNumber(0);
116 
117  for(unsigned iF(0); iF < inputRootFiles_.size(); ++iF){
119 
120  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " " << fileName;
121 
122  TPRegexp pat("DQM_V[0-9]+(?:|_[0-9a-zA-Z]+)_R([0-9]+)");
123  std::auto_ptr<TObjArray> matches(pat.MatchS(fileName.c_str()));
124  if(matches->GetEntries() == 0)
125  throw cms::Exception("Configuration") << "Input file " << fileName << " is not an DQM output";
126 
127  if(iF == 0)
128  runNumber = TString(matches->At(1)->GetName()).Atoi();
129  else if(TString(matches->At(1)->GetName()).Atoi() != runNumber)
130  throw cms::Exception("Configuration") << "Input files disagree in run number";
131 
132  dqmStore.open(fileName, false, "", "", DQMStore::StripRunDirs);
133  }
134 
135  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " Searching event info";
136 
137  uint64_t timeStampInFile(0);
138  unsigned processedEvents(0);
139 
140  dqmStore.cd();
141  std::vector<std::string> dirs(dqmStore.getSubdirs());
142  for(unsigned iD(0); iD < dirs.size(); ++iD){
143  if(!dqmStore.dirExists(dirs[iD] + "/EventInfo")) continue;
144 
145  MonitorElement* timeStampME(dqmStore.get(dirs[iD] + "/EventInfo/runStartTimeStamp"));
146  if(timeStampME){
147  double timeStampValue(timeStampME->getFloatValue());
148  uint64_t seconds(timeStampValue);
149  uint64_t microseconds((timeStampValue - seconds) * 1.e6);
150  timeStampInFile = (seconds << 32) | microseconds;
151  }
152 
153  MonitorElement* eventsME(dqmStore.get(dirs[iD] + "/EventInfo/processedEvents"));
154  if(eventsME)
155  processedEvents = eventsME->getIntValue();
156 
157  if(timeStampInFile != 0 && processedEvents != 0){
158  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " Event info found; timestamp=" << timeStampInFile << " processedEvents=" << processedEvents;
159  break;
160  }
161  }
162 
163  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
164 
166 
167  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Setting up source MonitorElements for given run type " << runType_;
168 
169  int taskList(0);
170  for(unsigned iC(0); iC < nTasks; ++iC){
171  if(!workers_[iC] || !workers_[iC]->runsOn(runType_)) continue;
172 
173  workers_[iC]->retrieveSource(dqmStore);
174 
175  setBit(taskList, iC);
176  }
177 
178  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
179 
181 
182  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Initializing DB entry";
183 
184  RunIOV runIOV;
185  RunTag runTag;
186  try{
187  runIOV = db_->fetchRunIOV(location_, runNumber);
188  runTag = runIOV.getRunTag();
189  }
190  catch(std::runtime_error& e){
191  std::cerr << e.what();
192 
193  if(timeStampInFile == 0)
194  throw cms::Exception("Initialization") << "Time stamp for the run could not be found";
195 
196  LocationDef locationDef;
197  locationDef.setLocation(location_);
198  RunTypeDef runTypeDef;
199  runTypeDef.setRunType(runType_);
200  runTag.setLocationDef(locationDef);
201  runTag.setRunTypeDef(runTypeDef);
203 
204  runIOV.setRunStart(Tm(timeStampInFile));
205  runIOV.setRunNumber(runNumber);
206  runIOV.setRunTag(runTag);
207 
208  try{
209  db_->insertRunIOV(&runIOV);
210  runIOV = db_->fetchRunIOV(&runTag, runNumber);
211  }
212  catch(std::runtime_error& e){
213  throw cms::Exception("DBError") << e.what();
214  }
215  }
216 
217  // No filtering - DAQ definitions change time to time..
218 // if(runType_ != runIOV.getRunTag().getRunTypeDef().getRunType())
219 // throw cms::Exception("Configuration") << "Given run type " << runType_ << " does not match the run type in DB " << runIOV.getRunTag().getRunTypeDef().getRunType();
220 
221  MonVersionDef versionDef;
222  versionDef.setMonitoringVersion("test01"); // the only mon_ver in mon_version_def table as of September 2012
223  MonRunTag monTag;
224  monTag.setMonVersionDef(versionDef);
226 
227  MonRunIOV monIOV;
228 
229  try{
230  monIOV = db_->fetchMonRunIOV(&runTag, &monTag, runNumber, 1);
231  }
232  catch(std::runtime_error& e){
233  std::cerr << e.what();
234 
235  monIOV.setRunIOV(runIOV);
236  monIOV.setSubRunNumber(1);
237  monIOV.setSubRunStart(runIOV.getRunStart());
238  monIOV.setSubRunEnd(runIOV.getRunEnd());
239  monIOV.setMonRunTag(monTag);
240 
241  try{
242  db_->insertMonRunIOV(&monIOV);
243  monIOV = db_->fetchMonRunIOV(&runTag, &monTag, runNumber, 1);
244  }
245  catch(std::runtime_error& e){
246  throw cms::Exception("DBError") << e.what();
247  }
248  }
249 
250  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
251 
253 
254  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Writing to DB";
255 
256  int outcome(0);
257  for(unsigned iC(0); iC < nTasks; ++iC){
258  if(!getBit(taskList, iC)) continue;
259 
260  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " " << workers_[iC]->getName();
261 
262  if(workers_[iC]->isActive() && workers_[iC]->run(db_, monIOV)) setBit(outcome, iC);
263  }
264 
265  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
266 
267  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Registering the outcome of DB writing";
268 
269  summaryWriter_.setTaskList(taskList);
270  summaryWriter_.setOutcome(outcome);
271  summaryWriter_.setProcessedEvents(processedEvents);
272  summaryWriter_.run(db_, monIOV);
273 
274  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
275 
276  executed_ = true;
277 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
void setRunStart(const Tm &start)
Definition: RunIOV.cc:52
bool run(EcalCondDBInterface *, MonRunIOV &) override
double seconds()
void insertRunIOV(RunIOV *iov)
std::string location_
std::string monRunGeneralTag_
Definition: RunTag.h:13
void setRunIOV(const RunIOV &iov)
Definition: MonRunIOV.cc:53
void setProcessedEvents(unsigned _n)
RunIOV fetchRunIOV(RunTag *tag, run_t run)
std::string runGeneralTag_
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
void setRunTag(const RunTag &tag)
Definition: RunIOV.cc:86
virtual void retrieveSource(DQMStore const &)
void setRunNumber(run_t run)
Definition: RunIOV.cc:29
RunTag getRunTag() const
Definition: RunIOV.cc:96
Tm getRunStart() const
Definition: RunIOV.cc:62
EcalCondDBInterface * db_
void setTaskList(int _list)
void setSubRunEnd(const Tm &end)
Definition: MonRunIOV.cc:101
void setSubRunNumber(subrun_t subrun)
Definition: MonRunIOV.cc:67
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:49
void setSubRunStart(const Tm &start)
Definition: MonRunIOV.cc:84
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void setBit(int &_bitArray, unsigned _iBit)
std::vector< std::string > inputRootFiles_
unsigned long long uint64_t
Definition: Time.h:15
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
int64_t getIntValue(void) const
Tm getRunEnd() const
Definition: RunIOV.cc:79
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunIOV.cc:36
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
void setMonitoringVersion(std::string ver)
std::string const & getName() const
void insertMonRunIOV(MonRunIOV *iov)
ecaldqm::DBWriterWorker * workers_[nTasks]
void setLocation(std::string loc)
Definition: LocationDef.cc:33
ecaldqm::SummaryWriter summaryWriter_
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
Definition: RunIOV.h:13
Definition: Tm.h:13
bool getBit(int &_bitArray, unsigned _iBit)
void setOutcome(int _outcome)
std::string runType_

Member Data Documentation

EcalCondDBInterface* EcalCondDBWriter::db_
private

Definition at line 38 of file EcalCondDBWriter.h.

Referenced by analyze(), EcalCondDBWriter(), and ~EcalCondDBWriter().

bool EcalCondDBWriter::executed_
private

Definition at line 48 of file EcalCondDBWriter.h.

Referenced by analyze().

std::vector<std::string> EcalCondDBWriter::inputRootFiles_
private

Definition at line 43 of file EcalCondDBWriter.h.

Referenced by analyze(), and EcalCondDBWriter().

std::string EcalCondDBWriter::location_
private

Definition at line 39 of file EcalCondDBWriter.h.

Referenced by analyze().

std::string EcalCondDBWriter::monRunGeneralTag_
private

Definition at line 42 of file EcalCondDBWriter.h.

Referenced by analyze().

std::string EcalCondDBWriter::runGeneralTag_
private

Definition at line 41 of file EcalCondDBWriter.h.

Referenced by analyze().

std::string EcalCondDBWriter::runType_
private

Definition at line 40 of file EcalCondDBWriter.h.

Referenced by analyze().

ecaldqm::SummaryWriter EcalCondDBWriter::summaryWriter_
private

Definition at line 45 of file EcalCondDBWriter.h.

Referenced by analyze().

int EcalCondDBWriter::verbosity_
private

Definition at line 47 of file EcalCondDBWriter.h.

Referenced by analyze(), and EcalCondDBWriter().

ecaldqm::DBWriterWorker* EcalCondDBWriter::workers_[nTasks]
private

Definition at line 44 of file EcalCondDBWriter.h.

Referenced by analyze(), EcalCondDBWriter(), and ~EcalCondDBWriter().