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
 
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

enum  { kLoose, kMedium, kTight, kCustom }
 

Private Attributes

int discriminatorOption_
 
bool doCaloMuonVeto_
 
double dRmuonMatch_
 
bool dRmuonMatchLimitedToJetArea_
 
double hop_
 
std::vector< int > maskHitsCSC_
 
std::vector< int > maskHitsDT_
 
std::vector< int > maskHitsRPC_
 
std::vector< int > maskMatchesCSC_
 
std::vector< int > maskMatchesDT_
 
std::vector< int > maskMatchesRPC_
 
int maxNumberOfHitsLast2Stations_
 
int maxNumberOfMatches_
 
int maxWarnings_
 
double minPtMatchedMuon_
 
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 28 of file PFRecoTauDiscriminationAgainstMuon2.cc.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

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

Definition at line 32 of file PFRecoTauDiscriminationAgainstMuon2.cc.

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

34  moduleLabel_(cfg.getParameter<std::string>("@module_label"))
35  {
36  std::string discriminatorOption_string = cfg.getParameter<std::string>("discriminatorOption");
37  if ( discriminatorOption_string == "loose" ) discriminatorOption_ = kLoose;
38  else if ( discriminatorOption_string == "medium" ) discriminatorOption_ = kMedium;
39  else if ( discriminatorOption_string == "tight" ) discriminatorOption_ = kTight;
40  else if ( discriminatorOption_string == "custom" ) discriminatorOption_ = kCustom;
42  << " Invalid Configuration parameter 'discriminatorOption' = " << discriminatorOption_string << " !!\n";
43  hop_ = cfg.getParameter<double>("HoPMin");
44  maxNumberOfMatches_ = cfg.exists("maxNumberOfMatches") ? cfg.getParameter<int>("maxNumberOfMatches"): 0;
45  doCaloMuonVeto_ = cfg.exists("doCaloMuonVeto") ? cfg.getParameter<bool>("doCaloMuonVeto"): false;
46  maxNumberOfHitsLast2Stations_ = cfg.exists("maxNumberOfHitsLast2Stations") ? cfg.getParameter<int>("maxNumberOfHitsLast2Stations"): 0;
47  if ( cfg.exists("srcMuons") ) {
48  srcMuons_ = cfg.getParameter<edm::InputTag>("srcMuons");
49  Muons_token = consumes<reco::MuonCollection>(srcMuons_);
50  dRmuonMatch_ = cfg.getParameter<double>("dRmuonMatch");
51  dRmuonMatchLimitedToJetArea_ = cfg.getParameter<bool>("dRmuonMatchLimitedToJetArea");
52  minPtMatchedMuon_ = cfg.getParameter<double>("minPtMatchedMuon");
53  }
54  typedef std::vector<int> vint;
55  maskMatchesDT_ = cfg.getParameter<vint>("maskMatchesDT");
56  maskMatchesCSC_ = cfg.getParameter<vint>("maskMatchesCSC");
57  maskMatchesRPC_ = cfg.getParameter<vint>("maskMatchesRPC");
58  maskHitsDT_ = cfg.getParameter<vint>("maskHitsDT");
59  maskHitsCSC_ = cfg.getParameter<vint>("maskHitsCSC");
60  maskHitsRPC_ = cfg.getParameter<vint>("maskHitsRPC");
61  numWarnings_ = 0;
62  maxWarnings_ = 3;
63  verbosity_ = cfg.exists("verbosity") ? cfg.getParameter<int>("verbosity") : 0;
64  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
double vint[400]
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
edm::EDGetTokenT< reco::MuonCollection > Muons_token
PFRecoTauDiscriminationAgainstMuon2::~PFRecoTauDiscriminationAgainstMuon2 ( )
inline

Definition at line 65 of file PFRecoTauDiscriminationAgainstMuon2.cc.

65 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 95 of file PFRecoTauDiscriminationAgainstMuon2.cc.

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

96 {
97  if ( srcMuons_.label() != "" ) {
99  }
100 }
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 152 of file PFRecoTauDiscriminationAgainstMuon2.cc.

References 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, maskHitsCSC_, maskHitsDT_, maskHitsRPC_, maskMatchesCSC_, maskMatchesDT_, maskMatchesRPC_, maxNumberOfHitsLast2Stations_, maxNumberOfMatches_, maxWarnings_, Min(), minPtMatchedMuon_, moduleLabel_, metsig::muon, muons_, patZpeak::numMuons, numWarnings_, reco::TrackBase::p(), Pi, srcMuons_, and verbosity_.

153 {
154  if ( verbosity_ ) {
155  edm::LogPrint("PFTauAgainstMuon2") << "<PFRecoTauDiscriminationAgainstMuon2::discriminate>:" ;
156  edm::LogPrint("PFTauAgainstMuon2") << " moduleLabel = " << moduleLabel_ ;
157  edm::LogPrint("PFTauAgainstMuon2") << "tau #" << pfTau.key() << ": Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() ;
158  }
159 
160  std::vector<int> numMatchesDT(4);
161  std::vector<int> numMatchesCSC(4);
162  std::vector<int> numMatchesRPC(4);
163  std::vector<int> numHitsDT(4);
164  std::vector<int> numHitsCSC(4);
165  std::vector<int> numHitsRPC(4);
166  for ( int iStation = 0; iStation < 4; ++iStation ) {
167  numMatchesDT[iStation] = 0;
168  numMatchesCSC[iStation] = 0;
169  numMatchesRPC[iStation] = 0;
170  numHitsDT[iStation] = 0;
171  numHitsCSC[iStation] = 0;
172  numHitsRPC[iStation] = 0;
173  }
174 
175  const reco::PFCandidatePtr& pfLeadChargedHadron = pfTau->leadPFChargedHadrCand();
176  if ( pfLeadChargedHadron.isNonnull() ) {
177  reco::MuonRef muonRef = pfLeadChargedHadron->muonRef();
178  if ( muonRef.isNonnull() ) {
179  if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " has muonRef." ;
180  countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC);
181  countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
182  }
183  }
184 
185  if ( srcMuons_.label() != "" ) {
186  size_t numMuons = muons_->size();
187  for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) {
188  reco::MuonRef muon(muons_, idxMuon);
189  if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << "muon #" << muon.key() << ": Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() ;
190  if ( !(muon->pt() > minPtMatchedMuon_) ) {
191  if ( verbosity_ ){ edm::LogPrint("PFTauAgainstMuon2") << " fails Pt cut --> skipping it." ;}
192  continue;
193  }
194  if ( pfLeadChargedHadron.isNonnull() && pfLeadChargedHadron->muonRef().isNonnull() && muon == pfLeadChargedHadron->muonRef() ) {
195  if ( verbosity_ ){ edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it." ;}
196  continue;
197  }
198  double dR = deltaR(muon->p4(), pfTau->p4());
199  double dRmatch = dRmuonMatch_;
201  double jetArea = 0.;
202  if ( pfTau->jetRef().isNonnull() ) jetArea = pfTau->jetRef()->jetArea();
203  if ( jetArea > 0. ) {
204  dRmatch = TMath::Min(dRmatch, TMath::Sqrt(jetArea/TMath::Pi()));
205  } else {
206  if ( numWarnings_ < maxWarnings_ ) {
207  edm::LogWarning("PFRecoTauDiscriminationAgainstMuon2::discriminate")
208  << "Jet associated to Tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi() << " has area = " << jetArea << " !!" ;
209  ++numWarnings_;
210  }
211  dRmatch = 0.1;
212  }
213  }
214  if ( dR < dRmatch ) {
215  if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << " overlaps with tau, dR = " << dR ;
216  countMatches(*muon, numMatchesDT, numMatchesCSC, numMatchesRPC);
217  countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
218  }
219  }
220  }
221 
222  int numStationsWithMatches = 0;
223  for ( int iStation = 0; iStation < 4; ++iStation ) {
224  if ( numMatchesDT[iStation] > 0 && !maskMatchesDT_[iStation] ) ++numStationsWithMatches;
225  if ( numMatchesCSC[iStation] > 0 && !maskMatchesCSC_[iStation] ) ++numStationsWithMatches;
226  if ( numMatchesRPC[iStation] > 0 && !maskMatchesRPC_[iStation] ) ++numStationsWithMatches;
227  }
228 
229  int numLast2StationsWithHits = 0;
230  for ( int iStation = 2; iStation < 4; ++iStation ) {
231  if ( numHitsDT[iStation] > 0 && !maskHitsDT_[iStation] ) ++numLast2StationsWithHits;
232  if ( numHitsCSC[iStation] > 0 && !maskHitsCSC_[iStation] ) ++numLast2StationsWithHits;
233  if ( numHitsRPC[iStation] > 0 && !maskHitsRPC_[iStation] ) ++numLast2StationsWithHits;
234  }
235 
236  if ( verbosity_ ) {
237  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesDT = " << format_vint(numMatchesDT) ;
238  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesCSC = " << format_vint(numMatchesCSC) ;
239  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesRPC = " << format_vint(numMatchesRPC) ;
240  edm::LogPrint("PFTauAgainstMuon2") << " --> numStationsWithMatches = " << numStationsWithMatches ;
241  edm::LogPrint("PFTauAgainstMuon2") << "numHitsDT = " << format_vint(numHitsDT) ;
242  edm::LogPrint("PFTauAgainstMuon2") << "numHitsCSC = " << format_vint(numHitsCSC) ;
243  edm::LogPrint("PFTauAgainstMuon2") << "numHitsRPC = " << format_vint(numHitsRPC) ;
244  edm::LogPrint("PFTauAgainstMuon2") << " --> numLast2StationsWithHits = " << numLast2StationsWithHits ;
245  }
246 
247  bool passesCaloMuonVeto = true;
248  if ( pfLeadChargedHadron.isNonnull() ) {
249  double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy();
250  if ( verbosity_ ) {
251  if ( pfLeadChargedHadron->trackRef().isNonnull() ) {
252  edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->trackRef()->p() ;
253  } else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) {
254  edm::LogPrint("PFTauAgainstMuon2") << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL << ", leadPFChargedHadronP = " << pfLeadChargedHadron->gsfTrackRef()->p() ;
255  }
256  }
257  const reco::Track* leadTrack = 0;
258  if ( pfLeadChargedHadron->trackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->trackRef().get();
259  else if ( pfLeadChargedHadron->gsfTrackRef().isNonnull() ) leadTrack = pfLeadChargedHadron->gsfTrackRef().get();
260  if ( pfTau->decayMode() == 0 && leadTrack && energyECALplusHCAL < (hop_*leadTrack->p()) ) passesCaloMuonVeto = false;
261  }
262 
263  double discriminatorValue = 0.;
264  if ( discriminatorOption_ == kLoose && numStationsWithMatches <= maxNumberOfMatches_ ) discriminatorValue = 1.;
265  else if ( discriminatorOption_ == kMedium && numStationsWithMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ ) discriminatorValue = 1.;
266  else if ( discriminatorOption_ == kTight && numStationsWithMatches <= maxNumberOfMatches_ && numLast2StationsWithHits <= maxNumberOfHitsLast2Stations_ && passesCaloMuonVeto ) discriminatorValue = 1.;
267  else if ( discriminatorOption_ == kCustom ) {
268  bool pass = true;
269  if ( maxNumberOfMatches_ >= 0 && numStationsWithMatches > maxNumberOfMatches_ ) pass = false;
270  if ( maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_ ) pass = false;
271  if ( doCaloMuonVeto_ && !passesCaloMuonVeto ) pass = false;
272  discriminatorValue = pass ? 1.: 0.;
273  }
274  if ( verbosity_ ) edm::LogPrint("PFTauAgainstMuon2") << "--> returning discriminatorValue = " << discriminatorValue ;
275 
276  return discriminatorValue;
277 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:127
const double Pi
T Min(T a, T b)
Definition: MathUtil.h:39
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

