 |
DAS
3.0
Das Analysis System
|
#include <helper.h>
◆ Helper()
Constructor
Only giving parameters in reference
◆ BufferWeightGroupXML()
string BufferWeightGroupXML |
( |
const LHERunInfoProduct & |
runInfo | ) |
const |
Extracts the XML fragment starting at <weightgroup> from LHE headers.
- Parameters
-
runInfo | The LHERunInfoProduct containing header lines to scan. |
- Returns
- A string with the buffered XML (empty if no <weightgroup> found).
341 ostringstream buffer;
342 bool startProcessing =
false;
344 for (
auto iter = runInfo.headers_begin(); iter != runInfo.headers_end(); ++iter) {
345 for (
const string& line : iter->lines()) {
346 string current = line;
349 auto cpos = current.find(
'#');
350 if (cpos != string::npos)
354 if (!startProcessing) {
355 auto wpos = current.find(
"<weightgroup");
356 if (wpos != string::npos) {
357 startProcessing =
true;
358 buffer << current.substr(wpos) <<
"\n";
363 buffer << current <<
"\n";
◆ CollectWeightIds()
vector< string > CollectWeightIds |
( |
const tinyxml2::XMLDocument & |
doc, |
|
|
const std::string & |
scaleChoice, |
|
|
const std::string & |
pdfGroupName |
|
) |
| const |
Extracts HT/2 variation and PDF variation IDs from an XML document, skipping any off‐diagonal static scale combinations (FactorisationUpRenormalisationDown and FactorisationDownRenormalisationUp).
- Parameters
-
doc | The XMLDocument containing <weightgroup> elements. |
scaleChoice | The substring to match in the <weight> text, e.g. "HT/2". |
pdfGroupName | The name of the PDF group to match, e.g. "NNPDF31_nlo_hessian_pdfas". |
- Returns
- A vector which contains all matched weight IDs.
273 vector<string> genweight_ids;
275 bool foundScale =
false;
276 bool foundPDF =
false;
278 for (
auto* wg = doc.FirstChildElement(
"weightgroup");
280 wg = wg->NextSiblingElement(
"weightgroup"))
282 const char* nameC = wg->Attribute(
"name");
283 if (!nameC)
continue;
284 const string name{ nameC };
286 if (
name ==
"Central scale variation") {
288 for (
auto* w = wg->FirstChildElement(
"weight");
290 w = w->NextSiblingElement(
"weight"))
292 const char* txt = w->GetText();
293 std::regex pat(
"dyn_scale_choice=" + scaleChoice +
"(\\s|$)");
294 if (!txt || !std::regex_search(txt, pat))
300 double muf = stod(w->Attribute(
"MUF"));
301 double mur = stod(w->Attribute(
"MUR"));
305 (muf < nominal && mur >
nominal))
310 if (
const char*
id = w->Attribute(
"id"))
311 genweight_ids.emplace_back(
id);
314 else if (
name == pdfGroupName) {
317 for (
auto* w = wg->FirstChildElement(
"weight");
319 w = w->NextSiblingElement(
"weight"))
321 if (
const char*
id = w->Attribute(
"id"))
322 genweight_ids.emplace_back(
id);
328 throw cms::Exception(
"Ntupliser") <<
"No weights found for scale choice: " + scaleChoice;
330 throw cms::Exception(
"Ntupliser") <<
"No weights found for PDF group: " + pdfGroupName;
332 return genweight_ids;
◆ CountPDFWeights()
int CountPDFWeights |
( |
const tinyxml2::XMLDocument & |
doc, |
|
|
const std::string & |
pdfGroupName |
|
) |
| const |
Counts the number of weights in the specified PDF group.
- Parameters
-
doc | The XML document containing <weightgroup> elements. |
pdfGroupName | The exact name attribute of the PDF group to count. |
- Returns
- The total count of <weight> tags under that group.
468 int pdfWeightCount = 0;
470 for (
const tinyxml2::XMLElement* group = doc.FirstChildElement(
"weightgroup");
472 group = group->NextSiblingElement(
"weightgroup"))
474 const char*
name = group->Attribute(
"name");
476 throw cms::Exception(
"Ntupliser") <<
"<weightgroup> element is missing required \"name\" attribute";
478 if (pdfGroupName ==
name)
480 for (
const tinyxml2::XMLElement* w = group->FirstChildElement(
"weight");
482 w = w->NextSiblingElement(
"weight"))
489 if (pdfWeightCount == 0)
490 throw cms::Exception(
"Ntupliser") <<
"PDF group \"" << pdfGroupName <<
"\" not found or empty";
492 return pdfWeightCount;
◆ GetGenJet() [1/2]
◆ GetGenJet() [2/2]
DAS::GenJet GetGenJet |
( |
const reco::JetFlavourInfoMatching & |
ijet | ) |
|
Helper to get DAS::GenJet
from MiniAOD with flavour.
32 const reco::Jet& Jet = *(ijet.first.get());
33 const reco::JetFlavourInfo& Info = ijet.second;
41 jjet.
nBHadrons = Info.getbHadrons().size();
42 jjet.
nCHadrons = Info.getcHadrons().size();
◆ GetGenMu()
◆ GetGenPhoton()
DAS::GenPhoton GetGenPhoton |
( |
const reco::GenParticle & |
photon, |
|
|
bool |
zAncestor |
|
) |
| |
◆ GetRecJet()
Helper to get DAS::RecJet
from MiniAOD.
General instructions DeepJet
57 jjet.
p4 = ijet.correctedP4(
"Uncorrected");
60 jjet.
area = ijet.jetArea();
61 jjet.
puID =
p.
PUjetID ? ijet.userFloat(
"pileupJetId:fullDiscriminant") : 1.;
68 jjet.
nBHadrons = ijet.jetFlavourInfo().getbHadrons().size();
69 jjet.
nCHadrons = ijet.jetFlavourInfo().getcHadrons().size();
72 jjet.
DeepJet.
probb = ijet.bDiscriminator(
"pfDeepFlavourJetTags:probb");
73 jjet.
DeepJet.
probbb = ijet.bDiscriminator(
"pfDeepFlavourJetTags:probbb");
74 jjet.
DeepJet.
problepb = ijet.bDiscriminator(
"pfDeepFlavourJetTags:problepb");
75 jjet.
DeepJet.
probc = ijet.bDiscriminator(
"pfDeepFlavourJetTags:probc");
77 jjet.
DeepJet.
probuds = ijet.bDiscriminator(
"pfDeepFlavourJetTags:probuds");
78 jjet.
DeepJet.
probg = ijet.bDiscriminator(
"pfDeepFlavourJetTags:probg");
80 static const auto eps = 10*numeric_limits<float>::epsilon();
85 jjet.
scales.resize(1, 1.0);
◆ GetRecMu()
Helper to get DAS::RecMuon
from MiniAOD.
177 Mu.
Dxy = mu.dB(pat::Muon::PV2D);
178 Mu.
Dz = mu.dB(pat::Muon::PVDZ);
179 if (mu.innerTrack().isNonnull())
180 Mu.
nTkHits = mu.innerTrack()->hitPattern().trackerLayersWithMeasurement();
◆ GetRecPhoton()
Helper to get DAS::RecLep
from MiniAOD.
206 dasPhoton.
p4 = photon.p4();
208 if (photon.hasUserFloat(
"ecalEnergyPostCorr")) {
210 const auto raw_energy = dasPhoton.
p4.E();
212 photon.userFloat(
"ecalEnergyPostCorr") / raw_energy,
213 photon.userFloat(
"energyScaleUp") / raw_energy,
214 photon.userFloat(
"energyScaleDown") / raw_energy,
215 photon.userFloat(
"energySigmaPhiUp") / raw_energy,
216 photon.userFloat(
"energySigmaPhiDown") / raw_energy,
217 photon.userFloat(
"energySigmaRhoUp") / raw_energy,
218 photon.userFloat(
"energySigmaRhoDown") / raw_energy,
224 dasPhoton.
r9 = photon.full5x5_r9();
225 dasPhoton.
scEta = photon.superCluster()->eta();
228 photon.hasUserFloat(
"seedGain") ? photon.userInt(
"seedGain") : -1;
231 dasPhoton.
hOverE = photon.hadronicOverEm();
233 if (photon.photonID(
"cutBasedPhotonID-Fall17-94X-V2-loose"))
235 if (photon.photonID(
"cutBasedPhotonID-Fall17-94X-V2-medium"))
237 if (photon.photonID(
"cutBasedPhotonID-Fall17-94X-V2-tight"))
239 if (photon.photonID(
"mvaPhoID-RunIIFall17-v2-wp80"))
241 if (photon.photonID(
"mvaPhoID-RunIIFall17-v2-wp90"))
243 if (photon.passElectronVeto())
245 if (!photon.hasPixelSeed())
◆ GetScaleVariations()
vector< string > GetScaleVariations |
( |
const tinyxml2::XMLDocument & |
doc, |
|
|
const std::string & |
scaleChoice |
|
) |
| const |
Extracts only the envelope scale variations (skipping nominal, off‐diagonals and placeholder scales) from the "Central scale variation" <weightgroup>, honoring the same dyn_scale_choice filter you use in CollectWeightIds.
- Parameters
-
doc | The XMLDocument containing <weightgroup> elements. |
scaleChoice | The substring to match in the <weight> text, e.g. "HT/2". |
- Returns
- A vector of variation names in the order they appear.
385 vector<string> variations;
388 for (
auto* wg = doc.FirstChildElement(
"weightgroup");
390 wg = wg->NextSiblingElement(
"weightgroup"))
392 const char* nameC = wg->Attribute(
"name");
396 if (
string{nameC} !=
"Central scale variation")
400 for (
auto* w = wg->FirstChildElement(
"weight");
402 w = w->NextSiblingElement(
"weight"))
404 const char* txt = w->GetText();
405 std::regex pat(
"dyn_scale_choice=" + scaleChoice +
"(\\s|$)");
406 if (!txt || !std::regex_search(txt, pat))
410 double muf = stod(w->Attribute(
"MUF"));
411 double mur = stod(w->Attribute(
"MUR"));
415 (muf < nominal && mur >
nominal))
426 variations.emplace_back(
428 ?
"RenormalisationScaleUp"
429 :
"RenormalisationScaleDown"
433 variations.emplace_back(
435 ?
"FactorisationScaleUp"
436 :
"FactorisationScaleDown"
442 variations.emplace_back(
"BothScaleUp");
444 variations.emplace_back(
"BothScaleDown");
453 if (variations.empty()) {
454 throw cms::Exception(
"Ntupliser") <<
"No valid envelope variations found for scale choice: " << scaleChoice;
◆ JetID()
bool JetID |
( |
const pat::Jet & |
jet | ) |
|
Testing tight ID lepton veto definition for jets (official from JetMET)
The values for Run 2 correspond to UL and are not expected to change. Instead, the values for Run 3 are only preliminary and are subject to changes.
- Note
- The formulae in blue from the original TWiki have been copied and their format adapted.
101 const auto eta = jet.eta();
103 auto NHF = jet.neutralHadronEnergyFraction();
104 auto NEMF = jet.photonEnergyFraction();
105 auto MUF = jet.muonEnergyFraction();
106 auto NumConst = jet.neutralMultiplicity() + jet.chargedMultiplicity();
108 auto CHF = jet.chargedHadronEnergyFraction();
109 auto CHM = jet.chargedHadronMultiplicity();
110 auto CEMF = jet.chargedEmEnergyFraction();
112 auto NumNeutralParticle = jet.neutralMultiplicity();
116 return (abs(
eta)<=2.4 && CEMF<0.8 && CHM>0 && CHF>0 && NumConst>1 && NEMF<0.9 && MUF <0.8 && NHF < 0.9)
117 || (
p.
CHS && abs(
eta)>2.4 && abs(
eta)<=2.7 && NEMF<0.99 && NHF < 0.9)
118 || (
p.
CHS && NEMF>0.0 && NEMF<0.99 && NHF<0.9 && NumNeutralParticle>1 && abs(
eta)>2.7 && abs(
eta)<=3.0)
119 || (
p.
CHS && NEMF<0.90 && NHF>0.2 && NumNeutralParticle>10 && abs(
eta)>3.0)
120 || (
p.
PUPPI && abs(
eta)>2.4 && abs(
eta)<=2.7 && NEMF<0.99 && NHF < 0.98)
121 || (
p.
PUPPI && NumNeutralParticle>=1 && abs(
eta)>2.7 && abs(
eta)<=3.0)
122 || (
p.
PUPPI && NEMF<0.90 && NumNeutralParticle>2 && abs(
eta)>3.0);
126 return (abs(
eta)<=2.6 && CEMF<0.8 && CHM>0 && CHF>0 && NumConst>1 && NEMF<0.9 && MUF <0.8 && NHF < 0.9)
127 || (
p.
CHS && abs(
eta)>2.6 && abs(
eta)<=2.7 && CEMF<0.8 && CHM>0 && NEMF<0.99 && MUF <0.8 && NHF < 0.9)
128 || (
p.
CHS && NEMF>0.01 && NEMF<0.99 && NumNeutralParticle>1 && abs(
eta)>2.7 && abs(
eta)<=3.0)
129 || (
p.
CHS && NEMF<0.90 && NHF>0.2 && NumNeutralParticle>10 && abs(
eta)>3.0)
130 || (
p.
PUPPI && abs(
eta)>2.6 && abs(
eta)<=2.7 && CEMF<0.8 && NEMF<0.99 && MUF <0.8 && NHF < 0.9)
131 || (
p.
PUPPI && NHF<0.9999 && abs(
eta)>2.7 && abs(
eta)<=3.0)
132 || (
p.
PUPPI && NEMF<0.90 && NumNeutralParticle>2 && abs(
eta)>3.0);
136 return (abs(
eta)<=2.6 && CEMF<0.8 && CHM>0 && CHF>0.01 && NumConst>1 && NEMF<0.9 && MUF <0.8 && NHF < 0.99)
137 || (
p.
PUPPI && abs(
eta)>2.6 && abs(
eta)<=2.7 && CEMF<0.8 && NEMF<0.99 && MUF <0.8 && NHF < 0.9)
138 || (
p.
PUPPI && NHF<0.99 && abs(
eta)>2.7 && abs(
eta)<=3.0)
139 || (
p.
PUPPI &&NEMF<0.40 && NumNeutralParticle>=2 && abs(
eta)>3.0)
140 || (
p.
CHS && abs(
eta)>2.6 && abs(
eta)<=2.7 && CEMF<0.8 && CHM>0 && NEMF<0.99 && MUF <0.8 && NHF < 0.9)
141 || (
p.
CHS && NEMF<0.99 && NHF<0.99 && NumNeutralParticle>1 && abs(
eta)>2.7 && abs(
eta)<=3.0)
142 || (
p.
CHS && NEMF<0.40 && NumNeutralParticle>10 && abs(
eta)>3.0);
144 auto err_msg =
"\x1B[31m\x1B[1mThe JetID has not yet been imlemented in DAS for "s
145 + to_string(
p.
year) +
"\x1B[0m"s;
146 throw cms::Exception(
"Ntupliser") << err_msg;
The documentation for this struct was generated from the following files:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Ntupliser/plugins/helper.h
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Core/Ntupliser/plugins/helper.cc
int partonFlavour
Parton flavour (PDG ID)
Definition: Jet.h:15
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
cerr
Definition: Ntupliser_cfg.py:105
static const auto eps
Definition: Step.h:38
@ PixelSeedVeto
Pixel seed veto.
Definition: Photon.h:55
DAS::GenJet GetGenJet(const reco::JetFlavourInfoMatching &ijet)
Helper to get DAS::GenJet from MiniAOD with flavour.
Definition: helper.cc:30
@ CutBasedMedium
Medium cut-based ID.
Definition: Photon.h:50
float scEta
Super cluster eta, used to veto the barrel/endcap transition region.
Definition: Photon.h:59
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:50
float Dxy
transverse distance to PV
Definition: Lepton.h:31
float sigmaIEtaIEta
Width of the ECAL deposit along the eta axis.
Definition: Photon.h:60
DAS::Parameters & p
Definition: helper.h:33
int nBHadrons
Number of B hadrons (0, 1 or 2+)
Definition: Jet.h:13
float photonIsolation
Recomputed isolation from other photons.
Definition: Photon.h:64
@ CutBasedLoose
Loose cut-based ID.
Definition: Photon.h:49
float probc
Probability for the jet to contain at least one D hadron.
Definition: Jet.h:49
@ MVAWorkingPoint80
80% efficiency working point of the MVA ID
Definition: Photon.h:52
float probb
Probability for the jet to contain exactly one B hadron decaying hadronically.
Definition: Jet.h:50
int nTkHits
number of hits in tracker
Definition: Lepton.h:34
float Dz
longitudinal distance to PV
Definition: Lepton.h:32
std::vector< float > scales
energy scale corrections and variations
Definition: PhysicsObject.h:51
const int year
20xx
Definition: Parameters.h:57
std::uint32_t selectors
Identification cuts satisfied by the photon.
Definition: Photon.h:74
const bool PUPPI
Definition: Parameters.h:62
class RecMuon
Definition: Lepton.h:25
float probbb
Probability for the jet to contain at least two B hadrons.
Definition: Jet.h:51
class GenPhoton
Definition: Photon.h:13
struct DAS::RecJet::Tagger DeepJet
Reference
float problepb
Probability for the jet to contain exactly one B hadron decaying leptonically.
Definition: Jet.h:52
class GenMuon
Definition: Lepton.h:9
class GenJet
Definition: Jet.h:9
bool prompt
Originates directly from the matrix element.
Definition: Photon.h:18
const bool CHS
Definition: Parameters.h:62
int nCHadrons
Number of D hadrons (0, 1+ in 2017; 0, 1, 2+ in 2016)
Definition: Jet.h:14
float worstChargedIsolation
Recomputed charged isolation with the vertex chosen to maximize this value used for the ID.
Definition: Photon.h:65
const Variation nominal
Definition: Variation.h:55
float hOverE
Ratio of HCAL to ECAL energy.
Definition: Photon.h:61
unsigned int selectors
muon ID & PF isolation
Definition: Lepton.h:29
float area
Jet area (should be peaked at pi*R^2), used for the JES corrections.
Definition: Jet.h:42
float ecalEnergyErrPostCorr
Energy scale and smearing variations, indexed with the EnergyVariation enum.
Definition: Photon.h:72
float probuds
Probability for the jet to be a quark jet with no HF hadron.
Definition: Jet.h:53
@ CutBasedTight
Tight cut-based ID.
Definition: Photon.h:51
const bool flavour
Definition: Parameters.h:72
float r9
R9 of the supercluster, calculated with full 5x5 region.
Definition: Photon.h:58
bool zAncestor
Z boson among the particle mothers.
Definition: Photon.h:17
const bool PUjetID
Definition: Parameters.h:72
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
float neutralHadronIsolation
Recomputed isolation from neutral hadrons.
Definition: Photon.h:63
int Q
+/- 1
Definition: Lepton.h:13
float probg
Probability for the jet to be a gluon jet with no HF hadron.
Definition: Jet.h:54
int seedCrystalGain
Amplifier gain of the ECAL crystal used to seed the supercluster.
Definition: Photon.h:68
@ MVAWorkingPoint90
90% efficiency working point of the MVA ID
Definition: Photon.h:53
float chargedIsolation
Recomputed isolation from charged particles.
Definition: Photon.h:62
eta
DeepAK8/ParticleNet tagging.
Definition: jmarExample.py:19
class RecPhoton
Definition: Photon.h:27
@ ConversionSafeElectronVeto
Electron veto.
Definition: Photon.h:54
float puID
pile-up jet ID
Definition: Jet.h:43