20 #include <TBufferFile.h> 22 #include <google/protobuf/io/coded_stream.h> 23 #include <google/protobuf/io/gzip_stream.h> 24 #include <google/protobuf/io/zero_copy_stream_impl.h> 31 flagSkipFirstLumis_(
pset.getUntrackedParameter<
bool>(
"skipFirstLumis")),
32 flagEndOfRunKills_(
pset.getUntrackedParameter<
bool>(
"endOfRunKills")),
33 flagDeleteDatFiles_(
pset.getUntrackedParameter<
bool>(
"deleteDatFiles")),
34 flagLoadFiles_(
pset.getUntrackedParameter<
bool>(
"loadFiles")) {
35 produces<std::string, edm::Transition::BeginLuminosityBlock>(
"sourceDataPath");
36 produces<std::string, edm::Transition::BeginLuminosityBlock>(
"sourceJsonPath");
37 produces<DQMToken, edm::Transition::BeginRun>(
"DQMGenerationRecoRun");
38 produces<DQMToken, edm::Transition::BeginLuminosityBlock>(
"DQMGenerationRecoLumi");
52 return InputSource::IsStop;
57 return InputSource::IsStop;
63 return InputSource::IsStop;
68 return InputSource::IsLumi;
86 return std::shared_ptr<edm::RunAuxiliary>(
aux);
95 for (
auto const&
ME : allMEs) {
107 return std::shared_ptr<edm::LuminosityBlockAuxiliary>(
aux);
123 for (
auto const&
ME : allMEs) {
125 if (
ME->getLumiFlag()) {
135 std::unique_ptr<std::string> json_product(
new std::string(jspath));
141 if (!std::filesystem::exists(
path)) {
159 using google::protobuf::io::ArrayInputStream;
160 using google::protobuf::io::CodedInputStream;
161 using google::protobuf::io::FileInputStream;
162 using google::protobuf::io::FileOutputStream;
163 using google::protobuf::io::GzipInputStream;
164 using google::protobuf::io::GzipOutputStream;
167 if ((filedescriptor = ::open(
filename.c_str(), O_RDONLY)) == -1) {
172 FileInputStream
fin(filedescriptor);
174 CodedInputStream input_coded(&
input);
175 input_coded.SetTotalBytesLimit(1024 * 1024 * 1024);
176 if (!dqmstore_message.ParseFromCodedStream(&input_coded)) {
180 ::close(filedescriptor);
183 TObject*
obj =
nullptr;
186 size_t slash =
h.full_pathname().rfind(
'/');
187 size_t dirpos = (
slash == std::string::npos ? 0 :
slash);
188 size_t namepos = (
slash == std::string::npos ? 0 :
slash + 1);
190 dirname.assign(
h.full_pathname(), 0, dirpos);
191 objname.assign(
h.full_pathname(), namepos, std::string::npos);
192 TBufferFile
buf(TBufferFile::kRead,
h.size(), (
void*)
h.streamed_histo().data(), kFALSE);
194 if (
buf.Length() ==
buf.BufferSize()) {
198 void* ptr =
buf.ReadObjectAny(
nullptr);
199 obj =
reinterpret_cast<TObject*
>(ptr);
203 edm::LogError(
"DQMProtobufReader") <<
"Error reading element:'" <<
h.full_pathname();
209 store->
setScope(MonitorElementData::Scope::LUMI);
211 store->
setScope(MonitorElementData::Scope::RUN);
219 std::regex parseint{
"<.*>i=(.*)</.*>"};
221 bool ok = std::regex_match(
expression, match, parseint);
226 int value = std::atoi(match[1].
str().c_str());
231 std::regex parsefloat{
"<.*>f=(.*)</.*>"};
233 bool ok = std::regex_match(
expression, match, parsefloat);
238 double value = std::atof(match[1].
str().c_str());
241 auto value =
static_cast<TObjString*
>(
obj)->String();
244 auto value =
static_cast<TH1F*
>(
obj);
247 auto value =
static_cast<TH1S*
>(
obj);
250 auto value =
static_cast<TH1D*
>(
obj);
253 auto value =
static_cast<TH1I*
>(
obj);
256 auto value =
static_cast<TH2F*
>(
obj);
259 auto value =
static_cast<TH2S*
>(
obj);
262 auto value =
static_cast<TH2D*
>(
obj);
265 auto value =
static_cast<TH2I*
>(
obj);
268 auto value =
static_cast<TH3F*
>(
obj);
271 auto value =
static_cast<TProfile*
>(
obj);
274 auto value =
static_cast<TProfile2D*
>(
obj);
289 desc.setComment(
"Creates runs and lumis and fills the dqmstore from protocol buffer files.");
292 desc.addUntracked<
bool>(
"skipFirstLumis",
false)
294 "Skip (and ignore the minEventsPerLumi parameter) for the files which have been available at the begining of " 295 "the processing. If set to true, the reader will open last available file for processing.");
297 desc.addUntracked<
bool>(
"deleteDatFiles",
false)
298 ->setComment(
"Delete data files after they have been closed, in order to save disk space.");
300 desc.addUntracked<
bool>(
"endOfRunKills",
false)
302 "Kill the processing as soon as the end-of-run file appears, even if there are/will be unprocessed " 305 desc.addUntracked<
bool>(
"loadFiles",
true)
307 "Tells the source to load the data files. If set to False, the source will create skeleton lumi " 311 descriptions.
add(
"source",
desc);
LuminosityBlockID id() const
LuminosityBlockNumber_t luminosityBlock() const
static const uint32_t DQM_PROP_TYPE_TH1S
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
bool const flagLoadFiles_
static const uint32_t DQM_PROP_TYPE_TPROF
MonitorElement * book1I(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
void readEvent_(edm::EventPrincipal &) override
unsigned int runNumber() const
static const uint32_t DQM_PROP_TYPE_TH2D
void load(DQMStore *store, std::string filename)
void fillLuminosityBlockPrincipal(ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
void logLumiState(const LumiEntry &lumi, const std::string &msg)
ProcessHistoryID const & processHistoryID() const
volatile std::atomic< bool > shutdown_flag
void setCurrentFolder(std::string const &fullpath) override
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
bool const flagEndOfRunKills_
static const uint32_t DQM_PROP_TYPE_TH3F
static const uint32_t DQM_PROP_TYPE_TH1F
Log< level::Error, false > LogError
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void readRun_(edm::RunPrincipal &rpCache) override
void readLuminosityBlock_(edm::LuminosityBlockPrincipal &lbCache) override
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
static std::string const input
DQMFileIterator fiterator_
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
std::shared_ptr< edm::RunAuxiliary > readRunAuxiliary_() override
static const uint32_t DQM_PROP_TYPE_INT
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
void put(std::unique_ptr< PROD > product)
Put a new product.
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
std::shared_ptr< edm::LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
void beginLuminosityBlock(edm::LuminosityBlock &lb) override
MonitorElement * book1S(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
static const uint32_t DQM_PROP_TYPE_TH1D
std::string get_data_path() const
static const uint32_t DQM_PROP_TYPE_TH1I
DQMFileIterator::LumiEntry currentLumi_
void logFileAction(const std::string &msg, const std::string &fileName="") const
static void fillDescription(ParameterSetDescription &desc)
const ::dqmstorepb::ROOTFilePB_Histo & histo(int index) const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MonitorElement * book2DD(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::InputSource::ItemType getNextItemType() override
static const uint32_t DQM_PROP_TYPE_TH2S
static const uint32_t DQM_PROP_TYPE_STRING
LuminosityBlockAuxiliary const & aux() const
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
static const uint32_t DQM_PROP_TYPE_MASK
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
MonitorElement * book3D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, FUNC onbooking=NOOP())
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
static const uint32_t DQM_PROP_LUMI
static const uint32_t DQM_PROP_TYPE_TH2I
static const uint32_t DQM_PROP_TYPE_REAL
static void fillDescription(edm::ParameterSetDescription &d)
DQMProtobufReader(edm::ParameterSet const &, edm::InputSourceDescription const &)
static const uint32_t DQM_PROP_TYPE_TPROF2D
static const uint32_t DQM_PROP_TYPE_TH2F
std::string get_json_path() const