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
EBDetId::kCrystalsInPhi
static const int kCrystalsInPhi
Definition: EBDetId.h:142
EBDetId::crystalUnitToEta
static const float crystalUnitToEta
Definition: EBDetId.h:153
EBDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
EBDetId::positiveZ
bool positiveZ() const
Definition: EBDetId.h:76
EBDetId::isNextToEtaBoundary
static bool isNextToEtaBoundary(EBDetId id)
Definition: EBDetId.cc:108
EBDetId::kCrystalsPerSM
static const int kCrystalsPerSM
Definition: EBDetId.h:144
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
mps_fire.i
i
Definition: mps_fire.py:428
EBDetId::Subdet
Definition: EBDetId.h:19
EBDetId::isNextToBoundary
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:106
EBDetId::EBDetId
EBDetId()
Definition: EBDetId.h:21
EBDetId::kCrystalsInEta
static const int kCrystalsInEta
Definition: EBDetId.h:143
EBDetId::approxEta
float approxEta() const
Definition: EBDetId.h:102
EBDetId::ic
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
EBDetId::kModuleBoundaries
static const int kModuleBoundaries[4]
Definition: EBDetId.h:141
EBDetId
Definition: EBDetId.h:17
EBDetId::MAX_SM
static const int MAX_SM
Definition: EBDetId.h:146
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
EBDetId::im
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.h:64
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalBarrel
Definition: EcalSubdetector.h:10
EBDetId::kModulesPerSM
static const int kModulesPerSM
Definition: EBDetId.h:140
DetId
Definition: DetId.h:17
EBDetId::zside
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:45
alignCSCRings.s
s
Definition: alignCSCRings.py:92
EBDetId::tower_ieta
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:53
EBDetId::tower
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
EBDetId::EBDetId
EBDetId(const DetId &id)
Definition: EBDetId.h:33
EBDetId::MAX_IPHI
static const int MAX_IPHI
Definition: EBDetId.h:137
b
double b
Definition: hdecay.h:118
EBDetId::MIN_IETA
static const int MIN_IETA
range constants
Definition: EBDetId.h:134
EcalTrigTowerDetId.h
EcalSubdetector.h
EBDetId::ETAPHIMODE
static const int ETAPHIMODE
Definition: EBDetId.h:158
EBDetId::tower_iphi
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:100
EBDetId::numberBySM
int numberBySM() const
Definition: EBDetId.cc:48
a
double a
Definition: hdecay.h:119
cropTnPTrees.din
din
Definition: cropTnPTrees.py:30
DetId::id_
uint32_t id_
Definition: DetId.h:69
operator<<
std::ostream & operator<<(std::ostream &s, const EBDetId &id)
Definition: EBDetId.cc:146
EBDetId::distanceEta
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:118
EBDetId::detIdFromDenseIndex
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:107
EBDetId::validDenseIndex
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:105
EBDetId::MAX_C
static const int MAX_C
Definition: EBDetId.h:148
EBDetId::kChannelsPerCard
static const int kChannelsPerCard
Definition: EBDetId.h:138
EBDetId::kTowersInPhi
static const int kTowersInPhi
Definition: EBDetId.h:139
EBDetId::validHashIndex
static bool validHashIndex(int i)
Definition: EBDetId.h:115
EBDetId::denseIndex
uint32_t denseIndex() const
Definition: EBDetId.h:84
EBDetId::MAX_HASH
static const int MAX_HASH
Definition: EBDetId.h:150
EBDetId::offsetBy
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:50
DetId::Ecal
Definition: DetId.h:27
EBDetId::MIN_SM
static const int MIN_SM
Definition: EBDetId.h:145
EBDetId::validDetId
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
EBDetId::isNextToPhiBoundary
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:113
hi
Definition: EPCuts.h:4
EBDetId::operator=
EBDetId & operator=(const DetId &id)
Definition: EBDetId.h:35
EBDetId::MIN_C
static const int MIN_C
Definition: EBDetId.h:147
EBDetId::numberByEtaPhi
int numberByEtaPhi() const
Definition: EBDetId.h:78
EBDetId::switchZSide
EBDetId switchZSide() const
Definition: EBDetId.cc:72
DetId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EBDetId::iphiSM
int iphiSM() const
get the crystal iphi (1-20)
Definition: EBDetId.h:73
EBDetId::ietaAbs
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:47
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
EBDetId::subdet
static EcalSubdetector subdet()
get the subdetector .i.e EcalBarrel (what else?)
Definition: EBDetId.h:42
EBDetId::ism
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
EBDetId::MIN_HASH
static const int MIN_HASH
Definition: EBDetId.h:149
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EBDetId::distancePhi
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:125
EBDetId::EBDetId
EBDetId(uint32_t rawid)
Definition: EBDetId.h:23
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EBDetId::ietaSM
int ietaSM() const
get the crystal ieta in the SM convention (1-85)
Definition: EBDetId.h:71
EBDetId::SMCRYSTALMODE
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
cuy.ii
ii
Definition: cuy.py:590
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136
EBDetId::EBDetId
EBDetId(int crystal_ieta, int crystal_iphi)
Definition: EBDetId.h:27
EBDetId::MIN_IPHI
static const int MIN_IPHI
Definition: EBDetId.h:135