Geant4  10.03
ML2WorldConstruction.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 // The code was written by :
27 // ^Claudio Andenna claudio.andenna@ispesl.it, claudio.andenna@iss.infn.it
28 // *Barbara Caccia barbara.caccia@iss.it
29 // with the support of Pablo Cirrone (LNS, INFN Catania Italy)
30 // with the contribute of Alessandro Occhigrossi*
31 //
32 // ^INAIL DIPIA - ex ISPESL and INFN Roma, gruppo collegato Sanità, Italy
33 // *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità, Italy
34 // Viale Regina Elena 299, 00161 Roma (Italy)
35 // tel (39) 06 49902246
36 // fax (39) 06 49387075
37 //
38 // more information:
39 // http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
40 //
41 //*******************************************************//
42 
43 #include "ML2WorldConstruction.hh"
44 #include "G4SystemOfUnits.hh"
45 
46 CML2WorldConstruction::CML2WorldConstruction():acceleratorEnv(0),phantomEnv(0),PVWorld(0),phaseSpace(0),backScatteredPlane(0)
47 {
50  bWorldCreated=false;
51 }
52 
54 {
55  delete PVWorld;
56  delete phantomEnv;
57  delete acceleratorEnv;
58  delete phaseSpace;
59  delete backScatteredPlane;
60 }
61 
63 
65 {
66  if (instance == 0)
67  {
69  }
70  return instance;
71 }
72 
74 {
75  return PVWorld;
76 }
77 
78 bool CML2WorldConstruction::create(SInputData *inputData, bool bOV)
79 {
80  // create the world box
81  bOnlyVisio=bOV;
82  G4double halfSize=3000.*mm;
83  G4Material *Vacuum=G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
84  G4Box *worldB = new G4Box("worldG", halfSize, halfSize, halfSize);
85  G4LogicalVolume *worldLV = new G4LogicalVolume(worldB, Vacuum, "worldL", 0, 0, 0);
86  G4VisAttributes* simpleWorldVisAtt= new G4VisAttributes(G4Colour::Black());
87  simpleWorldVisAtt->SetVisibility(false);
88  // simpleWorldVisAtt->SetForceSolid(false);
89  worldLV->SetVisAttributes(simpleWorldVisAtt);
90  PVWorld= new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "worldPV", worldLV, 0, false, 0);
91 
92  // create the accelerator-world box
93  if (!acceleratorEnv->Construct(PVWorld, bOV))
94  {
95  std::cout <<"\n\n The macro file '"<<inputData->generalData.StartFileInputData<<"' refers to a not defined accelerator.\n"<< acceleratorEnv->getAcceleratorName()<<"\n\nSTOP\n\n" << G4endl;
96  return false;
97  }
98 
99  // create the phantom-world box
101  {
102  std::cout <<"\n\n The macro file '"<<inputData->generalData.StartFileInputData<<"' refers to a not defined phantom.\n"<< phantomEnv->getPhantomName()<<"\n\nSTOP\n\n" << G4endl;
103  return false;
104  }
105 
106  // if the bSavePhaseSpace flag is true create a phase plane
107  if (inputData->generalData.bSavePhaseSpace)
108  {
113  }
114 
115  // create a killer plane to destroy the particles back scattered from the target
117  backScatteredPlane->createPlane(acceleratorEnv->getPhysicalVolume(), "killerPlane", G4ThreeVector(0, 0, -50*mm), G4ThreeVector(200*mm, 200*mm, 1*mm));
118 
119  bWorldCreated=true;
120  return true;
121 }
123 {
124  // loop inside all the daughters volumes
125  std::cout<< G4endl;
126  // bool bCheckOverlap;
127  // bCheckOverlap=false;
128 
129  int nSubWorlds, nSubWorlds2;
130  for (int i=0; i<(int) PVWorld->GetLogicalVolume()->GetNoDaughters(); i++)
131  {
134  for (int j=0; j<nSubWorlds; j++)
135  {
138  for (int k=0; k<nSubWorlds2; k++)
139  {
141  }
142  }
143  }
144  std::cout<< G4endl;
145 }
147 {
148  G4bool bNewRotation=false;
149  G4bool bNewCentre=false;
150  G4bool bNewGeometry=false;
151  bNewCentre=phantomEnv->applyNewCentre();
153  if (rmInv!=0)
154  {
156  bNewRotation=true;
157  }
158  if (bNewRotation || bNewCentre){bNewGeometry=true;}
159  return bNewGeometry;
160 }
161 
G4ThreeVector centrePhaseSpace
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
bool create(SInputData *inputData, bool bOnlyVisio)
static constexpr double mm
Definition: G4SIunits.hh:115
G4int nMaxParticlesInRamPlanePhaseSpace
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
bool Construct(G4VPhysicalVolume *PVWorld, G4int saving_in_ROG_Voxels_every_events, G4int seed, G4String ROGOutFile, G4bool bSaveROG, G4bool bOnlyVisio)
static CML2AcceleratorConstruction * GetInstance(void)
Definition: G4Box.hh:64
G4VPhysicalVolume * getPhysicalVolume(void)
G4VPhysicalVolume * Construct()
G4VPhysicalVolume * GetDaughter(const G4int i) const
static CML2WorldConstruction * GetInstance(void)
static G4NistManager * Instance()
static G4Colour Black()
Definition: G4Colour.hh:146
G4String StartFileInputData
G4VPhysicalVolume * PVWorld
CML2PhantomConstruction * phantomEnv
G4bool bStopAtPhaseSpace
void SetVisibility(G4bool=true)
bool G4bool
Definition: G4Types.hh:79
G4bool bForcePhaseSpaceBeforeJaws
void setRotation(G4RotationMatrix *val)
CML2PhaseSpaces * phaseSpace
CML2PhaseSpaces * backScatteredPlane
G4bool bSavePhaseSpace
G4int GetNoDaughters() const
SPrimaryParticle primaryParticleData
bool Construct(G4VPhysicalVolume *PVWorld, G4bool bOnlyVisio)
CML2AcceleratorConstruction * acceleratorEnv
SGeneralData generalData
G4LogicalVolume * GetLogicalVolume() const
int max_N_particles_in_PhSp_File
int saving_in_ROG_Voxels_every_events
G4ThreeVector halfSizePhaseSpace
static CML2WorldConstruction * instance
static CML2PrimaryGenerationAction * GetInstance(void)
G4String ROGOutFile
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
bool createPlane(G4VPhysicalVolume *PVWorld, G4String name, G4ThreeVector centre, G4ThreeVector halfSize)
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
void SetVisAttributes(const G4VisAttributes *pVA)
static CML2PhantomConstruction * GetInstance(void)
G4String PhaseSpaceOutFile
void applyNewCentre(G4ThreeVector val)