Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
G02DetectorConstruction Class Reference

Detector construction used in GDML read/write example. More...

#include <Doxymodules_persistency.h>

Inheritance diagram for G02DetectorConstruction:
G4VUserDetectorConstruction

Public Member Functions

 G02DetectorConstruction ()
 
 ~G02DetectorConstruction ()
 
virtual G4VPhysicalVolumeConstruct ()
 
G4LogicalVolumeConstructSubDetector1 ()
 
G4LogicalVolumeConstructSubDetector2 ()
 
G4VPhysicalVolumeConstructDetector ()
 
G4LogicalVolumeConstructAssembly ()
 
G4LogicalVolumeConstructParametrisationChamber ()
 
void ListOfMaterials ()
 
void SetReadFile (const G4String &File)
 
void SetWriteFile (const G4String &File)
 
void SetStepFile (const G4String &File)
 

Private Attributes

G4MaterialfAir
 
G4MaterialfAluminum
 
G4MaterialfPb
 
G4MaterialfXenon
 
G4GDMLParser fParser
 
G4String fReadFile
 
G4String fWriteFile
 
G4String fStepFile
 
G4int fWritingChoice
 
G02DetectorMessengerfDetectorMessenger
 
G4double fExpHall_x
 

Detailed Description

Detector construction used in GDML read/write example.

Definition at line 35 of file Doxymodules_persistency.h.

Constructor & Destructor Documentation

◆ G02DetectorConstruction()

G02DetectorConstruction::G02DetectorConstruction ( )

◆ ~G02DetectorConstruction()

G02DetectorConstruction::~G02DetectorConstruction ( )

Definition at line 107 of file G02DetectorConstruction.cc.

108{
110}

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * G02DetectorConstruction::Construct ( )
virtual

Definition at line 116 of file G02DetectorConstruction.cc.

117{
118 // Writing or Reading of Geometry using G4GDML
119
120 G4VPhysicalVolume* fWorldPhysVol;
121
122 if(fWritingChoice==0)
123 {
124 // **** LOOK HERE*** FOR READING GDML FILES
125 //
126
127 // ACTIVATING OVERLAP CHECK when read volumes are placed.
128 // Can take long time in case of complex geometries
129 //
130 // fParser.SetOverlapCheck(true);
131
132 fParser.Read(fReadFile);
133
134 // READING GDML FILES OPTION: 2nd Boolean argument "Validate".
135 // Flag to "false" disables check with the Schema when reading GDML file.
136 // See the GDML Documentation for more information.
137 //
138 // fParser.Read(fReadFile,false);
139
140 // Prints the material information
141 //
142 G4cout << *(G4Material::GetMaterialTable() ) << G4endl;
143
144 // Giving World Physical Volume from GDML Parser
145 //
146 fWorldPhysVol = fParser.GetWorldVolume();
147 }
148 else if(fWritingChoice==1)
149 {
150 // **** LOOK HERE*** FOR WRITING GDML FILES
151 // Detector Construction and WRITING to GDML
152 //
154 fWorldPhysVol = ConstructDetector();
155
156 // OPTION: TO ADD MODULE AT DEPTH LEVEL ...
157 //
158 // Can be a integer or a pointer to the top Physical Volume:
159 //
160 // G4int depth=1;
161 // fParser.AddModule(depth);
162
163 // OPTION: SETTING ADDITION OF POINTER TO NAME TO FALSE
164 //
165 // By default, written names in GDML consist of the given name with
166 // appended the pointer reference to it, in order to make it unique.
167 // Naming policy can be changed by using the following method, or
168 // calling Write with additional Boolean argument to "false".
169 // NOTE: you have to be sure not to have duplication of names in your
170 // Geometry Setup.
171 //
172 // fParser.SetAddPointerToName(false);
173 //
174 // or
175 //
176 // fParser.Write(fWriteFile, fWorldPhysVol, false);
177
178 // OPTION: SET MAXIMUM LEVEL TO EXPORT (REDUCED TREE)...
179 //
180 // Can be a integer greater than zero:
181 //
182 // G4int maxlevel=3;
183 // fParser.SetMaxExportLevel(maxlevel);
184
185 // Writing Geometry to GDML File
186 //
187 fParser.Write(fWriteFile, fWorldPhysVol);
188
189 // OPTION: SPECIFYING THE SCHEMA LOCATION
190 //
191 // When writing GDML file the default the Schema Location from the
192 // GDML web site will be used:
193 // "http://cern.ch/service-spi/app/releases/GDML/GDML_2_10_0/src/GDMLSchema/gdml.xsd"
194 //
195 // NOTE: GDML Schema is distributed in Geant4 in the directory:
196 // $G4INSTALL/source/persistency/gdml/schema
197 //
198 // You can change the Schema path by adding a parameter to the Write
199 // command, as follows:
200 //
201 // fParser.Write(fWriteFile, fWorldPhysVol, "your-path-to-schema/gdml.xsd");
202 }
203 else // Demonstration how to Read STEP files using GDML
204 {
205 // Some printout...
206 //
208
209 // Arbitrary values that should enclose any reasonable geometry
210 //
211 const G4double expHall_y = fExpHall_x/50.;
212 const G4double expHall_z = fExpHall_x/50.;
213
214 // Create the hall
215 //
216 G4Box * experimentalHallBox
217 = new G4Box("ExpHallBox",fExpHall_x/50.,expHall_y,expHall_z);
218 G4LogicalVolume * experimentalHallLV
219 = new G4LogicalVolume(experimentalHallBox, fAir,"ExpHallLV");
220 fWorldPhysVol
221 = new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0),
222 experimentalHallLV, "ExpHallPhys", 0, false, 0);
223
224 // G02DetectorConstruction via reading STEP File
225 //
226 G4LogicalVolume* LogicalVolST
227 = fParser.ParseST(fStepFile,fAir,fAluminum);
228
229 // Placement inside of the hall
230 //
231 new G4PVPlacement(0, G4ThreeVector(10.0,0.0,0.0), LogicalVolST,
232 "StepPhys", experimentalHallLV, false, 0);
233 }
234
235 // Set Visualization attributes to world
236 //
237 G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
238 fWorldPhysVol->GetLogicalVolume()->SetVisAttributes(BoxVisAtt);
239
240 return fWorldPhysVol;
241}
G4VPhysicalVolume * ConstructDetector()

