CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
PFRecoTauDiscriminationByHPSSelection Class Reference
Inheritance diagram for PFRecoTauDiscriminationByHPSSelection:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  DecayModeCuts
 

Public Member Functions

double discriminate (const reco::PFTauRef &) override
 
 PFRecoTauDiscriminationByHPSSelection (const edm::ParameterSet &)
 
 ~PFRecoTauDiscriminationByHPSSelection ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual void beginEvent (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
virtual double discriminate (const TauRef &tau)=0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< IntPair,
DecayModeCuts
DecayModeCutMap
 
typedef std::pair< double, double > DoublePair
 
typedef std::pair< unsigned
int, unsigned int > 
IntPair
 
typedef StringObjectFunction
< reco::PFTau
TauFunc
 

Private Attributes

DecayModeCutMap decayModeCuts_
 
double matchingCone_
 
double minPt_
 
bool requireTauChargedHadronsToBeChargedPFCands_
 
TauFunc signalConeFun_
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 21 of file PFRecoTauDiscriminationByHPSSelection.cc.

Member Typedef Documentation

Definition at line 48 of file PFRecoTauDiscriminationByHPSSelection.cc.

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

Definition at line 47 of file PFRecoTauDiscriminationByHPSSelection.cc.

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

Definition at line 46 of file PFRecoTauDiscriminationByHPSSelection.cc.

Definition at line 29 of file PFRecoTauDiscriminationByHPSSelection.cc.

Constructor & Destructor Documentation

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

Definition at line 60 of file PFRecoTauDiscriminationByHPSSelection.cc.

References PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::assumeStripMass_, hpstanc_transforms::cuts, decayModeCuts_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), matchingCone_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxPi0Mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minPi0Mass_, minPt_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nChargedPFCandsMin_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nTracksMin_, requireTauChargedHadronsToBeChargedPFCands_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

62  signalConeFun_(pset.getParameter<std::string>("coneSizeFormula"))
63 {
64  // Get the matchign cut
65  matchingCone_ = pset.getParameter<double>("matchingCone");
66  minPt_ = pset.getParameter<double>("minTauPt");
67  // Get the mass cuts for each decay mode
68  typedef std::vector<edm::ParameterSet> VPSet;
69  const VPSet& decayModes = pset.getParameter<VPSet>("decayModes");
70  BOOST_FOREACH( const edm::ParameterSet &decayMode, decayModes ) {
71  // The mass window(s)
72  DecayModeCuts cuts;
73  if ( decayMode.exists("nTracksMin") ) {
74  cuts.nTracksMin_ = decayMode.getParameter<unsigned>("nTracksMin");
75  } else {
76  cuts.nTracksMin_ = 0;
77  }
78  if ( decayMode.exists("nChargedPFCandsMin") ) {
79  cuts.nChargedPFCandsMin_ = decayMode.getParameter<unsigned>("nChargedPFCandsMin");
80  } else {
81  cuts.nChargedPFCandsMin_ = 0;
82  }
83  cuts.minMass_ = decayMode.getParameter<double>("minMass");
84  cuts.maxMass_ = new TauFunc(decayMode.getParameter<std::string>("maxMass"));
85  if ( decayMode.exists("minPi0Mass") ) {
86  cuts.minPi0Mass_ = decayMode.getParameter<double>("minPi0Mass");
87  cuts.maxPi0Mass_ = decayMode.getParameter<double>("maxPi0Mass");
88  } else {
89  cuts.minPi0Mass_ = -1.e3;
90  cuts.maxPi0Mass_ = 1.e9;
91  }
92  if ( decayMode.exists("assumeStripMass") ) {
93  cuts.assumeStripMass_ = decayMode.getParameter<double>("assumeStripMass");
94  } else {
95  cuts.assumeStripMass_ = -1.0;
96  }
97  decayModeCuts_.insert(std::make_pair(
98  // The decay mode as a key
99  std::make_pair(
100  decayMode.getParameter<uint32_t>("nCharged"),
101  decayMode.getParameter<uint32_t>("nPiZeros")),
102  cuts
103  ));
104  }
105  requireTauChargedHadronsToBeChargedPFCands_ = pset.getParameter<bool>("requireTauChargedHadronsToBeChargedPFCands");
106  verbosity_ = pset.exists("verbosity") ?
107  pset.getParameter<int>("verbosity") : 0;
108 }
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 ( )

Definition at line 110 of file PFRecoTauDiscriminationByHPSSelection.cc.

References decayModeCuts_.

111 {
112  for ( DecayModeCutMap::iterator it = decayModeCuts_.begin();
113  it != decayModeCuts_.end(); ++it ) {
114  delete it->second.maxMass_;
115  }
116 }

Member Function Documentation

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

Definition at line 119 of file PFRecoTauDiscriminationByHPSSelection.cc.

