CMS 3D CMS Logo

GEMEfficiencyHarvester.cc
Go to the documentation of this file.
2 
5 
7  : GEMDQMEfficiencyClientBase(ps), kFolders_(ps.getUntrackedParameter<std::vector<std::string> >("folders")) {}
8 
10 
13 
14  // GEMDQMEfficiencyClientBase
15  desc.addUntracked<double>("confidenceLevel", 0.683); // 1-sigma
16  desc.addUntracked<std::string>("logCategory", "GEMEfficiencyHarvester");
17 
18  // GEMEfficiencyHarvester
19  desc.addUntracked<std::vector<std::string> >("folders", {"GEM/Efficiency/muonSTA"});
20  descriptions.add("gemEfficiencyHarvester", desc);
21 }
22 
23 // boook MEs for
24 // - efficiency vs camber id
25 // - efficiency vs ieta
26 // by projecting MEs used for 2d chamber-ieta efficiency.
28  DQMStore::IGetter& igetter,
29  const std::string& folder) {
30  const std::map<std::string, MEPair> me_pairs = makeEfficiencySourcePair(ibooker, igetter, folder, "chamber_ieta_");
31 
32  for (const auto& [key, value] : me_pairs) {
33  // numerator and denominator
34  const auto& [me_num, me_den] = value;
35 
36  if (me_num->kind() != MonitorElement::Kind::TH2F) {
37  edm::LogError(kLogCategory_) << key << "expected TH2F but got "; // TODO
38  continue;
39  }
40 
41  const TH2F* h_num = me_num->getTH2F();
42  if (h_num == nullptr) {
43  edm::LogError(kLogCategory_) << "numerator: failed to get TH2F from MonitorElement" << key;
44  continue;
45  }
46 
47  const TH2F* h_den = me_den->getTH2F();
48  if (h_den == nullptr) {
49  edm::LogError(kLogCategory_) << "denominator: failed to get TH2F from MonitorElement" << key;
50  continue;
51  }
52 
53  const auto [parsing_success, var_name, gem_name, is_matched] = parseEfficiencySourceName(me_den->getName());
54  if (not parsing_success) {
55  edm::LogError(kLogCategory_) << "failed to parse " << me_den->getName();
56  continue;
57  }
58 
59  // TODO sanity-check
60  const TH1F* h_chamber_num = projectHistogram(h_num, TH1::kXaxis);
61  const TH1F* h_chamber_den = projectHistogram(h_den, TH1::kXaxis);
62  const char* eff_chamber_name = Form("eff_chamber_%s", gem_name.c_str());
63  if (TH1F* eff = makeEfficiency(h_chamber_num, h_chamber_den, eff_chamber_name)) {
64  ibooker.book1D(eff_chamber_name, eff);
65  }
66 
67  const TH1F* h_ieta_num = projectHistogram(h_num, TH1::kYaxis);
68  const TH1F* h_ieta_den = projectHistogram(h_den, TH1::kYaxis);
69  const char* eff_ieta_name = Form("eff_ieta_%s", gem_name.c_str());
70  if (TH1F* eff = makeEfficiency(h_ieta_num, h_ieta_den, eff_ieta_name)) {
71  ibooker.book1D(eff_ieta_name, eff);
72  }
73  } // pairs
74 }
75 
77  for (const std::string& folder : kFolders_) {
78  bookEfficiencyAuto(ibooker, igetter, folder);
79  bookDetector1DEfficiency(ibooker, igetter, folder);
80  }
81 }
void bookDetector1DEfficiency(DQMStore::IBooker &, DQMStore::IGetter &, const std::string &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
GEMEfficiencyHarvester(const edm::ParameterSet &)
TH1F * makeEfficiency(const TH1F *, const TH1F *, const char *name=nullptr, const char *title=nullptr)
void bookEfficiencyAuto(DQMStore::IBooker &, DQMStore::IGetter &, const std::string &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
Log< level::Error, false > LogError
TH1F * projectHistogram(const TH2F *, const unsigned int)
key
prepare the HTCondor submission files and eventually submit them
Definition: value.py:1
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::tuple< bool, std::string, std::string, bool > parseEfficiencySourceName(std::string)
std::map< std::string, MEPair > makeEfficiencySourcePair(DQMStore::IBooker &, DQMStore::IGetter &, const std::string &, const std::string prefix="")
const std::vector< std::string > kFolders_