test
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 // #include "FWCore/Sources/interface/ProducerSourceBase.h"
8 
9 using namespace dqmservices;
10 
12  edm::InputSourceDescription const& desc)
13  : InputSource(pset, desc), fiterator_(pset) {
14 
15  flagSkipFirstLumis_ = pset.getUntrackedParameter<bool>("skipFirstLumis");
16  flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
17  flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");
18  flagLoadFiles_ = pset.getUntrackedParameter<bool>("loadFiles");
19 
20  produces<std::string, edm::InLumi>("sourceDataPath");
21  produces<std::string, edm::InLumi>("sourceJsonPath");
22 }
23 
25 
28  typedef DQMFileIterator::LumiEntry LumiEntry;
29 
30  // fiterator_.logFileAction("getNextItemType");
31 
32  for (;;) {
34 
35  // check for end of run file and force quit
36  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
37  return InputSource::IsStop;
38  }
39 
40  // check for end of run and quit if everything has been processed.
41  // this is the clean exit
42  if ((!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
43  return InputSource::IsStop;
44  }
45 
46  // skip to the next file if we have no files openned yet
47  if (fiterator_.lumiReady()) {
48  return InputSource::IsLumi;
49  }
50 
51  fiterator_.delay();
52  // BUG: for an unknown reason it fails after a certain time if we use
53  // IsSynchronize state
54  // comment out in order to block at this level
55  // the only downside is that we cannot Ctrl+C :)
56  // return InputSource::IsSynchronize;
57  }
58 
59  // this is unreachable
60 }
61 
62 std::shared_ptr<edm::RunAuxiliary> DQMProtobufReader::readRunAuxiliary_() {
63  // fiterator_.logFileAction("readRunAuxiliary_");
64 
67  return std::shared_ptr<edm::RunAuxiliary>(aux);
68 }
69 
71  // fiterator_.logFileAction("readRun_");
73 
75  std::vector<MonitorElement*> allMEs = store->getAllContents("");
76  for (auto const& ME : allMEs) {
77  ME->Reset();
78  }
79 }
80 
81 std::shared_ptr<edm::LuminosityBlockAuxiliary>
83  // fiterator_.logFileAction("readLuminosityBlockAuxiliary_");
84 
88  edm::Timestamp());
89 
90  return std::shared_ptr<edm::LuminosityBlockAuxiliary>(aux);
91 }
92 
95  // fiterator_.logFileAction("readLuminosityBlock_");
96 
98  jr->reportInputLumiSection(lbCache.id().run(),
99  lbCache.id().luminosityBlock());
101 }
102 
105 
106  // clear the old lumi histograms
107  std::vector<MonitorElement*> allMEs = store->getAllContents("");
108  for (auto const& ME : allMEs) {
109  // We do not want to reset Run Products here!
110  if (ME->getLumiFlag()) {
111  ME->Reset();
112  }
113  }
114 
115  // load the new file
118 
119  std::auto_ptr<std::string> path_product(new std::string(path));
120  std::auto_ptr<std::string> json_product(new std::string(jspath));
121 
122  lb.put(path_product, "sourceDataPath");
123  lb.put(json_product, "sourceJsonPath");
124 
125  if (flagLoadFiles_) {
126  if (!boost::filesystem::exists(path)) {
127  fiterator_.logFileAction("Data file is missing ", path);
128  fiterator_.logLumiState(currentLumi_, "error: data file missing");
129  return;
130  }
131 
132  fiterator_.logFileAction("Initiating request to open file ", path);
133  fiterator_.logFileAction("Successfully opened file ", path);
134  store->load(path);
135  fiterator_.logFileAction("Closed file ", path);
136  fiterator_.logLumiState(currentLumi_, "close: ok");
137  } else {
138  fiterator_.logFileAction("Not loading the data file at source level ", path);
139  fiterator_.logLumiState(currentLumi_, "close: not loading");
140  }
141 }
142 
143 
145 
147  edm::ConfigurationDescriptions& descriptions) {
149 
150  desc.setComment(
151  "Creates runs and lumis and fills the dqmstore from protocol buffer "
152  "files.");
154 
155  desc.addUntracked<bool>("skipFirstLumis", false)
156  ->setComment(
157  "Skip (and ignore the minEventsPerLumi parameter) for the files "
158  "which have been available at the begining of the processing. "
159  "If set to true, the reader will open last available file for "
160  "processing.");
161 
162  desc.addUntracked<bool>("deleteDatFiles", false)
163  ->setComment(
164  "Delete data files after they have been closed, in order to "
165  "save disk space.");
166 
167  desc.addUntracked<bool>("endOfRunKills", false)
168  ->setComment(
169  "Kill the processing as soon as the end-of-run file appears, even if "
170  "there are/will be unprocessed lumisections.");
171 
172  desc.addUntracked<bool>("loadFiles", true)
173  ->setComment(
174  "Tells the source load the data files. If set to false, source will create skeleton lumi transitions.");
175 
177  descriptions.add("source", desc);
178 }
179 
182 
T getUntrackedParameter(std::string const &, T const &) const
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
virtual void beginLuminosityBlock(edm::LuminosityBlock &lb) override
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:286
static void fillDescription(edm::ParameterSetDescription &d)
DQMProtobufReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
Helper class to handle FWLite file input sources.
void put(std::auto_ptr< PROD > product)
Put a new product.