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 
52  class ElectronSeed : public TrajectorySeed {
53  public :
54  struct PMVars {
55  float dRZPos;
56  float dRZNeg;
57  float dPhiPos;
58  float dPhiNeg;
59  int detId; //this is already stored as the hit is stored in traj seed but a useful sanity check
60  int layerOrDiskNr;//redundant as stored in detId but its a huge pain to hence why its saved here
61 
62  PMVars();
63 
64  void setDPhi(float pos,float neg);
65  void setDRZ(float pos,float neg);
66  void setDet(int iDetId,int iLayerOrDiskNr);
67 
68  };
69 
73 
74  static std::string const & name()
75  {
76  static std::string const name_("ElectronSeed") ;
77  return name_;
78  }
79 
81  ElectronSeed() ;
82  ElectronSeed( const TrajectorySeed & ) ;
83  ElectronSeed( PTrajectoryStateOnDet & pts, RecHitContainer & rh, PropagationDirection & dir ) ;
84  ElectronSeed * clone() const { return new ElectronSeed(*this) ; }
85  virtual ~ElectronSeed();
86 
88  void setCtfTrack( const CtfTrackRef & ) ;
89  void setCaloCluster( const CaloClusterRef& clus){caloCluster_=clus;isEcalDriven_=true;}
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);}
113 
114  //redundant, backwards compatible function names
115  //to be cleaned up asap
116  //no new code should use them
117  //they were created as time is short and there is less risk having
118  //the functions here rather than adapting all the function call to them in other
119  //CMSSW code
120  float dPhi1()const{return dPhiNeg(0);}
121  float dPhi1Pos()const{return dPhiPos(0);}
122  float dPhi2()const{return dPhiNeg(1);}
123  float dPhi2Pos()const{return dPhiPos(1);}
124  float dRz1()const{return dRZNeg(0);}
125  float dRz1Pos()const{return dRZPos(0);}
126  float dRz2()const{return dRZNeg(1);}
127  float dRz2Pos()const{return dRZPos(1);}
128  int subDet1()const{return subDet(0);}
129  int subDet2()const{return subDet(1);}
130  unsigned int hitsMask()const;
131  void initTwoHitSeed(const unsigned char hitMask);
134  const float dRZ1=std::numeric_limits<float>::infinity(),
138  const float dRZ1=std::numeric_limits<float>::infinity(),
140 
141  //this is a backwards compatible function designed to
142  //convert old format ElectronSeeds to the new format
143  //only public due to root io rules, not intended for any other use
144  //also in theory not necessary to part of this class
145  static std::vector<PMVars> createHitInfo(const float dPhi1Pos,const float dPhi1Neg,
146  const float dRZ1Pos,const float dRZ1Neg,
147  const float dPhi2Pos,const float dPhi2Neg,
148  const float dRZ2Pos,const float dRZ2Neg,
149  const char hitMask,const TrajectorySeed::range recHits);
150  private:
151  static float bestVal(float val1,float val2){return std::abs(val1)<std::abs(val2) ? val1 : val2;}
152  template<typename T>
153  T getVal(unsigned int hitNr,T PMVars::*val)const{
154  return hitNr<hitInfo_.size() ? hitInfo_[hitNr].*val : std::numeric_limits<T>::infinity();
155  }
156  static std::vector<unsigned int> hitNrsFromMask(unsigned int hitMask);
157 
158  private:
159  CtfTrackRef ctfTrack_;
160  CaloClusterRef caloCluster_;
161  std::vector<PMVars> hitInfo_;
163 
166 
167  };
168 }
169 
170 #endif
T getVal(unsigned int hitNr, T PMVars::*val) const
Definition: ElectronSeed.h:153
static std::string const & name()
Definition: ElectronSeed.h:74
std::vector< PMVars > hitInfo_
Definition: ElectronSeed.h:161
float dPhi1() const
Definition: ElectronSeed.h:120
ElectronSeed * clone() const
Definition: ElectronSeed.h:84
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
int subDet(size_t hitNr) const
Definition: ElectronSeed.h:110
edm::Ref< TrackCollection > CtfTrackRef
Definition: ElectronSeed.h:72
const CaloClusterRef & caloCluster() const
Definition: ElectronSeed.h:94
void setDPhi(float pos, float neg)
float dPhi1Pos() const
Definition: ElectronSeed.h:121
PropagationDirection
int nrLayersAlongTraj() const
Definition: ElectronSeed.h:112
float dRZPos(size_t hitNr) const
Definition: ElectronSeed.h:106
edm::OwnVector< TrackingRecHit > RecHitContainer
Definition: ElectronSeed.h:70
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:35
static const double pts[33]
Definition: Constants.h:30
int TrackCharge
Definition: TrackCharge.h:4
void setNrLayersAlongTraj(int val)
Definition: ElectronSeed.h:91
float dPhi2() const
Definition: ElectronSeed.h:122
bool isTrackerDriven() const
Definition: ElectronSeed.h:100
float dRz2Pos() const
Definition: ElectronSeed.h:127
float dRz1() const
Definition: ElectronSeed.h:124
static float bestVal(float val1, float val2)
Definition: ElectronSeed.h:151
ElectronSeed()
Construction of base attributes.
Definition: ElectronSeed.cc:9
void setDet(int iDetId, int iLayerOrDiskNr)
const double infinity
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< const_iterator, const_iterator > range
float dRz1Pos() const
Definition: ElectronSeed.h:125
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
float dPhiBest(size_t hitNr) const
Definition: ElectronSeed.h:105
CaloClusterRef caloCluster_
Definition: ElectronSeed.h:160
int subDet1() const
Definition: ElectronSeed.h:128
float dRz2() const
Definition: ElectronSeed.h:126
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
float dPhi2Pos() const
Definition: ElectronSeed.h:123
int layerOrDiskNr(size_t hitNr) const
Definition: ElectronSeed.h:111
int detId(size_t hitNr) const
Definition: ElectronSeed.h:109
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:87
const std::vector< PMVars > & hitInfo() const
Definition: ElectronSeed.h:102
range recHits() const
TrackCharge getCharge() const
Utility.
Definition: ElectronSeed.h:97
edm::RefToBase< CaloCluster > CaloClusterRef
Definition: ElectronSeed.h:71
TrackCharge charge() const
Charge (-1, 0 or 1)
virtual ~ElectronSeed()
void setCaloCluster(const CaloClusterRef &clus)
Definition: ElectronSeed.h:89
float dRZBest(size_t hitNr) const
Definition: ElectronSeed.h:108
fixed size matrix
unsigned int hitsMask() const
Definition: ElectronSeed.cc:44
float dRZNeg(size_t hitNr) const
Definition: ElectronSeed.h:107
int subDet2() const
Definition: ElectronSeed.h:129
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)
dbl *** dir
Definition: mlp_gen.cc:35
void addHitInfo(const PMVars &hitVars)
Definition: ElectronSeed.h:90
float dPhiNeg(size_t hitNr) const
Definition: ElectronSeed.h:103
long double T
CtfTrackRef ctfTrack_
Definition: ElectronSeed.h:159
void setDRZ(float pos, float neg)
float dPhiPos(size_t hitNr) const
Definition: ElectronSeed.h:104
static std::vector< unsigned int > hitNrsFromMask(unsigned int hitMask)
const LocalTrajectoryParameters & parameters() const
bool isEcalDriven() const
Definition: ElectronSeed.h:99
const CtfTrackRef & ctfTrack() const
Accessors.
Definition: ElectronSeed.h:93
void initTwoHitSeed(const unsigned char hitMask)
Definition: ElectronSeed.cc:58