CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
CastorNumberingScheme Class Reference

#include <SimG4CMS/Forward/interface/CastorNumberingScheme.h>

Public Member Functions

 CastorNumberingScheme ()
 
virtual uint32_t getUnitID (const G4Step *aStep) const
 
virtual ~CastorNumberingScheme ()
 

Static Public Member Functions

static uint32_t packIndex (int z, int sector, int zmodule)
 
static void unpackIndex (const uint32_t &idx, int &z, int &sector, int &zmodule)
 

Private Types

typedef G4LogicalVolume * lvp
 

Private Member Functions

void detectorLevel (const G4Step *, int &, int *, lvp *) const
 

Private Attributes

lvp lvC3EF
 
lvp lvC3HF
 
lvp lvC4EF
 
lvp lvC4HF
 
lvp lvCAER
 
lvp lvCAES
 
lvp lvCAHR
 
lvp lvCAHS
 
lvp lvCAST
 
lvp lvCASTFar
 
lvp lvCASTNear
 
lvp lvCEDR
 
lvp lvCEDS
 
lvp lvCHDR
 
lvp lvCHDS
 

Detailed Description

Description: This class manages the UnitID that labels Castor sensitive volumes

Usage: Used in CastorSD to get unique ID of sensitive detector element

Definition at line 31 of file CastorNumberingScheme.h.

Member Typedef Documentation

typedef G4LogicalVolume* CastorNumberingScheme::lvp
private

Definition at line 58 of file CastorNumberingScheme.h.

Constructor & Destructor Documentation

CastorNumberingScheme::CastorNumberingScheme ( )

Definition at line 15 of file CastorNumberingScheme.cc.

References LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAER, lvCAES, lvCAHR, lvCAHS, lvCAST, lvCASTFar, lvCASTNear, lvCEDR, lvCEDS, lvCHDR, lvCHDS, mod(), and DetId::rawId().

15  : lvCASTFar(0),lvCASTNear(0),
16  lvCAST(0),lvCAES(0),lvCEDS(0),
17  lvCAHS(0),lvCHDS(0),lvCAER(0),
18  lvCEDR(0),lvCAHR(0),lvCHDR(0),
19  lvC3EF(0),lvC3HF(0),lvC4EF(0),
20  lvC4HF(0) {
21  edm::LogInfo("ForwardSim") << "Creating CastorNumberingScheme";
22  const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
23  std::vector<lvp>::const_iterator lvcite;
24  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
25  if (strcmp(((*lvcite)->GetName()).c_str(),"CASTFar") == 0) lvCASTFar = (*lvcite);
26  if (strcmp(((*lvcite)->GetName()).c_str(),"CASTNear") == 0) lvCASTNear = (*lvcite);
27  if (strcmp(((*lvcite)->GetName()).c_str(),"CAST") == 0) lvCAST = (*lvcite);
28  if (strcmp(((*lvcite)->GetName()).c_str(),"CAES") == 0) lvCAES = (*lvcite);
29  if (strcmp(((*lvcite)->GetName()).c_str(),"CEDS") == 0) lvCEDS = (*lvcite);
30  if (strcmp(((*lvcite)->GetName()).c_str(),"CAHS") == 0) lvCAHS = (*lvcite);
31  if (strcmp(((*lvcite)->GetName()).c_str(),"CHDS") == 0) lvCHDS = (*lvcite);
32  if (strcmp(((*lvcite)->GetName()).c_str(),"CAER") == 0) lvCAER = (*lvcite);
33  if (strcmp(((*lvcite)->GetName()).c_str(),"CEDR") == 0) lvCEDR = (*lvcite);
34  if (strcmp(((*lvcite)->GetName()).c_str(),"CAHR") == 0) lvCAHR = (*lvcite);
35  if (strcmp(((*lvcite)->GetName()).c_str(),"CHDR") == 0) lvCHDR = (*lvcite);
36  if (strcmp(((*lvcite)->GetName()).c_str(),"C3EF") == 0) lvC3EF = (*lvcite);
37  if (strcmp(((*lvcite)->GetName()).c_str(),"C3HF") == 0) lvC3HF = (*lvcite);
38  if (strcmp(((*lvcite)->GetName()).c_str(),"C4EF") == 0) lvC4EF = (*lvcite);
39  if (strcmp(((*lvcite)->GetName()).c_str(),"C4HF") == 0) lvC4HF = (*lvcite);
40  }
41 #ifdef castornumschemedebug
42  LogDebug("ForwardSim") << "CastorNumberingScheme:: LogicalVolume pointers\n"
43  << lvCASTFar << " for CASTFar; " << lvCASTNear << " for CASTNear; "
44  << lvCAST << " for CAST; " << lvCAES << " for CAES; "
45  << lvCEDS << " for CEDS; " << lvCAHS << " for CAHS; "
46  << lvCHDS << " for CHDS; " << lvCAER << " for CAER; "
47  << lvCEDR << " for CEDR; " << lvCAHR << " for CAHR; "
48  << lvCHDR << " for CHDR; " << lvC3EF << " for C3EF; "
49  << lvC3HF << " for C3HF; " << lvC4EF << " for C4EF; "
50  << lvC4HF << " for C4HF.";
51 
52  LogDebug("ForwardSim") << "Call to init CastorNumberingScheme\n";
53  for (int mod=0; mod<15; mod++)
54  for (int sec=0; sec<17; sec++)
55  {
56  HcalCastorDetId castorId = HcalCastorDetId(false, sec, mod);
57  LogDebug("ForwardSim") << "Mod: " << mod << " Sec: " << sec << " Id: " << castorId.rawId() << "\n";
58  }
59 
60 #endif
61 
62 }
#define LogDebug(id)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
CastorNumberingScheme::~CastorNumberingScheme ( )
virtual

