CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFRecoTauDiscriminationAgainstElectronMVA5 Class Reference
Inheritance diagram for PFRecoTauDiscriminationAgainstElectronMVA5:
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 &)
 
double discriminate (const PFTauRef &) const
 
void endEvent (edm::Event &)
 
 PFRecoTauDiscriminationAgainstElectronMVA5 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA5 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool isInEcalCrack (double) const
 

Private Attributes

std::auto_ptr< PFTauDiscriminatorcategory_output_
 
edm::Handle
< reco::GsfElectronCollection
gsfElectrons_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
GsfElectrons_token
 
std::string moduleLabel_
 
AntiElectronIDMVA5mva_
 
float * mvaInput_
 
edm::InputTag srcGsfElectrons_
 
edm::Handle< TauCollectiontaus_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd
< TauCollection
TauRefProd
 
- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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 29 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

Constructor & Destructor Documentation

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

Definition at line 32 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

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

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

Member Function Documentation

void PFRecoTauDiscriminationAgainstElectronMVA5::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 78 of file PFRecoTauDiscriminationAgainstElectronMVA5.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:457
void beginEvent(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< TauCollection > Tau_token
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
double PFRecoTauDiscriminationAgainstElectronMVA5::discriminate ( const PFTauRef thePFTauRef) const

Definition at line 88 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

References Abs(), python.rootplot.argparse::category, reco::deltaR(), reco::TrackBase::eta(), edm::Ref< C, T, F >::isNonnull(), Min(), and reco::TrackBase::pt().

89 {
90  double mvaValue = 1.;
91  double category = -1.;
92  bool isGsfElectronMatched = false;
93 
94  float deltaRDummy = 9.9;
95 
96  float tauEtaAtEcalEntrance = -99.;
97  float sumEtaTimesEnergy = 0.;
98  float sumEnergy = 0.;
99  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
100  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
101  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
102  sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy());
103  sumEnergy += (*pfCandidate)->energy();
104  }
105  if ( sumEnergy > 0. ) {
106  tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
107  }
108 
109  float leadChargedPFCandEtaAtEcalEntrance = -99.;
110  float leadChargedPFCandPt = -99.;
111  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
112  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
113  const reco::Track* track = 0;
114  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
115  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
116  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
117  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
118  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
119  if ( track ) {
120  if ( track->pt() > leadChargedPFCandPt ) {
121  leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
122  leadChargedPFCandPt = track->pt();
123  }
124  }
125  }
126 
127  if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
128  for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin();
129  theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
130  if ( theGsfElectron->pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account...
131  double deltaREleTau = deltaR(theGsfElectron->p4(), thePFTauRef->p4());
132  deltaRDummy = deltaREleTau;
133  if ( deltaREleTau < 0.3 ) {
134  double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron);
135  size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
136  bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
137 
139  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
140  // add category index
141  category_output_->setValue(tauIndex_, category);
142  // return MVA output value
143  return -99;
144  }
146 
147  if ( TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) { // Barrel
148  if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
149  category = 4.;
150  } else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
151  category = 5.;
152  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
153  category = 6.;
154  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
155  category = 7.;
156  }
157  } else { // Endcap
158  if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
159  category = 12.;
160  } else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
161  category = 13.;
162  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
163  category = 14.;
164  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
165  category = 15.;
166  }
167  }
168 
169  mvaValue = TMath::Min(mvaValue, mva_match);
170  isGsfElectronMatched = true;
171  } // deltaR < 0.3
172  } // electron pt > 10
173  } // end of loop over electrons
174 
175  if ( !isGsfElectronMatched ) {
176  mvaValue = mva_->MVAValue(*thePFTauRef);
177  size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
178  bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
179 
181  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
182  // add category index
183  category_output_->setValue(tauIndex_, category);
184  // return MVA output value
185  return -99;
186  }
188 
189  if ( TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) { // Barrel
190  if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
191  category = 0.;
192  } else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
193  category = 1.;
194  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
195  category = 2.;
196  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
197  category = 3.;
198  }
199  } else { // Endcap
200  if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
201  category = 8.;
202  } else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
203  category = 9.;
204  } else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
205  category = 10.;
206  } else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
207  category = 11.;
208  }
209  }
210  }
211  }
212 
213  if ( verbosity_ ) {
214  edm::LogPrint("PFTauAgainstEleMVA5") << "<PFRecoTauDiscriminationAgainstElectronMVA5::discriminate>:" ;
215  edm::LogPrint("PFTauAgainstEleMVA5") << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi();
216  edm::LogPrint("PFTauAgainstEleMVA5") << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched;
217  edm::LogPrint("PFTauAgainstEleMVA5") << " #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size();
218  edm::LogPrint("PFTauAgainstEleMVA5") << " MVA = " << mvaValue << ", category = " << category;
219  }
220 
221  // add category index
222  category_output_->setValue(tauIndex_, category);
223  // return MVA output value
224  return mvaValue;
225 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
T Min(T a, T b)
Definition: MathUtil.h:39
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:614
double pt() const
track transverse momentum
Definition: TrackBase.h:584
T Abs(T a)
Definition: MathUtil.h:49
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauLeadChargedPFCandPt, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauEmFraction, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMass, Float_t TauHadrMva, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t TauKFNumHits, Float_t TauGSFNumHits, Float_t TauGSFChi2, Float_t TauGSFTrackResol, Float_t TauGSFTracklnPt, Float_t TauGSFTrackEta, Float_t TauPhi, Float_t TauSignalPFChargedCands, Float_t TauHasGsf, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecFbrem, Float_t ElecChi2GSF, Float_t ElecGSFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)
void PFRecoTauDiscriminationAgainstElectronMVA5::endEvent ( edm::Event evt)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 227 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

References edm::Event::put().

228 {
229  // add all category indices to event
230  evt.put(category_output_, "category");
231 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
bool PFRecoTauDiscriminationAgainstElectronMVA5::isInEcalCrack ( double  eta) const
private

Definition at line 234 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

235 {
236  double absEta = fabs(eta);
237  return (absEta > 1.460 && absEta < 1.558);
238 }

Member Data Documentation

std::auto_ptr<PFTauDiscriminator> PFRecoTauDiscriminationAgainstElectronMVA5::category_output_
private
edm::Handle<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA5::gsfElectrons_
private
edm::EDGetTokenT<reco::GsfElectronCollection> PFRecoTauDiscriminationAgainstElectronMVA5::GsfElectrons_token
private
std::string PFRecoTauDiscriminationAgainstElectronMVA5::moduleLabel_
private
AntiElectronIDMVA5* PFRecoTauDiscriminationAgainstElectronMVA5::mva_
private
float* PFRecoTauDiscriminationAgainstElectronMVA5::mvaInput_
private
edm::InputTag PFRecoTauDiscriminationAgainstElectronMVA5::srcGsfElectrons_
private
edm::Handle<TauCollection> PFRecoTauDiscriminationAgainstElectronMVA5::taus_
private
int PFRecoTauDiscriminationAgainstElectronMVA5::verbosity_
private