CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
reco::SingleTauDiscriminatorContainer discriminate (const PFTauRef &) const override
 
 PFRecoTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA6 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
virtual TauDiscriminatorDataType discriminate (const TauRef &tau) const =0
 
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< reco::GsfElectronCollectiongsfElectrons_
 
edm::EDGetTokenT< reco::GsfElectronCollectionGsfElectrons_token
 
std::string moduleLabel_
 
std::unique_ptr< AntiElectronIDMVA6mva_
 
edm::InputTag srcGsfElectrons_
 
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 29 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

◆ PFRecoTauDiscriminationAgainstElectronMVA6()

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

Definition at line 31 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

33  mva_ = std::make_unique<AntiElectronIDMVA6>(cfg);
34 
35  srcGsfElectrons_ = cfg.getParameter<edm::InputTag>("srcGsfElectrons");
36  GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
37  vetoEcalCracks_ = cfg.getParameter<bool>("vetoEcalCracks");
38 
39  verbosity_ = cfg.getParameter<int>("verbosity");
40  }

References looper::cfg.

◆ ~PFRecoTauDiscriminationAgainstElectronMVA6()

PFRecoTauDiscriminationAgainstElectronMVA6::~PFRecoTauDiscriminationAgainstElectronMVA6 ( )
inlineoverride

Definition at line 46 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

46 {}

Member Function Documentation

◆ beginEvent()

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

◆ discriminate()

reco::SingleTauDiscriminatorContainer PFRecoTauDiscriminationAgainstElectronMVA6::discriminate ( const PFTauRef thePFTauRef) const
override

Definition at line 74 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

