CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PATTauDiscriminationAgainstElectronMVA6 Class Reference
Inheritance diagram for PATTauDiscriminationAgainstElectronMVA6:
TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
reco::SingleTauDiscriminatorContainer discriminate (const TauRef &) const override
 
 PATTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationAgainstElectronMVA6 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
virtual void endEvent (edm::Event &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase ()
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 
static std::string getTauTypeString ()
 helper method to retrieve tau type name, e.g. to build correct cfi getter More...
 

Private Member Functions

bool isInEcalCrack (double) const
 

Private Attributes

edm::Handle< pat::ElectronCollectionElectrons
 
edm::EDGetTokenT< pat::ElectronCollectionelectronToken
 
std::string moduleLabel_
 
std::unique_ptr< AntiElectronIDMVA6mva_
 
edm::InputTag srcElectrons
 
edm::Handle< TauCollectiontaus_
 
int verbosity_
 
bool vetoEcalCracks_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 27 of file PATTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

◆ PATTauDiscriminationAgainstElectronMVA6()

PATTauDiscriminationAgainstElectronMVA6::PATTauDiscriminationAgainstElectronMVA6 ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 29 of file PATTauDiscriminationAgainstElectronMVA6.cc.

31  mva_ = std::make_unique<AntiElectronIDMVA6>(cfg);
32 
33  srcElectrons = cfg.getParameter<edm::InputTag>("srcElectrons");
34  electronToken = consumes<pat::ElectronCollection>(srcElectrons);
35  vetoEcalCracks_ = cfg.getParameter<bool>("vetoEcalCracks");
36  verbosity_ = cfg.getParameter<int>("verbosity");
37  }

References looper::cfg, and PATTauDiscriminationAgainstElectronMVA6_cfi::srcElectrons.

◆ ~PATTauDiscriminationAgainstElectronMVA6()

PATTauDiscriminationAgainstElectronMVA6::~PATTauDiscriminationAgainstElectronMVA6 ( )
inlineoverride

Definition at line 43 of file PATTauDiscriminationAgainstElectronMVA6.cc.

43 {}

Member Function Documentation

◆ beginEvent()

void PATTauDiscriminationAgainstElectronMVA6::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

◆ discriminate()

reco::SingleTauDiscriminatorContainer PATTauDiscriminationAgainstElectronMVA6::discriminate ( const TauRef theTauRef) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >.

Definition at line 71 of file PATTauDiscriminationAgainstElectronMVA6.cc.

