SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SToGS_PlainDF.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 //
27 
28 // G4 includes
29 #include "G4Material.hh"
30 #include "G4Box.hh"
31 #include "G4Tubs.hh"
32 #include "G4Polyhedra.hh"
33 #include "G4Sphere.hh"
34 #include "G4GenericTrap.hh"
35 #include "G4Polycone.hh"
36 
37 #include "G4LogicalVolume.hh"
38 #include "G4AssemblyVolume.hh"
39 
40 #include "G4PVPlacement.hh"
41 #include "G4PVParameterised.hh"
42 #include "G4UserLimits.hh"
43 #include "G4VisAttributes.hh"
44 #include "G4Colour.hh"
45 #include "G4ios.hh"
46 #include "G4SubtractionSolid.hh"
47 #include "G4UnionSolid.hh"
48 #include "G4IntersectionSolid.hh"
49 
50 #include "G4PhysicalVolumeStore.hh"
51 #include "G4LogicalVolumeStore.hh"
52 #include "G4SDManager.hh"
53 #include "G4UnitsTable.hh"
54 
55 #include <stdlib.h>
56 
57 // Project includes
58 #include "SToGS_PlainDF.hh"
59 
60 #include "SToGS_DetectorFactory.hh"
63 
64 using namespace std;
65 
66 // list of all specific factories
67 namespace {
68  // all Plain Detectors
69  SToGS::PlainDF thePlainFactory("PlainDetectors/");
70 }
71 
72 G4VPhysicalVolume * SToGS::PlainDF::Make(G4String detname, G4String opt)
73 {
74 
75  // **************************************************************************
76  // * the WORLD *
77  // **************************************************************************
78 
79  G4VPhysicalVolume *theDetector = 0x0;
80 
81  const G4double world_x = 10.*CLHEP::cm;
82  const G4double world_y = 10.*CLHEP::cm;
83  const G4double world_z = 10.*CLHEP::cm;
84 
85  // use a physical as a container to describe the detector
86 
87  G4Box *detWorld= new G4Box(detname,world_x,world_y,world_z);
88  G4LogicalVolume *detlogicWorld= new G4LogicalVolume(detWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), detname, 0, 0, 0);
89 
90  detlogicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
91 
92  // Must place the World Physical volume unrotated at (0,0,0).
93  theDetector = new G4PVPlacement(0, // no rotation
94  G4ThreeVector(), // at (0,0,0)
95  detlogicWorld, // its logical volume
96  detname, // its name
97  0, // its mother volume
98  false, // no boolean operations
99  -1); // copy number
100 
101  // **************************************************************************
102  // * the geometries *
103  // **************************************************************************
104 
105 
106  //cube geometry
107  G4double cube_x = 1.*CLHEP::mm;
108  G4double cube_y = 1.*CLHEP::mm;
109  G4double cube_z = 1.*CLHEP::mm;
110 
111  //tube geometry
112  G4double innerRadius = 10.*CLHEP::mm;
113  G4double outerRadius = 20.*CLHEP::mm;
114  G4double hz = 20.*CLHEP::mm;
115  G4double startAngle = 0.*CLHEP::deg;
116  G4double spanningAngle = 360.*CLHEP::deg;
117 
118  //sphere geometry
119  G4double sphereRmin= 0.* CLHEP::mm;
120  G4double sphereRmax= 100*CLHEP::mm;
121  G4double sphereSPhi= 0.*CLHEP::mm;
122  G4double sphereDPhi= 360.*CLHEP::deg;//2*Pi
123  G4double sphereSTheta = 0 *CLHEP::deg;
124  G4double sphereDTheta = 180 *CLHEP::deg;
125 
126 
127  G4VSolid *plaindetector = 0x0; G4VPhysicalVolume *plain_physical = 0x0; //it means is a pointer
128  G4String tmp;
129  tmp = detname;
130  tmp += "_Shape";
131  if (detname=="PLAIN_cube")
132  {
133  plaindetector= new G4Box(tmp,cube_x,cube_y,cube_z);
134  }
135  if (detname=="PLAIN_tube")
136  {
137  plaindetector = new G4Tubs(tmp,
138  innerRadius,
139  outerRadius,
140  hz,
141  startAngle,
142  spanningAngle);
143  }
144 
145  if (detname=="PLAIN_sphere")
146  {
147  plaindetector= new G4Sphere (tmp,
148  sphereRmin,
149  sphereRmax,
150  sphereSPhi,
151  sphereDPhi,
152  sphereSTheta,
153  sphereDTheta );
154  }
155  tmp = detname;
156  tmp += "_LV";
157  G4LogicalVolume *plain_logic= new G4LogicalVolume(plaindetector, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), tmp, 0, 0, 0);
158  plain_logic->SetSensitiveDetector( SToGS::UserActionInitialization::GetTrackerSD() );
159 
160  G4VisAttributes *plain_logicVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); //red
161  plain_logic->SetVisAttributes(plain_logicVisAtt);
162 
163  // Must place the Detector Physical volume unrotated at (0,0,0).
164  plain_physical = new G4PVPlacement(0, // no rotation
165  G4ThreeVector(), // at (0,0,0)
166  plain_logic, // its logical volume
167  "plain_P", // its name
168  detlogicWorld, // its mother volume
169  false, // no boolean operations
170  0); // copy number
171 
172 
173 
174 
175  // **************************************************************************
176  // * the CUBE *
177  // **************************************************************************
178 
179 
180  /*
181  //box geometry for test
182  const G4double cube_x = 1.*CLHEP::mm;
183  const G4double cube_y = 1.*CLHEP::mm;
184  const G4double cube_z = 1.*CLHEP::mm;
185 
186  G4VPhysicalVolume *thecube = 0x0; //it means is a pointer
187 
188  // G4bool do_caps = false, do_housing = false;
189 
190  // use a physical as a container to describe the detector
191 
192  G4Box *detCube= new G4Box("detcube",cube_x,cube_y,cube_z);
193  G4LogicalVolume *detlogicCube= new G4LogicalVolume(detCube, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), "det_log", 0, 0, 0);
194 
195  detlogicCube->SetSensitiveDetector( SToGS::UserActionInitialization::GetTrackerSD() );
196 
197  G4VisAttributes *detlogicCubeVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); //red
198  detlogicCube->SetVisAttributes(detlogicCubeVisAtt);
199 
200  // Must place the Cube Physical volume unrotated at (0,0,0).
201  thecube = new G4PVPlacement(0, // no rotation
202  G4ThreeVector(), // at (0,0,0)
203  detlogicCube, // its logical volume
204  "det_P", // its name
205  detlogicWorld, // its mother volume
206  false, // no boolean operations
207  0); // copy number
208 
209 
210  // **************************************************************************
211  // * the TUBE *
212  // **************************************************************************
213 
214 
215  //make a cylinder
216 
217  G4double innerRadius = 10.*CLHEP::mm;
218  G4double outerRadius = 20.*CLHEP::mm;
219  G4double hz = 20.*CLHEP::mm;
220  G4double startAngle = 0.*CLHEP::deg;
221  G4double spanningAngle = 360.*CLHEP::deg;
222 
223  G4VPhysicalVolume *theTube = 0x0;
224 
225 
226  G4Tubs *detTube = new G4Tubs("dettube",
227  innerRadius,
228  outerRadius,
229  hz,
230  startAngle,
231  spanningAngle);
232 
233  G4LogicalVolume *detlogicTube= new G4LogicalVolume(detTube, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), "tube_log", 0, 0, 0);
234 
235 
236  G4VisAttributes *detlogicTubeVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,1.0)); //cyan
237  detlogicTube->SetVisAttributes(detlogicTubeVisAtt);
238  detlogicTube->SetSensitiveDetector( SToGS::UserActionInitialization::GetTrackerSD() );
239 
240  theTube = new G4PVPlacement(0, // no rotation
241  G4ThreeVector(0,0,0), // at (0,0,0)
242  detlogicTube, // its logical volume
243  "tube_P", // its name
244  detlogicWorld, // its mother volume
245  false, // no boolean operations
246  0); // copy number
247 
248 
249  // **************************************************************************
250  // * the SPHERE *
251  // **************************************************************************
252 
253  //make a sphere
254  G4double sphereRmin= 0.* CLHEP::mm;
255  G4double sphereRmax= 100*CLHEP::mm;
256  G4double sphereSPhi= 0.*CLHEP::mm;
257  G4double sphereDPhi= 360.*CLHEP::deg;//2*Pi
258  G4double sphereSTheta = 0 *CLHEP::deg;
259  G4double sphereDTheta = 180 *CLHEP::deg;
260 
261 
262  G4VPhysicalVolume *theSphere = 0x0;
263 
264  G4Sphere *detSphere= new G4Sphere ("detsphere",
265  sphereRmin,
266  sphereRmax,
267  sphereSPhi,
268  sphereDPhi,
269  sphereSTheta,
270  sphereDTheta );
271 
272 
273  G4LogicalVolume *detlogicSphere= new G4LogicalVolume(detSphere, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), "sphere_log", 0, 0, 0);
274 
275 
276  G4VisAttributes *detlogicSphereVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0)); //green
277  detlogicSphere->SetVisAttributes(detlogicSphereVisAtt);
278  detlogicSphere->SetSensitiveDetector( SToGS::UserActionInitialization::GetTrackerSD() );
279 
280  theSphere = new G4PVPlacement(0, // no rotation
281  G4ThreeVector(0,0,0), // at (0,0,0)
282  detlogicSphere, // its logical volume
283  "sphere_P", // its name
284  detlogicWorld, // its mother volume
285  false, // no boolean operations
286  0); // copy number
287 
288 
289  */
290 
291  return theDetector;
292 }
293 /*
294  G4VPhysicalVolume * SToGS::PlainDF::Make(G4String name, G4String version_string)
295  {
296  G4VPhysicalVolume *theDetector = 0x0; G4String detname;
297 
298  if ( name == "PLAIN" ) {
299  detname = GetDetName("PLAIN",version_string);
300  theDetector =
301  MakePLAIN(detname,version_string);
302  }
303 
304 
305 
306  return theDetector;
307  }
308  */
310 {
311 
312 
314  MakeInStore("PLAIN_cube",""); //
315 
317  MakeInStore("PLAIN_tube","");//
318 
320  MakeInStore("PLAIN_sphere","");//
321 
322 }
323 
324 
325 
326 
virtual void MakeStore()
build the default store i.e. all the Ge detectors.
static G4int SetGCopyNb(G4int val)
virtual G4VPhysicalVolume * Make(G4String, G4String)
Should be implemented in any sub factory. It built (C++) a detector and return it.
Base classe to build all Ge like detectors.
static G4VSensitiveDetector * GetTrackerSD(G4String name="/SToGS/SD/Tracker")
to get a general SToGS tracker. In Multi-threading mode, return a new instance otherwise a global one...