CMS 3D CMS Logo

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