Geant4  10.01
ML2AcceleratorConstruction.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 
45 #include "G4SystemOfUnits.hh"
46 
48 {
51 }
52 
54 {
55  if (AcceleratorName=="acc1")
56  {delete accelerator1;}
57 
58  delete PVAccWorld;
60 }
62 
64 {
65  if (instance == 0)
66  {
68  }
69  return instance;
70 }
71 
73 {
74  if (AcceleratorName=="acc1")
75  {
77  }
78 
79 }
80 
82 {
83 // switch between different accelerators according to the main macro selection (actually only one accelerator is available)
84  std::cout << "I'm building "<< AcceleratorName<<" accelerator"<< G4endl;
85  bool bAccExists=false;
86  if (AcceleratorName=="acc1")
87  {accelerator1=CML2Acc1::GetInstance();bAccExists=true;}
88 
89  if (bAccExists && AcceleratorMacFileName!="")
90  {
91  // read the messenger data related to the accelerator selected
93  G4String command = "/control/execute ";
95  }
96 
97  if (rotationsX.size()<1)
99 
100  return bAccExists;
101 }
103 {
104 // a call to select the right accelerator
105  bOnlyVisio=bOV;
106  if (design())
107  {
109  // create the accelerator-world box
110  G4Material *Vacuum=G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
111  G4ThreeVector halfSize;
112  initialCentre.set(0.*mm, 0.*mm, -isoCentre);
113  halfSize.set(600.*mm, 600.*mm, 600.*mm);
114  G4Box *accWorldB = new G4Box("accWorldG", halfSize.getX(), halfSize.getY(), halfSize.getZ());
115  G4LogicalVolume *accWorldLV = new G4LogicalVolume(accWorldB, Vacuum, "accWorldL", 0, 0, 0);
116  G4VisAttributes* simpleAlSVisAtt= new G4VisAttributes(G4Colour::White());
117  simpleAlSVisAtt->SetVisibility(false);
118 // simpleAlSVisAtt->SetForceWireframe(false);
119  accWorldLV->SetVisAttributes(simpleAlSVisAtt);
120 
121  PVAccWorld= new G4PVPlacement(0, initialCentre, "acceleratorBox", accWorldLV, PVWorld, false, 0);
122 
123  // create the actual accelerator
124  if (AcceleratorName=="acc1")
125  {
129  }
130  }
131  else
132  {
133  return false;
134  }
135  return true;
136 }
137 
139 {
140  if (!bOnlyVisio)
141  {std::cout <<"Actual rotation: "<<idCurrentRotationX<<"/"<<rotationsX.size() <<" "<< G4endl;}
142  std::cout <<"Accelerator angle: "<< currentRotationX/deg << " [deg]"<< G4endl;
143 }
144 
146 {
147  G4RotationMatrix *rmInv=new G4RotationMatrix();
148  if (idCurrentRotationX <(int) rotationsX.size())
149  {
153  }
154  else
155  {rmInv=0;}
156  return rmInv;
157 }
159 {
160  currentRotationX=angleX;
162  G4ThreeVector NewCentre;
164  G4RotationMatrix *rmInv=new G4RotationMatrix();
166  PVAccWorld->SetRotation(rm);
167  if (bRotate90Y) {rm->rotateY(90.*deg);}
168  rm->rotateX(-angleX);
169  PVAccWorld->SetRotation(rm);
170  *rmInv=CLHEP::inverseOf(*rm);
171  NewCentre=*rmInv*initialCentre;
172  PVAccWorld->SetTranslation(NewCentre);
175  return rmInv;
176 }
178 {
179  char cR[5];
180  G4int cRI=(G4int)((currentRotationX/deg)+.5);
181  sprintf(cR,"%d",cRI);
182  G4String rotationName=G4String(cR);
183  if (bRotate90Y)
184  {rotationName="_Ro90Y"+rotationName;}
185  else
186  {rotationName="_Ro"+rotationName;}
187  return rotationName;
188 }
void GeometryHasBeenModified(G4bool prop=true)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CML2AcceleratorConstructionMessenger * acceleratorConstructionMessenger
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
static CML2AcceleratorConstruction * GetInstance(void)
Definition: G4Box.hh:64
void SetVisibility(G4bool)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
void SetRotation(G4RotationMatrix *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void Construct(G4VPhysicalVolume *PVWorld, G4double isoCentre)
Definition: ML2Acc1.cc:156
static const double deg
Definition: G4SIunits.hh:133
bool G4bool
Definition: G4Types.hh:79
void SetTranslation(const G4ThreeVector &v)
static G4GeometryManager * GetInstance()
static CML2AcceleratorConstruction * instance
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
bool Construct(G4VPhysicalVolume *PVWorld, G4bool bOnlyVisio)
void writeInfo()
Definition: ML2Acc1.cc:66
void reset()
Definition: ML2Acc1.cc:172
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
G4double getBeforeJaws_Z_PhaseSpacePosition()
Definition: ML2Acc1.hh:81
double G4double
Definition: G4Types.hh:76
static CML2Acc1 * GetInstance(void)
Definition: ML2Acc1.cc:58
static const double mm
Definition: G4SIunits.hh:102
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=0)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
static G4Colour White()
Definition: G4Colour.hh:143