Skip to content

Commit

Permalink
Merge pull request #29739 from cms-tau-pog/CMSSW_10_6_X_tau-pog_deadECAL
Browse files Browse the repository at this point in the history
Restructured code of againstElectronDeadECAL tauID (10_6_X)
  • Loading branch information
cmsbuild authored May 28, 2020
2 parents 59ecfb8 + a1006be commit aa544ff
Show file tree
Hide file tree
Showing 15 changed files with 1,044 additions and 880 deletions.
28 changes: 28 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,34 @@ def miniAOD_customizeCommon(process):
era.toReplaceWith(process.deepTauIDTask,
deepTauIDTaskNew_)

#-- Adding tauID against dead ECal towers to taus
process.hpsPFTauDiscriminationByDeadECALElectronRejectionForMiniAOD = \
process.hpsPFTauDiscriminationByDeadECALElectronRejection.clone(
extrapolateToECalEntrance = True
)
_makePatTausTaskWithDeadECalVeto = process.makePatTausTask.copy()
_makePatTausTaskWithDeadECalVeto.add(
process.hpsPFTauDiscriminationByDeadECALElectronRejectionForMiniAOD
)
run2_miniAOD_devel.toReplaceWith(
process.makePatTausTask, _makePatTausTaskWithDeadECalVeto
)
_withDeadEcalTauIDPs = cms.PSet(
process.patTaus.tauIDSources,
againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejectionForMiniAOD")
)
run2_miniAOD_devel.toModify(process.patTaus,
tauIDSources = _withDeadEcalTauIDPs)
#... and to boosted taus
run2_miniAOD_devel.toModify(process.hpsPFTauDiscriminationByDeadECALElectronRejectionBoosted,
extrapolateToECalEntrance = True)
_withDeadEcalTauIDBoostedPs = cms.PSet(
process.patTausBoosted.tauIDSources,
againstElectronDeadECAL = cms.InputTag("hpsPFTauDiscriminationByDeadECALElectronRejectionBoosted")
)
run2_miniAOD_devel.toModify(process.patTausBoosted,
tauIDSources = _withDeadEcalTauIDBoostedPs)

#-- Adding customization for 80X 2016 legacy reMiniAOD and 2018 heavy ions
from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
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 @@ -175,6 +175,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
5 changes: 3 additions & 2 deletions RecoTauTag/Configuration/python/HPSPFTaus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackFinding_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectron_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronMVA6_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstElectronDeadECAL_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon2_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuonMVA_cfi import *
Expand Down Expand Up @@ -300,7 +300,8 @@
## ByDeadECALElectronRejection
hpsPFTauDiscriminationByDeadECALElectronRejection = pfRecoTauDiscriminationAgainstElectronDeadECAL.clone(
PFTauProducer = cms.InputTag('hpsPFTauProducer'),
Prediscriminants = requireDecayMode.clone()
Prediscriminants = requireDecayMode.clone(),
extrapolateToECalEntrance = cms.bool(False)
)
## ByMVA6rawElectronRejection
hpsPFTauDiscriminationByMVA6rawElectronRejection = pfRecoTauDiscriminationAgainstElectronMVA6.clone(
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

0 comments on commit aa544ff

Please sign in to comment.