CMS 3D CMS Logo

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

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &)
 
double discriminate (const reco::PFTauRef &)
 
 PFRecoTauDiscriminationAgainstMuon2 (const edm::ParameterSet &cfg)
 
 ~PFRecoTauDiscriminationAgainstMuon2 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

enum  { kLoose, kMedium, kTight, kCustom }
 

Private Attributes

int discriminatorOption_
 
bool doCaloMuonVeto_
 
double dRmuonMatch_
 
double hop_
 
int maxNumberOfHitsLast2Stations_
 
int maxNumberOfMatches_
 
std::string moduleLabel_
 
edm::Handle< reco::MuonCollectionmuons_
 
edm::InputTag srcMuons_
 
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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
double prediscriminantFailValue_
 
edm::InputTag TauProducer_
 

Detailed Description

Compute tau Id. discriminator against muons.

Author
Christian Veelken, LLR
Version
Revision:
1.10
Id:
PFRecoTauDiscriminationAgainstMuon2.cc,v 1.10 2013/04/08 11:45:27 jez Exp

Definition at line 31 of file PFRecoTauDiscriminationAgainstMuon2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 35 of file PFRecoTauDiscriminationAgainstMuon2.cc.

References discriminatorOption_, doCaloMuonVeto_, dRmuonMatch_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), hop_, kCustom, kLoose, kMedium, kTight, maxNumberOfHitsLast2Stations_, maxNumberOfMatches_, srcMuons_, edm::errors::UnimplementedFeature, and verbosity_.

