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
PATTauDiscriminationAgainstElectronMVA6 Class Reference
Inheritance diagram for PATTauDiscriminationAgainstElectronMVA6:
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 TauRef &) const
 
void endEvent (edm::Event &)
 
 PATTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationAgainstElectronMVA6 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
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)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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 & 
itemsToGetFromEvent () 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
< PATTauDiscriminator
category_output_
 
edm::Handle
< pat::ElectronCollection
Electrons
 
edm::EDGetTokenT
< pat::ElectronCollection
electronToken
 
std::string moduleLabel_
 
std::unique_ptr
< AntiElectronIDMVA6
mva_
 
edm::InputTag srcElectrons
 
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 24 of file PATTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

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

Definition at line 27 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References looper::cfg, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and PATTauDiscriminationAgainstElectronMVA6_cfi::srcElectrons.

29  mva_(),
31  {
32  mva_ = std::make_unique<AntiElectronIDMVA6>(cfg);
33 
34  srcElectrons = cfg.getParameter<edm::InputTag>("srcElectrons");
35  electronToken = consumes<pat::ElectronCollection>(srcElectrons);
36  verbosity_ = ( cfg.exists("verbosity") ) ?
37  cfg.getParameter<int>("verbosity") : 0;
38 
39  // add category index
40  produces<PATTauDiscriminator>("category");
41  }
T getParameter(std::string const &) const
tuple cfg
Definition: looper.py:293
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< pat::Tau, pat::PATTauDiscriminator > PATTauDiscriminationProducerBase
edm::EDGetTokenT< pat::ElectronCollection > electronToken
PATTauDiscriminationAgainstElectronMVA6::~PATTauDiscriminationAgainstElectronMVA6 ( )
inline

Definition at line 49 of file PATTauDiscriminationAgainstElectronMVA6.cc.

49 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 67 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References edm::Event::getByToken().

68 {
69  mva_->beginEvent(evt, es);
70 
73 
75 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< pat::ElectronCollection > electronToken
edm::EDGetTokenT< TauCollection > Tau_token
double PATTauDiscriminationAgainstElectronMVA6::discriminate ( const TauRef theTauRef) const
virtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 77 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), edm::PtrVector< T >::begin(), python.rootplot.argparse::category, compareJSON::const, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, edm::PtrVector< T >::end(), edm::Ref< C, T, F >::get(), pat::Electron::gsfTrack(), edm::Ref< C, T, F >::isNonnull(), bookConverter::max, min(), reco::GsfElectron::p4(), pat::PackedCandidate::pdgId(), and reco::LeafCandidate::pt().

