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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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)
 

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 29 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

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

Definition at line 48 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References fillDescriptions().

48 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 70 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

70  {
71  mva_->beginEvent(evt, es);
72 
75 
77 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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 79 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), taus_updatedMVAIds_cff::category, watchdog::const, PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, HLTTauDQMOffline_cfi::Electrons, CustomPhysics_cfi::gamma, edm::Ref< C, T, F >::get(), SiStripPI::max, min(), and pat::PackedCandidate::pdgId().

79  {
80  double mvaValue = 1.;
81  double category = -1.;
82  bool isGsfElectronMatched = false;
83  float deltaRDummy = 9.9;
84  const float ECALBarrelEndcapEtaBorder = 1.479;
85  float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
86  float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
87 
88  if ((*theTauRef).leadChargedHadrCand().isNonnull()) {
89  int numSignalPFGammaCandsInSigCone = 0;
90  const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands();
91  for (const auto& gamma : signalGammaCands) {
92  double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
93  double signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTauRef->pt())));
94  // gammas inside the tau signal cone
95  if (dR < signalrad) {
96  numSignalPFGammaCandsInSigCone += 1;
97  }
98  }
99  // loop over the electrons
100  for (const auto& theElectron : *Electrons) {
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 = false;
107  pat::PackedCandidate const* packedLeadTauCand =
108  dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
109  if (abs(packedLeadTauCand->pdgId()) == 11)
110  hasGsfTrack = true;
111  if (!hasGsfTrack)
112  hasGsfTrack = theElectron.gsfTrack().isNonnull();
113 
114  // veto taus that go to Ecal crack
115  if (vetoEcalCracks_ &&
116  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
117  // add category index
118  category_output_->setValue(tauIndex_, category);
119  // return MVA output value
120  return -99;
121  }
122  // Veto taus that go to Ecal crack
123  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
124  if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
125  category = 5.;
126  } else if (numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack) {
127  category = 7.;
128  }
129  } else { // Endcap
130  if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
131  category = 13.;
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 = false;
145  pat::PackedCandidate const* packedLeadTauCand =
146  dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
147  if (abs(packedLeadTauCand->pdgId()) == 11)
148  hasGsfTrack = true;
149 
150  // veto taus that go to Ecal crack
151  if (vetoEcalCracks_ &&
152  (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
153  // add category index
154  category_output_->setValue(tauIndex_, category);
155  // return MVA output value
156  return -99;
157  }
158  // veto taus that go to Ecal crack
159  if (std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) { // Barrel
160  if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
161  category = 0.;
162  } else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
163  category = 2.;
164  }
165  } else { // Endcap
166  if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
167  category = 8.;
168  } else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
169  category = 10.;
170  }
171  }
172  }
173  }
174  if (verbosity_) {
175  edm::LogPrint("PATTauAgainstEleMVA6") << "<PATTauDiscriminationAgainstElectronMVA6::discriminate>:";
176  edm::LogPrint("PATTauAgainstEleMVA6")
177  << " tau: Pt = " << theTauRef->pt() << ", eta = " << theTauRef->eta() << ", phi = " << theTauRef->phi();
178  edm::LogPrint("PATTauAgainstEleMVA6")
179  << " deltaREleTau = " << deltaRDummy << ", isGsfElectronMatched = " << isGsfElectronMatched;
180  edm::LogPrint("PATTauAgainstEleMVA6") << " #Prongs = " << theTauRef->signalChargedHadrCands().size();
181  edm::LogPrint("PATTauAgainstEleMVA6") << " MVA = " << mvaValue << ", category = " << category;
182  }
183  // add category index
184  category_output_->setValue(tauIndex_, category);
185  // return MVA output value
186  return mvaValue;
187 }
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:232
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 189 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

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

Definition at line 199 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

199  {
200  // patTauDiscriminationAgainstElectronMVA6
202  desc.add<double>("minMVANoEleMatchWOgWOgsfBL", 0.0);
203  desc.add<double>("minMVANoEleMatchWgWOgsfBL", 0.0);
204  desc.add<bool>("vetoEcalCracks", true);
205  desc.add<bool>("usePhiAtEcalEntranceExtrapolation", false);
206  desc.add<std::string>("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC");
207  desc.add<double>("minMVAWgWgsfBL", 0.0);
208  desc.add<std::string>("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC");
209  desc.add<double>("minMVAWOgWgsfEC", 0.0);
210  desc.add<std::string>("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL");
211  desc.add<std::string>("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL");
212  desc.add<bool>("returnMVA", true);
213  desc.add<bool>("loadMVAfromDB", true);
214  {
216  psd0.add<std::string>("BooleanOperator", "and");
217  {
219  psd1.add<double>("cut");
220  psd1.add<edm::InputTag>("Producer");
221  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
222  }
223  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
224  }
225  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL");
226  desc.add<edm::InputTag>("srcElectrons", edm::InputTag("slimmedElectrons"));
227  desc.add<double>("minMVANoEleMatchWOgWOgsfEC", 0.0);
228  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL");
229  desc.add<edm::InputTag>("PATTauProducer", edm::InputTag("slimmedTaus"));
230  desc.add<double>("minMVAWOgWgsfBL", 0.0);
231  desc.add<double>("minMVAWgWgsfEC", 0.0);
232  desc.add<int>("verbosity", 0);
233  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC");
234  desc.add<std::string>("method", "BDTG");
235  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC");
236  desc.add<double>("minMVANoEleMatchWgWOgsfEC", 0.0);
237  descriptions.add("patTauDiscriminationAgainstElectronMVA6", desc);
238 }
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 194 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 63 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 60 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 59 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 56 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::InputTag PATTauDiscriminationAgainstElectronMVA6::srcElectrons
private

Definition at line 58 of file PATTauDiscriminationAgainstElectronMVA6.cc.

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

Definition at line 61 of file PATTauDiscriminationAgainstElectronMVA6.cc.

int PATTauDiscriminationAgainstElectronMVA6::verbosity_
private

Definition at line 67 of file PATTauDiscriminationAgainstElectronMVA6.cc.

bool PATTauDiscriminationAgainstElectronMVA6::vetoEcalCracks_
private

Definition at line 65 of file PATTauDiscriminationAgainstElectronMVA6.cc.