75  {
77  result.rawValues = {1., -1.};
78  double category = -1.;
79  bool isGsfElectronMatched = false;
80 
81  float deltaRDummy = 9.9;
82 
83  const float ECALBarrelEndcapEtaBorder = 1.479;
84  float tauEtaAtEcalEntrance = -99.;
85  float sumEtaTimesEnergy = 0.;
86  float sumEnergy = 0.;
87  for (const auto& pfCandidate : thePFTauRef->signalPFCands()) {
88  sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta() * pfCandidate->energy());
89  sumEnergy += pfCandidate->energy();
90  }
91  if (sumEnergy > 0.) {
92  tauEtaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
93  }
94 
95  float leadChargedPFCandEtaAtEcalEntrance = -99.;
96  float leadChargedPFCandPt = -99.;
97  for (const auto& pfCandidate : thePFTauRef->signalPFCands()) {
98  const reco::Track* track = nullptr;
99  if (pfCandidate->trackRef().isNonnull())
100  track = pfCandidate->trackRef().get();
101  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
102  track = pfCandidate->muonRef()->innerTrack().get();
103  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
104  track = pfCandidate->muonRef()->globalTrack().get();
105  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
106  track = pfCandidate->muonRef()->outerTrack().get();
107  else if (pfCandidate->gsfTrackRef().isNonnull())
108  track = pfCandidate->gsfTrackRef().get();
109  if (track) {
110  if (track->pt() > leadChargedPFCandPt) {
111  leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta();
112  leadChargedPFCandPt = track->pt();
113  }
114  }
115  }
116 
117  if ((*thePFTauRef).leadChargedHadrCand().isNonnull()) {
118  int numSignalGammaCandsInSigCone = 0;
119  const std::vector<reco::CandidatePtr>& signalGammaCands = thePFTauRef->signalGammaCands();
120 
121  for (const auto& pfGamma : signalGammaCands) {
122  double dR = deltaR(pfGamma->p4(), thePFTauRef->leadChargedHadrCand()->p4());
123  double signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, thePFTauRef->pt())));
124 
125  // pfGammas inside the tau signal cone
126  if (dR < signalrad) {
127  numSignalGammaCandsInSigCone += 1;
128  }
129  }
130 
131  // loop over the electrons
132  for (const auto& theGsfElectron : *gsfElectrons_) {
133  if (theGsfElectron.pt() > 10.) { // CV: only take electrons above some minimal energy/Pt into account...
134  double deltaREleTau = deltaR(theGsfElectron.p4(), thePFTauRef->p4());
135  deltaRDummy = deltaREleTau;
136  if (deltaREleTau < 0.3) {
137  double mva_match = mva_->MVAValue(*thePFTauRef, theGsfElectron);
138  const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand();
139  bool hasGsfTrack = false;
140  if (lpfch.isNonnull()) {
141  hasGsfTrack = lpfch->gsfTrackRef().isNonnull();
142  }
143  if (!hasGsfTrack)
144  hasGsfTrack = theGsfElectron.gsfTrack().isNonnull();
145 
147  if (vetoEcalCracks_ &&
148  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
149  // return MVA output value
150  result.rawValues.at(0) = -99.;
151  return result;
152  }
154 
155  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
156  if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
157  category = 5.;
158  } else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
159  category = 7.;
160  }
161  } else { // Endcap
162  if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
163  category = 13.;
164  } else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
165  category = 15.;
166  }
167  }
168 
169  result.rawValues.at(0) = std::min(result.rawValues.at(0), float(mva_match));
170  isGsfElectronMatched = true;
171  } // deltaR < 0.3
172  } // electron pt > 10
173  } // end of loop over electrons
174 
175  if (!isGsfElectronMatched) {
176  result.rawValues.at(0) = mva_->MVAValue(*thePFTauRef);
177  const reco::PFCandidatePtr& lpfch = thePFTauRef->leadPFChargedHadrCand();
178  bool hasGsfTrack = false;
179  if (lpfch.isNonnull()) {
180  hasGsfTrack = lpfch->gsfTrackRef().isNonnull();
181  }
182 
184  if (vetoEcalCracks_ &&
185  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
186  // add category index
187  result.rawValues.at(1) = category;
188  // return MVA output value
189  result.rawValues.at(0) = -99.;
190  return result;
191  }
193 
194  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
195  if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
196  category = 0.;
197  } else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
198  category = 2.;
199  }
200  } else { // Endcap
201  if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
202  category = 8.;
203  } else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
204  category = 10.;
205  }
206  }
207  }
208  }
209 
210  if (verbosity_) {
211  edm::LogPrint("PFTauAgainstEleMVA6") << "<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:";
212  edm::LogPrint("PFTauAgainstEleMVA6") << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta()
213  << ", phi = " << thePFTauRef->phi();
214  edm::LogPrint("PFTauAgainstEleMVA6") << " deltaREleTau = " << deltaRDummy
215  << ", isGsfElectronMatched = " << isGsfElectronMatched;
216  edm::LogPrint("PFTauAgainstEleMVA6") << " #Prongs = " << thePFTauRef->signalChargedHadrCands().size();
217  edm::LogPrint("PFTauAgainstEleMVA6") << " MVA = " << result.rawValues.at(0) << ", category = " << category;
218  }
219 
220  // add category index
221  result.rawValues.at(1) = category;
222  // return MVA output value
223  return result;
224 }

References funct::abs(), taus_updatedMVAIds_cff::category, reco::deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, dqmMemoryStats::float, reco::PFCandidate::gsfTrackRef(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), SiStripPI::max, min(), boostedElectronIsolation_cff::pfGamma, mps_fire::result, and HLT_2018_cff::track.

◆ fillDescriptions()

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

Definition at line 231 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

