CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetId.cc
Go to the documentation of this file.
3 #include <ostream>
4 
6 
8 }
9 
10 HcalDetId::HcalDetId(uint32_t rawid) : DetId(rawid) {
11 }
12 
13 HcalDetId::HcalDetId(HcalSubdetector subdet, int tower_ieta, int tower_iphi, int depth) : DetId(Hcal,subdet) {
14  // (no checking at this point!)
15  id_ |= ((depth&0x1F)<<14) |
16  ((tower_ieta>0)?(0x2000|(tower_ieta<<7)):((-tower_ieta)<<7)) |
17  (tower_iphi&0x7F);
18 }
19 
21  if (!gen.null()) {
23  if (gen.det()!=Hcal ||
24  (subdet!=HcalBarrel && subdet!=HcalEndcap &&
25  subdet!=HcalOuter && subdet!=HcalForward )) {
26  throw cms::Exception("Invalid DetId") << "Cannot initialize HcalDetId from " << std::hex << gen.rawId() << std::dec;
27  }
28  }
29  id_=gen.rawId();
30 }
31 
33  if (!gen.null()) {
35  if (gen.det()!=Hcal ||
36  (subdet!=HcalBarrel && subdet!=HcalEndcap &&
37  subdet!=HcalOuter && subdet!=HcalForward ))
38  {
39  throw cms::Exception("Invalid DetId") << "Cannot assign HcalDetId from " << std::hex << gen.rawId() << std::dec;
40  }
41  }
42  id_=gen.rawId();
43  return (*this);
44 }
45 
47  int simple_iphi=((iphi()-1)*5)+1;
48  simple_iphi+=10;
49  return ((simple_iphi>360)?(simple_iphi-360):(simple_iphi));
50 }
51 
53  int simple_iphi=((iphi()-1)*5)+5;
54  simple_iphi+=10;
55  return ((simple_iphi>360)?(simple_iphi-360):(simple_iphi));
56 }
57 
58 std::ostream& operator<<(std::ostream& s,const HcalDetId& id) {
59  switch (id.subdet()) {
60  case(HcalBarrel) : return s << "(HB " << id.ieta() << ',' << id.iphi() << ',' << id.depth() << ')';
61  case(HcalEndcap) : return s << "(HE " << id.ieta() << ',' << id.iphi() << ',' << id.depth() << ')';
62  case(HcalForward) : return s << "(HF " << id.ieta() << ',' << id.iphi() << ',' << id.depth() << ')';
63  case(HcalOuter) : return s << "(HO " << id.ieta() << ',' << id.iphi() << ')';
64  default : return s << id.rawId();
65  }
66 }
67 
68 
static const HcalDetId Undefined
Definition: HcalDetId.h:50
HcalDetId & operator=(const DetId &id)
Definition: HcalDetId.cc:32
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
int crystal_iphi_low() const
get the smallest crystal_iphi of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.cc:46
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
HcalDetId()
Definition: HcalDetId.cc:7
HcalSubdetector
Definition: HcalAssistant.h:31
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
Definition: DetId.h:18
uint32_t id_
Definition: DetId.h:55
bool null() const
is this a null id ?
Definition: DetId.h:45
int crystal_iphi_high() const
get the largest crystal_iphi of the crystal in front of this tower (HB and HE tower 17 only) ...
Definition: HcalDetId.cc:52
Detector det() const
get the detector field from this detid
Definition: DetId.h:35