CMS 3D CMS Logo

HLTTauPostProcessor.cc
Go to the documentation of this file.
4 
5 #include "TEfficiency.h"
6 #include "TProfile.h"
7 
8 #include <tuple>
9 
10 namespace {
11  std::tuple<float, float> calcEfficiency(float num, float denom) {
12  if (denom == 0.0f)
13  return std::make_tuple(0.0f, 0.0f);
14 
15  //float eff = num/denom;
16  constexpr double cl = 0.683f; // "1-sigma"
17  const float eff = num / denom;
18  const float errDown = TEfficiency::ClopperPearson(denom, num, cl, false);
19  const float errUp = TEfficiency::ClopperPearson(denom, num, cl, true);
20 
21  // Because of limitation of TProfile, just take max
22  return std::make_tuple(eff, std::max(eff - errDown, errUp - eff));
23  }
24 } // namespace
25 
27  : dqmBaseFolder_(ps.getUntrackedParameter<std::string>("DQMBaseFolder")) {}
28 
30 
32  if (!iGetter.dirExists(dqmBaseFolder_)) {
33  LogDebug("HLTTauDQMOffline") << "Folder " << dqmBaseFolder_ << " does not exist";
34  return;
35  }
37  for (const std::string& subfolder : iGetter.getSubdirs()) {
38  std::size_t pos = subfolder.rfind('/');
39  if (pos == std::string::npos)
40  continue;
41  ++pos; // position of first letter after /
42  if (subfolder.compare(pos, 4, "HLT_") == 0) { // start with HLT_
43  LogDebug("HLTTauDQMOffline") << "Processing path " << subfolder.substr(pos);
44  plotFilterEfficiencies(iBooker, iGetter, subfolder);
45  }
46  }
47 }
48 
50  DQMStore::IGetter& iGetter,
51  const std::string& folder) const {
52  // Get the source
53  const MonitorElement* eventsPerFilter = iGetter.get(folder + "/EventsPerFilter");
54  if (!eventsPerFilter) {
55  LogDebug("HLTTauDQMOffline") << "ME " << folder << "/EventsPerFilter not found";
56  return;
57  }
58 
59  // Book efficiency TProfile
60  iBooker.setCurrentFolder(folder);
61  MonitorElement* efficiency = iBooker.bookProfile("EfficiencyRefPrevious",
62  "Efficiency to previous filter",
63  eventsPerFilter->getNbinsX() - 1,
64  0,
65  eventsPerFilter->getNbinsX() - 1,
66  100,
67  0,
68  1);
69  efficiency->setAxisTitle("Efficiency", 2);
70  const TAxis* xaxis = eventsPerFilter->getTH1F()->GetXaxis();
71  for (int bin = 1; bin < eventsPerFilter->getNbinsX(); ++bin) {
72  efficiency->setBinLabel(bin, xaxis->GetBinLabel(bin + 1));
73  }
74 
75  // Fill efficiency TProfile
76  TProfile* prev = efficiency->getTProfile();
77  for (int i = 2; i <= eventsPerFilter->getNbinsX(); ++i) {
78  if (eventsPerFilter->getBinContent(i - 1) < eventsPerFilter->getBinContent(i)) {
79  LogDebug("HLTTauDQMOffline") << "HLTTauPostProcessor: Encountered denominator < numerator with efficiency plot "
80  "EfficiencyRefPrevious in folder "
81  << folder << ", bin " << i << " numerator " << eventsPerFilter->getBinContent(i)
82  << " denominator " << eventsPerFilter->getBinContent(i - 1);
83  continue;
84  }
85  const std::tuple<float, float> effErr =
86  calcEfficiency(eventsPerFilter->getBinContent(i), eventsPerFilter->getBinContent(i - 1));
87  const float efficiency = std::get<0>(effErr);
88  const float err = std::get<1>(effErr);
89 
90  prev->SetBinContent(i - 1, efficiency);
91  prev->SetBinEntries(i - 1, 1);
92  prev->SetBinError(i - 1, std::sqrt(efficiency * efficiency + err * err));
93  }
94 }
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
makePileupJSON.denom
denom
Definition: makePileupJSON.py:146
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
printsummarytable.folder
folder
Definition: printsummarytable.py:7
pos
Definition: PixelAliasList.h:18
HLTTauPostProcessor::plotFilterEfficiencies
void plotFilterEfficiencies(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const std::string &folder) const
Definition: HLTTauPostProcessor.cc:49
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
HLTTauPostProcessor::HLTTauPostProcessor
HLTTauPostProcessor(const edm::ParameterSet &)
Definition: HLTTauPostProcessor.cc:26
L1TObjectsTimingClient_cff.efficiency
efficiency
Definition: L1TObjectsTimingClient_cff.py:10
HLTTauPostProcessor.h
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:479
HLTTauPostProcessor::dqmEndJob
void dqmEndJob(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
Definition: HLTTauPostProcessor.cc:31
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
HLTTauPostProcessor::~HLTTauPostProcessor
~HLTTauPostProcessor() override
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::implementation::IBooker::bookProfile
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())
Definition: DQMStore.h:322
HLTTauPostProcessor::dqmBaseFolder_
const std::string dqmBaseFolder_
Definition: HLTTauPostProcessor.h:23
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
std
Definition: JetResolutionObject.h:76
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
dqm::implementation::IBooker
Definition: DQMStore.h:43
LaserClient_cfi.xaxis
xaxis
Definition: LaserClient_cfi.py:49
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730