CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ZdcNumberingScheme Class Reference

#include <ZdcNumberingScheme.h>

Public Member Functions

int detectorLevel (const G4Step *) const
 
void detectorLevel (const G4Step *, int &, int *, G4String *) const
 
virtual unsigned int getUnitID (const G4Step *aStep) const
 
void setVerbosity (const int)
 
 ZdcNumberingScheme (int)
 
virtual ~ZdcNumberingScheme ()
 

Static Public Member Functions

static unsigned int packZdcIndex (int subDet, int layer, int fiber, int channel, int z)
 
static void unpackZdcIndex (const unsigned int &idx, int &subDet, int &layer, int &fiber, int &channel, int &z)
 

Private Attributes

int verbosity
 

Detailed Description

Definition at line 13 of file ZdcNumberingScheme.h.

Constructor & Destructor Documentation

ZdcNumberingScheme::ZdcNumberingScheme ( int  iv)

Definition at line 13 of file ZdcNumberingScheme.cc.

References gather_cfg::cout, and verbosity.

13  {
14  verbosity = iv;
15  if (verbosity>0)
16  std::cout << "Creating ZDCNumberingScheme" << std::endl;
17 }
ZdcNumberingScheme::~ZdcNumberingScheme ( )
virtual

Definition at line 19 of file ZdcNumberingScheme.cc.

References gather_cfg::cout, and verbosity.

19  {
20  if (verbosity>0)
21  std::cout<< " Deleting ZdcNumberingScheme" << std::endl;
22 }

Member Function Documentation

int ZdcNumberingScheme::detectorLevel ( const G4Step *  aStep) const

Definition at line 167 of file ZdcNumberingScheme.cc.

References hcalDigis_cfi::level.

Referenced by getUnitID().

167  {
168 
169  //Find number of levels
170  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
171  int level = 0;
172  if (touch) level = ((touch->GetHistoryDepth())+1);
173  return level;
174 }
void ZdcNumberingScheme::detectorLevel ( const G4Step *  aStep,
int &  level,
int *  copyno,
G4String *  name 
) const

Definition at line 176 of file ZdcNumberingScheme.cc.

References mps_fire::i, cuy::ii, and hcalDigis_cfi::level.

177  {
178 
179  //Get name and copy numbers
180  if (level > 0) {
181  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
182  for (int ii = 0; ii < level; ii++) {
183  int i = level - ii - 1;
184  name[ii] = touch->GetVolume(i)->GetName();
185  copyno[ii] = touch->GetReplicaNumber(i);
186  }
187  }
188 }
ii
Definition: cuy.py:588
unsigned int ZdcNumberingScheme::getUnitID ( const G4Step *  aStep) const
virtual

Definition at line 27 of file ZdcNumberingScheme.cc.

References gather_cfg::cout, detectorLevel(), HcalZDCDetId::EM, HcalZDCDetId::HAD, hcalDigis_cfi::level, HcalZDCDetId::LUM, dataset::name, packZdcIndex(), DetId::rawId(), trackingPlots::section, HcalZDCDetId::Unknown, and ecaldqm::zside().

Referenced by ZdcSD::setDetUnitId().

