42 <<
" Invalid Configuration parameter 'discriminatorOption' = " << discriminatorOption_string <<
" !!\n";
47 if ( cfg.
exists(
"srcMuons") ) {
54 typedef std::vector<int>
vint;
104 void countHits(
const reco::Muon&
muon, std::vector<int>& numHitsDT, std::vector<int>& numHitsCSC, std::vector<int>& numHitsRPC)
108 for (
int iHit = 0; iHit < muonHitPattern.
numberOfHits(); ++iHit ) {
110 if ( hit == 0 )
break;
113 if ( muonStation >= 0 && muonStation < 4 ) {
123 std::string format_vint(
const std::vector<int>& vi)
125 std::ostringstream os;
128 for (
unsigned iEntry = 0; iEntry <
numEntries; ++iEntry ) {
130 if ( iEntry < (numEntries - 1) ) os <<
", ";
136 void countMatches(
const reco::Muon& muon, std::vector<int>& numMatchesDT, std::vector<int>& numMatchesCSC, std::vector<int>& numMatchesRPC)
138 const std::vector<reco::MuonChamberMatch>& muonSegments = muon.
matches();
139 for ( std::vector<reco::MuonChamberMatch>::const_iterator muonSegment = muonSegments.begin();
140 muonSegment != muonSegments.end(); ++muonSegment ) {
141 if ( muonSegment->segmentMatches.empty() )
continue;
142 int muonDetector = muonSegment->detector();
143 int muonStation = muonSegment->station() - 1;
144 assert(muonStation >= 0 && muonStation <= 3);
155 edm::LogPrint(
"PFTauAgainstMuon2") <<
"<PFRecoTauDiscriminationAgainstMuon2::discriminate>:" ;
157 edm::LogPrint(
"PFTauAgainstMuon2") <<
"tau #" << pfTau.
key() <<
": Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi() ;
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;
180 countMatches(*muonRef, numMatchesDT, numMatchesCSC, numMatchesRPC);
181 countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
187 for (
size_t idxMuon = 0; idxMuon <
numMuons; ++idxMuon ) {
189 if (
verbosity_ )
edm::LogPrint(
"PFTauAgainstMuon2") <<
"muon #" << muon.
key() <<
": Pt = " << muon->pt() <<
", eta = " << muon->eta() <<
", phi = " << muon->phi() ;
194 if ( pfLeadChargedHadron.
isNonnull() && pfLeadChargedHadron->muonRef().
isNonnull() && muon == pfLeadChargedHadron->muonRef() ) {
198 double dR =
deltaR(muon->p4(), pfTau->p4());
202 if ( pfTau->jetRef().
isNonnull() ) jetArea = pfTau->jetRef()->jetArea();
203 if ( jetArea > 0. ) {
208 <<
"Jet associated to Tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi() <<
" has area = " << jetArea <<
" !!" ;
214 if ( dR < dRmatch ) {
216 countMatches(*muon, numMatchesDT, numMatchesCSC, numMatchesRPC);
217 countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
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;
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;
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 ;
247 bool passesCaloMuonVeto =
true;
249 double energyECALplusHCAL = pfLeadChargedHadron->ecalEnergy() + pfLeadChargedHadron->hcalEnergy();
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() ;
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;
263 double discriminatorValue = 0.;
272 discriminatorValue = pass ? 1.: 0.;
274 if (
verbosity_ )
edm::LogPrint(
"PFTauAgainstMuon2") <<
"--> returning discriminatorValue = " << discriminatorValue ;
276 return discriminatorValue;
double p() const
momentum vector magnitude
T getParameter(std::string const &) const
double discriminate(const reco::PFTauRef &) override
std::vector< int > maskMatchesDT_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static bool muonDTHitFilter(uint32_t pattern)
#define DEFINE_FWK_MODULE(type)
std::vector< int > maskHitsDT_
void beginEvent(const edm::Event &, const edm::EventSetup &) override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static uint32_t getHitType(uint32_t pattern)
static uint32_t getMuonStation(uint32_t pattern)
Muon station (1-4). Only valid for muon patterns, of course.
int maxNumberOfHitsLast2Stations_
static bool muonHitFilter(uint32_t pattern)
bool isNonnull() const
Checks for non-null.
std::vector< int > maskHitsCSC_
bool isNonnull() const
Checks for non-null.
std::vector< int > maskHitsRPC_
T const * get() const
Returns C++ pointer to the item.
bool dRmuonMatchLimitedToJetArea_
Long64_t numEntries(TFile *hdl, std::string const &trname)
~PFRecoTauDiscriminationAgainstMuon2()
std::vector< int > maskMatchesCSC_
static bool muonRPCHitFilter(uint32_t pattern)
edm::Handle< reco::MuonCollection > muons_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
double deltaR(double eta1, double eta2, double phi1, double phi2)
key_type key() const
Accessor for product key.
std::vector< MuonChamberMatch > & matches()
get muon matching information
std::vector< int > maskMatchesRPC_
static bool muonCSCHitFilter(uint32_t pattern)
uint32_t getHitPattern(int position) const
PFRecoTauDiscriminationAgainstMuon2(const edm::ParameterSet &cfg)
edm::EDGetTokenT< reco::MuonCollection > Muons_token