CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  if (x > 0)
21  bitmask = bitmask | 1;
22  bitmask = bitmask | (absx << 1);
23  if (y > 0)
24  bitmask = bitmask | (1 << 4);
25  bitmask = bitmask | (absy << 5);
26  if (z > 0)
27  bitmask = bitmask | (1 << 8);
28  bitmask = bitmask | (absz << 9);
29 
30  auto pos = neighbours_.size();
31  if (z == 0) {
32  pos = neighbours8_++;
33  //find only the 4 neighbours
34  if (absx + absy == 1)
35  pos = neighbours4_++;
36  }
37  neighbours_.insert(neighbours_.begin() + pos, ref);
38  neighbourInfos_.insert(neighbourInfos_.begin() + pos, bitmask);
39 
40  assert(neighbours4_ < 5);
41  assert(neighbours8_ < 9);
43  assert(neighbours8_ <= neighbours_.size());
44  }
45 
46  unsigned int PFRecHit::getNeighbour(short x, short y, short z) const {
47  unsigned short absx = abs(x);
48  unsigned short absy = abs(y);
49  unsigned short absz = abs(z);
50 
51  unsigned short bitmask = 0;
52 
53  if (x > 0)
54  bitmask = bitmask | 1;
55  bitmask = bitmask | (absx << 1);
56  if (y > 0)
57  bitmask = bitmask | (1 << 4);
58  bitmask = bitmask | (absy << 5);
59  if (z > 0)
60  bitmask = bitmask | (1 << 8);
61  bitmask = bitmask | (absz << 9);
62 
63  for (unsigned int i = 0; i < neighbourInfos_.size(); ++i) {
64  if (neighbourInfos_[i] == bitmask)
65  return neighbours_[i];
66  }
68  }
69 
70 } // namespace reco
71 
72 std::ostream& operator<<(std::ostream& out, const reco::PFRecHit& hit) {
73  if (!out)
74  return out;
75 
76  out << "hit id:" << hit.detId() << " l:" << hit.layer() << " E:" << hit.energy() << " t:" << hit.time();
77  if (hit.hasCaloCell()) {
78  auto const& pos = hit.positionREP();
79  out << " rep:" << pos.rho() << "," << pos.eta() << "," << pos.phi() << "|";
80  }
81  return out;
82 }
float rho() const
transverse momentum
Definition: PtEtaPhiMass.h:50
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:161
std::vector< unsigned int > neighbours_
indices to existing neighbours (1 common side)
Definition: PFRecHit.h:160
unsigned int neighbours4_
Definition: PFRecHit.h:164
float time() const
timing for cleaned hits
Definition: PFRecHit.h:102
unsigned detId() const
rechit detId
Definition: PFRecHit.h:93
void addNeighbour(short x, short y, short z, unsigned int)
Definition: PFRecHit.cc:5
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
unsigned int getNeighbour(short x, short y, short z) const
Definition: PFRecHit.cc:46
assert(be >=bs)
unsigned int neighbours8_
Definition: PFRecHit.h:165
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:96
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
bool hasCaloCell() const
Definition: PFRecHit.h:90
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float energy() const
rechit energy
Definition: PFRecHit.h:99
RhoEtaPhi const & positionREP() const
Definition: PFRecHit.h:119