CMS 3D CMS Logo

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