CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalZDCDetId.cc
Go to the documentation of this file.
3 
5 }
6 
7 
8 HcalZDCDetId::HcalZDCDetId(uint32_t rawid) : DetId(rawid) {
9 }
10 
11 HcalZDCDetId::HcalZDCDetId(Section section, bool true_for_positive_eta, int channel) : DetId(DetId::Calo,SubdetectorId) {
12  id_|=(section&0x3)<<4;
13  if (true_for_positive_eta) id_|=0x40;
14  id_|=channel&0xF;
15 }
16 
18  if (!gen.null() && (gen.det()!=Calo || gen.subdetId()!=SubdetectorId)) {
19  throw cms::Exception("Invalid DetId") << "Cannot initialize ZDCDetId from " << std::hex << gen.rawId() << std::dec;
20  }
21  id_=gen.rawId();
22 }
23 
25  if (!gen.null() && (gen.det()!=Calo || gen.subdetId()!=SubdetectorId)) {
26  throw cms::Exception("Invalid DetId") << "Cannot assign ZDCDetId from " << std::hex << gen.rawId() << std::dec;
27  }
28  id_=gen.rawId();
29  return *this;
30 }
31 
32 uint32_t
34 {
35  const int se ( section() ) ;
36  return ( ( zside()<0 ? 0 : kDepTot ) + channel() - 1 +
37  ( se == HAD ? kDepEM :
38  ( se == LUM ? kDepEM + kDepHAD : 0 ) ) ) ;
39 }
40 
43 {
44  if( validDenseIndex( di ) )
45  {
46  const bool lz ( di >= kDepTot ) ;
47  const uint32_t in ( di%kDepTot ) ;
48  const Section se ( in<kDepEM ? EM :
49  ( in<kDepEM+kDepHAD ? HAD : LUM ) ) ;
50  const uint32_t dp ( EM == se ? in+1 :
51  ( HAD == se ? in - kDepEM + 1 : in - kDepEM - kDepHAD + 1 ) ) ;
52  return HcalZDCDetId( se, lz, dp ) ;
53  }
54  else
55  {
56  return HcalZDCDetId() ;
57  }
58 }
59 
60 bool
62  int dp )
63 {
64  return ( dp >= 1 && (
65  ( ( se == EM ) &&
66  ( dp <= kDepEM ) ) ||
67  ( ( se == HAD ) &&
68  ( dp <= kDepHAD ) ) ||
69  ( ( se == LUM ) &&
70  ( dp <= kDepLUM ) )
71  )
72  ) ;
73 }
74 
75 std::ostream& operator<<(std::ostream& s,const HcalZDCDetId& id) {
76  s << "(ZDC" << ((id.zside()==1)?("+"):("-"));
77  switch (id.section()) {
78  case(HcalZDCDetId::EM) : s << " EM "; break;
79  case(HcalZDCDetId::HAD) : s << " HAD "; break;
80  case(HcalZDCDetId::LUM) : s << " LUM "; break;
81  default : s <<" UNKNOWN ";
82  }
83  return s << id.channel() << "," << id.depth() << ')';
84 }
85 
static bool validDetId(Section se, int dp)
Definition: HcalZDCDetId.cc:61
static bool validDenseIndex(uint32_t di)
Definition: HcalZDCDetId.h:44
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:34
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Section section() const
get the section
Definition: HcalZDCDetId.h:36
static HcalZDCDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalZDCDetId.cc:42
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:20
auto dp
Definition: deltaR.h:22
uint32_t id_
Definition: DetId.h:55
bool null() const
is this a null id ?
Definition: DetId.h:45
int channel() const
get the channel
Definition: HcalZDCDetId.h:40
HcalZDCDetId & operator=(const DetId &id)
Definition: HcalZDCDetId.cc:24
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:33