CMS 3D CMS Logo

EBDetId.h
Go to the documentation of this file.
1 #ifndef ECALDETID_EBDETID_H
2 #define ECALDETID_EBDETID_H
3 
4 #include <iosfwd>
5 #include <cmath>
6 #include <cstdlib>
10 
17 class EBDetId : public DetId {
18 public:
19  enum { Subdet = EcalBarrel };
21  EBDetId() {}
23  EBDetId(uint32_t rawid) : DetId(rawid) {}
26  // fast
27  EBDetId(int crystal_ieta, int crystal_iphi) : DetId(Ecal, EcalBarrel) {
28  id_ |= ((crystal_ieta > 0) ? (0x10000 | (crystal_ieta << 9)) : ((-crystal_ieta) << 9)) | (crystal_iphi & 0x1FF);
29  }
30  // slow
31  EBDetId(int index1, int index2, int mode);
33  EBDetId(const DetId& id) : DetId(id) {}
35  EBDetId& operator=(const DetId& id) {
36  id_ = id.rawId();
37  return *this;
38  }
39 
41  // EcalSubdetector subdet() const { return EcalSubdetector(subdetId()); }
42  static EcalSubdetector subdet() { return EcalBarrel; }
43 
45  int zside() const { return (id_ & 0x10000) ? (1) : (-1); }
47  int ietaAbs() const { return (id_ >> 9) & 0x7F; }
49  int ieta() const { return zside() * ietaAbs(); }
51  int iphi() const { return id_ & 0x1FF; }
53  int tower_ieta() const { return ((ietaAbs() - 1) / 5 + 1) * zside(); }
55  int tower_iphi() const;
59  int ism() const {
60  int id = (iphi() - 1) / kCrystalsInPhi + 1;
61  return positiveZ() ? id : id + 18;
62  }
64  int im() const {
65  int ii = (ietaAbs() - 26);
66  return ii < 0 ? 1 : (ii / 20 + 2);
67  }
69  int ic() const;
71  int ietaSM() const { return ietaAbs(); }
73  int iphiSM() const { return ((ic() - 1) % kCrystalsInPhi) + 1; }
74 
75  // is z positive?
76  bool positiveZ() const { return id_ & 0x10000; }
77  // crystal number in eta-phi grid
78  int numberByEtaPhi() const { return (MAX_IETA + (positiveZ() ? ietaAbs() - 1 : -ietaAbs())) * MAX_IPHI + iphi() - 1; }
79  // index numbering crystal by SM
80  int numberBySM() const;
82  int hashedIndex() const { return numberByEtaPhi(); }
83 
84  uint32_t denseIndex() const { return hashedIndex(); }
85 
88  EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const;
89 
92  EBDetId switchZSide() const;
93 
97  static DetId offsetBy(const DetId startId, int nrStepsEta, int nrStepsPhi);
98  static DetId switchZSide(const DetId startId);
99 
102  float approxEta() const { return ieta() * crystalUnitToEta; }
103  static float approxEta(const DetId id);
104 
105  static bool validDenseIndex(uint32_t din) { return (din < kSizeForDenseIndexing); }
106 
107  static EBDetId detIdFromDenseIndex(uint32_t di) { return unhashIndex(di); }
108 
110  static EBDetId unhashIndex(int hi) {
111  const int pseudo_eta = hi / MAX_IPHI - MAX_IETA;
112  return (validHashIndex(hi) ? EBDetId(pseudo_eta < 0 ? pseudo_eta : pseudo_eta + 1, hi % MAX_IPHI + 1) : EBDetId());
113  }
114 
115  static bool validHashIndex(int i) { return !(i < MIN_HASH || i > MAX_HASH); }
116 
118  static bool validDetId(int i, int j) {
119  return i != 0 && (std::abs(i) <= MAX_IETA) && (j >= MIN_IPHI) && (j <= MAX_IPHI);
120  }
121 
122  static bool isNextToBoundary(EBDetId id);
123 
124  static bool isNextToEtaBoundary(EBDetId id);
125 
126  static bool isNextToPhiBoundary(EBDetId id);
127 
128  //return the distance in eta units between two EBDetId
129  static int distanceEta(const EBDetId& a, const EBDetId& b);
130  //return the distance in phi units between two EBDetId
131  static int distancePhi(const EBDetId& a, const EBDetId& b);
132 
134  static const int MIN_IETA = 1;
135  static const int MIN_IPHI = 1;
136  static const int MAX_IETA = 85;
137  static const int MAX_IPHI = 360;
138  static const int kChannelsPerCard = 5;
139  static const int kTowersInPhi = 4; // per SM
140  static const int kModulesPerSM = 4;
141  static const int kModuleBoundaries[4];
142  static const int kCrystalsInPhi = 20; // per SM
143  static const int kCrystalsInEta = 85; // per SM
144  static const int kCrystalsPerSM = 1700;
145  static const int MIN_SM = 1;
146  static const int MAX_SM = 36;
147  static const int MIN_C = 1;
148  static const int MAX_C = kCrystalsPerSM;
149  static const int MIN_HASH = 0; // always 0 ...
150  static const int MAX_HASH = 2 * MAX_IPHI * MAX_IETA - 1;
151 
152  // eta coverage of one crystal (approximate)
153  static const float crystalUnitToEta;
154 
156 
157  // function modes for (int, int) constructor
158  static const int ETAPHIMODE = 0;
159  static const int SMCRYSTALMODE = 1;
160 };
161 
162 std::ostream& operator<<(std::ostream& s, const EBDetId& id);
163 
164 #endif
static const int MIN_IPHI
Definition: EBDetId.h:135
static bool isNextToEtaBoundary(EBDetId id)
Definition: EBDetId.cc:108
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:47
static EcalSubdetector subdet()
get the subdetector .i.e EcalBarrel (what else?)
Definition: EBDetId.h:42
static const int kCrystalsInEta
Definition: EBDetId.h:143
static const int MAX_HASH
Definition: EBDetId.h:150
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
int numberByEtaPhi() const
Definition: EBDetId.h:78
static const int MIN_IETA
range constants
Definition: EBDetId.h:134
static const int kTowersInPhi
Definition: EBDetId.h:139
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.h:64
static const int kCrystalsPerSM
Definition: EBDetId.h:144
uint32_t denseIndex() const
Definition: EBDetId.h:84
EBDetId()
Definition: EBDetId.h:21
int numberBySM() const
Definition: EBDetId.cc:48
float approxEta() const
Definition: EBDetId.h:102
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
static const int MIN_C
Definition: EBDetId.h:147
static const int MIN_SM
Definition: EBDetId.h:145
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:107
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:53
EBDetId(const DetId &id)
Definition: EBDetId.h:33
EBDetId(uint32_t rawid)
Definition: EBDetId.h:23
static const int kCrystalsInPhi
Definition: EBDetId.h:142
static const int MAX_C
Definition: EBDetId.h:148
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
bool positiveZ() const
Definition: EBDetId.h:76
Definition: EPCuts.h:4
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:106
static const int MIN_HASH
Definition: EBDetId.h:149
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:113
static const int kModulesPerSM
Definition: EBDetId.h:140
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kModuleBoundaries[4]
Definition: EBDetId.h:141
static const float crystalUnitToEta
Definition: EBDetId.h:153
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:45
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:100
EBDetId(int crystal_ieta, int crystal_iphi)
Definition: EBDetId.h:27
static const int ETAPHIMODE
Definition: EBDetId.h:158
EBDetId switchZSide() const
Definition: EBDetId.cc:72
ii
Definition: cuy.py:589
std::ostream & operator<<(std::ostream &s, const EBDetId &id)
Definition: EBDetId.cc:146
Definition: DetId.h:17
static const int MAX_IPHI
Definition: EBDetId.h:137
uint32_t id_
Definition: DetId.h:69
static const int MAX_IETA
Definition: EBDetId.h:136
double b
Definition: hdecay.h:120
static const int kChannelsPerCard
Definition: EBDetId.h:138
static bool validHashIndex(int i)
Definition: EBDetId.h:115
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:50
double a
Definition: hdecay.h:121
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
int iphiSM() const
get the crystal iphi (1-20)
Definition: EBDetId.h:73
EBDetId & operator=(const DetId &id)
Definition: EBDetId.h:35
static const int MAX_SM
Definition: EBDetId.h:146
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
EcalSubdetector
int ietaSM() const
get the crystal ieta in the SM convention (1-85)
Definition: EBDetId.h:71
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:105