27  {
28 
29  uint32_t index = 0;
30  int level = detectorLevel(aStep);
31 
32  if (level > 0) {
33  int* copyno = new int[level];
34  G4String* name = new G4String[level];
35 
36  detectorLevel(aStep, level, copyno, name);
37 
38  int zside = 0;
39  int channel = 0;
40  int fiber = 0;
41  int layer = 0;
43 
44  for (int ich=0; ich < level; ich++) {
45  if (name[ich] == "ZDC") {
46  if(copyno[ich] == 1)zside = 1;
47  if(copyno[ich] == 2)zside = -1;
48  }
49  else if (name[ich] == "ZDC_EMLayer") {
50  section = HcalZDCDetId::EM;
51 #ifdef debug
52  layer = copyno[ich];
53 #endif
54  }
55  else if (name[ich] == "ZDC_EMFiber") {
56  fiber = copyno[ich];
57  if (fiber < 20)
58  channel = 1;
59  else if (fiber < 39)
60  channel = 2;
61  else if (fiber < 58)
62  channel = 3;
63  else if (fiber < 77)
64  channel = 4;
65  else
66  channel = 5;
67  }
68  else if (name[ich] == "ZDC_LumLayer") {
69  section = HcalZDCDetId::LUM;
70  layer = copyno[ich];
71  channel = layer;
72  }
73  else if (name[ich] == "ZDC_HadLayer") {
74  section = HcalZDCDetId::HAD;
75  layer = copyno[ich];
76  if (layer < 6)
77  channel = 1;
78  else if (layer < 12)
79  channel = 2;
80  else if (layer < 18)
81  channel = 3;
82  else
83  channel = 4;
84  }
85 #ifdef debug
86  else if (name[ich] == "ZDC_LumGas") {
87  fiber = 1;
88  }
89  else if (name[ich] == "ZDC_HadFiber") {
90  fiber = copyno[ich];
91  }
92 #endif
93  }
94 
95 #ifdef debug
96  unsigned intindex=0;
97  intindex = packZdcIndex (section, layer, fiber, channel, zside);
98 #endif
99 
100  bool true_for_positive_eta = true;
101  if(zside == -1)true_for_positive_eta = false;
102 
103  HcalZDCDetId zdcId(section, true_for_positive_eta, channel);
104  index = zdcId.rawId();
105 
106 #ifdef debug
107  std::cout<<"DetectorId: ";
108  std::cout<<zdcId<<std::endl;
109 
110 
111  std::cout<< "ZdcNumberingScheme:"
112  << " getUnitID - # of levels = "
113  << level << std::endl;
114  for (int ich = 0; ich < level; ich++)
115  std::cout<< " " << ich << ": copyno " << copyno[ich]
116  << " name=" << name[ich]
117  << " section " << section << " zside " << zside
118  << " layer " << layer << " fiber " << fiber
119  << " channel " << channel << "packedIndex ="
120  << intindex << " detId raw: "<<index<<std::endl;
121 
122 #endif
123 
124  delete[] copyno;
125  delete[] name;
126  }
127 
128  return index;
129 
130 }
static unsigned int packZdcIndex(int subDet, int layer, int fiber, int channel, int z)
int zside(DetId const &)
int detectorLevel(const G4Step *) const
unsigned ZdcNumberingScheme::packZdcIndex ( int  subDet,
int  layer,
int  fiber,
int  channel,
int  z 
)
static

pack the Unit ID for Zdc
z = 1,2 = -z,+z; subDet = 1,2,3 = EM,Lum,HAD; fiber = 1-96 (EM,HAD), 1 (Lum); channel = 1-5 (EM), layer# (Lum), 1-3 (HAD)

Definition at line 132 of file ZdcNumberingScheme.cc.

References gather_cfg::cout, training_settings::idx, and unpackZdcIndex().

Referenced by getUnitID().

133  {
134  unsigned int idx = ((z-1)&1)<<20; //bit 20
135  idx += (channel&7)<<17; //bits 17-19
136  idx += (fiber&255)<<9; //bits 9-16
137  idx += (layer&127)<<2; //bits 2-8
138  idx += (section&3); //bits 0-1
139 
140  #ifdef debug
141  std::cout<< "ZDC packing: section " << section << " layer " << layer << " fiber "
142  << fiber << " channel " << channel << " zside " << z << "idx: " <<idx << std::endl;
143  int newsubdet, newlayer, newfiber, newchannel, newz;
144  unpackZdcIndex(idx, newsubdet, newlayer, newfiber, newchannel, newz);
145  #endif
146 
147  return idx;
148 }
static void unpackZdcIndex(const unsigned int &idx, int &subDet, int &layer, int &fiber, int &channel, int &z)
void ZdcNumberingScheme::setVerbosity ( const int  iv)

Definition at line 25 of file ZdcNumberingScheme.cc.

References verbosity.

25 { verbosity = iv; }
void ZdcNumberingScheme::unpackZdcIndex ( const unsigned int &  idx,
int &  subDet,
int &  layer,
int &  fiber,
int &  channel,
int &  z 
)
static

Definition at line 151 of file ZdcNumberingScheme.cc.

References gather_cfg::cout.

Referenced by packZdcIndex(), and ZdcTestAnalysis::update().

153  {
154  z = 1 + ((idx>>20)&1);
155  channel = (idx>>17)&7;
156  fiber = (idx>>9)&255;
157  layer = (idx>>2)&127;
158  section = idx&3;
159 
160  #ifdef debug
161  std::cout<< "ZDC unpacking: idx:"<< idx << " -> section " << section
162  << " layer " << layer << " fiber " << fiber << " channel "
163  << channel << " zside " << z << std::endl;
164  #endif
165 }

Member Data Documentation

int ZdcNumberingScheme::verbosity
private

Definition at line 38 of file ZdcNumberingScheme.h.

Referenced by setVerbosity(), ZdcNumberingScheme(), and ~ZdcNumberingScheme().