DAS  3.0
Das Analysis System
TriggerEff

Description

Functor to return the efficiency of a given trigger for a given (leading) jet.

#include <TriggerEff.h>

+ Collaboration diagram for TriggerEff:

Public Member Functions

 TriggerEff (const fs::path &file, const std::map< int, TriggerLumi > &triggers_lumi, int year)
 
double operator() (const DAS::RecJet &j)
 

Public Attributes

TH2 * h
 
std::vector< TH2 * > contribs
 

Constructor & Destructor Documentation

◆ TriggerEff()

TriggerEff ( const fs::path &  file,
const std::map< int, TriggerLumi > &  triggers_lumi,
int  year 
)
inline

Constructor: extracts and normalises the efficiency for each rapidity bin

Bins with content above 99.95% for the last trigger are set to one

Todo:
Exception if the file doesn't exist
Todo:
revisit this threshold for UL samples
37  :
38  h(new TH2D("efficiency", "efficiency", nPtBins, pt_edges.data(), nYbins, y_edges.data()))
39  {
40  using namespace std;
41 
42  assert(fs::exists(file));
43  auto f = make_unique<TFile>(file.c_str(), "READ");
44 
45  int firsttrigger = triggers_lumi.begin()->first; // e.g. typically 40 for HLT_PFJet_* in high pile-up runs
46 
47  for (auto trigger_lumi: triggers_lumi) {
48  int trigger = trigger_lumi.first,
49  turnon = trigger_lumi.second.turnon;
50 
51  const char * method = trigger == firsttrigger ? "TnP" : "emulation";
52  auto hIn = unique_ptr<TH2>(f->Get<TH2>(Form("%s/HLT%d/efficiency", method, trigger)));
53  if (hIn.get() == nullptr) {
54  cerr << red << "No efficiency found for trigger " << trigger << normal << '\n';
55  contribs.push_back(nullptr);
56  continue;
57  }
58  cout << "Getting efficiency for trigger " << trigger << ": " << hIn.get() << endl;
59 
60  assert(hIn->GetNbinsX() == h->GetNbinsX());
61 
62  int I = h->GetXaxis()->FindBin(turnon);
63 
64  for (int iy = 1; iy <= nYbins; ++iy)
65  for (int ipt = I; ipt <= h->GetNbinsX(); ++ipt) {
66  double content = hIn->GetBinContent(ipt, iy),
67  error = hIn->GetBinError (ipt, iy);
68  h->SetBinContent(ipt, iy, content);
69  h->SetBinError (ipt, iy, error );
70  }
71 
72  auto name = Form("HLT%d", trigger);
73  auto hContrib = dynamic_cast<TH2*>(hIn->Clone(name));
74  hContrib->SetDirectory(0);
75  hContrib->Reset();
76  contribs.push_back(hContrib);
77  }
78  f->Close();
79 
80  // regularise at high pt
81  auto lasttrigger = prev(triggers_lumi.end())->first;
82  for (int iy = 1; iy <= nYbins; ++iy) {
83  double turnon = triggers_lumi.at(lasttrigger).turnon;
84  int ipt = h->GetXaxis()->FindBin(turnon);
85 
86  // first, find the first bin of the last trigger reaching 0.9995
87  while (ipt <= h->GetNbinsX()) {
88  double content = h->GetBinContent(ipt, iy);
89  if (content > 0.9995) break;
90  ++ipt;
91  }
92  // then, put all next bins to one
93  while (ipt <= h->GetNbinsX()) {
94  h->SetBinContent(ipt,iy,1);
95  h->SetBinError (ipt,iy,0);
96  ++ipt;
97  }
98  }
99  }

Member Function Documentation

◆ operator()()

double operator() ( const DAS::RecJet j)
inline

Get trigger efficiency as a function of the leading jet.

Todo:
revisit the limit at 905 GeV
104  {
105  using namespace std;
106 
107  auto pt = j.CorrPt();
108  if (pt > 905) return 1.;
109 
110  auto y = j.AbsRap();
111 
112  int ipt = h->GetXaxis()->FindBin(pt),
113  iy = h->GetYaxis()->FindBin(y );
114 
115  auto e = h->GetBinContent(ipt, iy);
116  if (e < 0 || e > 1) {
117  cerr << "\x1B[31m\e[1m" << pt << ' ' << y << '\t' << ipt << ' ' << iy << '\t' << e << '\n';
118  h->Print("all");
119  cerr << "\x1B[30m\e[0m";
120  exit(EXIT_FAILURE);
121  }
122  return e;
123  }

Member Data Documentation

◆ contribs

std::vector<TH2 *> contribs

contributions from each trigger for global overview

◆ h

TH2* h

one single histogram with trigger efficiency


The documentation for this struct was generated from the following file:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
method
method
Definition: Core-gitclone-lastrun.txt:5
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
DAS::y_edges
static const std::vector< double > y_edges
Definition: binnings.h:36
jmarExample.pt
pt
Definition: jmarExample.py:19
DAS::pt_edges
static const std::vector< double > pt_edges
Definition: binnings.h:33
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:256
DAS::PhysicsObject::AbsRap
float AbsRap(const Uncertainties::Variation &=Uncertainties::nominal) const final
absolute rapidity
Definition: PhysicsObject.h:58
Step::red
static const char * red
Definition: Step.h:34
DAS::Normalisation::TriggerEff::h
TH2 * h
one single histogram with trigger efficiency
Definition: TriggerEff.h:29
normal
static const char * normal
Definition: colours.h:8
DAS::PhysicsObject::CorrPt
float CorrPt(size_t i=0) const
corrected transverse momentum
Definition: PhysicsObject.h:55
DAS::nPtBins
static const int nPtBins
Definition: binnings.h:39
DAS::Normalisation::TriggerEff::contribs
std::vector< TH2 * > contribs
contributions from each trigger for global overview
Definition: TriggerEff.h:31
DAS::nYbins
static const int nYbins
Definition: binnings.h:38