CMS 3D CMS Logo

EcalTrigTowerDetId.cc
Go to the documentation of this file.
3 #include <cassert>
4 
6 
7 EcalTrigTowerDetId::EcalTrigTowerDetId(uint32_t rawid) : DetId(rawid) {}
8 
11  int tower_i = 0;
12  int tower_j = 0;
13 
14  if (mode == SUBDETIJMODE) {
15  tower_i = i;
16  tower_j = j;
17  } else if (mode == SUBDETDCCTTMODE) {
18  throw cms::Exception("InvalidDetId")
19  << "EcalTriggerTowerDetId: Cannot create object. SUBDETDCCTTMODE not yet implemented.";
20  } else
21  throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId: Cannot create object. Unknown mode for (int, "
22  "EcalSubdetector, int, int) constructor.";
23 
24  if (tower_i > MAX_I || tower_i < MIN_I || tower_j > MAX_J || tower_j < MIN_J)
25  throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId: Cannot create object. Indexes out of bounds.";
26 
27  id_ |= ((zside > 0) ? (0x8000) : (0x0)) | ((subDet == EcalBarrel) ? (0x4000) : (0x0)) | (tower_i << 7) |
28  (tower_j & 0x7F);
29 }
30 
32  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalTriggerTower)) {
33  throw cms::Exception("InvalidDetId");
34  }
35  id_ = gen.rawId();
36 }
37 
39  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalTriggerTower)) {
40  throw cms::Exception("InvalidDetId");
41  }
42  id_ = gen.rawId();
43  return *this;
44 }
45 
46 //New SM numbering scheme. Avoids discontinuity in phi crossing \eta=0
48  if (subDet() == EcalBarrel) {
49  //Correction since iphi is uniformized with HB convention
50  int iphi_simple = iphi() + 2;
51  if (iphi_simple > 72)
52  iphi_simple = iphi_simple % 72;
53  int id = (iphi_simple - 1) / kEBTowersInPhi + 1;
54  if (zside() < 0)
55  id += 18;
56  return id;
57  } else
58  throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iDCC not yet implemented";
59 }
60 
62  if (subDet() == EcalBarrel) {
63  int ie = ietaAbs() - 1;
64  int ip;
65  int iphi_simple = iphi() + 2;
66  if (iphi_simple > 72)
67  iphi_simple = iphi_simple % 72;
68  if (zside() < 0) {
69  ip = ((iphi_simple - 1) % kEBTowersInPhi) + 1;
70  } else {
71  ip = kEBTowersInPhi - ((iphi_simple - 1) % kEBTowersInPhi);
72  }
73 
74  return (ie * kEBTowersInPhi) + ip;
75  } else
76  throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iTT not yet implemented";
77 }
78 
80  if (subDet() == EcalEndcap)
81  return int((iphi() - 1) / kEETowersInPhiPerQuadrant) + 1;
82  else
83  throw cms::Exception("MethodNotApplicable") << "EcalTriggerTowerDetId: iquadrant not applicable";
84 }
85 
87  return (
88  1 == abs(iz) && 0 < i && 0 < j && kEETowersInPhiPerEndcap >= j &&
89  ((EcalBarrel == sd && kEBTowersInEta >= i) || (EcalEndcap == sd && kEEOuterEta <= i && kEEInnerEta >= i &&
90  (27 > i || ((0 > iz && 0 == j % 2) || (0 < iz && 1 == j % 2))))));
91 }
92 
94  const unsigned int iea(ietaAbs());
95  const unsigned int iph(iphi());
96  return (subDet() == EcalBarrel ? (iDCC() - 1) * kEBTowersPerSM + iTT() - 1
97  : kEBTotalTowers + ((zside() + 1) / 2) * kEETowersPerEndcap +
98  ((iea < 27 ? iea : 27) - kEEOuterEta) * kEETowersInPhiPerEndcap +
99  (iea < 27 ? iph : // for iphi=27,28 only half TT present, odd for EE-, even EE+
100  (iea - 27) * kEETowersInPhiPerEndcap / 2 + (iph + 1) / 2) -
101  1);
102 }
103 
106  const int iz(di < kEBTotalTowers ? (di < kEBHalfTowers ? 1 : -1)
107  : (di - kEBTotalTowers < kEETowersPerEndcap ? -1 : 1));
108  int i;
109  int j;
110  if (di < kEBTotalTowers) // barrel
111  {
112  const unsigned int itt(di % kEBTowersPerSM);
113  const unsigned int idc(di / kEBTowersPerSM);
114  j = (idc % 18) * kEBTowersInPhi + ((1 + iz) / 2) * kEBTowersInPhi - iz * (itt % kEBTowersInPhi) + 1 - (1 + iz) / 2 -
115  2;
116  if (j < 1)
117  j += 72;
118  i = 1 + itt / kEBTowersInPhi;
119  } else {
120  const int eonly((di - kEBTotalTowers) % kEETowersPerEndcap);
121  i = kEEOuterEta + eonly / kEETowersInPhiPerEndcap;
122  j = 1 + eonly % kEETowersInPhiPerEndcap;
123  if (27 == i) // last two rings have half of normal phi elementes
124  {
125  if (j > kEETowersInPhiPerEndcap / 2) {
126  ++i;
127  j -= kEETowersInPhiPerEndcap / 2;
128  }
129  j = 2 * j;
130  if (0 < iz)
131  --j;
132  }
133  }
134  assert(validDetId(iz, sd, i, j));
135  return EcalTrigTowerDetId(iz, sd, i, j);
136 }
137 
138 #include <ostream>
139 std::ostream& operator<<(std::ostream& s, const EcalTrigTowerDetId& id) {
140  return s << "(EcalTT subDet " << ((id.subDet() == EcalBarrel) ? ("Barrel") : ("Endcap")) << " iz "
141  << ((id.zside() > 0) ? ("+ ") : ("- ")) << " ieta " << id.ietaAbs() << " iphi " << id.iphi() << ')';
142 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
constexpr bool null() const
is this a null id ?
Definition: DetId.h:52
static const int SUBDETIJMODE
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
static const int kEBTowersInPhi
static const int MIN_J
int iDCC() const
get the ECAL DCC id - in the barrrel ism == iDCC
static const int MAX_J
int zside() const
get the z-side of the tower (1/-1)
static const int kEETowersInPhiPerQuadrant
int ietaAbs() const
get the absolute value of the tower ieta
EcalTrigTowerDetId & operator=(const DetId &id)
static const int MAX_I
static const int kEBTowersInEta
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::ostream & operator<<(std::ostream &s, const EcalTrigTowerDetId &id)
Definition: DetId.h:18
int iphi() const
get the tower iphi
static const int SUBDETDCCTTMODE
double sd
uint32_t id_
Definition: DetId.h:62
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
int iTT() const
sequential index within one DCC
static const int kEBTowersPerSM
EcalSubdetector
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39