ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ML2PhantomConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ML2PhantomConstruction.cc
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 
46 
47 #include "G4ios.hh"
48 #include "G4SystemOfUnits.hh"
49 
51 {
53  idCurrentCentre = 0;
54 }
55 
57 {}
58 
60 
62 {
63  if (instance == 0)
64  {
66 
67  }
68  return instance;
69 }
71 {
72  // switch between two different phantoms according to the macro ml2.mac
73  bool bPhanExists = false;
74 
75  G4cout << "I'm building "<< phantomName<<" phantom"<< G4endl;
76 
77  if (phantomName == "fullWater")
78  {
80  bPhanExists=true;
82  }
83  else if (phantomName == "boxInBox")
84  {
86  bPhanExists=true;
88  }
89 
90  if (centre.size() < 1)
91  {
92  addNewCentre(G4ThreeVector(0.,0.,0.));
93  }
94  return bPhanExists;
95 }
97 {
98 G4cout << "Not implemented at the moment " << G4endl;
99  /*if (phantomName == "fullWater")
100  {
101  return Ph_fullWater->getTotalNumberOfEvents();
102  }
103  else if (phantomName == "boxInBox")
104  {
105  return Ph_BoxInBox->getTotalNumberOfEvents();
106  }
107 
108 */
109 return 0;
110 }
111 
113  G4int voxelX, G4int voxelY, G4int voxelZ, G4bool bOV)
114 {
115  idVolumeName = 0;
116  bOnlyVisio = bOV;
117  // a call to select the right phantom
118  if(design())
119  {
120  phantomContstructionMessenger->SetReferenceWorld(bOV); // create the phantom-world box
121  G4Material *Vacuum=G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
122 
123  G4Box *phmWorldB = new G4Box("phmWorldG", halfPhantomInsideSize.getX(),
125  G4LogicalVolume *phmWorldLV = new G4LogicalVolume(phmWorldB, Vacuum, "phmWorldL", 0, 0, 0);
126  G4VisAttributes* simpleAlSVisAtt= new G4VisAttributes(G4Colour::White());
127  simpleAlSVisAtt->SetVisibility(false);
128  phmWorldLV->SetVisAttributes(simpleAlSVisAtt);
129 
130 
131  PVPhmWorld = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "phmWorldPV", phmWorldLV, PVWorld, false, 0);
132 
133  // create the actual phantom
134  if (phantomName=="fullWater")
135  {
136  Ph_fullWater->Construct(PVPhmWorld, voxelX, voxelY, voxelZ); // provide the voxelisation to the phantom
137  //sensDet=Ph_fullWater->getSensDet();
140  }
141  else if (phantomName=="boxInBox")
142  {
144  //sensDet=Ph_BoxInBox->getSensDet();
147 
148  }
149 
150  }
151  else
152  {
153  return false;
154  }
155  return true;
156 }
158 {
159  SvolumeNameId svnid;
160  for (int i=0;i< nMatNames; i++)
161  {
162  svnid.volumeId=i;
163  svnid.volumeName=matNames[i];
164  volumeNameIdLink.push_back(svnid);
165  }
166 }
168 {
169  int nLVD1;
170  nLVD1=(int) PV->GetLogicalVolume()->GetNoDaughters();
171  SvolumeNameId svnid;
172  G4cout << "PV in name: " <<PV->GetName() << G4endl;
173  if (nLVD1>0)
174  {
175  for (int i=0; i <nLVD1; i++)
176  {
178  }
179  idVolumeName++;
180  svnid.volumeId=idVolumeName;
182  volumeNameIdLink.push_back(svnid);
183  G4cout << "physical volume name: " <<svnid.volumeName << G4endl;
184  }
185  else
186  {
187  idVolumeName++;
188  svnid.volumeId=idVolumeName;
190  volumeNameIdLink.push_back(svnid);
191  G4cout << "physical volume name: " <<svnid.volumeName << G4endl;
192  }
193 }
195 {
196  if (idCurrentCentre <(int) centre.size())
197  {
200  idCurrentCentre++;
201  return true;
202  }
203  return false;
204 }
206 {
207  if (!bOnlyVisio)
208  {
209  G4cout << "Actual centre: "<<idCurrentCentre << "/" << centre.size() << " " << G4endl;
210  }
211  G4cout <<"Phantom and its ROG centre: " << currentCentre<< G4endl;
212 }
214 {
215  if (PVPhmWorld)
216  {
217  currentCentre=ctr;
222  }
223 }
225 {
226  char cT[5];
227  G4int cTI;
228  G4String translationName;
229  cTI=(G4int)((currentCentre.getX()/mm));
230  sprintf(cT,"%d",cTI);
231  translationName="_TrX"+G4String(cT)+"_";
232  cTI=(G4int)((currentCentre.getY()/mm));
233  sprintf(cT,"%d",cTI);
234  translationName+="Y"+G4String(cT)+"_";
235  cTI=(G4int)((currentCentre.getZ()/mm));
236  sprintf(cT,"%d",cTI);
237  translationName+="Z"+G4String(cT);
238  return translationName;
239 }
240