CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
PFRecoTauDiscriminationAgainstMuon2Helper Struct Reference

#include <PFRecoTauDiscriminationAgainstMuon2Helper.h>

Public Member Functions

bool eval (const PFRecoTauDiscriminationAgainstMuonConfigSet &, const reco::PFTauRef &) const
 
 PFRecoTauDiscriminationAgainstMuon2Helper (const bool &, const std::string &, const bool, const double &, const double &, const bool &, std::atomic< unsigned int > &, const unsigned int &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const edm::Handle< reco::MuonCollection > &, const reco::PFTauRef &, const reco::PFCandidatePtr &)
 

Public Attributes

double energyECALplusHCAL_
 
const reco::TrackleadTrack_ = nullptr
 
int numLast2StationsWithHits_ = 0
 
int numStationsWithMatches_ = 0
 
const reco::PFCandidatePtrpfLeadChargedHadron_
 

Detailed Description

Definition at line 24 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Constructor & Destructor Documentation

◆ PFRecoTauDiscriminationAgainstMuon2Helper()

PFRecoTauDiscriminationAgainstMuon2Helper::PFRecoTauDiscriminationAgainstMuon2Helper ( const bool &  verbosity,
const std::string &  moduleLabel,
const bool  srcMuons_label_empty,
const double &  minPtMatchedMuon,
const double &  dRmuonMatch,
const bool &  dRmuonMatchLimitedToJetArea,
std::atomic< unsigned int > &  numWarnings,
const unsigned int &  maxWarnings,
const std::vector< int > &  maskMatchesDT,
const std::vector< int > &  maskMatchesCSC,
const std::vector< int > &  maskMatchesRPC,
const std::vector< int > &  maskHitsDT,
const std::vector< int > &  maskHitsCSC,
const std::vector< int > &  maskHitsRPC,
const edm::Handle< reco::MuonCollection > &  muons,
const reco::PFTauRef pfTau,
const reco::PFCandidatePtr pfCand 
)

Definition at line 21 of file PFRecoTauDiscriminationAgainstMuon2Helper.cc.

