CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const PFTauRef &) const override
 
void endEvent (edm::Event &) override
 
 PFRecoTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA6 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

bool isInEcalCrack (double) const
 

Private Attributes

std::unique_ptr< PFTauDiscriminatorcategory_output_
 
edm::Handle< reco::GsfElectronCollectiongsfElectrons_
 
edm::EDGetTokenT< reco::GsfElectronCollectionGsfElectrons_token
 
std::string moduleLabel_
 
AntiElectronIDMVA6mva_
 
float * mvaInput_
 
edm::InputTag srcGsfElectrons_
 
edm::Handle< TauCollectiontaus_
 
bool usePhiAtEcalEntranceExtrapolation_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
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 >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 27 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

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

Definition at line 30 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

32  mva_(nullptr),
34  {
35  mva_ = new AntiElectronIDMVA6(cfg);
36 
37  usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter<bool>("usePhiAtEcalEntranceExtrapolation");
38  srcGsfElectrons_ = cfg.getParameter<edm::InputTag>("srcGsfElectrons");
39  GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
40 
41  verbosity_ = ( cfg.exists("verbosity") ) ?
42  cfg.getParameter<int>("verbosity") : 0;
43 
44  // add category index
45  produces<PFTauDiscriminator>("category");
46  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
PFRecoTauDiscriminationAgainstElectronMVA6::~PFRecoTauDiscriminationAgainstElectronMVA6 ( )
inlineoverride

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 78 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References edm::Event::getByToken().

79 {
80  mva_->beginEvent(evt, es);
81 
84 
86 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void beginEvent(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
edm::EDGetTokenT< TauCollection > Tau_token
double PFRecoTauDiscriminationAgainstElectronMVA6::discriminate ( const PFTauRef thePFTauRef) const
override

Definition at line 88 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), taus_updatedMVAIds_cff::category, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::TrackBase::eta(), edm::Ref< C, T, F >::isNonnull(), SiStripPI::max, min(), boostedElectronIsolation_cff::pfGamma, reco::TrackBase::pt(), and HiIsolationCommonParameters_cff::track.

89 {
90  double mvaValue = 1.;
91  double category = -1.;
92  bool isGsfElectronMatched = false;
93 
94  float deltaRDummy = 9.9;
95 
96  const float ECALBarrelEndcapEtaBorder = 1.479;
97  float tauEtaAtEcalEntrance = -99.;
98  float sumEtaTimesEnergy = 0.;
99  float sumEnergy = 0.;
100  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
101  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
102  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
103  sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy());
104  sumEnergy += (*pfCandidate)->energy();
105  }
106  if ( sumEnergy > 0. ) {
107  tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
108  }
109 
110  float leadChargedPFCandEtaAtEcalEntrance = -99.;
111  float leadChargedPFCandPt = -99.;
112  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
113  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
114  const reco::Track* track = nullptr;
115  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
116  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
117  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
118  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
119  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
120  if ( track ) {
121  if ( track->pt() > leadChargedPFCandPt ) {
122  leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
123  leadChargedPFCandPt = track->pt();
124  }
125  }
126  }
127 
128  if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
129 
130  int numSignalPFGammaCandsInSigCone = 0;
131  const std::vector<reco::PFCandidatePtr>& signalPFGammaCands = thePFTauRef->signalPFGammaCands();
132 
133  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfGamma = signalPFGammaCands.begin();
134  pfGamma != signalPFGammaCands.end(); ++pfGamma ) {
135 
136  double dR = deltaR((*pfGamma)->p4(), thePFTauRef->leadPFChargedHadrCand()->p4());
137  double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, thePFTauRef->pt())));
138 
139  // pfGammas inside the tau signal cone
140  if (dR < signalrad) {
141  numSignalPFGammaCandsInSigCone += 1;
142  }
143  }
144 
145  // loop over the electrons
146  for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin();
147  theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
148  if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account...
149  double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4());
150  deltaRDummy = deltaREleTau;
151  if ( deltaREleTau < 0.3 ) {
152  double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron, usePhiAtEcalEntranceExtrapolation_);
153  bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
154  if ( !hasGsfTrack )
155  hasGsfTrack = theGsfElectron->gsfTrack().isNonnull();
156 
158  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
159  // add category index
160  category_output_->setValue(tauIndex_, category);
161  // return MVA output value
162  return -99;
163  }
165 
166  if ( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { // Barrel
167  if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
168  category = 5.;
169  }
170  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
171  category = 7.;
172  }
173  } else { // Endcap
174  if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
175  category = 13.;
176  }
177  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
178  category = 15.;
179  }
180  }
181 
182  mvaValue = std::min(mvaValue, mva_match);
183  isGsfElectronMatched = true;
184  } // deltaR < 0.3
185  } // electron pt > 10
186  } // end of loop over electrons
187 
188  if ( !isGsfElectronMatched ) {
189  mvaValue = mva_->MVAValue(*thePFTauRef, usePhiAtEcalEntranceExtrapolation_);
190  bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
191 
193  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
194  // add category index
195  category_output_->setValue(tauIndex_, category);
196  // return MVA output value
197  return -99;
198  }
200 
201  if ( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) { // Barrel
202  if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
203  category = 0.;
204  }
205  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
206  category = 2.;
207  }
208  } else { // Endcap
209  if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
210  category = 8.;
211  }
212  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
213  category = 10.;
214  }
215  }
216  }
217  }
218 
219  if ( verbosity_ ) {
220  edm::LogPrint("PFTauAgainstEleMVA6") << "<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
221  edm::LogPrint("PFTauAgainstEleMVA6") << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi();
222  edm::LogPrint("PFTauAgainstEleMVA6") << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched;
223  edm::LogPrint("PFTauAgainstEleMVA6") << " #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size();
224  edm::LogPrint("PFTauAgainstEleMVA6") << " MVA = " << mvaValue << ", category = " << category;
225  }
226 
227  // add category index
228  category_output_->setValue(tauIndex_, category);
229  // return MVA output value
230  return mvaValue;
231 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
double pt() const
track transverse momentum
Definition: TrackBase.h:621
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double MVAValue(Float_t TauPt, Float_t TauEtaAtEcalEntrance, Float_t TauPhi, Float_t TauLeadChargedPFCandPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauEmFraction, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMassIn, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauHasGsf, Int_t TauSignalPFGammaCandsIn, Int_t TauSignalPFGammaCandsOut, const std::vector< Float_t > &GammasdEtaInSigCone, const std::vector< Float_t > &GammasdPhiInSigCone, const std::vector< Float_t > &GammasPtInSigCone, const std::vector< Float_t > &GammasdEtaOutSigCone, const std::vector< Float_t > &GammasdPhiOutSigCone, const std::vector< Float_t > &GammasPtOutSigCone, Float_t ElecEta, Float_t ElecPhi, Float_t ElecEtotOverPin, Float_t ElecChi2NormGSF, Float_t ElecChi2NormKF, Float_t ElecGSFNumHits, Float_t ElecKFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecPin, Float_t ElecPout, Float_t ElecEecal, Float_t ElecDeltaEta, Float_t ElecDeltaPhi, Float_t ElecMvaInSigmaEtaEta, Float_t ElecMvaInHadEnergy, Float_t ElecMvaInDeltaEta)
void PFRecoTauDiscriminationAgainstElectronMVA6::endEvent ( edm::Event evt)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 233 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References eostools::move(), and edm::Event::put().

