Construct detector geometry.
More...
Construct detector geometry.
This uses two types of instructions to construct a detector:
It won't work together with HP neutron simulation if Geant4 version is lower than 10 because of this bug: http://hypernews.slac.stanford.edu/HyperNews/geant4/get/hadronprocess/1242.html?inline=-1
Definition at line 506 of file gears.cc.
◆ Detector()
Definition at line 526 of file gears.cc.
527 : G4VUserDetectorConstruction(), G4UImessenger(), fWorld(0) {
529 fCmdOut =
new G4UIcmdWithAString(
"/geometry/export",
this);
530 fCmdOut->SetGuidance(
"Export geometry gdml file name");
531 fCmdOut->SetParameterName(
"gdml geometry output",
false);
532 fCmdOut->AvailableForStates(G4State_Idle);
537 fCmdSrc =
new G4UIcmdWithAString(
"/geometry/source",
this);
538 fCmdSrc->SetGuidance(
"Set geometry source file name");
539 fCmdSrc->SetParameterName(
"text geometry input",
false);
540 fCmdSrc->AvailableForStates(G4State_PreInit);
542 fCmdLmt =
new G4UIcommand(
"/tracking/setStepLimit",
this);
543 fCmdLmt->SetGuidance(
"set max step length for a logical volume");
544 fCmdLmt->AvailableForStates(G4State_Idle);
545 G4UIparameter *p0 =
new G4UIparameter(
"logical volume name",
's',
false);
546 G4UIparameter *p1 =
new G4UIparameter(
"step length in mm",
'd',
false);
547 fCmdLmt->SetParameter(p0);
548 fCmdLmt->SetParameter(p1);
550 fCmdSetB =
new G4UIcmdWith3VectorAndUnit(
"/geometry/SetB",
this);
551 fCmdSetB->SetGuidance(
"Set uniform magnetic field value.");
552 fCmdSetB->SetParameterName(
"Bx",
"By",
"Bz",
false);
553 fCmdSetB->SetUnitCategory(
"Magnetic flux density");
◆ ~Detector()
◆ Construct()
| G4VPhysicalVolume * Detector::Construct |
( |
| ) |
|
called at /run/initialize
Definition at line 609 of file gears.cc.
610 if (fWorld == NULL) {
611 G4cout <<
"GEARS: no detector specified, set to a 10x10x10 m^3 box." 613 auto box =
new G4Box(
"hall", 5 * CLHEP::m, 5 * CLHEP::m, 5 * CLHEP::m);
614 G4NistManager *nist = G4NistManager::Instance();
615 G4Material *vacuum = nist->FindOrBuildMaterial(
"G4_Galactic");
616 auto v =
new G4LogicalVolume(box, vacuum,
"hall");
617 fWorld =
new G4PVPlacement(0, G4ThreeVector(), v,
"hall", 0, 0, 0);
◆ SetNewValue()
| void Detector::SetNewValue |
( |
G4UIcommand * |
cmd, |
|
|
G4String |
value |
|
) |
| |
for G4UI
Definition at line 565 of file gears.cc.
566 if (cmd == fCmdSetB) {
567 auto field =
new G4UniformMagField(0, 0, 0);
568 field->SetFieldValue(fCmdSetB->GetNew3VectorValue(value));
569 G4FieldManager *mgr =
570 G4TransportationManager::GetTransportationManager()->GetFieldManager();
571 mgr->SetDetectorField(field);
572 mgr->CreateChordFinder(field);
573 G4cout <<
"GEARS: Magnetic field is set to " << value << G4endl;
575 }
else if (cmd == fCmdOut) {
577 paser.Write(value, fWorld);
579 }
else if (cmd == fCmdLmt) {
580 istringstream iss(value);
583 auto v = G4LogicalVolumeStore::GetInstance()->GetVolume(vlm);
585 v->SetUserLimits(
new G4UserLimits(stof(limit)));
586 G4cout <<
"GEARS: max step length in " << vlm <<
": " << limit <<
" mm" 590 if (value.substr(value.length() - 4) !=
"gdml") {
591 G4tgbVolumeMgr *mgr = G4tgbVolumeMgr::GetInstance();
592 mgr->AddTextFile(value);
594 mgr->SetDetectorBuilder(tgb);
595 fWorld = mgr->ReadAndConstructDetector();
600 fWorld = parser.GetWorldVolume();
Construct detector based on text geometry description.
The documentation for this class was generated from the following file: