Back to home page

EIC code displayed by LXR

 
 

    


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

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 // 070618 Comment out unused private member leaking by T. Koi
0028 //
0029 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
0030 //
0031 #ifndef G4ParticleHPPartial_h
0032 #define G4ParticleHPPartial_h 1
0033 
0034 #include "G4InterpolationManager.hh"
0035 #include "G4ParticleHPInterpolator.hh"
0036 #include "G4ParticleHPVector.hh"
0037 #include "globals.hh"
0038 
0039 #include <CLHEP/Units/SystemOfUnits.h>
0040 
0041 class G4ParticleHPPartial
0042 {
0043   public:
0044     G4ParticleHPPartial(G4int n)
0045     {
0046       X = new G4double[n];
0047       data = new G4ParticleHPVector[n];
0048       nData = n;
0049       T = nullptr;
0050     }
0051 
0052     G4ParticleHPPartial(G4int n1, G4int n2)
0053     {
0054       T = new G4double[n2];
0055       X = new G4double[n1];
0056       data = new G4ParticleHPVector[n1];
0057       nData = std::max(n1, n2);
0058     }
0059 
0060     void InitInterpolation(G4int i, std::istream& aDataFile)
0061     {
0062       data[i].InitInterpolation(aDataFile);
0063     }
0064 
0065     void InitInterpolation(std::istream& aDataFile) { theManager.Init(aDataFile); }
0066 
0067     void Init(std::istream& aDataFile)
0068     {
0069       G4int i;
0070       G4double e;
0071       for (i = 0; i < nData; i++) {
0072         aDataFile >> e;
0073         e *= CLHEP::eV;
0074         SetX(i, e);
0075         InitData(i, aDataFile, CLHEP::eV);  // energy and probability for gammas
0076       }
0077     }
0078 
0079     void InitData(G4int i, std::istream& aDataFile, G4double unit = 1.)
0080     {
0081       G4int ii;
0082       G4double eg, pg;
0083       G4int neg;
0084       aDataFile >> neg;
0085       data[i].InitInterpolation(aDataFile);
0086       for (ii = 0; ii < neg; ii++) {
0087         aDataFile >> eg >> pg;
0088         eg *= unit;
0089         SetX(i, ii, eg);
0090         SetY(i, ii, pg);
0091       }
0092       data[i].Hash();
0093     }
0094 
0095     ~G4ParticleHPPartial()
0096     {
0097       delete[] X;
0098       delete[] T;
0099       delete[] data;
0100     }
0101     inline G4int GetNumberOfEnergies() { return nData; }
0102 
0103     inline void SetX(G4int i, G4double x) { X[i] = x; }
0104     inline void SetT(G4int i, G4double x) { T[i] = x; }
0105     inline void SetX(G4int i, G4int j, G4double x) { data[i].SetX(j, x); }
0106     inline void SetY(G4int i, G4int j, G4double y) { data[i].SetY(j, y); }
0107     void DoneSetXY(G4int i) { data[i].Hash(); }
0108 
0109     inline G4double GetX(G4int i) { return X[i]; }
0110     inline G4double GetT(G4int i) { return T[i]; }
0111     inline G4double GetX(G4int i, G4int j) { return data[i].GetX(j); }
0112     inline G4double GetY(G4int i, G4int j) { return data[i].GetY(j); }
0113     inline G4double GetY(G4int i, G4double e) { return data[i].GetY(e); }
0114     inline G4int GetNEntries(G4int i) { return data[i].GetVectorLength(); }
0115     G4ParticleHPVector* GetY(G4double e1);
0116     G4double Sample(G4double x);
0117 
0118   private:
0119     G4double* X;
0120     G4double* T;
0121     G4ParticleHPVector* data;
0122     // TKDB
0123     // G4ParticleHPVector * theBuffer;
0124     G4int nData;
0125     G4InterpolationManager theManager;  // interpolate between different data[i]
0126     G4ParticleHPInterpolator theInt;
0127 };
0128 
0129 #endif