CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCastorDetId.cc
Go to the documentation of this file.
4 
6 
7 HcalCastorDetId::HcalCastorDetId(uint32_t rawid) : DetId(rawid) {}
8 
9 void
11  bool true_for_positive_eta,
12  int sector,
13  int module )
14 {
15  sector -= 1; // we count sector from 1-16 instead of 0-15
16  id_ |= ( true_for_positive_eta << 8 ) | ( sector << 4 ) | module;
17 }
18 
20  bool true_for_positive_eta,
21  int sector,
22  int module )
23  : DetId(DetId::Calo, SubdetectorId)
24 {
25  buildMe( section, true_for_positive_eta, sector, module ) ;
26 }
27 
28 
29 HcalCastorDetId::HcalCastorDetId( bool true_for_positive_eta,
30  int sector,
31  int module )
32  : DetId( DetId::Calo, SubdetectorId )
33 {
34  buildMe( Section(Unknown), true_for_positive_eta, sector, module ) ;
35 }
36 
38 {
39  if( !gen.null() &&
40  ( gen.det() != DetId::Calo ||
41  gen.subdetId() != SubdetectorId ) )
42  {
43  throw cms::Exception("Invalid DetId") << "Cannot initialize CASTORDetId from " << std::hex << gen.rawId() << std::dec;
44  }
45  id_= gen.rawId();
46 }
47 
50 {
51  if( !gen.null() &&
52  ( gen.det() != DetId::Calo ||
53  gen.subdetId() != SubdetectorId ) )
54  {
55  throw cms::Exception("Invalid DetId") << "Cannot assign Castor DetId from " << std::hex << gen.rawId() << std::dec;
56  }
57 
58  id_ = gen.rawId();
59 
60  return *this;
61 }
62 
63 /*
64 int HcalCastorDetId::channel() const {
65  int channelid = 16*(sector-1)+module;
66  return channelid;
67 }
68 */
69 
72 {
73  const int mod = module();
74 
75  Section sect ;
76  if ( mod <= 2 )
77  {
78  sect = HcalCastorDetId::EM ;
79  }
80  else
81  {
82  if( mod > 2 && mod <= 14 )
83  {
84  sect = HcalCastorDetId::HAD ;
85  }
86  else
87  {
89  }
90  }
91  return sect ;
92 }
93 
94 uint32_t
96 {
97  return ( kNumberCellsPerEnd*( zside() + 1 )/2 +
98  kNumberSectorsPerEnd*( module() - 1 ) + sector() - 1 ) ;
99 }
100 
101 bool
103  bool posEta,
104  int iSector,
105  int iModule )
106 {
107  return ( 0 < iSector &&
108  kNumberSectorsPerEnd >= iSector &&
109  0 < iModule &&
110  kNumberModulesPerEnd >= iModule ) ;
111 }
112 
115 {
116  return HcalCastorDetId( kNumberCellsPerEnd <= di ,
117  di%kNumberSectorsPerEnd + 1 ,
119 }
120 
121 std::ostream& operator<<(std::ostream& s,const HcalCastorDetId& id)
122 {
123  s << "(CASTOR" << ((id.zside()==1)?("+"):("-"));
124 
125  switch (id.section())
126  {
127  case(HcalCastorDetId::EM) : s << " EM "; break;
128  case(HcalCastorDetId::HAD) : s << " HAD "; break;
129  default : s <<" UNKNOWN ";
130  }
131 
132  return s << id.sector() << ',' << id.module() << ',' << ')';
133 }
134 
static bool validDetId(Section iSection, bool posEta, int iSector, int iMod)
int sector() const
get the sector (1-16)
void buildMe(Section section, bool true_for_positive_eta, int sector, int module)
int module() const
get the module (1-2 for EM, 1-12 for HAD)
uint32_t denseIndex() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
Section section() const
get the section
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
static HcalCastorDetId detIdFromDenseIndex(uint32_t di)
int zside() const
get the z-side of the cell (1/-1)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
static const int SubdetectorId
HcalCastorDetId & operator=(const DetId &id)
Definition: DetId.h:20
uint32_t id_
Definition: DetId.h:57
bool null() const
is this a null id ?
Definition: DetId.h:47
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
Definition: vlib.h:209