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 20 of file PFRecoTauDiscriminationAgainstMuon2Helper.cc.

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

Member Function Documentation

◆ eval()

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

Definition at line 170 of file PFRecoTauDiscriminationAgainstMuon2Helper.cc.

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

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().

HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
HLT_2018_cff.dRmuonMatch
dRmuonMatch
Definition: HLT_2018_cff.py:34290
muon
Definition: MuonCocktails.h:17
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition: TrackBase.h:605
min
T min(T a, T b)
Definition: MathUtil.h:58
HLT_2018_cff.maskHitsCSC
maskHitsCSC
Definition: HLT_2018_cff.py:34292
edm::LogInfo
Definition: MessageLogger.h:254
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
HLT_2018_cff.muon
muon
Definition: HLT_2018_cff.py:10349
PFRecoTauDiscriminationAgainstMuon2Helper::energyECALplusHCAL_
double energyECALplusHCAL_
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:25
edm::Ref< MuonCollection >
reco::tau::format_vint
std::string format_vint(const std::vector< int > &vi)
Definition: RecoTauMuonTools.cc:33
PFRecoTauDiscriminationAgainstMuonConfigSet::kTight
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
config
Definition: config.py:1
HLT_2018_cff.dRmuonMatchLimitedToJetArea
dRmuonMatchLimitedToJetArea
Definition: HLT_2018_cff.py:34289
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
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PFRecoTauDiscriminationAgainstMuonConfigSet::kMedium
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
HLT_2018_cff.maskMatchesCSC
maskMatchesCSC
Definition: HLT_2018_cff.py:34299
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
HLT_2018_cff.minPtMatchedMuon
minPtMatchedMuon
Definition: HLT_2018_cff.py:34288
HLT_2018_cff.maskHitsDT
maskHitsDT
Definition: HLT_2018_cff.py:34295
HLT_2018_cff.maskMatchesRPC
maskMatchesRPC
Definition: HLT_2018_cff.py:34284
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:50
edm::LogPrint
Definition: MessageLogger.h:342
PFRecoTauDiscriminationAgainstMuonConfigSet::kCustom
Definition: PFRecoTauDiscriminationAgainstMuon2Helper.h:8
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
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
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
HLT_2018_cff.maskHitsRPC
maskHitsRPC
Definition: HLT_2018_cff.py:34282
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_2018_cff.maskMatchesDT
maskMatchesDT
Definition: HLT_2018_cff.py:34298