CMS 3D CMS Logo

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 }
reco::PFRecHit::getNeighbour
unsigned int getNeighbour(short x, short y, short z) const
Definition: PFRecHit.cc:46
mps_fire.i
i
Definition: mps_fire.py:428
pos
Definition: PixelAliasList.h:18
cms::cuda::assert
assert(be >=bs)
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PFRecHit.h
reco::PFRecHit::addNeighbour
void addNeighbour(short x, short y, short z, unsigned int)
Definition: PFRecHit.cc:5
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
reco::PFRecHit::neighbours4_
unsigned int neighbours4_
Definition: PFRecHit.h:164
reco::PFRecHit::neighbourInfos_
std::vector< unsigned short > neighbourInfos_
Definition: PFRecHit.h:161
operator<<
std::ostream & operator<<(std::ostream &out, const reco::PFRecHit &hit)
Definition: PFRecHit.cc:72
reco::PFRecHit::neighbours_
std::vector< unsigned int > neighbours_
indices to existing neighbours (1 common side)
Definition: PFRecHit.h:160
reco::PFRecHit::neighbours8_
unsigned int neighbours8_
Definition: PFRecHit.h:165
reco::PFRecHit
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
hit
Definition: SiStripHitEffFromCalibTree.cc:88