File indexing completed on 2024-04-06 12:31:35
0001 #ifndef TrackingTools_TrackAssociator_DetIdAssociator_h
0002 #define TrackingTools_TrackAssociator_DetIdAssociator_h 1
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "DataFormats/DetId/interface/DetId.h"
0032 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0033 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0034 #include "DataFormats/GeometrySurface/interface/Plane.h"
0035 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0036 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0037 #include "FWCore/Utilities/interface/Exception.h"
0038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0039 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixStateInfo.h"
0040 #include "TrackingTools/TrackAssociator/interface/FiducialVolume.h"
0041 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0042 #include <set>
0043 #include <vector>
0044
0045 class DetIdAssociator {
0046 public:
0047 enum PropagationTarget { Barrel, ForwardEndcap, BackwardEndcap };
0048 struct MapRange {
0049 float dThetaPlus;
0050 float dThetaMinus;
0051 float dPhiPlus;
0052 float dPhiMinus;
0053 };
0054 typedef std::vector<GlobalPoint>::const_iterator const_iterator;
0055
0056 DetIdAssociator(const int nPhi, const int nEta, const double etaBinSize);
0057 virtual ~DetIdAssociator() {}
0058
0059
0060
0061 virtual std::set<DetId> getDetIdsCloseToAPoint(const GlobalPoint&, const int iN = 0) const;
0062 virtual std::set<DetId> getDetIdsCloseToAPoint(const GlobalPoint& direction,
0063 const unsigned int iNEtaPlus,
0064 const unsigned int iNEtaMinus,
0065 const unsigned int iNPhiPlus,
0066 const unsigned int iNPhiMinus) const;
0067 virtual std::set<DetId> getDetIdsCloseToAPoint(const GlobalPoint& direction, const MapRange& mapRange) const;
0068
0069
0070
0071
0072 virtual std::set<DetId> getDetIdsCloseToAPoint(const GlobalPoint& point, const double d = 0) const;
0073
0074
0075 virtual std::set<DetId> getDetIdsCloseToAPoint(const GlobalPoint& point,
0076 const double dThetaPlus,
0077 const double dThetaMinus,
0078 const double dPhiPlus,
0079 const double dPhiMinus) const;
0080
0081
0082 virtual bool selectAllInACone(const double dR) const { return dR > 2 * M_PI && dR > maxEta_; }
0083
0084
0085
0086 virtual std::set<DetId> getDetIdsInACone(const std::set<DetId>&,
0087 const std::vector<GlobalPoint>& trajectory,
0088 const double dR) const;
0089
0090
0091
0092
0093
0094
0095 virtual std::vector<DetId> getCrossedDetIds(const std::set<DetId>&, const std::vector<GlobalPoint>& trajectory) const;
0096 virtual std::vector<DetId> getCrossedDetIds(const std::set<DetId>&,
0097 const std::vector<SteppingHelixStateInfo>& trajectory,
0098 const double toleranceInSigmas = -1) const;
0099
0100 virtual int iEta(const GlobalPoint&) const;
0101
0102 virtual int iPhi(const GlobalPoint&) const;
0103
0104 int nPhiBins() const { return nPhi_; }
0105
0106 int nEtaBins() const { return nEta_; }
0107
0108 double etaBinSize() const { return etaBinSize_; };
0109
0110 virtual void buildMap();
0111
0112 const FiducialVolume& volume() const;
0113
0114 virtual const GeomDet* getGeomDet(const DetId&) const = 0;
0115
0116 virtual const char* name() const = 0;
0117
0118 protected:
0119 virtual void check_setup() const;
0120
0121 virtual void dumpMapContent(int, int) const;
0122 virtual void dumpMapContent(int, int, int, int) const;
0123
0124 virtual GlobalPoint getPosition(const DetId&) const = 0;
0125 virtual const unsigned int getNumberOfSubdetectors() const { return 1; }
0126 virtual void getValidDetIds(unsigned int subDetectorIndex, std::vector<DetId>&) const = 0;
0127 virtual std::pair<const_iterator, const_iterator> getDetIdPoints(const DetId&, std::vector<GlobalPoint>&) const = 0;
0128
0129 virtual bool insideElement(const GlobalPoint&, const DetId&) const = 0;
0130 virtual bool crossedElement(const GlobalPoint&,
0131 const GlobalPoint&,
0132 const DetId&,
0133 const double toleranceInSigmas = -1,
0134 const SteppingHelixStateInfo* = nullptr) const {
0135 return false;
0136 }
0137 virtual bool nearElement(const GlobalPoint& point, const DetId& id, const double distance) const;
0138
0139 unsigned int index(unsigned int iEta, unsigned int iPhi) const { return iEta * nPhi_ + iPhi; }
0140 void fillSet(std::set<DetId>& set, unsigned int iEta, unsigned int iPhi) const;
0141
0142
0143 const int nPhi_;
0144 const int nEta_;
0145
0146
0147
0148 std::vector<std::pair<unsigned int, unsigned int> > lookupMap_;
0149 std::vector<DetId> container_;
0150 bool theMapIsValid_;
0151 const double etaBinSize_;
0152 double maxEta_;
0153 double minTheta_;
0154
0155
0156
0157
0158 FiducialVolume volume_;
0159 };
0160 #endif