DAS  3.0
Das Analysis System
DAS::Photon Namespace Reference

Classes

class  ConversionVetoApplier
 
class  IDApplier
 
struct  PerformanceHist
 

Functions

void applyPhotonConversionVeto (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
 
void applyPhotonID (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0})
 
void getPhotonPerformance (const vector< fs::path > &inputs, const fs::path &output, const int steering, const DT::Slice slice={1, 0})
 

Variables

vector< double > pt_edges = MakeBinning<double>({20,500}, 25, BinningOptions::logarithmic)
 
vector< double > eta_edges = MakeBinning<double>({-3, 3}, 0.2, BinningOptions::step)
 
vector< double > phi_edges = MakeBinning<double>({-3.15, 3.15}, 0.15, BinningOptions::step)
 

Function Documentation

◆ applyPhotonConversionVeto()

void DAS::Photon::applyPhotonConversionVeto ( const vector< fs::path > &  inputs,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)

Applies one of the photon conversion veto and (optionally) scale factors.

This function fetches the scale factor for the ID cut previously applied using applyPhotonID (automatically retrieved from the metainfo).

Todo:
ControlPlots
Parameters
inputsinput ROOT files (n-tuples)
outputoutput ROOT file (n-tuple)
configconfig handled with `Darwin::Tools::options`
steeringparameters obtained from explicit options
slicenumber and index of slice
120  {1,0}
121  )
122 {
123  cout << __func__ << ' ' << slice << " start" << endl;
124 
125  DT::Flow flow(steering, inputs);
126  auto tIn = flow.GetInputTree(slice);
127  auto tOut = flow.GetOutputTree(output);
128 
129  DT::MetaInfo metainfo(tOut);
130  metainfo.Check(config);
131 
132  auto recPhotons = flow.GetBranchReadWrite<vector<RecPhoton>>("recPhotons");
133 
134  auto ID = metainfo.Get<string>("corrections", "photons", "ID", "WP");
135  auto table = config.get<fs::path>("corrections.photons.conversion_veto.table");
136  auto type = config.get<string>("corrections.photons.conversion_veto.type");
137  metainfo.Set<string>("corrections", "photons", "conversion_veto", "type", type);
138  metainfo.Set<fs::path>("corrections", "photons", "conversion_veto", "table", table);
139 
140  ConversionVetoApplier applier(table, ID, table != "/dev/null",
141  steering & DT::syst, type);
142  for (const auto& name: applier.weightNames())
143  metainfo.Set<string>("variations", RecPhoton::WeightVar, name);
144 
146 
147  for (DT::Looper looper(tIn); looper(); ++looper) {
148  [[ maybe_unused]]
149  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
150 
151  applier(*recPhotons);
152 
153  if (steering & DT::fill) tOut->Fill();
154  }
155 
156  metainfo.Set<bool>("git", "complete", true);
157 
158  cout << __func__ << ' ' << slice << " stop" << endl;
159 }

◆ applyPhotonID()

void DAS::Photon::applyPhotonID ( const vector< fs::path > &  inputs,
const fs::path &  output,
const pt::ptree &  config,
const int  steering,
const DT::Slice  slice = {1,0} 
)
Todo:
ControlPlots
Parameters
inputsinput ROOT files (n-tuples)
outputoutput ROOT file (n-tuple)
configconfig handled with `Darwin::Tools::options`
steeringparameters obtained from explicit options
slicenumber and index of slice
100  {1,0}
101  )
102 {
103  cout << __func__ << ' ' << slice << " start" << endl;
104 
105  DT::Flow flow(steering, inputs);
106  auto tIn = flow.GetInputTree(slice);
107  auto tOut = flow.GetOutputTree(output);
108 
109  DT::MetaInfo metainfo(tOut);
110  metainfo.Check(config);
111 
112  auto recPhotons = flow.GetBranchReadWrite<vector<RecPhoton>>("recPhotons");
113 
114  auto ID = config.get<string>("corrections.photons.ID.WP");
115  auto path = config.get<fs::path>("corrections.photons.ID.table");
116  metainfo.Set<string>("corrections", "photons", "ID", "WP", ID);
117  metainfo.Set<fs::path>("corrections", "photons", "ID", "table", path);
118  IDApplier applier(path, ID, path != "/dev/null", steering & DT::syst);
119  for (const auto& name: applier.weightNames())
120  metainfo.Set<string>("variations", RecPhoton::WeightVar, name);
121 
123 
124  for (DT::Looper looper(tIn); looper(); ++looper) {
125  [[ maybe_unused]]
126  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
127 
128  applier(*recPhotons);
129 
130  if (steering & DT::fill) tOut->Fill();
131  }
132 
133  metainfo.Set<bool>("git", "complete", true);
134 
135  cout << __func__ << ' ' << slice << " stop" << endl;
136 }