39  : pfLeadChargedHadron_{pfCand} {
40  if (verbosity) {
41  edm::LogPrint("PFTauAgainstMuon2") << "<PFRecoTauDiscriminationAgainstMuon2Container::discriminate>:";
42  edm::LogPrint("PFTauAgainstMuon2") << " moduleLabel = " << moduleLabel;
43  edm::LogPrint("PFTauAgainstMuon2") << "tau #" << pfTau.key() << ": Pt = " << pfTau->pt()
44  << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi();
45  }
46 
47  std::vector<int> numMatchesDT(4);
48  std::vector<int> numMatchesCSC(4);
49  std::vector<int> numMatchesRPC(4);
50  std::vector<int> numHitsDT(4);
51  std::vector<int> numHitsCSC(4);
52  std::vector<int> numHitsRPC(4);
53  for (int iStation = 0; iStation < 4; ++iStation) {
54  numMatchesDT[iStation] = 0;
55  numMatchesCSC[iStation] = 0;
56  numMatchesRPC[iStation] = 0;
57  numHitsDT[iStation] = 0;
58  numHitsCSC[iStation] = 0;
59  numHitsRPC[iStation] = 0;
60  }
61 
62  //pfLeadChargedHadron_ = pfTau->leadPFChargedHadrCand();
64  reco::MuonRef muonRef = pfLeadChargedHadron_->muonRef();
65  if (muonRef.isNonnull()) {
66  if (verbosity)
67  edm::LogPrint("PFTauAgainstMuon2") << " has muonRef.";
68  reco::tau::countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC);
69  reco::tau::countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
70  }
71  }
72 
73  if (!srcMuons_label_empty) {
74  size_t numMuons = muons->size();
75  for (size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon) {
76  reco::MuonRef muon(muons, idxMuon);
77  if (verbosity)
78  edm::LogPrint("PFTauAgainstMuon2") << "muon #" << muon.key() << ": Pt = " << muon->pt()
79  << ", eta = " << muon->eta() << ", phi = " << muon->phi();
80  if (!(muon->pt() > minPtMatchedMuon)) {
81  if (verbosity) {
82  edm::LogPrint("PFTauAgainstMuon2") << " fails Pt cut --> skipping it.";
83  }
84  continue;
85  }
87  reco::MuonRef muonRef = pfLeadChargedHadron_->muonRef();
88  if (muonRef.isNonnull() && muon == pfLeadChargedHadron_->muonRef()) {
89  if (verbosity) {
90  edm::LogPrint("PFTauAgainstMuon2") << " matches muonRef of tau --> skipping it.";
91  }
92  continue;
93  }
94  }
95  double dR = deltaR(muon->p4(), pfTau->p4());
96  double dRmatch = dRmuonMatch;
98  double jetArea = 0.;
99  if (pfTau->jetRef().isNonnull())
100  jetArea = pfTau->jetRef()->jetArea();
101  if (jetArea > 0.) {
102  dRmatch = std::min(dRmatch, std::sqrt(jetArea / M_PI));
103  } else {
104  if (numWarnings < maxWarnings) {
105  edm::LogInfo("PFRecoTauDiscriminationAgainstMuon2Container::discriminate")
106  << "Jet associated to Tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta()
107  << ", phi = " << pfTau->phi() << " has area = " << jetArea << " !!";
108  ++numWarnings;
109  }
110  dRmatch = 0.1;
111  }
112  }
113  if (dR < dRmatch) {
114  if (verbosity)
115  edm::LogPrint("PFTauAgainstMuon2") << " overlaps with tau, dR = " << dR;
116  reco::tau::countMatches(*muon, numMatchesDT, numMatchesCSC, numMatchesRPC);
117  reco::tau::countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
118  }
119  }
120  }
121 
122  for (int iStation = 0; iStation < 4; ++iStation) {
123  if (numMatchesDT[iStation] > 0 && !maskMatchesDT[iStation])
125  if (numMatchesCSC[iStation] > 0 && !maskMatchesCSC[iStation])
127  if (numMatchesRPC[iStation] > 0 && !maskMatchesRPC[iStation])
129  }
130 
131  for (int iStation = 2; iStation < 4; ++iStation) {
132  if (numHitsDT[iStation] > 0 && !maskHitsDT[iStation])
134  if (numHitsCSC[iStation] > 0 && !maskHitsCSC[iStation])
136  if (numHitsRPC[iStation] > 0 && !maskHitsRPC[iStation])
138  }
139 
140  if (verbosity) {
141  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesDT = " << format_vint(numMatchesDT);
142  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesCSC = " << format_vint(numMatchesCSC);
143  edm::LogPrint("PFTauAgainstMuon2") << "numMatchesRPC = " << format_vint(numMatchesRPC);
144  edm::LogPrint("PFTauAgainstMuon2") << " --> numStationsWithMatches_ = " << numStationsWithMatches_;
145  edm::LogPrint("PFTauAgainstMuon2") << "numHitsDT = " << format_vint(numHitsDT);
146  edm::LogPrint("PFTauAgainstMuon2") << "numHitsCSC = " << format_vint(numHitsCSC);
147  edm::LogPrint("PFTauAgainstMuon2") << "numHitsRPC = " << format_vint(numHitsRPC);
148  edm::LogPrint("PFTauAgainstMuon2") << " --> numLast2StationsWithHits_ = " << numLast2StationsWithHits_;
149  }
150 
152  energyECALplusHCAL_ = pfLeadChargedHadron_->ecalEnergy() + pfLeadChargedHadron_->hcalEnergy();
153  if (verbosity) {
154  if (pfLeadChargedHadron_->trackRef().isNonnull()) {
155  edm::LogPrint("PFTauAgainstMuon2")
156  << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL_
157  << ", leadPFChargedHadronP = " << pfLeadChargedHadron_->trackRef()->p();
158  } else if (pfLeadChargedHadron_->gsfTrackRef().isNonnull()) {
159  edm::LogPrint("PFTauAgainstMuon2")
160  << "decayMode = " << pfTau->decayMode() << ", energy(ECAL+HCAL) = " << energyECALplusHCAL_
161  << ", leadPFChargedHadronP = " << pfLeadChargedHadron_->gsfTrackRef()->p();
162  }
163  }
164  if (pfLeadChargedHadron_->trackRef().isNonnull())
165  leadTrack_ = pfLeadChargedHadron_->trackRef().get();
166  else if (pfLeadChargedHadron_->gsfTrackRef().isNonnull())
167  leadTrack_ = pfLeadChargedHadron_->gsfTrackRef().get();
168  }
169 }

