9 #include "CLHEP/Units/GlobalSystemOfUnits.h" 10 #include "G4LogicalVolumeStore.hh" 31 edm::LogInfo(
"ForwardSim") <<
"Creating CastorNumberingScheme";
32 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
33 std::vector<lvp>::const_iterator lvcite;
34 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
35 if (strcmp(((*lvcite)->GetName()).c_str(),
"CASTFar") == 0)
37 if (strcmp(((*lvcite)->GetName()).c_str(),
"CASTNear") == 0)
39 if (strcmp(((*lvcite)->GetName()).c_str(),
"CAST") == 0)
41 if (strcmp(((*lvcite)->GetName()).c_str(),
"CAES") == 0)
43 if (strcmp(((*lvcite)->GetName()).c_str(),
"CEDS") == 0)
45 if (strcmp(((*lvcite)->GetName()).c_str(),
"CAHS") == 0)
47 if (strcmp(((*lvcite)->GetName()).c_str(),
"CHDS") == 0)
49 if (strcmp(((*lvcite)->GetName()).c_str(),
"CAER") == 0)
51 if (strcmp(((*lvcite)->GetName()).c_str(),
"CEDR") == 0)
53 if (strcmp(((*lvcite)->GetName()).c_str(),
"CAHR") == 0)
55 if (strcmp(((*lvcite)->GetName()).c_str(),
"CHDR") == 0)
57 if (strcmp(((*lvcite)->GetName()).c_str(),
"C3EF") == 0)
59 if (strcmp(((*lvcite)->GetName()).c_str(),
"C3HF") == 0)
61 if (strcmp(((*lvcite)->GetName()).c_str(),
"C4EF") == 0)
63 if (strcmp(((*lvcite)->GetName()).c_str(),
"C4HF") == 0)
66 #ifdef castornumschemedebug 67 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme:: LogicalVolume pointers\n" 72 <<
" for C3HF; " <<
lvC4EF <<
" for C4EF; " <<
lvC4HF <<
" for C4HF.";
74 LogDebug(
"ForwardSim") <<
"Call to init CastorNumberingScheme\n";
78 LogDebug(
"ForwardSim") <<
"Mod: " <<
mod <<
" Sec: " <<
sec <<
" Id: " << castorId.
rawId() <<
"\n";
88 int level, copyno[20];
92 #ifdef castornumschemedebug 93 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme number of levels= " <<
level;
101 bool farSide =
false;
102 int castorGeoVersion = 0;
105 for (
int ich = 0; ich <
level; ich++) {
108 assert(1 <= copyno[ich] && copyno[ich] <= 3);
109 zside = copyno[ich] == 1 ? 1 : 2;
112 castorGeoVersion = 1;
117 int copyn = copyno[ich];
118 if (castorGeoVersion == 1) {
136 module = copyno[ich];
139 module = copyno[ich] + 2;
145 sector = sector * 2 - 1;
148 #ifdef castornumschemedebug 149 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme " 150 <<
"ich = " << ich <<
"copyno = " << copyno[ich] <<
"name = " << lvs[ich]->GetName();
160 bool true_for_positive_eta =
false;
162 true_for_positive_eta =
true;
165 index = castorId.
rawId();
167 #ifdef castornumschemedebug 168 uint32_t intindex = 0;
169 intindex =
packIndex(zside, sector, module);
170 LogDebug(
"ForwardSim") <<
"CastorNumberingScheme: " 171 <<
" zside " << zside <<
" module " << module <<
" sector " << sector <<
" UnitID 0x" 187 uint32_t
idx = ((z - 1) & 1) << 8;
188 idx += (sector & 15) << 4;
189 idx += (module & 15);
203 sector = (idx >> 4) & 15;
209 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
212 level = ((touch->GetHistoryDepth()) + 1);
215 int i = level -
ii - 1;
216 lvs[
ii] = touch->GetVolume(i)->GetLogicalVolume();
217 copyno[
ii] = touch->GetReplicaNumber(i);
constexpr uint32_t rawId() const
get the raw id
static void unpackIndex(const uint32_t &idx, int &z, int §or, int &zmodule)
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)