78 {
79  double mvaValue = 1.;
80  double category = -1.;
81  bool isGsfElectronMatched = false;
82  float deltaRDummy = 9.9;
83  const float ECALBarrelEndcapEtaBorder = 1.479;
84  float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
85  float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
86 
87  if( (*theTauRef).leadChargedHadrCand().isNonnull()) {
88  int numSignalPFGammaCandsInSigCone = 0;
89  const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands();
90  for( reco::CandidatePtrVector::const_iterator gamma = signalGammaCands.begin(); gamma != signalGammaCands.end(); ++gamma ){
91  double dR = deltaR((*gamma)->p4(), theTauRef->leadChargedHadrCand()->p4());
92  double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTauRef->pt())));
93  // gammas inside the tau signal cone
94  if (dR < signalrad) {
95  numSignalPFGammaCandsInSigCone += 1;
96  }
97  }
98  // loop over the electrons
99  for( unsigned int ie = 0; ie < Electrons->size(); ++ie ){
100  const pat::Electron& theElectron = Electrons->at(ie);
101  if ( theElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account...
102  double deltaREleTau = deltaR(theElectron.p4(), theTauRef->p4());
103  deltaRDummy = deltaREleTau;
104  if( deltaREleTau < 0.3 ){
105  double mva_match = mva_->MVAValue(*theTauRef, theElectron);
106  bool hasGsfTrack = 0;
107  pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
108  if( abs(packedLeadTauCand->pdgId()) == 11 )
109  hasGsfTrack = 1;
110  if ( !hasGsfTrack )
111  hasGsfTrack = theElectron.gsfTrack().isNonnull();
112 
113  // veto taus that go to Ecal crack
114  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
115  // add category index
116  category_output_->setValue(tauIndex_, category);
117  // return MVA output value
118  return -99;
119  }
120  // Veto taus that go to Ecal crack
121  if( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){ // Barrel
122  if( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ){
123  category = 5.;
124  }
125  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
126  category = 7.;
127  }
128  } else { // Endcap
129  if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
130  category = 13.;
131  }
132  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
133  category = 15.;
134  }
135  }
136  mvaValue = std::min(mvaValue, mva_match);
137  isGsfElectronMatched = true;
138  } // deltaR < 0.3
139  } // electron pt > 10
140  } // end of loop over electrons
141 
142  if ( !isGsfElectronMatched ) {
143  mvaValue = mva_->MVAValue(*theTauRef);
144  bool hasGsfTrack = 0;
145  pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
146  if( abs(packedLeadTauCand->pdgId()) == 11 ) hasGsfTrack = 1;
147 
148  // veto taus that go to Ecal crack
149  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
150  // add category index
151  category_output_->setValue(tauIndex_, category);
152  // return MVA output value
153  return -99;
154  }
155  // veto taus that go to Ecal crack
156  if( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){ // Barrel
157  if( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ){
158  category = 0.;
159  }
160  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
161  category = 2.;
162  }
163  } else { // Endcap
164  if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
165  category = 8.;
166  }
167  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
168  category = 10.;
169  }
170  }
171  }
172  }
173  if ( verbosity_ ) {
174  edm::LogPrint("PATTauAgainstEleMVA6") << "<PATTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
175  edm::LogPrint("PATTauAgainstEleMVA6") << " tau: Pt = " << theTauRef->pt() << ", eta = " << theTauRef->eta() << ", phi = " << theTauRef->phi();
176  edm::LogPrint("PATTauAgainstEleMVA6") << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched;
177  edm::LogPrint("PATTauAgainstEleMVA6") << " #Prongs = " << theTauRef->signalChargedHadrCands().size();
178  edm::LogPrint("PATTauAgainstEleMVA6") << " MVA = " << mvaValue << ", category = " << category;
179  }
180  // add category index
181  category_output_->setValue(tauIndex_, category);
182  // return MVA output value
183  return mvaValue;
184 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:224
const_iterator begin() const
Definition: PtrVector.h:130
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const_iterator end() const
Definition: PtrVector.h:135
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
T min(T a, T b)
Definition: MathUtil.h:58
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Analysis-level electron class.
Definition: Electron.h:52
string const
Definition: compareJSON.py:14
virtual int pdgId() const
PDG identifier.
virtual double pt() const final
transverse momentum
void PATTauDiscriminationAgainstElectronMVA6::endEvent ( edm::Event evt)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 186 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

187 {
188  // add all category indices to event
189  evt.put(std::move(category_output_), "category");
190 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
def move
Definition: eostools.py:510
bool PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 193 of file PATTauDiscriminationAgainstElectronMVA6.cc.

194 {
195  double absEta = fabs(eta);
196  return (absEta > 1.460 && absEta < 1.558);
197 }

Member Data Documentation

std::unique_ptr<PATTauDiscriminator> PATTauDiscriminationAgainstElectronMVA6::category_output_
private

Definition at line 62 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::Handle<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::Electrons
private

Definition at line 59 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::EDGetTokenT<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::electronToken
private

Definition at line 58 of file PATTauDiscriminationAgainstElectronMVA6.cc.

std::string PATTauDiscriminationAgainstElectronMVA6::moduleLabel_
private
std::unique_ptr<AntiElectronIDMVA6> PATTauDiscriminationAgainstElectronMVA6::mva_
private

Definition at line 55 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::InputTag PATTauDiscriminationAgainstElectronMVA6::srcElectrons
private

Definition at line 57 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 60 of file PATTauDiscriminationAgainstElectronMVA6.cc.

int PATTauDiscriminationAgainstElectronMVA6::verbosity_
private

Definition at line 64 of file PATTauDiscriminationAgainstElectronMVA6.cc.