Member Function Documentation

◆ eval()

bool PFRecoTauDiscriminationAgainstMuon2Helper::eval ( const PFRecoTauDiscriminationAgainstMuonConfigSet config,
const reco::PFTauRef pfTau 
) const

Definition at line 171 of file PFRecoTauDiscriminationAgainstMuon2Helper.cc.

172  {
173  bool passesCaloMuonVeto = true;
175  if (pfTau->decayMode() == 0 && leadTrack_ && energyECALplusHCAL_ < (config.hop * leadTrack_->p()))
176  passesCaloMuonVeto = false;
177  }
178 
179  bool discriminatorValue = false;
180  if (config.discriminatorOption == PFRecoTauDiscriminationAgainstMuonConfigSet::kLoose &&
181  numStationsWithMatches_ <= config.maxNumberOfMatches)
182  discriminatorValue = true;
183  else if (config.discriminatorOption == PFRecoTauDiscriminationAgainstMuonConfigSet::kMedium &&
184  numStationsWithMatches_ <= config.maxNumberOfMatches &&
185  numLast2StationsWithHits_ <= config.maxNumberOfHitsLast2Stations)
186  discriminatorValue = true;
187  else if (config.discriminatorOption == PFRecoTauDiscriminationAgainstMuonConfigSet::kTight &&
188  numStationsWithMatches_ <= config.maxNumberOfMatches &&
189  numLast2StationsWithHits_ <= config.maxNumberOfHitsLast2Stations && passesCaloMuonVeto)
190  discriminatorValue = true;
191  else if (config.discriminatorOption == PFRecoTauDiscriminationAgainstMuonConfigSet::kCustom) {
192  discriminatorValue = true;
193  if (config.maxNumberOfMatches >= 0 && numStationsWithMatches_ > config.maxNumberOfMatches)
194  discriminatorValue = false;
195  if (config.maxNumberOfHitsLast2Stations >= 0 && numLast2StationsWithHits_ > config.maxNumberOfHitsLast2Stations)
196  discriminatorValue = false;
197  if (config.doCaloMuonVeto && !passesCaloMuonVeto)
198  discriminatorValue = false;
199  }
200  return discriminatorValue;
201 }

References energyECALplusHCAL_, edm::Ptr< T >::isNonnull(), PFRecoTauDiscriminationAgainstMuonConfigSet::kCustom, PFRecoTauDiscriminationAgainstMuonConfigSet::kLoose, PFRecoTauDiscriminationAgainstMuonConfigSet::kMedium, PFRecoTauDiscriminationAgainstMuonConfigSet::kTight, leadTrack_, numLast2StationsWithHits_, numStationsWithMatches_, reco::TrackBase::p(), and pfLeadChargedHadron_.

Member Data Documentation

◆ energyECALplusHCAL_

double PFRecoTauDiscriminationAgainstMuon2Helper::energyECALplusHCAL_

Definition at line 25 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Referenced by eval().

