10 #include <phparameter/PHParameters.h>
11 #include <phparameter/PHParametersContainer.h>
24 #include <Geant4/G4AssemblyVolume.hh>
25 #include <Geant4/G4LogicalVolume.hh>
26 #include <Geant4/G4Material.hh>
27 #include <Geant4/G4RotationMatrix.hh>
28 #include <Geant4/G4String.hh>
29 #include <Geant4/G4SystemOfUnits.hh>
30 #include <Geant4/G4ThreeVector.hh>
31 #include <Geant4/G4Transform3D.hh>
32 #include <Geant4/G4Types.hh>
33 #include <Geant4/G4VPhysicalVolume.hh>
36 #pragma GCC diagnostic push
37 #pragma GCC diagnostic ignored "-Wshadow"
38 #include <Geant4/G4GDMLParser.hh>
39 #include <Geant4/G4GDMLReadStructure.hh>
40 #pragma GCC diagnostic pop
55 , m_ParamsContainer(_paramsContainer)
56 , m_StaveGeometryFile(_paramsContainer->GetParameters(PHG4MvtxDefs::
GLOBAL)->get_string_param(
"stave_geometry_file"))
62 cout <<
"PHG4EICMvtxDetector constructor called" << endl;
67 cout <<
" cm " <<
cm <<
" mm " <<
mm << endl;
69 for (
int ilayer = 0; ilayer <
n_Layers; ++ilayer)
88 cout <<
"PHG4EICMvtxDetector constructor: making Mvtx detector. " << endl;
102 cout <<
" -- PHG4MvtxTDetector::IsSensor --" << endl;
103 cout <<
" volume Name : " << volume->GetName() << endl;
104 cout <<
" -----------------------------------------" << endl;
120 tie(layer, stave) = iter->second;
123 cout <<
" -- PHG4EICMvtxDetector::IsInMvtx --" << endl;
124 cout <<
" layer: " << layer << endl;
125 cout <<
" stave: " << stave << endl;
126 cout <<
" volume Name : " << volume->GetName() << endl;
127 cout <<
" stave Name : " << iter->first->GetName() << endl;
128 cout <<
" -----------------------------------------" << endl;
168 <<
"PHG4EICMvtxDetector::Construct called for Mvtx " << endl;
183 cout <<
" PHG4EICMvtxDetector::ConstructMvtx:" << endl;
191 std::unique_ptr<G4GDMLReadStructure>
reader(
new G4GDMLReadStructure());
192 G4GDMLParser gdmlParser(reader.get());
196 char assemblyname[500];
197 sprintf(assemblyname,
"MVTXStave");
201 cout <<
"Geting the stave assembly named " << assemblyname << endl;
203 G4AssemblyVolume* av_ITSUStave = reader->GetAssembly(assemblyname);
205 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
212 cout <<
" Constructing Layer " << ilayer << endl;
239 double arcstep = 12.25;
240 double numstaves = 2.0 * M_PI * layer_nominal_radius / arcstep;
241 N_staves = int(2.0 * M_PI * layer_nominal_radius / arcstep);
246 cout <<
" Calculated N_staves for layer "
247 <<
" layer_nominal_radius " << layer_nominal_radius
248 <<
" ITS arcstep " << arcstep
249 <<
" circumference divided by arcstep " << numstaves
250 <<
" N_staves " << N_staves
252 cout <<
"A radius for this layer of " << (
double) N_staves * arcstep / (2.0 * M_PI) + 0.01 <<
" or "
253 << (
double) (N_staves + 1) * arcstep / (2.0 * M_PI) + 0.01 <<
" would produce perfect stave spacing" << endl;
258 double z_location = 0.0;
263 <<
" layer_nominal_radius " << layer_nominal_radius
264 <<
" N_staves " << N_staves
265 <<
" phistep " << phistep
266 <<
" phitilt " << phitilt
274 double phi_offset = M_PI / 2.0;
276 for (
int iphi = 0; iphi < N_staves; iphi++)
281 G4double phi_rotation = phi0 + (
double) iphi * phistep;
288 cout <<
"phi_offset = " << phi_offset <<
" iphi " << iphi <<
" phi_rotation = " << phi_rotation <<
" phitilt " << phitilt << endl;
293 Ra.rotateZ(phi_rotation + phi_offset + phitilt);
296 Ta.setX(layer_nominal_radius * cos(phi_rotation));
297 Ta.setY(layer_nominal_radius * sin(phi_rotation));
302 cout <<
" iphi " << iphi <<
" phi_rotation " << phi_rotation
303 <<
" x " << layer_nominal_radius * cos(phi_rotation)
304 <<
" y " << layer_nominal_radius * sin(phi_rotation)
305 <<
" z " << z_location
308 G4Transform3D Tr(Ra, Ta);
310 av_ITSUStave->MakeImprint(trackerenvelope, Tr, 0,
OverlapCheck());
315 cout <<
"This layer has a total of " << N_staves <<
" staves" << endl;
325 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
327 int nDaughters = av->TotalImprintedVolumes();
328 for (
int i = 0;
i < nDaughters; ++
i, ++
it)
333 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
340 string material_name(lv->GetMaterial()->GetName());
344 cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" built with "
345 << material_name << endl;
347 vector<string> matname = {
"SI",
"KAPTON",
"ALUMINUM",
"Carbon",
"M60J3K",
"WATER"};
349 for (
const string& nam : matname)
351 if (material_name.find(nam) != std::string::npos)
356 cout <<
"SetDisplayProperty - LV " << lv->GetName() <<
" display with " << nam << endl;
366 int nDaughters = lv->GetNoDaughters();
367 for (
int i = 0;
i < nDaughters; ++
i)
373 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
387 ostringstream geonode;
400 for (
unsigned short ilayer = 0; ilayer <
n_Layers; ++ilayer)
421 cout <<
"-- FillPVArray --" << endl;
423 std::vector<G4VPhysicalVolume*>::iterator
it = av->GetVolumesIterator();
425 int nDaughters = av->TotalImprintedVolumes();
426 for (
int i = 0;
i < nDaughters; ++
i, ++
it)
430 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
432 if (pv->GetName().find(
"MVTXHalfStave_pv") != string::npos)
441 cout <<
"Mvtx layer id " << layer << endl;
442 cout <<
"Stave in layer id " << stave << endl;
443 cout <<
"Mvtx stave count " <<
m_StavePV.size() << endl;
444 cout <<
"FillPVArray - AV[" <<
i <<
"] = " << (*it)->GetName() << endl;
445 cout <<
" LV[" <<
i <<
"] = " << worldLogical->GetName() << endl;
454 cout <<
"FillPVArray - AV[" <<
i <<
"] = " << (*it)->GetName() << endl;
455 cout <<
" LV[" <<
i <<
"] = " << worldLogical->GetName() << endl;
463 int nDaughters = lv->GetNoDaughters();
464 for (
int i = 0;
i < nDaughters; ++
i)
469 cout <<
" PV[" <<
i <<
"]: " << pv->GetName() << endl;
471 if (pv->GetName().find(
"MVTXSensor_") != string::npos)
477 cout <<
" Adding Sensor Vol <" << pv->GetName() <<
" (" <<
m_SensorPV.size() <<
")>" << endl;
481 G4LogicalVolume* worldLogical = pv->GetLogicalVolume();
485 cout <<
" LV[" <<
i <<
"]: " << worldLogical->GetName() << endl;