Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:57

0001 #ifndef Validation_CSCRecHits_CSCRecHitMatcher_h
0002 #define Validation_CSCRecHits_CSCRecHitMatcher_h
0003 
0004 /**\class DigiMatcher
0005 
0006  Description: Matching of rechits and segments for SimTrack in CSC
0007 
0008  Author:  Sven Dildick
0009 */
0010 
0011 #include "FWCore/Framework/interface/ConsumesCollector.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/Framework/interface/ConsumesCollector.h"
0017 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0018 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0019 #include "Validation/MuonCSCDigis/interface/CSCDigiMatcher.h"
0020 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
0021 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0022 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0023 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0024 
0025 #include <vector>
0026 #include <map>
0027 #include <set>
0028 
0029 typedef std::vector<CSCRecHit2D> CSCRecHit2DContainer;
0030 typedef std::vector<CSCSegment> CSCSegmentContainer;
0031 
0032 class CSCRecHitMatcher {
0033 public:
0034   // constructor
0035   CSCRecHitMatcher(edm::ParameterSet const& iPS, edm::ConsumesCollector&& iC);
0036 
0037   // destructor
0038   ~CSCRecHitMatcher() {}
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   // layer detIds with CSCRecHit2D
0047   std::set<unsigned int> layerIdsCSCRecHit2D() const;
0048   // chamber detIds with CSCRecHit2D
0049   std::set<unsigned int> chamberIdsCSCRecHit2D() const;
0050   // chamber detIds with CSCSegment
0051   std::set<unsigned int> chamberIdsCSCSegment() const;
0052 
0053   //CSC rechits from a particular layer or chamber
0054   const CSCRecHit2DContainer& cscRecHit2DsInLayer(unsigned int) const;
0055   const CSCRecHit2DContainer& cscRecHit2DsInChamber(unsigned int) const;
0056   //CSC segments from a particular chamber
0057   const CSCSegmentContainer& cscSegmentsInChamber(unsigned int) const;
0058 
0059   const CSCSegmentContainer cscSegments() const;
0060   const CSCRecHit2DContainer cscRecHit2Ds() const;
0061 
0062   // check if a certain rechit appears in a container
0063   bool cscRecHit2DInContainer(const CSCRecHit2D&, const CSCRecHit2DContainer&) const;
0064   bool cscSegmentInContainer(const CSCSegment&, const CSCSegmentContainer&) const;
0065 
0066   // check if a certain rechit was matched to a simtrack
0067   bool isCSCRecHit2DMatched(const CSCRecHit2D&) const;
0068   bool isCSCSegmentMatched(const CSCSegment&) const;
0069 
0070   int nCSCRecHit2Ds() const;
0071   int nCSCSegments() const;
0072   bool areCSCSegmentsSame(const CSCSegment&, const CSCSegment&) const;
0073   bool areCSCRecHit2DsSame(const CSCRecHit2D&, const CSCRecHit2D&) const;
0074 
0075   int nCSCRecHit2DsInLayer(unsigned int) const;
0076   int nCSCRecHit2DsInChamber(unsigned int) const;
0077   int nCSCSegmentsInChamber(unsigned int) const;
0078 
0079   CSCSegment bestCSCSegment(unsigned int);
0080 
0081   GlobalPoint globalPoint(const CSCSegment&) const;
0082 
0083 private:
0084   std::unique_ptr<CSCDigiMatcher> cscDigiMatcher_;
0085 
0086   edm::EDGetTokenT<CSCRecHit2DCollection> cscRecHit2DToken_;
0087   edm::EDGetTokenT<CSCSegmentCollection> cscSegmentToken_;
0088 
0089   edm::Handle<CSCRecHit2DCollection> cscRecHit2DH_;
0090   edm::Handle<CSCSegmentCollection> cscSegmentH_;
0091 
0092   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
0093   const CSCGeometry* cscGeometry_;
0094 
0095   void matchCSCRecHit2DsToSimTrack(const CSCRecHit2DCollection&);
0096   void matchCSCSegmentsToSimTrack(const CSCSegmentCollection&);
0097 
0098   int verboseCSCRecHit2D_;
0099   int maxBXCSCRecHit2D_;
0100   int minBXCSCRecHit2D_;
0101 
0102   int verboseCSCSegment_;
0103   int maxBXCSCSegment_;
0104   int minBXCSCSegment_;
0105 
0106   std::map<unsigned int, CSCRecHit2DContainer> layer_to_cscRecHit2D_;
0107   std::map<unsigned int, CSCRecHit2DContainer> chamber_to_cscRecHit2D_;
0108   std::map<unsigned int, CSCSegmentContainer> chamber_to_cscSegment_;
0109 
0110   CSCRecHit2DContainer no_cscRecHit2Ds_;
0111   CSCSegmentContainer no_cscSegments_;
0112 };
0113 
0114 #endif