|
DAS
3.0
Das Analysis System
|
|
unordered_map< unsigned long long, float > | GetMaxGenPts (const fs::path &input) |
|
void | applyPUcleaning (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0}) |
|
unordered_map< unsigned long long, float > | GetMaxGenHts (const fs::path &input) |
|
void | applyPUcleaningHT (const vector< fs::path > &inputs, const fs::path &output, const pt::ptree &config, const int steering, const DT::Slice slice={1, 0}) |
|
|
static const std::vector< double > | pthat_edges = {0, 1e-6, 15, 30, 50, 80, 120, 170, 300, 470, 600, 800, 1000, 1400, 1800, 2400, 3200, 6500} |
|
static const int | nPtHatBins = pthat_edges.size()-1 |
|
◆ applyPUcleaning()
void DAS::PUstaub::applyPUcleaning |
( |
const vector< fs::path > & |
inputs, |
|
|
const fs::path & |
output, |
|
|
const pt::ptree & |
config, |
|
|
const int |
steering, |
|
|
const DT::Slice |
slice = {1,0} |
|
) |
| |
Remove PU staub (i.e. high-weight events due to PU sampling)
- Todo:
- Hard-coded cut currently tuned for Pythia UL18
- Parameters
-
inputs | input ROOT files (n-tuple) |
output | output ROOT file (n-tuple) |
config | config handled with `Darwin::Tools::Options` |
steering | parameters obtained from explicit options |
slice | number and index of slice |
75 cout << __func__ <<
' ' << slice <<
" start" << endl;
79 auto tOut = shared_ptr<TTree>(tIn->CloneTree(0));
83 auto isMC = metainfo.Get<
bool>(
"flags",
"isMC");
84 if (!
isMC) BOOST_THROW_EXCEPTION(
DE::BadInput(
"Only MC may be used as input.",
85 make_unique<TFile>(
inputs.front().c_str() )) );
86 auto R = metainfo.Get<
int>(
"flags",
"R");
87 const auto maxDR = R/10.;
89 auto fMBmaxgenpt =
config.get<fs::path>(
"corrections.PUcleaning.MBmaxgenpt");
91 metainfo.Set<fs::path>(
"corrections",
"PUcleaning",
"MBmaxgenpt", fMBmaxgenpt);
94 RecEvent * recEvt =
nullptr;
95 GenEvent * genEvt =
nullptr;
97 PrimaryVertex * pv =
nullptr;
98 tIn->SetBranchAddress(
"recEvent", &recEvt);
99 tIn->SetBranchAddress(
"genEvent", &genEvt);
100 tIn->SetBranchAddress(
"pileup", &
pileup);
101 tIn->SetBranchAddress(
"primaryvertex", &pv);
102 vector<RecJet> *
recjets =
nullptr;
103 vector<GenJet> *
genjets =
nullptr;
104 tIn->SetBranchAddress(
"recJets", &
recjets);
105 tIn->SetBranchAddress(
"genJets", &
genjets);
107 auto pt_logw = make_unique<TH2F>(
"pt_logw",
";Jet p_{T}^{rec} [GeV];log(w);N_{eff}^{j}",
nPtBins,
pt_edges.data(), 400, -30, 20),
108 mjj_logw = make_unique<TH2F>(
"mjj_logw",
";m_{jj}^{rec} [GeV];log(w);N_{eff}^{jj}",
nMjjBins,
Mjj_edges.data(), 400, -30, 20);
111 ControlPlots raw(
"raw"),
113 corrected(
"corrected");
115 Plots PUbefore(
"PUbefore"),
117 PUgenveto(
"PUgenveto");
119 for (
DT::Looper looper(tIn, slice); looper(); ++looper) {
123 raw(*
genjets, genEvt->weights.front());
124 raw(*
recjets, genEvt->weights.front() * recEvt->weights.front());
129 const float maxpthatPU = pthats_it !=
pileup->
pthats.end() ? *pthats_it : 0.;
130 bool bad_rec = (maxpthatPU > genEvt->hard_scale);
137 auto it = maxgenpts.find(evtID);
138 if (it == maxgenpts.end())
continue;
139 bad_rec |= it->second >
genjets->front().p4.Pt();
140 cout << recEvt->evtNo <<
' ' << evtID <<
' ' << it->second << endl;
147 bool matched =
false;
151 : genEvt->hard_scale;
152 static const float m = 156;
153 if (
recjet->
p4.Pt() > max(2*maxgenpt, m))
160 recEvt->weights *= 0;
161 genveto(*
genjets, genEvt->weights.front());
162 genveto(*
recjets, genEvt->weights.front() * recEvt->weights.front());
168 corrected(*
genjets, genEvt->weights.front());
169 corrected(*
recjets, genEvt->weights.front() * recEvt->weights.front());
175 metainfo.Set<
bool>(
"git",
"complete",
true);
178 raw.Write(fOut.get());
179 genveto.Write(fOut.get());
180 corrected.Write(fOut.get());
181 PUbefore.Write(fOut.get());
182 PUgenveto.Write(fOut.get());
183 PUafter.Write(fOut.get());
185 cout << __func__ <<
' ' << slice <<
" stop" << endl;
◆ applyPUcleaningHT()
void DAS::PUstaub::applyPUcleaningHT |
( |
const vector< fs::path > & |
inputs, |
|
|
const fs::path & |
output, |
|
|
const pt::ptree & |
config, |
|
|
const int |
steering, |
|
|
const DT::Slice |
slice = {1,0} |
|
) |
| |
Remove PU staub (i.e. high-weight events due to PU sampling)
- Todo:
- Hard-coded cut currently tuned for Pythia UL18
- Parameters
-
inputs | input ROOT files (n-tuple) |
output | output ROOT file (n-tuple) |
config | config handled with `Darwin::Tools::Options` |
steering | parameters obtained from explicit options |
slice | number and index of slice |
75 cout << __func__ <<
' ' << slice <<
" start" << endl;
79 auto tOut = shared_ptr<TTree>(tIn->CloneTree(0));
83 auto isMC = metainfo.Get<
bool>(
"flags",
"isMC");
84 if (!
isMC) BOOST_THROW_EXCEPTION(
DE::BadInput(
"Only MC may be used as input.",
85 make_unique<TFile>(
inputs.front().c_str() )) );
86 auto R = metainfo.Get<
int>(
"flags",
"R");
87 const auto maxDR = R/10.;
89 auto fMBmaxgenht =
config.get<fs::path>(
"corrections.PUcleaning.MBmaxgenht");
91 metainfo.Set<fs::path>(
"corrections",
"PUcleaning",
"MBmaxgenht", fMBmaxgenht);
94 RecEvent * recEvt =
nullptr;
95 GenEvent * genEvt =
nullptr;
97 PrimaryVertex * pv =
nullptr;
98 tIn->SetBranchAddress(
"recEvent", &recEvt);
99 tIn->SetBranchAddress(
"genEvent", &genEvt);
100 tIn->SetBranchAddress(
"pileup", &
pileup);
101 tIn->SetBranchAddress(
"primaryvertex", &pv);
102 vector<RecJet> *
recjets =
nullptr;
103 vector<GenJet> *
genjets =
nullptr;
104 tIn->SetBranchAddress(
"recJets", &
recjets);
105 tIn->SetBranchAddress(
"genJets", &
genjets);
107 auto pt_logw = make_unique<TH2F>(
"pt_logw",
";Jet p_{T}^{rec} [GeV];log(w);N_{eff}^{j}",
nPtBins,
pt_edges.data(), 400, -30, 20),
108 mjj_logw = make_unique<TH2F>(
"mjj_logw",
";m_{jj}^{rec} [GeV];log(w);N_{eff}^{jj}",
nMjjBins,
Mjj_edges.data(), 400, -30, 20);
111 ControlPlots raw(
"raw"),
113 corrected(
"corrected");
115 Plots PUbefore(
"PUbefore"),
117 PUgenveto(
"PUgenveto");
119 for (
DT::Looper looper(tIn, slice); looper(); ++looper) {
123 raw(*
genjets, genEvt->weights.front());
124 raw(*
recjets, genEvt->weights.front() * recEvt->weights.front());
127 bool bad_rec =
false;
129 for (
const auto& jet : *
genjets) {
136 auto it = maxgenhts.find(evtID);
137 if (it == maxgenhts.end())
continue;
138 bad_rec |= it->second > ht;
139 cout << recEvt->evtNo <<
' ' << evtID <<
' ' << it->second << endl;
146 bool matched =
false;
150 : genEvt->hard_scale;
151 static const float m = 156;
152 if (
recjet->
p4.Pt() > max(2*maxgenpt, m))
153 genEvt->weights.front() = 0;
159 recEvt->weights *= 0;
160 genveto(*
genjets, genEvt->weights.front());
161 genveto(*
recjets, genEvt->weights.front() * recEvt->weights.front());
167 corrected(*
genjets, genEvt->weights.front());
168 corrected(*
recjets, genEvt->weights.front() * recEvt->weights.front());
174 metainfo.Set<
bool>(
"git",
"complete",
true);
177 raw.Write(fOut.get());
178 genveto.Write(fOut.get());
179 corrected.Write(fOut.get());
180 PUbefore.Write(fOut.get());
181 PUgenveto.Write(fOut.get());
182 PUafter.Write(fOut.get());
184 cout << __func__ <<
' ' << slice <<
" stop" << endl;
◆ GetMaxGenHts()
unordered_map<unsigned long long, float> DAS::PUstaub::GetMaxGenHts |
( |
const fs::path & |
input | ) |
|
Build a map from 2-column file with max gen pt and event IDs from MB sample.
42 unordered_map<unsigned long long, float> maxgenhts;
43 if (
input ==
"/dev/null")
46 if (!fs::exists(
input))
47 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Missing 2-column file with max gen ht.",
48 input, make_error_code(errc::no_such_file_or_directory)));
52 read_info(
input.c_str(), prop_tree);
56 for (
const auto& evtID_ht: prop_tree) {
57 auto evtID = stoull(evtID_ht.first);
58 auto ht = evtID_ht.second.get_value<
float>();
59 maxgenhts[evtID] = ht;
◆ GetMaxGenPts()
unordered_map<unsigned long long, float> DAS::PUstaub::GetMaxGenPts |
( |
const fs::path & |
input | ) |
|
Build a map from 2-column file with max gen pt and event IDs from MB sample.
42 unordered_map<unsigned long long, float> maxgenpts;
43 if (
input ==
"/dev/null")
46 if (!fs::exists(
input))
47 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Missing 2-column file with max gen pt.",
48 input, make_error_code(errc::no_such_file_or_directory)));
52 read_info(
input.c_str(), prop_tree);
56 for (
const auto& evtID_pt: prop_tree) {
57 auto evtID = stoull(evtID_pt.first);
58 auto pt = evtID_pt.second.get_value<
float>();
59 maxgenpts[evtID] =
pt;
◆ nPtHatBins
const int nPtHatBins = pthat_edges.size()-1 |
|
static |
◆ pthat_edges
const std::vector<double> pthat_edges = {0, 1e-6, 15, 30, 50, 80, 120, 170, 300, 470, 600, 800, 1000, 1400, 1800, 2400, 3200, 6500} |
|
static |
pt
Definition: jmarExample.py:19
static bool verbose
Definition: Step.h:40
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:47
static const std::vector< double > pt_edges
Definition: binnings.h:33
static const int nMjjBins
Definition: binnings.h:40
genjets
Definition: Ntupliser_cfg.py:271
DAS::RecJet recjet
Definition: classes.h:15
config
Definition: Ntupliser_cfg.py:263
input
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:35
recjets
Definition: Ntupliser_cfg.py:272
static const std::vector< double > Mjj_edges
Definition: binnings.h:34
unordered_map< unsigned long long, float > GetMaxGenPts(const fs::path &input)
Build a map from 2-column file with max gen pt and event IDs from MB sample.
Definition: applyPUcleaning.cc:40
static const int nPtBins
Definition: binnings.h:39
DAS::PileUp pileup
Definition: classes.h:27
string isMC
Definition: Ntupliser_cfg.py:59
DAS::GenJet genjet
Definition: classes.h:14
unordered_map< unsigned long long, float > GetMaxGenHts(const fs::path &input)
Build a map from 2-column file with max gen pt and event IDs from MB sample.
Definition: applyPUcleaningHT.cc:40
std::vector< float > pthats
all hard scales found in PU
Definition: Event.h:106
def inputs
Definition: jercExample.py:118
std::vector< unsigned long long > MBevents
event IDs in MB sample
Definition: Event.h:107
#define DT_GetOutput(output)
Definition: FileUtils.h:96