Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Validation_MuonGEMRecHits_GEMRecHitMatcher_h
0002 #define Validation_MuonGEMRecHits_GEMRecHitMatcher_h
0003 
0004 /**\class GEMRecHitMatcher
0005 
0006  Description: Matching of RecHits for SimTrack in GEM
0007 
0008  Original Author    : "Vadim Khotilovich"
0009  Contibuting Author : "Claudio Caputo"
0010 
0011 */
0012 
0013 #include "FWCore/Utilities/interface/InputTag.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/Framework/interface/ConsumesCollector.h"
0018 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0019 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0020 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0021 #include "Validation/MuonGEMDigis/interface/GEMDigiMatcher.h"
0022 
0023 #include <vector>
0024 #include <map>
0025 #include <set>
0026 
0027 typedef std::vector<GEMRecHit> GEMRecHitContainer;
0028 
0029 class GEMGeometry;
0030 class GEMRecHitMatcher {
0031 public:
0032   // constructor
0033   GEMRecHitMatcher(edm::ParameterSet const& iPS, edm::ConsumesCollector&& iC);
0034 
0035   // destructor
0036   ~GEMRecHitMatcher() {}
0037 
0038   // initialize the event
0039   void init(const edm::Event& e, const edm::EventSetup& eventSetup);
0040 
0041   // do the matching
0042   void match(const SimTrack& t, const SimVertex& v);
0043 
0044   // partition GEM detIds with rechits
0045   std::set<unsigned int> detIds() const;
0046 
0047   // chamber detIds with rechits
0048   std::set<unsigned int> chamberIds() const;
0049 
0050   // superchamber detIds with rechits
0051   std::set<unsigned int> superChamberIds() const;
0052 
0053   // GEM recHits from a particular partition, chamber or superchamber
0054   const GEMRecHitContainer& recHits() const { return recHits_; }
0055   const GEMRecHitContainer& recHitsInDetId(unsigned int) const;
0056   const GEMRecHitContainer& recHitsInChamber(unsigned int) const;
0057   const GEMRecHitContainer& recHitsInSuperChamber(unsigned int) const;
0058 
0059   // #layers with recHits from this simtrack
0060   int nLayersWithRecHitsInSuperChamber(unsigned int) const;
0061 
0062   /// How many recHits in GEM did this simtrack get in total?
0063   int nGEMRecHits() const;
0064 
0065   std::set<int> stripNumbersInDetId(unsigned int) const;
0066 
0067   // what unique partitions numbers with recHits from this simtrack?
0068   std::set<int> partitionNumbers() const;
0069 
0070   // verbose value
0071   bool verbose() const { return verbose_; }
0072 
0073   // global position of the rechit (based on the first strip hit)
0074   GlobalPoint recHitPosition(const GEMRecHit& rechit) const;
0075 
0076   // mean position of a rechit collection (all based on the first strip hit)
0077   GlobalPoint recHitMeanPosition(const GEMRecHitContainer& rechits) const;
0078 
0079   std::shared_ptr<GEMDigiMatcher> gemDigiMatcher() const { return gemDigiMatcher_; }
0080 
0081   bool recHitInContainer(const GEMRecHit& rh, const GEMRecHitContainer& c) const;
0082 
0083   bool isGEMRecHitMatched(const GEMRecHit& thisRh) const;
0084 
0085   bool areGEMRecHitSame(const GEMRecHit& l, const GEMRecHit& r) const;
0086 
0087 private:
0088   void matchRecHitsToSimTrack(const GEMRecHitCollection& recHits);
0089 
0090   edm::EDGetTokenT<GEMRecHitCollection> gemRecHitToken_;
0091   edm::Handle<GEMRecHitCollection> gemRecHitH_;
0092 
0093   edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
0094   const GEMGeometry* gemGeometry_;
0095 
0096   int minBX_, maxBX_;
0097   bool verbose_;
0098 
0099   std::map<unsigned int, GEMRecHitContainer> detid_to_recHits_;
0100   std::map<unsigned int, GEMRecHitContainer> chamber_to_recHits_;
0101   std::map<unsigned int, GEMRecHitContainer> superchamber_to_recHits_;
0102 
0103   const GEMRecHitContainer no_recHits_;
0104   GEMRecHitContainer recHits_;
0105 
0106   std::shared_ptr<GEMDigiMatcher> gemDigiMatcher_;
0107 };
0108 
0109 #endif