Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tauID against electrons in dead ECal regions (102X) #522

Closed
1 change: 1 addition & 0 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@
NoPlot('genPartIdx'),
Plot1D('idAntiEle', 'idAntiEle', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6: bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'),
Plot1D('idAntiEle2018', 'idAntiEle2018', 32, -0.5, 31.5, 'Anti-electron MVA discriminator V6 (2018): bitmask 1 = VLoose, 2 = Loose, 4 = Medium, 8 = Tight, 16 = VTight'),
Plot1D('idAntiEleDeadECal', 'idAntiEleDeadECal', 2, -0.5, 1.5, "tauID('againstElectronDeadECAL')"),
Plot1D('idAntiMu', 'idAntiMu', 4, -0.5, 3.5, 'Anti-muon discriminator V3: : bitmask 1 = Loose, 2 = Tight'),
Plot1D('idDecayMode', 'idDecayMode', 2, -0.5, 1.5, "tauID('decayModeFinding')"),
Plot1D('idDecayModeNewDMs', 'idDecayModeNewDMs', 2, -0.5, 1.5, "tauID('decayModeFindingNewDMs')"),
Expand Down
9 changes: 8 additions & 1 deletion PhysicsTools/NanoAOD/python/taus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _tauId8WPMask(pattern,doc):
variables = cms.PSet() # PSet defined below in era dependent way
)
_tauVarsBase = cms.PSet(P4Vars,
charge = Var("charge", int, doc="electric charge"),
charge = Var("charge", int, doc="electric charge"),
jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
decayMode = Var("decayMode()",int),
idDecayMode = Var("tauID('decayModeFinding')", bool),
Expand All @@ -79,6 +79,7 @@ def _tauId8WPMask(pattern,doc):

idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: "),
idAntiEle = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6"),
idAntiEleDeadECal = Var("tauID('againstElectronDeadECAL')", bool, doc = "Anti-electron dead-ECal discriminator"),

# isoCI3hit = Var( "tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")" doc="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"),
# photonOutsideSigCone = Var( "tauID("photonPtSumOutsideSignalCone")" doc="photonPtSumOutsideSignalCone raw output discriminator"),
Expand Down Expand Up @@ -151,6 +152,12 @@ def _tauId8WPMask(pattern,doc):
variables = _variables80X
)

for era in [eras.run2_miniAOD_80XLegacy, eras.run2_nanoAOD_92X, eras.run2_nanoAOD_94XMiniAODv1, \
eras.run2_nanoAOD_94XMiniAODv2, eras.run2_nanoAOD_94X2016, eras.run2_nanoAOD_102Xv1]:
era.toModify(tauTable.variables,
idAntiEleDeadECal = None
)

tauGenJets.GenParticles = cms.InputTag("prunedGenParticles")
tauGenJets.includeNeutrinos = cms.bool(False)

Expand Down
20 changes: 20 additions & 0 deletions PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,26 @@
)
slimmedTausUpdated.tauIDSources=_tauIDSourcesWithAntiE

### anti-e in dead-ECal regions
from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronDeadECAL_cfi import *
# add to tauID sequence
_patTauMVAIDsSeqWithAntiEdeadECalSeq = cms.Sequence(
patTauMVAIDsSeq.copy() +
patTauDiscriminationAgainstElectronDeadECAL
)
# add to tauIDSources PSet
_tauIDSourcesWithAntiEdeadECal = cms.PSet(
slimmedTausUpdated.tauIDSources.clone(),
againstElectronDeadECAL = cms.InputTag("patTauDiscriminationAgainstElectronDeadECAL")
)
# modify actually used sequence and TauIDSources PSet for any new era
(~eras.run2_miniAOD_80XLegacy & ~eras.run2_nanoAOD_92X & ~eras.run2_nanoAOD_94XMiniAODv1 & \
~eras.run2_nanoAOD_94XMiniAODv2 & ~eras.run2_nanoAOD_94X2016 & ~eras.run2_nanoAOD_102Xv1 \
).toReplaceWith(patTauMVAIDsSeq, _patTauMVAIDsSeqWithAntiEdeadECalSeq)
(~eras.run2_miniAOD_80XLegacy & ~eras.run2_nanoAOD_92X & ~eras.run2_nanoAOD_94XMiniAODv1 & \
~eras.run2_nanoAOD_94XMiniAODv2 & ~eras.run2_nanoAOD_94X2016 & ~eras.run2_nanoAOD_102Xv1 \
).toModify(slimmedTausUpdated,
tauIDSources = _tauIDSourcesWithAntiEdeadECal)