Definition at line 64 of file CastorNumberingScheme.cc.

64  {
65  edm::LogInfo("ForwardSim") << "Deleting CastorNumberingScheme";
66 }

Member Function Documentation

void CastorNumberingScheme::detectorLevel ( const G4Step *  aStep,
int &  level,
int *  copyno,
lvp lvs 
) const
private

Definition at line 205 of file CastorNumberingScheme.cc.

References i, cuy::ii, and testEve_cfg::level.

Referenced by getUnitID().

206  {
207 
208  //Get name and copy numbers
209  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
210  level = 0;
211  if (touch) level = ((touch->GetHistoryDepth())+1);
212  if (level > 0) {
213  for (int ii = 0; ii < level; ii++) {
214  int i = level - ii - 1;
215  lvs[ii] = touch->GetVolume(i)->GetLogicalVolume();
216  copyno[ii] = touch->GetReplicaNumber(i);
217  }
218  }
219 }
int i
Definition: DBlmapReader.cc:9
int ii
Definition: cuy.py:588
tuple level
Definition: testEve_cfg.py:34
uint32_t CastorNumberingScheme::getUnitID ( const G4Step *  aStep) const
virtual

Definition at line 68 of file CastorNumberingScheme.cc.

References detectorLevel(), cmsHarvester::index, testEve_cfg::level, LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAER, lvCAES, lvCAHR, lvCAHS, lvCAST, lvCASTFar, lvCASTNear, lvCEDR, lvCEDS, lvCHDR, lvCHDS, packIndex(), DetId::rawId(), and ecaldqm::zside().

Referenced by CastorSD::setDetUnitId().

