Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:51

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 //
0027 //
0028 // 080718 Add ClearHistories method and related class member
0029 //
0030 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
0031 // V. Ivanchenko, July-2023 Basic revision of particle HP classes
0032 //
0033 #ifndef G4ParticleHPContAngularPar_h
0034 #define G4ParticleHPContAngularPar_h 1
0035 
0036 #include "G4Cache.hh"
0037 #include "G4InterpolationManager.hh"
0038 #include "G4ParticleHPInterpolator.hh"
0039 #include "G4ParticleHPList.hh"
0040 #include "G4ReactionProduct.hh"
0041 #include "G4ios.hh"
0042 #include "globals.hh"
0043 
0044 #include <fstream>
0045 #include <set>
0046 
0047 class G4ParticleDefinition;
0048 
0049 class G4ParticleHPContAngularPar
0050 {
0051     struct toBeCached
0052     {
0053       G4bool fresh{true};
0054       G4double currentMeanEnergy{-2.0};
0055       G4double remaining_energy{0.0};
0056       G4double theTargetCode{-1.0};
0057       G4ReactionProduct* theTarget{nullptr};
0058       G4ReactionProduct* thePrimary{nullptr};
0059       toBeCached() = default;
0060     };
0061 
0062   public:
0063     G4ParticleHPContAngularPar(const G4ParticleDefinition* p = nullptr);
0064     G4ParticleHPContAngularPar(G4ParticleHPContAngularPar&);
0065 
0066     ~G4ParticleHPContAngularPar();
0067 
0068     void Init(std::istream& aDataFile, const G4ParticleDefinition* projectile);
0069 
0070     G4ReactionProduct* Sample(G4double anEnergy, G4double massCode,
0071                               G4double mass, G4int angularRep, G4int interpol);
0072 
0073     G4double GetEnergy() const { return theEnergy; }
0074 
0075     void SetPrimary(G4ReactionProduct* aPrimary) { fCache.Get().thePrimary = aPrimary; }
0076 
0077     void SetTarget(G4ReactionProduct* aTarget) { fCache.Get().theTarget = aTarget; }
0078 
0079     void SetTargetCode(G4double aTargetCode) { fCache.Get().theTargetCode = aTargetCode; }
0080 
0081     void SetInterpolation(G4int theInterpolation)
0082     {
0083       theManager.Init(theInterpolation, nEnergies);  // one range only
0084     }
0085 
0086     void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
0087                               G4ParticleHPContAngularPar& store1,
0088                               G4ParticleHPContAngularPar& store2);
0089     // NOTE: this interpolates legendre coefficients
0090 
0091     void PrepareTableInterpolation();
0092 
0093     G4double MeanEnergyOfThisInteraction()
0094     {
0095       G4double result = std::max(fCache.Get().currentMeanEnergy, 0.0);
0096       fCache.Get().currentMeanEnergy = -2.0;
0097       return result;
0098     }
0099 
0100     G4int GetNEnergies() const { return nEnergies; }
0101     G4int GetNDiscreteEnergies() const { return nDiscreteEnergies; }
0102     std::set<G4double> GetEnergiesTransformed() const { return theEnergiesTransformed; }
0103     G4int GetNEnergiesTransformed() const { return (G4int)theEnergiesTransformed.size(); }
0104     G4double GetMinEner() const { return theMinEner; }
0105     G4double GetMaxEner() const { return theMaxEner; }
0106     std::map<G4double, G4int> GetDiscreteEnergiesOwn() const { return theDiscreteEnergiesOwn; }
0107     G4ParticleHPList* GetAngDataList() const { return theAngular; }
0108 
0109     void ClearHistories()
0110     {
0111       fCache.Get().fresh = true;
0112       fCache.Get().currentMeanEnergy = -2.0;
0113       fCache.Get().remaining_energy = 0.0;
0114       fCache.Get().theTargetCode = -1.0;
0115       fCache.Get().theTarget = nullptr;
0116       fCache.Get().thePrimary = nullptr;
0117     }
0118 
0119     void Dump() const;
0120 
0121     G4ParticleHPContAngularPar& operator=(const G4ParticleHPContAngularPar &right) = delete;
0122 
0123   private:
0124     // incoming particle
0125     G4double theEnergy{0.0};
0126     G4double theMinEner{DBL_MAX};
0127     G4double theMaxEner{-DBL_MAX};
0128     // number of exit channel energies
0129     G4int nEnergies{0};
0130     // number of discrete exit channels
0131     G4int nDiscreteEnergies{0};
0132     // number of angular paramerers per channel
0133     G4int nAngularParameters{0};
0134 
0135     const G4ParticleDefinition* theProjectile{nullptr};
0136     // on per exit-channel energy
0137     G4ParticleHPList* theAngular{nullptr};
0138 
0139     // knows the interpolation between List labels
0140     G4InterpolationManager theManager;
0141 
0142     G4ParticleHPInterpolator theInt;
0143 
0144     G4Cache<toBeCached> fCache;
0145 
0146     G4bool adjustResult{true};
0147     // if not set it will not force the conservation of energy in angularRep==1,
0148     // but will sample the particle energy according to the database
0149 
0150     std::set<G4double> theEnergiesTransformed;
0151     std::set<G4double> theDiscreteEnergies;
0152     std::map<G4double, G4int> theDiscreteEnergiesOwn;
0153 };
0154 
0155 #endif