// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // $Id: HadrontherapyMatrix.cc; // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy// #include "HadrontherapyMatrix.hh" #include "HadrontherapyAnalysisManager.hh" #include "globals.hh" #include HadrontherapyMatrix* HadrontherapyMatrix::instance = NULL; // Static method that only return a pointer to the matrix object HadrontherapyMatrix* HadrontherapyMatrix::getInstance() { return instance; } // This STATIC method delete (!) the old matrix and rewrite a new object returning a pointer to it HadrontherapyMatrix* HadrontherapyMatrix::getInstance(G4int voxelX, G4int voxelY, G4int voxelZ) { if (instance) delete instance; instance = new HadrontherapyMatrix(voxelX, voxelY, voxelZ); instance -> Initialize(); return instance; } HadrontherapyMatrix::HadrontherapyMatrix(G4int voxelX, G4int voxelY, G4int voxelZ): matrix(0) { // Number of the voxels of the phantom // For Y = Z = 1 the phantom is divided in slices (and not in voxels) // orthogonal to the beam axis numberVoxelX = voxelX; numberVoxelY = voxelY; numberVoxelZ = voxelZ; // Create the dose matrix matrix = new G4double[numberVoxelX*numberVoxelY*numberVoxelZ]; if (matrix) G4cout << "Matrix: Memory space to store physical dose into " << numberVoxelX*numberVoxelY*numberVoxelZ << " voxels has been allocated " << G4endl; else G4Exception("Can't allocate memory to store physical dose!"); } HadrontherapyMatrix::~HadrontherapyMatrix() { delete[] matrix; } void HadrontherapyMatrix::flush() { if(matrix) for(int i=0; i FillEnergyDeposit(n, m, k, matrix[i]); analysis -> BraggPeak(n, matrix[i]); #endif } } } } } }