patTauMVAIDsSeq += slimmedTausUpdated
Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/PatAlgos/python/tools/tauTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def _switchToPFTau(process,
("againstElectronMediumMVA6", "DiscriminationByMVA6MediumElectronRejection"),
("againstElectronTightMVA6", "DiscriminationByMVA6TightElectronRejection"),
("againstElectronVTightMVA6", "DiscriminationByMVA6VTightElectronRejection"),
("againstElectronDeadECAL", "DiscriminationByDeadECALElectronRejection"),
]

# switch to PFTau collection produced for fixed dR = 0.07 signal cone size
Expand Down
4 changes: 4 additions & 0 deletions RecoTauTag/RecoTau/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="CondFormats/EgammaObjects"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/EcalObjects"/>
<use name="DataFormats/Math"/>
<use name="DataFormats/TauReco"/>
<use name="DataFormats/VertexReco"/>
<use name="DataFormats/PatCandidates"/>
<use name="DataFormats/ParticleFlowCandidate"/>
<use name="DataFormats/TrackReco"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/EcalDetId"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
Expand Down
74 changes: 74 additions & 0 deletions RecoTauTag/RecoTau/interface/AntiElectronDeadECAL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef RecoTauTag_RecoTau_AntiElectronDeadECAL_h
#define RecoTauTag_RecoTau_AntiElectronDeadECAL_h

/** \class AntiElectronDeadECAL
*
* Flag tau candidates reconstructed near dead ECAL channels,
* in order to reduce e -> tau fakes not rejected by anti-e MVA discriminator
*
* The motivation for this flag is this presentation:
* https://indico.cern.ch/getFile.py/access?contribId=0&resId=0&materialId=slides&confId=177223
*
* Code adapted from:
* RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc
*
* \authors Lauri Andreas Wendland,
* Christian Veelken
*
*
*
*/

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h"

#include <vector>
#include <string>

class EcalChannelStatusRcd;
class CaloGeometryRecord;
class IdealGeometryRecord;

class AntiElectronDeadECAL {
public:
explicit AntiElectronDeadECAL(const edm::ParameterSet&);
~AntiElectronDeadECAL();

void beginEvent(const edm::EventSetup&);

bool operator()(const reco::Candidate* tau) const;

private:
const unsigned minStatus_;
const double dR2_;
const bool extrapolateToECalEntrance_;
const int verbosity_;

PositionAtECalEntranceComputer positionAtECalEntrance_;

void updateBadTowers(const edm::EventSetup&);

struct TowerInfo {
TowerInfo(uint32_t id, unsigned nBad, unsigned maxStatus, double eta, double phi)
: id_(id), nBad_(nBad), maxStatus_(maxStatus), eta_(eta), phi_(phi) {}
uint32_t id_;
unsigned nBad_;
unsigned maxStatus_;
double eta_;
double phi_;
};

std::vector<TowerInfo> badTowers_;
static const uint16_t statusMask_ = 0x1F;

edm::ESWatcher<EcalChannelStatusRcd> channelStatusWatcher_;
edm::ESWatcher<CaloGeometryRecord> caloGeometryWatcher_;
edm::ESWatcher<IdealGeometryRecord> idealGeometryWatcher_;

bool isFirstEvent_;
};

#endif // RecoTauTag_RecoTau_AntiElectronDeadECAL_h
Loading