CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMProtobufReader.cc
Go to the documentation of this file.
1 #include "DQMProtobufReader.h"
2 
6 
7 using namespace dqmservices;
8 
10  edm::InputSourceDescription const& desc)
11  : InputSource(pset, desc), fiterator_(pset) {
12 
13  flagSkipFirstLumis_ = pset.getUntrackedParameter<bool>("skipFirstLumis");
14  flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
15  flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");
16 }
17 
19 
22  typedef DQMFileIterator::LumiEntry LumiEntry;
23 
24  //fiterator_.logFileAction("getNextItemType");
25 
26  for (;;) {
28 
29  // check for end of run file and force quit
30  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
31  return InputSource::IsStop;
32  }
33 
34  // check for end of run and quit if everything has been processed.
35  // this is the clean exit
36  if ((!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
37 
38  return InputSource::IsStop;
39  }
40 
41  // skip to the next file if we have no files openned yet
42  if (fiterator_.lumiReady()) {
43 
44  return InputSource::IsLumi;
45  }
46 
47  fiterator_.delay();
48  // BUG: for an unknown reason it fails after a certain time if we use IsSynchronize state
49  // comment out in order to block at this level
50  // the only downside is that we cannot Ctrl+C :)
51  //return InputSource::IsSynchronize;
52  }
53 
54  // this is unreachable
55 }
56 
57 std::shared_ptr<edm::RunAuxiliary> DQMProtobufReader::readRunAuxiliary_() {
58  //fiterator_.logFileAction("readRunAuxiliary_");
59 
62  return std::shared_ptr<edm::RunAuxiliary>(aux);
63 }
64 
66  //fiterator_.logFileAction("readRun_");
68 
70  std::vector<MonitorElement*> allMEs = store->getAllContents("");
71  for (auto const& ME : allMEs) {
72  ME->Reset();
73  }
74 }
75 
76 std::shared_ptr<edm::LuminosityBlockAuxiliary>
78  //fiterator_.logFileAction("readLuminosityBlockAuxiliary_");
79 
83  edm::Timestamp());
84 
85  return std::shared_ptr<edm::LuminosityBlockAuxiliary>(aux);
86 }
87 
90 
91  //fiterator_.logFileAction("readLuminosityBlock_");
93 
95  jr->reportInputLumiSection(lbCache.id().run(),
96  lbCache.id().luminosityBlock());
98 
99  // clear the old lumi histograms
100  std::vector<MonitorElement*> allMEs = store->getAllContents("");
101  for (auto const& ME : allMEs) {
102  // We do not want to reset Run Products here!
103  if (ME->getLumiFlag()) {
104  ME->Reset();
105  }
106  }
107 
108  // load the new file
110 
111  if (!boost::filesystem::exists(p)) {
112  fiterator_.logFileAction("Data file is missing ", p);
113  fiterator_.logLumiState(currentLumi_, "error: data file missing");
114  return;
115  }
116 
117  fiterator_.logFileAction("Initiating request to open file ", p);
118  fiterator_.logFileAction("Successfully opened file ", p);
119  store->load(p);
120  fiterator_.logFileAction("Closed file ", p);
121 
122  fiterator_.logLumiState(currentLumi_, "closed: ok");
123 };
124 
126 
128  edm::ConfigurationDescriptions& descriptions) {
130 
131  desc.setComment(
132  "Creates runs and lumis and fills the dqmstore from protocol buffer "
133  "files.");
135 
136  desc.addUntracked<bool>("skipFirstLumis", false)->setComment(
137  "Skip (and ignore the minEventsPerLumi parameter) for the files "
138  "which have been available at the begining of the processing. "
139  "If set to true, the reader will open last available file for "
140  "processing.");
141 
142  desc.addUntracked<bool>("deleteDatFiles", false)->setComment(
143  "Delete data files after they have been closed, in order to "
144  "save disk space.");
145 
146  desc.addUntracked<bool>("endOfRunKills", false)->setComment(
147  "Kill the processing as soon as the end-of-run file appears, even if "
148  "there are/will be unprocessed lumisections.");
149 
151  descriptions.add("source", desc);
152 }
153 
156 
T getUntrackedParameter(std::string const &, T const &) const
std::string make_path(const std::string &fn)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void readEvent_(edm::EventPrincipal &) override
void logLumiState(const LumiEntry &lumi, const std::string &msg)
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
Definition: RunPrincipal.cc:21
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void readRun_(edm::RunPrincipal &rpCache) override
virtual void readLuminosityBlock_(edm::LuminosityBlockPrincipal &lbCache) override
Definition: ME.h:11
void setComment(std::string const &value)
void fillLuminosityBlockPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
virtual std::shared_ptr< edm::RunAuxiliary > readRunAuxiliary_() override
#define DEFINE_FWK_INPUT_SOURCE(type)
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:544
virtual std::shared_ptr< edm::LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
RunNumber_t run() const
void logFileAction(const std::string &msg, const std::string &fileName="") const
static void fillDescription(ParameterSetDescription &desc)
DQMFileIterator::LumiEntry currentLumi_
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual edm::InputSource::ItemType getNextItemType() override
ProcessHistoryRegistry & processHistoryRegistryForUpdate() const
Definition: InputSource.h:346
State
Definition: hltDiff.cc:314
static void fillDescription(edm::ParameterSetDescription &d)
DQMProtobufReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
Helper class to handle FWLite file input sources.