CMS 3D CMS Logo

HcalZDCDetId.cc
Go to the documentation of this file.
3 
10 
12 }
13 
14 
15 HcalZDCDetId::HcalZDCDetId(uint32_t rawid) : DetId(rawid) {
16 }
17 
19  if (section == RPD) {
21  id_ |= kZDCRPDMask;
22  id_ |= ((channel-1)&kZDCChannelMask);
23  } else {
25  id_ |= (channel&kZDCChannelMask);
26  }
27  if (true_for_positive_eta) id_ |= kZDCZsideMask;
28 }
29 
31  if (!gen.null() && (gen.det()!=Calo || gen.subdetId()!=SubdetectorId)) {
32  throw cms::Exception("Invalid DetId")
33  << "Cannot initialize ZDCDetId from " << std::hex << gen.rawId() << std::dec;
34  }
35  id_ = gen.rawId();
36 }
37 
39  if (!gen.null() && (gen.det()!=Calo || gen.subdetId()!=SubdetectorId)) {
40  throw cms::Exception("Invalid DetId")
41  << "Cannot assign ZDCDetId from " << std::hex << gen.rawId() << std::dec;
42  }
43  id_=gen.rawId();
44  return *this;
45 }
46 
48  if (id_ & kZDCRPDMask)
49  return RPD;
50  else
52 }
53 
54 int HcalZDCDetId::depth() const {
55  const int se ( section() ) ;
56  if (se == EM) return 1;
57  else if (se == HAD) return (channel()+2);
58  else if (se == RPD) return 2;
59  else return channel();
60 }
61 
62 int HcalZDCDetId::channel() const {
63  const int se ( section() ) ;
64  if (se == RPD) return (1+(id_&kZDCChannelMask));
65  else return (id_&kZDCChannelMask);
66 }
67 
68 uint32_t HcalZDCDetId::denseIndex() const {
69  const int se ( section() ) ;
70  uint32_t di = (channel() - 1 +
71  ( se == RPD ? 2*kDepRun1 + ( zside()<0 ? 0 : kDepRPD ) :
72  ( ( zside()<0 ? 0 : kDepRun1 ) +
73  ( se == HAD ? kDepEM :
74  ( se == LUM ? kDepEM + kDepHAD : 0 ) ) ) ) );
75  return di;
76 }
77 
79  if ( validDenseIndex( di ) ) {
80  bool lz (false);
81  uint32_t dp(0);
82  Section se(Unknown);
83  if (di >= 2*kDepRun1) {
84  lz = (di >= (kDepRun1+kDepTot));
85  se = RPD;
86  dp = 1 + ((di-2*kDepRun1) % kDepRPD);
87  } else {
88  lz = (di >= kDepRun1);
89  uint32_t in = (di%kDepRun1) ;
90  se = (in<kDepEM ? EM :
91  (in<kDepEM+kDepHAD ? HAD : LUM) );
92  dp = (EM == se ? in+1 :
93  (HAD == se ? in-kDepEM+1 : in-kDepEM-kDepHAD+1) );
94  }
95  return HcalZDCDetId( se, lz, dp ) ;
96  } else{
97  return HcalZDCDetId() ;
98  }
99 }
100 
102  bool flag = (dp >= 1 && (
103  ( ( se == EM ) &&
104  ( dp <= kDepEM ) ) ||
105  ( ( se == HAD ) &&
106  ( dp <= kDepHAD ) ) ||
107  ( ( se == LUM ) &&
108  ( dp <= kDepLUM ) ) ||
109  ( ( se == RPD ) &&
110  ( dp <= kDepRPD ) )
111  )
112  );
113  return flag;
114 }
115 
116 std::ostream& operator<<(std::ostream& s,const HcalZDCDetId& id) {
117  s << "(ZDC" << ((id.zside()==1)?("+"):("-"));
118  switch (id.section()) {
119  case(HcalZDCDetId::EM) : s << " EM "; break;
120  case(HcalZDCDetId::HAD) : s << " HAD "; break;
121  case(HcalZDCDetId::LUM) : s << " LUM "; break;
122  case(HcalZDCDetId::RPD) : s << " RPD "; break;
123  default : s << " UNKNOWN ";
124  }
125  return s << id.channel() << "," << id.depth() << ')';
126 }
static bool validDetId(Section se, int dp)
static bool validDenseIndex(uint32_t di)
Definition: HcalZDCDetId.h:49
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
static const int kZDCSectionOffset
Definition: HcalZDCDetId.h:20
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
static const int kZDCZsideMask
Definition: HcalZDCDetId.h:21
static const int kZDCChannelMask
Definition: HcalZDCDetId.h:18
static const int kZDCSectionMask
Definition: HcalZDCDetId.h:19
static const int kZDCRPDMask
Definition: HcalZDCDetId.h:22
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
static HcalZDCDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalZDCDetId.cc:78
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
auto dp
Definition: deltaR.h:22
int depth() const
get the depth (1 for EM, channel + 1 for HAD, 2 for RPD, not sure yet for LUM, leave as default) ...
Definition: HcalZDCDetId.cc:54
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.cc:62
std::ostream & operator<<(std::ostream &s, const HcalZDCDetId &id)
Section section() const
get the section
Definition: HcalZDCDetId.cc:47
HcalZDCDetId & operator=(const DetId &id)
Definition: HcalZDCDetId.cc:38
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:68