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 413 of file gears.cc.
◆ Detector()
Definition at line 429 of file gears.cc.
429 : G4VUserDetectorConstruction(), G4UImessenger(), fWorld(0)
432 fCmdOut =
new G4UIcmdWithAString(
"/geometry/export",
this);
433 fCmdOut->SetGuidance(
"Export geometry gdml file name");
434 fCmdOut->SetParameterName(
"gdml geometry output",
false);
435 fCmdOut->AvailableForStates(G4State_Idle);
440 fCmdSrc =
new G4UIcmdWithAString(
"/geometry/source",
this);
441 fCmdSrc->SetGuidance(
"Set geometry source file name");
442 fCmdSrc->SetParameterName(
"text geometry input",
false);
443 fCmdSrc->AvailableForStates(G4State_PreInit);
445 fCmdSetB =
new G4UIcmdWith3VectorAndUnit(
"/geometry/SetB",
this);
446 fCmdSetB->SetGuidance(
"Set uniform magnetic field value.");
447 fCmdSetB->SetParameterName(
"Bx",
"By",
"Bz",
false);
448 fCmdSetB->SetUnitCategory(
"Magnetic flux density");
◆ ~Detector()
Definition at line 417 of file gears.cc.
417 {
delete fCmdSetB;
delete fCmdSrc;
delete fCmdOut; }
◆ Construct()
G4VPhysicalVolume * Detector::Construct |
( |
| ) |
|
called at /run/initialize
Definition at line 493 of file gears.cc.
496 G4cout<<
"GEARS: no detector specified, set to a 10x10x10 m^3 box."<<G4endl;
497 auto box =
new G4Box(
"hall", 5*CLHEP::m, 5*CLHEP::m, 5*CLHEP::m);
498 G4NistManager *nist = G4NistManager::Instance();
499 G4Material *vacuum = nist->FindOrBuildMaterial(
"G4_Galactic");
500 auto v =
new G4LogicalVolume(box, vacuum,
"hall");
501 fWorld =
new G4PVPlacement(0, G4ThreeVector(), v,
"hall", 0, 0, 0);
◆ SetNewValue()
void Detector::SetNewValue |
( |
G4UIcommand * |
cmd, |
|
|
G4String |
value |
|
) |
| |
for G4UI
Definition at line 458 of file gears.cc.
461 auto field =
new G4UniformMagField(0,0,0);
462 field->SetFieldValue(fCmdSetB->GetNew3VectorValue(value));
463 G4FieldManager* mgr =
464 G4TransportationManager::GetTransportationManager()->GetFieldManager();
465 mgr->SetDetectorField(field);
466 mgr->CreateChordFinder(field);
467 G4cout<<
"GEARS: Magnetic field is set to "<<value<<G4endl;
469 }
else if(cmd==fCmdOut) {
471 paser.Write(value,fWorld);
474 if (value.substr(value.length()-4)!=
"gdml") {
475 G4tgbVolumeMgr* mgr = G4tgbVolumeMgr::GetInstance();
476 mgr->AddTextFile(value);
478 mgr->SetDetectorBuilder(tgb);
479 fWorld = mgr->ReadAndConstructDetector();
484 fWorld=parser.GetWorldVolume();
Construct detector based on text geometry description.
The documentation for this class was generated from the following file: