File indexing completed on 2024-07-18 23:17:37
0001 #ifndef DataFormats_EgammaReco_ElectronSeed_h
0002 #define DataFormats_EgammaReco_ElectronSeed_h
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
0032
0033
0034
0035
0036
0037 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
0038 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0039 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0040 #include "DataFormats/TrajectoryState/interface/TrackCharge.h"
0041 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0042 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0043 #include "DataFormats/Common/interface/RefToBase.h"
0044 #include "DataFormats/Common/interface/Ref.h"
0045
0046 #include <vector>
0047 #include <limits>
0048
0049 namespace reco {
0050
0051 class ElectronSeed : public TrajectorySeed {
0052 public:
0053 struct PMVars {
0054 float dRZPos;
0055 float dRZNeg;
0056 float dPhiPos;
0057 float dPhiNeg;
0058 int detId;
0059 int layerOrDiskNr;
0060
0061 PMVars();
0062
0063 void setDPhi(float pos, float neg);
0064 void setDRZ(float pos, float neg);
0065 void setDet(int iDetId, int iLayerOrDiskNr);
0066 };
0067
0068 typedef edm::RefToBase<CaloCluster> CaloClusterRef;
0069 typedef edm::Ref<TrackCollection> CtfTrackRef;
0070
0071 static std::string const& name() {
0072 static std::string const name_("ElectronSeed");
0073 return name_;
0074 }
0075
0076
0077 ElectronSeed();
0078 ElectronSeed(const TrajectorySeed&);
0079 ElectronSeed(PTrajectoryStateOnDet& pts, RecHitContainer& rh, PropagationDirection& dir);
0080 ElectronSeed* clone() const override { return new ElectronSeed(*this); }
0081 ~ElectronSeed() override;
0082
0083
0084 void setCtfTrack(const CtfTrackRef&);
0085 void setCaloCluster(const CaloClusterRef& clus) {
0086 caloCluster_ = clus;
0087 isEcalDriven_ = true;
0088 }
0089 void addHitInfo(const PMVars& hitVars) { hitInfo_.push_back(hitVars); }
0090 void setNrLayersAlongTraj(int val) { nrLayersAlongTraj_ = val; }
0091
0092 const CtfTrackRef& ctfTrack() const { return ctfTrack_; }
0093 const CaloClusterRef& caloCluster() const { return caloCluster_; }
0094
0095
0096 TrackCharge getCharge() const { return startingState().parameters().charge(); }
0097
0098 bool isEcalDriven() const { return isEcalDriven_; }
0099 bool isTrackerDriven() const { return isTrackerDriven_; }
0100
0101 const std::vector<PMVars>& hitInfo() const { return hitInfo_; }
0102 float dPhiNeg(size_t hitNr) const { return getVal(hitNr, &PMVars::dPhiNeg); }
0103 float dPhiPos(size_t hitNr) const { return getVal(hitNr, &PMVars::dPhiPos); }
0104 float dPhiBest(size_t hitNr) const { return bestVal(dPhiNeg(hitNr), dPhiPos(hitNr)); }
0105 float dRZPos(size_t hitNr) const { return getVal(hitNr, &PMVars::dRZPos); }
0106 float dRZNeg(size_t hitNr) const { return getVal(hitNr, &PMVars::dRZNeg); }
0107 float dRZBest(size_t hitNr) const { return bestVal(dRZNeg(hitNr), dRZPos(hitNr)); }
0108 int detId(size_t hitNr) const { return hitNr < hitInfo_.size() ? hitInfo_[hitNr].detId : 0; }
0109 int subDet(size_t hitNr) const { return DetId(detId(hitNr)).subdetId(); }
0110 int layerOrDiskNr(size_t hitNr) const { return getVal(hitNr, &PMVars::layerOrDiskNr); }
0111 int nrLayersAlongTraj() const { return nrLayersAlongTraj_; }
0112
0113 unsigned int hitsMask() const;
0114 void initTwoHitSeed(const unsigned char hitMask);
0115 void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
0116 const float dPhi2 = std::numeric_limits<float>::max(),
0117 const float dRZ1 = std::numeric_limits<float>::max(),
0118 const float dPhi1 = std::numeric_limits<float>::max());
0119 void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::max(),
0120 const float dPhi2 = std::numeric_limits<float>::max(),
0121 const float dRZ1 = std::numeric_limits<float>::max(),
0122 const float dPhi1 = std::numeric_limits<float>::max());
0123
0124
0125
0126
0127
0128 static std::vector<PMVars> createHitInfo(const float dPhi1Pos,
0129 const float dPhi1Neg,
0130 const float dRZ1Pos,
0131 const float dRZ1Neg,
0132 const float dPhi2Pos,
0133 const float dPhi2Neg,
0134 const float dRZ2Pos,
0135 const float dRZ2Neg,
0136 const char hitMask,
0137 TrajectorySeed::RecHitRange const& recHits);
0138
0139 private:
0140 static float bestVal(float val1, float val2) { return std::abs(val1) < std::abs(val2) ? val1 : val2; }
0141 template <typename T>
0142 T getVal(unsigned int hitNr, T PMVars::*val) const {
0143 return hitNr < hitInfo_.size() ? hitInfo_[hitNr].*val : std::numeric_limits<T>::max();
0144 }
0145 static std::vector<unsigned int> hitNrsFromMask(unsigned int hitMask);
0146
0147 private:
0148 CtfTrackRef ctfTrack_;
0149 CaloClusterRef caloCluster_;
0150 std::vector<PMVars> hitInfo_;
0151 int nrLayersAlongTraj_;
0152
0153 bool isEcalDriven_;
0154 bool isTrackerDriven_;
0155 };
0156 }
0157
0158 #endif