CMS 3D CMS Logo

DQMProtobufReader.cc
Go to the documentation of this file.
1 #include "DQMProtobufReader.h"
2 
6 
8 // #include "FWCore/Sources/interface/ProducerSourceBase.h"
9 
10 using namespace dqmservices;
11 
13  edm::InputSourceDescription const& desc)
14  : PuttableSourceBase(pset, desc), fiterator_(pset) {
15 
16  flagSkipFirstLumis_ = pset.getUntrackedParameter<bool>("skipFirstLumis");
17  flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
18  flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");
19  flagLoadFiles_ = pset.getUntrackedParameter<bool>("loadFiles");
20 
21  produces<std::string, edm::Transition::BeginLuminosityBlock>("sourceDataPath");
22  produces<std::string, edm::Transition::BeginLuminosityBlock>("sourceJsonPath");
23 }
24 
26 
29  typedef DQMFileIterator::LumiEntry LumiEntry;
30 
31  // fiterator_.logFileAction("getNextItemType");
32 
33  for (;;) {
35 
36  if (edm::shutdown_flag.load()) {
37  fiterator_.logFileAction("Shutdown flag was set, shutting down.");
38  return InputSource::IsStop;
39  }
40 
41  // check for end of run file and force quit
42  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
43  return InputSource::IsStop;
44  }
45 
46  // check for end of run and quit if everything has been processed.
47  // this is the clean exit
48  if ((!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
49  return InputSource::IsStop;
50  }
51 
52  // skip to the next file if we have no files openned yet
53  if (fiterator_.lumiReady()) {
54  return InputSource::IsLumi;
55  }
56 
57  fiterator_.delay();
58  // BUG: for an unknown reason it fails after a certain time if we use
59  // IsSynchronize state
60  //
61  // comment out in order to block at this level
62  // return InputSource::IsSynchronize;
63  }
64 
65  // this is unreachable
66 }
67 
68 std::shared_ptr<edm::RunAuxiliary> DQMProtobufReader::readRunAuxiliary_() {
69  // fiterator_.logFileAction("readRunAuxiliary_");
70 
73  return std::shared_ptr<edm::RunAuxiliary>(aux);
74 }
75 
77  // fiterator_.logFileAction("readRun_");
79 
81  std::vector<MonitorElement*> allMEs = store->getAllContents("");
82  for (auto const& ME : allMEs) {
83  ME->Reset();
84  }
85 }
86 
87 std::shared_ptr<edm::LuminosityBlockAuxiliary>
89  // fiterator_.logFileAction("readLuminosityBlockAuxiliary_");
90 
94  edm::Timestamp());
95 
96  return std::shared_ptr<edm::LuminosityBlockAuxiliary>(aux);
97 }
98 
101  // fiterator_.logFileAction("readLuminosityBlock_");
102 
104  jr->reportInputLumiSection(lbCache.id().run(),
105  lbCache.id().luminosityBlock());
107 }
108 
111 
112  // clear the old lumi histograms
113  std::vector<MonitorElement*> allMEs = store->getAllContents("");
114  for (auto const& ME : allMEs) {
115  // We do not want to reset Run Products here!
116  if (ME->getLumiFlag()) {
117  ME->Reset();
118  }
119  }
120 
121  // load the new file
124 
125  std::unique_ptr<std::string> path_product(new std::string(path));
126  std::unique_ptr<std::string> json_product(new std::string(jspath));
127 
128  lb.put(std::move(path_product), "sourceDataPath");
129  lb.put(std::move(json_product), "sourceJsonPath");
130 
131  if (flagLoadFiles_) {
132  if (!boost::filesystem::exists(path)) {
133  fiterator_.logFileAction("Data file is missing ", path);
134  fiterator_.logLumiState(currentLumi_, "error: data file missing");
135  return;
136  }
137 
138  fiterator_.logFileAction("Initiating request to open file ", path);
139  fiterator_.logFileAction("Successfully opened file ", path);
140  store->load(path);
141  fiterator_.logFileAction("Closed file ", path);
142  fiterator_.logLumiState(currentLumi_, "close: ok");
143  } else {
144  fiterator_.logFileAction("Not loading the data file at source level ", path);
145  fiterator_.logLumiState(currentLumi_, "close: not loading");
146  }
147 }
148 
149 
151 
153  edm::ConfigurationDescriptions& descriptions) {
155 
156  desc.setComment(
157  "Creates runs and lumis and fills the dqmstore from protocol buffer "
158  "files.");
160 
161  desc.addUntracked<bool>("skipFirstLumis", false)
162  ->setComment(
163  "Skip (and ignore the minEventsPerLumi parameter) for the files "
164  "which have been available at the begining of the processing. "
165  "If set to true, the reader will open last available file for "
166  "processing.");
167 
168  desc.addUntracked<bool>("deleteDatFiles", false)
169  ->setComment(
170  "Delete data files after they have been closed, in order to "
171  "save disk space.");
172 
173  desc.addUntracked<bool>("endOfRunKills", false)
174  ->setComment(
175  "Kill the processing as soon as the end-of-run file appears, even if "
176  "there are/will be unprocessed lumisections.");
177 
178  desc.addUntracked<bool>("loadFiles", true)
179  ->setComment(
180  "Tells the source load the data files. If set to false, source will create skeleton lumi transitions.");
181 
183  descriptions.add("source", desc);
184 }
185 
188 
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void readEvent_(edm::EventPrincipal &) override
void logLumiState(const LumiEntry &lumi, const std::string &msg)
volatile std::atomic< bool > shutdown_flag
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
Definition: RunPrincipal.cc:20
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void readRun_(edm::RunPrincipal &rpCache) override
void readLuminosityBlock_(edm::LuminosityBlockPrincipal &lbCache) override
Definition: ME.h:11
void setComment(std::string const &value)
void fillLuminosityBlockPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
std::shared_ptr< edm::RunAuxiliary > readRunAuxiliary_() override
#define DEFINE_FWK_INPUT_SOURCE(type)
void put(std::unique_ptr< PROD > product)
Put a new product.
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:492
std::shared_ptr< edm::LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
RunNumber_t run() const
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_
def load(fileName)
Definition: svgfig.py:546
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:335
edm::InputSource::ItemType getNextItemType() override
static void fillDescription(edm::ParameterSetDescription &d)
DQMProtobufReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
def move(src, dest)
Definition: eostools.py:510