Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:19

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 /// \file radiobiology/include/RBEAccumulable.hh
0027 /// \brief Definition of the RadioBio::RBEAccumulable class
0028 
0029 #ifndef RadiobiologyRBEACCUMULABLE_HH
0030 #define RadiobiologyRBEACCUMULABLE_HH
0031 
0032 #include "VRadiobiologicalAccumulable.hh"
0033 #include <G4VAccumulable.hh>
0034 
0035 #include <valarray>
0036 
0037 namespace RadioBio
0038 {
0039 
0040 // Forward declariation of other radiobiology classes
0041 class Hit;
0042 
0043 /**
0044  * @brief Accumulable of RBE-related data (that must be thread-local).
0045  *
0046  * It keeps the sum of alpha and beta numerators/denominator, as well as energy deposits.
0047  * The class is closely tied with the singleton RBE that is used both
0048  * to calculate alphas and betas, and also to store results.
0049  *
0050  * This is implemented as a customized G4VAccumulable with non-scalar data.
0051  *
0052  * @note There are two levels of merging (accumulation):
0053  *   1) From more threads in one run (G4VAccumulable merging is applied)
0054  *   2) (Optional) inter-run merging of data (implemented in RBE).
0055  *
0056  * @note std::valarray is used (instead of C arrays or std::vectors)
0057  *    to accumulate data for its logical simplicity.
0058  */
0059 class RBEAccumulable : public VRadiobiologicalAccumulable
0060 {
0061   public:
0062     RBEAccumulable();
0063     RBEAccumulable(const RBEAccumulable& other) = default;
0064 
0065     // G4VAccumulable virtual methods to override
0066     void Merge(const G4VAccumulable& rhs) override;
0067     void Reset() override;
0068 
0069     // Store information from a single step
0070     void Accumulate(G4double E, G4double energyDeposit, G4double dX, G4int Z, G4int i, G4int j,
0071                     G4int k);
0072     void Accumulate(Hit* hit) override;
0073 
0074     // Type alias for numerical arrays
0075     using array_type = std::valarray<G4double>;
0076 
0077     // Access to stored data (to be called on the merged data)
0078     const array_type GetAlphaNumerator() const { return fAlphaNumerator; }
0079     const array_type GetBetaNumerator() const { return fBetaNumerator; }
0080     const array_type GetDenominator() const { return fDenominator; }
0081 
0082     // Verbosity, shared with RBE
0083     G4int GetVerboseLevel() const;
0084 
0085   private:
0086     // Apply configuration from the RBE class and prepare matrices
0087     void Initialize();
0088     G4bool fInitialized = false;
0089 
0090     array_type fAlphaNumerator = {};
0091     array_type fBetaNumerator = {};
0092     array_type fDenominator = {};
0093 
0094     // How many voxels do we have?
0095     // ...along each axis
0096     size_t fVoxelsAlongX = -1;
0097     size_t fVoxelsAlongY = -1;
0098     size_t fVoxelsAlongZ = -1;
0099     // ...and in total
0100     size_t fVoxels = -1;
0101 };
0102 
0103 }  // namespace RadioBio
0104 
0105 #endif  // RBEACCUMULABLE_HH