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 430 of file gears.cc.
430 : G4VUserDetectorConstruction(), G4UImessenger(), fWorld(0)
433 fCmdOut =
new G4UIcmdWithAString(
"/geometry/export",
this);
434 fCmdOut->SetGuidance(
"Export geometry gdml file name");
435 fCmdOut->SetParameterName(
"gdml geometry output",
false);
436 fCmdOut->AvailableForStates(G4State_Idle);
441 fCmdSrc =
new G4UIcmdWithAString(
"/geometry/source",
this);
442 fCmdSrc->SetGuidance(
"Set geometry source file name");
443 fCmdSrc->SetParameterName(
"text geometry input",
false);
444 fCmdSrc->AvailableForStates(G4State_PreInit);
446 fCmdLmt =
new G4UIcommand(
"/tracking/setStepLimit",
this);
447 fCmdLmt->SetGuidance(
"set max step length for a logical volume");
448 fCmdLmt->AvailableForStates(G4State_Idle);
449 G4UIparameter *p0 =
new G4UIparameter(
"logical volume name",
's',
false);
450 G4UIparameter *p1 =
new G4UIparameter(
"step length in mm",
'd',
false);
451 fCmdLmt->SetParameter(p0); fCmdLmt->SetParameter(p1);
453 fCmdSetB =
new G4UIcmdWith3VectorAndUnit(
"/geometry/SetB",
this);
454 fCmdSetB->SetGuidance(
"Set uniform magnetic field value.");
455 fCmdSetB->SetParameterName(
"Bx",
"By",
"Bz",
false);
456 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 510 of file gears.cc.
513 G4cout<<
"GEARS: no detector specified, set to a 10x10x10 m^3 box."<<G4endl;
514 auto box =
new G4Box(
"hall", 5*CLHEP::m, 5*CLHEP::m, 5*CLHEP::m);
515 G4NistManager *nist = G4NistManager::Instance();
516 G4Material *vacuum = nist->FindOrBuildMaterial(
"G4_Galactic");
517 auto v =
new G4LogicalVolume(box, vacuum,
"hall");
518 fWorld =
new G4PVPlacement(0, G4ThreeVector(), v,
"hall", 0, 0, 0);
◆ SetNewValue()
void Detector::SetNewValue |
( |
G4UIcommand * |
cmd, |
|
|
G4String |
value |
|
) |
| |
for G4UI
Definition at line 468 of file gears.cc.
471 auto field =
new G4UniformMagField(0,0,0);
472 field->SetFieldValue(fCmdSetB->GetNew3VectorValue(value));
473 G4FieldManager* mgr =
474 G4TransportationManager::GetTransportationManager()->GetFieldManager();
475 mgr->SetDetectorField(field);
476 mgr->CreateChordFinder(field);
477 G4cout<<
"GEARS: Magnetic field is set to "<<value<<G4endl;
479 }
else if (cmd==fCmdOut) {
481 paser.Write(value, fWorld);
483 }
else if (cmd==fCmdLmt) {
484 istringstream iss(value); G4String vlm, limit; iss>>vlm>>limit;
485 auto v = G4LogicalVolumeStore::GetInstance()->GetVolume(vlm);
487 v->SetUserLimits(
new G4UserLimits(stof(limit)));
488 G4cout<<
"GEARS: max step length in "<<vlm<<
": "<<limit<<
" mm"<<G4endl;
491 if (value.substr(value.length()-4)!=
"gdml") {
492 G4tgbVolumeMgr* mgr = G4tgbVolumeMgr::GetInstance();
493 mgr->AddTextFile(value);
495 mgr->SetDetectorBuilder(tgb);
496 fWorld = mgr->ReadAndConstructDetector();
501 fWorld=parser.GetWorldVolume();
Construct detector based on text geometry description.
The documentation for this class was generated from the following file: