Skip to content
Snippets Groups Projects
Commit c8939dd6 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: add an example to show how place a sub-detelem inside world.

parent 6b755fa9
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ include(${Geant4_USE_FILE})
set(DetSimGeom_srcs
src/WorldDetElemTool.cpp
src/AnExampleDetElemTool.cpp
)
gaudi_add_module(DetSimGeom ${DetSimGeom_srcs}
......
#include "AnExampleDetElemTool.h"
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
#include "G4Isotope.hh"
#include "G4Element.hh"
#include "G4MaterialPropertiesTable.hh"
#include "G4Box.hh"
#include "G4Sphere.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SDManager.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4LogicalBorderSurface.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4OpticalSurface.hh"
DECLARE_COMPONENT(AnExampleDetElemTool)
G4LogicalVolume*
AnExampleDetElemTool::getLV() {
G4Material* Galactic = G4Material::GetMaterial("Galactic");
G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value());
G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0);
return logicAnExample;
}
StatusCode
AnExampleDetElemTool::initialize() {
StatusCode sc;
return sc;
}
StatusCode
AnExampleDetElemTool::finalize() {
StatusCode sc;
return sc;
}
#ifndef AnExampleDetElemTool_h
#define AnExampleDetElemTool_h
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/Property.h"
#include "DetSimInterface/IDetElemTool.h"
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
class AnExampleDetElemTool: public extends<AlgTool, IDetElemTool> {
public:
using extends::extends;
G4LogicalVolume* getLV() override;
StatusCode initialize() override;
StatusCode finalize() override;
private:
Gaudi::Property<double> m_x{this, "X", 30.*m};
Gaudi::Property<double> m_y{this, "Y", 30.*m};
Gaudi::Property<double> m_z{this, "Z", 30.*m};
};
#endif
#include "WorldDetElemTool.h"
#include <GaudiKernel/ToolHandle.h>
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
......@@ -30,6 +32,21 @@ WorldDetElemTool::getLV() {
G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m);
G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0);
// An example, get a detelem first, then place the detector components inside world.
ToolHandle<IDetElemTool> inner_detelem_tool("AnExampleDetElemTool");
G4LogicalVolume* inner_lv = inner_detelem_tool->getLV();
if (inner_lv) {
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
inner_lv, // logical volume
"pAnExampleDetElem", // name
logicWorld, // mother volume
false, // no boolean operations
0); // no field
} else {
warning() << "Can't Find the logical volume ExampleDetElem " << std::endl;
}
return logicWorld;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment