CMS 3D CMS Logo

ElectronSeed.h
Go to the documentation of this file.
1 #ifndef DataFormats_EgammaReco_ElectronSeed_h
2 #define DataFormats_EgammaReco_ElectronSeed_h
3 
4 //********************************************************************
5 //
6 // A verson of reco::ElectronSeed which can have N hits as part of the
7 // 2017 upgrade of E/gamma pixel matching for the phaseI pixels
8 //
9 // author: S. Harper (RAL), 2017
10 //
11 //notes:
12 // While it is technically named ElectronSeed, it is effectively a new class
13 // However to simplify things, the name ElectronSeed was kept
14 // (trust me it was simplier...)
15 //
16 // Noticed that h/e values never seem to used anywhere and they are a
17 // mild pain to propagate in the new framework so they were removed
18 //
19 // infinities are used to mark invalid unset values to maintain
20 // compatibilty with the orginal ElectronSeed class
21 //
22 //description:
23 // An ElectronSeed is a TrajectorySeed with E/gamma specific information
24 // A TrajectorySeed has a series of hits associated with it
25 // (accessed by TrajectorySeed::nHits(), TrajectorySeed::recHits())
26 // and ElectronSeed stores which of those hits match well to a supercluster
27 // together with the matching parameters (this is known as EcalDriven).
28 // ElectronSeeds can be TrackerDriven in which case the matching is not done.
29 // It used to be fixed to two matched hits, now this is an arbitary number
30 // Its designed with pixel matching with mind but tries to be generally
31 // applicable to strips as well.
32 // It is worth noting that due to different ways ElectronSeeds can be created
33 // they do not always have all parameters filled
34 //
35 //********************************************************************
36 
45 
46 #include <vector>
47 #include <limits>
48 
49 namespace reco {
50 
51  class ElectronSeed : public TrajectorySeed {
52  public:
53  struct PMVars {
54  float dRZPos;
55  float dRZNeg;
56  float dPhiPos;
57  float dPhiNeg;
58  int detId; //this is already stored as the hit is stored in traj seed but a useful sanity check
59  int layerOrDiskNr; //redundant as stored in detId but its a huge pain to hence why its saved here
60 
61  PMVars();
62 
63  void setDPhi(float pos, float neg);
64  void setDRZ(float pos, float neg);
65  void setDet(int iDetId, int iLayerOrDiskNr);
66  };
67 
71 
72  static std::string const& name() {
73  static std::string const name_("ElectronSeed");
74  return name_;
75  }
76 
78  ElectronSeed();
81  ElectronSeed* clone() const override { return new ElectronSeed(*this); }
82  ~ElectronSeed() override;
83 
85  void setCtfTrack(const CtfTrackRef&);
86  void setCaloCluster(const CaloClusterRef& clus) {
87  caloCluster_ = clus;
88  isEcalDriven_ = true;
89  }
90  void addHitInfo(const PMVars& hitVars) { hitInfo_.push_back(hitVars); }
93  const CtfTrackRef& ctfTrack() const { return ctfTrack_; }
94  const CaloClusterRef& caloCluster() const { return caloCluster_; }
95 
98 
99  bool isEcalDriven() const { return isEcalDriven_; }
100  bool isTrackerDriven() const { return isTrackerDriven_; }
101 
102  const std::vector<PMVars>& hitInfo() const { return hitInfo_; }
103  float dPhiNeg(size_t hitNr) const { return getVal(hitNr, &PMVars::dPhiNeg); }
104  float dPhiPos(size_t hitNr) const { return getVal(hitNr, &PMVars::dPhiPos); }
105  float dPhiBest(size_t hitNr) const { return bestVal(dPhiNeg(hitNr), dPhiPos(hitNr)); }
106  float dRZPos(size_t hitNr) const { return getVal(hitNr, &PMVars::dRZPos); }
107  float dRZNeg(size_t hitNr) const { return getVal(hitNr, &PMVars::dRZNeg); }
108  float dRZBest(size_t hitNr) const { return bestVal(dRZNeg(hitNr), dRZPos(hitNr)); }
109  int detId(size_t hitNr) const { return hitNr < hitInfo_.size() ? hitInfo_[hitNr].detId : 0; }
110  int subDet(size_t hitNr) const { return DetId(detId(hitNr)).subdetId(); }
111  int layerOrDiskNr(size_t hitNr) const { return getVal(hitNr, &PMVars::layerOrDiskNr); }
112  int nrLayersAlongTraj() const { return nrLayersAlongTraj_; }
113 
114  unsigned int hitsMask() const;
115  void initTwoHitSeed(const unsigned char hitMask);
116  void setNegAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
117  const float dPhi2 = std::numeric_limits<float>::infinity(),
118  const float dRZ1 = std::numeric_limits<float>::infinity(),
119  const float dPhi1 = std::numeric_limits<float>::infinity());
120  void setPosAttributes(const float dRZ2 = std::numeric_limits<float>::infinity(),
121  const float dPhi2 = std::numeric_limits<float>::infinity(),
122  const float dRZ1 = std::numeric_limits<float>::infinity(),
123  const float dPhi1 = std::numeric_limits<float>::infinity());
124 
125  //this is a backwards compatible function designed to
126  //convert old format ElectronSeeds to the new format
127  //only public due to root io rules, not intended for any other use
128  //also in theory not necessary to part of this class
129  static std::vector<PMVars> createHitInfo(const float dPhi1Pos,
130  const float dPhi1Neg,
131  const float dRZ1Pos,
132  const float dRZ1Neg,
133  const float dPhi2Pos,
134  const float dPhi2Neg,
135  const float dRZ2Pos,
136  const float dRZ2Neg,
137  const char hitMask,
139 
140  private:
141  static float bestVal(float val1, float val2) { return std::abs(val1) < std::abs(val2) ? val1 : val2; }
142  template <typename T>
143  T getVal(unsigned int hitNr, T PMVars::*val) const {
144  return hitNr < hitInfo_.size() ? hitInfo_[hitNr].*val : std::numeric_limits<T>::infinity();
145  }
146  static std::vector<unsigned int> hitNrsFromMask(unsigned int hitMask);
147 
148  private:
151  std::vector<PMVars> hitInfo_;
153 
156  };
157 } // namespace reco
158 
159 #endif
reco::ElectronSeed::ctfTrack
const CtfTrackRef & ctfTrack() const
Accessors.
Definition: ElectronSeed.h:93
reco::ElectronSeed::CaloClusterRef
edm::RefToBase< CaloCluster > CaloClusterRef
Definition: ElectronSeed.h:69
reco::ElectronSeed::ElectronSeed
ElectronSeed()
Construction of base attributes.
Definition: ElectronSeed.cc:8
reco::ElectronSeed::setCaloCluster
void setCaloCluster(const CaloClusterRef &clus)
Definition: ElectronSeed.h:86
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
reco::ElectronSeed::bestVal
static float bestVal(float val1, float val2)
Definition: ElectronSeed.h:141
reco::ElectronSeed::setNegAttributes
void setNegAttributes(const float dRZ2=std::numeric_limits< float >::infinity(), const float dPhi2=std::numeric_limits< float >::infinity(), const float dRZ1=std::numeric_limits< float >::infinity(), const float dPhi1=std::numeric_limits< float >::infinity())
Definition: ElectronSeed.cc:86
reco::ElectronSeed::isEcalDriven_
bool isEcalDriven_
Definition: ElectronSeed.h:154
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
reco::ElectronSeed::createHitInfo
static std::vector< PMVars > createHitInfo(const float dPhi1Pos, const float dPhi1Neg, const float dRZ1Pos, const float dRZ1Neg, const float dPhi2Pos, const float dPhi2Neg, const float dRZ2Pos, const float dRZ2Neg, const char hitMask, const TrajectorySeed::range recHits)
Definition: ElectronSeed.cc:122
pos
Definition: PixelAliasList.h:18
reco::ElectronSeed::PMVars::setDPhi
void setDPhi(float pos, float neg)
Definition: ElectronSeed.cc:174
reco::ElectronSeed::caloCluster_
CaloClusterRef caloCluster_
Definition: ElectronSeed.h:150
reco::ElectronSeed::nrLayersAlongTraj_
int nrLayersAlongTraj_
Definition: ElectronSeed.h:152
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
infinity
const double infinity
Definition: CSCChamberFitter.cc:10
reco::ElectronSeed::~ElectronSeed
~ElectronSeed() override
reco::ElectronSeed::PMVars::dPhiPos
float dPhiPos
Definition: ElectronSeed.h:56
reco::ElectronSeed::initTwoHitSeed
void initTwoHitSeed(const unsigned char hitMask)
Definition: ElectronSeed.cc:60
reco::ElectronSeed::PMVars::layerOrDiskNr
int layerOrDiskNr
Definition: ElectronSeed.h:59
reco::ElectronSeed::setPosAttributes
void setPosAttributes(const float dRZ2=std::numeric_limits< float >::infinity(), const float dPhi2=std::numeric_limits< float >::infinity(), const float dRZ1=std::numeric_limits< float >::infinity(), const float dPhi1=std::numeric_limits< float >::infinity())
Definition: ElectronSeed.cc:99
ElectronSeedFwd.h
edm::Ref< TrackCollection >
reco::ElectronSeed::layerOrDiskNr
int layerOrDiskNr(size_t hitNr) const
Definition: ElectronSeed.h:111
reco::ElectronSeed::hitsMask
unsigned int hitsMask() const
Definition: ElectronSeed.cc:47
DetId
Definition: DetId.h:17
TrackingRecHit.h
reco::ElectronSeed::hitNrsFromMask
static std::vector< unsigned int > hitNrsFromMask(unsigned int hitMask)
Definition: ElectronSeed.cc:112
reco::ElectronSeed
Definition: ElectronSeed.h:51
TrackFwd.h
reco::ElectronSeed::isEcalDriven
bool isEcalDriven() const
Definition: ElectronSeed.h:99
reco::ElectronSeed::PMVars::dRZPos
float dRZPos
Definition: ElectronSeed.h:54
reco::ElectronSeed::clone
ElectronSeed * clone() const override
Definition: ElectronSeed.h:81
reco::ElectronSeed::PMVars::detId
int detId
Definition: ElectronSeed.h:58
TrackCharge.h
reco::ElectronSeed::PMVars::setDet
void setDet(int iDetId, int iLayerOrDiskNr)
Definition: ElectronSeed.cc:184
reco::ElectronSeed::PMVars::dPhiNeg
float dPhiNeg
Definition: ElectronSeed.h:57
reco::ElectronSeed::detId
int detId(size_t hitNr) const
Definition: ElectronSeed.h:109
CaloClusterFwd.h
reco::ElectronSeed::getCharge
TrackCharge getCharge() const
Utility.
Definition: ElectronSeed.h:97
reco::ElectronSeed::isTrackerDriven
bool isTrackerDriven() const
Definition: ElectronSeed.h:100
reco::ElectronSeed::subDet
int subDet(size_t hitNr) const
Definition: ElectronSeed.h:110
LocalTrajectoryParameters::charge
TrackCharge charge() const
Charge (-1, 0 or 1)
Definition: LocalTrajectoryParameters.h:110
TrajectorySeed.h
RefToBase.h
reco::ElectronSeed::hitInfo
const std::vector< PMVars > & hitInfo() const
Definition: ElectronSeed.h:102
reco::ElectronSeed::addHitInfo
void addHitInfo(const PMVars &hitVars)
Definition: ElectronSeed.h:90
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::ElectronSeed::nrLayersAlongTraj
int nrLayersAlongTraj() const
Definition: ElectronSeed.h:112
reco::ElectronSeed::setCtfTrack
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:39
reco::ElectronSeed::name
static std::string const & name()
Definition: ElectronSeed.h:72
reco::ElectronSeed::ctfTrack_
CtfTrackRef ctfTrack_
Definition: ElectronSeed.h:149
reco::ElectronSeed::dPhiBest
float dPhiBest(size_t hitNr) const
Definition: ElectronSeed.h:105
RPCpg::pts
static const double pts[33]
Definition: Constants.h:30
reco::ElectronSeed::dRZPos
float dRZPos(size_t hitNr) const
Definition: ElectronSeed.h:106
reco::ElectronSeed::hitInfo_
std::vector< PMVars > hitInfo_
Definition: ElectronSeed.h:151
reco::ElectronSeed::dPhiNeg
float dPhiNeg(size_t hitNr) const
Definition: ElectronSeed.h:103
reco::ElectronSeed::setNrLayersAlongTraj
void setNrLayersAlongTraj(int val)
Definition: ElectronSeed.h:91
heppy_batch.val
val
Definition: heppy_batch.py:351
Ref.h
PTrajectoryStateOnDet::parameters
const LocalTrajectoryParameters & parameters() const
Definition: PTrajectoryStateOnDet.h:60
reco::ElectronSeed::PMVars::dRZNeg
float dRZNeg
Definition: ElectronSeed.h:55
T
long double T
Definition: Basic3DVectorLD.h:48
reco::ElectronSeed::dRZNeg
float dRZNeg(size_t hitNr) const
Definition: ElectronSeed.h:107
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
TrajectorySeed
Definition: TrajectorySeed.h:17
reco::ElectronSeed::CtfTrackRef
edm::Ref< TrackCollection > CtfTrackRef
Definition: ElectronSeed.h:70
reco::ElectronSeed::isTrackerDriven_
bool isTrackerDriven_
Definition: ElectronSeed.h:155
edm::RefToBase< CaloCluster >
reco::ElectronSeed::dRZBest
float dRZBest(size_t hitNr) const
Definition: ElectronSeed.h:108
reco::ElectronSeed::dPhiPos
float dPhiPos(size_t hitNr) const
Definition: ElectronSeed.h:104
TrajectorySeed::startingState
PTrajectoryStateOnDet const & startingState() const
Definition: TrajectorySeed.h:55
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::ElectronSeed::PMVars::PMVars
PMVars()
Definition: ElectronSeed.cc:166
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
reco::ElectronSeed::PMVars
Definition: ElectronSeed.h:53
reco::ElectronSeed::RecHitContainer
edm::OwnVector< TrackingRecHit > RecHitContainer
Definition: ElectronSeed.h:68
reco::ElectronSeed::PMVars::setDRZ
void setDRZ(float pos, float neg)
Definition: ElectronSeed.cc:179
edm::OwnVector< TrackingRecHit >
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
reco::ElectronSeed::caloCluster
const CaloClusterRef & caloCluster() const
Definition: ElectronSeed.h:94
reco::ElectronSeed::getVal
T getVal(unsigned int hitNr, T PMVars::*val) const
Definition: ElectronSeed.h:143