Facebook
From Wilk, 6 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 228
  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  [email protected], [email protected]
  28. //      *Barbara Caccia [email protected]
  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 "ML2Ph_FullWater.hh"
  44. #include "G4SystemOfUnits.hh"
  45.  
  46. CML2Ph_FullWater::CML2Ph_FullWater()
  47. {
  48.         // phantom size and position
  49.         halfSize.set(150.*mm,150.*mm,150.*mm);
  50.         // phantom position
  51.         centre.set(0.,0.,0.);
  52. }
  53.  
  54. CML2Ph_FullWater::~CML2Ph_FullWater(void)
  55. {
  56. }
  57. void CML2Ph_FullWater::writeInfo()
  58. {
  59.         std::cout<<"\n\n\tcentre of the phantom: " <<centre/mm<<" [mm]"<< G4endl;
  60.         std::cout<<"\thalf thickness of the phantom: " <<halfSize/mm<<" [mm]\n"<< G4endl;
  61. }
  62. bool CML2Ph_FullWater::Construct(G4VPhysicalVolume *PWorld, G4int saving_in_ROG_Voxels_every_events, G4int seed, G4String ROGOutFile, G4bool bSaveROG)
  63. {
  64.         PVWorld=PWorld;
  65.  
  66.         bool bCreated=false;
  67.         G4Material *WATER=G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
  68.         G4Box *fullWaterPhantomBox = new G4Box("fullWaterPhantomBox", halfSize.getX(), halfSize.getY(), halfSize.getZ());
  69.         G4LogicalVolume *fullWaterPhantomLV = new G4LogicalVolume(fullWaterPhantomBox, WATER, "fullWaterPhantomLV", 0, 0, 0);
  70.         fullWaterPhantomPV = new G4PVPlacement(0, centre, "fullWaterPhantomPV", fullWaterPhantomLV, PVWorld, false, 0);
  71.  
  72.         // Region for cuts
  73.         G4Region *regVol= new G4Region("fullWaterPhantomR");
  74.         G4ProductionCuts* cuts = new G4ProductionCuts;
  75.         cuts->SetProductionCut(0.1*mm);
  76.         regVol->SetProductionCuts(cuts);
  77.  
  78.         fullWaterPhantomLV->SetRegion(regVol);
  79.         regVol->AddRootLogicalVolume(fullWaterPhantomLV);
  80.  
  81.         // Visibility
  82.         G4VisAttributes* simpleAlSVisAtt= new G4VisAttributes(G4Colour::Red());
  83.         simpleAlSVisAtt->SetVisibility(true);
  84. //      simpleAlSVisAtt->SetForceSolid(true);
  85.         fullWaterPhantomLV->SetVisAttributes(simpleAlSVisAtt);
  86.  
  87.         // Sensitive detector
  88.         sensDet=new CML2SDWithVoxels("Water phantom", saving_in_ROG_Voxels_every_events, seed, ROGOutFile, bSaveROG, G4ThreeVector(0.,0.,0.), halfSize, 100, 100, 100);
  89.         G4SDManager *SDManager=G4SDManager::GetSDMpointer();
  90.         SDManager->AddNewDetector(sensDet);
  91.        
  92.         // Read Out Geometry
  93.         CML2ReadOutGeometry *ROG = new CML2ReadOutGeometry();
  94.         ROG->setBuildData(PVWorld->GetFrameTranslation(), halfSize, 100, 100, 100);
  95.         ROG->BuildROGeometry();
  96.         sensDet->SetROgeometry(ROG);
  97.         fullWaterPhantomLV->SetSensitiveDetector(sensDet);
  98.  
  99.         bCreated=true;
  100.         return bCreated;
  101. }
  102.  
  103.  
  104.