Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:47

0001 #ifndef Validation_MuonCSCDigis_CSCStubMatcher_h
0002 #define Validation_MuonCSCDigis_CSCStubMatcher_h
0003 
0004 /**\class CSCStubMatcher
0005 
0006    Description: Matching of CSC L1 trigger stubs to SimTrack
0007 
0008    Author: Sven Dildick (TAMU), Tao Huang (TAMU)
0009 */
0010 
0011 #include "Validation/MuonCSCDigis/interface/CSCDigiMatcher.h"
0012 #include "Validation/MuonGEMDigis/interface/GEMDigiMatcher.h"
0013 
0014 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0015 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
0016 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
0017 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0018 
0019 typedef std::vector<CSCALCTDigi> CSCALCTDigiContainer;
0020 typedef std::vector<CSCCLCTDigi> CSCCLCTDigiContainer;
0021 typedef std::vector<CSCCorrelatedLCTDigi> CSCCorrelatedLCTDigiContainer;
0022 
0023 class CSCStubMatcher {
0024 public:
0025   CSCStubMatcher(edm::ParameterSet const& iPS, edm::ConsumesCollector&& iC);
0026 
0027   ~CSCStubMatcher() {}
0028 
0029   /// initialize the event
0030   void init(const edm::Event& e, const edm::EventSetup& eventSetup);
0031 
0032   /// do the matching
0033   void match(const SimTrack& t, const SimVertex& v);
0034 
0035   /// crossed chamber detIds with not necessarily matching stubs
0036   std::set<unsigned int> chamberIdsAllCLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0037   std::set<unsigned int> chamberIdsAllALCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0038   std::set<unsigned int> chamberIdsAllLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0039   std::set<unsigned int> chamberIdsAllMPLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0040 
0041   /// chamber detIds with matching stubs
0042   std::set<unsigned int> chamberIdsCLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0043   std::set<unsigned int> chamberIdsALCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0044   std::set<unsigned int> chamberIdsLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0045   std::set<unsigned int> chamberIdsMPLCT(int csc_type = MuonHitHelper::CSC_ALL) const;
0046 
0047   /// all stubs (not necessarily matching) from a particular crossed chamber
0048   const CSCCLCTDigiContainer& allCLCTsInChamber(unsigned int) const;
0049   const CSCALCTDigiContainer& allALCTsInChamber(unsigned int) const;
0050   const CSCCorrelatedLCTDigiContainer& allLCTsInChamber(unsigned int) const;
0051   const CSCCorrelatedLCTDigiContainer& allMPLCTsInChamber(unsigned int) const;
0052 
0053   /// all matching from a particular crossed chamber
0054   const CSCCLCTDigiContainer& clctsInChamber(unsigned int) const;
0055   const CSCALCTDigiContainer& alctsInChamber(unsigned int) const;
0056   const CSCCorrelatedLCTDigiContainer& lctsInChamber(unsigned int) const;
0057   const CSCCorrelatedLCTDigiContainer& mplctsInChamber(unsigned int) const;
0058 
0059   /// all matching lcts
0060   std::map<unsigned int, CSCCLCTDigiContainer> clcts() const { return chamber_to_clcts_; }
0061   std::map<unsigned int, CSCALCTDigiContainer> alcts() const { return chamber_to_alcts_; }
0062   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> lcts() const { return chamber_to_lcts_; }
0063   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> mplcts() const { return chamber_to_mplcts_; }
0064 
0065   /// best matching from a particular crossed chamber
0066   CSCCLCTDigi bestClctInChamber(unsigned int) const;
0067   CSCALCTDigi bestAlctInChamber(unsigned int) const;
0068   CSCCorrelatedLCTDigi bestLctInChamber(unsigned int) const;
0069   CSCCorrelatedLCTDigi bestMplctInChamber(unsigned int) const;
0070 
0071   //z position of  certain layer
0072   float zpositionOfLayer(unsigned int detid, int layer) const;
0073 
0074   /// How many CSC chambers with matching stubs of some minimal quality did this SimTrack hit?
0075   int nChambersWithCLCT(int min_quality = 0) const;
0076   int nChambersWithALCT(int min_quality = 0) const;
0077   int nChambersWithLCT(int min_quality = 0) const;
0078   int nChambersWithMPLCT(int min_quality = 0) const;
0079 
0080   bool lctInChamber(const CSCDetId& id, const CSCCorrelatedLCTDigi& lct) const;
0081 
0082   // get the position of an LCT in global coordinates
0083   GlobalPoint getGlobalPosition(unsigned int rawId, const CSCCorrelatedLCTDigi& lct) const;
0084 
0085   std::shared_ptr<CSCDigiMatcher> cscDigiMatcher() { return cscDigiMatcher_; }
0086   std::shared_ptr<GEMDigiMatcher> gemDigiMatcher() { return gemDigiMatcher_; }
0087 
0088 private:
0089   void matchCLCTsToSimTrack(const CSCCLCTDigiCollection&);
0090   void matchALCTsToSimTrack(const CSCALCTDigiCollection&);
0091   void matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection&);
0092   void matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection&);
0093 
0094   void clear();
0095 
0096   void addGhostLCTs(const CSCCorrelatedLCTDigi& lct11,
0097                     const CSCCorrelatedLCTDigi& lct22,
0098                     CSCCorrelatedLCTDigiContainer& lctcontainer) const;
0099 
0100   edm::InputTag clctInputTag_;
0101   edm::InputTag alctInputTag_;
0102   edm::InputTag lctInputTag_;
0103   edm::InputTag mplctInputTag_;
0104 
0105   edm::EDGetTokenT<CSCCLCTDigiCollection> clctToken_;
0106   edm::EDGetTokenT<CSCALCTDigiCollection> alctToken_;
0107   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> lctToken_;
0108   edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> mplctToken_;
0109 
0110   edm::Handle<CSCCLCTDigiCollection> clctsH_;
0111   edm::Handle<CSCALCTDigiCollection> alctsH_;
0112   edm::Handle<CSCCorrelatedLCTDigiCollection> lctsH_;
0113   edm::Handle<CSCCorrelatedLCTDigiCollection> mplctsH_;
0114 
0115   std::shared_ptr<CSCDigiMatcher> cscDigiMatcher_;
0116   std::shared_ptr<GEMDigiMatcher> gemDigiMatcher_;
0117 
0118   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
0119   const CSCGeometry* cscGeometry_;
0120 
0121   // all stubs (not necessarily matching) in crossed chambers with digis
0122   std::map<unsigned int, CSCCLCTDigiContainer> chamber_to_clcts_all_;
0123   std::map<unsigned int, CSCALCTDigiContainer> chamber_to_alcts_all_;
0124   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> chamber_to_lcts_all_;
0125   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> chamber_to_mplcts_all_;
0126 
0127   // all matching stubs in crossed chambers with digis
0128   std::map<unsigned int, CSCCLCTDigiContainer> chamber_to_clcts_;
0129   std::map<unsigned int, CSCALCTDigiContainer> chamber_to_alcts_;
0130   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> chamber_to_lcts_;
0131   std::map<unsigned int, CSCCorrelatedLCTDigiContainer> chamber_to_mplcts_;
0132 
0133   template <class D>
0134   std::set<unsigned int> selectDetIds(D&, int) const;
0135 
0136   bool addGhostLCTs_;
0137   bool useGEMs_;
0138 
0139   bool matchTypeTightLCT_;
0140 
0141   int minNHitsChamber_;
0142   int minNHitsChamberALCT_;
0143   int minNHitsChamberCLCT_;
0144   int minNHitsChamberLCT_;
0145   int minNHitsChamberMPLCT_;
0146 
0147   bool verboseALCT_;
0148   bool verboseCLCT_;
0149   bool verboseLCT_;
0150   bool verboseMPLCT_;
0151 
0152   int minBXCLCT_, maxBXCLCT_;
0153   int minBXALCT_, maxBXALCT_;
0154   int minBXLCT_, maxBXLCT_;
0155   int minBXMPLCT_, maxBXMPLCT_;
0156 
0157   CSCCLCTDigiContainer no_clcts_;
0158   CSCALCTDigiContainer no_alcts_;
0159   CSCCorrelatedLCTDigiContainer no_lcts_;
0160   CSCCorrelatedLCTDigiContainer no_mplcts_;
0161 };
0162 
0163 template <class D>
0164 std::set<unsigned int> CSCStubMatcher::selectDetIds(D& digis, int csc_type) const {
0165   std::set<unsigned int> result;
0166   for (auto& p : digis) {
0167     auto id = p.first;
0168     if (csc_type > 0) {
0169       CSCDetId detId(id);
0170       if (MuonHitHelper::toCSCType(detId.station(), detId.ring()) != csc_type)
0171         continue;
0172     }
0173     result.insert(p.first);
0174   }
0175   return result;
0176 }
0177 
0178 #endif