References reco::PFRecoTauChargedHadron::algo(), PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::assumeStripMass_, decayModeCuts_, deltaR(), reco::PFRecoTauChargedHadron::kChargedPFCandidate, reco::PFRecoTauChargedHadron::kPFNeutralHadron, reco::PFRecoTauChargedHadron::kTrack, matchingCone_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::maxPi0Mass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minMass_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::minPi0Mass_, minPt_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nChargedPFCandsMin_, PFRecoTauDiscriminationByHPSSelection::DecayModeCuts::nTracksMin_, reco::LeafCandidate::p4(), requireTauChargedHadronsToBeChargedPFCands_, signalConeFun_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

120 {
121  if ( verbosity_ ) {
122  edm::LogPrint("PFTauByHPSSelect") << "<PFRecoTauDiscriminationByHPSSelection::discriminate>:" ;
123  edm::LogPrint("PFTauByHPSSelect") << " nCharged = " << tau->signalTauChargedHadronCandidates().size() ;
124  edm::LogPrint("PFTauByHPSSelect") << " nPiZeros = " << tau->signalPiZeroCandidates().size() ;
125  }
126 
127  // Check if we pass the min pt
128  if ( tau->pt() < minPt_ ) {
129  if ( verbosity_ ) {
130  edm::LogPrint("PFTauByHPSSelect") << " fails minPt cut." ;
131  }
132  return 0.0;
133  }
134 
135  // See if we select this decay mode
136  DecayModeCutMap::const_iterator massWindowIter =
137  decayModeCuts_.find(std::make_pair(tau->signalTauChargedHadronCandidates().size(),
138  tau->signalPiZeroCandidates().size()));
139  // Check if decay mode is supported
140  if ( massWindowIter == decayModeCuts_.end() ) {
141  if ( verbosity_ ) {
142  edm::LogPrint("PFTauByHPSSelect") << " fails mass-window definition requirement." ;
143  }
144  return 0.0;
145  }
146  const DecayModeCuts& massWindow = massWindowIter->second;
147 
148  if ( massWindow.nTracksMin_ > 0 ) {
149  unsigned int nTracks = 0;
150  const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
151  for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
152  chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
153  if ( chargedHadron->algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate) || chargedHadron->algoIs(reco::PFRecoTauChargedHadron::kTrack) ) {
154  ++nTracks;
155  }
156  }
157  if ( verbosity_ ) {
158  edm::LogPrint("PFTauByHPSSelect") << "nTracks = " << nTracks << " (min = " << massWindow.nTracksMin_ << ")" ;
159  }
160  if ( nTracks < massWindow.nTracksMin_ ) {
161  if ( verbosity_ ) {
162  edm::LogPrint("PFTauByHPSSelect") << " fails nTracks requirement for mass-window." ;
163  }
164  return 0.0;
165  }
166  }
167  if ( massWindow.nChargedPFCandsMin_ > 0 ) {
168  unsigned int nChargedPFCands = 0;
169  const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
170  for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
171  chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
172  if ( chargedHadron->algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate) ) {
173  ++nChargedPFCands;
174  }
175  }
176  if ( verbosity_ ) {
177  edm::LogPrint("PFTauByHPSSelect") << "nChargedPFCands = " << nChargedPFCands << " (min = " << massWindow.nChargedPFCandsMin_ << ")" ;
178  }
179  if ( nChargedPFCands < massWindow.nChargedPFCandsMin_ ) {
180  if ( verbosity_ ) {
181  edm::LogPrint("PFTauByHPSSelect") << " fails nChargedPFCands requirement for mass-window." ;
182  }
183  return 0.0;
184  }
185  }
186 
187  math::XYZTLorentzVector tauP4 = tau->p4();
188  if ( verbosity_ ) {
189  edm::LogPrint("PFTauByHPSSelect") << "tau: Pt = " << tauP4.pt() << ", eta = " << tauP4.eta() << ", phi = " << tauP4.phi() << ", mass = " << tauP4.mass() ;
190  }
191  // Find the total pizero p4
193  BOOST_FOREACH(const reco::RecoTauPiZero& cand,
194  tau->signalPiZeroCandidates()){
195  math::XYZTLorentzVector candP4 = cand.p4();
196  stripsP4 += candP4;
197  }
198 
199  // Apply strip mass assumption corrections
200  if (massWindow.assumeStripMass_ >= 0) {
201  BOOST_FOREACH(const reco::RecoTauPiZero& cand,
202  tau->signalPiZeroCandidates()){
203  math::XYZTLorentzVector uncorrected = cand.p4();
204  math::XYZTLorentzVector corrected =
205  applyMassConstraint(uncorrected, massWindow.assumeStripMass_);
206  math::XYZTLorentzVector correction = corrected - uncorrected;
207  tauP4 += correction;
208  stripsP4 += correction;
209  }
210  }
211  if ( verbosity_ ) {
212  edm::LogPrint("PFTauByHPSSelect") << "strips: Pt = " << stripsP4.pt() << ", eta = " << stripsP4.eta() << ", phi = " << stripsP4.phi() << ", mass = " << stripsP4.mass() ;
213  }
214 
215  // Check if tau fails mass cut
216  double maxMass_value = (*massWindow.maxMass_)(*tau);
217  if ( tauP4.M() > maxMass_value || tauP4.M() < massWindow.minMass_ ) {
218  if ( verbosity_ ) {
219  edm::LogPrint("PFTauByHPSSelect") << " fails tau mass-window cut." ;
220  }
221  return 0.0;
222  }
223 
224  // Check if it fails the pi0 IM cut
225  if ( stripsP4.M() > massWindow.maxPi0Mass_ ||
226  stripsP4.M() < massWindow.minPi0Mass_ ) {
227  if ( verbosity_ ) {
228  edm::LogPrint("PFTauByHPSSelect") << " fails strip mass-window cut." ;
229  }
230  return 0.0;
231  }
232 
233  // Check if tau passes matching cone cut
234  //edm::LogPrint("PFTauByHPSSelect") << "dR(tau, jet) = " << deltaR(tauP4, tau->jetRef()->p4()) ;
235  if ( deltaR(tauP4, tau->jetRef()->p4()) > matchingCone_ ) {
236  if ( verbosity_ ) {
237  edm::LogPrint("PFTauByHPSSelect") << " fails matching-cone cut." ;
238  }
239  return 0.0;
240  }
241 
242  // Check if tau passes cone cut
243  double cone_size = signalConeFun_(*tau);
244  // Check if any charged objects fail the signal cone cut
245  BOOST_FOREACH(const reco::PFRecoTauChargedHadron& cand, tau->signalTauChargedHadronCandidates()) {
246  if ( verbosity_ ) {
247  edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPFChargedHadr) = " << deltaR(cand.p4(), tauP4) ;
248  }
249  if ( deltaR(cand.p4(), tauP4) > cone_size ) {
250  if ( verbosity_ ) {
251  edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for charged hadron(s)." ;
252  }
253  return 0.0;
254  }
255  }
256  // Now check the pizeros
257  BOOST_FOREACH(const reco::RecoTauPiZero& cand, tau->signalPiZeroCandidates()) {
258  if ( verbosity_ ) {
259  edm::LogPrint("PFTauByHPSSelect") << "dR(tau, signalPiZero) = " << deltaR(cand.p4(), tauP4) ;
260  }
261  if ( deltaR(cand.p4(), tauP4) > cone_size ) {
262  if ( verbosity_ ) {
263  edm::LogPrint("PFTauByHPSSelect") << " fails signal-cone cut for strip(s)." ;
264  }
265  return 0.0;
266  }
267  }
268 
270  BOOST_FOREACH(const reco::PFRecoTauChargedHadron& cand, tau->signalTauChargedHadronCandidates()) {
271  if ( verbosity_ ) {
272  std::string algo_string;
273  if ( cand.algo() == reco::PFRecoTauChargedHadron::kChargedPFCandidate ) algo_string = "ChargedPFCandidate";
274  else if ( cand.algo() == reco::PFRecoTauChargedHadron::kTrack ) algo_string = "Track";
275  else if ( cand.algo() == reco::PFRecoTauChargedHadron::kPFNeutralHadron ) algo_string = "PFNeutralHadron";
276  else algo_string = "Undefined";
277  edm::LogPrint("PFTauByHPSSelect") << "algo(signalPFChargedHadr) = " << algo_string ;
278  }
280  if ( verbosity_ ) {
281  edm::LogPrint("PFTauByHPSSelect") << " fails cut on PFRecoTauChargedHadron algo." ;
282  }
283  return 0.0;
284  }
285  }
286  }
287 
288  // Otherwise, we pass!
289  if ( verbosity_ ) {
290  edm::LogPrint("PFTauByHPSSelect") << " passes all cuts." ;
291  }
292  return 1.0;
293 }
PFRecoTauChargedHadronAlgorithm algo() const
Algorithm that built this charged hadron.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual const LorentzVector & p4() const
four-momentum Lorentz vector

Member Data Documentation

DecayModeCutMap PFRecoTauDiscriminationByHPSSelection::decayModeCuts_
private
double PFRecoTauDiscriminationByHPSSelection::matchingCone_
private
double PFRecoTauDiscriminationByHPSSelection::minPt_
private
bool PFRecoTauDiscriminationByHPSSelection::requireTauChargedHadronsToBeChargedPFCands_
private
TauFunc PFRecoTauDiscriminationByHPSSelection::signalConeFun_
private

Definition at line 50 of file PFRecoTauDiscriminationByHPSSelection.cc.

Referenced by discriminate().

int PFRecoTauDiscriminationByHPSSelection::verbosity_
private