43 doCaloMuonVeto_ = cfg.
getParameter<
bool>(
"doCaloMuonVeto");
45 Muons_token = consumes<pat::MuonCollection>(srcPatMuons_);
47 dRmuonMatchLimitedToJetArea_ = cfg.
getParameter<
bool>(
"dRmuonMatchLimitedToJetArea");
48 minPtMatchedMuon_ = cfg.
getParameter<
double>(
"minPtMatchedMuon");
49 maxNumberOfMatches_ = cfg.
getParameter<
int>(
"maxNumberOfMatches");
50 maxNumberOfHitsLast2Stations_ = cfg.
getParameter<
int>(
"maxNumberOfHitsLast2Stations");
51 typedef std::vector<int>
vint;
52 maskMatchesDT_ = cfg.
getParameter<vint>(
"maskMatchesDT");
53 maskMatchesCSC_ = cfg.
getParameter<vint>(
"maskMatchesCSC");
54 maskMatchesRPC_ = cfg.
getParameter<vint>(
"maskMatchesRPC");
58 maxNumberOfSTAMuons_ = cfg.
getParameter<
int>(
"maxNumberOfSTAMuons");
59 maxNumberOfRPCMuons_ = cfg.
getParameter<
int>(
"maxNumberOfRPCMuons");
65 ~PFRecoTauDiscriminationAgainstMuonSimple()
override {}
73 int discriminatorOption_;
80 bool dRmuonMatchLimitedToJetArea_;
81 double minPtMatchedMuon_;
82 int maxNumberOfMatches_;
83 std::vector<int> maskMatchesDT_;
84 std::vector<int> maskMatchesCSC_;
85 std::vector<int> maskMatchesRPC_;
86 int maxNumberOfHitsLast2Stations_;
87 std::vector<int> maskHitsDT_;
88 std::vector<int> maskHitsCSC_;
89 std::vector<int> maskHitsRPC_;
90 int maxNumberOfSTAMuons_, maxNumberOfRPCMuons_;
92 mutable int numWarnings_;
105 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"<PFRecoTauDiscriminationAgainstMuonSimple::discriminate>:" ;
107 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"tau #" << pfTau.
key() <<
": Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi() <<
", decay mode = " << pfTau->decayMode() ;
113 bool passesCaloMuonVeto =
true;
116 if ( pCand !=
nullptr ) {
120 edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"decayMode = " << pfTau->decayMode() <<
", rawCaloEnergy(ECAL+HCAL)Fraction = " << rawCaloEnergyFraction <<
", leadPFChargedHadronP = " << pCand->
p() <<
", leadPFChargedHadron pdgId = " << pCand->
pdgId();
122 if ( pfTau->decayMode() == 0 && rawCaloEnergyFraction < hop_ ) passesCaloMuonVeto =
false;
125 if ( doCaloMuonVeto_ && !passesCaloMuonVeto ) {
126 if ( verbosity_ )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"--> CaloMuonVeto failed, returning 0";
131 std::vector<const pat::Muon*> muonsToCheck;
132 size_t numMuons = muons_->size();
133 for (
size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) {
136 if ( verbosity_ )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"muon #" <<
muon.key() <<
": Pt = " <<
muon->pt() <<
", eta = " <<
muon->eta() <<
", phi = " <<
muon->phi() ;
138 for (
size_t iCand = 0; iCand <
muon->numberOfSourceCandidatePtrs(); ++iCand) {
141 srcCand.
id()==pfLeadChargedHadron.
id() &&
142 srcCand.
key()==pfLeadChargedHadron.
key() ) {
143 muonsToCheck.push_back(
muon.get());
145 if ( verbosity_ )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" tau has muonRef." ;
149 if (matched)
continue;
151 if ( !(
muon->pt() > minPtMatchedMuon_) ) {
152 if ( verbosity_ ){
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" fails Pt cut --> skipping it." ;}
157 if ( dRmuonMatchLimitedToJetArea_ ) {
159 if ( pfTau->jetRef().
isNonnull() ) jetArea = pfTau->jetRef()->jetArea();
160 if ( jetArea > 0. ) {
163 if ( numWarnings_ < maxWarnings_ ) {
164 edm::LogInfo(
"PFRecoTauDiscriminationAgainstMuonSimple::discriminate")
165 <<
"Jet associated to Tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi() <<
" has area = " << jetArea <<
" !!" ;
168 dRmatch = pfTau->signalConeSize();
170 dRmatch =
TMath::Max(dRmatch,pfTau->signalConeSize());
171 if ( dR < dRmatch ) {
172 if ( verbosity_ )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
" overlaps with tau, dR = " <<
dR ;
173 muonsToCheck.push_back(
muon.get());
179 std::vector<int> numMatchesDT(4);
180 std::vector<int> numMatchesCSC(4);
181 std::vector<int> numMatchesRPC(4);
182 std::vector<int> numHitsDT(4);
183 std::vector<int> numHitsCSC(4);
184 std::vector<int> numHitsRPC(4);
186 for (
int iStation = 0; iStation < 4; ++iStation ) {
187 numMatchesDT[iStation] = 0;
188 numMatchesCSC[iStation] = 0;
189 numMatchesRPC[iStation] = 0;
190 numHitsDT[iStation] = 0;
191 numHitsCSC[iStation] = 0;
192 numHitsRPC[iStation] = 0;
194 int numSTAMuons=0, numRPCMuons=0;
195 if ( verbosity_ && !muonsToCheck.empty() )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"Muons to check (" << muonsToCheck.size() <<
"):";
197 for (
const auto &
mu: muonsToCheck) {
198 if (
mu->isStandAloneMuon() ) numSTAMuons++;
199 if (
mu->muonID(
"RPCMuLoose") ) numRPCMuons++;
201 int numStationsWithMatches = 0;
202 for (
int iStation = 0; iStation < 4; ++iStation ) {
203 if ( numMatchesDT[iStation] > 0 && !maskMatchesDT_[iStation] ) ++numStationsWithMatches;
204 if ( numMatchesCSC[iStation] > 0 && !maskMatchesCSC_[iStation] ) ++numStationsWithMatches;
205 if ( numMatchesRPC[iStation] > 0 && !maskMatchesRPC_[iStation] ) ++numStationsWithMatches;
208 int numLast2StationsWithHits = 0;
209 for (
int iStation = 2; iStation < 4; ++iStation ) {
210 if ( numHitsDT[iStation] > 0 && !maskHitsDT_[iStation] ) ++numLast2StationsWithHits;
211 if ( numHitsCSC[iStation] > 0 && !maskHitsCSC_[iStation] ) ++numLast2StationsWithHits;
212 if ( numHitsRPC[iStation] > 0 && !maskHitsRPC_[iStation] ) ++numLast2StationsWithHits;
216 <<
"\t" << iMu <<
": Pt = " <<
mu->pt() <<
", eta = " <<
mu->eta() <<
", phi = " <<
mu->phi()
218 <<
" isSTA: "<<
mu->isStandAloneMuon()
219 <<
", isRPCLoose: "<<
mu->muonID(
"RPCMuLoose")
220 <<
"\n\t numMatchesDT = " <<
format_vint(numMatchesDT)
221 <<
"\n\t numMatchesCSC = " <<
format_vint(numMatchesCSC)
222 <<
"\n\t numMatchesRPC = " <<
format_vint(numMatchesRPC)
223 <<
"\n\t --> numStationsWithMatches = " << numStationsWithMatches
227 <<
"\n\t --> numLast2StationsWithHits = " << numLast2StationsWithHits ;
228 if ( maxNumberOfMatches_ >= 0 && numStationsWithMatches > maxNumberOfMatches_ ) {
232 if ( maxNumberOfHitsLast2Stations_ >= 0 && numLast2StationsWithHits > maxNumberOfHitsLast2Stations_ ) {
236 if ( maxNumberOfSTAMuons_ >= 0 && numSTAMuons > maxNumberOfSTAMuons_ ) {
240 if ( maxNumberOfRPCMuons_ >= 0 && numRPCMuons > maxNumberOfRPCMuons_ ) {
247 double discriminatorValue = pass ? 1.: 0.;
248 if ( verbosity_ )
edm::LogPrint(
"PFTauAgainstMuonSimple") <<
"--> returning discriminatorValue = " << discriminatorValue ;
250 return discriminatorValue;
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
int pdgId() const override
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T const * get() const
Returns C++ pointer to the item.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void countMatches(const reco::Muon &muon, std::vector< int > &numMatchesDT, std::vector< int > &numMatchesCSC, std::vector< int > &numMatchesRPC)
key_type key() const
Accessor for product key.
#define DEFINE_FWK_MODULE(type)
virtual void beginEvent(const edm::Event &, const edm::EventSetup &)
double p() const override
magnitude of momentum vector
bool isNonnull() const
Checks for non-null.
virtual double discriminate(const TauRef &tau) const =0
ProductID id() const
Accessor for product ID.
float rawCaloFraction() const
std::string format_vint(const std::vector< int > &vi)
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)