72  {
74  result.rawValues = {1., -1.};
75  double category = -1.;
76  bool isGsfElectronMatched = false;
77  float deltaRDummy = 9.9;
78  const float ECALBarrelEndcapEtaBorder = 1.479;
79  float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
80  float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
81 
82  if ((*theTauRef).leadChargedHadrCand().isNonnull()) {
83  int numSignalPFGammaCandsInSigCone = 0;
84  const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands();
85  for (const auto& gamma : signalGammaCands) {
86  double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
87  double signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTauRef->pt())));
88  // gammas inside the tau signal cone
89  if (dR < signalrad) {
90  numSignalPFGammaCandsInSigCone += 1;
91  }
92  }
93  // loop over the electrons
94  for (const auto& theElectron : *Electrons) {
95  if (theElectron.pt() > 10.) { // CV: only take electrons above some minimal energy/Pt into account...
96  double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4());
97  deltaRDummy = deltaREleTau;
98  if (deltaREleTau < 0.3) {
99  double mva_match = mva_->MVAValue(*theTauRef, theElectron);
100  bool hasGsfTrack = false;
101  pat::PackedCandidate const* packedLeadTauCand =
102  dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
103  if (abs(packedLeadTauCand->pdgId()) == 11)
104  hasGsfTrack = true;
105  if (!hasGsfTrack)
106  hasGsfTrack = theElectron.gsfTrack().isNonnull();
107 
108  // veto taus that go to Ecal crack
109  if (vetoEcalCracks_ &&
110  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
111  // return MVA output value
112  result.rawValues.at(0) = -99;
113  return result;
114  }
115  // Veto taus that go to Ecal crack
116  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
117  if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
118  category = 5.;
119  } else if (numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack) {
120  category = 7.;
121  }
122  } else { // Endcap
123  if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
124  category = 13.;
125  } else if (numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack) {
126  category = 15.;
127  }
128  }
129  result.rawValues.at(0) = std::min(result.rawValues.at(0), float(mva_match));
130  isGsfElectronMatched = true;
131  } // deltaR < 0.3
132  } // electron pt > 10
133  } // end of loop over electrons
134 
135  if (!isGsfElectronMatched) {
136  result.rawValues.at(0) = mva_->MVAValue(*theTauRef);
137  bool hasGsfTrack = false;
138  pat::PackedCandidate const* packedLeadTauCand =
139  dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
140  if (abs(packedLeadTauCand->pdgId()) == 11)
141  hasGsfTrack = true;
142 
143  // veto taus that go to Ecal crack
144  if (vetoEcalCracks_ &&
145  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
146  // add category index
147  result.rawValues.at(1) = category;
148  // return MVA output value
149  result.rawValues.at(0) = -99;
150  return result;
151  }
152  // veto taus that go to Ecal crack
153  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
154  if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
155  category = 0.;
156  } else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
157  category = 2.;
158  }
159  } else { // Endcap
160  if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
161  category = 8.;
162  } else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
163  category = 10.;
164  }
165  }
166  }
167  }
168  if (verbosity_) {
169  edm::LogPrint("PATTauAgainstEleMVA6") << "<PATTauDiscriminationAgainstElectronMVA6::discriminate>:";
170  edm::LogPrint("PATTauAgainstEleMVA6")
171  << " tau: Pt = " << theTauRef->pt() << ", eta = " << theTauRef->eta() << ", phi = " << theTauRef->phi();
172  edm::LogPrint("PATTauAgainstEleMVA6")
173  << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched;
174  edm::LogPrint("PATTauAgainstEleMVA6") << " #Prongs = " << theTauRef->signalChargedHadrCands().size();
175  edm::LogPrint("PATTauAgainstEleMVA6") << " MVA = " << result.rawValues.at(0) << ", category = " << category;
176  }
177  // add category index
178  result.rawValues.at(1) = category;
179  // return MVA output value
180  return result;
181 }

References funct::abs(), taus_updatedMVAIds_cff::category, PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, HLTTauDQMOffline_cfi::Electrons, dqmMemoryStats::float, CustomPhysics_cfi::gamma, edm::Ref< C, T, F >::get(), SiStripPI::max, min(), pat::PackedCandidate::pdgId(), and mps_fire::result.

◆ fillDescriptions()

void PATTauDiscriminationAgainstElectronMVA6::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 188 of file PATTauDiscriminationAgainstElectronMVA6.cc.

