CMS 3D CMS Logo

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

Classes

struct  DecayModeCuts
 

Public Member Functions

double discriminate (const reco::PFTauRef &) const override
 
 PFRecoTauDiscriminationByHPSSelection (const edm::ParameterSet &)
 
 ~PFRecoTauDiscriminationByHPSSelection () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual void beginEvent (const edm::Event &, const edm::EventSetup &)
 
virtual double discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &)
 
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
 

Private Types

typedef std::map< IntPair, DecayModeCutsDecayModeCutMap
 
typedef std::pair< double, double > DoublePair
 
typedef std::pair< unsigned int, unsigned int > IntPair
 
typedef StringObjectFunction< reco::PFTauTauFunc
 

Private Attributes

DecayModeCutMap decayModeCuts_
 
double matchingCone_
 
int minPixelHits_
 
double minPt_
 
bool requireTauChargedHadronsToBeChargedPFCands_
 
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 19 of file PFRecoTauDiscriminationByHPSSelection.cc.

Member Typedef Documentation

Definition at line 49 of file PFRecoTauDiscriminationByHPSSelection.cc.

typedef std::pair<double, double> PFRecoTauDiscriminationByHPSSelection::DoublePair
private

Definition at line 48 of file PFRecoTauDiscriminationByHPSSelection.cc.

typedef std::pair<unsigned int, unsigned int> PFRecoTauDiscriminationByHPSSelection::IntPair
private

Definition at line 47 of file PFRecoTauDiscriminationByHPSSelection.cc.

Definition at line 27 of file PFRecoTauDiscriminationByHPSSelection.cc.

Constructor & Destructor Documentation

PFRecoTauDiscriminationByHPSSelection::PFRecoTauDiscriminationByHPSSelection ( const edm::ParameterSet pset)
explicit

Definition at line 62 of file PFRecoTauDiscriminationByHPSSelection.cc.

References PFRecoTauDiscriminationByHPSSelection_cfi::applyBendCorrection, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_eta_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_phi_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::assumeStripMass_, egammaForCoreTracking_cff::cuts, taus_cff::decayMode, decayModeCuts_, tauJetCorrFactors_cfi::decayModes, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), matchingCone_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxPi0Mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minPi0Mass_, minPixelHits_, minPt_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nChargedPFCandsMin_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nTracksMin_, requireTauChargedHadronsToBeChargedPFCands_, AlCaHLTBitMon_QueryRunRegistry::string, verbosity_, and HistogramManager_cfi::VPSet().

