test
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:
DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 EcalCondDBWriter (edm::ParameterSet const &)
 
 ~EcalCondDBWriter ()
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDHarvester (void)
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 10 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 19 of file EcalCondDBWriter.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file EcalCondDBWriter.cc.

References BeamCalo, BeamHodo, Cluster, Cosmic, EcalCondDB::db, db_, Exception, MillePedeFileConverter_cfg::fileName, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), Integrity, Laser, Led, matches, nTasks, Occupancy, DQMStore::open(), Pedestal, Presample, RawData, runNumber_, AlCaHLTBitMon_QueryRunRegistry::string, DQMStore::StripRunDirs, TestPulse, Timing, TriggerPrimitives, verbosity_, and workers_.

27  :
28  runNumber_(0),
29  db_(0),
30  location_(_ps.getUntrackedParameter<std::string>("location")),
31  runType_(_ps.getUntrackedParameter<std::string>("runType")),
32  runGeneralTag_(_ps.getUntrackedParameter<std::string>("runGeneralTag")),
33  monRunGeneralTag_(_ps.getUntrackedParameter<std::string>("monRunGeneralTag")),
34  summaryWriter_(_ps.getUntrackedParameterSet("workerParams")),
35  verbosity_(_ps.getUntrackedParameter<int>("verbosity")),
36  executed_(false)
37 {
38  std::vector<std::string> inputRootFiles(_ps.getUntrackedParameter<std::vector<std::string> >("inputRootFiles"));
39 
40  if(inputRootFiles.size() == 0)
41  throw cms::Exception("Configuration") << "No input ROOT file given";
42 
43  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Initializing DQMStore from input ROOT files";
44 
45  DQMStore& dqmStore(*edm::Service<DQMStore>());
46 
47  for(unsigned iF(0); iF < inputRootFiles.size(); ++iF){
48  std::string& fileName(inputRootFiles[iF]);
49 
50  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " " << fileName;
51 
52  TPRegexp pat("DQM_V[0-9]+(?:|_[0-9a-zA-Z]+)_R([0-9]+)");
53  std::auto_ptr<TObjArray> matches(pat.MatchS(fileName.c_str()));
54  if(matches->GetEntries() == 0)
55  throw cms::Exception("Configuration") << "Input file " << fileName << " is not an DQM output";
56 
57  if(iF == 0)
58  runNumber_ = TString(matches->At(1)->GetName()).Atoi();
59  else if(TString(matches->At(1)->GetName()).Atoi() != runNumber_)
60  throw cms::Exception("Configuration") << "Input files disagree in run number";
61 
62  dqmStore.open(fileName, false, "", "", DQMStore::StripRunDirs);
63  }
64 
65  std::string DBName(_ps.getUntrackedParameter<std::string>("DBName"));
66  std::string hostName(_ps.getUntrackedParameter<std::string>("hostName"));
67  int hostPort(_ps.getUntrackedParameter<int>("hostPort"));
68  std::string userName(_ps.getUntrackedParameter<std::string>("userName"));
69  std::string password(_ps.getUntrackedParameter<std::string>("password"));
70 
71  std::auto_ptr<EcalCondDBInterface> db(0);
72 
73  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Establishing DB connection";
74 
75  try{
76  db = std::auto_ptr<EcalCondDBInterface>(new EcalCondDBInterface(DBName, userName, password));
77  }
78  catch(std::runtime_error& re){
79  if(hostName != ""){
80  try{
81  db = std::auto_ptr<EcalCondDBInterface>(new EcalCondDBInterface(hostName, DBName, userName, password, hostPort));
82  }
83  catch(std::runtime_error& re2){
84  throw cms::Exception("DBError") << re2.what();
85  }
86  }
87  else
88  throw cms::Exception("DBError") << re.what();
89  }
90 
91  db_ = db.release();
92 
93  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
94 
95  edm::ParameterSet const& workerParams(_ps.getUntrackedParameterSet("workerParams"));
96 
97  workers_[Integrity] = new ecaldqm::IntegrityWriter(workerParams);
98  workers_[Cosmic] = 0;
99  workers_[Laser] = new ecaldqm::LaserWriter(workerParams);
100  workers_[Pedestal] = new ecaldqm::PedestalWriter(workerParams);
101  workers_[Presample] = new ecaldqm::PresampleWriter(workerParams);
102  workers_[TestPulse] = new ecaldqm::TestPulseWriter(workerParams);
103  workers_[BeamCalo] = 0;
104  workers_[BeamHodo] = 0;
105  workers_[TriggerPrimitives] = 0;
106  workers_[Cluster] = 0;
107  workers_[Timing] = new ecaldqm::TimingWriter(workerParams);
108  workers_[Led] = new ecaldqm::LedWriter(workerParams);
109  workers_[RawData] = 0;
110  workers_[Occupancy] = new ecaldqm::OccupancyWriter(workerParams);
111 
112  for(unsigned iC(0); iC < nTasks; ++iC)
113  if(workers_[iC]) workers_[iC]->setVerbosity(verbosity_);
114 }
std::string location_
std::string monRunGeneralTag_
tuple db
Definition: EcalCondDB.py:151
std::string runGeneralTag_
EcalCondDBInterface * db_
ecaldqm::DBWriterWorker * workers_[nTasks]
ecaldqm::SummaryWriter summaryWriter_
std::string runType_
EcalCondDBWriter::~EcalCondDBWriter ( )