234 {
235  // add all category indices to event
236  evt.put(std::move(category_output_), "category");
237 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
def move(src, dest)
Definition: eostools.py:511
bool PFRecoTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 240 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References DEFINE_FWK_MODULE.

241 {
242  double absEta = fabs(eta);
243  return (absEta > 1.460 && absEta < 1.558);
244 }

Member Data Documentation

std::unique_ptr<PFTauDiscriminator> PFRecoTauDiscriminationAgainstElectronMVA6::category_output_
private
edm::Handle<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA6::gsfElectrons_
private
edm::EDGetTokenT<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA6::GsfElectrons_token
private
std::string PFRecoTauDiscriminationAgainstElectronMVA6::moduleLabel_
private
AntiElectronIDMVA6* PFRecoTauDiscriminationAgainstElectronMVA6::mva_
private
float* PFRecoTauDiscriminationAgainstElectronMVA6::mvaInput_
private
edm::InputTag PFRecoTauDiscriminationAgainstElectronMVA6::srcGsfElectrons_
private
edm::Handle<TauCollection> PFRecoTauDiscriminationAgainstElectronMVA6::taus_
private
bool PFRecoTauDiscriminationAgainstElectronMVA6::usePhiAtEcalEntranceExtrapolation_
private
int PFRecoTauDiscriminationAgainstElectronMVA6::verbosity_
private