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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- 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:508
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:127
def move(src, dest)
Definition: eostools.py:510
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