11 #include <phparameter/PHParameters.h>
12 #include <phparameter/PHParametersContainer.h>
25 #include <Geant4/G4AssemblyVolume.hh>
26 #include <Geant4/G4LogicalVolume.hh>
27 #include <Geant4/G4Material.hh>
28 #include <Geant4/G4PVPlacement.hh>
29 #include <Geant4/G4Polycone.hh>
30 #include <Geant4/G4RotationMatrix.hh>
31 #include <Geant4/G4String.hh>
32 #include <Geant4/G4SystemOfUnits.hh>
33 #include <Geant4/G4ThreeVector.hh>
34 #include <Geant4/G4Transform3D.hh>
35 #include <Geant4/G4Tubs.hh>
36 #include <Geant4/G4Types.hh>
37 #include <Geant4/G4VPhysicalVolume.hh>
40 #pragma GCC diagnostic push
41 #pragma GCC diagnostic ignored "-Wshadow"
42 #include <Geant4/G4GDMLParser.hh>
43 #include <Geant4/G4GDMLReadStructure.hh>
44 #pragma GCC diagnostic pop
68 , m_ParamsContainer(_paramsContainer)
69 , m_StaveGeometryFile(_paramsContainer->GetParameters(PHG4MvtxDefs::
GLOBAL)->get_string_param(
"stave_geometry_file"))
74 std::cout <<
"PHG4MvtxDetector constructor called" << std::endl;
77 for (
int ilayer = 0; ilayer <
n_Layers; ++ilayer)
92 std::cout <<
"PHG4MvtxDetector constructor: making Mvtx detector. " << std::endl;
104 std::cout <<
" -- PHG4MvtxTDetector::IsSensor --" << std::endl;
105 std::cout <<
" volume Name : " << volume->GetName() << std::endl;
106 std::cout <<
" -----------------------------------------" << std::endl;
128 std::tie(layer, stave) = iter->second;
131 std::cout <<
" -- PHG4MvtxDetector::IsInMvtx --" << std::endl;
132 std::cout <<
" layer: " << layer << std::endl;
133 std::cout <<
" stave: " << stave << std::endl;
134 std::cout <<
" volume Name : " << volume->GetName() << std::endl;
135 std::cout <<
" stave Name : " << iter->first->GetName() << std::endl;
136 std::cout <<
" -----------------------------------------" << std::endl;
174 std::cout << std::endl
175 <<
"PHG4MvtxDetector::Construct called for Mvtx " << std::endl;
178 const G4int numZPlanes = 4;
189 mvtxGeomDef::wrap_smallCylR};
191 auto mvtxWrapSol =
new G4Polycone(
"sol_MVTX_Wrapper", 0, 2.0 * M_PI,
192 numZPlanes, zPlane, rInner, rOuter);
194 auto world_mat = logicWorld->GetMaterial();
196 auto logicMVTX =
new G4LogicalVolume(mvtxWrapSol, world_mat,
"log_MVTX_Wrapper");
200 G4Transform3D Tr(Ra, Ta);
201 new G4PVPlacement(Tr, logicMVTX,
"MVTX_Wrapper",
202 logicWorld,
false, 0,
false);
218 std::cout <<
" PHG4MvtxDetector::ConstructMvtx:" << std::endl;
219 std::cout << std::endl;
226 std::unique_ptr<G4GDMLReadStructure>
reader(
new G4GDMLReadStructure());
227 G4GDMLParser gdmlParser(reader.get());
231 char assemblyname[500];
232 sprintf(assemblyname,
"MVTXStave");
236 std::cout <<
"Geting the stave assembly named " << assemblyname << std::endl;
238 G4AssemblyVolume* av_ITSUStave = reader->GetAssembly(assemblyname);
240 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
246 std::cout << std::endl;
247 std::cout <<
" Constructing Layer " << ilayer << std::endl;
274 double arcstep = 12.25;
275 double numstaves = 2.0 * M_PI * layer_nominal_radius / arcstep;
276 N_staves = int(2.0 * M_PI * layer_nominal_radius / arcstep);
281 std::cout <<
" Calculated N_staves for layer "
282 <<
" layer_nominal_radius " << layer_nominal_radius
283 <<
" ITS arcstep " << arcstep
284 <<
" circumference divided by arcstep " << numstaves
285 <<
" N_staves " << N_staves
287 std::cout <<
"A radius for this layer of " << (
double) N_staves * arcstep / (2.0 * M_PI) + 0.01 <<
" or "
288 << (
double) (N_staves + 1) * arcstep / (2.0 * M_PI) + 0.01 <<
" would produce perfect stave spacing" << std::endl;
293 double z_location = 0.0;
297 std::cout <<
" layer "
298 <<
" layer_nominal_radius " << layer_nominal_radius
299 <<
" N_staves " << N_staves
300 <<
" phistep " << phistep
301 <<
" phitilt " << phitilt
309 double phi_offset = M_PI / 2.0;
311 for (
int iphi = 0; iphi < N_staves; iphi++)
316 G4double phi_rotation = phi0 + (
double) iphi * phistep;
323 std::cout <<
"phi_offset = " << phi_offset <<
" iphi " << iphi <<
" phi_rotation = " << phi_rotation <<
" phitilt " << phitilt << std::endl;
328 Ra.rotateZ(phi_rotation + phi_offset + phitilt);
331 Ta.setX(layer_nominal_radius * cos(phi_rotation));
332 Ta.setY(layer_nominal_radius * sin(phi_rotation));
337 std::cout <<
" iphi " << iphi <<
" phi_rotation " << phi_rotation
338 <<
" x " << layer_nominal_radius * cos(phi_rotation)
339 <<
" y " << layer_nominal_radius * sin(phi_rotation)
340 <<
" z " << z_location
343 G4Transform3D Tr(Ra, Ta);
345 av_ITSUStave->MakeImprint(trackerenvelope, Tr, 0,
OverlapCheck());
350 std::cout <<
"This layer has a total of " << N_staves <<
" staves" << std::endl;
359 std::cout <<
" PHG4MvtxDetector::ConstructMvtxServices:" << std::endl;
360 std::cout << std::endl;
367 delete mvtxSupportSystem;
377 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
379 int nDaughters = av->TotalImprintedVolumes();
380 for (
int i = 0;
i < nDaughters; ++
i, ++
it)
385 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
392 std::string material_name(lv->GetMaterial()->GetName());
396 std::cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" built with "
397 << material_name << std::endl;
399 std::vector<std::string> matname = {
"SI",
"KAPTON",
"ALUMINUM",
"Carbon",
"M60J3K",
"WATER"};
403 if (material_name.find(nam) != std::string::npos)
408 std::cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" display with " << nam << std::endl;
418 int nDaughters = lv->GetNoDaughters();
419 for (
int i = 0;
i < nDaughters; ++
i)
425 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
452 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
473 std::cout <<
"-- FillPVArray --" << std::endl;
475 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
477 int nDaughters = av->TotalImprintedVolumes();
478 for (
int i = 0;
i < nDaughters; ++
i, ++
it)
482 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
484 if (pv->GetName().find(
"MVTXHalfStave_pv") != std::string::npos)
493 std::cout <<
"Mvtx layer id " << layer << std::endl;
494 std::cout <<
"Stave in layer id " << stave << std::endl;
495 std::cout <<
"Mvtx stave count " <<
m_StavePV.size() << std::endl;
496 std::cout <<
"FillPVArray - AV[" <<
i <<
"] = " << (*it)->GetName() << std::endl;
497 std::cout <<
" LV[" <<
i <<
"] = " << worldLogical->GetName() << std::endl;
506 std::cout <<
"FillPVArray - AV[" <<
i <<
"] = " << (*it)->GetName() << std::endl;
507 std::cout <<
" LV[" <<
i <<
"] = " << worldLogical->GetName() << std::endl;
515 int nDaughters = lv->GetNoDaughters();
516 for (
int i = 0;
i < nDaughters; ++
i)
521 std::cout <<
" PV[" <<
i <<
"]: " << pv->GetName() << std::endl;
523 if (pv->GetName().find(
"MVTXSensor_") != std::string::npos)
529 std::cout <<
" Adding Sensor Vol <" << pv->GetName() <<
" (" <<
m_SensorPV.size() <<
")>" << std::endl;
533 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
537 std::cout <<
" LV[" <<
i <<
"]: " << worldLogical->GetName() << std::endl;