Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4ParticleHPArbitaryTab.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
0029 //
0030 #ifndef G4ParticleHPArbitaryTab_h
0031 #define G4ParticleHPArbitaryTab_h 1
0032 
0033 #include "G4InterpolationManager.hh"
0034 #include "G4ParticleHPVector.hh"
0035 #include "G4VParticleHPEDis.hh"
0036 #include "G4ios.hh"
0037 #include "Randomize.hh"
0038 #include "globals.hh"
0039 
0040 #include <CLHEP/Units/SystemOfUnits.h>
0041 
0042 #include <fstream>
0043 
0044 // we will need a List of these .... one per term.
0045 
0046 class G4ParticleHPArbitaryTab : public G4VParticleHPEDis
0047 {
0048   public:
0049     G4ParticleHPArbitaryTab()
0050     {
0051       theDistFunc = nullptr;
0052       nDistFunc = 0;
0053     }
0054     ~G4ParticleHPArbitaryTab() override { delete[] theDistFunc; }
0055 
0056     inline void Init(std::istream& theData) override
0057     {
0058       std::size_t i;
0059       theFractionalProb.Init(theData, CLHEP::eV);
0060       theData >> nDistFunc;  // = number of incoming n energy points
0061       const std::size_t dsize = nDistFunc > 0 ? nDistFunc : 1;
0062       theDistFunc = new G4ParticleHPVector[dsize];
0063       theManager.Init(theData);
0064       G4double currentEnergy;
0065       for (i = 0; i < dsize; ++i) {
0066         theData >> currentEnergy;
0067         theDistFunc[i].SetLabel(currentEnergy * CLHEP::eV);
0068         theDistFunc[i].Init(theData, CLHEP::eV);
0069         theDistFunc[i].IntegrateAndNormalise();
0070         //************************************************************************
0071         // EMendoza:
0072         // ThinOut() assumes that the data is linear-linear, what is false:
0073         // theDistFunc[i].ThinOut(0.02); // @@@ optimization to be finished.
0074         //************************************************************************
0075       }
0076 
0077       //************************************************************************
0078       // EMendoza:
0079       // Here we calculate the thresholds for the 2D sampling:
0080       for (i = 0; i < dsize; ++i) {
0081         G4int np = theDistFunc[i].GetVectorLength();
0082         theLowThreshold[i] = theDistFunc[i].GetEnergy(0);
0083         theHighThreshold[i] = theDistFunc[i].GetEnergy(np - 1);
0084         for (G4int j = 0; j < np - 1; ++j) {
0085           if (theDistFunc[i].GetXsec(j + 1) > 1.e-20) {
0086             theLowThreshold[i] = theDistFunc[i].GetEnergy(j);
0087             break;
0088           }
0089         }
0090         for (G4int j = 1; j < np; ++j) {
0091           if (theDistFunc[i].GetXsec(j - 1) > 1.e-20) {
0092             theHighThreshold[i] = theDistFunc[i].GetEnergy(j);
0093           }
0094         }
0095       }
0096       //************************************************************************
0097     }
0098 
0099     inline G4double GetFractionalProbability(G4double anEnergy) override
0100     {
0101       return theFractionalProb.GetY(anEnergy);
0102     }
0103 
0104     G4double Sample(G4double anEnergy) override;
0105 
0106   private:
0107     G4ParticleHPVector theFractionalProb;
0108     G4int nDistFunc;
0109     G4InterpolationManager theManager;  // knows the interpolation between stores
0110     G4ParticleHPVector* theDistFunc;  // one per incoming energy
0111     G4ParticleHPVector theBuffer;
0112     //************************************************************************
0113     // EMendoza:
0114     G4double theLowThreshold[1000];
0115     G4double theHighThreshold[1000];
0116     //************************************************************************
0117 };
0118 
0119 #endif