Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef TrackAssociator_TrackDetectorAssociator_h
0002 #define TrackAssociator_TrackDetectorAssociator_h 1
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    TrackAssociator
0007 // Class:      TrackDetectorAssociator
0008 //
0009 /*
0010 
0011  Description: main class of tools to associate a track to calorimeter and muon detectors
0012 
0013 */
0014 //
0015 // Original Author:  Dmytro Kovalskyi
0016 //         Created:  Fri Apr 21 10:59:41 PDT 2006
0017 //
0018 //
0019 
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/interface/ESWatcher.h"
0023 
0024 #include "DataFormats/TrackReco/interface/TrackBase.h"
0025 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0026 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0027 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0028 #include "MagneticField/Engine/interface/MagneticField.h"
0029 
0030 #include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
0031 #include "TrackingTools/TrackAssociator/interface/TrackDetMatchInfo.h"
0032 #include "TrackingTools/TrackAssociator/interface/CachedTrajectory.h"
0033 #include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
0034 
0035 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0036 #include "DataFormats/TrackReco/interface/Track.h"
0037 #include "DataFormats/TrackingRecHit/interface/RecSegment.h"
0038 
0039 #include "SimDataFormats/Track/interface/SimTrack.h"
0040 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0041 
0042 #include "FWCore/Utilities/interface/Visibility.h"
0043 
0044 class TrackDetectorAssociator {
0045 public:
0046   explicit TrackDetectorAssociator();
0047   ~TrackDetectorAssociator();
0048 
0049   typedef TrackAssociatorParameters AssociatorParameters;
0050   enum Direction { Any, InsideOut, OutsideIn };
0051 
0052   /// propagate a track across the whole detector and
0053   /// find associated objects. Association is done in
0054   /// two modes
0055   ///  1) an object is associated to a track only if
0056   ///     crossed by track
0057   ///  2) an object is associated to a track if it is
0058   ///     withing an eta-phi cone of some radius with
0059   ///     respect to a track.
0060   ///     (the cone origin is at (0,0,0))
0061   /// Trajectory bending in eta-phi is taking into account
0062   /// when matching is performed
0063   ///
0064   /// associate using FreeTrajectoryState
0065   TrackDetMatchInfo associate(const edm::Event&,
0066                               const edm::EventSetup&,
0067                               const FreeTrajectoryState&,
0068                               const AssociatorParameters&);
0069   /// associate using inner and outer most states of a track
0070   /// in the silicon tracker.
0071   TrackDetMatchInfo associate(const edm::Event& iEvent,
0072                               const edm::EventSetup& iSetup,
0073                               const AssociatorParameters& parameters,
0074                               const FreeTrajectoryState* innerState,
0075                               const FreeTrajectoryState* outerState = nullptr);
0076   /// associate using reco::Track
0077   TrackDetMatchInfo associate(const edm::Event&,
0078                               const edm::EventSetup&,
0079                               const reco::Track&,
0080                               const AssociatorParameters&,
0081                               Direction direction = Any);
0082   /// associate using a simulated track
0083   TrackDetMatchInfo associate(
0084       const edm::Event&, const edm::EventSetup&, const SimTrack&, const SimVertex&, const AssociatorParameters&);
0085   /// associate using 3-momentum, vertex and charge
0086   TrackDetMatchInfo associate(const edm::Event&,
0087                               const edm::EventSetup&,
0088                               const GlobalVector&,
0089                               const GlobalPoint&,
0090                               const int,
0091                               const AssociatorParameters&);
0092   /// trajector information
0093   const CachedTrajectory& getCachedTrajector() const { return cachedTrajectory_; }
0094 
0095   /// use a user configured propagator
0096   void setPropagator(const Propagator*);
0097 
0098   /// use the default propagator
0099   void useDefaultPropagator();
0100 
0101   /// get FreeTrajectoryState from different track representations
0102   static FreeTrajectoryState getFreeTrajectoryState(const MagneticField*, const reco::Track&);
0103   static FreeTrajectoryState getFreeTrajectoryState(const MagneticField*, const SimTrack&, const SimVertex&);
0104   static FreeTrajectoryState getFreeTrajectoryState(const MagneticField*,
0105                                                     const GlobalVector&,
0106                                                     const GlobalPoint&,
0107                                                     const int);
0108 
0109   static bool crossedIP(const reco::Track& track);
0110 
0111 private:
0112   DetIdAssociator::MapRange getMapRange(const std::pair<float, float>& delta, const float dR) dso_internal;
0113 
0114   void fillEcal(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0115 
0116   void fillCaloTowers(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0117 
0118   void fillHcal(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0119 
0120   void fillHO(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0121 
0122   void fillPreshower(const edm::Event& iEvent, TrackDetMatchInfo& info, const AssociatorParameters&) dso_internal;
0123 
0124   void fillMuon(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0125 
0126   void fillCaloTruth(const edm::Event&, TrackDetMatchInfo&, const AssociatorParameters&) dso_internal;
0127 
0128   bool addTAMuonSegmentMatch(TAMuonChamberMatch&, const RecSegment*, const AssociatorParameters&) dso_internal;
0129 
0130   void getTAMuonChamberMatches(std::vector<TAMuonChamberMatch>& matches,
0131                                const AssociatorParameters& parameters,
0132                                std::set<DetId> occupancy) dso_internal;
0133 
0134   void init(const edm::EventSetup&, const AssociatorParameters&) dso_internal;
0135 
0136   math::XYZPoint getPoint(const GlobalPoint& point) dso_internal {
0137     return math::XYZPoint(point.x(), point.y(), point.z());
0138   }
0139 
0140   math::XYZPoint getPoint(const LocalPoint& point) dso_internal {
0141     return math::XYZPoint(point.x(), point.y(), point.z());
0142   }
0143 
0144   math::XYZVector getVector(const GlobalVector& vec) dso_internal { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
0145 
0146   math::XYZVector getVector(const LocalVector& vec) dso_internal { return math::XYZVector(vec.x(), vec.y(), vec.z()); }
0147 
0148   const Propagator* ivProp_;
0149   std::unique_ptr<Propagator> defProp_;
0150   CachedTrajectory cachedTrajectory_;
0151   bool useDefaultPropagator_;
0152 
0153   const DetIdAssociator* ecalDetIdAssociator_;
0154   const DetIdAssociator* hcalDetIdAssociator_;
0155   const DetIdAssociator* hoDetIdAssociator_;
0156   const DetIdAssociator* caloDetIdAssociator_;
0157   const DetIdAssociator* muonDetIdAssociator_;
0158   const DetIdAssociator* preshowerDetIdAssociator_;
0159 
0160   const CaloGeometry* theCaloGeometry_;
0161   const GlobalTrackingGeometry* theTrackingGeometry_;
0162 
0163   edm::ESWatcher<IdealMagneticFieldRecord> theMagneticFieldWatcher_;
0164 };
0165 #endif