11 #include <google/protobuf/io/coded_stream.h>
12 #include <google/protobuf/io/gzip_stream.h>
13 #include <google/protobuf/io/zero_copy_stream_impl.h>
15 #include "TBufferFile.h"
20 using namespace dqmservices;
29 produces<std::string, edm::Transition::BeginLuminosityBlock>(
"sourceDataPath");
30 produces<std::string, edm::Transition::BeginLuminosityBlock>(
"sourceJsonPath");
31 produces<DQMToken, edm::Transition::BeginRun>(
"DQMGenerationRecoRun");
32 produces<DQMToken, edm::Transition::BeginLuminosityBlock>(
"DQMGenerationRecoLumi");
48 return InputSource::IsStop;
53 return InputSource::IsStop;
59 return InputSource::IsStop;
64 return InputSource::IsLumi;
82 return std::shared_ptr<edm::RunAuxiliary>(
aux);
91 for (
auto const&
ME : allMEs) {
103 return std::shared_ptr<edm::LuminosityBlockAuxiliary>(
aux);
119 for (
auto const&
ME : allMEs) {
121 if (
ME->getLumiFlag()) {
130 std::unique_ptr<std::string> path_product(
new std::string(path));
131 std::unique_ptr<std::string> json_product(
new std::string(jspath));
137 if (!std::filesystem::exists(path)) {
155 using google::protobuf::io::ArrayInputStream;
156 using google::protobuf::io::CodedInputStream;
157 using google::protobuf::io::FileInputStream;
158 using google::protobuf::io::FileOutputStream;
159 using google::protobuf::io::GzipInputStream;
160 using google::protobuf::io::GzipOutputStream;
163 if ((filedescriptor = ::open(filename.c_str(), O_RDONLY)) == -1) {
164 edm::LogError(
"DQMProtobufReader") <<
"File " << filename <<
" does not exist.";
167 dqmstorepb::ROOTFilePB dqmstore_message;
168 FileInputStream
fin(filedescriptor);
169 GzipInputStream
input(&fin);
170 CodedInputStream input_coded(&input);
171 input_coded.SetTotalBytesLimit(1024 * 1024 * 1024);
172 if (!dqmstore_message.ParseFromCodedStream(&input_coded)) {
173 edm::LogError(
"DQMProtobufReader") <<
"Fatal parsing file '" << filename <<
"'";
176 ::close(filedescriptor);
178 for (
int i = 0;
i < dqmstore_message.histo_size(); ++
i) {
179 TObject*
obj =
nullptr;
180 dqmstorepb::ROOTFilePB::Histo
const&
h = dqmstore_message.histo(
i);
182 size_t slash = h.full_pathname().rfind(
'/');
183 size_t dirpos = (slash == std::string::npos ? 0 :
slash);
184 size_t namepos = (slash == std::string::npos ? 0 : slash + 1);
186 dirname.assign(h.full_pathname(), 0, dirpos);
187 objname.assign(h.full_pathname(), namepos, std::string::npos);
188 TBufferFile
buf(TBufferFile::kRead, h.size(), (
void*)h.streamed_histo().data(), kFALSE);
190 if (
buf.Length() ==
buf.BufferSize()) {
194 void* ptr =
buf.ReadObjectAny(
nullptr);
195 obj =
reinterpret_cast<TObject*
>(ptr);
199 edm::LogError(
"DQMProtobufReader") <<
"Error reading element:'" << h.full_pathname();
205 store->
setScope(MonitorElementData::Scope::LUMI);
207 store->
setScope(MonitorElementData::Scope::RUN);
214 auto expression =
std::string(static_cast<TObjString*>(obj)->String().
View());
215 std::regex parseint{
"<.*>i=(.*)</.*>"};
217 bool ok = std::regex_match(expression, match, parseint);
219 edm::LogError(
"DQMProtobufReader") <<
"Malformed object of type INT: '" << expression <<
"'";
222 int value = std::atoi(match[1].
str().c_str());
226 auto expression =
std::string(static_cast<TObjString*>(obj)->String().
View());
227 std::regex parsefloat{
"<.*>f=(.*)</.*>"};
229 bool ok = std::regex_match(expression, match, parsefloat);
231 edm::LogError(
"DQMProtobufReader") <<
"Malformed object of type REAL: '" << expression <<
"'";
234 double value = std::atof(match[1].
str().c_str());
237 auto value =
static_cast<TObjString*
>(
obj)->String();
240 auto value =
static_cast<TH1F*
>(
obj);
243 auto value =
static_cast<TH1S*
>(
obj);
246 auto value =
static_cast<TH1D*
>(
obj);
249 auto value =
static_cast<TH1I*
>(
obj);
252 auto value =
static_cast<TH2F*
>(
obj);
255 auto value =
static_cast<TH2S*
>(
obj);
258 auto value =
static_cast<TH2D*
>(
obj);
261 auto value =
static_cast<TH2I*
>(
obj);
264 auto value =
static_cast<TH3F*
>(
obj);
267 auto value =
static_cast<TProfile*
>(
obj);
270 auto value =
static_cast<TProfile2D*
>(
obj);
286 "Creates runs and lumis and fills the dqmstore from protocol buffer "
292 "Skip (and ignore the minEventsPerLumi parameter) for the files "
293 "which have been available at the begining of the processing. "
294 "If set to true, the reader will open last available file for "
299 "Delete data files after they have been closed, in order to "
304 "Kill the processing as soon as the end-of-run file appears, even if "
305 "there are/will be unprocessed lumisections.");
309 "Tells the source load the data files. If set to false, source will create skeleton lumi transitions.");
312 descriptions.
add(
"source", desc);
T getUntrackedParameter(std::string const &, T const &) 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())
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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
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)
LuminosityBlockAuxiliary const & aux() const
static const uint32_t DQM_PROP_TYPE_TH3F
std::string get_json_path() const
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
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
void readLuminosityBlock_(edm::LuminosityBlockPrincipal &lbCache) override
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
static std::string const input
DQMFileIterator fiterator_
void setComment(std::string const &value)
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())
std::string get_data_path() const
void put(std::unique_ptr< PROD > product)
Put a new product.
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())
void logFileAction(const std::string &msg, const std::string &fileName="") const
static const uint32_t DQM_PROP_TYPE_TH1D
static const uint32_t DQM_PROP_TYPE_TH1I
DQMFileIterator::LumiEntry currentLumi_
static void fillDescription(ParameterSetDescription &desc)
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())
LuminosityBlockNumber_t luminosityBlock() const
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
~DQMProtobufReader() override
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
static const uint32_t DQM_PROP_TYPE_STRING
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
LuminosityBlockID id() const
static const uint32_t DQM_PROP_TYPE_TH2F