File indexing completed on 2022-05-01 22:51:55
0001 #ifndef DQMServices_Core_DQMStore_h
0002 #define DQMServices_Core_DQMStore_h
0003
0004 #include "DQMServices/Core/interface/MonitorElement.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006
0007 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0008
0009 #include <type_traits>
0010 #include <functional>
0011 #include <mutex>
0012
0013
0014 #define TRACE(msg) \
0015 std::cout << "TRACE: " << __FILE__ << ":" << __LINE__ << "(" << __FUNCTION__ << ") " << msg << std::endl;
0016 #define TRACE_ TRACE("");
0017
0018 namespace dqm {
0019 namespace implementation {
0020 using MonitorElement = dqm::legacy::MonitorElement;
0021 class DQMStore;
0022
0023
0024 class NavigatorBase {
0025 public:
0026 virtual void cd();
0027
0028 DQM_DEPRECATED
0029 virtual void cd(std::string const& dir);
0030
0031 virtual void setCurrentFolder(std::string const& fullpath);
0032 virtual void goUp();
0033
0034 virtual std::string pwd();
0035
0036 virtual ~NavigatorBase() {}
0037
0038 protected:
0039 NavigatorBase(){};
0040 std::string cwd_ = "";
0041 };
0042
0043 class IBooker : public dqm::implementation::NavigatorBase {
0044 public:
0045
0046 friend class DQMStore;
0047
0048
0049 struct NOOP {
0050 void operator()(TH1*) const {};
0051 void operator()() const {};
0052 };
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0073 MonitorElement* bookInt(TString const& name, FUNC onbooking = NOOP()) {
0074 return bookME(name, MonitorElementData::Kind::INT, [=]() {
0075 onbooking();
0076 return nullptr;
0077 });
0078 }
0079 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0080 MonitorElement* bookFloat(TString const& name, FUNC onbooking = NOOP()) {
0081 return bookME(name, MonitorElementData::Kind ::REAL, [=]() {
0082 onbooking();
0083 return nullptr;
0084 });
0085 }
0086 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0087 MonitorElement* bookString(TString const& name, TString const& value, FUNC onbooking = NOOP()) {
0088 std::string initial_value(value);
0089 auto me = bookME(name, MonitorElementData::Kind::STRING, [=]() {
0090 onbooking();
0091 return nullptr;
0092 });
0093 me->Fill(initial_value);
0094 return me;
0095 }
0096
0097 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0098 MonitorElement* book1D(TString const& name,
0099 TString const& title,
0100 int const nchX,
0101 double const lowX,
0102 double const highX,
0103 FUNC onbooking = NOOP()) {
0104 return bookME(name, MonitorElementData::Kind::TH1F, [=]() {
0105 auto th1 = new TH1F(name, title, nchX, lowX, highX);
0106 onbooking(th1);
0107 return th1;
0108 });
0109 }
0110 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0111 MonitorElement* book1D(
0112 TString const& name, TString const& title, int nchX, float const* xbinsize, FUNC onbooking = NOOP()) {
0113 return bookME(name, MonitorElementData::Kind::TH1F, [=]() {
0114 auto th1 = new TH1F(name, title, nchX, xbinsize);
0115 onbooking(th1);
0116 return th1;
0117 });
0118 }
0119 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0120 MonitorElement* book1D(TString const& name, TH1F* object, FUNC onbooking = NOOP()) {
0121 return bookME(
0122 name,
0123 MonitorElementData::Kind::TH1F,
0124 [=]() {
0125 auto th1 = static_cast<TH1F*>(object->Clone(name));
0126 onbooking(th1);
0127 return th1;
0128 },
0129 true);
0130 }
0131
0132 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0133 MonitorElement* book1S(
0134 TString const& name, TString const& title, int nchX, double lowX, double highX, FUNC onbooking = NOOP()) {
0135 return bookME(name, MonitorElementData::Kind::TH1S, [=]() {
0136 auto th1 = new TH1S(name, title, nchX, lowX, highX);
0137 onbooking(th1);
0138 return th1;
0139 });
0140 }
0141 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0142 MonitorElement* book1S(TString const& name, TH1S* object, FUNC onbooking = NOOP()) {
0143 return bookME(
0144 name,
0145 MonitorElementData::Kind::TH1S,
0146 [=]() {
0147 auto th1 = static_cast<TH1S*>(object->Clone(name));
0148 onbooking(th1);
0149 return th1;
0150 },
0151 true);
0152 }
0153
0154 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0155 MonitorElement* book1DD(
0156 TString const& name, TString const& title, int nchX, double lowX, double highX, FUNC onbooking = NOOP()) {
0157 return bookME(name, MonitorElementData::Kind::TH1D, [=]() {
0158 auto th1 = new TH1D(name, title, nchX, lowX, highX);
0159 onbooking(th1);
0160 return th1;
0161 });
0162 }
0163 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0164 MonitorElement* book1DD(TString const& name, TH1D* object, FUNC onbooking = NOOP()) {
0165 return bookME(
0166 name,
0167 MonitorElementData::Kind::TH1D,
0168 [=]() {
0169 auto th1 = static_cast<TH1D*>(object->Clone(name));
0170 onbooking(th1);
0171 return th1;
0172 },
0173 true);
0174 }
0175
0176 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0177 MonitorElement* book1I(TString const& name,
0178 TString const& title,
0179 int const nchX,
0180 double const lowX,
0181 double const highX,
0182 FUNC onbooking = NOOP()) {
0183 return bookME(name, MonitorElementData::Kind::TH1I, [=]() {
0184 auto th1 = new TH1I(name, title, nchX, lowX, highX);
0185 onbooking(th1);
0186 return th1;
0187 });
0188 }
0189 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0190 MonitorElement* book1I(
0191 TString const& name, TString const& title, int nchX, float const* xbinsize, FUNC onbooking = NOOP()) {
0192 return bookME(name, MonitorElementData::Kind::TH1I, [=]() {
0193 auto th1 = new TH1I(name, title, nchX, xbinsize);
0194 onbooking(th1);
0195 return th1;
0196 });
0197 }
0198 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0199 MonitorElement* book1I(TString const& name, TH1I* object, FUNC onbooking = NOOP()) {
0200 return bookME(
0201 name,
0202 MonitorElementData::Kind::TH1I,
0203 [=]() {
0204 auto th1 = static_cast<TH1I*>(object->Clone(name));
0205 onbooking(th1);
0206 return th1;
0207 },
0208 true);
0209 }
0210
0211 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0212 MonitorElement* book2D(TString const& name,
0213 TString const& title,
0214 int nchX,
0215 double lowX,
0216 double highX,
0217 int nchY,
0218 double lowY,
0219 double highY,
0220 FUNC onbooking = NOOP()) {
0221 return bookME(name, MonitorElementData::Kind::TH2F, [=]() {
0222 auto th2 = new TH2F(name, title, nchX, lowX, highX, nchY, lowY, highY);
0223 onbooking(th2);
0224 return th2;
0225 });
0226 }
0227 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0228 MonitorElement* book2D(TString const& name,
0229 TString const& title,
0230 int nchX,
0231 float const* xbinsize,
0232 int nchY,
0233 float const* ybinsize,
0234 FUNC onbooking = NOOP()) {
0235 return bookME(name, MonitorElementData::Kind::TH2F, [=]() {
0236 auto th2 = new TH2F(name, title, nchX, xbinsize, nchY, ybinsize);
0237 onbooking(th2);
0238 return th2;
0239 });
0240 }
0241 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0242 MonitorElement* book2D(TString const& name, TH2F* object, FUNC onbooking = NOOP()) {
0243 return bookME(
0244 name,
0245 MonitorElementData::Kind::TH2F,
0246 [=]() {
0247 auto th2 = static_cast<TH2F*>(object->Clone(name));
0248 onbooking(th2);
0249 return th2;
0250 },
0251 true);
0252 }
0253 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0254 MonitorElement* book2S(TString const& name,
0255 TString const& title,
0256 int nchX,
0257 double lowX,
0258 double highX,
0259 int nchY,
0260 double lowY,
0261 double highY,
0262 FUNC onbooking = NOOP()) {
0263 return bookME(name, MonitorElementData::Kind::TH2S, [=]() {
0264 auto th2 = new TH2S(name, title, nchX, lowX, highX, nchY, lowY, highY);
0265 onbooking(th2);
0266 return th2;
0267 });
0268 }
0269 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0270 MonitorElement* book2S(TString const& name,
0271 TString const& title,
0272 int nchX,
0273 float const* xbinsize,
0274 int nchY,
0275 float const* ybinsize,
0276 FUNC onbooking = NOOP()) {
0277 return bookME(name, MonitorElementData::Kind::TH2S, [=]() {
0278 auto th2 = new TH2S(name, title, nchX, xbinsize, nchY, ybinsize);
0279 onbooking(th2);
0280 return th2;
0281 });
0282 }
0283 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0284 MonitorElement* book2S(TString const& name, TH2S* object, FUNC onbooking = NOOP()) {
0285 return bookME(
0286 name,
0287 MonitorElementData::Kind::TH2S,
0288 [=]() {
0289 auto th2 = static_cast<TH2S*>(object->Clone(name));
0290 onbooking(th2);
0291 return th2;
0292 },
0293 true);
0294 }
0295 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0296 MonitorElement* book2I(TString const& name,
0297 TString const& title,
0298 int nchX,
0299 double lowX,
0300 double highX,
0301 int nchY,
0302 double lowY,
0303 double highY,
0304 FUNC onbooking = NOOP()) {
0305 return bookME(name, MonitorElementData::Kind::TH2I, [=]() {
0306 auto th2 = new TH2I(name, title, nchX, lowX, highX, nchY, lowY, highY);
0307 onbooking(th2);
0308 return th2;
0309 });
0310 }
0311 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0312 MonitorElement* book2I(TString const& name,
0313 TString const& title,
0314 int nchX,
0315 float const* xbinsize,
0316 int nchY,
0317 float const* ybinsize,
0318 FUNC onbooking = NOOP()) {
0319 return bookME(name, MonitorElementData::Kind::TH2I, [=]() {
0320 auto th2 = new TH2I(name, title, nchX, xbinsize, nchY, ybinsize);
0321 onbooking(th2);
0322 return th2;
0323 });
0324 }
0325 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0326 MonitorElement* book2I(TString const& name, TH2I* object, FUNC onbooking = NOOP()) {
0327 return bookME(
0328 name,
0329 MonitorElementData::Kind::TH2I,
0330 [=]() {
0331 auto th2 = static_cast<TH2I*>(object->Clone(name));
0332 onbooking(th2);
0333 return th2;
0334 },
0335 true);
0336 }
0337 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0338 MonitorElement* book2DD(TString const& name,
0339 TString const& title,
0340 int nchX,
0341 double lowX,
0342 double highX,
0343 int nchY,
0344 double lowY,
0345 double highY,
0346 FUNC onbooking = NOOP()) {
0347 return bookME(name, MonitorElementData::Kind::TH2D, [=]() {
0348 auto th2 = new TH2D(name, title, nchX, lowX, highX, nchY, lowY, highY);
0349 onbooking(th2);
0350 return th2;
0351 });
0352 }
0353 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0354 MonitorElement* book2DD(TString const& name, TH2D* object, FUNC onbooking = NOOP()) {
0355 return bookME(
0356 name,
0357 MonitorElementData::Kind::TH2D,
0358 [=]() {
0359 auto th2 = static_cast<TH2D*>(object->Clone(name));
0360 onbooking(th2);
0361 return th2;
0362 },
0363 true);
0364 }
0365
0366 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0367 MonitorElement* book3D(TString const& name,
0368 TString const& title,
0369 int nchX,
0370 double lowX,
0371 double highX,
0372 int nchY,
0373 double lowY,
0374 double highY,
0375 int nchZ,
0376 double lowZ,
0377 double highZ,
0378 FUNC onbooking = NOOP()) {
0379 return bookME(name, MonitorElementData::Kind::TH3F, [=]() {
0380 auto th3 = new TH3F(name, title, nchX, lowX, highX, nchY, lowY, highY, nchZ, lowZ, highZ);
0381 onbooking(th3);
0382 return th3;
0383 });
0384 }
0385 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0386 MonitorElement* book3D(TString const& name, TH3F* object, FUNC onbooking = NOOP()) {
0387 return bookME(
0388 name,
0389 MonitorElementData::Kind::TH3F,
0390 [=]() {
0391 auto th3 = static_cast<TH3F*>(object->Clone(name));
0392 onbooking(th3);
0393 return th3;
0394 },
0395 true);
0396 }
0397
0398 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0399 MonitorElement* bookProfile(TString const& name,
0400 TString const& title,
0401 int nchX,
0402 double lowX,
0403 double highX,
0404 int ,
0405 double lowY,
0406 double highY,
0407 char const* option = "s",
0408 FUNC onbooking = NOOP()) {
0409 return bookME(name, MonitorElementData::Kind::TPROFILE, [=]() {
0410 auto tprofile = new TProfile(name, title, nchX, lowX, highX, lowY, highY, option);
0411 onbooking(tprofile);
0412 return tprofile;
0413 });
0414 }
0415 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0416 MonitorElement* bookProfile(TString const& name,
0417 TString const& title,
0418 int nchX,
0419 double lowX,
0420 double highX,
0421 double lowY,
0422 double highY,
0423 char const* option = "s",
0424 FUNC onbooking = NOOP()) {
0425 return bookME(name, MonitorElementData::Kind::TPROFILE, [=]() {
0426 auto tprofile = new TProfile(name, title, nchX, lowX, highX, lowY, highY, option);
0427 onbooking(tprofile);
0428 return tprofile;
0429 });
0430 }
0431 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0432 MonitorElement* bookProfile(TString const& name,
0433 TString const& title,
0434 int nchX,
0435 double const* xbinsize,
0436 int ,
0437 double lowY,
0438 double highY,
0439 char const* option = "s",
0440 FUNC onbooking = NOOP()) {
0441 return bookME(name, MonitorElementData::Kind::TPROFILE, [=]() {
0442 auto tprofile = new TProfile(name, title, nchX, xbinsize, lowY, highY, option);
0443 onbooking(tprofile);
0444 return tprofile;
0445 });
0446 }
0447 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0448 MonitorElement* bookProfile(TString const& name,
0449 TString const& title,
0450 int nchX,
0451 double const* xbinsize,
0452 double lowY,
0453 double highY,
0454 char const* option = "s",
0455 FUNC onbooking = NOOP()) {
0456 return bookME(name, MonitorElementData::Kind::TPROFILE, [=]() {
0457 auto tprofile = new TProfile(name, title, nchX, xbinsize, lowY, highY, option);
0458 onbooking(tprofile);
0459 return tprofile;
0460 });
0461 }
0462 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0463 MonitorElement* bookProfile(TString const& name, TProfile* object, FUNC onbooking = NOOP()) {
0464 return bookME(
0465 name,
0466 MonitorElementData::Kind::TPROFILE,
0467 [=]() {
0468 auto tprofile = static_cast<TProfile*>(object->Clone(name));
0469 onbooking(tprofile);
0470 return tprofile;
0471 },
0472 true);
0473 }
0474
0475 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0476 MonitorElement* bookProfile2D(TString const& name,
0477 TString const& title,
0478 int nchX,
0479 double lowX,
0480 double highX,
0481 int nchY,
0482 double lowY,
0483 double highY,
0484 double lowZ,
0485 double highZ,
0486 char const* option = "s",
0487 FUNC onbooking = NOOP()) {
0488 return bookME(name, MonitorElementData::Kind::TPROFILE2D, [=]() {
0489 auto tprofile = new TProfile2D(name, title, nchX, lowX, highX, nchY, lowY, highY, lowZ, highZ, option);
0490 onbooking(tprofile);
0491 return tprofile;
0492 });
0493 }
0494 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0495 MonitorElement* bookProfile2D(TString const& name,
0496 TString const& title,
0497 int nchX,
0498 double lowX,
0499 double highX,
0500 int nchY,
0501 double lowY,
0502 double highY,
0503 int ,
0504 double lowZ,
0505 double highZ,
0506 char const* option = "s",
0507 FUNC onbooking = NOOP()) {
0508 return bookME(name, MonitorElementData::Kind::TPROFILE2D, [=]() {
0509 auto tprofile = new TProfile2D(name, title, nchX, lowX, highX, nchY, lowY, highY, lowZ, highZ, option);
0510 onbooking(tprofile);
0511 return tprofile;
0512 });
0513 }
0514 template <typename FUNC = NOOP, std::enable_if_t<not std::is_arithmetic<FUNC>::value, int> = 0>
0515 MonitorElement* bookProfile2D(TString const& name, TProfile2D* object, FUNC onbooking = NOOP()) {
0516 return bookME(
0517 name,
0518 MonitorElementData::Kind::TPROFILE2D,
0519 [=]() {
0520 auto tprofile = static_cast<TProfile2D*>(object->Clone(name));
0521 onbooking(tprofile);
0522 return tprofile;
0523 },
0524 true);
0525 }
0526
0527
0528
0529
0530
0531 virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope);
0532
0533 template <MonitorElementData::Scope SCOPE>
0534 struct UseScope {
0535 IBooker& parent;
0536 MonitorElementData::Scope oldscope;
0537 UseScope(IBooker& booker) : parent(booker) { oldscope = parent.setScope(SCOPE); }
0538 ~UseScope() { parent.setScope(oldscope); }
0539 };
0540 using UseLumiScope = UseScope<MonitorElementData::Scope::LUMI>;
0541 using UseRunScope = UseScope<MonitorElementData::Scope::RUN>;
0542 using UseJobScope = UseScope<MonitorElementData::Scope::JOB>;
0543
0544 ~IBooker() override;
0545
0546 private:
0547 IBooker(DQMStore* store);
0548 virtual uint64_t setModuleID(uint64_t moduleID);
0549 virtual edm::LuminosityBlockID setRunLumi(edm::LuminosityBlockID runlumi);
0550 virtual MonitorElement* bookME(TString const& name,
0551 MonitorElementData::Kind kind,
0552 std::function<TH1*()> makeobject,
0553 bool forceReplace = false);
0554
0555 DQMStore* store_ = nullptr;
0556 MonitorElementData::Scope scope_ = MonitorElementData::Scope::JOB;
0557 uint64_t moduleID_ = 0;
0558 edm::LuminosityBlockID runlumi_ = edm::LuminosityBlockID();
0559 };
0560
0561 class IGetter : public dqm::implementation::NavigatorBase {
0562 public:
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575 virtual std::vector<dqm::harvesting::MonitorElement*> getContents(std::string const& path) const;
0576
0577
0578
0579 virtual std::vector<dqm::harvesting::MonitorElement*> getAllContents(std::string const& path) const;
0580 DQM_DEPRECATED
0581 virtual std::vector<dqm::harvesting::MonitorElement*> getAllContents(std::string const& path,
0582 uint32_t runNumber,
0583 uint32_t lumi) const;
0584
0585
0586 virtual MonitorElement* get(std::string const& fullpath) const;
0587
0588
0589
0590 virtual MonitorElement* get(MonitorElementData::Key const& key) const;
0591
0592
0593
0594 DQM_DEPRECATED
0595 virtual MonitorElement* getElement(std::string const& path) const;
0596
0597
0598
0599
0600 DQM_DEPRECATED
0601 virtual std::vector<std::string> getSubdirs() const;
0602
0603 virtual std::vector<std::string> getMEs() const;
0604
0605 virtual bool dirExists(std::string const& path) const;
0606
0607 ~IGetter() override;
0608
0609 protected:
0610 IGetter(DQMStore* store);
0611
0612 DQMStore* store_;
0613 };
0614
0615 class DQMStore : public IGetter, public IBooker {
0616 public:
0617
0618 friend IGetter;
0619 enum OpenRunDirs { KeepRunDirs, StripRunDirs };
0620
0621 DQMStore(edm::ParameterSet const& pset, edm::ActivityRegistry&);
0622 DQMStore(DQMStore const&) = delete;
0623 DQMStore(DQMStore&&) = delete;
0624 DQMStore& operator=(DQMStore const&) = delete;
0625 ~DQMStore() override;
0626
0627
0628
0629 DQM_DEPRECATED
0630 void save(std::string const& filename, std::string const& path = "");
0631 DQM_DEPRECATED
0632 bool open(std::string const& filename,
0633 bool overwrite = false,
0634 std::string const& path = "",
0635 std::string const& prepend = "",
0636 OpenRunDirs stripdirs = KeepRunDirs,
0637 bool fileMustExist = true);
0638
0639
0640
0641 void cd() override { this->IBooker::cd(); }
0642 void cd(std::string const& dir) override { this->IBooker::cd(dir); }
0643 void goUp() override { this->IBooker::goUp(); }
0644 std::string pwd() override { return this->IBooker::pwd(); }
0645
0646 void setCurrentFolder(std::string const& fullpath) override {
0647
0648 this->IBooker::setCurrentFolder(fullpath);
0649 this->IGetter::setCurrentFolder(fullpath);
0650 }
0651
0652 public:
0653
0654 template <typename iFunc>
0655 void bookTransaction(iFunc f, uint64_t moduleId, bool canSaveByLumi) {
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668 auto lock = std::scoped_lock(this->booking_mutex_);
0669
0670
0671
0672
0673
0674 struct ModuleIdScope {
0675 IBooker& booker_;
0676 uint64_t oldid_;
0677 MonitorElementData::Scope oldscope_;
0678 edm::LuminosityBlockID oldrunlumi_;
0679 ModuleIdScope(IBooker& booker,
0680 uint64_t newid,
0681 MonitorElementData::Scope newscope,
0682 edm::LuminosityBlockID newrunlumi)
0683 : booker_(booker) {
0684 oldid_ = booker_.setModuleID(newid);
0685 oldscope_ = booker_.setScope(newscope);
0686 oldrunlumi_ = booker_.setRunLumi(newrunlumi);
0687 assert(newid != 0 || !"moduleID must be set for normal booking transaction");
0688 assert(oldid_ == 0 || !"Nested booking transaction?");
0689 }
0690 ~ModuleIdScope() {
0691 booker_.setModuleID(oldid_);
0692 booker_.setScope(oldscope_);
0693 booker_.setRunLumi(oldrunlumi_);
0694 }
0695 };
0696
0697 ModuleIdScope booker(
0698 *this,
0699 moduleId,
0700
0701 canSaveByLumi && this->doSaveByLumi_ ? MonitorElementData::Scope::LUMI : MonitorElementData::Scope::RUN,
0702
0703 edm::LuminosityBlockID());
0704
0705 f(booker.booker_);
0706 };
0707
0708 template <typename iFunc>
0709 void meBookerGetter(iFunc f) {
0710 auto lock = std::scoped_lock(this->booking_mutex_);
0711
0712
0713 f(*this, *this);
0714
0715
0716
0717 };
0718
0719
0720 MonitorElement* findOrRecycle(MonitorElementData::Key const&);
0721
0722
0723
0724
0725
0726 void initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi);
0727 void initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID);
0728
0729
0730
0731
0732 void enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID);
0733 void leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID);
0734
0735
0736
0737
0738 void cleanupLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi);
0739
0740
0741
0742
0743 MonitorElement* putME(MonitorElement* me);
0744
0745 MonitorElement* putME(MonitorElement* me, uint64_t moduleID);
0746
0747
0748 template <typename MELIKE>
0749 MonitorElement* findME(MELIKE const& path);
0750
0751 void printTrace(std::string const& message);
0752
0753 void debugTrackME(const char* message, MonitorElement* me_local, MonitorElement* me_global) const;
0754
0755 private:
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775 std::map<edm::LuminosityBlockID, std::set<MonitorElement*, MonitorElement::MEComparison>> globalMEs_;
0776
0777
0778
0779 std::map<uint64_t, std::set<MonitorElement*, MonitorElement::MEComparison>> localMEs_;
0780
0781
0782
0783 std::recursive_mutex booking_mutex_;
0784
0785
0786
0787 int verbose_;
0788
0789
0790
0791 bool assertLegacySafe_;
0792
0793
0794 bool doSaveByLumi_;
0795 std::vector<std::string> MEsToSave_;
0796
0797
0798
0799 std::string trackME_;
0800 };
0801 }
0802
0803
0804 namespace legacy {
0805 class DQMStore : public dqm::implementation::DQMStore {
0806 public:
0807 using IBooker = dqm::implementation::IBooker;
0808 using IGetter = dqm::implementation::IGetter;
0809
0810 using dqm::implementation::DQMStore::DQMStore;
0811 };
0812 }
0813 namespace reco {
0814 using DQMStore = dqm::legacy::DQMStore;
0815 }
0816 namespace harvesting {
0817 using DQMStore = dqm::legacy::DQMStore;
0818 }
0819 }
0820
0821 #endif