68  {
69 
70  uint32_t index=0;
71  int level, copyno[20];
72  lvp lvs[20];
73  detectorLevel(aStep, level, copyno, lvs);
74 
75 #ifdef castornumschemedebug
76  LogDebug("ForwardSim") << "CastorNumberingScheme number of levels= " <<level;
77 #endif
78 
79  if (level > 0) {
80 
81  int zside = 0;
82  int sector = 0;
83  int module = 0;
84 
85  bool farSide = false;
86  int castorGeoVersion = 0; //0 = original // 1 = separated-halves geometry
87 
88  // HcalCastorDetId::Section section;
89  for (int ich=0; ich < level; ich++) {
90  if(lvs[ich] == lvCAST) {
91  // Z index +Z = 1 ; -Z = 2
92  assert (1 <= copyno[ich] && copyno[ich] <= 3);
93  zside = copyno[ich] == 1 ? 1 : 2;
94  } // copyno 2 = Far : 3 = Near
95  else if(lvs[ich] == lvCASTFar || lvs[ich] == lvCASTNear) {
96  castorGeoVersion = 1; //detected separated-halves geometry
97  if(lvs[ich] == lvCASTFar)
98  farSide = true;
99  }
100  else if(lvs[ich] == lvCAES || lvs[ich] == lvCEDS ||
101  lvs[ich] == lvCAHS || lvs[ich] == lvCHDS) {
102  // sector number for dead material 1 - 8
103  int copyn = copyno[ich];
104  if(castorGeoVersion == 1) {
105  //for separated-half geometry the copy numbers do not start at "3 o'clock" and go from 1-8.
106  //instead they start at "12 o'clock" for near side 1-4. and "6 o'clock" for far side 1-4 again
107  if(farSide) {
108  if (copyn<3)
109  copyn += 6; //maps 1->7, 2->8
110  else
111  copyn -= 2; //maps 3->1 and 4->2
112  }
113  else { //nearSide
114  copyn += 2; //maps 1->3, ...
115  }
116  } //endif separated-half geometry
117  if (copyn<5)
118  sector = 5-copyn;
119  else
120  sector = 13-copyn;
121  }
122  else if(lvs[ich] == lvCAER || lvs[ich] == lvCEDR) {
123  // zmodule number 1-2 for EM section (2 copies)
124  module = copyno[ich];
125  }
126  else if(lvs[ich] == lvCAHR || lvs[ich] == lvCHDR) {
127  //zmodule number 3-14 for HAD section (12 copies)
128  module = copyno[ich] + 2;
129  }
130  else if(lvs[ich] == lvC3EF || lvs[ich] == lvC3HF) {
131  // sector number for sensitive material 1 - 16
132  sector = sector*2;
133  }
134  else if(lvs[ich] == lvC4EF || lvs[ich] == lvC4HF) {
135  // sector number for sensitive material 1 - 16
136  sector = sector*2 - 1;
137  }
138 
139 #ifdef castornumschemedebug
140  LogDebug("ForwardSim") << "CastorNumberingScheme " << "ich = " << ich
141  << "copyno = " << copyno[ich] << "name = "
142  << lvs[ich]->GetName();
143 #endif
144  } //end for loop over levels
145 
146  // use for Castor number det = 9
147  //
148  // Z index +Z = 1 ; -Z = 2
149  // sector number 1 - 16
150  // zmodule number 1 - 18
151 
152  bool true_for_positive_eta = false;
153  if(zside == 1) true_for_positive_eta = true;
154 
155  HcalCastorDetId castorId = HcalCastorDetId(true_for_positive_eta, sector, module);
156  index = castorId.rawId();
157 
158 #ifdef castornumschemedebug
159  uint32_t intindex = 0;
160  intindex = packIndex(zside, sector, module);
161  LogDebug("ForwardSim") << "CastorNumberingScheme: " << " zside "
162  << zside << " module " << module << " sector "
163  << sector << " UnitID 0x" << std::hex << intindex
164  << std::dec << " index: " << index;
165 #endif
166  }
167  return index;
168 
169 }
#define LogDebug(id)
int zside(DetId const &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void detectorLevel(const G4Step *, int &, int *, lvp *) const
tuple level
Definition: testEve_cfg.py:34
static uint32_t packIndex(int z, int sector, int zmodule)
Definition: vlib.h:208
uint32_t CastorNumberingScheme::packIndex ( int  z,
int  sector,
int  zmodule 
)
static

pack the Unit ID for Castor
Bits 0- 5: zmodule index
Bits 6- 9: sector index
Bits 10-19: unused
Bit 20: +/- z side
Bits 22-27: unused
Bits 28-31: subdetector
(+z=1,-z=2); sector=1..16, zmodule=1..18;

Definition at line 173 of file CastorNumberingScheme.cc.

References customizeTrackingMonitorSeedNumber::idx.

Referenced by CastorShowerLibraryMaker::FillShowerEvent(), and getUnitID().

173  {
174  /*
175  uint32_t idx=(section&31)<<28; //bits 28-31 (21-27 are free for now)
176  idx+=((z-1)&1)<<20; //bits 20 (1...2)
177  idx+=(sector&15)<<6; //bits 6-9 (1...16)
178  idx+=(module&63); //bits 0-5 (1...18)
179  return idx;
180  */
181 
182  uint32_t idx=((z-1)&1)<<8; //bit 8
183  idx+=(sector&15)<<4; //bits 4-7 (1...16)
184  idx+=(module&15); //bits 0-3 (1...14)
185  return idx;
186 
187 }
float float float z
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
Definition: vlib.h:208
void CastorNumberingScheme::unpackIndex ( const uint32_t &  idx,
int &  z,
int &  sector,
int &  zmodule 
)
static

Definition at line 191 of file CastorNumberingScheme.cc.

Referenced by CastorShowerLibraryMaker::FillShowerEvent(), CastorTestAnalysis::getCastorBranchData(), and DoCastorAnalysis::update().

191  {
192  /*
193  section = (idx>>28)&31;
194  z = (idx>>20)&1;
195  z += 1;
196  sector = (idx>>6)&15;
197  module= (idx&63);
198  */
199  z = (idx>>8)&1;
200  z += 1;
201  sector = (idx>>4)&15;
202  module = (idx&15);
203 }
float float float z
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
Definition: vlib.h:208

Member Data Documentation

lvp CastorNumberingScheme::lvC3EF
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvC3HF
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvC4EF
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvC4HF
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCAER
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCAES
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCAHR
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCAHS
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCAST
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCASTFar
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCASTNear
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCEDR
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCEDS
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCHDR
private

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

lvp CastorNumberingScheme::lvCHDS
private

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().