◆ leadTrack_

const reco::Track* PFRecoTauDiscriminationAgainstMuon2Helper::leadTrack_ = nullptr

Definition at line 27 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Referenced by eval().

◆ numLast2StationsWithHits_

int PFRecoTauDiscriminationAgainstMuon2Helper::numLast2StationsWithHits_ = 0

Definition at line 29 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Referenced by eval().

◆ numStationsWithMatches_

int PFRecoTauDiscriminationAgainstMuon2Helper::numStationsWithMatches_ = 0

Definition at line 28 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Referenced by eval().

◆ pfLeadChargedHadron_

const reco::PFCandidatePtr& PFRecoTauDiscriminationAgainstMuon2Helper::pfLeadChargedHadron_

Definition at line 26 of file PFRecoTauDiscriminationAgainstMuon2Helper.h.

Referenced by eval().

PFRecoTauDiscriminationAgainstMuonConfigSet::kCustom
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
ctppsCommonDQMSource_cfi.verbosity
verbosity
Definition: ctppsCommonDQMSource_cfi.py:14
muon
Definition: MuonCocktails.h:17
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HLT_FULL_cff.maskHitsCSC
maskHitsCSC
Definition: HLT_FULL_cff.py:35635
PFRecoTauDiscriminationAgainstMuon2Helper::energyECALplusHCAL_
double energyECALplusHCAL_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:25
HLT_FULL_cff.maskMatchesDT
maskMatchesDT
Definition: HLT_FULL_cff.py:35638
edm::Ref< MuonCollection >
reco::tau::format_vint
std::string format_vint(const std::vector< int > &vi)
Definition: RecoTauMuonTools.cc:33
config
Definition: config.py:1
reco::tau::countMatches
void countMatches(const reco::Muon &muon, std::vector< int > &numMatchesDT, std::vector< int > &numMatchesCSC, std::vector< int > &numMatchesRPC)
Definition: RecoTauMuonTools.cc:46
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11725
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HLT_FULL_cff.maskHitsDT
maskHitsDT
Definition: HLT_FULL_cff.py:35642
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
HLT_FULL_cff.dRmuonMatchLimitedToJetArea
dRmuonMatchLimitedToJetArea
Definition: HLT_FULL_cff.py:35640
PFRecoTauDiscriminationAgainstMuonConfigSet::kMedium
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
PFRecoTauDiscriminationAgainstMuon2Helper::leadTrack_
const reco::Track * leadTrack_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:27
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
HLT_FULL_cff.minPtMatchedMuon
minPtMatchedMuon
Definition: HLT_FULL_cff.py:35639
PFRecoTauDiscriminationAgainstMuonConfigSet::kTight
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
HLT_FULL_cff.dRmuonMatch
dRmuonMatch
Definition: HLT_FULL_cff.py:35646
PFRecoTauDiscriminationAgainstMuon2Helper::pfLeadChargedHadron_
const reco::PFCandidatePtr & pfLeadChargedHadron_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:26
PFRecoTauDiscriminationAgainstMuon2Helper::numLast2StationsWithHits_
int numLast2StationsWithHits_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:29
PFRecoTauDiscriminationAgainstMuonConfigSet::kLoose
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
PFRecoTauDiscriminationAgainstMuon2Helper::numStationsWithMatches_
int numStationsWithMatches_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:28
HLT_FULL_cff.maskMatchesRPC
maskMatchesRPC
Definition: HLT_FULL_cff.py:35633
reco::tau::countHits
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)
Definition: RecoTauMuonTools.cc:7
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
HLT_FULL_cff.maskMatchesCSC
maskMatchesCSC
Definition: HLT_FULL_cff.py:35634
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
patZpeak.numMuons
numMuons
Definition: patZpeak.py:41
HLT_FULL_cff.maskHitsRPC
maskHitsRPC
Definition: HLT_FULL_cff.py:35631