◆ getPhotonPerformance()

void DAS::Photon::getPhotonPerformance ( const vector< fs::path > &  inputs,
const fs::path &  output,
const int  steering,
const DT::Slice  slice = {1, 0} 
)

Obtain photon plots.

Parameters
inputsinput ROOT files (n-tuples)
outputoutput ROOT file (n-tuple)
steeringparameters obtained from explicit options
slicenumber and index of slice
91  {1, 0}
92 ) {
93  cout << __func__ << ' ' << slice << " start" << endl;
94 
95  DT::Flow flow(steering, inputs);
96  auto tIn = flow.GetInputTree(slice);
97  auto [fOut,tOut] = flow.GetOutput(output);
98 
99  DT::MetaInfo metainfo(tOut);
100  auto isMC = metainfo.Get<bool>("flags", "isMC");
101  JMEmatching<vector<RecPhoton>, vector<GenPhoton>>::maxDR = 0.1;
102 
103  auto recEvt = flow.GetBranchReadOnly<RecEvent>("recEvent");
104  auto genEvt = isMC ? flow.GetBranchReadOnly<GenEvent>("genEvent") : nullptr;
105 
106  auto recPhotons = flow.GetBranchReadOnly<vector<RecPhoton>>("recPhotons");
107  auto genPhotons = isMC ? flow.GetBranchReadOnly<vector<GenPhoton>>("genPhotons") : nullptr;
108 
109  map<TString, PerformanceHist> histograms;
110  for (TString name: {"rec", "gen"}) {
111  histograms.insert({name, PerformanceHist(name)});
112  name = "matched_" + name;
113  histograms.insert({name, PerformanceHist(name)});
114  }
115 
116  vector<double> pt_eff_edges {0, 10, 20, 35, 50, 65, 80, 100, 120, 150, 200, 500};
117  TEfficiency h_eff_fake_ph("eff_fake_ph", "", pt_eff_edges.size() - 1, pt_eff_edges.data(),
118  eta_edges.size() - 1, eta_edges.data());
119  TEfficiency h_eff_miss_ph("eff_miss_ph", "", pt_eff_edges.size() - 1, pt_eff_edges.data(),
120  eta_edges.size() - 1, eta_edges.data());
121 
122  for (DT::Looper looper(tIn); looper(); ++looper) {
123  [[maybe_unused]]
124  static auto& cout = steering & DT::verbose ? ::cout : DT::dev_null;
125 
126  double w_rec_ev = recEvt->Weight(),
127  w_ev = w_rec_ev;
128  if (isMC) {
129  double w_gen_ev = genEvt->Weight();
130  w_ev *= w_gen_ev;
131  }
132 
133  const float minPt = 20;
134 
135  for (const auto& recPhoton : *recPhotons) {
136  if (recPhoton.CorrPt() < minPt) continue;
137  double w_rec_ph = recPhoton.Weight();
138  histograms.at("rec").FillUnmatched(recPhoton, w_ev * w_rec_ph);
139  }
140 
141  if (!isMC) continue;
142 
143  for (const auto& genPhoton : *genPhotons) {
144  if (genPhoton.CorrPt() < minPt) continue;
145  double w_gen_ph = genPhoton.Weight();
146  histograms.at("gen").FillUnmatched(genPhoton, w_ev * w_gen_ph);
147  }
148 
149  // Perform gen-reco matching and extract fakes/misses
150  JMEmatching matching(*recPhotons, *genPhotons);
151  auto fake_its = matching.fake_its;
152  auto miss_its = matching.miss_its;
153  bool matched = true;
154 
155  for (const auto& [rec_it, gen_it]: matching.match_its) {
156  if (rec_it->CorrPt() < minPt) continue;
157  if (gen_it->CorrPt() < minPt) continue;
158 
159  // Calculate photon weights
160  double w_rec_ph = rec_it->Weight(),
161  w_gen_ph = gen_it->Weight();
162 
163  for (const auto& rec_it: fake_its) {
164  double w_rec_ph = rec_it->Weight();
165  h_eff_fake_ph.FillWeighted(matched, w_rec_ph, rec_it->CorrPt(), rec_it->CorrP4().Eta());
166  }
167  for (const auto& gen_it: miss_its) {
168  double w_gen_ph = gen_it->Weight();
169  h_eff_miss_ph.FillWeighted(matched, w_gen_ph, gen_it->CorrPt(), gen_it->CorrP4().Eta());
170  }
171 
172  histograms.at("matched_rec").FillMatched(rec_it, w_ev * w_rec_ph);
173  histograms.at("matched_gen").FillMatched(gen_it, w_ev * w_gen_ph);
174  }
175 
176  matched = false;
177  for (const auto& rec_it: fake_its) {
178  double w_rec_ph = rec_it->Weight();
179  h_eff_fake_ph.FillWeighted(matched, w_rec_ph, rec_it->CorrPt(), rec_it->CorrP4().Eta());
180  }
181  for (const auto& gen_it: miss_its) {
182  double w_gen_ph = gen_it->Weight();
183  h_eff_miss_ph.FillWeighted(matched, w_gen_ph, gen_it->CorrPt(), gen_it->CorrP4().Eta());
184  }
185  }
186 
187  for (auto& h: histograms)
188  h.second.Write(fOut);
189  fOut->cd();
190  for (auto eff: {&h_eff_fake_ph, &h_eff_miss_ph}) {
191  eff->SetDirectory(fOut);
192  eff->Write();
193  }
194 
195  metainfo.Set<bool>("git", "complete", true);
196 
197  cout << __func__ << ' ' << slice << " stop" << endl;
198 }