64 {
65  // Get the matchign cut
66  matchingCone_ = pset.getParameter<double>("matchingCone");
67  minPt_ = pset.getParameter<double>("minTauPt");
68  // Get the mass cuts for each decay mode
69  typedef std::vector<edm::ParameterSet> VPSet;
70  const VPSet& decayModes = pset.getParameter<VPSet>("decayModes");
71  for(auto const& decayMode : decayModes ) {
72  // The mass window(s)
73  DecayModeCuts cuts;
74  if ( decayMode.exists("nTracksMin") ) {
75  cuts.nTracksMin_ = decayMode.getParameter<unsigned>("nTracksMin");
76  } else {
77  cuts.nTracksMin_ = 0;
78  }
79  if ( decayMode.exists("nChargedPFCandsMin") ) {
80  cuts.nChargedPFCandsMin_ = decayMode.getParameter<unsigned>("nChargedPFCandsMin");
81  } else {
82  cuts.nChargedPFCandsMin_ = 0;
83  }
84  cuts.minMass_ = decayMode.getParameter<double>("minMass");
85  cuts.maxMass_ = new TauFunc(decayMode.getParameter<std::string>("maxMass"));
86  edm::ParameterSet applyBendCorrection = decayMode.getParameter<edm::ParameterSet>("applyBendCorrection");
87  cuts.applyBendCorrection_eta_ = applyBendCorrection.getParameter<bool>("eta");
88  cuts.applyBendCorrection_phi_ = applyBendCorrection.getParameter<bool>("phi");
89  cuts.applyBendCorrection_mass_ = applyBendCorrection.getParameter<bool>("mass");
90  if ( decayMode.exists("minPi0Mass") ) {
91  cuts.minPi0Mass_ = decayMode.getParameter<double>("minPi0Mass");
92  cuts.maxPi0Mass_ = decayMode.getParameter<double>("maxPi0Mass");
93  } else {
94  cuts.minPi0Mass_ = -1.e3;
95  cuts.maxPi0Mass_ = 1.e9;
96  }
97  if ( decayMode.exists("assumeStripMass") ) {
98  cuts.assumeStripMass_ = decayMode.getParameter<double>("assumeStripMass");
99  } else {
100  cuts.assumeStripMass_ = -1.0;
101  }
102  decayModeCuts_.insert(std::make_pair(
103  // The decay mode as a key
104  std::make_pair(
105  decayMode.getParameter<uint32_t>("nCharged"),
106  decayMode.getParameter<uint32_t>("nPiZeros")),
107  cuts
108  ));
109  }
110  requireTauChargedHadronsToBeChargedPFCands_ = pset.getParameter<bool>("requireTauChargedHadronsToBeChargedPFCands");
111  minPixelHits_ = pset.getParameter<int>("minPixelHits");
112  verbosity_ = pset.exists("verbosity") ?
113  pset.getParameter<int>("verbosity") : 0;
114 
115 
116 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
PFRecoTauDiscriminationByHPSSelection::~PFRecoTauDiscriminationByHPSSelection ( )
override

Definition at line 118 of file PFRecoTauDiscriminationByHPSSelection.cc.

References decayModeCuts_.

119 {
120  for ( DecayModeCutMap::iterator it = decayModeCuts_.begin();
121  it != decayModeCuts_.end(); ++it ) {
122  delete it->second.maxMass_;
123  }
124 }

Member Function Documentation

double PFRecoTauDiscriminationByHPSSelection::discriminate ( const reco::PFTauRef tau) const
override

Definition at line 127 of file PFRecoTauDiscriminationByHPSSelection.cc.

References funct::abs(), PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_eta_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::applyBendCorrection_phi_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::assumeStripMass_, muons2muons_cfi::chargedHadron, decayModeCuts_, DEFINE_FWK_MODULE, reco::deltaPhi(), deltaR(), particleFlow_cfi::dEta, particleFlow_cfi::dPhi, reco::TrackBase::hitPattern(), reco::PFRecoTauChargedHadron::kChargedPFCandidate, reco::PFRecoTauChargedHadron::kPFNeutralHadron, reco::PFRecoTauChargedHadron::kTrack, matchingCone_, SiStripPI::max, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxPi0Mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minPi0Mass_, minPixelHits_, minPt_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nChargedPFCandsMin_, nTracks(), PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nTracksMin_, reco::HitPattern::numberOfValidPixelHits(), requireTauChargedHadronsToBeChargedPFCands_, AlCaHLTBitMon_QueryRunRegistry::string, HiIsolationCommonParameters_cff::track, and verbosity_.

128 {
129  if ( verbosity_ ) {
130  edm::LogPrint("PFTauByHPSSelect") << "<PFRecoTauDiscriminationByHPSSelection::discriminate>:" ;
131  edm::LogPrint("PFTauByHPSSelect") << " nCharged = " << tau->signalTauChargedHadronCandidates().size() ;
132  edm::LogPrint("PFTauByHPSSelect") << " nPiZeros = " << tau->signalPiZeroCandidates().size() ;
133  }
134 
135  // Check if we pass the min pt
136  if ( tau->pt() < minPt_ ) {
137  if ( verbosity_ ) {
138  edm::LogPrint("PFTauByHPSSelect") << " fails minPt cut." ;
139  }
140  return 0.0;
141  }
142 
143  // See if we select this decay mode
144  DecayModeCutMap::const_iterator massWindowIter =
145  decayModeCuts_.find(std::make_pair(tau->signalTauChargedHadronCandidates().size(),
146  tau->signalPiZeroCandidates().size()));
147  // Check if decay mode is supported
148  if ( massWindowIter == decayModeCuts_.end() ) {
149  if ( verbosity_ ) {
150  edm::LogPrint("PFTauByHPSSelect") << " fails mass-window definition requirement." ;
151  }
152  return 0.0;
153  }
154  const DecayModeCuts& massWindow = massWindowIter->second;
155 
156  if ( massWindow.nTracksMin_ > 0 ) {
157  unsigned int nTracks = 0;
158  const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
159  for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
160  chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
162  ++nTracks;
163  }
164  }
165  if ( verbosity_ ) {
166  edm::LogPrint("PFTauByHPSSelect") << "nTracks = " << nTracks << " (min = " << massWindow.nTracksMin_ << ")" ;
167  }
168  if ( nTracks < massWindow.nTracksMin_ ) {
169  if ( verbosity_ ) {
170  edm::LogPrint("PFTauByHPSSelect") << " fails nTracks requirement for mass-window." ;
171  }
172  return 0.0;
173  }
174  }
175  if ( massWindow.nChargedPFCandsMin_ > 0 ) {
176  unsigned int nChargedPFCands = 0;
177  const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
178  for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
179  chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
181  ++nChargedPFCands;
182  }
183  }
184  if ( verbosity_ ) {
185  edm::LogPrint("PFTauByHPSSelect") << "nChargedPFCands = " << nChargedPFCands << " (min = " << massWindow.nChargedPFCandsMin_ << ")" ;
186  }
187  if ( nChargedPFCands < massWindow.nChargedPFCandsMin_ ) {
188  if ( verbosity_ ) {
189  edm::LogPrint("PFTauByHPSSelect") << " fails nChargedPFCands requirement for mass-window." ;
190  }
191  return 0.0;
192  }
193  }
194 
195  math::XYZTLorentzVector tauP4 = tau->p4();
196  if ( verbosity_ ) {
197  edm::LogPrint("PFTauByHPSSelect") << "tau: Pt = " << tauP4.pt() << ", eta = " << tauP4.eta() << ", phi = " << tauP4.phi() << ", mass = " << tauP4.mass() ;
198  }
199  // Find the total pizero p4
201  for(auto const& cand : tau->signalPiZeroCandidates()){
202  const math::XYZTLorentzVector& candP4 = cand.p4();
203  stripsP4 += candP4;
204  }
205 
206  // Apply strip mass assumption corrections
207  if (massWindow.assumeStripMass_ >= 0) {
208  for(auto const& cand : tau->signalPiZeroCandidates()){
209  const math::XYZTLorentzVector& uncorrected = cand.p4();
210  math::XYZTLorentzVector corrected =
211  applyMassConstraint(uncorrected, massWindow.assumeStripMass_);
212  math::XYZTLorentzVector correction = corrected - uncorrected;
213  tauP4 += correction;
214  stripsP4 += correction;
215  }
216  }
217  if ( verbosity_ ) {
218  edm::LogPrint("PFTauByHPSSelect") << "strips: Pt = " << stripsP4.pt() << ", eta = " << stripsP4.eta() << ", phi = " << stripsP4.phi() << ", mass = " << stripsP4.mass() ;
219  }
220 
221  // Check if tau fails mass cut
222  double maxMass_value = (*massWindow.maxMass_)(*tau);
223  double bendCorrection_mass = ( massWindow.applyBendCorrection_mass_ ) ? tau->bendCorrMass() : 0.;
224  if ( !((tauP4.M() - bendCorrection_mass) < maxMass_value && (tauP4.M() + bendCorrection_mass) > massWindow.minMass_) ) {
225  if ( verbosity_ ) {
226  edm::LogPrint("PFTauByHPSSelect") << " fails tau mass-window cut." ;
227  }
228  return 0.0;
229  }
230  // CV: require that mass of charged tau decay products is always within specified mass window,
231  // irrespective of bendCorrection_mass
232  reco::Candidate::LorentzVector tauP4_charged;
233  const std::vector<reco::PFRecoTauChargedHadron>& signalChargedHadrons = tau->signalTauChargedHadronCandidates();
234  for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator signalChargedHadron = signalChargedHadrons.begin();
235  signalChargedHadron != signalChargedHadrons.end(); ++signalChargedHadron ) {
236  tauP4_charged += signalChargedHadron->p4();
237  }
238  if ( !(tauP4_charged.mass() < maxMass_value) ) {
239  if ( verbosity_ ) {
240  edm::LogPrint("PFTauByHPSSelect") << " fails tau mass-window cut." ;
241  }
242  return 0.0;
243  }
244 
245  // Check if it fails the pi0 IM cut
246  if ( stripsP4.M() > massWindow.maxPi0Mass_ ||
247  stripsP4.M() < massWindow.minPi0Mass_ ) {
248  if ( verbosity_ ) {
249  edm::LogPrint("PFTauByHPSSelect") << " fails strip mass-window cut." ;
250  }
251  return 0.0;
252  }
253 
254  // Check if tau passes matching cone cut
255  //edm::LogPrint("PFTauByHPSSelect") << "dR(tau, jet) = " << deltaR(tauP4, tau->jetRef()->p4()) ;
256  if ( deltaR(tauP4, tau->jetRef()->p4()) > matchingCone_ ) {
257  if ( verbosity_ ) {
258  edm::LogPrint("PFTauByHPSSelect") << " fails matching-cone cut." ;
259  }
260  return 0.0;
261  }
262 
263  // Check if tau passes cone cut
264  double cone_size = tau->signalConeSize();
265  // Check if any charged objects fail the signal cone cut
266  for (auto const& cand : tau->signalTauChargedHadronCandidates()) {
267  if ( verbosity_ ) {
268  edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPFChargedHadr) = " << deltaR(cand.p4(), tauP4) ;
269  }
270  if ( deltaR(cand.p4(), tauP4) > cone_size ) {
271  if ( verbosity_ ) {
272  edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for charged hadron(s)." ;
273  }
274  return 0.0;
275  }
276  }
277  // Now check the pizeros
278  for (auto const& cand : tau->signalPiZeroCandidates()) {
279  double bendCorrection_eta = ( massWindow.applyBendCorrection_eta_ ) ? cand.bendCorrEta() : 0.;
280  double dEta = std::max(0., fabs(cand.eta() - tauP4.eta()) - bendCorrection_eta);
281  double bendCorrection_phi = ( massWindow.applyBendCorrection_phi_ ) ? cand.bendCorrPhi() : 0.;
282  double dPhi = std::max(0., std::abs(reco::deltaPhi(cand.phi(), tauP4.phi())) - bendCorrection_phi);
283  double dR2 = dEta*dEta + dPhi*dPhi;
284  if ( verbosity_ ) {
285  edm::LogPrint("PFTauByHPSSelect") << "dR2(tau, signalPiZero) = " << dR2 ;
286  }
287  if ( dR2 > cone_size*cone_size ) {
288  if ( verbosity_ ) {
289  edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for strip(s)." ;
290  }
291  return 0.0;
292  }
293  }
294 
296  for(auto const& cand : tau->signalTauChargedHadronCandidates()) {
297  if ( verbosity_ ) {
298  std::string algo_string;
299  if ( cand.algo() == reco::PFRecoTauChargedHadron::kChargedPFCandidate ) algo_string = "ChargedPFCandidate";
300  else if ( cand.algo() == reco::PFRecoTauChargedHadron::kTrack ) algo_string = "Track";
301  else if ( cand.algo() == reco::PFRecoTauChargedHadron::kPFNeutralHadron ) algo_string = "PFNeutralHadron";
302  else algo_string = "Undefined";
303  edm::LogPrint("PFTauByHPSSelect") << "algo(signalPFChargedHadr) = " << algo_string ;
304  }
306  if ( verbosity_ ) {
307  edm::LogPrint("PFTauByHPSSelect") << " fails cut on PFRecoTauChargedHadron algo." ;
308  }
309  return 0.0;
310  }
311  }
312  }
313 
314  if ( minPixelHits_ > 0 ) {
315  int numPixelHits = 0;
316  const std::vector<reco::PFCandidatePtr>& chargedHadrCands = tau->signalPFChargedHadrCands();
317  for ( std::vector<reco::PFCandidatePtr>::const_iterator chargedHadrCand = chargedHadrCands.begin();
318  chargedHadrCand != chargedHadrCands.end(); ++chargedHadrCand ) {
319  const reco::Track* track = nullptr;
320  if ( (*chargedHadrCand)->trackRef().isNonnull() ) track = (*chargedHadrCand)->trackRef().get();
321  else if ( (*chargedHadrCand)->gsfTrackRef().isNonnull() ) track = (*chargedHadrCand)->gsfTrackRef().get();
322  if ( track ) {
323  numPixelHits += track->hitPattern().numberOfValidPixelHits();
324  }
325  }
326  if ( !(numPixelHits >= minPixelHits_) ) {
327  if ( verbosity_ ) {
328  edm::LogPrint("PFTauByHPSSelect") << " fails cut on sum of pixel hits." ;
329  }
330  return 0.0;
331  }
332  }
333 
334  // Otherwise, we pass!
335  if ( verbosity_ ) {
336  edm::LogPrint("PFTauByHPSSelect") << " passes all cuts." ;
337  }
338  return 1.0;
339 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
const unsigned int nTracks(const reco::Vertex &sv)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:479
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
int numberOfValidPixelHits() const
Definition: HitPattern.h:908

Member Data Documentation

DecayModeCutMap PFRecoTauDiscriminationByHPSSelection::decayModeCuts_
private
double PFRecoTauDiscriminationByHPSSelection::matchingCone_
private
int PFRecoTauDiscriminationByHPSSelection::minPixelHits_
private
double PFRecoTauDiscriminationByHPSSelection::minPt_
private
bool PFRecoTauDiscriminationByHPSSelection::requireTauChargedHadronsToBeChargedPFCands_
private
int PFRecoTauDiscriminationByHPSSelection::verbosity_
private