-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard muon selectors #20612
Standard muon selectors #20612
Changes from 15 commits
b9c86bc
e317148
4886664
8bf0616
ec7e863
1832ba3
ba73ec9
0c5ab4a
dd8206b
04cfab4
ba190d9
e8d20f7
bf7f6b5
738fd09
42f4170
718dc74
9dd45cf
8689825
7fbd779
a26e056
a8dcb6f
59ad7ca
57e47ad
30998ea
f5af074
9cfcfb7
7902379
75d3480
f4cb782
9cc9137
79958f0
0dce48d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,43 @@ namespace reco { | |
enum ArbitrationType { NoArbitration, SegmentArbitration, SegmentAndTrackArbitration, SegmentAndTrackArbitrationCleaned, | ||
RPCHitAndTrackArbitration, GEMSegmentAndTrackArbitration, ME0SegmentAndTrackArbitration }; | ||
|
||
/// | ||
/// ====================== STANDARD SELECTORS =========================== | ||
/// | ||
enum Selector { | ||
CutBasedIdLoose = 1UL<< 0, | ||
CutBasedIdMedium = 1UL<< 1, | ||
CutBasedIdMediumPrompt = 1UL<< 2, // IP cuts | ||
CutBasedIdTight = 1UL<< 3, | ||
CutBasedIdHighPt = 1UL<< 4, | ||
PFIsoVeryLoose = 1UL<< 5, // reliso<0.40 | ||
PFIsoLoose = 1UL<< 6, // reliso<0.25 | ||
PFIsoMedium = 1UL<< 7, // reliso<0.20 | ||
PFIsoTight = 1UL<< 8, // reliso<0.15 | ||
PFIsoVeryTight = 1UL<< 9, // reliso<0.10 | ||
TkIsoLoose = 1UL<<10, // reliso<0.10 | ||
TkIsoTight = 1UL<<11, // reliso<0.05 | ||
SoftCutBasedId = 1UL<<12, | ||
SoftMvaId = 1UL<<13, | ||
MvaLoose = 1UL<<14, | ||
MvaMedium = 1UL<<15, | ||
MvaTight = 1UL<<16, | ||
MiniIsoLoose = 1UL<<17, // reliso<0.40 | ||
MiniIsoMedium = 1UL<<18, // reliso<0.20 | ||
MiniIsoTight = 1UL<<19, // reliso<0.10 | ||
MiniIsoVeryTight = 1UL<<20 // reliso<0.05 | ||
}; | ||
|
||
bool passed( unsigned int selection ) const { return (selectors_ & selection)==selection; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enums are known in ROOT as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the choice of type is intentional to be able to do passed(TkIsoLoose|CutBasedIdHighPt), which would check that all flags are set. That's the most typical use case and it's a bit ugly and error prone to do it by hand on the bitmap itself. |
||
unsigned int getSelectionMask() const { return selectors_; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are no accessors starting with "get" in this class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, there is some naming inconsistency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
void setSelectionMask( unsigned int mask ){ selectors_ = mask; } | ||
void setSelector(Selector selector, bool passed){ | ||
if (passed) | ||
selectors_ |= selector; | ||
else | ||
selectors_ &= ~selector; | ||
} | ||
|
||
/// | ||
/// ====================== USEFUL METHODs =========================== | ||
/// | ||
|
@@ -288,7 +325,8 @@ namespace reco { | |
/// get pointers to best segment and corresponding chamber in vector of chambers | ||
std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> pair( const std::vector<const MuonChamberMatch*> &, | ||
ArbitrationType type = SegmentAndTrackArbitration ) const; | ||
|
||
/// selector bitmap | ||
unsigned int selectors_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it safe to commit to 32 bits now, considering that 22 are already taken? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 32 is good enough. We need to resist a temptation to introduce any minor modification as a separate selector. If that's done I don't think we will reach the limit any time soon. In other words it's good to have some limits to avoid id proliferation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, OK. |
||
public: | ||
/// get number of segments | ||
int numberOfSegments( int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration ) const; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -929,3 +929,46 @@ int muon::sharedSegments( const reco::Muon& mu, const reco::Muon& mu2, unsigned | |
|
||
return ret; | ||
} | ||
|
||
void muon::setCutBasedSelectorFlags(reco::Muon& muon, | ||
const reco::Vertex* vertex) | ||
{ | ||
// https://twiki.cern.ch/twiki/bin/viewauth/CMS/SWGuideMuonIdRun2 | ||
unsigned int selection = muon.getSelectionMask(); | ||
// Compute Id and Isolation variables | ||
double chIso = muon.pfIsolationR04().sumChargedHadronPt; | ||
double nIso = muon.pfIsolationR04().sumNeutralHadronEt; | ||
double phoIso = muon.pfIsolationR04().sumPhotonEt; | ||
double puIso = muon.pfIsolationR04().sumPUPt; | ||
double dbCorrectedIsolation = chIso + std::max( nIso + phoIso - .5*puIso, 0. ) ; | ||
double dbCorectedRelIso = dbCorrectedIsolation/muon.pt(); | ||
double tkRelIso = muon.isolationR03().sumPt/muon.pt(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all original values are floats. Is there a need to go to double precision here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any harm? Impressed that you have noticed that, but I don't see any compiler warnings. These variables are used in calculations and it's better to use double precision for any calculations, so sooner or later translation from float to double will happen. See no reason to change that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the harm is in more CPU cycles. |
||
|
||
// Base selectors | ||
if (muon::isLooseMuon(muon)) selection |= reco::Muon::CutBasedIdLoose; | ||
if (vertex){ | ||
if (muon::isTightMuon(muon,*vertex)) selection |= reco::Muon::CutBasedIdTight; | ||
if (muon::isSoftMuon(muon,*vertex)) selection |= reco::Muon::SoftCutBasedId; | ||
if (muon::isHighPtMuon(muon,*vertex)) selection |= reco::Muon::CutBasedIdHighPt; | ||
} | ||
if (muon::isMediumMuon(muon)){ | ||
selection |= reco::Muon::CutBasedIdMedium; | ||
if ( vertex and | ||
fabs(muon.muonBestTrack()->dz( vertex->position()))<0.1 and | ||
fabs(muon.muonBestTrack()->dxy(vertex->position()))< 0.02 ) | ||
selection |= reco::Muon::CutBasedIdMediumPrompt; | ||
} | ||
|
||
// PF isolation | ||
if (dbCorectedRelIso<0.40) selection |= reco::Muon::PFIsoVeryLoose; | ||
if (dbCorectedRelIso<0.25) selection |= reco::Muon::PFIsoLoose; | ||
if (dbCorectedRelIso<0.20) selection |= reco::Muon::PFIsoMedium; | ||
if (dbCorectedRelIso<0.15) selection |= reco::Muon::PFIsoTight; | ||
if (dbCorectedRelIso<0.10) selection |= reco::Muon::PFIsoVeryTight; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these magic constants (0.4, 0.25 etc) should be made consts of e.g. reco::Muon:: or in some other place and used consistently instead of entering values explicitly in multiple places and producers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are used in one place only and that place sets the flags. Where do you see them used beside that place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0.10 as a "Tight" appears multiple times in this PR, different variants of "Tight" though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0.10 doesn't mean tight, it's just a number that was selected for different isolations that happens to represent tight, i.e. not a magic number. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
|
||
// Tracker isolation | ||
if (tkRelIso<0.10) selection |= reco::Muon::TkIsoLoose; | ||
if (tkRelIso<0.05) selection |= reco::Muon::TkIsoTight; | ||
|
||
muon.setSelectionMask(selection); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef __RecoMuon_MuonIdentification_MuonMvaEstimator__ | ||
#define __RecoMuon_MuonIdentification_MuonMvaEstimator__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
#include "DataFormats/MuonReco/interface/Muon.h" | ||
#include "DataFormats/PatCandidates/interface/Muon.h" | ||
#include "DataFormats/BTauReco/interface/JetTag.h" | ||
#include "TMVA/Reader.h" | ||
|
||
namespace reco { | ||
class JetCorrector; | ||
} | ||
namespace pat { | ||
class MuonMvaEstimator{ | ||
public: | ||
MuonMvaEstimator(); | ||
void initialize(std::string weightsfile, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's called once in the PATMuonProducer::produce. It's a waste of time to change it. |
||
float dRmax); | ||
void computeMva(const pat::Muon& imuon, | ||
const reco::Vertex& vertex, | ||
const reco::JetTagCollection& bTags, | ||
const reco::JetCorrector* correctorL1=0, | ||
const reco::JetCorrector* correctorL1L2L3Res=0); | ||
float mva() const {return mva_;} | ||
float jetPtRatio() const {return jetPtRatio_;} | ||
float jetPtRel() const {return jetPtRel_;} | ||
private: | ||
TMVA::Reader tmvaReader_; | ||
bool initialized_; | ||
float mva_; | ||
float dRmax_; | ||
|
||
/// MVA VAriables | ||
Float_t pt_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MVA reader chocks if it's not Float_t. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like I was wrong (it chocked on double, not float). Float seems to be Ok, so I will change it to float. |
||
Float_t eta_; | ||
Float_t jetNDauCharged_; | ||
Float_t miniRelIsoCharged_; | ||
Float_t miniRelIsoNeutral_; | ||
Float_t jetPtRel_; | ||
Float_t jetPtRatio_; | ||
Float_t jetBTagCSV_; | ||
Float_t sip_; | ||
Float_t log_abs_dxyBS_; | ||
Float_t log_abs_dzPV_; | ||
Float_t segmentCompatibility_; | ||
}; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDSelector may be more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not ID. It's any selector including isolation.