3 #include <fwk/CentralConfig.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/Reader.h>
6 #include <utl/MathConstants.h>
9 #include <G4RunManager.hh>
10 #include <G4RegionStore.hh>
13 #include <G4LogicalVolume.hh>
14 #include <G4ThreeVector.hh>
15 #include <G4PVPlacement.hh>
16 #include <G4Transform3D.hh>
17 #include <G4RotationMatrix.hh>
18 #include <G4VisAttributes.hh>
19 #include <G4Colour.hh>
20 #include <G4Material.hh>
21 #include <G4Element.hh>
22 #include <G4MaterialPropertiesTable.hh>
24 #include <utl/TabularStream.h>
25 #include <utl/ConfigUtils.h>
30 using namespace EdepSimulatorAG;
32 ScintillatorConstruction::ScintillatorConstruction ( )
36 fLogicalScintillator = 0;
37 fPhysicalScintillator = 0;
38 L_LogScintillator = 0;
39 L_PhyScintillator = 0;
40 R_LogScintillator = 0;
41 R_PhyScintillator = 0;
43 INFO(
"\n++++\nGetting parameters from XML file...");
46 fLog.Configure(config);
48 fUnits.SetEnergyDefault(
utl::MeV,
"MeV");
49 fUnits.SetLengthDefault(
utl::cm ,
"cm");
50 fUnits.Configure(config);
54 std::vector<G4double> vScintiSize, vScintiSizeDefault;
56 vScintiSizeDefault.push_back( 4.01*
utl::cm );
57 vScintiSizeDefault.push_back( 400.00*
utl::cm );
58 vScintiSizeDefault.push_back( 1.00*
utl::cm );
62 fScint_Side_X = vScintiSize.at(0)/2;
63 fScint_Side_Y = vScintiSize.at(1)/2;
64 fScint_Side_Z = vScintiSize.at(2)/2;
66 fWorld_Side_X = 3*fScint_Side_X;
67 fWorld_Side_Y = fScint_Side_Y;
68 fWorld_Side_Z = fScint_Side_Z;
81 G4cerr <<
"X World size " << 2*fWorld_Side_X/
CLHEP::m <<
" (m)" << G4endl;
82 G4cerr <<
"Y World size " << 2*fWorld_Side_Y/
CLHEP::m <<
" (m)" << G4endl;
83 G4cerr <<
"Z World size " << 2*fWorld_Side_Z/
CLHEP::m <<
" (m)" << G4endl;
85 G4cerr <<
"Scintillator Density " << fScintillatorDensity/(
CLHEP::g/
CLHEP::cm3) <<
" g/cm3"<< G4endl;
87 G4cerr <<
"X Scinti size " << 2*fScint_Side_X/
CLHEP::m <<
" (m)" << G4endl;
88 G4cerr <<
"Y Scinti size " << 2*fScint_Side_Y/
CLHEP::m <<
" (m)" << G4endl;
89 G4cerr <<
"Z Scinti size " << 2*fScint_Side_Z/
CLHEP::m <<
" (m)" << G4endl;
95 ScintillatorConstruction::~ScintillatorConstruction ( ){}
98 ScintillatorConstruction::Construct ( )
101 G4Colour
red ( 1, 0, 0 );
102 G4Colour
green ( 0, 1, 0 );
103 G4Colour
blue ( 0, 0, 1 );
105 G4ThreeVector placement;
107 INFO(
"\n++++\nCreating World for scintillator simulation");
109 G4Box *WorldBox =
new G4Box(
"WorldBox", fWorld_Side_X, fWorld_Side_Y, fWorld_Side_Z);
110 fLogicalWorld =
new G4LogicalVolume ( WorldBox, fWorldMaterial,
"LogWorld", 0, 0, 0 );
111 fPhysicalWorld =
new G4PVPlacement ( 0, G4ThreeVector ( ), fLogicalWorld,
"WorldPhys", 0,
false, 0 );
112 G4VisAttributes *fLogicalWorldVisAtt =
new G4VisAttributes ( red );
113 fLogicalWorld->SetVisAttributes ( fLogicalWorldVisAtt );
116 INFO(
"\n++++\nCreating scintillator + first neighbours");
118 G4Box *ScintillatorBox =
new G4Box (
"ScintillatorBox", fScint_Side_X, fScint_Side_Y, fScint_Side_Z );
119 fLogicalScintillator =
new G4LogicalVolume ( ScintillatorBox, fScintillatorMaterial,
"ScintillatorLog" );
121 G4double scintillator_pos_x;
122 G4double scintillator_pos_y;
123 G4double scintillator_pos_z;
126 scintillator_pos_x = 0.0 *
utl::m;
127 scintillator_pos_y = 0.0 *
utl::m;
128 scintillator_pos_z = 0.0 *
utl::m;
129 placement = G4ThreeVector ( scintillator_pos_x, scintillator_pos_y, scintillator_pos_z );
130 fPhysicalScintillator =
new G4PVPlacement ( 0, placement, fLogicalScintillator,
"CentralScint", fLogicalWorld,
false, 0 );
131 fLogicalScintillator->SetVisAttributes (
new G4VisAttributes ( green ) );
134 L_LogScintillator =
new G4LogicalVolume ( ScintillatorBox, fScintillatorMaterial,
"L_ScintillatorLog" );
135 placement = G4ThreeVector ( scintillator_pos_x - 2*fScint_Side_X, scintillator_pos_y, scintillator_pos_z );
136 L_PhyScintillator =
new G4PVPlacement ( 0, placement, L_LogScintillator,
"LeftScint", fLogicalWorld,
false, 0 );
137 L_LogScintillator ->SetVisAttributes (
new G4VisAttributes ( blue ) );
139 R_LogScintillator =
new G4LogicalVolume ( ScintillatorBox, fScintillatorMaterial,
"R_ScintillatorLog" );
140 placement = G4ThreeVector ( scintillator_pos_x + 2*fScint_Side_X, scintillator_pos_y, scintillator_pos_z );
141 R_PhyScintillator =
new G4PVPlacement ( 0, placement, R_LogScintillator,
"RightScint", fLogicalWorld,
false, 0 );
142 R_LogScintillator ->SetVisAttributes (
new G4VisAttributes ( blue ) );
144 return fPhysicalWorld;
148 ScintillatorConstruction::CreateMaterials ( )
150 INFO(
"\n++++\nCreating materials...");
159 G4Material *Polystyrene =
new G4Material (
"Polystyrene", fScintillatorDensity, nel = 2 );
160 Polystyrene->AddElement ( C, 8 );
161 Polystyrene->AddElement ( H, 8 );
164 fScintillatorMaterial =
new G4Material (
"Scintillator", fScintillatorDensity , nel = 1 );
165 fScintillatorMaterial->AddMaterial ( Polystyrene, 100.0 *
CLHEP::perCent );
static const G4Colour green(0.0, 1.0, 0.0)
#define INFO(message)
Macro for logging informational messages.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Class representing a document branch.
static const G4Colour red(1.0, 0.0, 0.0)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
static const G4Colour blue(0.0, 0.0, 1.0)