Member Data Documentation

int PFRecoTauDiscriminationAgainstMuon2::discriminatorOption_
private
bool PFRecoTauDiscriminationAgainstMuon2::doCaloMuonVeto_
private
double PFRecoTauDiscriminationAgainstMuon2::dRmuonMatch_
private
bool PFRecoTauDiscriminationAgainstMuon2::dRmuonMatchLimitedToJetArea_
private
double PFRecoTauDiscriminationAgainstMuon2::hop_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskHitsCSC_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskHitsDT_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskHitsRPC_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskMatchesCSC_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskMatchesDT_
private
std::vector<int> PFRecoTauDiscriminationAgainstMuon2::maskMatchesRPC_
private
int PFRecoTauDiscriminationAgainstMuon2::maxNumberOfHitsLast2Stations_
private
int PFRecoTauDiscriminationAgainstMuon2::maxNumberOfMatches_
private
int PFRecoTauDiscriminationAgainstMuon2::maxWarnings_
private
double PFRecoTauDiscriminationAgainstMuon2::minPtMatchedMuon_
private
std::string PFRecoTauDiscriminationAgainstMuon2::moduleLabel_
private
edm::Handle<reco::MuonCollection> PFRecoTauDiscriminationAgainstMuon2::muons_
private

Definition at line 79 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