Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-23 02:30:01

0001 /**
0002  *  \package: MuonIdentification
0003  *  \class: MuonShowerInformationFiller
0004  *
0005  *  Description: class for muon shower identification
0006  *
0007  *
0008  *  \author: A. Svyatkovskiy, Purdue University
0009  *
0010  **/
0011 
0012 #ifndef MuonIdentification_MuonShowerInformationFiller_h
0013 #define MuonIdentification_MuonShowerInformationFiller_h
0014 
0015 #include <vector>
0016 
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "DataFormats/Common/interface/ValueMap.h"
0019 
0020 #include "FWCore/Framework/interface/ESHandle.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "DataFormats/Math/interface/deltaPhi.h"
0024 #include "DataFormats/Math/interface/deltaR.h"
0025 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
0026 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
0027 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0028 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0029 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0030 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0031 #include "DataFormats/MuonReco/interface/Muon.h"
0032 #include "DataFormats/TrackReco/interface/Track.h"
0033 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0034 
0035 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0036 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0037 
0038 #include "DataFormats/MuonReco/interface/MuonShower.h"
0039 
0040 #include "FWCore/Framework/interface/ConsumesCollector.h"
0041 
0042 namespace edm {
0043   class ParameterSet;
0044   class Event;
0045   class EventSetup;
0046 }  // namespace edm
0047 namespace reco {
0048   class TransientTrack;
0049   struct MuonShower;
0050 }  // namespace reco
0051 
0052 class MuonServiceProxy;
0053 class Trajectory;
0054 class Cylinder;
0055 class Disk;
0056 class BarrelDetLayer;
0057 class ForwardDetLayer;
0058 class TransientTrackingRecHitBuilder;
0059 class GeometricSearchTracker;
0060 class GlobalTrackingGeometry;
0061 class MuonDetLayerGeometry;
0062 class TrackerRecoGeometryRecord;
0063 class GlobalTrackingGeometryRecord;
0064 class IdealMagneticFieldRecord;
0065 class MuonGeometryRecord;
0066 class TransientRecHitRecord;
0067 
0068 class MuonShowerInformationFiller {
0069 public:
0070   typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer;
0071   typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
0072   typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer;
0073 
0074 public:
0075   ///constructors
0076   MuonShowerInformationFiller(){};
0077   MuonShowerInformationFiller(const edm::ParameterSet&, edm::ConsumesCollector&);
0078 
0079   ///destructor
0080   virtual ~MuonShowerInformationFiller();
0081 
0082   /// fill muon shower variables
0083   reco::MuonShower fillShowerInformation(const reco::Muon& muon, const edm::Event&, const edm::EventSetup&);
0084 
0085   /// pass the Event to the algorithm at each event
0086   virtual void setEvent(const edm::Event&);
0087 
0088   /// set the services needed
0089   void setServices(const edm::EventSetup&);
0090 
0091   //set the data members
0092   void fillHitsByStation(const reco::Muon&);
0093 
0094 protected:
0095   const MuonServiceProxy* getService() const { return theService; }
0096 
0097 private:
0098   std::vector<float> theStationShowerDeltaR;
0099   std::vector<float> theStationShowerTSize;
0100   std::vector<int> theAllStationHits;
0101   std::vector<int> theCorrelatedStationHits;
0102 
0103   MuonServiceProxy* theService;
0104 
0105   GlobalPoint crossingPoint(const GlobalPoint&, const GlobalPoint&, const BarrelDetLayer*) const;
0106   GlobalPoint crossingPoint(const GlobalPoint&, const GlobalPoint&, const Cylinder&) const;
0107   GlobalPoint crossingPoint(const GlobalPoint&, const GlobalPoint&, const ForwardDetLayer*) const;
0108   GlobalPoint crossingPoint(const GlobalPoint&, const GlobalPoint&, const Disk&) const;
0109   std::vector<const GeomDet*> dtPositionToDets(const GlobalPoint&) const;
0110   std::vector<const GeomDet*> cscPositionToDets(const GlobalPoint&) const;
0111   MuonRecHitContainer findPerpCluster(MuonRecHitContainer& muonRecHits) const;
0112   TransientTrackingRecHit::ConstRecHitContainer findThetaCluster(TransientTrackingRecHit::ConstRecHitContainer&,
0113                                                                  const GlobalPoint&) const;
0114   TransientTrackingRecHit::ConstRecHitContainer hitsFromSegments(const GeomDet*,
0115                                                                  edm::Handle<DTRecSegment4DCollection>,
0116                                                                  edm::Handle<CSCSegmentCollection>) const;
0117   std::vector<const GeomDet*> getCompatibleDets(const reco::Track&) const;
0118 
0119   struct LessMag {
0120     LessMag(const GlobalPoint& point) : thePoint(point) {}
0121     bool operator()(const GlobalPoint& lhs, const GlobalPoint& rhs) const {
0122       return (lhs - thePoint).mag() < (rhs - thePoint).mag();
0123     }
0124     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0125                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0126       return (lhs->globalPosition() - thePoint).mag() < (rhs->globalPosition() - thePoint).mag();
0127     }
0128     GlobalPoint thePoint;
0129   };
0130 
0131   struct LessDPhi {
0132     LessDPhi(const GlobalPoint& point) : thePoint(point) {}
0133     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0134                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0135       return deltaPhi(lhs->globalPosition().barePhi(), thePoint.barePhi()) <
0136              deltaPhi(rhs->globalPosition().barePhi(), thePoint.barePhi());
0137     }
0138     GlobalPoint thePoint;
0139   };
0140 
0141   struct AbsLessDPhi {
0142     AbsLessDPhi(const GlobalPoint& point) : thePoint(point) {}
0143     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0144                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0145       return (fabs(deltaPhi(lhs->globalPosition().barePhi(), thePoint.barePhi())) <
0146               fabs(deltaPhi(rhs->globalPosition().barePhi(), thePoint.barePhi())));
0147     }
0148     GlobalPoint thePoint;
0149   };
0150 
0151   struct AbsLessDTheta {
0152     AbsLessDTheta(const GlobalPoint& point) : thePoint(point) {}
0153     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer& lhs,
0154                     const TransientTrackingRecHit::ConstRecHitPointer& rhs) const {
0155       return (fabs(lhs->globalPosition().bareTheta() - thePoint.bareTheta()) <
0156               fabs(rhs->globalPosition().bareTheta() - thePoint.bareTheta()));
0157     }
0158     GlobalPoint thePoint;
0159   };
0160 
0161   struct LessPhi {
0162     LessPhi() : thePoint(0, 0, 0) {}
0163     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0164                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0165       return (lhs->globalPosition().barePhi() < rhs->globalPosition().barePhi());
0166     }
0167     GlobalPoint thePoint;
0168   };
0169 
0170   struct LessPerp {
0171     LessPerp() : thePoint(0, 0, 0) {}
0172     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0173                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0174       return (lhs->globalPosition().perp() < rhs->globalPosition().perp());
0175     }
0176     GlobalPoint thePoint;
0177   };
0178 
0179   struct LessAbsMag {
0180     LessAbsMag() : thePoint(0, 0, 0) {}
0181     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0182                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0183       return (lhs->globalPosition().mag() < rhs->globalPosition().mag());
0184     }
0185     GlobalPoint thePoint;
0186   };
0187 
0188   std::string category_;
0189 
0190   unsigned long long theCacheId_TRH;
0191   unsigned long long theCacheId_MT;
0192 
0193   edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
0194   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTrackerRecHitBuilderToken;
0195 
0196   edm::ESHandle<TransientTrackingRecHitBuilder> theMuonRecHitBuilder;
0197   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuilderToken;
0198 
0199   edm::InputTag theDTRecHitLabel;
0200   edm::InputTag theCSCRecHitLabel;
0201   edm::InputTag theCSCSegmentsLabel;
0202   edm::InputTag theDT4DRecSegmentLabel;
0203 
0204   edm::Handle<DTRecHitCollection> theDTRecHits;
0205   edm::Handle<CSCRecHit2DCollection> theCSCRecHits;
0206   edm::Handle<CSCSegmentCollection> theCSCSegments;
0207   edm::Handle<DTRecSegment4DCollection> theDT4DRecSegments;
0208 
0209   edm::EDGetTokenT<DTRecHitCollection> theDTRecHitToken;
0210   edm::EDGetTokenT<CSCRecHit2DCollection> theCSCRecHitToken;
0211   edm::EDGetTokenT<CSCSegmentCollection> theCSCSegmentsToken;
0212   edm::EDGetTokenT<DTRecSegment4DCollection> theDT4DRecSegmentToken;
0213 
0214   // geometry
0215   edm::ESHandle<GeometricSearchTracker> theTracker;
0216   edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
0217   edm::ESHandle<MagneticField> theField;
0218   edm::ESHandle<CSCGeometry> theCSCGeometry;
0219   edm::ESHandle<DTGeometry> theDTGeometry;
0220 
0221   edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> theTrackerToken;
0222   edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> theTrackingGeometryToken;
0223   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0224   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> theCSCGeometryToken;
0225   edm::ESGetToken<DTGeometry, MuonGeometryRecord> theDTGeometryToken;
0226 };
0227 #endif