231  {
232  // pfRecoTauDiscriminationAgainstElectronMVA6
234  desc.add<double>("minMVANoEleMatchWOgWOgsfBL", 0.0);
235  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfTauProducer"));
236  desc.add<double>("minMVANoEleMatchWgWOgsfBL", 0.0);
237  desc.add<std::string>("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC");
238  desc.add<double>("minMVAWgWgsfBL", 0.0);
239  desc.add<std::string>("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC");
240  desc.add<double>("minMVAWOgWgsfEC", 0.0);
241  desc.add<std::string>("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL");
242  desc.add<std::string>("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL");
243  desc.add<bool>("returnMVA", true);
244  desc.add<bool>("loadMVAfromDB", true);
245  {
246  edm::ParameterSetDescription pset_Prediscriminants;
247  pset_Prediscriminants.add<std::string>("BooleanOperator", "and");
248  {
250  psd1.add<double>("cut");
251  psd1.add<edm::InputTag>("Producer");
252  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
253  }
254  {
255  // encountered this at
256  // RecoTauTag/Configuration/python/HPSPFTaus_cff.py
258  psd1.add<double>("cut");
259  psd1.add<edm::InputTag>("Producer");
260  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("decayMode", psd1);
261  }
262  desc.add<edm::ParameterSetDescription>("Prediscriminants", pset_Prediscriminants);
263  }
264  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL");
265  desc.add<bool>("vetoEcalCracks", true);
266  desc.add<bool>("usePhiAtEcalEntranceExtrapolation", false);
267  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL");
268  desc.add<double>("minMVANoEleMatchWOgWOgsfEC", 0.0);
269  desc.add<double>("minMVAWOgWgsfBL", 0.0);
270  desc.add<double>("minMVAWgWgsfEC", 0.0);
271  desc.add<int>("verbosity", 0);
272  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC");
273  desc.add<std::string>("method", "BDTG");
274  desc.add<edm::InputTag>("srcGsfElectrons", edm::InputTag("gedGsfElectrons"));
275  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC");
276  desc.add<double>("minMVANoEleMatchWgWOgsfEC", 0.0);
277  descriptions.add("pfRecoTauDiscriminationAgainstElectronMVA6", desc);
278 }

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

◆ isInEcalCrack()

bool PFRecoTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 226 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

226  {
227  double absEta = fabs(eta);
228  return (absEta > 1.460 && absEta < 1.558);
229 }

References PVValHelper::eta.

Member Data Documentation

◆ gsfElectrons_

edm::Handle<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA6::gsfElectrons_
private

◆ GsfElectrons_token

edm::EDGetTokenT<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA6::GsfElectrons_token
private

◆ moduleLabel_

std::string PFRecoTauDiscriminationAgainstElectronMVA6::moduleLabel_
private

◆ mva_

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

◆ srcGsfElectrons_

edm::InputTag PFRecoTauDiscriminationAgainstElectronMVA6::srcGsfElectrons_
private

◆ taus_

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

◆ verbosity_

int PFRecoTauDiscriminationAgainstElectronMVA6::verbosity_
private

◆ vetoEcalCracks_

bool PFRecoTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
private
PFRecoTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
bool vetoEcalCracks_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:61
PFTauDiscriminationContainerProducerBase
TauDiscriminationProducerBase< reco::PFTau, reco::TauDiscriminatorContainer, reco::SingleTauDiscriminatorContainer, reco::PFTauDiscriminator > PFTauDiscriminationContainerProducerBase
Definition: TauDiscriminationProducerBase.h:123
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
PFRecoTauDiscriminationAgainstElectronMVA6::isInEcalCrack
bool isInEcalCrack(double) const
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:226
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
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
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PFRecoTauDiscriminationAgainstElectronMVA6::GsfElectrons_token
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:57
reco::Track
Definition: Track.h:27
PFRecoTauDiscriminationAgainstElectronMVA6::srcGsfElectrons_
edm::InputTag srcGsfElectrons_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:56
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
PFRecoTauDiscriminationAgainstElectronMVA6::gsfElectrons_
edm::Handle< reco::GsfElectronCollection > gsfElectrons_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:58
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
reco::PFCandidate::gsfTrackRef
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:440
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
TauDiscriminationProducerBase::Tau_token
edm::EDGetTokenT< TauCollection > Tau_token
Definition: TauDiscriminationProducerBase.h:107
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
edm::LogPrint
Definition: MessageLogger.h:342
edm::Ptr< PFCandidate >
looper.cfg
cfg
Definition: looper.py:297
PFRecoTauDiscriminationAgainstElectronMVA6::mva_
std::unique_ptr< AntiElectronIDMVA6 > mva_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:54
boostedElectronIsolation_cff.pfGamma
pfGamma
Definition: boostedElectronIsolation_cff.py:91
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
PFRecoTauDiscriminationAgainstElectronMVA6::verbosity_
int verbosity_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:63
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
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
PFRecoTauDiscriminationAgainstElectronMVA6::taus_
edm::Handle< TauCollection > taus_
Definition: PFRecoTauDiscriminationAgainstElectronMVA6.cc:59
reco::SingleTauDiscriminatorContainer
Definition: TauDiscriminatorContainer.h:9