188  {
189  // patTauDiscriminationAgainstElectronMVA6
191  desc.add<double>("minMVANoEleMatchWOgWOgsfBL", 0.0);
192  desc.add<double>("minMVANoEleMatchWgWOgsfBL", 0.0);
193  desc.add<bool>("vetoEcalCracks", true);
194  desc.add<bool>("usePhiAtEcalEntranceExtrapolation", false);
195  desc.add<std::string>("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC");
196  desc.add<double>("minMVAWgWgsfBL", 0.0);
197  desc.add<std::string>("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC");
198  desc.add<double>("minMVAWOgWgsfEC", 0.0);
199  desc.add<std::string>("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL");
200  desc.add<std::string>("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL");
201  desc.add<bool>("returnMVA", true);
202  desc.add<bool>("loadMVAfromDB", true);
203  {
205  psd0.add<std::string>("BooleanOperator", "and");
206  {
208  psd1.add<double>("cut");
209  psd1.add<edm::InputTag>("Producer");
210  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
211  }
212  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
213  }
214  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL");
215  desc.add<edm::InputTag>("srcElectrons", edm::InputTag("slimmedElectrons"));
216  desc.add<double>("minMVANoEleMatchWOgWOgsfEC", 0.0);
217  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL");
218  desc.add<edm::InputTag>("PATTauProducer", edm::InputTag("slimmedTaus"));
219  desc.add<double>("minMVAWOgWgsfBL", 0.0);
220  desc.add<double>("minMVAWgWgsfEC", 0.0);
221  desc.add<int>("verbosity", 0);
222  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC");
223  desc.add<std::string>("method", "BDTG");
224  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC");
225  desc.add<double>("minMVANoEleMatchWgWOgsfEC", 0.0);
226  descriptions.add("patTauDiscriminationAgainstElectronMVA6", desc);
227 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ isInEcalCrack()

bool PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 183 of file PATTauDiscriminationAgainstElectronMVA6.cc.

183  {
184  double absEta = fabs(eta);
185  return (absEta > 1.460 && absEta < 1.558);
186 }

References PVValHelper::eta.

Member Data Documentation

◆ Electrons

edm::Handle<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::Electrons
private

Definition at line 55 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ electronToken

edm::EDGetTokenT<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::electronToken
private

Definition at line 54 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ moduleLabel_

std::string PATTauDiscriminationAgainstElectronMVA6::moduleLabel_
private

◆ mva_

std::unique_ptr<AntiElectronIDMVA6> PATTauDiscriminationAgainstElectronMVA6::mva_
private

Definition at line 51 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ srcElectrons

edm::InputTag PATTauDiscriminationAgainstElectronMVA6::srcElectrons
private

Definition at line 53 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ taus_

edm::Handle<TauCollection> PATTauDiscriminationAgainstElectronMVA6::taus_
private

Definition at line 56 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ verbosity_

int PATTauDiscriminationAgainstElectronMVA6::verbosity_
private

Definition at line 60 of file PATTauDiscriminationAgainstElectronMVA6.cc.

◆ vetoEcalCracks_

bool PATTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
private

Definition at line 58 of file PATTauDiscriminationAgainstElectronMVA6.cc.

taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PATTauDiscriminationAgainstElectronMVA6::electronToken
edm::EDGetTokenT< pat::ElectronCollection > electronToken
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:54
pat::PackedCandidate::pdgId
int pdgId() const override
PDG identifier.
Definition: PackedCandidate.h:832
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::PtrVector< Candidate >
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PATTauDiscriminationAgainstElectronMVA6::taus_
edm::Handle< TauCollection > taus_
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:56
PATTauDiscriminationAgainstElectronMVA6::srcElectrons
edm::InputTag srcElectrons
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:53
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PATTauDiscriminationAgainstElectronMVA6::verbosity_
int verbosity_
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:60
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
PATTauDiscriminationAgainstElectronMVA6::Electrons
edm::Handle< pat::ElectronCollection > Electrons
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:55
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
pat::PackedCandidate
Definition: PackedCandidate.h:22
TauDiscriminationProducerBase::Tau_token
edm::EDGetTokenT< TauCollection > Tau_token
Definition: TauDiscriminationProducerBase.h:107
edm::LogPrint
Definition: MessageLogger.h:342
looper.cfg
cfg
Definition: looper.py:297
PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack
bool isInEcalCrack(double) const
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:183
PATTauDiscriminationAgainstElectronMVA6::mva_
std::unique_ptr< AntiElectronIDMVA6 > mva_
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:51
mps_fire.result
result
Definition: mps_fire.py:303
PATTauDiscriminationContainerProducerBase
TauDiscriminationProducerBase< pat::Tau, reco::TauDiscriminatorContainer, reco::SingleTauDiscriminatorContainer, pat::PATTauDiscriminator > PATTauDiscriminationContainerProducerBase
Definition: TauDiscriminationProducerBase.h:129
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
edm::InputTag
Definition: InputTag.h:15
PATTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
bool vetoEcalCracks_
Definition: PATTauDiscriminationAgainstElectronMVA6.cc:58
reco::SingleTauDiscriminatorContainer
Definition: TauDiscriminatorContainer.h:9