CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FastTimeTopology.cc
Go to the documentation of this file.
4 
5 //#define EDM_ML_DEBUG
6 
8  : hdcons_(hdcons), subdet_(sub), type_(type) {
11  kHGhalf_ = nEtaZ_ * nPhi_;
12  kHGeomHalf_ = 1;
13  kSizeForDenseIndexing = (unsigned int)(2 * kHGhalf_);
14 #ifdef EDM_ML_DEBUG
15  edm::LogVerbatim("FastTime") << "FastTimeTopology initialized for subDetetcor " << subdet_ << " Type " << type_
16  << " with " << nEtaZ_ << " cells along Z|Eta and " << nPhi_
17  << " cells along phi: total channels " << kSizeForDenseIndexing << ":"
18  << (2 * kHGeomHalf_);
19 #endif
20 }
21 
22 uint32_t FastTimeTopology::detId2denseId(const DetId& id) const {
24  uint32_t idx = (uint32_t)(((id_.zside > 0) ? kHGhalf_ : 0) + ((id_.iEtaZ - 1) * nPhi_ + id_.iPhi - 1));
25  return idx;
26 }
27 
29  if (validHashIndex(hi)) {
31  id_.iType = type_;
32  id_.zside = ((int)(hi) < kHGhalf_ ? -1 : 1);
33  int di = ((int)(hi) % kHGhalf_);
34  int iPhi = (di % nPhi_);
35  id_.iPhi = iPhi + 1;
36  id_.iEtaZ = (((di - iPhi) / nPhi_) + 1);
37  return encode(id_);
38  } else {
39  return DetId(0);
40  }
41 }
42 
43 uint32_t FastTimeTopology::detId2denseGeomId(const DetId& id) const {
45  uint32_t idx = (uint32_t)((id_.zside > 0) ? kHGeomHalf_ : 0);
46  return idx;
47 }
48 
49 bool FastTimeTopology::valid(const DetId& id) const {
51  bool flag = hdcons_.isValidXY(id_.iType, id_.iEtaZ, id_.iPhi);
52  return flag;
53 }
54 
55 DetId FastTimeTopology::offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const {
56  if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)) {
57  DetId id = changeXY(startId, nrStepsX, nrStepsY);
58  if (valid(id))
59  return id;
60  }
61  return DetId(0);
62 }
63 
65  if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)) {
67  id_.zside = -id_.zside;
68  DetId id = encode(id_);
69  if (valid(id))
70  return id;
71  }
72  return DetId(0);
73 }
74 
77  if (hi < totalGeomModules()) {
78  id_.zside = ((int)(hi) < kHGeomHalf_ ? -1 : 1);
79  }
80  return id_;
81 }
82 
85  FastTimeDetId id(startId);
86  id_.iPhi = id.iphi();
87  id_.iEtaZ = id.ieta();
88  id_.iType = id.type();
89  id_.zside = id.zside();
90  id_.subdet = id.subdetId();
91  return id_;
92 }
93 
95  DetId id = FastTimeDetId(id_.iType, id_.iEtaZ, id_.iPhi, id_.zside);
96  return id;
97 }
98 
99 DetId FastTimeTopology::changeXY(const DetId& id, int nrStepsX, int nrStepsY) const {
101  int iEtaZ = id_.iEtaZ + nrStepsX;
102  int iPhi = id_.iPhi + nrStepsY;
103  if (iPhi < 1)
104  iPhi += nPhi_;
105  else if (iPhi > nPhi_)
106  iPhi -= nPhi_;
107  if (id_.iType == 1 && iEtaZ < 0) {
108  iEtaZ = -iEtaZ;
109  id_.zside = -id_.zside;
110  }
111  id_.iPhi = iPhi;
112  id_.iEtaZ = iEtaZ;
113  DetId nextPoint = encode(id_);
114  if (valid(nextPoint))
115  return nextPoint;
116  else
117  return DetId(0);
118 }
119 
121 
Log< level::Info, true > LogVerbatim
int numberEtaZ(int type) const
DetId changeXY(const DetId &id, int nrStepsX, int nrStepsY) const
move the nagivator along x, y
unsigned int totalGeomModules() const
ForwardSubdetector subdet_
bool valid(const DetId &id) const override
Is this a valid cell id.
uint32_t detId2denseId(const DetId &id) const override
Dense indexing.
ForwardSubdetector
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
bool validHashIndex(uint32_t ix) const
DetId denseId2detId(uint32_t denseId) const override
unsigned int kSizeForDenseIndexing
Definition: EPCuts.h:4
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const FastTimeDDDConstants & hdcons_
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
Definition: DetId.h:17
FastTimeTopology(const FastTimeDDDConstants &hdcons, ForwardSubdetector subdet, int type)
create a new Topology
DecodedDetId decode(const DetId &id) const
DecodedDetId geomDenseId2decId(const uint32_t &hi) const
bool isValidXY(int type, int izeta, int iphi) const
virtual uint32_t detId2denseGeomId(const DetId &id) const
DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const
DetId switchZSide(const DetId startId) const
DetId encode(const DecodedDetId &id_) const
int numberPhi(int type) const