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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const reco::PFTauRef &) override
 
 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 ()
 
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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  { kLoose, kMedium, kTight, kCustom }
 

Private Attributes

int discriminatorOption_
 
bool doCaloMuonVeto_
 
double dRmuonMatch_
 
bool dRmuonMatchLimitedToJetArea_
 
double hop_
 
int maxNumberOfHitsLast2Stations_
 
int maxNumberOfMatches_
 
int maxWarnings_
 
std::string moduleLabel_
 
edm::Handle< reco::MuonCollectionmuons_
 
edm::EDGetTokenT
< reco::MuonCollection
Muons_token
 
int numWarnings_
 
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
 
- 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

Compute tau Id. discriminator against muons.

Author
Christian Veelken, LLR

Definition at line 29 of file PFRecoTauDiscriminationAgainstMuon2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 33 of file PFRecoTauDiscriminationAgainstMuon2.cc.

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

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

Definition at line 58 of file PFRecoTauDiscriminationAgainstMuon2.cc.

58 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 81 of file PFRecoTauDiscriminationAgainstMuon2.cc.

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

82 {
83  if ( srcMuons_.label() != "" ) {
85  }
86 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< reco::MuonCollection > Muons_token
double PFRecoTauDiscriminationAgainstMuon2::discriminate ( const reco::PFTauRef pfTau)
override

Definition at line 123 of file PFRecoTauDiscriminationAgainstMuon2.cc.

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

124 {
125  if ( verbosity_ ) {
126  std::cout << "<PFRecoTauDiscriminationAgainstMuon2::discriminate>:" << std::endl;
127  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
128  std::cout << "tau #" << pfTau.key() << ": Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << std::endl;
129  }
130 
131  int numMatches = 0;
132 
133  std::vector<int> numHitsDT(4);
134  std::vector<int> numHitsCSC(4);
135  std::vector<int> numHitsRPC(4);
136  for ( int iStation = 0; iStation < 4; ++iStation ) {
137  numHitsDT[iStation] = 0;
138  numHitsCSC[iStation] = 0;
139  numHitsRPC[iStation] = 0;
140  }
141 
142  const reco::PFCandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand();
143  if ( pfLeadChargedHadron.isNonnull() ) {
144  reco::MuonRef muonRef = pfLeadChargedHadron->muonRef();
145  if ( muonRef.isNonnull() ) {
146  if ( verbosity_ ) std::cout << " has muonRef." << std::endl;
147  numMatches = muonRef->numberOfMatches(reco::Muon::NoArbitration);
148  countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
149  }
150  }
151 
152  if ( srcMuons_.label() != "" ) {
153  size_t numMuons = muons_->size();
154  for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) {
155  reco::MuonRef muon(muons_, idxMuon);
156  if ( verbosity_ ) std::cout << "muon #" << muon.key() << ": Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
157  if ( pfLeadChargedHadron.isNonnull() && pfLeadChargedHadron->muonRef().isNonnull() && muon == pfLeadChargedHadron->muonRef() ) {
158  if ( verbosity_ ) std::cout << " matches muonRef of tau --> skipping it." << std::endl;
159  continue;
160  }
161  double dR = deltaR(muon->p4(), pfTau->p4());
162  double dRmatch = dRmuonMatch_;
164  double jetArea = 0.;
165  if ( pfTau->jetRef().isNonnull() ) jetArea = pfTau->jetRef()->jetArea();
166  if ( jetArea > 0. ) {
167  dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi()));
168  } else {
169  if ( numWarnings_ < maxWarnings_ ) {
170  edm::LogWarning("PFRecoTauDiscriminationAgainstMuon2::discriminate")
171  << "Jet associated to Tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << " has area = " << jetArea << " !!" << std::endl;
172  ++numWarnings_;
173  }
174  dRmatch = 0.1;
175  }
176  }
177  if ( dR < dRmatch ) {
178  if ( verbosity_ ) std::cout << " overlaps with tau, dR = " << dR << std::endl;
179  numMatches += muon->numberOfMatches(reco::Muon::NoArbitration);
180  countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
181  }
182  }
183  }
184 
185  if ( verbosity_ ) {
186  std::cout << "numMatches = " << numMatches << std::endl;
187  std::cout << "numHitsDT = " << format_vint(numHitsDT) << std::endl;
188  std::cout << "numHitsCSC = " << format_vint(numHitsCSC) << std::endl;
189  std::cout << "numHitsRPC = " << format_vint(numHitsRPC) << std::endl;
190  }
191 
192  int numLast2StationsWithHits = 0;
193  for ( int iStation = 2; iStation < 4; ++iStation ) {
194  if ( numHitsDT[iStation] > 0 ) ++numLast2StationsWithHits;
195  if ( numHitsCSC[iStation] > 0 ) ++numLast2StationsWithHits;
196  if ( numHitsRPC[iStation] > 0 ) ++numLast2StationsWithHits;
197  }
198 
199 
200  bool passesCaloMuonVeto = true;
201  if ( pfLeadChargedHadron.isNonnull() ) {
202  double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy();
203  if ( verbosity_ ) {
204  if ( pfLeadChargedHadron->trackRef().isNonnull() ) std::cout << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->trackRef()->p() << std::endl;
205  else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() )
206 std::cout << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->gsfTrackRef()->p() << std::endl;
207 
208  }
209  const reco::Track* leadTrack = 0;
210  if ( pfLeadChargedHadron->trackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->trackRef().get();
211  else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->gsfTrackRef().get();
212  if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false;
213  }
214 
215  double discriminatorValue = 0.;
216  if ( discriminatorOption_ == kLoose && numMatches <= maxNumberOfMatches_ ) discriminatorValue = 1.;
217  else if ( discriminatorOption_ == kMedium && numMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ ) discriminatorValue = 1.;
218  else if ( discriminatorOption_ == kTight && numMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ && passesCaloMuonVeto ) discriminatorValue = 1.;
219  else if ( discriminatorOption_ == kCustom ) {
220  bool pass = true;
221  if ( maxNumberOfMatches_ >= 0 && numMatches > maxNumberOfMatches_ ) pass = false;
222  if ( maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_ ) pass = false;
223  if ( doCaloMuonVeto_ && !passesCaloMuonVeto ) pass = false;
224  discriminatorValue = pass ? 1.: 0.;
225  }
226  if ( verbosity_ ) std::cout << "--> returning discriminatorValue = " << discriminatorValue << std::endl;
227 
228  return discriminatorValue;
229 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
const double Pi
tuple numMuons
Definition: patZpeak.py:40
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
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:42
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

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

Definition at line 72 of file PFRecoTauDiscriminationAgainstMuon2.cc.

Referenced by beginEvent(), and discriminate().

edm::EDGetTokenT<reco::MuonCollection> PFRecoTauDiscriminationAgainstMuon2::Muons_token
private
int PFRecoTauDiscriminationAgainstMuon2::numWarnings_
mutableprivate
edm::InputTag PFRecoTauDiscriminationAgainstMuon2::srcMuons_
private
int PFRecoTauDiscriminationAgainstMuon2::verbosity_
private