test
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
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 &)
 
double discriminate (const PFTauRef &) const
 
void endEvent (edm::Event &)
 
 PFRecoTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA6 ()
 
- 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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_
 
AntiElectronIDMVA6mva_
 
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 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_(0),
34  {
35  mva_ = new AntiElectronIDMVA6(cfg);
36 
37  srcGsfElectrons_ = cfg.getParameter<edm::InputTag>("srcGsfElectrons");
38  GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
39 
40  verbosity_ = ( cfg.exists("verbosity") ) ?
41  cfg.getParameter<int>("verbosity") : 0;
42 
43  // add category index
44  produces<PFTauDiscriminator>("category");
45  }
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 ( )
inline

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 76 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References edm::Event::getByToken().

77 {
78  mva_->beginEvent(evt, es);
79 
82 
84 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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

Definition at line 86 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), python.rootplot.argparse::category, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::TrackBase::eta(), edm::Ref< C, T, F >::isNonnull(), bookConverter::max, min(), boostedElectronIsolation_cff::pfGamma, and reco::TrackBase::pt().

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 231 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

References edm::Event::put().

232 {
233  // add all category indices to event
234  evt.put(category_output_, "category");
235 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
bool PFRecoTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 238 of file PFRecoTauDiscriminationAgainstElectronMVA6.cc.

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

Member Data Documentation

std::auto_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
int PFRecoTauDiscriminationAgainstElectronMVA6::verbosity_
private