10 #include <phparameter/PHParameters.h>
11 #include <phparameter/PHParametersContainer.h>
24 #include <Geant4/G4AssemblyVolume.hh>
25 #include <Geant4/G4GDMLParser.hh>
26 #include <Geant4/G4GDMLReadStructure.hh>
27 #include <Geant4/G4LogicalVolume.hh>
28 #include <Geant4/G4Material.hh>
29 #include <Geant4/G4RotationMatrix.hh>
30 #include <Geant4/G4String.hh>
31 #include <Geant4/G4SystemOfUnits.hh>
32 #include <Geant4/G4ThreeVector.hh>
33 #include <Geant4/G4Transform3D.hh>
34 #include <Geant4/G4Types.hh>
35 #include <Geant4/G4VPhysicalVolume.hh>
36 #include <Geant4/G4PVPlacement.hh>
37 #include <Geant4/G4Tubs.hh>
65 , m_ParamsContainer(_paramsContainer)
66 , m_StaveGeometryFile(_paramsContainer->GetParameters(PHG4MvtxDefs::
GLOBAL)->get_string_param(
"stave_geometry_file"))
67 , m_EndWheelsSideS(_paramsContainer->GetParameters(PHG4MvtxDefs::
GLOBAL)->get_string_param(
"end_wheels_sideS"))
68 , m_EndWheelsSideN(_paramsContainer->GetParameters(PHG4MvtxDefs::
GLOBAL)->get_string_param(
"end_wheels_sideN"))
73 cout <<
"PHG4MvtxDetector constructor called" << endl;
76 cout <<
" cm " <<
cm <<
" mm " <<
mm << endl;
77 for (
int ilayer = 0; ilayer <
n_Layers; ++ilayer)
96 cout <<
"PHG4MvtxDetector constructor: making Mvtx detector. " << endl;
110 cout <<
" -- PHG4MvtxTDetector::IsSensor --" << endl;
111 cout <<
" volume Name : " << volume->GetName() << endl;
112 cout <<
" -----------------------------------------" << endl;
128 tie(layer, stave) = iter->second;
131 cout <<
" -- PHG4MvtxDetector::IsInMvtx --" << endl;
132 cout <<
" layer: " << layer << endl;
133 cout <<
" stave: " << stave << endl;
134 cout <<
" volume Name : " << volume->GetName() << endl;
135 cout <<
" stave Name : " << iter->first->GetName() << endl;
136 cout <<
" -----------------------------------------" << endl;
176 <<
"PHG4MvtxDetector::Construct called for Mvtx " << endl;
182 auto world_mat = logicWorld->GetMaterial();
183 auto logicMVTX =
new G4LogicalVolume(tube, world_mat,
"log_MVTX_Wrapper");
184 new G4PVPlacement(
new G4RotationMatrix(), G4ThreeVector(), logicMVTX,
"MVTX_Wrapper", logicWorld,
false, 0,
false);
199 cout <<
" PHG4MvtxDetector::ConstructMvtx:" << endl;
212 char assemblyname[500];
213 sprintf(assemblyname,
"MVTXStave");
217 cout <<
"Geting the stave assembly named " << assemblyname << endl;
219 G4AssemblyVolume* av_ITSUStave = reader->
GetAssembly(assemblyname);
221 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
228 cout <<
" Constructing Layer " << ilayer << endl;
255 double arcstep = 12.25;
256 double numstaves = 2.0 *
M_PI * layer_nominal_radius / arcstep;
257 N_staves = int(2.0 *
M_PI * layer_nominal_radius / arcstep);
262 cout <<
" Calculated N_staves for layer "
263 <<
" layer_nominal_radius " << layer_nominal_radius
264 <<
" ITS arcstep " << arcstep
265 <<
" circumference divided by arcstep " << numstaves
266 <<
" N_staves " << N_staves
268 cout <<
"A radius for this layer of " << (double) N_staves * arcstep / (2.0 *
M_PI) + 0.01 <<
" or "
269 << (double) (N_staves + 1) * arcstep / (2.0 *
M_PI) + 0.01 <<
" would produce perfect stave spacing" << endl;
274 double z_location = 0.0;
279 <<
" layer_nominal_radius " << layer_nominal_radius
280 <<
" N_staves " << N_staves
281 <<
" phistep " << phistep
282 <<
" phitilt " << phitilt
290 double phi_offset =
M_PI / 2.0;
292 for (
int iphi = 0; iphi <
N_staves; iphi++)
297 G4double phi_rotation = phi0 + (double) iphi * phistep;
304 cout <<
"phi_offset = " << phi_offset <<
" iphi " << iphi <<
" phi_rotation = " << phi_rotation <<
" phitilt " << phitilt << endl;
309 Ra.rotateZ(phi_rotation + phi_offset + phitilt);
312 Ta.setX(layer_nominal_radius *
cos(phi_rotation));
313 Ta.setY(layer_nominal_radius * sin(phi_rotation));
318 cout <<
" iphi " << iphi <<
" phi_rotation " << phi_rotation
319 <<
" x " << layer_nominal_radius *
cos(phi_rotation)
320 <<
" y " << layer_nominal_radius * sin(phi_rotation)
321 <<
" z " << z_location
324 G4Transform3D Tr(Ra, Ta);
326 av_ITSUStave->MakeImprint(trackerenvelope, Tr, 0,
OverlapCheck());
331 cout <<
"This layer has a total of " << N_staves <<
" staves" << endl;
340 cout <<
" PHG4MvtxDetector::ConstructMvtxServices:" << endl;
348 new G4PVPlacement(0, G4ThreeVector(0, 0.0), mvtx_shell_outer_skin_volume,
349 "mvtx_shell_outer_skin_volume", lv,
false, 0,
OverlapCheck());
365 G4Transform3D TrS(Ra, Ta);
368 G4AssemblyVolume* av_EW_S = reader->
GetAssembly(
"EndWheelsSideA");
372 G4Transform3D TrN(Ra, Ta);
375 G4AssemblyVolume* av_EW_N = reader->
GetAssembly(
"EndWheelsSideC");
385 G4Tubs* mvtx_outer_shell_tube =
new G4Tubs(
"mvtx_outer_shell",
390 G4LogicalVolume *mvtx_outer_shell_volume =
new G4LogicalVolume(mvtx_outer_shell_tube,
391 trackerenvelope->GetMaterial(),
392 "mvtx_outer_shell_volume", 0, 0, 0);
399 G4Tubs *mvtx_shell_inner_skin_tube =
new G4Tubs(
"mvtx_shell_inner_skin",
400 mvtx_shell_inner_skin_inner_radius,
401 mvtx_shell_inner_skin_inner_radius + mvtxGeomDef::skin_thickness,
404 G4LogicalVolume *mvtx_shell_inner_skin_volume =
new G4LogicalVolume(mvtx_shell_inner_skin_tube,
406 "mvtx_shell_inner_skin_volume", 0, 0, 0);
408 new G4PVPlacement(0, G4ThreeVector(0, 0.0), mvtx_shell_inner_skin_volume,
409 "mvtx_shell_inner_skin", mvtx_outer_shell_volume,
false, 0,
OverlapCheck());
412 G4Tubs *mvtx_shell_foam_core_tube =
new G4Tubs(
"mvtx_shell_foam_core",
413 mvtx_shell_foam_core_inner_radius,
414 mvtx_shell_foam_core_inner_radius + mvtxGeomDef::foam_core_thickness,
417 G4LogicalVolume *mvtx_shell_foam_core_volume =
new G4LogicalVolume(mvtx_shell_foam_core_tube,
419 "mvtx_shell_foam_core_volume", 0, 0, 0);
421 new G4PVPlacement(0, G4ThreeVector(0, 0.0), mvtx_shell_foam_core_volume,
422 "mvtx_shell_foam_core", mvtx_outer_shell_volume,
false, 0,
OverlapCheck());
425 G4Tubs *mvtx_shell_outer_skin_tube =
new G4Tubs(
"mvtx_shell_outer_skin",
426 mvtx_shell_outer_skin_inner_radius,
427 mvtx_shell_outer_skin_inner_radius + mvtxGeomDef::skin_thickness,
430 G4LogicalVolume *mvtx_shell_outer_skin_volume =
new G4LogicalVolume(mvtx_shell_outer_skin_tube,
432 "mvtx_shell_outer_skin_volume", 0, 0, 0);
434 new G4PVPlacement(0, G4ThreeVector(0, 0.0), mvtx_shell_outer_skin_volume,
435 "mvtx_shell_outer_skin", mvtx_outer_shell_volume,
false, 0,
OverlapCheck());
438 return mvtx_outer_shell_volume;
447 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
449 int nDaughters = av->TotalImprintedVolumes();
450 for (
int i = 0; i < nDaughters; ++i, ++
it)
453 G4VPhysicalVolume* pv = (*it);
455 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
462 string material_name(lv->GetMaterial()->GetName());
466 cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" built with "
467 << material_name << endl;
469 vector<string> matname = {
"SI",
"KAPTON",
"ALUMINUM",
"Carbon",
"M60J3K",
"WATER"};
471 for (
string nam : matname)
473 if (material_name.find(nam) != std::string::npos)
478 cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" display with " << nam << endl;
488 int nDaughters = lv->GetNoDaughters();
489 for (
int i = 0; i < nDaughters; ++i)
491 G4VPhysicalVolume* pv = lv->GetDaughter(i);
495 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
509 ostringstream geonode;
522 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
544 cout <<
"-- FillPVArray --" << endl;
546 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
548 int nDaughters = av->TotalImprintedVolumes();
549 for (
int i = 0; i < nDaughters; ++i, ++
it)
551 G4VPhysicalVolume* pv = (*it);
553 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
555 if (pv->GetName().find(
"MVTXHalfStave_pv") != string::npos)
560 m_StavePV.insert(make_pair(pv, make_tuple(layer, stave)));
564 cout <<
"Mvtx layer id " << layer << endl;
565 cout <<
"Stave in layer id " << stave << endl;
566 cout <<
"Mvtx stave count " <<
m_StavePV.size() << endl;
567 cout <<
"FillPVArray - AV[" << i <<
"] = " << (*it)->GetName() << endl;
568 cout <<
" LV[" << i <<
"] = " << worldLogical->GetName() << endl;
577 cout <<
"FillPVArray - AV[" << i <<
"] = " << (*it)->GetName() << endl;
578 cout <<
" LV[" << i <<
"] = " << worldLogical->GetName() << endl;
586 int nDaughters = lv->GetNoDaughters();
587 for (
int i = 0; i < nDaughters; ++i)
589 G4VPhysicalVolume* pv = lv->GetDaughter(i);
592 cout <<
" PV[" << i <<
"]: " << pv->GetName() << endl;
594 if (pv->GetName().find(
"MVTXSensor_") != string::npos)
600 cout <<
" Adding Sensor Vol <" << pv->GetName() <<
" (" <<
m_SensorPV.size() <<
")>" << endl;
604 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
608 cout <<
" LV[" << i <<
"]: " << worldLogical->GetName() << endl;