◆ ConstructSubDetector1()

G4LogicalVolume * G02DetectorConstruction::ConstructSubDetector1 ( )

Definition at line 404 of file G02DetectorConstruction.cc.

405{
406 const G4double sub_x = fExpHall_x/5.;
407 const G4double sub_y = sub_x;
408
409 // Create the hall
410 //
411 G4Tubs * subTub =
412 new G4Tubs("subTub", 0., sub_x, sub_y, -90.*deg, 180*deg);
413 G4LogicalVolume * subTubLV =
414 new G4LogicalVolume(subTub, fPb, "tubLV");
415 G4LogicalVolume *AssemblyLV = ConstructAssembly();
416 // G4PVPlacement * detAss =
417 new G4PVPlacement(0, G4ThreeVector(sub_x/3,0.0,0.0), AssemblyLV,
418 "AssemblyPhys", subTubLV, false, 0);
419 return subTubLV;
420}
G4LogicalVolume * ConstructAssembly()

◆ ConstructSubDetector2()

G4LogicalVolume * G02DetectorConstruction::ConstructSubDetector2 ( )

Definition at line 426 of file G02DetectorConstruction.cc.

427{
428 const G4double sub_x = fExpHall_x/10.;
429 const G4double sub_y = sub_x*2.;
430 const G4double sub_z = sub_x;
431
432 // Create the hall
433 //
434 G4Box * detHallBox =
435 new G4Box("detHallBox", sub_x, sub_y, sub_z);
436 G4LogicalVolume * detHallLV =
437 new G4LogicalVolume(detHallBox, fAluminum, "detHallLV");
438
439 return detHallLV;
440}

◆ ConstructDetector()

G4VPhysicalVolume * G02DetectorConstruction::ConstructDetector ( )

Definition at line 307 of file G02DetectorConstruction.cc.

