CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBDetId.h
Go to the documentation of this file.
1 #ifndef ECALDETID_EBDETID_H
2 #define ECALDETID_EBDETID_H
3 
4 #include <ostream>
5 #include <cmath>
6 #include <cstdlib>
10 
11 
20 class EBDetId : public DetId {
21  public:
22  enum { Subdet=EcalBarrel};
24  EBDetId() {}
26  EBDetId(uint32_t rawid) : DetId(rawid) {}
29  EBDetId(int index1, int index2, int mode = ETAPHIMODE);
31  EBDetId(const DetId& id);
33  EBDetId& operator=(const DetId& id);
34 
36  // EcalSubdetector subdet() const { return EcalSubdetector(subdetId()); }
37  static EcalSubdetector subdet() { return EcalBarrel;}
38 
40  int zside() const { return (id_&0x10000)?(1):(-1); }
42  int ietaAbs() const { return (id_>>9)&0x7F; }
44  int ieta() const { return zside()*ietaAbs(); }
46  int iphi() const { return id_&0x1FF; }
48  int tower_ieta() const { return ((ietaAbs()-1)/5+1)*zside(); }
50  int tower_iphi() const;
54  int ism() const;
56  int im() const;
58  int ic() const;
60  int ietaSM() const { return ietaAbs(); }
62  int iphiSM() const { return (( ic() -1 ) % kCrystalsInPhi ) + 1; }
63 
64  // is z positive?
65  bool positiveZ() const { return id_&0x10000;}
66  // crystal number in eta-phi grid
67  int numberByEtaPhi() const {
68  return (MAX_IETA + (positiveZ() ? ietaAbs()-1 : -ietaAbs()) )*MAX_IPHI+ iphi()-1;
69  }
70  // index numbering crystal by SM
71  int numberBySM() const;
73  int hashedIndex() const { return numberByEtaPhi(); }
74 
75  uint32_t denseIndex() const { return hashedIndex() ; }
76 
79  EBDetId offsetBy( int nrStepsEta, int nrStepsPhi ) const;
80 
83  EBDetId switchZSide() const;
84 
88  static DetId offsetBy( const DetId startId, int nrStepsEta, int nrStepsPhi );
89  static DetId switchZSide( const DetId startId );
90 
93  float approxEta() const { return ieta() * crystalUnitToEta; }
94  static float approxEta( const DetId id );
95 
96  static bool validDenseIndex( uint32_t din ) { return ( din < kSizeForDenseIndexing ) ; }
97 
98  static EBDetId detIdFromDenseIndex( uint32_t di ) { return unhashIndex( di ) ; }
99 
101  static EBDetId unhashIndex( int hi ) ;
102 
103  static bool validHashIndex(int i) { return !(i<MIN_HASH || i>MAX_HASH); }
104 
106  static bool validDetId(int i, int j) ;
107 
108  static bool isNextToBoundary(EBDetId id);
109 
110  static bool isNextToEtaBoundary(EBDetId id);
111 
112  static bool isNextToPhiBoundary(EBDetId id);
113 
114  //return the distance in eta units between two EBDetId
115  static int distanceEta(const EBDetId& a,const EBDetId& b);
116  //return the distance in phi units between two EBDetId
117  static int distancePhi(const EBDetId& a,const EBDetId& b);
118 
120  static const int MIN_IETA = 1;
121  static const int MIN_IPHI = 1;
122  static const int MAX_IETA = 85;
123  static const int MAX_IPHI = 360;
124  static const int kChannelsPerCard = 5;
125  static const int kTowersInPhi = 4; // per SM
126  static const int kModulesPerSM = 4;
127  static const int kModuleBoundaries[4] ;
128  static const int kCrystalsInPhi = 20; // per SM
129  static const int kCrystalsInEta = 85; // per SM
130  static const int kCrystalsPerSM = 1700;
131  static const int MIN_SM = 1;
132  static const int MAX_SM = 36;
133  static const int MIN_C = 1;
134  static const int MAX_C = kCrystalsPerSM;
135  static const int MIN_HASH = 0; // always 0 ...
136  static const int MAX_HASH = 2*MAX_IPHI*MAX_IETA-1;
137 
138  // eta coverage of one crystal (approximate)
139  static const float crystalUnitToEta;
140 
142 
143 
144  // function modes for (int, int) constructor
145  static const int ETAPHIMODE = 0;
146  static const int SMCRYSTALMODE = 1;
147 };
148 
149 std::ostream& operator<<(std::ostream& s,const EBDetId& id);
150 
151 
152 #endif
float approxEta() const
Definition: EBDetId.h:93
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.cc:59
int i
Definition: DBlmapReader.cc:9
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:73
static const int MIN_IPHI
Definition: EBDetId.h:121
static bool isNextToEtaBoundary(EBDetId id)
Definition: EBDetId.cc:175
static EcalSubdetector subdet()
get the subdetector .i.e EcalBarrel (what else?)
Definition: EBDetId.h:37
static const int kCrystalsInEta
Definition: EBDetId.h:129
static const int MAX_HASH
Definition: EBDetId.h:136
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:48
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:164
EBDetId switchZSide() const
Definition: EBDetId.cc:132
#define abs(x)
Definition: mlp_lapack.h:159
static const int MIN_IETA
range constants
Definition: EBDetId.h:120
int numberBySM() const
Definition: EBDetId.cc:107
static const int kTowersInPhi
Definition: EBDetId.h:125
static const int kCrystalsPerSM
Definition: EBDetId.h:130
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
EBDetId()
Definition: EBDetId.h:24
int ism() const
get the ECAL/SM id
Definition: EBDetId.cc:79
int iphiSM() const
get the crystal iphi (1-20)
Definition: EBDetId.h:62
static const int MIN_C
Definition: EBDetId.h:133
static const int MIN_SM
Definition: EBDetId.h:131
int iphi() const
get the crystal iphi
Definition: EBDetId.h:46
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:98
EBDetId(uint32_t rawid)
Definition: EBDetId.h:26
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.cc:85
static const int kCrystalsInPhi
Definition: EBDetId.h:128
static const int MAX_C
Definition: EBDetId.h:134
static int distanceEta(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:185
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:171
static const int MIN_HASH
Definition: EBDetId.h:135
static int distancePhi(const EBDetId &a, const EBDetId &b)
Definition: EBDetId.cc:193
static bool isNextToPhiBoundary(EBDetId id)
Definition: EBDetId.cc:180
static const int kModulesPerSM
Definition: EBDetId.h:126
int j
Definition: DBlmapReader.cc:9
static const int kModuleBoundaries[4]
Definition: EBDetId.h:127
static const float crystalUnitToEta
Definition: EBDetId.h:139
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:52
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:111
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
EBDetId & operator=(const DetId &id)
Definition: EBDetId.cc:70
static const int ETAPHIMODE
Definition: EBDetId.h:145
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:94
int numberByEtaPhi() const
Definition: EBDetId.h:67
Definition: DetId.h:20
bool positiveZ() const
Definition: EBDetId.h:65
static const int MAX_IPHI
Definition: EBDetId.h:123
uint32_t id_
Definition: DetId.h:57
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.cc:12
static const int MAX_IETA
Definition: EBDetId.h:122
int mode
Definition: AMPTWrapper.h:139
double b
Definition: hdecay.h:120
static const int kChannelsPerCard
Definition: EBDetId.h:124
static bool validHashIndex(int i)
Definition: EBDetId.h:103
int ietaSM() const
get the crystal ieta in the SM convention (1-85)
Definition: EBDetId.h:60
double a
Definition: hdecay.h:121
static const int MAX_SM
Definition: EBDetId.h:132
string s
Definition: asciidump.py:422
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
EcalSubdetector
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:42
uint32_t denseIndex() const
Definition: EBDetId.h:75
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:96
int zside() const
get the z-side of the crystal (1/-1)
Definition: EBDetId.h:40