Definition at line 116 of file EcalCondDBWriter.cc.

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

117 {
118  try{
119  delete db_;
120  }
121  catch(std::runtime_error& e){
122  throw cms::Exception("DBError") << e.what();
123  }
124 
125  for(unsigned iC(0); iC < nTasks; ++iC)
126  delete workers_[iC];
127 }
EcalCondDBInterface * db_
ecaldqm::DBWriterWorker * workers_[nTasks]

Member Function Documentation

void EcalCondDBWriter::dqmEndJob ( DQMStore::IBooker ,
DQMStore::IGetter _igetter 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 130 of file EcalCondDBWriter.cc.

References DQMStore::IGetter::cd(), ecal_dqm_sourceclient-live_cfg::cerr, db_, DQMStore::IGetter::dirExists(), heppy_check::dirs, alignCSCRings::e, Exception, executed_, EcalCondDBInterface::fetchMonRunIOV(), EcalCondDBInterface::fetchRunIOV(), DQMStore::IGetter::get(), getBit(), MonitorElement::getIntValue(), ecaldqm::DBWriterWorker::getName(), RunIOV::getRunEnd(), RunIOV::getRunStart(), RunIOV::getRunTag(), DQMStore::IGetter::getSubdirs(), EcalCondDBInterface::insertMonRunIOV(), EcalCondDBInterface::insertRunIOV(), location_, monRunGeneralTag_, nTasks, ecaldqm::DBWriterWorker::retrieveSource(), DTTTrigCorrFirst::run, ecaldqm::SummaryWriter::run(), runGeneralTag_, 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(), summaryWriter_, verbosity_, and workers_.

131 {
132  if(executed_) return;
133 
135 
136  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " Searching event info";
137 
138  uint64_t timeStampInFile(0);
139  unsigned processedEvents(0);
140 
141  _igetter.cd();
142  std::vector<std::string> dirs(_igetter.getSubdirs());
143  for(unsigned iD(0); iD < dirs.size(); ++iD){
144  if(!_igetter.dirExists(dirs[iD] + "/EventInfo")) continue;
145 
146  MonitorElement* timeStampME(_igetter.get(dirs[iD] + "/EventInfo/runStartTimeStamp"));
147  if(timeStampME){
148  double timeStampValue(timeStampME->getFloatValue());
149  uint64_t seconds(timeStampValue);
150  uint64_t microseconds((timeStampValue - seconds) * 1.e6);
151  timeStampInFile = (seconds << 32) | microseconds;
152  }
153 
154  MonitorElement* eventsME(_igetter.get(dirs[iD] + "/EventInfo/processedEvents"));
155  if(eventsME)
156  processedEvents = eventsME->getIntValue();
157 
158  if(timeStampInFile != 0 && processedEvents != 0){
159  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " Event info found; timestamp=" << timeStampInFile << " processedEvents=" << processedEvents;
160  break;
161  }
162  }
163 
164  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
165 
167 
168  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Setting up source MonitorElements for given run type " << runType_;
169 
170  int taskList(0);
171  for(unsigned iC(0); iC < nTasks; ++iC){
172  if(!workers_[iC] || !workers_[iC]->runsOn(runType_)) continue;
173 
174  workers_[iC]->retrieveSource(_igetter);
175 
176  setBit(taskList, iC);
177  }
178 
179  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
180 
182 
183  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Initializing DB entry";
184 
185  RunIOV runIOV;
186  RunTag runTag;
187  try{
188  runIOV = db_->fetchRunIOV(location_, runNumber_);
189  runTag = runIOV.getRunTag();
190  }
191  catch(std::runtime_error& e){
192  std::cerr << e.what();
193 
194  if(timeStampInFile == 0)
195  throw cms::Exception("Initialization") << "Time stamp for the run could not be found";
196 
197  LocationDef locationDef;
198  locationDef.setLocation(location_);
199  RunTypeDef runTypeDef;
200  runTypeDef.setRunType(runType_);
201  runTag.setLocationDef(locationDef);
202  runTag.setRunTypeDef(runTypeDef);
204 
205  runIOV.setRunStart(Tm(timeStampInFile));
206  runIOV.setRunNumber(runNumber_);
207  runIOV.setRunTag(runTag);
208 
209  try{
210  db_->insertRunIOV(&runIOV);
211  runIOV = db_->fetchRunIOV(&runTag, runNumber_);
212  }
213  catch(std::runtime_error& e){
214  throw cms::Exception("DBError") << e.what();
215  }
216  }
217 
218  // No filtering - DAQ definitions change time to time..
219 // if(runType_ != runIOV.getRunTag().getRunTypeDef().getRunType())
220 // throw cms::Exception("Configuration") << "Given run type " << runType_ << " does not match the run type in DB " << runIOV.getRunTag().getRunTypeDef().getRunType();
221 
222  MonVersionDef versionDef;
223  versionDef.setMonitoringVersion("test01"); // the only mon_ver in mon_version_def table as of September 2012
224  MonRunTag monTag;
225  monTag.setMonVersionDef(versionDef);
227 
228  MonRunIOV monIOV;
229 
230  try{
231  monIOV = db_->fetchMonRunIOV(&runTag, &monTag, runNumber_, 1);
232  }
233  catch(std::runtime_error& e){
234  std::cerr << e.what();
235 
236  monIOV.setRunIOV(runIOV);
237  monIOV.setSubRunNumber(1);
238  monIOV.setSubRunStart(runIOV.getRunStart());
239  monIOV.setSubRunEnd(runIOV.getRunEnd());
240  monIOV.setMonRunTag(monTag);
241 
242  try{
243  db_->insertMonRunIOV(&monIOV);
244  monIOV = db_->fetchMonRunIOV(&runTag, &monTag, runNumber_, 1);
245  }
246  catch(std::runtime_error& e){
247  throw cms::Exception("DBError") << e.what();
248  }
249  }
250 
251  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
252 
254 
255  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Writing to DB";
256 
257  int outcome(0);
258  for(unsigned iC(0); iC < nTasks; ++iC){
259  if(!getBit(taskList, iC)) continue;
260 
261  if(verbosity_ > 1) edm::LogInfo("EcalDQM") << " " << workers_[iC]->getName();
262 
263  if(workers_[iC]->isActive() && workers_[iC]->run(db_, monIOV)) setBit(outcome, iC);
264  }
265 
266  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
267 
268  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << "Registering the outcome of DB writing";
269 
270  summaryWriter_.setTaskList(taskList);
271  summaryWriter_.setOutcome(outcome);
272  summaryWriter_.setProcessedEvents(processedEvents);
273  summaryWriter_.run(db_, monIOV);
274 
275  if(verbosity_ > 0) edm::LogInfo("EcalDQM") << " Done.";
276 
277  executed_ = true;
278 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
void setRunStart(const Tm &start)
Definition: RunIOV.cc:52
bool run(EcalCondDBInterface *, MonRunIOV &) override
void cd(void)
Definition: DQMStore.cc:338
double seconds()
void insertRunIOV(RunIOV *iov)
std::string location_
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:304
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
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)
bool dirExists(const std::string &path)
Definition: DQMStore.cc:334
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 retrieveSource(DQMStore::IGetter &)
void setMonitoringVersion(std::string ver)
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:322
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 dqmEndJob(), EcalCondDBWriter(), and ~EcalCondDBWriter().

bool EcalCondDBWriter::executed_
private

Definition at line 48 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

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

Definition at line 43 of file EcalCondDBWriter.h.

std::string EcalCondDBWriter::location_
private

Definition at line 39 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

std::string EcalCondDBWriter::monRunGeneralTag_
private

Definition at line 42 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

std::string EcalCondDBWriter::runGeneralTag_
private

Definition at line 41 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

int EcalCondDBWriter::runNumber_
private

Definition at line 37 of file EcalCondDBWriter.h.

Referenced by dqmEndJob(), and EcalCondDBWriter().

std::string EcalCondDBWriter::runType_
private

Definition at line 40 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

ecaldqm::SummaryWriter EcalCondDBWriter::summaryWriter_
private

Definition at line 45 of file EcalCondDBWriter.h.

Referenced by dqmEndJob().

int EcalCondDBWriter::verbosity_
private

Definition at line 47 of file EcalCondDBWriter.h.

Referenced by dqmEndJob(), and EcalCondDBWriter().

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

Definition at line 44 of file EcalCondDBWriter.h.

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