Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:59

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(const MuonRecHitContainer& muonRecHits) const;
0112   TransientTrackingRecHit::ConstRecHitContainer findThetaCluster(const 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 MagTransform {
0120     MagTransform(const GlobalPoint& point) : thePoint(point) {}
0121     double operator()(const GlobalPoint& p) const { return (p - thePoint).mag(); }
0122     double operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& hit) const {
0123       return (hit->globalPosition() - thePoint).mag();
0124     }
0125     GlobalPoint thePoint;
0126   };
0127 
0128   struct LessMag {
0129     LessMag(const GlobalPoint& point) : thePoint(point) {}
0130     bool operator()(const GlobalPoint& lhs, const GlobalPoint& rhs) const {
0131       return (lhs - thePoint).mag() < (rhs - thePoint).mag();
0132     }
0133     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0134                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0135       return (lhs->globalPosition() - thePoint).mag() < (rhs->globalPosition() - thePoint).mag();
0136     }
0137     GlobalPoint thePoint;
0138   };
0139 
0140   struct AbsDThetaTransform {
0141     AbsDThetaTransform(const GlobalPoint& point) : thePoint(point) {}
0142     double operator()(const TransientTrackingRecHit::ConstRecHitPointer& hit) const {
0143       return std::fabs(hit->globalPosition().bareTheta() - thePoint.bareTheta());
0144     }
0145     GlobalPoint thePoint;
0146   };
0147 
0148   struct AbsLessDTheta {
0149     AbsLessDTheta(const GlobalPoint& point) : thePoint(point) {}
0150     bool operator()(const TransientTrackingRecHit::ConstRecHitPointer& lhs,
0151                     const TransientTrackingRecHit::ConstRecHitPointer& rhs) const {
0152       return (fabs(lhs->globalPosition().bareTheta() - thePoint.bareTheta()) <
0153               fabs(rhs->globalPosition().bareTheta() - thePoint.bareTheta()));
0154     }
0155     GlobalPoint thePoint;
0156   };
0157 
0158   struct PhiTransform {
0159     double operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& hit) const {
0160       return hit->globalPosition().barePhi();
0161     }
0162   };
0163 
0164   struct LessPhi {
0165     LessPhi() : thePoint(0, 0, 0) {}
0166     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0167                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0168       return (lhs->globalPosition().barePhi() < rhs->globalPosition().barePhi());
0169     }
0170     GlobalPoint thePoint;
0171   };
0172 
0173   struct PerpTransform {
0174     double operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& hit) const {
0175       return hit->globalPosition().perp();
0176     }
0177   };
0178 
0179   struct LessPerp {
0180     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0181                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0182       return (lhs->globalPosition().perp() < rhs->globalPosition().perp());
0183     }
0184   };
0185 
0186   struct AbsMagTransform {
0187     double operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& hit) const {
0188       return hit->globalPosition().mag();
0189     }
0190   };
0191 
0192   struct LessAbsMag {
0193     bool operator()(const MuonTransientTrackingRecHit::MuonRecHitPointer& lhs,
0194                     const MuonTransientTrackingRecHit::MuonRecHitPointer& rhs) const {
0195       return (lhs->globalPosition().mag() < rhs->globalPosition().mag());
0196     }
0197   };
0198 
0199   std::string category_;
0200 
0201   unsigned long long theCacheId_TRH;
0202   unsigned long long theCacheId_MT;
0203 
0204   edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
0205   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTrackerRecHitBuilderToken;
0206 
0207   edm::ESHandle<TransientTrackingRecHitBuilder> theMuonRecHitBuilder;
0208   edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuilderToken;
0209 
0210   edm::InputTag theDTRecHitLabel;
0211   edm::InputTag theCSCRecHitLabel;
0212   edm::InputTag theCSCSegmentsLabel;
0213   edm::InputTag theDT4DRecSegmentLabel;
0214 
0215   edm::Handle<DTRecHitCollection> theDTRecHits;
0216   edm::Handle<CSCRecHit2DCollection> theCSCRecHits;
0217   edm::Handle<CSCSegmentCollection> theCSCSegments;
0218   edm::Handle<DTRecSegment4DCollection> theDT4DRecSegments;
0219 
0220   edm::EDGetTokenT<DTRecHitCollection> theDTRecHitToken;
0221   edm::EDGetTokenT<CSCRecHit2DCollection> theCSCRecHitToken;
0222   edm::EDGetTokenT<CSCSegmentCollection> theCSCSegmentsToken;
0223   edm::EDGetTokenT<DTRecSegment4DCollection> theDT4DRecSegmentToken;
0224 
0225   // geometry
0226   edm::ESHandle<GeometricSearchTracker> theTracker;
0227   edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
0228   edm::ESHandle<MagneticField> theField;
0229   edm::ESHandle<CSCGeometry> theCSCGeometry;
0230   edm::ESHandle<DTGeometry> theDTGeometry;
0231 
0232   edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> theTrackerToken;
0233   edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> theTrackingGeometryToken;
0234   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0235   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> theCSCGeometryToken;
0236   edm::ESGetToken<DTGeometry, MuonGeometryRecord> theDTGeometryToken;
0237 };
0238 #endif