Variable Documentation

◆ eta_edges

vector<double> eta_edges = MakeBinning<double>({-3, 3}, 0.2, BinningOptions::step)

◆ phi_edges

vector<double> phi_edges = MakeBinning<double>({-3.15, 3.15}, 0.15, BinningOptions::step)

◆ pt_edges

vector<double> pt_edges = MakeBinning<double>({20,500}, 25, BinningOptions::logarithmic)
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
Darwin::Tools::fill
@ fill
activate -f to fill the tree
Definition: Options.h:27
Darwin::Tools::Flow
User-friendly handling of input and output n-tuples.
Definition: Flow.h:78
Step::verbose
static bool verbose
Definition: Step.h:40
DAS::Photon::eta_edges
vector< double > eta_edges
Definition: getPhotonPerformance.cc:37
Darwin::Tools::Looper
Facility to loop over a n-tuple, including parallelisation and printing.
Definition: Looper.h:22
Darwin::Tools::syst
@ syst
activate -s to systematic uncertainties
Definition: Options.h:29
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:68
Ntupliser_cfg.config
config
Definition: Ntupliser_cfg.py:330
DAS::Unfolding::DrellYan::minPt
static const double minPt
Definition: ZPtY.h:34
Ntupliser_cfg.isMC
dictionary isMC
Definition: Ntupliser_cfg.py:62
jercExample.inputs
def inputs
Definition: jercExample.py:118
Darwin::Tools::dev_null
static std::ostream dev_null(nullptr)
to redirect output stream to nowhere