308{
309 // Arbitary values that should enclose any reasonable geometry
310 //
311 const G4double expHall_y = fExpHall_x;
312 const G4double expHall_z = fExpHall_x;
313
314 // Create the hall
315 //
316 G4Box * experimentalHallBox =
317 new G4Box("ExpHallBox", fExpHall_x, expHall_y, expHall_z);
318 G4LogicalVolume * experimentalHallLV =
319 new G4LogicalVolume(experimentalHallBox, fAir, "ExpHallLV");
320 G4PVPlacement * experimentalHallPhys =
321 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), experimentalHallLV,
322 "ExpHallPhys", 0, false, 0);
323
324 // G02DetectorConstruction
325
326 const G4double det_x = fExpHall_x*0.8;
327 const G4double det_y = fExpHall_x*0.7;
328 const G4double det_z = det_y;
329
330 // Create the detector box
331 //
332 G4Box * detectorBox =
333 new G4Box("detectorBox", det_x, det_y, det_z);
334 G4LogicalVolume * detectorLV =
335 new G4LogicalVolume(detectorBox, fAir, "detLV");
336 // G4PVPlacement * detectorPhys =
337 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), detectorLV,
338 "detPhys", experimentalHallLV, false, 0);
339
340 // Create the Control room box
341 //
342 const G4double room_x = fExpHall_x/20.;
343 const G4double room_y = room_x;
344 const G4double room_z = room_x;
345
346 G4Box * roomBox =
347 new G4Box("roomBox", room_x, room_y, room_z);
348 G4LogicalVolume * roomLV =
349 new G4LogicalVolume(roomBox, fAir, "roomLV");
350 // G4PVPlacement * roomPhys =
351 new G4PVPlacement(0, G4ThreeVector(fExpHall_x-room_x-10.,0.0,0.0), roomLV,
352 "roomPhys", experimentalHallLV, false, 0);
353
354 // SubDetector1
355 //
356 const G4double bigL=fExpHall_x/5.+50.;
357 G4LogicalVolume* subDetectorLV1 = ConstructSubDetector1();
358 // G4PVPlacement * detPhys1 =
359 new G4PVPlacement(0, G4ThreeVector(bigL,0.0,0.0), subDetectorLV1,
360 "PhysSubDetector1", detectorLV, false, 0);
361
362 //
363 // LOOK HERE FOR REFLECTIONS
364 //
365
366 // SubDetector2
367 //
368 G4Translate3D translation(-bigL, 0., 0.);
369 G4RotationMatrix* rotD3 = new G4RotationMatrix();
370 G4Transform3D rotation = G4Rotate3D(*rotD3);
371 G4ReflectX3D reflection;
372 G4Transform3D transform = translation*rotation*reflection;
373
374 // Place the reflected part using G4ReflectionFactory
375 //
376 G4ReflectionFactory::Instance()->Place(transform, "reflSubDetector",
377 subDetectorLV1, detectorLV, false, 0);
378
379 // SubDetector3
380 //
381 G4LogicalVolume* subDetectorLV3 = ConstructSubDetector2();
382 // G4PVPlacement * detPhys3 =
383 new G4PVPlacement(0, G4ThreeVector(0.0,bigL,0.0), subDetectorLV3,
384 "PhysSubDetectorFirst3", detectorLV, false, 0);
385
386 // SubDetector4, placement of parameterised chambers
387 //
388 G4LogicalVolume* subDetectorLV4 = ConstructSubDetector2();
390 // G4PVPlacement * detChamb =
391 new G4PVPlacement(0, G4ThreeVector(0,0.0,0.0), subChamberLV,
392 "AssemblyPhys", subDetectorLV4, false, 0);
393 // G4PVPlacement * detPhys4 =
394 new G4PVPlacement(0, G4ThreeVector(0.0,-bigL,0.0), subDetectorLV4,
395 "PhysSubDetectorSecond3", detectorLV, false, 0);
396
397 return experimentalHallPhys;
398}
G4LogicalVolume * ConstructParametrisationChamber()
G4LogicalVolume * ConstructSubDetector1()
G4LogicalVolume * ConstructSubDetector2()

◆ ConstructAssembly()

G4LogicalVolume * G02DetectorConstruction::ConstructAssembly ( )

Definition at line 446 of file G02DetectorConstruction.cc.

