40 hop_ =
cfg.getParameter<
double>(
"HoPMin");
41 doCaloMuonVeto_ =
cfg.getParameter<
bool>(
"doCaloMuonVeto");
43 Muons_token = consumes<pat::MuonCollection>(srcPatMuons_);
44 dRmuonMatch_ =
cfg.getParameter<
double>(
"dRmuonMatch");
45 dRmuonMatchLimitedToJetArea_ =
cfg.getParameter<
bool>(
"dRmuonMatchLimitedToJetArea");
46 minPtMatchedMuon_ =
cfg.getParameter<
double>(
"minPtMatchedMuon");
47 maxNumberOfMatches_ =
cfg.getParameter<
int>(
"maxNumberOfMatches");
48 maxNumberOfHitsLast2Stations_ =
cfg.getParameter<
int>(
"maxNumberOfHitsLast2Stations");
49 typedef std::vector<int>
vint;
50 maskMatchesDT_ =
cfg.getParameter<
vint>(
"maskMatchesDT");
51 maskMatchesCSC_ =
cfg.getParameter<
vint>(
"maskMatchesCSC");
52 maskMatchesRPC_ =
cfg.getParameter<
vint>(
"maskMatchesRPC");
53 maskHitsDT_ =
cfg.getParameter<
vint>(
"maskHitsDT");
54 maskHitsCSC_ =
cfg.getParameter<
vint>(
"maskHitsCSC");
55 maskHitsRPC_ =
cfg.getParameter<
vint>(
"maskHitsRPC");
56 maxNumberOfSTAMuons_ =
cfg.getParameter<
int>(
"maxNumberOfSTAMuons");
57 maxNumberOfRPCMuons_ =
cfg.getParameter<
int>(
"maxNumberOfRPCMuons");
59 verbosity_ =
cfg.exists(
"verbosity") ?
cfg.getParameter<
int>(
"verbosity") : 0;
61 ~PFRecoTauDiscriminationAgainstMuonSimple()
override {}
69 int discriminatorOption_;
76 bool dRmuonMatchLimitedToJetArea_;
77 double minPtMatchedMuon_;
78 int maxNumberOfMatches_;
79 std::vector<int> maskMatchesDT_;
80 std::vector<int> maskMatchesCSC_;
81 std::vector<int> maskMatchesRPC_;
82 int maxNumberOfHitsLast2Stations_;
83 std::vector<int> maskHitsDT_;
84 std::vector<int> maskHitsCSC_;
85 std::vector<int> maskHitsRPC_;
86 int maxNumberOfSTAMuons_, maxNumberOfRPCMuons_;
88 static std::atomic<unsigned int> numWarnings_;
89 static constexpr
unsigned int maxWarnings_ = 3;
93 std::atomic<unsigned int> PFRecoTauDiscriminationAgainstMuonSimple::numWarnings_{0};
101 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"<PFRecoTauDiscriminationAgainstMuonSimple::discriminate>:";
102 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" moduleLabel = " << moduleLabel_;
104 <<
"tau #" << pfTau.
key() <<
": Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta()
105 <<
", phi = " << pfTau->phi() <<
", decay mode = " << pfTau->decayMode();
111 bool passesCaloMuonVeto =
true;
114 if (pCand !=
nullptr) {
119 <<
"decayMode = " << pfTau->decayMode()
120 <<
", rawCaloEnergy(ECAL+HCAL)Fraction = " << rawCaloEnergyFraction
121 <<
", leadPFChargedHadronP = " << pCand->
p() <<
", leadPFChargedHadron pdgId = " << pCand->
pdgId();
123 if (pfTau->decayMode() == 0 && rawCaloEnergyFraction < hop_)
124 passesCaloMuonVeto =
false;
127 if (doCaloMuonVeto_ && !passesCaloMuonVeto) {
129 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"--> CaloMuonVeto failed, returning 0";
134 std::vector<const pat::Muon*> muonsToCheck;
136 for (
size_t idxMuon = 0; idxMuon <
numMuons; ++idxMuon) {
141 <<
", eta = " <<
muon->eta() <<
", phi = " <<
muon->phi();
143 for (
size_t iCand = 0; iCand <
muon->numberOfSourceCandidatePtrs(); ++iCand) {
146 srcCand.
key() == pfLeadChargedHadron.
key()) {
147 muonsToCheck.push_back(
muon.get());
150 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" tau has muonRef.";
157 if (!(
muon->pt() > minPtMatchedMuon_)) {
159 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" fails Pt cut --> skipping it.";
164 double dRmatch = dRmuonMatch_;
165 if (dRmuonMatchLimitedToJetArea_) {
168 jetArea = pfTau->jetRef()->jetArea();
172 if (numWarnings_ < maxWarnings_) {
173 edm::LogInfo(
"PFRecoTauDiscriminationAgainstMuonSimple::discriminate")
174 <<
"Jet associated to Tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta()
175 <<
", phi = " << pfTau->phi() <<
" has area = " << jetArea <<
" !!";
178 dRmatch = pfTau->signalConeSize();
180 dRmatch =
TMath::Max(dRmatch, pfTau->signalConeSize());
183 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" overlaps with tau, dR = " <<
dR;
184 muonsToCheck.push_back(
muon.get());
190 std::vector<int> numMatchesDT(4);
191 std::vector<int> numMatchesCSC(4);
192 std::vector<int> numMatchesRPC(4);
193 std::vector<int> numHitsDT(4);
194 std::vector<int> numHitsCSC(4);
195 std::vector<int> numHitsRPC(4);
197 for (
int iStation = 0; iStation < 4; ++iStation) {
198 numMatchesDT[iStation] = 0;
199 numMatchesCSC[iStation] = 0;
200 numMatchesRPC[iStation] = 0;
201 numHitsDT[iStation] = 0;
202 numHitsCSC[iStation] = 0;
203 numHitsRPC[iStation] = 0;
205 int numSTAMuons = 0, numRPCMuons = 0;
206 if (verbosity_ && !muonsToCheck.empty())
207 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"Muons to check (" << muonsToCheck.size() <<
"):";
209 for (
const auto&
mu : muonsToCheck) {
210 if (
mu->isStandAloneMuon())
212 if (
mu->muonID(
"RPCMuLoose"))
215 int numStationsWithMatches = 0;
216 for (
int iStation = 0; iStation < 4; ++iStation) {
217 if (numMatchesDT[iStation] > 0 && !maskMatchesDT_[iStation])
218 ++numStationsWithMatches;
219 if (numMatchesCSC[iStation] > 0 && !maskMatchesCSC_[iStation])
220 ++numStationsWithMatches;
221 if (numMatchesRPC[iStation] > 0 && !maskMatchesRPC_[iStation])
222 ++numStationsWithMatches;
225 int numLast2StationsWithHits = 0;
226 for (
int iStation = 2; iStation < 4; ++iStation) {
227 if (numHitsDT[iStation] > 0 && !maskHitsDT_[iStation])
228 ++numLast2StationsWithHits;
229 if (numHitsCSC[iStation] > 0 && !maskHitsCSC_[iStation])
230 ++numLast2StationsWithHits;
231 if (numHitsRPC[iStation] > 0 && !maskHitsRPC_[iStation])
232 ++numLast2StationsWithHits;
236 <<
"\t" << iMu <<
": Pt = " <<
mu->pt() <<
", eta = " <<
mu->eta() <<
", phi = " <<
mu->phi() <<
"\n\t"
237 <<
" isSTA: " <<
mu->isStandAloneMuon() <<
", isRPCLoose: " <<
mu->muonID(
"RPCMuLoose")
238 <<
"\n\t numMatchesDT = " <<
format_vint(numMatchesDT)
239 <<
"\n\t numMatchesCSC = " <<
format_vint(numMatchesCSC)
240 <<
"\n\t numMatchesRPC = " <<
format_vint(numMatchesRPC)
241 <<
"\n\t --> numStationsWithMatches = " << numStationsWithMatches
244 <<
"\n\t --> numLast2StationsWithHits = " << numLast2StationsWithHits;
245 if (maxNumberOfMatches_ >= 0 && numStationsWithMatches > maxNumberOfMatches_) {
249 if (maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_) {
253 if (maxNumberOfSTAMuons_ >= 0 && numSTAMuons > maxNumberOfSTAMuons_) {
257 if (maxNumberOfRPCMuons_ >= 0 && numRPCMuons > maxNumberOfRPCMuons_) {
264 double discriminatorValue = pass ? 1. : 0.;
266 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"--> returning discriminatorValue = " << discriminatorValue;
268 return discriminatorValue;