CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const TauRef &) const override
 
void endEvent (edm::Event &) override
 
 PATTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationAgainstElectronMVA6 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 
static std::string getTauTypeString ()
 helper method to retrieve tau type name, e.g. to build correct cfi getter More...
 

Private Member Functions

bool isInEcalCrack (double) const
 

Private Attributes

std::unique_ptr< PATTauDiscriminatorcategory_output_
 
edm::Handle< pat::ElectronCollectionElectrons
 
edm::EDGetTokenT< pat::ElectronCollectionelectronToken
 
std::string moduleLabel_
 
std::unique_ptr< AntiElectronIDMVA6mva_
 
edm::InputTag srcElectrons
 
edm::Handle< TauCollectiontaus_
 
int verbosity_
 
bool vetoEcalCracks_
 

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 PATTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

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

Definition at line 30 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

32  mva_(),
34  {
35  mva_ = std::make_unique<AntiElectronIDMVA6>(cfg);
36 
37  srcElectrons = cfg.getParameter<edm::InputTag>("srcElectrons");
38  electronToken = consumes<pat::ElectronCollection>(srcElectrons);
39  vetoEcalCracks_ = cfg.getParameter<bool>("vetoEcalCracks");
40  verbosity_ = cfg.getParameter<int>("verbosity");
41 
42  // add category index
43  produces<PATTauDiscriminator>("category");
44  }
T getParameter(std::string const &) const
TauDiscriminationProducerBase< pat::Tau, pat::PATTauDiscriminator > PATTauDiscriminationProducerBase
edm::EDGetTokenT< pat::ElectronCollection > electronToken
PATTauDiscriminationAgainstElectronMVA6::~PATTauDiscriminationAgainstElectronMVA6 ( )
inlineoverride

Definition at line 52 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References fillDescriptions().

52 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 73 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References JetPlusTrackCorrections_cfi::Electrons, and edm::Event::getByToken().

74 {
75  mva_->beginEvent(evt, es);
76 
79 
81 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< pat::ElectronCollection > electronToken
edm::EDGetTokenT< TauCollection > Tau_token
double PATTauDiscriminationAgainstElectronMVA6::discriminate ( const TauRef theTauRef) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 83 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), taus_updatedMVAIds_cff::category, boostedElectronIsolation_cff::deltaR, JetPlusTrackCorrections_cfi::Electrons, CustomPhysics_cfi::gamma, edm::Ref< C, T, F >::get(), SiStripPI::max, min(), and pat::PackedCandidate::pdgId().

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 191 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

192 {
193  // add all category indices to event
194  evt.put(std::move(category_output_), "category");
195 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
def move(src, dest)
Definition: eostools.py:511
void PATTauDiscriminationAgainstElectronMVA6::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 205 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

205  {
206  // patTauDiscriminationAgainstElectronMVA6
208  desc.add<double>("minMVANoEleMatchWOgWOgsfBL", 0.0);
209  desc.add<double>("minMVANoEleMatchWgWOgsfBL", 0.0);
210  desc.add<bool>("vetoEcalCracks", true);
211  desc.add<bool>("usePhiAtEcalEntranceExtrapolation", false);
212  desc.add<std::string>("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC");
213  desc.add<double>("minMVAWgWgsfBL", 0.0);
214  desc.add<std::string>("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC");
215  desc.add<double>("minMVAWOgWgsfEC", 0.0);
216  desc.add<std::string>("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL");
217  desc.add<std::string>("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL");
218  desc.add<bool>("returnMVA", true);
219  desc.add<bool>("loadMVAfromDB", true);
220  {
222  psd0.add<std::string>("BooleanOperator", "and");
223  {
225  psd1.add<double>("cut");
226  psd1.add<edm::InputTag>("Producer");
227  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
228  }
229  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
230  }
231  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL");
232  desc.add<edm::InputTag>("srcElectrons", edm::InputTag("slimmedElectrons"));
233  desc.add<double>("minMVANoEleMatchWOgWOgsfEC", 0.0);
234  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL");
235  desc.add<edm::InputTag>("PATTauProducer", edm::InputTag("slimmedTaus"));
236  desc.add<double>("minMVAWOgWgsfBL", 0.0);
237  desc.add<double>("minMVAWgWgsfEC", 0.0);
238  desc.add<int>("verbosity", 0);
239  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC");
240  desc.add<std::string>("method", "BDTG");
241  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC");
242  desc.add<double>("minMVANoEleMatchWgWOgsfEC", 0.0);
243  descriptions.add("patTauDiscriminationAgainstElectronMVA6", desc);
244 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 198 of file PATTauDiscriminationAgainstElectronMVA6.cc.

199 {
200  double absEta = fabs(eta);
201  return (absEta > 1.460 && absEta < 1.558);
202 }

Member Data Documentation

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

Definition at line 66 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 63 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 62 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 59 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::InputTag PATTauDiscriminationAgainstElectronMVA6::srcElectrons
private

Definition at line 61 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 64 of file PATTauDiscriminationAgainstElectronMVA6.cc.

int PATTauDiscriminationAgainstElectronMVA6::verbosity_
private

Definition at line 70 of file PATTauDiscriminationAgainstElectronMVA6.cc.

bool PATTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
private

Definition at line 68 of file PATTauDiscriminationAgainstElectronMVA6.cc.