447{
448 const G4double big_x = fExpHall_x/17;
449 const G4double big_y = big_x;
450 const G4double big_z = big_x;
451
452 // Create the Box
453 //
454 G4Box * OuterBox =
455 new G4Box("OuterBox", big_x, big_y, big_z);
456 G4LogicalVolume * OuterBoxLV =
457 new G4LogicalVolume(OuterBox, fAir, "OuterBoxLV");
458 // G4PVPlacement * OuterBoxPhys =
459 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), OuterBoxLV,
460 "OuterBoxPhys", 0, false, 0);
461
462 // The aluminum object's logical volume
463 //
464 const G4double bigL=big_x/2.5;
465 const G4double medL=big_x/8;
466 const G4double smalL=big_x/12;
467
468 G4Box * BigBox =
469 new G4Box("BBox", bigL, bigL, bigL);
470 G4LogicalVolume * BigBoxLV =
471 new G4LogicalVolume(BigBox, fAluminum, "AlBigBoxLV");
472 G4Box * MedBox =
473 new G4Box("MBox", medL, medL, medL);
474 G4LogicalVolume * MedBoxLV1 =
475 new G4LogicalVolume(MedBox, fAluminum, "AlMedBoxLV1");
476 G4Box * SmallBox =
477 new G4Box("SBox", smalL, smalL, smalL);
478 G4LogicalVolume * SmallBoxLV =
479 new G4LogicalVolume(SmallBox, fAluminum, "AlSmaBoxLV");
480
481 const G4double bigPlace=bigL+10.;
482 const G4double medPlace=medL+10.;
483 // G4PVPlacement * BigBoxPhys =
484 new G4PVPlacement(0, G4ThreeVector(bigPlace,0.0,0.0), BigBoxLV,
485 "AlPhysBig", OuterBoxLV, false, 0);
486
487 // Construction of Tub
488 //
489 G4Tubs * BigTube =
490 new G4Tubs("BTube",0,smalL,smalL,-pi/2.,pi);
491
492 // Construction of Reflection of Tub
493 //
494 G4ReflectX3D Xreflection;
495 G4Translate3D translation(-bigPlace, 0., 0.);
496 G4Transform3D transform =Xreflection;
497
498 G4ReflectedSolid * ReflBig =
499 new G4ReflectedSolid("Refll_Big", BigTube, transform);
500 G4LogicalVolume * ReflBigLV =
501 new G4LogicalVolume(ReflBig, fXenon, "ReflBigAl");
502 new G4PVPlacement(0, G4ThreeVector(0.,0.0,0.0), ReflBigLV,
503 "AlPhysBigTube", SmallBoxLV, false, 0);
504 //
505 // LOOK HERE FOR ASSEMBLY
506 //
507
508 // create Assembly of Boxes and Tubs
509 //
510 G4AssemblyVolume* assembly = new G4AssemblyVolume();
511 G4RotationMatrix* rot = new G4RotationMatrix();
512 G4ThreeVector posBig(-bigPlace, 0, 0);
513 G4ThreeVector posBig0(bigPlace/4, 0, 0);
514 G4ThreeVector posMed(-medPlace, 0, 0);
515 G4ThreeVector posMed0(medPlace, 0, 0);
516 G4ThreeVector position(0., 0., 0.);
517
518 // Add to Assembly the MediumBox1
519 //
520 assembly->AddPlacedVolume(MedBoxLV1, posMed0, rot);
521
522 // Add to Assembly the Small Box
523 //
524 assembly->AddPlacedVolume(SmallBoxLV, posMed, rot);
525
526 // Place the Assembly
527 //
528 assembly->MakeImprint(BigBoxLV, posBig0, rot, 0);
529
530 //
531 // LOOK HERE FOR ASSEMBLY with REFLECTION
532 //
533
534 G4Translate3D translation1(-bigPlace, 0., 0.);
535 G4RotationMatrix* rotD3 = new G4RotationMatrix();
536 G4Transform3D rotation = G4Rotate3D(*rotD3);
537 G4ReflectX3D reflection;
538 G4Transform3D transform1 = translation1*rotation*reflection;
539
540 assembly->MakeImprint(OuterBoxLV, transform1, 0, 0);
541
542 return OuterBoxLV;
543}

◆ ConstructParametrisationChamber()

G4LogicalVolume * G02DetectorConstruction::ConstructParametrisationChamber ( )

Definition at line 549 of file G02DetectorConstruction.cc.

550{
551 const G4double chamber_x = fExpHall_x/12.;
552 const G4double chamber_y = chamber_x;
553 const G4double chamber_z = chamber_x;
554
555 // Create the hall
556 //
557 G4Box * paramChamberBox =
558 new G4Box("ChamberBox", chamber_x, chamber_y, chamber_z);
559 G4LogicalVolume * paramChamberLV =
560 new G4LogicalVolume(paramChamberBox, fAir, "ChamberLV");
561
562 // Parametrisation Chamber (taken from N02 novice example)
563 //
564 G4int NbOfChambers = 5;
565 G4double ChamberWidth = 2*cm;
566 G4double ChamberSpacing = 8*cm;
567 G4double fTrackerLength = (NbOfChambers+1)*ChamberSpacing; // Full length
568 G4double trackerSize = 0.5*fTrackerLength;
569
570 // An example of parameterised volume
571 // dummy values for G4Box -- modified by parameterised volume
572 //
573 G4Box *solidChamber =
574 new G4Box("chamber", 10*cm, 10*cm, 1*cm);
575 G4LogicalVolume* logicChamber =
576 new G4LogicalVolume(solidChamber, fAluminum, "Chamber", 0, 0, 0);
577
578 G4double firstPosition = -trackerSize + 0.5*ChamberWidth;
579 G4double firstLength = fTrackerLength/10;
580 G4double lastLength = fTrackerLength;
581
582 G4VPVParameterisation* chamberParam =
583 new G02ChamberParameterisation( NbOfChambers, // NoChambers
584 firstPosition, // Z of center of first
585 ChamberSpacing, // Z spacing of centers
586 ChamberWidth, // Width Chamber
587 firstLength, // lengthInitial
588 lastLength); // lengthFinal
589 // G4VPhysicalVolume* physiChamber =
590 new G4PVParameterised( "Chamber", // their name
591 logicChamber, // their logical volume
592 paramChamberLV, // mother logical volume
593 kZAxis, // Are placed along this axis
594 NbOfChambers, // Number of chambers
595 chamberParam); // The parametrisation
596 return paramChamberLV;
597}
Chamber parametrisation used in the GDML read/write example.

