Geant4  10.01
exrdmDetectorConstruction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: exrdmDetectorConstruction.cc 84601 2014-10-17 07:44:52Z gcosmo $
27 //
30 //
33 //#include "exrdmDetectorSD.hh"
34 #include "G4UImanager.hh"
35 #include "G4Tubs.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 //#include "G4SDManager.hh"
39 #include "G4Region.hh"
40 #include "G4RegionStore.hh"
41 
42 #include "exrdmMaterial.hh"
43 
44 #include "G4VisAttributes.hh"
45 #include "G4Colour.hh"
46 #include "G4PhysicalConstants.hh"
47 #include "G4SystemOfUnits.hh"
48 
49 #include "G4ios.hh"
50 #include <sstream>
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
56  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
57  fSolidTarget(0), fLogicTarget(0), fPhysiTarget(0),
58  fSolidDetector(0),fLogicDetector(0),fPhysiDetector(0),
59  fDetectorMessenger(0),
60  fMaterialsManager(0),
61  fDefaultMater(0),fTargetMater(0),fDetectorMater(0),
62  fTargetLength (1.*cm), fTargetRadius(0.5*cm),
63  fDetectorLength(5.0 * cm), fDetectorThickness(2.0 * cm),
64  fWorldLength (std::max(fTargetLength,fDetectorLength)),
65  fWorldRadius (fTargetRadius + fDetectorThickness),
66  fTargetRegion(0), fDetectorRegion(0)
67 {
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  delete fDetectorMessenger;
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
82 {
83 //--------- Material definition ---------
84 
86  // Lead
87  fMaterialsManager->AddMaterial("Lead","Pb",11.3*g/cm3,"");
88  //Germanium detector
89  fMaterialsManager->AddMaterial("Germanium","Ge",5.323*g/cm3,"");
90  //CsI
91  fMaterialsManager->AddMaterial("CsI","Cs-I",4.51*g/cm3,"");
92 
93  // G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
94  // G4cout << *(G4Material::GetMaterialTable()) << G4endl;
95 
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
104 {
105 //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
106  //--------- Sizes of the principal geometrical components (solids) ---------
107 
110 
111  //------------------------------
112  // World
113  //------------------------------
114 
115  fSolidWorld= new G4Tubs("world",0.,fWorldRadius,fWorldLength/2.,0.,twopi);
116  fLogicWorld= new G4LogicalVolume( fSolidWorld, fDefaultMater, "World", 0, 0, 0);
117 
118  // Must place the World Physical volume unrotated at (0,0,0).
119  //
120  fPhysiWorld = new G4PVPlacement(0, // no rotation
121  G4ThreeVector(), // at (0,0,0)
122  fLogicWorld, // its logical volume
123  "World", // its name
124  0, // its mother volume
125  false, // no boolean operations
126  0); // no field specific to volume
127 
128  //------------------------------
129  // Target
130  //------------------------------
131 
132  G4ThreeVector positionTarget = G4ThreeVector(0,0,0);
133 
134  fSolidTarget = new G4Tubs("target",0.,fTargetRadius,fTargetLength/2.,0.,twopi);
136  fPhysiTarget = new G4PVPlacement(0, // no rotation
137  positionTarget, // at (x,y,z)
138  fLogicTarget, // its logical volume
139  "Target", // its name
140  fLogicWorld, // its mother volume
141  false, // no boolean operations
142  0); // no particular field
143 
144  // G4cout << "Target is a cylinder with rdius of " << targetradius/cm << " cm of "
145  // << fTargetMater->GetName() << G4endl;
146 
147  //------------------------------
148  // Detector
149  //------------------------------
150 
151  G4ThreeVector positionDetector = G4ThreeVector(0,0,0);
152 
154  fDetectorLength/2.,0.,twopi);
156  "Detector",0,0,0);
157  fPhysiDetector = new G4PVPlacement(0, // no rotation
158  positionDetector, // at (x,y,z)
159  fLogicDetector, // its logical volume
160  "Detector", // its name
161  fLogicWorld, // its mother volume
162  false, // no boolean operations
163  0); // no particular field
164 
165  //------------------------------------------------
166  // Sensitive detectors
167  //------------------------------------------------
168 
169  // G4SDManager* SDman = G4SDManager::GetSDMpointer();
170 
171  // G4String detectortargetSDname = "exrdm/DetectorTargetSD";
172  // exrdmDetectorSD* aDetectorSD = new exrdmDetectorSD( detectorTargetSDname );
173  // SDman->AddNewDetector( aDetectorSD );
174  //fLogicTarget->SetSensitiveDetector( aDetectorSD );
175  // fLogicDetector->SetSensitiveDetector( aDetectorSD );
176  //
177  //-------------------------------------------------
178  // regions
179  //
180  // if(fTargetRegion) delete fTargetRegion;
181  // if(fDetectorRegion) delete fDetectorRegion;
182  fTargetRegion = new G4Region("Target");
183  fDetectorRegion = new G4Region("Detector");
186 
187  //--------- Visualization attributes -------------------------------
189  G4VisAttributes* TargetVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
190  fLogicTarget ->SetVisAttributes(TargetVisAtt);
191  G4VisAttributes* DetectorVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,.0));
192  fLogicDetector->SetVisAttributes(DetectorVisAtt);
193 
194 
195  //------------ set the incident position ------
196 
197  // get the pointer to the User Interface manager
198 
200  // UI->ApplyCommand("/run/verbose 1");
201  // UI->ApplyCommand("/event/verbose 2");
202  // UI->ApplyCommand("/tracking/verbose 1");
203 
204  G4double zpos = -fWorldLength/2.;
205  G4String command = "/gps/pos/centre ";
206  std::ostringstream os;
207  os << zpos ;
208  G4String xs = os.str();
209  UI->ApplyCommand(command+"0. 0. "+xs+" mm");
210  UI->ApplyCommand("/gps/pos/type Point");
211  command = "/gps/position ";
212  // UI->ApplyCommand(command+"0. 0. "+xs+" mm");
213  UI->ApplyCommand("/gps/particle proton");
214  UI->ApplyCommand("/gps/direction 0 0 1");
215  UI->ApplyCommand("/gps/energy 100 MeV");
216  //
217 
218  return fPhysiWorld;
219 }
220 
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
222 
224 {
225  // search the material by its name
226  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
227  if (pttoMaterial)
228  {fTargetMater = pttoMaterial;
229  if (fLogicTarget) fLogicTarget->SetMaterial(pttoMaterial);
230  G4cout << "\n----> The target has been changed to " << fTargetLength/cm
231  << " cm of "
232  << materialName << G4endl;
233  }
234 }
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
237 
239 {
240  // search the material by its name
241  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
242  if (pttoMaterial)
243  {fDetectorMater = pttoMaterial;
244  if (fLogicDetector) fLogicDetector->SetMaterial(pttoMaterial);
245  G4cout << "\n----> The Deetctor has been changed to" << fDetectorLength/cm
246  << " cm of "
247  << materialName << G4endl;
248  }
249 }
250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
static const double cm
Definition: G4SIunits.hh:106
exrdmDetectorMessenger * fDetectorMessenger
G4Material * GetMaterial(G4int i)
Definition of the exrdmDetectorConstruction class.
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
Definition: G4Tubs.hh:85
void AddMaterial(G4String, G4String, G4double, G4String, G4double tem=CLHEP::STP_Temperature, G4double pres=CLHEP::STP_Pressure)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
Definition of the exrdmMaterial class.
G4GLOB_DLL std::ostream G4cout
static const double cm3
Definition: G4SIunits.hh:108
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static const double g
Definition: G4SIunits.hh:162
Definition of the exrdmDetectorMessenger class.
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
void SetVisAttributes(const G4VisAttributes *pVA)
virtual G4VPhysicalVolume * Construct()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432