CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecHit.cc
Go to the documentation of this file.
2 #include<limits>
3 namespace reco {
4 
5 void PFRecHit::addNeighbour(short x,short y,short z, unsigned int ref) {
6  //bitmask interface to accomodate more advanced naighbour finding [i.e in z as well]
7  //bit 0 side for eta [0 for <=0 , 1 for >0]
8  //bits 1,2,3 : abs(eta) wrt the center
9  //bit 4 side for phi
10  //bits 5,6,7 : abs(phi) wrt the center
11  //bit 8 side for z
12  //bits 9,10,11 : abs(z) wrt the center
13 
14  unsigned short absx = std::abs(x);
15  unsigned short absy = std::abs(y);
16  unsigned short absz = std::abs(z);
17 
18  unsigned short bitmask=0;
19 
20 
21  if (x>0)
22  bitmask = bitmask | 1 ;
23  bitmask = bitmask | (absx << 1);
24  if (y>0)
25  bitmask = bitmask | (1<<4) ;
26  bitmask = bitmask | (absy << 5);
27  if (z>0)
28  bitmask = bitmask | (1<<8) ;
29  bitmask = bitmask | (absz << 9);
30 
31  auto pos = neighbours_.size();
32  if (z==0) {
33  pos = neighbours8_++;
34  //find only the 4 neighbours
35  if (absx+absy==1)
36  pos = neighbours4_++;
37  }
38  neighbours_.insert(neighbours_.begin()+pos,ref);
39  neighbourInfos_.insert(neighbourInfos_.begin()+pos,bitmask);
40 
41  assert( neighbours4_<5);
42  assert( neighbours8_<9);
45 
46 }
47 
48 
49 unsigned int PFRecHit::getNeighbour(short x,short y,short z) const {
50  unsigned short absx = abs(x);
51  unsigned short absy = abs(y);
52  unsigned short absz = abs(z);
53 
54  unsigned short bitmask=0;
55 
56  if (x>0)
57  bitmask = bitmask | 1 ;
58  bitmask = bitmask | (absx << 1);
59  if (y>0)
60  bitmask = bitmask | (1<<4) ;
61  bitmask = bitmask | (absy << 5);
62  if (z>0)
63  bitmask = bitmask | (1<<8) ;
64  bitmask = bitmask | (absz << 9);
65 
66  for (unsigned int i=0;i<neighbourInfos_.size();++i) {
67  if (neighbourInfos_[i] == bitmask)
68  return neighbours_[i];
69  }
71 }
72 
73 }
74 
75 std::ostream& operator<<(std::ostream& out, const reco::PFRecHit& hit) {
76 
77  if(!out) return out;
78 
79  out<<"hit id:"<<hit.detId()
80  <<" l:"<<hit.layer()
81  <<" E:"<<hit.energy()
82  <<" t:"<<hit.time();
83  if (hit.hasCaloCell()) {
84  auto const & pos = hit.positionREP();
85  out <<" rep:"<<pos.rho()<<","<<pos.eta()<<","<<pos.phi()<<"|";
86  }
87  return out;
88 }
std::vector< unsigned int > neighbours_
indices to existing neighbours (1 common side)
Definition: PFRecHit.h:176
float rho() const
transverse momentum
Definition: PtEtaPhiMass.h:49
int i
Definition: DBlmapReader.cc:9
unsigned int neighbours4_
Definition: PFRecHit.h:180
float time() const
timing for cleaned hits
Definition: PFRecHit.h:118
unsigned detId() const
rechit detId
Definition: PFRecHit.h:108
assert(m_qm.get())
void addNeighbour(short x, short y, short z, unsigned int)
Definition: PFRecHit.cc:5
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:177
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
unsigned int getNeighbour(short x, short y, short z) const
Definition: PFRecHit.cc:49
unsigned int neighbours8_
Definition: PFRecHit.h:181
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:111
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
bool hasCaloCell() const
Definition: PFRecHit.h:105
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
rechit energy
Definition: PFRecHit.h:114
RhoEtaPhi const & positionREP() const
Definition: PFRecHit.h:131