◆ ListOfMaterials()

void G02DetectorConstruction::ListOfMaterials ( )

Definition at line 247 of file G02DetectorConstruction.cc.

248{
249 G4double a; // atomic mass
250 G4double z; // atomic number
251 G4double density,temperature,pressure;
252 G4double fractionmass;
253 G4String name, symbol;
254 G4int ncomponents;
255
256 // Elements needed for the materials
257
258 a = 14.01*g/mole;
259 G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a);
260
261 a = 16.00*g/mole;
262 G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a);
263
264 a = 26.98*g/mole;
265 G4Element* elAl = new G4Element(name="Aluminum", symbol="Al", z=13., a);
266
267 // Print the Element information
268 //
269 G4cout << *(G4Element::GetElementTable()) << G4endl;
270
271 // Air
272 //
273 density = 1.29*mg/cm3;
274 fAir = new G4Material(name="Air", density, ncomponents=2);
275 fAir->AddElement(elN, fractionmass=0.7);
276 fAir->AddElement(elO, fractionmass=0.3);
277
278 // Aluminum
279 //
280 density = 2.70*g/cm3;
281 fAluminum = new G4Material(name="Aluminum", density, ncomponents=1);
282 fAluminum->AddElement(elAl, fractionmass=1.0);
283
284 // Lead
285 //
286 fPb = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
287
288 // Xenon gas
289 //
290 fXenon = new G4Material("XenonGas", z=54., a=131.29*g/mole,
291 density= 5.458*mg/cm3, kStateGas,
292 temperature= 293.15*kelvin, pressure= 1*atmosphere);
293
294 // Prints the material information
295 //
296 G4cout << *(G4Material::GetMaterialTable() ) << G4endl;
297}
std::vector< ExP01TrackerHit * > a

◆ SetReadFile()

void G02DetectorConstruction::SetReadFile ( const G4String File)

Definition at line 603 of file G02DetectorConstruction.cc.

604{
605 fReadFile=File;
607}

◆ SetWriteFile()

void G02DetectorConstruction::SetWriteFile ( const G4String File)

Definition at line 613 of file G02DetectorConstruction.cc.

614{
615 fWriteFile=File;
617}

◆ SetStepFile()

void G02DetectorConstruction::SetStepFile ( const G4String File)

Definition at line 623 of file G02DetectorConstruction.cc.

624{
625 fStepFile=File;
627}

Member Data Documentation

◆ fAir

G4Material* G02DetectorConstruction::fAir
private

Definition at line 87 of file G02DetectorConstruction.hh.

◆ fAluminum

G4Material* G02DetectorConstruction::fAluminum
private

Definition at line 88 of file G02DetectorConstruction.hh.

◆ fPb

G4Material* G02DetectorConstruction::fPb
private

Definition at line 89 of file G02DetectorConstruction.hh.

◆ fXenon

G4Material* G02DetectorConstruction::fXenon
private

Definition at line 90 of file G02DetectorConstruction.hh.

◆ fParser

G4GDMLParser G02DetectorConstruction::fParser
private

Definition at line 94 of file G02DetectorConstruction.hh.

◆ fReadFile

G4String G02DetectorConstruction::fReadFile
private

Definition at line 98 of file G02DetectorConstruction.hh.

◆ fWriteFile

G4String G02DetectorConstruction::fWriteFile
private

Definition at line 99 of file G02DetectorConstruction.hh.

◆ fStepFile

G4String G02DetectorConstruction::fStepFile
private

Definition at line 100 of file G02DetectorConstruction.hh.

◆ fWritingChoice

G4int G02DetectorConstruction::fWritingChoice
private

Definition at line 101 of file G02DetectorConstruction.hh.

◆ fDetectorMessenger

G02DetectorMessenger* G02DetectorConstruction::fDetectorMessenger
private

Definition at line 105 of file G02DetectorConstruction.hh.

◆ fExpHall_x

G4double G02DetectorConstruction::fExpHall_x
private

Definition at line 109 of file G02DetectorConstruction.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration