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  flagSkipFirstLumis_ = pset.getUntrackedParameter<bool>("skipFirstLumis");
13  flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
14  flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");
15 }
16 
18 
21  typedef DQMFileIterator::LumiEntry LumiEntry;
22 
23  // fiterator_.logFileAction("getNextItemType");
24 
25  for (;;) {
27 
28  // check for end of run file and force quit
29  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
30  return InputSource::IsStop;
31  }
32 
33  // check for end of run and quit if everything has been processed.
34  // this is the clean exit
35  if ((!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
36  return InputSource::IsStop;
37  }
38 
39  // skip to the next file if we have no files openned yet
40  if (fiterator_.lumiReady()) {
41  return InputSource::IsLumi;
42  }
43 
44  fiterator_.delay();
45  // BUG: for an unknown reason it fails after a certain time if we use
46  // IsSynchronize state
47  // comment out in order to block at this level
48  // the only downside is that we cannot Ctrl+C :)
49  // return InputSource::IsSynchronize;
50  }
51 
52  // this is unreachable
53 }
54 
55 std::shared_ptr<edm::RunAuxiliary> DQMProtobufReader::readRunAuxiliary_() {
56  // fiterator_.logFileAction("readRunAuxiliary_");
57 
60  return std::shared_ptr<edm::RunAuxiliary>(aux);
61 }
62 
64  // fiterator_.logFileAction("readRun_");
66 
68  std::vector<MonitorElement*> allMEs = store->getAllContents("");
69  for (auto const& ME : allMEs) {
70  ME->Reset();
71  }
72 }
73 
74 std::shared_ptr<edm::LuminosityBlockAuxiliary>
76  // fiterator_.logFileAction("readLuminosityBlockAuxiliary_");
77 
81  edm::Timestamp());
82 
83  return std::shared_ptr<edm::LuminosityBlockAuxiliary>(aux);
84 }
85 
88  // fiterator_.logFileAction("readLuminosityBlock_");
90 
92  jr->reportInputLumiSection(lbCache.id().run(),
93  lbCache.id().luminosityBlock());
95 
96  // clear the old lumi histograms
97  std::vector<MonitorElement*> allMEs = store->getAllContents("");
98  for (auto const& ME : allMEs) {
99  // We do not want to reset Run Products here!
100  if (ME->getLumiFlag()) {
101  ME->Reset();
102  }
103  }
104 
105  // load the new file
107 
108  if (!boost::filesystem::exists(p)) {
109  fiterator_.logFileAction("Data file is missing ", p);
110  fiterator_.logLumiState(currentLumi_, "error: data file missing");
111  return;
112  }
113 
114  fiterator_.logFileAction("Initiating request to open file ", p);
115  fiterator_.logFileAction("Successfully opened file ", p);
116  store->load(p);
117  fiterator_.logFileAction("Closed file ", p);
118 
119  fiterator_.logLumiState(currentLumi_, "closed: ok");
120 };
121 
123 
125  edm::ConfigurationDescriptions& descriptions) {
127 
128  desc.setComment(
129  "Creates runs and lumis and fills the dqmstore from protocol buffer "
130  "files.");
132 
133  desc.addUntracked<bool>("skipFirstLumis", false)
134  ->setComment(
135  "Skip (and ignore the minEventsPerLumi parameter) for the files "
136  "which have been available at the begining of the processing. "
137  "If set to true, the reader will open last available file for "
138  "processing.");
139 
140  desc.addUntracked<bool>("deleteDatFiles", false)
141  ->setComment(
142  "Delete data files after they have been closed, in order to "
143  "save disk space.");
144 
145  desc.addUntracked<bool>("endOfRunKills", false)
146  ->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)
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:351
virtual edm::InputSource::ItemType getNextItemType() override
State
Definition: hltDiff.cc:319
static void fillDescription(edm::ParameterSetDescription &d)
DQMProtobufReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
Helper class to handle FWLite file input sources.