Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-16 06:12:37

0001 #ifndef MuonReco_MuonSelectors_h
0002 #define MuonReco_MuonSelectors_h
0003 //
0004 // Package:    MuonReco
0005 //
0006 //
0007 // Original Author:  Jake Ribnik, Dmytro Kovalskyi
0008 
0009 #include "DataFormats/MuonReco/interface/Muon.h"
0010 #include <string>
0011 
0012 namespace reco {
0013   class Vertex;
0014 }
0015 
0016 namespace muon {
0017   /// Selector type
0018   enum SelectionType {
0019     All = 0,                                // dummy options - always true
0020     AllGlobalMuons = 1,                     // checks isGlobalMuon flag
0021     AllStandAloneMuons = 2,                 // checks isStandAloneMuon flag
0022     AllTrackerMuons = 3,                    // checks isTrackerMuon flag
0023     TrackerMuonArbitrated = 4,              // resolve ambiguity of sharing segments
0024     AllArbitrated = 5,                      // all muons with the tracker muon arbitrated
0025     GlobalMuonPromptTight = 6,              // global muons with tighter fit requirements
0026     TMLastStationLoose = 7,                 // penetration depth loose selector
0027     TMLastStationTight = 8,                 // penetration depth tight selector
0028     TM2DCompatibilityLoose = 9,             // likelihood based loose selector
0029     TM2DCompatibilityTight = 10,            // likelihood based tight selector
0030     TMOneStationLoose = 11,                 // require one well matched segment
0031     TMOneStationTight = 12,                 // require one well matched segment
0032     TMLastStationOptimizedLowPtLoose = 13,  // combination of TMLastStation and TMOneStation
0033     TMLastStationOptimizedLowPtTight = 14,  // combination of TMLastStation and TMOneStation
0034     GMTkChiCompatibility = 15,              // require tk stub have good chi2 relative to glb track
0035     GMStaChiCompatibility = 16,             // require sta stub have good chi2 compatibility relative to glb track
0036     GMTkKinkTight = 17,                     // require a small kink value in the tracker stub
0037     TMLastStationAngLoose = 18,             // TMLastStationLoose with additional angular cuts
0038     TMLastStationAngTight = 19,             // TMLastStationTight with additional angular cuts
0039     TMOneStationAngLoose = 20,              // TMOneStationLoose with additional angular cuts
0040     TMOneStationAngTight = 21,              // TMOneStationTight with additional angular cuts
0041     // The two algorithms that follow are identical to what were known as
0042     // TMLastStationOptimizedLowPt* (sans the Barrel) as late as revision
0043     // 1.7 of this file. The names were changed because indeed the low pt
0044     // optimization applies only to the barrel region, whereas the sel-
0045     // ectors above are more efficient at low pt in the endcaps, which is
0046     // what we feel is more suggestive of the algorithm name. This will be
0047     // less confusing for future generations of CMS members, I hope...
0048     // combination of TMLastStation and TMOneStation but with low pT optimization in barrel only
0049     TMLastStationOptimizedBarrelLowPtLoose = 22,
0050     // combination of TMLastStation and TMOneStation but with low pT optimization in barrel only
0051     TMLastStationOptimizedBarrelLowPtTight = 23,
0052     RPCMuLoose = 24,  // checks isRPCMuon flag (require two well matched hits in different RPC layers)
0053     AllME0Muons = 25,
0054     ME0MuonArbitrated = 26,
0055     AllGEMMuons = 27,
0056     GEMMuonArbitrated = 28,
0057     TriggerIdLoose = 29
0058   };
0059 
0060   /// a lightweight "map" for selection type string label and enum value
0061   struct SelectionTypeStringToEnum {
0062     const char* label;
0063     SelectionType value;
0064   };
0065 
0066   static const SelectionTypeStringToEnum selectionTypeStringToEnumMap[] = {
0067       {"All", All},
0068       {"AllGlobalMuons", AllGlobalMuons},
0069       {"AllStandAloneMuons", AllStandAloneMuons},
0070       {"AllTrackerMuons", AllTrackerMuons},
0071       {"TrackerMuonArbitrated", TrackerMuonArbitrated},
0072       {"AllArbitrated", AllArbitrated},
0073       {"GlobalMuonPromptTight", GlobalMuonPromptTight},
0074       {"TMLastStationLoose", TMLastStationLoose},
0075       {"TMLastStationTight", TMLastStationTight},
0076       {"TM2DCompatibilityLoose", TM2DCompatibilityLoose},
0077       {"TM2DCompatibilityTight", TM2DCompatibilityTight},
0078       {"TMOneStationLoose", TMOneStationLoose},
0079       {"TMOneStationTight", TMOneStationTight},
0080       {"TMLastStationOptimizedLowPtLoose", TMLastStationOptimizedLowPtLoose},
0081       {"TMLastStationOptimizedLowPtTight", TMLastStationOptimizedLowPtTight},
0082       {"GMTkChiCompatibility", GMTkChiCompatibility},
0083       {"GMStaChiCompatibility", GMStaChiCompatibility},
0084       {"GMTkKinkTight", GMTkKinkTight},
0085       {"TMLastStationAngLoose", TMLastStationAngLoose},
0086       {"TMLastStationAngTight", TMLastStationAngTight},
0087       {"TMOneStationAngLoose", TMOneStationAngLoose},
0088       {"TMOneStationAngTight", TMOneStationAngTight},
0089       {"TMLastStationOptimizedBarrelLowPtLoose", TMLastStationOptimizedBarrelLowPtLoose},
0090       {"TMLastStationOptimizedBarrelLowPtTight", TMLastStationOptimizedBarrelLowPtTight},
0091       {"RPCMuLoose", RPCMuLoose},
0092       {"AllME0Muons", AllME0Muons},
0093       {"ME0MuonArbitrated", ME0MuonArbitrated},
0094       {"AllGEMMuons", AllGEMMuons},
0095       {"GEMMuonArbitrated", GEMMuonArbitrated},
0096       {"TriggerIdLoose", TriggerIdLoose},
0097       {nullptr, (SelectionType)-1}};
0098 
0099   SelectionType selectionTypeFromString(const std::string& label);
0100 
0101   // a map for string label to reco::Muon::Selector enum
0102   struct SelectorStringToEnum {
0103     const char* label;
0104     reco::Muon::Selector value;
0105   };
0106 
0107   static const SelectorStringToEnum selectorStringToEnumMap[] = {
0108       {"CutBasedIdLoose", reco::Muon::CutBasedIdLoose},
0109       {"CutBasedIdMedium", reco::Muon::CutBasedIdMedium},
0110       {"CutBasedIdMediumPrompt", reco::Muon::CutBasedIdMediumPrompt},
0111       {"CutBasedIdTight", reco::Muon::CutBasedIdTight},
0112       {"CutBasedIdGlobalHighPt", reco::Muon::CutBasedIdGlobalHighPt},
0113       {"CutBasedIdTrkHighPt", reco::Muon::CutBasedIdTrkHighPt},
0114       {"PFIsoVeryLoose", reco::Muon::PFIsoVeryLoose},
0115       {"PFIsoLoose", reco::Muon::PFIsoLoose},
0116       {"PFIsoMedium", reco::Muon::PFIsoMedium},
0117       {"PFIsoTight", reco::Muon::PFIsoTight},
0118       {"PFIsoVeryTight", reco::Muon::PFIsoVeryTight},
0119       {"TkIsoLoose", reco::Muon::TkIsoLoose},
0120       {"TkIsoTight", reco::Muon::TkIsoTight},
0121       {"SoftCutBasedId", reco::Muon::SoftCutBasedId},
0122       {"SoftMvaId", reco::Muon::SoftMvaId},
0123       {"MvaLoose", reco::Muon::MvaLoose},
0124       {"MvaMedium", reco::Muon::MvaMedium},
0125       {"MvaTight", reco::Muon::MvaTight},
0126       {"MiniIsoLoose", reco::Muon::MiniIsoLoose},
0127       {"MiniIsoMedium", reco::Muon::MiniIsoMedium},
0128       {"MiniIsoTight", reco::Muon::MiniIsoTight},
0129       {"MiniIsoVeryTight", reco::Muon::MiniIsoVeryTight},
0130       {"TriggerIdLoose", reco::Muon::TriggerIdLoose},
0131       {"InTimeMuon", reco::Muon::InTimeMuon},
0132       {"PFIsoVeryVeryTight", reco::Muon::PFIsoVeryVeryTight},
0133       {"MultiIsoLoose", reco::Muon::MultiIsoLoose},
0134       {"MultiIsoMedium", reco::Muon::MultiIsoMedium},
0135       {"PuppiIsoLoose", reco::Muon::PuppiIsoLoose},
0136       {"PuppiIsoMedium", reco::Muon::PuppiIsoMedium},
0137       {"PuppiIsoTight", reco::Muon::PuppiIsoTight},
0138       {"MvaVTight", reco::Muon::MvaVTight},
0139       {"MvaVVTight", reco::Muon::MvaVVTight},
0140       {"LowPtMvaLoose", reco::Muon::LowPtMvaLoose},
0141       {"LowPtMvaMedium", reco::Muon::LowPtMvaMedium},
0142       {"MvaIDwpMedium", reco::Muon::MvaIDwpMedium},
0143       {"MvaIDwpTight", reco::Muon::MvaIDwpTight},
0144       {nullptr, (reco::Muon::Selector)-1}};
0145 
0146   reco::Muon::Selector selectorFromString(const std::string& label);
0147 
0148   /// main GoodMuon wrapper call
0149   bool isGoodMuon(const reco::Muon& muon,
0150                   SelectionType type,
0151                   reco::Muon::ArbitrationType arbitrationType = reco::Muon::SegmentAndTrackArbitration);
0152 
0153   // ===========================================================================
0154   //                               Support functions
0155   //
0156   enum AlgorithmType { TMLastStation, TM2DCompatibility, TMOneStation, RPCMu, ME0Mu, GEMMu };
0157 
0158   // specialized GoodMuon functions called from main wrapper
0159   bool isGoodMuon(const reco::Muon& muon,
0160                   AlgorithmType type,
0161                   double minCompatibility,
0162                   reco::Muon::ArbitrationType arbitrationType);
0163 
0164   bool isGoodMuon(const reco::Muon& muon,
0165                   AlgorithmType type,
0166                   int minNumberOfMatches,
0167                   double maxAbsDx,
0168                   double maxAbsPullX,
0169                   double maxAbsDy,
0170                   double maxAbsPullY,
0171                   double maxChamberDist,
0172                   double maxChamberDistPull,
0173                   reco::Muon::ArbitrationType arbitrationType,
0174                   bool syncMinNMatchesNRequiredStationsInBarrelOnly = true,  //this is what we had originally
0175                   bool applyAlsoAngularCuts = false);
0176 
0177   bool isTightMuon(const reco::Muon&, const reco::Vertex&);
0178   bool isLooseMuon(const reco::Muon&);
0179   bool isMediumMuon(const reco::Muon&, bool run2016_hip_mitigation = false);
0180   bool isSoftMuon(const reco::Muon&, const reco::Vertex&, bool run2016_hip_mitigation = false);
0181   bool isHighPtMuon(const reco::Muon&, const reco::Vertex&);
0182   bool isTrackerHighPtMuon(const reco::Muon&, const reco::Vertex&);
0183   bool isLooseTriggerMuon(const reco::Muon&);
0184 
0185   // determine if station was crossed well withing active volume
0186   unsigned int RequiredStationMask(const reco::Muon& muon,
0187                                    double maxChamberDist,
0188                                    double maxChamberDistPull,
0189                                    reco::Muon::ArbitrationType arbitrationType);
0190 
0191   // ------------ method to return the calo compatibility for a track with matched muon info  ------------
0192   float caloCompatibility(const reco::Muon& muon);
0193 
0194   // ------------ method to calculate the segment compatibility for a track with matched muon info  ------------
0195   float segmentCompatibility(const reco::Muon& muon,
0196                              reco::Muon::ArbitrationType arbitrationType = reco::Muon::SegmentAndTrackArbitration);
0197 
0198   // Check if two muon trajectory overlap
0199   // The overlap is performed by comparing distance between two muon
0200   // trajectories if they cross the same muon chamber. Trajectories
0201   // overlap if distance/uncertainty is smaller than allowed pullX
0202   // and pullY
0203   bool overlap(const reco::Muon& muon1,
0204                const reco::Muon& muon2,
0205                double pullX = 1.0,
0206                double pullY = 1.0,
0207                bool checkAdjacentChambers = false);
0208 
0209   /// Determine the number of shared segments between two muons.
0210   /// Comparison is done using the segment references in the reco::Muon object.
0211   int sharedSegments(const reco::Muon& muon1,
0212                      const reco::Muon& muon2,
0213                      unsigned int segmentArbitrationMask = reco::MuonSegmentMatch::BestInChamberByDR);
0214 
0215   reco::Muon::Selector makeSelectorBitset(reco::Muon const& muon,
0216                                           reco::Vertex const* vertex = nullptr,
0217                                           bool run2016_hip_mitigation = false);
0218 }  // namespace muon
0219 #endif