Commit b98ec029 authored by Elham E Khoda's avatar Elham E Khoda Committed by Nils Erik Krumnack
Browse files

21.2 modify electron-in-jet subtraction method

parent 6db40e28
......@@ -481,6 +481,10 @@ namespace top {
registerParameter("ApplyElectronInJetSubtraction",
"Subtract electrons close to jets for boosted analysis : True or False(top default)", "False");
registerParameter("ElectronInJetSubtractionCut",
"pT ratio cut used in the ElectronInJetSubtraction method. Default 0.37", "0.37");
registerParameter("ElectronInJetSubtractionBias",
"pT ratio bias used in the ElectronInJetSubtraction method. Default 20.0", "20.0");
registerParameter("TopPartonHistory", "Topology to be assumed when reconstructing parton-level history.", "False",
{"ttbar", "ttbarlight", "tb", "Wtb", "tchannel", "ttz", "ttgamma", "tHq", "tZq", "tttt", "False"});
registerParameter("TopPartonLevel", "Perform parton level analysis (stored in truth tree)? True or False", "True");
......
......@@ -114,6 +114,9 @@ namespace top {
m_applyTightSFsInLooseTree(false),
// For boosted analysis
m_applyElectronInJetSubtraction(false),
// Configure electron in jet subtraction method
m_elInJet_Ptcut(0.37),
m_elInJet_Ptbias(20.),
// Write Truth block info
m_doTruthBlockInfo(false),
// Write Truth PDF info
......@@ -1516,6 +1519,9 @@ namespace top {
// Apply Electron In Jet Subtraction - boosted analysis
if (settings->value("ApplyElectronInJetSubtraction") == "True") this->setApplyElectronInJetSubtraction();
// Configure the cut and bias values of the electron-in-jet subtraction method
this->elInJetPtcut(std::stof(settings->value("ElectronInJetSubtractionCut")));
this->elInJetPtbias(std::stof(settings->value("ElectronInJetSubtractionBias")));
// Set Number of events to run on (for testing)
this->numberOfEventsToRun(std::stoi(settings->value("NEvents")));
......
......@@ -339,6 +339,23 @@ namespace top {
}
}
// electron in jet subtraction configuration:
// detla pT cut and bias values
inline virtual void elInJetPtcut(const float cut) {
if (!m_configFixed) {
m_elInJet_Ptcut = cut;
}
}
inline virtual void elInJetPtbias(const float bias) {
if (!m_configFixed) {
m_elInJet_Ptbias = bias;
}
}
inline virtual float elInJetPtcut() const {return m_elInJet_Ptcut;}
inline virtual float elInJetPtbias() const {return m_elInJet_Ptbias;}
// Dump truth block info
inline bool doTruthBlockInfo() const {return m_doTruthBlockInfo;}
inline void setTruthBlockInfo() {
......@@ -2299,6 +2316,8 @@ namespace top {
// Apply Electron In Jet subtraction
// For boosted analysis
bool m_applyElectronInJetSubtraction;
float m_elInJet_Ptcut;
float m_elInJet_Ptbias;
// Write Truth block info
bool m_doTruthBlockInfo;
......
......@@ -15,6 +15,7 @@ namespace top {
}
void ElectronInJetSubtractionAlgorithm::apply(xAOD::ElectronContainer* electrons, xAOD::JetContainer* jets,
float elinjet_ptcut, float elinjet_ptbias,
const bool useLooseElectrons) {
std::string leptonDef;
if (!useLooseElectrons) {
......@@ -32,7 +33,7 @@ namespace top {
}
m_o.Load(jets, electrons, leptonDef);
m_o.AnalyzeEvent(leptonDef);
m_o.AnalyzeEvent(elinjet_ptcut, elinjet_ptbias, leptonDef);
unsigned int passedElectrons(0);
for (auto e : *electrons) {
......
......@@ -20,7 +20,7 @@ namespace top {
ElectronInJetSubtractionAlgorithm(ElectronInJetSubtractionAlgorithm&& rhs) = delete;
ElectronInJetSubtractionAlgorithm& operator = (const ElectronInJetSubtractionAlgorithm& rhs) = delete;
void apply(xAOD::ElectronContainer* electrons, xAOD::JetContainer* jets, const bool useLooseElectrons = false);
void apply(xAOD::ElectronContainer* electrons, xAOD::JetContainer* jets, float elinjet_ptcut, float elinjet_ptbias, const bool useLooseElectrons = false);
private:
bool m_doLooseCuts;
// Pass selection strings
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef __TTBARELECTRONJETOVERLAP_H__
#define __TTBARELECTRONJETOVERLAP_H__
......@@ -9,63 +9,45 @@
#include <set>
#include <utility>
#include "TLorentzVector.h"
#include "xAODJet/JetContainer.h"
#include "xAODEgamma/ElectronContainer.h"
class TTBarElectronJetOverlap {
private:
std::vector<TLorentzVector> fJetTLVs;
std::vector<float> fJetJVFs;
std::vector<float> fJetD3PDTrkPtPVSums;
std::vector<float> fJetD3PDTrkPtSums;
std::vector<bool> fGoodJets;
std::vector<int> fSubJets;
std::vector<std::set<int> > fJetAssocElCls;
std::vector<TLorentzVector> fElTLVs;
std::vector<TLorentzVector> fOrigJetTLVs;
std::vector<TLorentzVector> fElClTLVs;
std::vector<bool> fElGood; // this registers if the electron passed the object definition
std::vector<bool> fGoodEls;
std::vector<int> fElClAssocJet;
private:
std::vector<TLorentzVector> fJetTLVs; // all jet 4-vectors
std::vector<TLorentzVector> fOrigJetTLVs; // original jet 4-vectors
std::vector<bool> fGoodJets; // flags for jets passing overlap removal
std::vector<int> fSubJets; // flags for jets that undergo subtraction
std::vector<std::set<int> > fJetAssocElCls; // for each jet, filled with associated electron indexes (even more than one, -1 if no associated electron)
bool fDebug;
std::vector<TLorentzVector> fElTLVs; // all electron 4-vectors (track-based direction)
std::vector<TLorentzVector> fElClTLVs; // all electron 4-vectors (calo-based direction)
std::vector<bool> fElGood; // this registers if the electron passed the object definition (before this overlap removal)
std::vector<bool> fGoodEls; // flags for electrons passing overalp removal
std::vector<int> fElClAssocJet; // for each electron, filled with associated jet index (-1 otherwise)
void FindAssocEls();
void SubtractEls();
void FindGoodObjects();
void RecalcJVF();
void FindAssocEls();
void SubtractEls();
void FindGoodObjects(float pt_cut_value, float pt_bias_value);
xAOD::JetContainer *m_jets; //!
xAOD::ElectronContainer *m_electrons; //!
xAOD::JetContainer* m_jets; //!
xAOD::ElectronContainer* m_electrons; //!
public:
TTBarElectronJetOverlap() : fDebug(false), m_jets(nullptr), m_electrons(nullptr) {
}
~TTBarElectronJetOverlap() { }
public:
TTBarElectronJetOverlap() : m_jets(nullptr), m_electrons(nullptr)
{
}
void AnalyzeEvent(const std::string& leptonDef);
~TTBarElectronJetOverlap() {
}
// sets the debug level (info will print if set true).
void SetDebug(bool db) {
fDebug = db;
}
void AnalyzeEvent(float pt_cut_value, float pt_bias_value, const std::string &leptonDef);
bool GetDebug() {
return fDebug;
}
// Load all jets in the event (with variables corresponding to the *corrected* jet quantities)
// Load selected electrons (only *selected* electrons - i.e. pass ID and isolation cuts)
void Load(xAOD::JetContainer *jets, xAOD::ElectronContainer *electrons, const std::string &leptonDef);
// load all anti-kt 0.4 LCTopo jets in the event.
// these variables should correspond to the *corrected* jet
// quantities. Every jet in the D3PD should be passed.
// load selected electrons.
// these variables should only be filled for /selected/
// electrons (i.e. pass ID and isolation cuts).
void Load(xAOD::JetContainer* jets, xAOD::ElectronContainer* electrons, const std::string& leptonDef);
};
#endif
......@@ -472,27 +472,34 @@ namespace top {
for (auto jetPtr : *jets) {
bool decoration = m_jetSelection->passSelection(*jetPtr);
//Forward jets always get JVT=1, Central jets always get fJVT=1
bool passedJVT_and_fJVT = true;
if (jetPtr->isAvailable<char>("passJVT")) {
if (jetPtr->isAvailable<char>("AnalysisTop_fJVTdecision")) {
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("passJVT") && jetPtr->auxdataConst<char>("AnalysisTop_fJVTdecision");
}
else {
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("passJVT");
}
}
else if (jetPtr->isAvailable<char>("AnalysisTop_fJVTdecision")) { //Possibly redundant, fJVT shouldn't really be able to run if passJVT isn't avaliable
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("AnalysisTop_fJVTdecision");
}
//Forward jets always get JVT=1, Central jets always get fJVT=1
bool passedJVT_and_fJVT = true;
if (jetPtr->isAvailable<char>("passJVT")) {
if (jetPtr->isAvailable<char>("AnalysisTop_fJVTdecision")) {
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("passJVT") && jetPtr->auxdataConst<char>("AnalysisTop_fJVTdecision");
}
else {
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("passJVT");
}
}
else if (jetPtr->isAvailable<char>("AnalysisTop_fJVTdecision")) { //Possibly redundant, fJVT shouldn't really be able to run if passJVT isn't avaliable
passedJVT_and_fJVT = jetPtr->auxdataConst<char>("AnalysisTop_fJVTdecision");
}
// set it flase while using ElectronInJetSubtraction method
if (m_doLooseCuts && m_config->applyElectronInJetSubtraction()) {
if (jetPtr->isAvailable<char>("passesFancyOR")) {
if (!jetPtr->auxdecor<char>("passesFancyOR")) decoration = false;
}
}
// if JVT or fJVT cut enabled: jets that pass (f)JVT get passPreORSelection*2, jets which fail get the same as passPreORSelection
// if no JVT cut and central jet, or no fJVT cut and forward jet, jet gets: passPreORSelection * 2
jetPtr->auxdecor<char>(m_passPreORSelection) = decoration;
jetPtr->auxdecor<char>(m_passPreORSelectionLoose) = decoration;
jetPtr->auxdecor<char>(m_ORToolDecoration) = (decoration ? (passedJVT_and_fJVT ? 2 : 1) : 0);
jetPtr->auxdecor<char>(m_ORToolDecorationLoose) = (decoration ? (passedJVT_and_fJVT ? 2 : 1) : 0);;
jetPtr->auxdecor<char>(m_ORToolDecoration) = (decoration ? (passedJVT_and_fJVT ? 2 : 1) : 0);
jetPtr->auxdecor<char>(m_ORToolDecorationLoose) = (decoration ? (passedJVT_and_fJVT ? 2 : 1) : 0);
//decorate with b-tagging flags
std::vector<std::string> availableWPs = m_config->bTagWP_available();
......
......@@ -63,7 +63,10 @@ namespace top {
// Apply the Electron In Jet Subtraction
// The actual calculation is performed in another package
m_subtractionAlgorithm.apply(shallow_electrons.first, shallow_jets.first);
// Retrieve the threshold and offset values from the config file (defauls values are 0.37 and 20 GeV, respectively)
const float elinjet_ptcut_value = m_config->elInJetPtcut();
const float elinjet_ptbias_value = m_config->elInJetPtbias();
m_subtractionAlgorithm.apply(shallow_electrons.first, shallow_jets.first, elinjet_ptcut_value, elinjet_ptbias_value);
// Save the modified electrons to TStore
std::string outputElectronsSGKey = m_config->sgKeyElectrons(currentSystematic);
......@@ -97,7 +100,7 @@ namespace top {
// Apply the Electron In Jet Subtraction
// The actual calculation is performed in another package
m_subtractionAlgorithm.apply(shallow_electrons.first, shallow_jetsLoose.first, m_doLooseCuts);
m_subtractionAlgorithm.apply(shallow_electrons.first, shallow_jetsLoose.first, elinjet_ptcut_value, elinjet_ptbias_value, m_doLooseCuts);
// Save the modified jets to TStore
std::string outputJetsLooseSGKey = m_config->sgKeyJets(currentSystematic, m_doLooseCuts);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment