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 
10  : DetId(Ecal, EcalTriggerTower) {
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);
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 }
EcalTrigTowerDetId::MAX_I
static const int MAX_I
Definition: EcalTrigTowerDetId.h:97
EcalTrigTowerDetId::SUBDETIJMODE
static const int SUBDETIJMODE
Definition: EcalTrigTowerDetId.h:107
mps_fire.i
i
Definition: mps_fire.py:355
EcalTrigTowerDetId::iphi
int iphi() const
get the tower iphi
Definition: EcalTrigTowerDetId.h:52
EcalTrigTowerDetId::kEETowersInPhiPerEndcap
Definition: EcalTrigTowerDetId.h:111
EcalTrigTowerDetId::ietaAbs
int ietaAbs() const
get the absolute value of the tower ieta
Definition: EcalTrigTowerDetId.h:36
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EcalTrigTowerDetId::MAX_J
static const int MAX_J
Definition: EcalTrigTowerDetId.h:98
EcalTrigTowerDetId::iquadrant
int iquadrant() const
Definition: EcalTrigTowerDetId.cc:79
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
EcalTrigTowerDetId::SUBDETDCCTTMODE
static const int SUBDETDCCTTMODE
Definition: EcalTrigTowerDetId.h:108
cms::cuda::assert
assert(be >=bs)
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalTrigTowerDetId::iTT
int iTT() const
sequential index within one DCC
Definition: EcalTrigTowerDetId.cc:61
EcalTrigTowerDetId::zside
int zside() const
get the z-side of the tower (1/-1)
Definition: EcalTrigTowerDetId.h:30
EcalBarrel
Definition: EcalSubdetector.h:10
EcalTrigTowerDetId::EcalTrigTowerDetId
EcalTrigTowerDetId()
Definition: EcalTrigTowerDetId.cc:5
DetId
Definition: DetId.h:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
EcalTrigTowerDetId::kEETowersPerEndcap
Definition: EcalTrigTowerDetId.h:117
operator<<
std::ostream & operator<<(std::ostream &s, const EcalTrigTowerDetId &id)
Definition: EcalTrigTowerDetId.cc:139
EcalTrigTowerDetId::kEBTowersInPhi
static const int kEBTowersInPhi
Definition: EcalTrigTowerDetId.h:100
gen
Definition: PythiaDecays.h:13
EcalTrigTowerDetId::MIN_J
static const int MIN_J
Definition: EcalTrigTowerDetId.h:96
EcalTrigTowerDetId.h
EcalEndcap
Definition: EcalSubdetector.h:10
DetId::id_
uint32_t id_
Definition: DetId.h:69
EcalTrigTowerDetId::validDetId
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
Definition: EcalTrigTowerDetId.cc:86
createfilelist.int
int
Definition: createfilelist.py:10
EcalTrigTowerDetId::iDCC
int iDCC() const
get the ECAL DCC id - in the barrrel ism == iDCC
Definition: EcalTrigTowerDetId.cc:47
EcalTrigTowerDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: EcalTrigTowerDetId.cc:93
DetId::Ecal
Definition: DetId.h:27
EcalTrigTowerDetId::subDet
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
Definition: EcalTrigTowerDetId.h:33
EcalTrigTowerDetId::kEBTotalTowers
Definition: EcalTrigTowerDetId.h:116
EcalTrigTowerDetId::kEBTowersPerSM
static const int kEBTowersPerSM
Definition: EcalTrigTowerDetId.h:101
EcalTriggerTower
Definition: EcalSubdetector.h:10
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Exception
Definition: hltDiff.cc:246
EcalTrigTowerDetId::kEBHalfTowers
Definition: EcalTrigTowerDetId.h:115
Exception.h
EcalTrigTowerDetId::detIdFromDenseIndex
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
Definition: EcalTrigTowerDetId.cc:104
sd
double sd
Definition: CascadeWrapper.h:113
EcalTrigTowerDetId::kEETowersInPhiPerQuadrant
static const int kEETowersInPhiPerQuadrant
Definition: EcalTrigTowerDetId.h:104
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalTrigTowerDetId::operator=
EcalTrigTowerDetId & operator=(const DetId &id)
Definition: EcalTrigTowerDetId.cc:38
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EcalTrigTowerDetId::kEBTowersInEta
static const int kEBTowersInEta
Definition: EcalTrigTowerDetId.h:102
EcalTrigTowerDetId::kEEOuterEta
Definition: EcalTrigTowerDetId.h:112