9 #include "CLHEP/Units/GlobalSystemOfUnits.h" 10 #include "G4LogicalVolumeStore.hh" 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);
41 #ifdef castornumschemedebug 42 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme:: LogicalVolume pointers\n" 52 LogDebug(
"ForwardSim") <<
"Call to init CastorNumberingScheme\n";
54 for (
int sec=0; sec<17; sec++)
57 LogDebug(
"ForwardSim") <<
"Mod: " <<
mod <<
" Sec: " << sec <<
" Id: " << castorId.
rawId() <<
"\n";
65 edm::LogInfo(
"ForwardSim") <<
"Deleting CastorNumberingScheme";
71 int level, copyno[20];
75 #ifdef castornumschemedebug 76 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme number of levels= " <<
level;
86 int castorGeoVersion = 0;
89 for (
int ich=0; ich <
level; ich++) {
92 assert (1 <= copyno[ich] && copyno[ich] <= 3);
93 zside = copyno[ich] == 1 ? 1 : 2;
103 int copyn = copyno[ich];
104 if(castorGeoVersion == 1) {
124 module = copyno[ich];
128 module = copyno[ich] + 2;
136 sector = sector*2 - 1;
139 #ifdef castornumschemedebug 140 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme " <<
"ich = " << ich
141 <<
"copyno = " << copyno[ich] <<
"name = " 142 << lvs[ich]->GetName();
152 bool true_for_positive_eta =
false;
153 if(zside == 1) true_for_positive_eta =
true;
156 index = castorId.
rawId();
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
182 uint32_t
idx=((z-1)&1)<<8;
201 sector = (idx>>4)&15;
206 int* copyno,
lvp* lvs)
const {
209 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
211 if (touch) level = ((touch->GetHistoryDepth())+1);
214 int i = level -
ii - 1;
215 lvs[
ii] = touch->GetVolume(i)->GetLogicalVolume();
216 copyno[
ii] = touch->GetReplicaNumber(i);
static void unpackIndex(const uint32_t &idx, int &z, int §or, int &zmodule)
uint32_t rawId() const
get the raw id
virtual ~CastorNumberingScheme()
void detectorLevel(const G4Step *, int &, int *, lvp *) const
virtual uint32_t getUnitID(const G4Step *aStep) const
static uint32_t packIndex(int z, int sector, int zmodule)
T mod(const T &a, const T &b)