37  moduleLabel_(cfg.getParameter<std::string>("@module_label"))
38  {
39  std::string discriminatorOption_string = cfg.getParameter<std::string>("discriminatorOption");
40  if ( discriminatorOption_string == "loose" ) discriminatorOption_ = kLoose;
41  else if ( discriminatorOption_string == "medium" ) discriminatorOption_ = kMedium;
42  else if ( discriminatorOption_string == "tight" ) discriminatorOption_ = kTight;
43  else if ( discriminatorOption_string == "custom" ) discriminatorOption_ = kCustom;
45  << " Invalid Configuration parameter 'discriminatorOption' = " << discriminatorOption_string << " !!\n";
46  hop_ = cfg.getParameter<double>("HoPMin");
47  maxNumberOfMatches_ = cfg.exists("maxNumberOfMatches") ? cfg.getParameter<int>("maxNumberOfMatches"): 0;
48  doCaloMuonVeto_ = cfg.exists("doCaloMuonVeto") ? cfg.getParameter<bool>("doCaloMuonVeto"): false;
49  maxNumberOfHitsLast2Stations_ = cfg.exists("maxNumberOfHitsLast2Stations") ? cfg.getParameter<int>("maxNumberOfHitsLast2Stations"): 0;
50  if ( cfg.exists("srcMuons") ) {
51  srcMuons_ = cfg.getParameter<edm::InputTag>("srcMuons");
52  dRmuonMatch_ = cfg.getParameter<double>("dRmuonMatch");
53  }
54  verbosity_ = cfg.exists("verbosity") ? cfg.getParameter<int>("verbosity") : 0;
55  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
PFRecoTauDiscriminationAgainstMuon2::~PFRecoTauDiscriminationAgainstMuon2 ( )
inline

Definition at line 56 of file PFRecoTauDiscriminationAgainstMuon2.cc.

56 {}

Member Function Documentation

void PFRecoTauDiscriminationAgainstMuon2::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
virtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 75 of file PFRecoTauDiscriminationAgainstMuon2.cc.

References edm::Event::getByLabel(), edm::InputTag::label(), muons_, and srcMuons_.

76 {
77  if ( srcMuons_.label() != "" ) {
79  }
80 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string const & label() const
Definition: InputTag.h:25
double PFRecoTauDiscriminationAgainstMuon2::discriminate ( const reco::PFTauRef pfTau)

Definition at line 117 of file PFRecoTauDiscriminationAgainstMuon2.cc.

References gather_cfg::cout, deltaR(), discriminatorOption_, doCaloMuonVeto_, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, dRmuonMatch_, edm::Ref< C, T, F >::get(), hop_, edm::Ref< C, T, F >::isNonnull(), kCustom, edm::Ref< C, T, F >::key(), kLoose, kMedium, kTight, edm::InputTag::label(), singlePfTauSkim_cff::leadTrack, maxNumberOfHitsLast2Stations_, maxNumberOfMatches_, moduleLabel_, metsig::muon, muons_, reco::Muon::NoArbitration, patZpeak::numMuons, reco::TrackBase::p(), srcMuons_, and verbosity_.

118 {
119  if ( verbosity_ ) {
120  std::cout << "<PFRecoTauDiscriminationAgainstMuon2::discriminate>:" << std::endl;
121  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
122  std::cout << "tau #" << pfTau.key() << ": Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << std::endl;
123  }
124 
125  int numMatches = 0;
126 
127  std::vector<int> numHitsDT(4);
128  std::vector<int> numHitsCSC(4);
129  std::vector<int> numHitsRPC(4);
130  for ( int iStation = 0; iStation < 4; ++iStation ) {
131  numHitsDT[iStation] = 0;
132  numHitsCSC[iStation] = 0;
133  numHitsRPC[iStation] = 0;
134  }
135 
136  const reco::PFCandidateRef& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand();
137  if ( pfLeadChargedHadron.isNonnull() ) {
138  reco::MuonRef muonRef = pfLeadChargedHadron->muonRef();
139  if ( muonRef.isNonnull() ) {
140  if ( verbosity_ ) std::cout << " has muonRef." << std::endl;
141  numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration);
142  countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
143  }
144  }
145 
146  if ( srcMuons_.label() != "" ) {
147  size_t numMuons = muons_->size();
148  for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) {
149  reco::MuonRef muon(muons_, idxMuon);
150  if ( verbosity_ ) std::cout << "muon #" << muon.key() << ": Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
151  if ( pfLeadChargedHadron.isNonnull() && pfLeadChargedHadron->muonRef().isNonnull() && muon == pfLeadChargedHadron->muonRef() ) {
152  if ( verbosity_ ) std::cout << " matches muonRef of tau --> skipping it." << std::endl;
153  continue;
154  }
155  double dR = deltaR(muon->p4(), pfTau->p4());
156  if ( dR < dRmuonMatch_ ) {
157  if ( verbosity_ ) std::cout << " overlaps with tau, dR = " << dR << std::endl;
158  numMatches += muon->numberOfMatches(reco::Muon::NoArbitration);
159  countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
160  }
161  }
162  }
163 
164  if ( verbosity_ ) {
165  std::cout << "numMatches = " << numMatches << std::endl;
166  std::cout << "numHitsDT = " << format_vint(numHitsDT) << std::endl;
167  std::cout << "numHitsCSC = " << format_vint(numHitsCSC) << std::endl;
168  std::cout << "numHitsRPC = " << format_vint(numHitsRPC) << std::endl;
169  }
170 
171  int numLast2StationsWithHits = 0;
172  for ( int iStation = 2; iStation < 4; ++iStation ) {
173  if ( numHitsDT[iStation] > 0 ) ++numLast2StationsWithHits;
174  if ( numHitsCSC[iStation] > 0 ) ++numLast2StationsWithHits;
175  if ( numHitsRPC[iStation] > 0 ) ++numLast2StationsWithHits;
176  }
177 
178 
179  bool passesCaloMuonVeto = true;
180  if ( pfLeadChargedHadron.isNonnull() ) {
181  double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy();
182  if ( verbosity_ ) {
183  if ( pfLeadChargedHadron->trackRef().isNonnull() ) std::cout << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->trackRef()->p() << std::endl;
184  else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() )
185 std::cout << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->gsfTrackRef()->p() << std::endl;
186 
187  }
188  const reco::Track* leadTrack = 0;
189  if ( pfLeadChargedHadron->trackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->trackRef().get();
190  else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->gsfTrackRef().get();
191  if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false;
192  }
193 
194  double discriminatorValue = 0.;
195  if ( discriminatorOption_ == kLoose && numMatches <= maxNumberOfMatches_ ) discriminatorValue = 1.;
196  else if ( discriminatorOption_ == kMedium && numMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ ) discriminatorValue = 1.;
197  else if ( discriminatorOption_ == kTight && numMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ && passesCaloMuonVeto ) discriminatorValue = 1.;
198  else if ( discriminatorOption_ == kCustom ) {
199  bool pass = true;
200  if ( maxNumberOfMatches_ >= 0 && numMatches > maxNumberOfMatches_ ) pass = false;
201  if ( maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_ ) pass = false;
202  if ( doCaloMuonVeto_ && !passesCaloMuonVeto ) pass = false;
203  discriminatorValue = pass ? 1.: 0.;
204  }
205  if ( verbosity_ ) std::cout << "--> returning discriminatorValue = " << discriminatorValue << std::endl;
206 
207  return discriminatorValue;
208 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:129
tuple numMuons
Definition: patZpeak.py:40
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
key_type key() const
Accessor for product key.
Definition: Ref.h:266
std::string const & label() const
Definition: InputTag.h:25
tuple cout
Definition: gather_cfg.py:121
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242

Member Data Documentation

int PFRecoTauDiscriminationAgainstMuon2::discriminatorOption_
private
bool PFRecoTauDiscriminationAgainstMuon2::doCaloMuonVeto_
private
double PFRecoTauDiscriminationAgainstMuon2::dRmuonMatch_
private
double PFRecoTauDiscriminationAgainstMuon2::hop_
private
int PFRecoTauDiscriminationAgainstMuon2::maxNumberOfHitsLast2Stations_
private
int PFRecoTauDiscriminationAgainstMuon2::maxNumberOfMatches_
private
std::string PFRecoTauDiscriminationAgainstMuon2::moduleLabel_
private
edm::Handle<reco::MuonCollection> PFRecoTauDiscriminationAgainstMuon2::muons_
private

Definition at line 70 of file PFRecoTauDiscriminationAgainstMuon2.cc.

Referenced by beginEvent(), and discriminate().

edm::InputTag PFRecoTauDiscriminationAgainstMuon2::srcMuons_
private
int PFRecoTauDiscriminationAgainstMuon2::verbosity_
private