Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:18

0001 #ifndef Validation_MuonHits_MuonSimHitMatcher_h
0002 #define Validation_MuonHits_MuonSimHitMatcher_h
0003 
0004 /**\class MuonSimHitMatcher
0005 
0006    Description: Matching of muon SimHit to SimTrack
0007 
0008    Author: Sven Dildick (TAMU), Tao Huang (TAMU)
0009 */
0010 
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "DataFormats/Math/interface/deltaPhi.h"
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/Frameworkfwd.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/InputTag.h"
0020 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0021 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
0022 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0023 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0024 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0025 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0026 #include "Validation/MuonHits/interface/MuonHitHelper.h"
0027 
0028 #include <map>
0029 #include <set>
0030 #include <vector>
0031 
0032 class MuonSimHitMatcher {
0033 public:
0034   // constructor
0035   MuonSimHitMatcher(const edm::ParameterSet& iPS, edm::ConsumesCollector&& iC);
0036 
0037   // destructor
0038   ~MuonSimHitMatcher() {}
0039 
0040   // initialize the event
0041   void init(const edm::Event& e, const edm::EventSetup& eventSetup);
0042 
0043   // do the matching
0044   void match(const SimTrack& t, const SimVertex& v);
0045 
0046   // access to all the Muon SimHits (use MuonSubdetId::SubSystem)
0047   const edm::PSimHitContainer& simHits(int) const;
0048 
0049   // partitions' detIds with SimHits
0050   std::set<unsigned int> detIds(int type = 0) const;
0051 
0052   // chamber detIds with SimHits
0053   std::set<unsigned int> chamberIds(int type = 0) const;
0054 
0055   // simhits from a particular partition, chamber
0056   const edm::PSimHitContainer& hitsInDetId(unsigned int) const;
0057   const edm::PSimHitContainer& hitsInChamber(unsigned int) const;
0058 
0059   // calculate Global average position for a provided collection of simhits
0060   GlobalPoint simHitsMeanPosition(const edm::PSimHitContainer& sim_hits) const;
0061 
0062   // calculate Global average momentum for a provided collection of simhits in
0063   // CSC
0064   GlobalVector simHitsMeanMomentum(const edm::PSimHitContainer& sim_hits) const;
0065 
0066   // calculate the average position at the second station
0067   GlobalPoint simHitsMeanPositionStation(int n) const;
0068 
0069   const TrackingGeometry* geometry() { return geometry_; }
0070 
0071 protected:
0072   std::vector<unsigned int> getIdsOfSimTrackShower(unsigned trk_id,
0073                                                    const edm::SimTrackContainer& simTracks,
0074                                                    const edm::SimVertexContainer& simVertices);
0075 
0076   void clear();
0077 
0078   bool verboseSimTrack_;
0079   bool simMuOnly_;
0080   bool discardEleHits_;
0081   bool verbose_;
0082   bool hasGeometry_;
0083 
0084   const TrackingGeometry* geometry_;
0085 
0086   edm::EDGetTokenT<edm::SimVertexContainer> simVertexInput_;
0087   edm::EDGetTokenT<edm::SimTrackContainer> simTrackInput_;
0088   edm::EDGetTokenT<edm::PSimHitContainer> simHitInput_;
0089 
0090   edm::Handle<edm::SimTrackContainer> simTracksH_;
0091   edm::Handle<edm::SimVertexContainer> simVerticesH_;
0092   edm::Handle<edm::PSimHitContainer> simHitsH_;
0093 
0094   edm::SimTrackContainer simTracks_;
0095   edm::SimVertexContainer simVertices_;
0096   // input collection
0097   edm::PSimHitContainer simHits_;
0098 
0099   std::vector<unsigned> track_ids_;
0100   std::map<unsigned int, unsigned int> trkid_to_index_;
0101 
0102   edm::PSimHitContainer no_hits_;
0103 
0104   // selected hits
0105   edm::PSimHitContainer hits_;
0106   std::map<unsigned int, edm::PSimHitContainer> detid_to_hits_;
0107   std::map<unsigned int, edm::PSimHitContainer> chamber_to_hits_;
0108 
0109   edm::ParameterSet simHitPSet_;
0110 };
0111 
0112 #endif