CMS 3D CMS Logo

EcalTrigTowerDetId.cc
Go to the documentation of this file.
3 #include <cassert>
4 
6 }
7 
8 
9 EcalTrigTowerDetId::EcalTrigTowerDetId(uint32_t rawid) : DetId(rawid) {
10 }
11 
14 {
15  int tower_i=0;
16  int tower_j=0;
17 
18  if (mode == SUBDETIJMODE)
19  {
20  tower_i=i;
21  tower_j=j;
22  }
23  else if (mode == SUBDETDCCTTMODE)
24  {
25  throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId: Cannot create object. SUBDETDCCTTMODE not yet implemented.";
26  }
27  else
28  throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId: Cannot create object. Unknown mode for (int, EcalSubdetector, int, int) constructor.";
29 
30  if (tower_i > MAX_I || tower_i < MIN_I || tower_j > MAX_J || tower_j < MIN_J)
31  throw cms::Exception("InvalidDetId") << "EcalTriggerTowerDetId: Cannot create object. Indexes out of bounds.";
32 
33  id_|= ((zside>0)?(0x8000):(0x0)) | ((subDet == EcalBarrel)?(0x4000):(0x0)) | (tower_i<<7) | (tower_j & 0x7F);
34 
35 }
36 
38 {
39  if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalTriggerTower )) {
40  throw cms::Exception("InvalidDetId"); }
41  id_=gen.rawId();
42 }
43 
45  if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalTriggerTower )) {
46  throw cms::Exception("InvalidDetId");
47  }
48  id_=gen.rawId();
49  return *this;
50 }
51 
52 //New SM numbering scheme. Avoids discontinuity in phi crossing \eta=0
54 {
55  if ( subDet() == EcalBarrel )
56  {
57  //Correction since iphi is uniformized with HB convention
58  int iphi_simple = iphi() + 2 ;
59  if (iphi_simple > 72 ) iphi_simple = iphi_simple % 72;
60  int id = ( iphi_simple - 1 ) / kEBTowersInPhi + 1;
61  if ( zside() < 0 ) id += 18;
62  return id;
63  }
64  else
65  throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iDCC not yet implemented";
66 }
67 
69 {
70  if ( subDet() == EcalBarrel )
71  {
72  int ie = ietaAbs() -1;
73  int ip;
74  int iphi_simple = iphi() + 2 ;
75  if (iphi_simple > 72 ) iphi_simple = iphi_simple % 72;
76  if (zside() < 0) {
77  ip = (( iphi_simple -1 ) % kEBTowersInPhi ) + 1;
78  } else {
79  ip = kEBTowersInPhi - ((iphi_simple -1 ) % kEBTowersInPhi );
80  }
81 
82  return (ie * kEBTowersInPhi) + ip;
83  }
84  else
85  throw cms::Exception("MethodNotImplemented") << "EcalTriggerTowerDetId: iTT not yet implemented";
86 }
87 
89 {
90  if ( subDet() == EcalEndcap )
91  return int((iphi()-1)/kEETowersInPhiPerQuadrant)+1;
92  else
93  throw cms::Exception("MethodNotApplicable") << "EcalTriggerTowerDetId: iquadrant not applicable";
94 }
95 
96 bool
98 {
99  return ( 1 == abs( iz ) &&
100  0 < i &&
101  0 < j &&
103  ( ( EcalBarrel == sd &&
104  kEBTowersInEta >= i ) ||
105  ( EcalEndcap == sd &&
106  kEEOuterEta <= i &&
107  kEEInnerEta >= i &&
108  ( 27 > i ||
109  ( ( 0 > iz &&
110  0 == j%2 ) ||
111  ( 0 < iz &&
112  1 == j%2 ) ) ) ) ) ) ;
113 
114 }
115 
116 int
118 {
119  const unsigned int iea ( ietaAbs() ) ;
120  const unsigned int iph ( iphi() ) ;
121  return ( subDet() == EcalBarrel ?
122  ( iDCC() - 1 )*kEBTowersPerSM + iTT() - 1 :
123  kEBTotalTowers + ( ( zside() + 1 )/2 )*kEETowersPerEndcap +
124  ( ( iea < 27 ? iea : 27 ) - kEEOuterEta )*kEETowersInPhiPerEndcap +
125  ( iea < 27 ? iph : // for iphi=27,28 only half TT present, odd for EE-, even EE+
126  ( iea - 27 )*kEETowersInPhiPerEndcap/2 + ( iph + 1 )/2 ) - 1 ) ;
127 }
128 
131 {
133  const int iz ( di < kEBTotalTowers ?
134  ( di < kEBHalfTowers ? 1 : -1 ) :
135  ( di - kEBTotalTowers < kEETowersPerEndcap ? -1 : 1 ) ) ;
136  int i ;
137  int j ;
138  if( di < kEBTotalTowers ) // barrel
139  {
140  const unsigned int itt ( di%kEBTowersPerSM ) ;
141  const unsigned int idc ( di/kEBTowersPerSM ) ;
142  j = (idc%18)*kEBTowersInPhi +
143  ( (1+iz)/2 )*kEBTowersInPhi -
144  iz*(itt%kEBTowersInPhi) + 1 - (1+iz)/2 - 2 ;
145  if( j < 1 ) j += 72 ;
146  i = 1 + itt/kEBTowersInPhi ;
147  }
148  else
149  {
150  const int eonly ( ( di - kEBTotalTowers )%kEETowersPerEndcap ) ;
152  j = 1 + eonly%kEETowersInPhiPerEndcap ;
153  if( 27 == i ) // last two rings have half of normal phi elementes
154  {
155  if( j > kEETowersInPhiPerEndcap/2 )
156  {
157  ++i ;
158  j -= kEETowersInPhiPerEndcap/2 ;
159  }
160  j = 2*j ;
161  if( 0 < iz ) --j ;
162  }
163  }
164  assert( validDetId( iz, sd, i, j ) ) ;
165  return EcalTrigTowerDetId( iz, sd, i, j ) ;
166 }
167 
168 #include <ostream>
169 std::ostream& operator<<(std::ostream& s,const EcalTrigTowerDetId& id) {
170  return s << "(EcalTT subDet " << ((id.subDet()==EcalBarrel)?("Barrel"):("Endcap"))
171  << " iz " << ((id.zside()>0)?("+ "):("- ")) << " ieta "
172  << id.ietaAbs() << " iphi " << id.iphi() << ')';
173 }
174 
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