4 #include "G4Material.hh"
5 #include "G4Element.hh"
7 #include "G4LogicalVolume.hh"
8 #include "G4VPhysicalVolume.hh"
9 #include "G4PVPlacement.hh"
10 #include "G4ThreeVector.hh"
11 #include "G4Vector3D.hh"
13 #include "G4VisAttributes.hh"
15 #include "G4Sphere.hh"
17 #include "G4PhysicalConstants.hh"
18 #include "G4SystemOfUnits.hh"
28 (G4VPhysicalVolume* aPV ,
int aDepth,
int ,
29 const G4Transform3D& aTransform)
31 for (
int levels = 0; levels < aDepth; levels++) G4cout <<
" ";
32 G4cout << aPV->GetName() <<
" Level:" << aDepth
33 <<
" Pos:" << aTransform.getTranslation()
34 <<
" Rot:" << aTransform.getRotation().getTheta()/deg
35 <<
"," << aTransform.getRotation().getPhi()/deg
36 <<
"," << aTransform.getRotation().getPsi()/deg
41 (G4VPhysicalVolume* aPV ,
int aDepth,
int ,
42 const G4Transform3D& aTransform)
49 if ((aPV->GetName() ==
"WCBarrel") ||
50 (aPV->GetName() ==
"WorldBox")) {
52 WCOffset = G4ThreeVector(aTransform.getTranslation().getX()/cm,
53 aTransform.getTranslation().getY()/cm,
54 aTransform.getTranslation().getZ()/cm);
61 WCPMTSize = WCPMTRadius/cm;
65 static G4double zmin=100000,zmax=-100000.;
66 static G4double xmin=100000,xmax=-100000.;
67 static G4double ymin=100000,ymax=-100000.;
69 xmin=100000,xmax=-100000.;
70 ymin=100000,ymax=-100000.;
71 zmin=100000,zmax=-100000.;
74 if ((aPV->GetName() ==
"WCCapBlackSheet") || (aPV->GetName().find(
"glassFaceWCPMT") != std::string::npos)){
75 G4double x = aTransform.getTranslation().getX()/cm;
76 G4double y = aTransform.getTranslation().getY()/cm;
77 G4double z = aTransform.getTranslation().getZ()/cm;
90 WCCylInfo[0] = xmax-xmin;
91 WCCylInfo[1] = ymax-ymin;
92 WCCylInfo[2] = zmax-zmin;
98 const G4Transform3D& aTransform)
100 static std::string replicaNoString[20];
102 std::stringstream depth;
103 std::stringstream pvname;
106 pvname << aPV->GetName();
108 replicaNoString[aDepth] = pvname.str() +
"-" + depth.str();
122 for (
int i=0; i <= aDepth; i++)
123 tubeTag +=
":" + replicaNoString[i];
128 G4cerr <<
"Repeated tube tag: " << tubeTag << G4endl;
130 G4cerr <<
"Cannot continue -- hits will not be recorded correctly." << G4endl;
131 G4cerr <<
"Please make sure that logical volumes with multiple placements are each given a unique copy number"
143 G4cerr <<
"Repeated tube tag: " << tubeTag << G4endl;
145 G4cerr <<
"Cannot continue -- hits will not be recorded correctly." << G4endl;
146 G4cerr <<
"Please make sure that logical volumes with multiple placements are each given a unique copy number"
175 geoFile.open(
"geofile.txt", std::ios::out);
182 G4Transform3D firstTransform =
tubeIDMap[2];
183 innerradius = sqrt(pow(firstTransform.getTranslation().getX()/cm,2)
184 + pow(firstTransform.getTranslation().getY()/cm,2));
205 for (
unsigned int i=0;i<
fpmts.size();i++){
211 for (
int tubeID = 1; tubeID <=
totalNumPMTs; tubeID++){
212 G4Transform3D newTransform =
tubeIDMap[tubeID];
215 G4Vector3D nullOrient = G4Vector3D(0,0,1);
216 G4Vector3D pmtOrientation = newTransform * nullOrient;
221 if (pmtOrientation.z()==1.0)
223 else if (pmtOrientation.z()==-1.0)
230 <<
" " << setw(8) << newTransform.getTranslation().getX()/cm
231 <<
" " << setw(8) << newTransform.getTranslation().getY()/cm
232 <<
" " << setw(8) << newTransform.getTranslation().getZ()/cm
233 <<
" " << setw(7) << pmtOrientation.x()
234 <<
" " << setw(7) << pmtOrientation.y()
235 <<
" " << setw(7) << pmtOrientation.z()
236 <<
" " << setw(3) << cylLocation
240 newTransform.getTranslation().getX()/cm,
241 newTransform.getTranslation().getY()/cm,
242 newTransform.getTranslation().getZ()/cm,
248 fpmts.push_back(new_pmt);
253 for (
unsigned int i=0;i<
fODpmts.size();i++){
263 G4Vector3D nullOrient = G4Vector3D(0,0,1);
264 G4Vector3D pmtOrientation = newTransform * nullOrient;
268 if (pmtOrientation.z()==1.0)
270 else if (pmtOrientation.z()==-1.0)
277 <<
" " << setw(8) << newTransform.getTranslation().getX()/CLHEP::cm
278 <<
" " << setw(8) << newTransform.getTranslation().getY()/CLHEP::cm
279 <<
" " << setw(8) << newTransform.getTranslation().getZ()/CLHEP::cm
280 <<
" " << setw(7) << pmtOrientation.x()
281 <<
" " << setw(7) << pmtOrientation.y()
282 <<
" " << setw(7) << pmtOrientation.z()
283 <<
" " << setw(3) << cylLocation
287 newTransform.getTranslation().getX()/CLHEP::cm,
288 newTransform.getTranslation().getY()/CLHEP::cm,
289 newTransform.getTranslation().getZ()/CLHEP::cm,
318 (G4VPhysicalVolume* aPV,
int aDepth,
const G4Transform3D& aTransform,
319 DescriptionFcnPtr registrationRoutine)
324 G4ThreeVector originalTranslation = aPV->GetTranslation();
325 G4RotationMatrix* pOriginalRotation = aPV->GetRotation();
327 if (aPV->IsReplicated() )
331 G4double width, offset;
334 aPV->GetReplicationData(axis,nReplicas,width,offset,consuming);
336 for (
int n = 0; n < nReplicas; n++)
341 aPV->SetTranslation(G4ThreeVector
342 (-width*(nReplicas-1)*0.5+n*width,0,0));
346 aPV->SetTranslation(G4ThreeVector
347 (0,-width*(nReplicas-1)*0.5+n*width,0));
351 aPV->SetTranslation(G4ThreeVector
352 (0,0,-width*(nReplicas-1)*0.5+n*width));
359 aPV->SetTranslation(G4ThreeVector(0,0,0));
364 G4RotationMatrix rotation;
365 rotation.rotateZ(-(offset+(n+0.5)*width));
368 aPV->SetTranslation(G4ThreeVector(0,0,0));
369 aPV->SetRotation(&rotation);
375 DescribeAndDescendGeometry(aPV, aDepth, n, aTransform,
376 registrationRoutine);
381 DescribeAndDescendGeometry(aPV, aDepth, aPV->GetCopyNo(), aTransform,
382 registrationRoutine);
385 aPV->SetTranslation(originalTranslation);
386 aPV->SetRotation(pOriginalRotation);
390 (G4VPhysicalVolume* aPV ,
int aDepth,
int replicaNo,
391 const G4Transform3D& aTransform, DescriptionFcnPtr registrationRoutine)
395 G4Transform3D* transform =
396 new G4Transform3D(*(aPV->GetObjectRotation()), aPV->GetTranslation());
398 G4Transform3D newTransform = aTransform * (*transform);
405 (this->*registrationRoutine)(aPV, aDepth, replicaNo, newTransform);
407 int nDaughters = aPV->GetLogicalVolume()->GetNoDaughters();
409 for (
int iDaughter = 0; iDaughter < nDaughters; iDaughter++)
410 TraverseReplicas(aPV->GetLogicalVolume()->GetDaughter(iDaughter),
411 aDepth+1, newTransform, registrationRoutine);
std::vector< WCSimPmtInfo * > fpmts
G4String WCODCollectionName
void DescribeAndRegisterPMT(G4VPhysicalVolume *, int, int, const G4Transform3D &)
void DescribeAndDescendGeometry(G4VPhysicalVolume *, int, int, const G4Transform3D &, DescriptionFcnPtr)
void PrintGeometryTree(G4VPhysicalVolume *, int, int, const G4Transform3D &)
void DumpGeometryTableToFile()
static hash_map< std::string, int, hash< std::string > > ODtubeLocationMap
void GetWCGeom(G4VPhysicalVolume *, int, int, const G4Transform3D &)
void TraverseReplicas(G4VPhysicalVolume *, int, const G4Transform3D &, DescriptionFcnPtr)
G4String WCIDCollectionName
static std::map< int, G4Transform3D > ODtubeIDMap
std::vector< WCSimPmtInfo * > fODpmts
G4double GetGeo_Dm(G4int)
static std::map< int, G4Transform3D > tubeIDMap
static hash_map< std::string, int, hash< std::string > > tubeLocationMap