CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const PFTauRef &) const override
 
void endEvent (edm::Event &) override
 
 PFRecoTauDiscriminationAgainstElectronMVA5 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstElectronMVA5 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
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< PFTauDiscriminatorcategory_output_
 
edm::Handle< reco::GsfElectronCollectiongsfElectrons_
 
edm::EDGetTokenT< reco::GsfElectronCollectionGsfElectrons_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< 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 32 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

Constructor & Destructor Documentation

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

Definition at line 35 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

References edm::ParameterSet::getParameter().

37  mva_(nullptr),
39  {
40  mva_ = new AntiElectronIDMVA5(cfg);
41 
42  srcGsfElectrons_ = cfg.getParameter<edm::InputTag>("srcGsfElectrons");
43  GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
44 
45  verbosity_ = cfg.getParameter<int>("verbosity");
46 
47  // add category index
48  produces<PFTauDiscriminator>("category");
49  }
T getParameter(std::string const &) const
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
PFRecoTauDiscriminationAgainstElectronMVA5::~PFRecoTauDiscriminationAgainstElectronMVA5 ( )
inlineoverride

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 81 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

References edm::Event::getByToken().

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

Definition at line 91 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

References Abs(), taus_updatedMVAIds_cff::category, reco::deltaR(), reco::TrackBase::eta(), edm::Ref< C, T, F >::isNonnull(), Min(), reco::TrackBase::pt(), and HiIsolationCommonParameters_cff::track.

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 230 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

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

231 {
232  // add all category indices to event
233  evt.put(std::move(category_output_), "category");
234 }
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 PFRecoTauDiscriminationAgainstElectronMVA5::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 244 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

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

244  {
245  // pfRecoTauDiscriminationAgainstElectronMVA5
247  desc.add<double>("minMVANoEleMatchWOgWOgsfBL", 0.0);
248  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfTauProducer"));
249  desc.add<std::string>("mvaName_woGwoGSF_EC", "gbr_woGwoGSF_EC");
250  desc.add<double>("minMVANoEleMatchWgWOgsfBL", 0.0);
251  desc.add<std::string>("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC");
252  desc.add<std::string>("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC");
253  desc.add<double>("minMVAWgWgsfBL", 0.0);
254  desc.add<double>("minMVAWgWOgsfBL", 0.0);
255  desc.add<double>("minMVANoEleMatchWgWgsfBL", 0.0);
256  desc.add<double>("minMVAWOgWgsfEC", 0.0);
257  desc.add<std::string>("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL");
258  desc.add<std::string>("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL");
259  desc.add<bool>("returnMVA", true);
260  desc.add<double>("minMVANoEleMatchWgWOgsfEC", 0.0);
261  desc.add<bool>("loadMVAfromDB", true);
262  {
264  psd0.add<std::string>("BooleanOperator", "and");
265  {
267  psd1.add<double>("cut");
268  psd1.add<edm::InputTag>("Producer");
269  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
270  }
271  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
272  }
273  desc.add<std::string>("mvaName_wGwoGSF_EC", "gbr_wGwoGSF_EC");
274  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL");
275  desc.add<double>("minMVAWOgWOgsfEC", 0.0);
276  desc.add<std::string>("mvaName_woGwoGSF_BL", "gbr_woGwoGSF_BL");
277  desc.add<std::string>("mvaName_wGwoGSF_BL", "gbr_wGwoGSF_BL");
278  desc.add<double>("minMVANoEleMatchWOgWOgsfEC", 0.0);
279  desc.add<std::string>("mvaName_NoEleMatch_woGwGSF_BL", "gbr_NoEleMatch_woGwGSF_BL");
280  desc.add<double>("minMVANoEleMatchWgWgsfEC", 0.0);
281  desc.add<double>("minMVAWOgWgsfBL", 0.0);
282  desc.add<double>("minMVANoEleMatchWOgWgsfEC", 0.0);
283  desc.add<double>("minMVAWgWOgsfEC", 0.0);
284  desc.add<std::string>("mvaName_NoEleMatch_wGwGSF_EC", "gbr_NoEleMatch_wGwGSF_EC");
285  desc.add<double>("minMVAWgWgsfEC", 0.0);
286  desc.add<int>("verbosity", 0);
287  desc.add<double>("minMVANoEleMatchWOgWgsfBL", 0.0);
288  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC");
289  desc.add<std::string>("method", "BDTG");
290  desc.add<std::string>("mvaName_NoEleMatch_wGwGSF_BL", "gbr_NoEleMatch_wGwGSF_BL");
291  desc.add<std::string>("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL");
292  desc.add<edm::InputTag>("srcGsfElectrons", edm::InputTag("gedGsfElectrons"));
293  desc.add<double>("minMVAWOgWOgsfBL", 0.0);
294  desc.add<std::string>("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC");
295  desc.add<std::string>("mvaName_NoEleMatch_woGwGSF_EC", "gbr_NoEleMatch_woGwGSF_EC");
296  descriptions.add("pfRecoTauDiscriminationAgainstElectronMVA5", desc);
297 }
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 PFRecoTauDiscriminationAgainstElectronMVA5::isInEcalCrack ( double  eta) const
private

Definition at line 237 of file PFRecoTauDiscriminationAgainstElectronMVA5.cc.

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

Member Data Documentation

std::unique_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