Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:16

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // HadrontherapyRBEAccumulable.hh;
0027 //
0028 #ifndef HADRONTHERAPYRBEACCUMULABLE_HH
0029 #define HADRONTHERAPYRBEACCUMULABLE_HH
0030 
0031 #include <G4VAccumulable.hh>
0032 
0033 #include <valarray>
0034 
0035 /**
0036  * @brief Accumulable of RBE-related data (that must be thread-local).
0037  *
0038  * It keeps the sum of alpha and beta numerators/denominator, as well as energy deposits.
0039  * The class is closely tied with the singleton HadrontherapyRBE that is used both
0040  * to calculate alphas and betas, and also to store results.
0041  *
0042  * This is implemented as a customized G4VAccumulable with non-scalar data.
0043  *
0044  * @note There are two levels of merging (accumulation):
0045  *   1) From more threads in one run (G4VAccumulable merging is applied)
0046  *   2) (Optional) inter-run merging of data (implemented in HadrontherapyRBE).
0047  *
0048  * @note std::valarray is used (instead of C arrays or std::vectors)
0049  *    to accumulate data for its logical simplicity.
0050  */
0051 class HadrontherapyRBEAccumulable : public G4VAccumulable
0052 {
0053 public:
0054     HadrontherapyRBEAccumulable();
0055     HadrontherapyRBEAccumulable(const HadrontherapyRBEAccumulable& other) = default;
0056 
0057     // G4VAccumulable virtual methods
0058     void Merge(const G4VAccumulable &rhs) override;
0059     void Reset() override;
0060 
0061     // Store information from a single step
0062     void Accumulate(G4double E, G4double energyDeposit, G4double dX, G4int Z, G4int i, G4int j, G4int k);
0063 
0064     // Type alias for numerical arrays
0065     using array_type = std::valarray<G4double>;
0066 
0067     // Access to stored data (to be called on the merged data)
0068     const array_type GetEnergyDeposit() const;
0069     const array_type GetAlphaNumerator() const { return fAlphaNumerator; }
0070     const array_type GetBetaNumerator() const { return fBetaNumerator; }
0071     const array_type GetDenominator() const { return fDenominator; }
0072 
0073     // Verbosity, shared with HadrontherapyRBE
0074     G4int GetVerboseLevel() const;
0075 
0076 private:
0077     /** @brief Helper function to get the 1D index in the 3D array */
0078     inline G4int GetIndex(G4int i, G4int j, G4int k) const {return (i * fVoxelsAlongY + j) * fVoxelsAlongZ + k; }
0079 
0080     // Apply configuration from the HadrontherapyRBE class and prepare matrices
0081     void Initialize();
0082     G4bool fInitialized { false };
0083 
0084     array_type fAlphaNumerator;
0085     array_type fBetaNumerator;
0086     array_type fDenominator;
0087     array_type fEnergyDeposit;
0088 
0089     // How many voxels do we have?
0090     // ...along each axis
0091      G4int fVoxelsAlongX;
0092     G4int fVoxelsAlongY;
0093     G4int fVoxelsAlongZ;
0094 
0095     // ...and in total
0096     size_t fVoxels;
0097 
0098   
0099 
0100 
0101 };
0102 
0103 #endif // HADRONTHERAPYRBEACCUMULABLE_HH