Geant4-11
Data Structures | Public Member Functions | Private Member Functions | Private Attributes
G4ParticleHPContAngularPar Class Reference

#include <G4ParticleHPContAngularPar.hh>

Data Structures

struct  toBeCached
 

Public Member Functions

void BuildByInterpolation (G4double anEnergy, G4InterpolationScheme aScheme, G4ParticleHPContAngularPar &store1, G4ParticleHPContAngularPar &store2)
 
void ClearHistories ()
 
void Dump () const
 
 G4ParticleHPContAngularPar ()
 
 G4ParticleHPContAngularPar (G4ParticleDefinition *projectile)
 
 G4ParticleHPContAngularPar (G4ParticleHPContAngularPar &val)
 
G4ParticleHPListGetAngDataList () const
 
std::map< G4double, G4intGetDiscreteEnergiesOwn () const
 
std::set< G4doubleGetEnergiesTransformed () const
 
G4double GetEnergy () const
 
G4double GetMaxEner () const
 
G4double GetMinEner () const
 
G4int GetNDiscreteEnergies () const
 
G4int GetNEnergies () const
 
G4int GetNEnergiesTransformed () const
 
void Init (std::istream &aDataFile, G4ParticleDefinition *projectile)
 
G4double MeanEnergyOfThisInteraction ()
 
void PrepareTableInterpolation ()
 
G4ReactionProductSample (G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
 
void SetInterpolation (G4int theInterpolation)
 
void SetPrimary (G4ReactionProduct *aPrimary)
 
void SetTarget (G4ReactionProduct *aTarget)
 
void SetTargetCode (G4double aTargetCode)
 
 ~G4ParticleHPContAngularPar ()
 

Private Member Functions

void cacheInit ()
 

Private Attributes

G4bool adjustResult
 
G4Cache< toBeCached * > fCache
 
G4int nAngularParameters
 
G4int nDiscreteEnergies
 
G4int nEnergies
 
G4ParticleHPListtheAngular
 
std::set< G4doubletheDiscreteEnergies
 
std::map< G4double, G4inttheDiscreteEnergiesOwn
 
std::set< G4doubletheEnergiesTransformed
 
G4double theEnergy
 
G4ParticleHPInterpolator theInt
 
G4InterpolationManager theManager
 
G4double theMaxEner
 
G4double theMinEner
 
G4ParticleDefinitiontheProjectile
 

Detailed Description

Definition at line 48 of file G4ParticleHPContAngularPar.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPContAngularPar() [1/3]

G4ParticleHPContAngularPar::G4ParticleHPContAngularPar ( )
inline

Definition at line 66 of file G4ParticleHPContAngularPar.hh.

References adjustResult, DBL_MAX, fCache, nAngularParameters, nDiscreteEnergies, nEnergies, theAngular, theEnergy, theMaxEner, theMinEner, and theProjectile.

◆ G4ParticleHPContAngularPar() [2/3]

G4ParticleHPContAngularPar::G4ParticleHPContAngularPar ( G4ParticleHPContAngularPar val)
inline

Definition at line 82 of file G4ParticleHPContAngularPar.hh.

83 {
84 theEnergy = val.theEnergy;
85 nEnergies = val.nEnergies;
90 theInt = val.theInt;
97 fCache.Put(0);
99 for(G4int ie=0;ie<nEnergies;++ie) {
100 theAngular[ie].SetLabel(val.theAngular[ie].GetLabel());
101 for(G4int ip=0;ip<nAngularParameters;++ip) {
102 theAngular[ie].SetValue(ip,val.theAngular[ie].GetValue(ip));
103 }
104 }
105 }
int G4int
Definition: G4Types.hh:85
std::map< G4double, G4int > theDiscreteEnergiesOwn
void SetLabel(G4double aLabel)
void SetValue(G4int i, G4double y)
G4double GetValue(G4int i)

References adjustResult, fCache, G4ParticleHPList::GetLabel(), G4ParticleHPList::GetValue(), nAngularParameters, nDiscreteEnergies, nEnergies, G4ParticleHPList::SetLabel(), G4ParticleHPList::SetValue(), theAngular, theDiscreteEnergies, theDiscreteEnergiesOwn, theEnergiesTransformed, theEnergy, theInt, theManager, theMaxEner, theMinEner, and theProjectile.

◆ G4ParticleHPContAngularPar() [3/3]

G4ParticleHPContAngularPar::G4ParticleHPContAngularPar ( G4ParticleDefinition projectile)

Definition at line 64 of file G4ParticleHPContAngularPar.cc.

65{
66 theAngular = 0;
67 if (fCache.Get() == 0) cacheInit();
68 fCache.Get()->currentMeanEnergy = -2;
69 fCache.Get()->fresh = true;
70 adjustResult = true;
71 if (G4ParticleHPManager::GetInstance()->GetDoNotAdjustFinalState() )
72 adjustResult = false;
73
76 theProjectile = projectile;
77
78 theEnergy = 0.0;
79 nEnergies = 0;
82}
static G4ParticleHPManager * GetInstance()

References adjustResult, cacheInit(), DBL_MAX, fCache, G4ParticleHPManager::GetInstance(), nAngularParameters, nDiscreteEnergies, nEnergies, theAngular, theEnergy, theMaxEner, theMinEner, and theProjectile.

◆ ~G4ParticleHPContAngularPar()

G4ParticleHPContAngularPar::~G4ParticleHPContAngularPar ( )
inline

Definition at line 109 of file G4ParticleHPContAngularPar.hh.

110 {
111 if (theAngular !=0 ) delete [] theAngular;
112 if (fCache.Get() != 0) delete fCache.Get();
113 }

References fCache, and theAngular.

Member Function Documentation

◆ BuildByInterpolation()

void G4ParticleHPContAngularPar::BuildByInterpolation ( G4double  anEnergy,
G4InterpolationScheme  aScheme,
G4ParticleHPContAngularPar store1,
G4ParticleHPContAngularPar store2 
)

Definition at line 714 of file G4ParticleHPContAngularPar.cc.

718{
719 G4int ie, ie1, ie2, ie1Prev, ie2Prev;
720 // Only rebuild the interpolation table if there is a new interaction.
721 // For several subsequent samplings of final state particles in the same
722 // interaction the existing table should be used
723 if (fCache.Get()->fresh != true) return;
724
725 // Make copies of angpar1 and angpar2. Since these are given by reference
726 // it can not be excluded that one of them is "this". Hence this code uses
727 // potentially the old "this" for creating the new this - which leads to
728 // memory corruption if the old is not stored as separarte object for lookup
729 const G4ParticleHPContAngularPar copyAngpar1(angpar1),copyAngpar2(angpar2);
730
731 nAngularParameters = copyAngpar1.nAngularParameters;
732 theManager = copyAngpar1.theManager;
733 theEnergy = anEnergy;
734 theMinEner = DBL_MAX; // min and max will be re-calculated after interpolation
736
737 // The two discrete sets must be merged. A vector holds the temporary data to
738 // be copied to the array in the end. Since the G4ParticleHPList class
739 // contains pointers, can't simply assign elements of this type. Each member
740 // needs to call the explicit Set() method instead.
741
742 // First, average probabilities for those lines that are in both sets
743 const std::map<G4double,G4int> discEnerOwn1 = copyAngpar1.GetDiscreteEnergiesOwn();
744 const std::map<G4double,G4int> discEnerOwn2 = copyAngpar2.GetDiscreteEnergiesOwn();
745 std::map<G4double,G4int>::const_iterator itedeo1;
746 std::map<G4double,G4int>::const_iterator itedeo2;
747 std::vector<G4ParticleHPList*> vAngular(discEnerOwn1.size() );
748 G4double discEner1;
749 for (itedeo1 = discEnerOwn1.begin(); itedeo1 != discEnerOwn1.end(); ++itedeo1) {
750 discEner1 = itedeo1->first;
751 if (discEner1 < theMinEner) {
752 theMinEner = discEner1;
753 }
754 if (discEner1 > theMaxEner) {
755 theMaxEner = discEner1;
756 }
757 ie1 = itedeo1->second;
758 itedeo2 = discEnerOwn2.find(discEner1);
759 if( itedeo2 == discEnerOwn2.end() ) {
760 ie2 = -1;
761 } else {
762 ie2 = itedeo2->second;
763 }
764 vAngular[ie1] = new G4ParticleHPList();
765 vAngular[ie1]->SetLabel(copyAngpar1.theAngular[ie1].GetLabel());
766 G4double val1, val2;
767 for (G4int ip = 0; ip < nAngularParameters; ++ip) {
768 val1 = copyAngpar1.theAngular[ie1].GetValue(ip);
769 if (ie2 != -1) {
770 val2 = copyAngpar2.theAngular[ie2].GetValue(ip);
771 } else {
772 val2 = 0.;
773 }
774 G4double value = theInt.Interpolate(aScheme, anEnergy,
775 copyAngpar1.theEnergy, copyAngpar2.theEnergy,
776 val1, val2);
777 if (std::getenv("G4PHPTEST2") )
778 G4cout << ie1 << " " << ip
779 << " G4ParticleHPContAngularPar::Merge DiscreteEnergies val1 "
780 << val1 << " val2 " << val2 << " value " << value << G4endl; //GDEB
781
782 vAngular[ie1]->SetValue(ip, value);
783 }
784 } // itedeo1 loop
785
786 // Add the ones in set2 but not in set1
787 std::vector<G4ParticleHPList*>::iterator itv;
788 G4double discEner2;
789 for (itedeo2 = discEnerOwn2.begin(); itedeo2 != discEnerOwn2.end(); ++itedeo2) {
790 discEner2 = itedeo2->first;
791 ie2 = itedeo2->second;
792 G4bool notFound = true;
793 itedeo1 = discEnerOwn1.find(discEner2);
794 if (itedeo1 != discEnerOwn1.end() ) {
795 notFound = false;
796 }
797 if (notFound) {
798 // not yet in list
799 if (discEner2 < theMinEner) {
800 theMinEner = discEner2;
801 }
802 if (discEner2 > theMaxEner) {
803 theMaxEner = discEner2;
804 }
805 // find position to insert
806 G4bool isInserted = false;
807 ie = 0;
808 for (itv = vAngular.begin(); itv != vAngular.end(); ++itv,++ie) {
809 if (discEner2 > (*itv)->GetLabel() ) {
810 itv = vAngular.insert(itv, new G4ParticleHPList);
811 (*itv)->SetLabel(copyAngpar2.theAngular[ie2].GetLabel());
812 isInserted = true;
813 break;
814 }
815 }
816 if (!isInserted) {
817 ie=vAngular.size();
818 vAngular.push_back(new G4ParticleHPList);
819 vAngular[ie]->SetLabel(copyAngpar2.theAngular[ie2].GetLabel());
820 isInserted = true;
821 }
822
823 G4double val1, val2;
824 for (G4int ip = 0; ip < nAngularParameters; ++ip) {
825 val1 = 0;
826 val2 = copyAngpar2.theAngular[ie2].GetValue(ip);
827 G4double value = theInt.Interpolate(aScheme, anEnergy,
828 copyAngpar1.theEnergy,
829 copyAngpar2.theEnergy,
830 val1, val2);
831 if (std::getenv("G4PHPTEST2") )
832 G4cout << ie << " " << ip
833 << " G4ParticleHPContAngularPar::Merge DiscreteEnergies val1 "
834 << val1 << " val2 " << val2 << " value " << value << G4endl; //GDEB
835 vAngular[ie]->SetValue(ip, value);
836 }
837 } // end if(notFound)
838 } // end loop on itedeo2
839
840 // Store new discrete list
841 nDiscreteEnergies = vAngular.size();
842 if (theAngular != 0) delete [] theAngular;
843 theAngular = 0;
844 if (nDiscreteEnergies > 0) {
846 }
848 theDiscreteEnergies.clear();
849 for (ie = 0; ie < nDiscreteEnergies; ++ie) {
850 theAngular[ie].SetLabel(vAngular[ie]->GetLabel() );
851 for (G4int ip = 0; ip < nAngularParameters; ++ip) {
852 theAngular[ie].SetValue(ip, vAngular[ie]->GetValue(ip));
853 }
855 theDiscreteEnergies.insert(theAngular[ie].GetLabel());
856 }
857
858 // The continuous energies need to be made from scratch like the discrete
859 // ones. Therefore the re-assignemnt of theAngular needs to be done
860 // after the continuous energy set is also finalized. Only then the
861 // total number of nEnergies is known and the array can be allocated.
862
863 // Get minimum and maximum energy interpolating
864 // Don't use theMinEner or theMaxEner here, since the transformed energies
865 // need the interpolated range from the original Angpar
866 G4double interMinEner = copyAngpar1.GetMinEner() + (theEnergy-copyAngpar1.GetEnergy() )
867 * (copyAngpar2.GetMinEner() - copyAngpar1.GetMinEner() )
868 / (copyAngpar2.GetEnergy()-copyAngpar1.GetEnergy() );
869 G4double interMaxEner = copyAngpar1.GetMaxEner() + (theEnergy-copyAngpar1.GetEnergy() )
870 * (copyAngpar2.GetMaxEner()-copyAngpar1.GetMaxEner() )
871 / (copyAngpar2.GetEnergy()-copyAngpar1.GetEnergy() );
872
873 if (std::getenv("G4PHPTEST2") )
874 G4cout << " G4ParticleHPContAngularPar::Merge E " << anEnergy << " minmax "
875 << interMinEner << " " << interMaxEner << G4endl; //GDEB
876
877 // Loop to energies of new set
879
880 G4int nEnergies1 = copyAngpar1.GetNEnergies();
881 G4int nDiscreteEnergies1 = copyAngpar1.GetNDiscreteEnergies();
882 G4double minEner1 = copyAngpar1.GetMinEner();
883 G4double maxEner1 = copyAngpar1.GetMaxEner();
884 G4int nEnergies2 = copyAngpar2.GetNEnergies();
885 G4int nDiscreteEnergies2 = copyAngpar2.GetNDiscreteEnergies();
886 G4double minEner2 = copyAngpar2.GetMinEner();
887 G4double maxEner2 = copyAngpar2.GetMaxEner();
888
889 // First build the list of transformed energies normalized
890 // to the new min max by assuming that the min-max range of
891 // each set would be scalable to the new, interpolated min
892 // max range
893
894 G4double e1(0.);
895 G4double eTNorm1(0.);
896 for (ie1 = nDiscreteEnergies1; ie1 < nEnergies1; ++ie1) {
897 e1 = copyAngpar1.theAngular[ie1].GetLabel();
898 eTNorm1 = (e1 - minEner1);
899 if (maxEner1 != minEner1) eTNorm1 /= (maxEner1-minEner1);
900 if (eTNorm1 >= 0 && eTNorm1 <= 1) theEnergiesTransformed.insert(eTNorm1);
901 }
902
903 G4double e2(0.);
904 G4double eTNorm2(0.);
905 for (ie2 = nDiscreteEnergies2; ie2 < nEnergies2; ++ie2) {
906 e2 = copyAngpar2.theAngular[ie2].GetLabel();
907 eTNorm2 = (e2 - minEner2);
908 if (maxEner2 != minEner2) eTNorm2 /= (maxEner2-minEner2);
909 if (eTNorm2 >= 0 && eTNorm2 <= 1) theEnergiesTransformed.insert(eTNorm2);
910 }
911
912 // Now the list of energies is complete
914
915 // Create final array of angular parameters
916 G4ParticleHPList* theNewAngular = new G4ParticleHPList [nEnergies];
917
918 // Copy discrete energies and interpolated parameters to new array
919
920 if (theAngular != 0) {
921 for (ie = 0; ie < nDiscreteEnergies; ++ie) {
922 theNewAngular[ie].SetLabel(theAngular[ie].GetLabel());
923 for (G4int ip = 0; ip < nAngularParameters; ++ip) {
924 theNewAngular[ie].SetValue(ip,theAngular[ie].GetValue(ip));
925 }
926 }
927 delete [] theAngular;
928 }
929 theAngular = theNewAngular;
930
931 // Interpolate the continuous energies for new array
932 std::set<G4double>::const_iterator iteet = theEnergiesTransformed.begin();
933
934 G4double e1Interp(0.);
935 G4double e2Interp(0.);
936 for (ie = nDiscreteEnergies; ie < nEnergies; ++ie, ++iteet) {
937 G4double eT = (*iteet);
938
939 //--- Use eT1 = eT: Get energy and parameters of copyAngpar1 for this eT
940 e1Interp = (maxEner1 - minEner1) * eT + minEner1;
941 //----- Get parameter value corresponding to this e1Interp
942 for (ie1 = nDiscreteEnergies1; ie1 < nEnergies1; ++ie1) {
943 if ((copyAngpar1.theAngular[ie1].GetLabel() - e1Interp) > 1.E-10*e1Interp) break;
944 }
945 ie1Prev = ie1 - 1;
946 if (ie1 == 0) ie1Prev++;
947 if (ie1 == nEnergies1) {
948 ie1--;
949 ie1Prev = ie1;
950 }
951
952 //--- Use eT2 = eT: Get energy and parameters of copyAngpar2 for this eT
953 e2Interp = (maxEner2-minEner2) * eT + minEner2;
954 //----- Get parameter value corresponding to this e2Interp
955 for (ie2 = nDiscreteEnergies2; ie2 < nEnergies2; ++ie2) {
956 if ((copyAngpar2.theAngular[ie2].GetLabel() - e2Interp) > 1.E-10*e2Interp) break;
957 }
958 ie2Prev = ie2 - 1;
959 if (ie2 == 0) ie2Prev++;
960 if (ie2 == nEnergies2) {
961 ie2--;
962 ie2Prev = ie2;
963 }
964
965 //---- Energy corresponding to energy transformed
966 G4double eN = (interMaxEner-interMinEner) * eT + interMinEner;
967 if (std::getenv("G4PHPTEST2") )
968 G4cout << ie << " " << ie1 << " " << ie2 << " G4ParticleHPContAngularPar::loop eT "
969 << eT << " -> eN " << eN << " e1Interp " << e1Interp << " e2Interp " << e2Interp << G4endl; //GDEB
970
971 theAngular[ie].SetLabel(eN);
972 if (eN < theMinEner) {
973 theMinEner = eN;
974 }
975 if (eN > theMaxEner) {
976 theMaxEner = eN;
977 }
978
979 G4double val1(0.);
980 G4double val2(0.);
981 G4double value(0.);
982 for (G4int ip = 0; ip < nAngularParameters; ++ip) {
984 e1Interp,
985 copyAngpar1.theAngular[ie1Prev].GetLabel(),
986 copyAngpar1.theAngular[ie1].GetLabel(),
987 copyAngpar1.theAngular[ie1Prev].GetValue(ip),
988 copyAngpar1.theAngular[ie1].GetValue(ip)) * (maxEner1-minEner1);
990 e2Interp,
991 copyAngpar2.theAngular[ie2Prev].GetLabel(),
992 copyAngpar2.theAngular[ie2].GetLabel(),
993 copyAngpar2.theAngular[ie2Prev].GetValue(ip),
994 copyAngpar2.theAngular[ie2].GetValue(ip)) * (maxEner2-minEner2);
995
996 value = theInt.Interpolate(aScheme, anEnergy,
997 copyAngpar1.theEnergy, copyAngpar2.theEnergy,
998 val1, val2);
999 if (interMaxEner != interMinEner) {
1000 value /= (interMaxEner-interMinEner);
1001 } else if (value != 0) {
1002 throw G4HadronicException(__FILE__, __LINE__,
1003 "G4ParticleHPContAngularPar::PrepareTableInterpolation interMaxEner == interMinEner and value != 0.");
1004 }
1005 if (std::getenv("G4PHPTEST2") )
1006 G4cout << ie << " " << ip << " G4ParticleHPContAngularPar::Merge val1 " << val1
1007 << " val2 " << val2 << " value " << value << G4endl; //GDEB
1008 theAngular[ie].SetValue(ip, value);
1009 }
1010 } // end loop on nDiscreteEnergies
1011
1012 for (itv = vAngular.begin(); itv != vAngular.end(); ++itv) delete (*itv);
1013
1014 if (std::getenv("G4PHPTEST2") ) {
1015 G4cout << " G4ParticleHPContAngularPar::Merge ANGPAR1 " << G4endl; //GDEB
1016 copyAngpar1.Dump();
1017 G4cout << " G4ParticleHPContAngularPar::Merge ANGPAR2 " << G4endl;
1018 copyAngpar2.Dump();
1019 G4cout << " G4ParticleHPContAngularPar::Merge ANGPARNEW " << G4endl;
1020 Dump();
1021 }
1022}
static const G4double e1[44]
static const G4double e2[44]
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4InterpolationScheme GetScheme(G4int index) const
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4double Interpolate2(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const

References DBL_MAX, Dump(), e1, e2, fCache, G4cout, G4endl, GetDiscreteEnergiesOwn(), GetEnergy(), G4ParticleHPList::GetLabel(), GetMaxEner(), GetMinEner(), GetNDiscreteEnergies(), GetNEnergies(), G4InterpolationManager::GetScheme(), G4ParticleHPList::GetValue(), G4ParticleHPInterpolator::Interpolate(), G4ParticleHPInterpolator::Interpolate2(), nAngularParameters, nDiscreteEnergies, nEnergies, G4ParticleHPList::SetLabel(), G4ParticleHPList::SetValue(), theAngular, theDiscreteEnergies, theDiscreteEnergiesOwn, theEnergiesTransformed, theEnergy, theInt, theManager, theMaxEner, and theMinEner.

Referenced by G4ParticleHPContEnergyAngular::Sample().

◆ cacheInit()

void G4ParticleHPContAngularPar::cacheInit ( )
inlineprivate

Definition at line 232 of file G4ParticleHPContAngularPar.hh.

233 {
234 toBeCached* val = new toBeCached;
235 val->currentMeanEnergy = -2;
236 val->remaining_energy = 0;
237 val->fresh=true;
238 fCache.Put( val );
239 };

References G4ParticleHPContAngularPar::toBeCached::currentMeanEnergy, fCache, G4ParticleHPContAngularPar::toBeCached::fresh, and G4ParticleHPContAngularPar::toBeCached::remaining_energy.

Referenced by ClearHistories(), G4ParticleHPContAngularPar(), and Sample().

◆ ClearHistories()

void G4ParticleHPContAngularPar::ClearHistories ( )
inline

Definition at line 204 of file G4ParticleHPContAngularPar.hh.

205 {
206 if ( fCache.Get() == 0 ) cacheInit();
207 fCache.Get()->fresh = true;
208 }

References cacheInit(), and fCache.

Referenced by G4ParticleHPContEnergyAngular::ClearHistories().

◆ Dump()

void G4ParticleHPContAngularPar::Dump ( ) const

Definition at line 1025 of file G4ParticleHPContAngularPar.cc.

1026{
1027 G4cout << theEnergy << " " << nEnergies << " " << nDiscreteEnergies
1028 << " " << nAngularParameters << G4endl;
1029
1030 for (G4int ii = 0; ii < nEnergies; ii++) theAngular[ii].Dump();
1031}

References Dump(), G4cout, G4endl, nAngularParameters, nDiscreteEnergies, nEnergies, theAngular, and theEnergy.

Referenced by BuildByInterpolation(), and Dump().

◆ GetAngDataList()

G4ParticleHPList * G4ParticleHPContAngularPar::GetAngDataList ( ) const
inline

Definition at line 199 of file G4ParticleHPContAngularPar.hh.

200 {
201 return theAngular;
202 }

References theAngular.

◆ GetDiscreteEnergiesOwn()

std::map< G4double, G4int > G4ParticleHPContAngularPar::GetDiscreteEnergiesOwn ( ) const
inline

Definition at line 195 of file G4ParticleHPContAngularPar.hh.

196 {
198 }

References theDiscreteEnergiesOwn.

Referenced by BuildByInterpolation().

◆ GetEnergiesTransformed()

std::set< G4double > G4ParticleHPContAngularPar::GetEnergiesTransformed ( ) const
inline

Definition at line 179 of file G4ParticleHPContAngularPar.hh.

180 {
182 }

References theEnergiesTransformed.

◆ GetEnergy()

G4double G4ParticleHPContAngularPar::GetEnergy ( ) const
inline

Definition at line 120 of file G4ParticleHPContAngularPar.hh.

121 {
122 if( std::getenv("G4PHPTEST") )
123 G4cout << this << " G4ParticleHPContAngularPar::GetEnergy "
124 << theEnergy << " nE " << nEnergies << G4endl;
125 return theEnergy;
126 }

References G4cout, G4endl, nEnergies, and theEnergy.

Referenced by BuildByInterpolation(), and G4ParticleHPContEnergyAngular::Sample().

◆ GetMaxEner()

G4double G4ParticleHPContAngularPar::GetMaxEner ( ) const
inline

Definition at line 191 of file G4ParticleHPContAngularPar.hh.

192 {
193 return theMaxEner;
194 }

References theMaxEner.

Referenced by BuildByInterpolation().

◆ GetMinEner()

G4double G4ParticleHPContAngularPar::GetMinEner ( ) const
inline

Definition at line 187 of file G4ParticleHPContAngularPar.hh.

188 {
189 return theMinEner;
190 }

References theMinEner.

Referenced by BuildByInterpolation().

◆ GetNDiscreteEnergies()

G4int G4ParticleHPContAngularPar::GetNDiscreteEnergies ( ) const
inline

Definition at line 175 of file G4ParticleHPContAngularPar.hh.

176 {
177 return nDiscreteEnergies;
178 }

References nDiscreteEnergies.

Referenced by BuildByInterpolation().

◆ GetNEnergies()

G4int G4ParticleHPContAngularPar::GetNEnergies ( ) const
inline

Definition at line 171 of file G4ParticleHPContAngularPar.hh.

172 {
173 return nEnergies;
174 }

References nEnergies.

Referenced by BuildByInterpolation(), and G4ParticleHPContEnergyAngular::Sample().

◆ GetNEnergiesTransformed()

G4int G4ParticleHPContAngularPar::GetNEnergiesTransformed ( ) const
inline

Definition at line 183 of file G4ParticleHPContAngularPar.hh.

184 {
185 return theEnergiesTransformed.size();
186 }

References theEnergiesTransformed.

◆ Init()

void G4ParticleHPContAngularPar::Init ( std::istream &  aDataFile,
G4ParticleDefinition projectile 
)

Definition at line 86 of file G4ParticleHPContAngularPar.cc.

87{
88 adjustResult = true;
89 if (G4ParticleHPManager::GetInstance()->GetDoNotAdjustFinalState() )
90 adjustResult = false;
91
92 theProjectile = projectile;
93
95 theEnergy *= eV;
97 G4double sEnergy;
98 for (G4int i = 0; i < nEnergies; i++) {
99 aDataFile >> sEnergy;
100 sEnergy *= eV;
101 theAngular[i].SetLabel(sEnergy);
102 theAngular[i].Init(aDataFile, nAngularParameters, 1.);
103 theMinEner = std::min(theMinEner,sEnergy);
104 theMaxEner = std::max(theMaxEner,sEnergy);
105 }
106}
static constexpr double eV
Definition: G4SIunits.hh:201
void Init(std::istream &aDataFile, G4int nPar, G4double unit=1.)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References adjustResult, eV, G4ParticleHPManager::GetInstance(), G4ParticleHPList::Init(), G4INCL::Math::max(), G4INCL::Math::min(), nAngularParameters, nDiscreteEnergies, nEnergies, G4ParticleHPList::SetLabel(), theAngular, theEnergy, theMaxEner, theMinEner, and theProjectile.

Referenced by G4ParticleHPContEnergyAngular::Init().

◆ MeanEnergyOfThisInteraction()

G4double G4ParticleHPContAngularPar::MeanEnergyOfThisInteraction ( )
inline

Definition at line 155 of file G4ParticleHPContAngularPar.hh.

156 {
157 G4double result;
158 if(fCache.Get()->currentMeanEnergy<-1)
159 {
160 return 0;
161 // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
162 }
163 else
164 {
165 result = fCache.Get()->currentMeanEnergy;
166 }
167 fCache.Get()->currentMeanEnergy = -2;
168 return result;
169 }

References fCache.

Referenced by G4ParticleHPContEnergyAngular::Sample().

◆ PrepareTableInterpolation()

void G4ParticleHPContAngularPar::PrepareTableInterpolation ( )

Definition at line 645 of file G4ParticleHPContAngularPar.cc.

646{
647 // Discrete energies: store own energies in a map for faster searching
648 //
649 // The data files sometimes have identical discrete energies (likely typos)
650 // which would lead to overwriting the already existing index and hence
651 // creating a hole in the lookup table.
652 // No attempt is made here to correct for the energies - rather an epsilon
653 // is subtracted from the energy in order to uniquely identify the line
654
655 for (G4int ie = 0; ie < nDiscreteEnergies; ie++) {
656 // check if energy is already present and subtract epsilon if that's the case
657 G4double myE = theAngular[ie].GetLabel();
658 while (theDiscreteEnergiesOwn.find(myE) != theDiscreteEnergiesOwn.end() ) {
659 myE -= 1e-6;
660 }
661 theDiscreteEnergiesOwn[myE] = ie;
662 }
663
664 /*
665 * the approach here makes no sense. It would work only for two sets that
666 * have identical min and max energy. If the 2 sets differ in min, max or
667 * both, the energy inserted would be normalized to its original set but
668 * interpreted with the new - which is not correct.
669 *
670 * Disable the code for now and simply return ...
671 */
672
673 return;
674
675 /*
676 *
677
678 if( !angParPrev ) return;
679
680 //----- Discrete energies: use energies that appear in one or another
681 for(ie=0; ie<nDiscreteEnergies; ie++) {
682 theDiscreteEnergies.insert(theAngular[ie].GetLabel());
683 }
684 G4int nDiscreteEnergiesPrev = angParPrev->GetNDiscreteEnergies();
685 for(ie=0; ie<nDiscreteEnergiesPrev; ie++) {
686 theDiscreteEnergies.insert(angParPrev->theAngular[ie].GetLabel());
687 }
688
689 //--- Get the values for which interpolation will be done : all energies of this and previous ContAngularPar
690 for(ie=nDiscreteEnergies; ie<nEnergies; ie++) {
691 G4double ener = theAngular[ie].GetLabel();
692 G4double enerT = (ener-theMinEner)/(theMaxEner-theMinEner);
693 theEnergiesTransformed.insert(enerT);
694 if( getenv("G4PHPTEST2") ) G4cout <<this << " G4ParticleHPContAngularPar::PrepareTableInterpolation theEnergiesTransformed1 " << enerT << G4endl; //GDEB
695 }
696 G4int nEnergiesPrev = angParPrev->GetNEnergies();
697 G4double minEnerPrev = angParPrev->GetMinEner();
698 G4double maxEnerPrev = angParPrev->GetMaxEner();
699 for(ie=nDiscreteEnergiesPrev; ie<nEnergiesPrev; ie++) {
700 G4double ener = angParPrev->theAngular[ie].GetLabel();
701 G4double enerT = (ener-minEnerPrev)/(maxEnerPrev-minEnerPrev);
702 theEnergiesTransformed.insert(enerT);
703 if( getenv("G4PHPTEST2") ) G4cout << this << " G4ParticleHPContAngularPar::PrepareTableInterpolation theEnergiesTransformed2 " << enerT << G4endl; //GDEB
704 }
705 // add the maximum energy
706 //theEnergiesTransformed.insert(1.);
707
708 *
709 */
710}

References G4ParticleHPList::GetLabel(), nDiscreteEnergies, theAngular, and theDiscreteEnergiesOwn.

Referenced by G4ParticleHPContEnergyAngular::Init().

◆ Sample()

G4ReactionProduct * G4ParticleHPContAngularPar::Sample ( G4double  anEnergy,
G4double  massCode,
G4double  mass,
G4int  angularRep,
G4int  interpol 
)

Definition at line 110 of file G4ParticleHPContAngularPar.cc.

113{
114 // The following line is needed because it may change between runs by UI command
115 if (G4ParticleHPManager::GetInstance()->GetDoNotAdjustFinalState() )
116 adjustResult = false;
117
118 if (std::getenv("G4PHPTEST") ) G4cout << " G4ParticleHPContAngularPar::Sample "
119 << anEnergy << " " << massCode << " "
120 << angularRep << G4endl; //GDEB
121 if (fCache.Get() == 0 ) cacheInit();
123 G4int Z = static_cast<G4int>(massCode/1000);
124 G4int A = static_cast<G4int>(massCode-1000*Z);
125 if (massCode == 0) {
126 result->SetDefinition(G4Gamma::Gamma());
127 } else if (A == 0) {
129 if (Z == 1) result->SetDefinition(G4Positron::Positron());
130 } else if (A == 1) {
132 if (Z == 1) result->SetDefinition(G4Proton::Proton());
133 } else if (A == 2) {
135 } else if (A == 3) {
137 if(Z == 2) result->SetDefinition(G4He3::He3());
138 } else if (A == 4) {
139 result->SetDefinition(G4Alpha::Alpha());
140 if (Z != 2) throw G4HadronicException(__FILE__, __LINE__,
141 "G4ParticleHPContAngularPar: Unknown ion case 1");
142 } else {
143 result->SetDefinition(G4IonTable::GetIonTable()->GetIon(Z,A,0) );
144 }
145
146 G4int i(0);
147 G4int it(0);
148 G4double fsEnergy(0);
149 G4double cosTh(0);
150
151 if (angularRep == 1) {
152 if (nDiscreteEnergies != 0) {
153 // 1st check remaining_energy
154 // if this is the first set it. (How?)
155 if (fCache.Get()->fresh == true) {
156 // Discrete Lines, larger energies come first
157 // Continues Emssions, low to high LAST
158 fCache.Get()->remaining_energy = std::max (theAngular[0].GetLabel(),
159 theAngular[nEnergies-1].GetLabel() );
160 fCache.Get()->fresh = false;
161 if (std::getenv("G4PHPTEST") )
162 G4cout << " G4ParticleHPContAngularPar::Sample fresh remaining_energy "
163 << fCache.Get()->remaining_energy << G4endl;
164 }
165
166 // Cheating for small remaining_energy
167 // Temporary solution
169 fCache.Get()->remaining_energy = std::max(fCache.Get()->remaining_energy,
170 theAngular[nDiscreteEnergies-1].GetLabel() ); //Minimum Line
171 if (std::getenv("G4PHPTEST") )
172 G4cout << " G4ParticleHPContAngularPar::Sample cheat case for small remaining_energy "
173 << fCache.Get()->remaining_energy << G4endl;
174 } else {
175 G4double cont_min = 0.0;
176 for (G4int j = nDiscreteEnergies; j < nEnergies; j++) {
177 cont_min = theAngular[j].GetLabel();
178 if (theAngular[j].GetValue(0) != 0.0 ) break;
179 }
180 fCache.Get()->remaining_energy =
181 std::max (fCache.Get()->remaining_energy,
182 std::min(theAngular[nDiscreteEnergies-1].GetLabel(), cont_min) ); //Minimum Line or grid
183 if (std::getenv("G4PHPTEST") )
184 G4cout << " G4ParticleHPContAngularPar::Sample max line or grid remaining_energy "
185 << fCache.Get()->remaining_energy << G4endl;
186 }
187
188 G4double random = G4UniformRand();
189 G4double* running = new G4double[nEnergies+1];
190 running[0] = 0.0;
191
192 G4double delta;
193 for (G4int j = 0; j < nDiscreteEnergies; j++) {
194 delta = 0.0;
195 if (theAngular[j].GetLabel() <= fCache.Get()->remaining_energy)
196 delta = theAngular[j].GetValue(0);
197 running[j+1] = running[j] + delta;
198 }
199
200 G4double tot_prob_DIS = running[nDiscreteEnergies];
201
202 G4double delta1;
203 for (G4int j = nDiscreteEnergies; j < nEnergies; j++) {
204 delta1 = 0.0;
205 G4double e_low = 0.0;
206 G4double e_high = 0.0;
207 if (theAngular[j].GetLabel() <= fCache.Get()->remaining_energy)
208 delta1 = theAngular[j].GetValue(0);
209
210 // To calculate Prob. e_low and e_high should be in eV
211 // There are two cases:
212 // 1: theAngular[nDiscreteEnergies].GetLabel() != 0.0
213 // delta1 should be used between j-1 and j
214 // At j = nDiscreteEnergies (the first) e_low should be set explicitly
215 if (theAngular[j].GetLabel() != 0) {
216 if (j == nDiscreteEnergies) {
217 e_low = 0.0/eV;
218 } else {
219 e_low = theAngular[j-1].GetLabel()/eV;
220 }
221 e_high = theAngular[j].GetLabel()/eV;
222 }
223
224 // 2: theAngular[nDiscreteEnergies].GetLabel() == 0.0
225 // delta1 should be used between j and j+1
226 if (theAngular[j].GetLabel() == 0.0) {
227 e_low = theAngular[j].GetLabel()/eV;
228 if (j != nEnergies-1) {
229 e_high = theAngular[j+1].GetLabel()/eV;
230 } else {
231 e_high = theAngular[j].GetLabel()/eV;
232 if (theAngular[j].GetValue(0) != 0.0) {
233 throw G4HadronicException(__FILE__, __LINE__,
234 "G4ParticleHPContAngularPar: Unexpected non zero value of theAngular[nEnergies-1].GetValue(0)");
235 }
236 }
237 }
238
239 running[j+1] = running[j] + ( ( e_high - e_low ) * delta1);
240 }
241 G4double tot_prob_CON = running[ nEnergies ] - running[ nDiscreteEnergies ];
242
243 // Normalize random
244 random *= (tot_prob_DIS + tot_prob_CON);
245 // 2nd Judge Discrete or not
246
247 // This should be relatively close to 1 For safty
248 if (random <= (tot_prob_DIS/(tot_prob_DIS + tot_prob_CON) ) || nDiscreteEnergies == nEnergies) {
249 // Discrete Emission
250 for (G4int j = 0; j < nDiscreteEnergies; j++) {
251 // Here we should use i+1
252 if (random < running[ j+1 ] ) {
253 it = j;
254 break;
255 }
256 }
257 fsEnergy = theAngular[ it ].GetLabel();
258
259 G4ParticleHPLegendreStore theStore(1);
260 theStore.Init(0,fsEnergy,nAngularParameters);
261 for (G4int j = 0; j < nAngularParameters; j++) {
262 theStore.SetCoeff(0,j,theAngular[it].GetValue(j));
263 }
264 // use it to sample.
265 cosTh = theStore.SampleMax(fsEnergy);
266 // Done
267
268 } else {
269 // Continuous emission
270 for (G4int j = nDiscreteEnergies; j < nEnergies; j++) {
271 // Here we should use i
272 if (random < running[ j ] ) {
273 it = j;
274 break;
275 }
276 }
277
278 G4double x1 = running[it-1];
279 G4double x2 = running[it];
280
281 G4double y1 = 0.0;
282 if (it != nDiscreteEnergies) y1 = theAngular[it-1].GetLabel();
283 G4double y2 = theAngular[it].GetLabel();
284
286 random,x1,x2,y1,y2);
287
288 G4ParticleHPLegendreStore theStore(2);
289 theStore.Init(0, y1, nAngularParameters);
290 theStore.Init(1, y2, nAngularParameters);
291 theStore.SetManager(theManager);
292 G4int itt;
293 for (G4int j = 0; j < nAngularParameters; j++) {
294 itt = it;
295 if (it == nDiscreteEnergies) itt = it+1;
296 // "This case "it-1" has data for Discrete, so we will use an extrpolated values it and it+1
297 if (it == 0) {
298 // Safty for unexpected it = 0;
299 itt = it+1;
300 }
301 theStore.SetCoeff(0, j, theAngular[itt-1].GetValue(j) );
302 theStore.SetCoeff(1, j, theAngular[itt].GetValue(j) );
303 }
304 // use it to sample.
305 cosTh = theStore.SampleMax(fsEnergy);
306
307 //Done
308 }
309
310 // The remaining energy needs to be lowered by the photon energy in *any* case.
311 // Otherwise additional photons with too high energy will be produced - therefore the
312 // adjustResult condition has been removed
313 if (std::getenv("G4PHPTEST") )
314 G4cout << " G4ParticleHPContAngularPar::Sample remaining_energy - fsEnergy "
315 << fCache.Get()->remaining_energy << " - " << fsEnergy << G4endl;
316 fCache.Get()->remaining_energy -= fsEnergy;
317 delete[] running;
318
319 // end (nDiscreteEnergies != 0) branch
320
321 } else {
322 // Only continue, TK will clean up
323 if (fCache.Get()->fresh == true) {
324 fCache.Get()->remaining_energy = theAngular[ nEnergies-1 ].GetLabel();
325 fCache.Get()->fresh = false;
326 if (std::getenv("G4PHPTEST") )
327 G4cout << " G4ParticleHPContAngularPar::Sample 2nd fresh remaining_energy "
328 << fCache.Get()->remaining_energy << G4endl;
329 }
330
331 G4double random = G4UniformRand();
332 G4double* running = new G4double[nEnergies];
333 running[0] = 0;
334 G4double weighted = 0;
335 for (i = 1; i < nEnergies; i++) {
336 running[i]=running[i-1];
337 if (fCache.Get()->remaining_energy >= theAngular[i].GetLabel() ) {
338 running[i] += theInt.GetBinIntegral(theManager.GetScheme(i-1),
339 theAngular[i-1].GetLabel(),
340 theAngular[i].GetLabel(),
341 theAngular[i-1].GetValue(0),
342 theAngular[i].GetValue(0) );
344 theAngular[i-1].GetLabel(),
345 theAngular[i].GetLabel(),
346 theAngular[i-1].GetValue(0),
347 theAngular[i].GetValue(0));
348 }
349 }
350
351 // Cache the mean energy in this distribution
352 if (nEnergies == 1 || running[nEnergies-1] == 0) {
353 fCache.Get()->currentMeanEnergy = 0.0;
354 } else {
355 fCache.Get()->currentMeanEnergy = weighted/running[nEnergies-1];
356 }
357
358 if (nEnergies == 1) it = 0;
359 if (running[nEnergies-1] != 0) {
360 for (i = 1; i < nEnergies; i++) {
361 it = i;
362 if (random < running [i]/running[nEnergies-1] ) break;
363 }
364 }
365
366 if (running[nEnergies-1] == 0) it = 0;
367 if (it < nDiscreteEnergies || it == 0) {
368 if (it == 0) {
369 fsEnergy = theAngular[it].GetLabel();
370 G4ParticleHPLegendreStore theStore(1);
371 theStore.Init(0,fsEnergy,nAngularParameters);
372 for (i = 0; i < nAngularParameters; i++) {
373 theStore.SetCoeff(0, i, theAngular[it].GetValue(i) );
374 }
375 // use it to sample.
376 cosTh = theStore.SampleMax(fsEnergy);
377
378 } else {
379 G4double e1, e2;
380 e1 = theAngular[it-1].GetLabel();
381 e2 = theAngular[it].GetLabel();
383 random,
384 running[it-1]/running[nEnergies-1],
385 running[it]/running[nEnergies-1],
386 e1, e2);
387 // fill a Legendrestore
388 G4ParticleHPLegendreStore theStore(2);
389 theStore.Init(0,e1,nAngularParameters);
390 theStore.Init(1,e2,nAngularParameters);
391 for (i = 0; i < nAngularParameters; i++) {
392 theStore.SetCoeff(0, i, theAngular[it-1].GetValue(i) );
393 theStore.SetCoeff(1, i, theAngular[it].GetValue(i) );
394 }
395 // use it to sample.
396 theStore.SetManager(theManager);
397 cosTh = theStore.SampleMax(fsEnergy);
398 }
399
400 } else { // continuum contribution
401 G4double x1 = running[it-1]/running[nEnergies-1];
402 G4double x2 = running[it]/running[nEnergies-1];
403 G4double y1 = theAngular[it-1].GetLabel();
404 G4double y2 = theAngular[it].GetLabel();
406 random,x1,x2,y1,y2);
407 G4ParticleHPLegendreStore theStore(2);
408 theStore.Init(0,y1,nAngularParameters);
409 theStore.Init(1,y2,nAngularParameters);
410 theStore.SetManager(theManager);
411 for (i = 0; i < nAngularParameters; i++) {
412 theStore.SetCoeff(0, i, theAngular[it-1].GetValue(i));
413 theStore.SetCoeff(1, i, theAngular[it].GetValue(i));
414 }
415 // use it to sample.
416 cosTh = theStore.SampleMax(fsEnergy);
417 }
418 delete [] running;
419
420 // The remaining energy needs to be lowered by the photon energy in
421 // *any* case. Otherwise additional photons with too much energy will be
422 // produced - therefore the adjustResult condition has been removed
423
424 if (std::getenv("G4PHPTEST") )
425 G4cout << " G4ParticleHPContAngularPar::Sample 2nd remaining_energy - fsEnergy "
426 << fCache.Get()->remaining_energy << " - " << fsEnergy << G4endl;
427 fCache.Get()->remaining_energy -= fsEnergy;
428 // end if (nDiscreteEnergies != 0)
429 }
430 // end of (angularRep == 1) branch
431
432 } else if (angularRep == 2) {
433 // first get the energy (already the right for this incoming energy)
434 G4int j;
435 G4double* running = new G4double[nEnergies];
436 running[0] = 0;
437 G4double weighted = 0;
438 if (std::getenv("G4PHPTEST") )
439 G4cout << " G4ParticleHPContAngularPar::Sample nEnergies " << nEnergies << G4endl;
440 for (j = 1; j < nEnergies; j++) {
441 if (j != 0) running[j] = running[j-1];
442 running[j] += theInt.GetBinIntegral(theManager.GetScheme(j-1),
444 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
447 theAngular[j-1].GetValue(0), theAngular[j].GetValue(0));
448 if (std::getenv("G4PHPTEST") )
449 G4cout << " G4ParticleHPContAngularPar::Sample " << j << " running " << running[j]
450 << " " << theManager.GetScheme(j-1) << " " << theAngular[j-1].GetLabel()
451 << " " << theAngular[j].GetLabel() << " " << theAngular[j-1].GetValue(0)
452 << " " << theAngular[j].GetValue(0) << G4endl; //GDEB
453 }
454
455 // Cache the mean energy in this distribution
456 if (nEnergies == 1)
457 fCache.Get()->currentMeanEnergy = 0.0;
458 else
459 fCache.Get()->currentMeanEnergy = weighted/running[nEnergies-1];
460
461 G4int itt(0);
462 G4double randkal = G4UniformRand();
463 for (j = 1; j < nEnergies; j++) {
464 itt = j;
465 if (randkal < running[j]/running[nEnergies-1] ) break;
466 }
467
468 // Interpolate the secondary energy
469 G4double x, x1, x2, y1, y2;
470 if (itt == 0) itt = 1;
471 x = randkal*running[nEnergies-1];
472 x1 = running[itt-1];
473 x2 = running[itt];
474 G4double compoundFraction;
475 // interpolate energy
476 y1 = theAngular[itt-1].GetLabel();
477 y2 = theAngular[itt].GetLabel();
479 x, x1, x2, y1, y2);
480 if (std::getenv("G4PHPTEST") )
481 G4cout << itt << " G4particleHPContAngularPar fsEnergy " << fsEnergy << " "
482 << theManager.GetInverseScheme(itt-1) << " x " << x << " " << x1 << " "
483 << x2 << " y " << y1 << " " << y2 << G4endl; //GDEB
484 // For theta, interpolate the compoundFractions
485 G4double cLow = theAngular[itt-1].GetValue(1);
486 G4double cHigh = theAngular[itt].GetValue(1);
487 compoundFraction = theInt.Interpolate(theManager.GetScheme(itt),
488 fsEnergy, y1, y2, cLow, cHigh);
489
490 if (compoundFraction > 1.0) compoundFraction = 1.0; // Protection against unphysical interpolation
491
492 if (std::getenv("G4PHPTEST") )
493 G4cout << itt << " G4particleHPContAngularPar compoundFraction " << compoundFraction
494 << " E " << fsEnergy << " " << theManager.GetScheme(itt) << " ener " << fsEnergy
495 << " y " << y1 << " " << y2 << " cLH " << cLow << " " << cHigh << G4endl; //GDEB
496 delete [] running;
497
498 // get cosTh
499 G4double incidentEnergy = anEnergy;
500 G4double incidentMass = theProjectile->GetPDGMass();
501 G4double productEnergy = fsEnergy;
502 G4double productMass = result->GetMass();
503 G4int targetZ = G4int(fCache.Get()->theTargetCode/1000);
504 G4int targetA = G4int(fCache.Get()->theTargetCode-1000*targetZ);
505
506 // To correspond to natural composition (-nat-) data files.
507 if (targetA == 0)
508 targetA = G4int ( fCache.Get()->theTarget->GetMass()/amu_c2 + 0.5 );
509 G4double targetMass = fCache.Get()->theTarget->GetMass();
510 G4int incidentA=G4int(incidentMass/amu_c2 + 0.5 );
511 G4int incidentZ=G4int(theProjectile->GetPDGCharge()+ 0.5 );
512 G4int residualA = targetA+incidentA-A;
513 G4int residualZ = targetZ+incidentZ-Z;
514 G4double residualMass =G4NucleiProperties::GetNuclearMass( residualA , residualZ );
515 G4ParticleHPKallbachMannSyst theKallbach(compoundFraction,
516 incidentEnergy, incidentMass,
517 productEnergy, productMass,
518 residualMass, residualA, residualZ,
519 targetMass, targetA, targetZ,
520 incidentA,incidentZ,A,Z);
521 cosTh = theKallbach.Sample(anEnergy);
522 if (std::getenv("G4PHPTEST") )
523 G4cout << " G4ParticleHPKallbachMannSyst::Sample resulttest " << cosTh << G4endl; //GDEB
524 // end (angularRep == 2) branch
525
526 } else if (angularRep > 10 && angularRep < 16) {
527 G4double random = G4UniformRand();
528 G4double* running = new G4double[nEnergies];
529 running[0]=0;
530 G4double weighted = 0;
531 for (i = 1; i < nEnergies; i++) {
532 if (i != 0) running[i] = running[i-1];
533 running[i] += theInt.GetBinIntegral(theManager.GetScheme(i-1),
535 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
538 theAngular[i-1].GetValue(0), theAngular[i].GetValue(0));
539 }
540
541 // Cache the mean energy in this distribution
542 if (nEnergies == 1)
543 fCache.Get()->currentMeanEnergy = 0.0;
544 else
545 fCache.Get()->currentMeanEnergy = weighted/running[nEnergies-1];
546
547 if (nEnergies == 1) it = 0;
548 for (i = 1; i < nEnergies; i++) {
549 it = i;
550 if(random<running[i]/running[nEnergies-1]) break;
551 }
552
553 if (it < nDiscreteEnergies || it == 0) {
554 if (it == 0) {
555 fsEnergy = theAngular[0].GetLabel();
556 G4ParticleHPVector theStore;
557 G4int aCounter = 0;
558 for (G4int j=1; j<nAngularParameters; j+=2) {
559 theStore.SetX(aCounter, theAngular[0].GetValue(j));
560 theStore.SetY(aCounter, theAngular[0].GetValue(j+1));
561 aCounter++;
562 }
564 aMan.Init(angularRep-10, nAngularParameters-1);
565 theStore.SetInterpolationManager(aMan);
566 cosTh = theStore.Sample();
567 } else {
568 fsEnergy = theAngular[it].GetLabel();
569 G4ParticleHPVector theStore;
571 aMan.Init(angularRep-10, nAngularParameters-1);
572 theStore.SetInterpolationManager(aMan); // Store interpolates f(costh)
574 G4int aCounter = 0;
575 for (G4int j=1; j<nAngularParameters; j+=2) {
576 theStore.SetX(aCounter, theAngular[it].GetValue(j));
577 theStore.SetY(aCounter,
578 theInt.Interpolate(currentScheme, random,
579 running[it-1]/running[nEnergies-1],
580 running[it]/running[nEnergies-1],
581 theAngular[it-1].GetValue(j+1),
582 theAngular[it].GetValue(j+1) ) );
583 aCounter++;
584 }
585 cosTh = theStore.Sample();
586 }
587
588 } else {
589 G4double x1 = running[it-1]/running[nEnergies-1];
590 G4double x2 = running[it]/running[nEnergies-1];
591 G4double y1 = theAngular[it-1].GetLabel();
592 G4double y2 = theAngular[it].GetLabel();
594 random,x1,x2,y1,y2);
595 G4ParticleHPVector theBuff1;
596 G4ParticleHPVector theBuff2;
598 aMan.Init(angularRep-10, nAngularParameters-1);
599
600 G4int j;
601 for (i = 0, j = 1; i < nAngularParameters; i++, j+=2) {
602 theBuff1.SetX(i, theAngular[it-1].GetValue(j));
603 theBuff1.SetY(i, theAngular[it-1].GetValue(j+1));
604 theBuff2.SetX(i, theAngular[it].GetValue(j));
605 theBuff2.SetY(i, theAngular[it].GetValue(j+1));
606 }
607
608 G4ParticleHPVector theStore;
609 theStore.SetInterpolationManager(aMan); // Store interpolates f(costh)
610 x1 = y1;
611 x2 = y2;
612 G4double x, y;
613 for (i = 0; i < theBuff1.GetVectorLength(); i++) {
614 x = theBuff1.GetX(i); // costh binning identical
615 y1 = theBuff1.GetY(i);
616 y2 = theBuff2.GetY(i);
618 fsEnergy, theAngular[it-1].GetLabel(),
619 theAngular[it].GetLabel(), y1, y2);
620 theStore.SetX(i, x);
621 theStore.SetY(i, y);
622 }
623 cosTh = theStore.Sample();
624 }
625 delete [] running;
626
627 } else {
628 throw G4HadronicException(__FILE__, __LINE__,
629 "G4ParticleHPContAngularPar::Sample: Unknown angular representation");
630 }
631
632 result->SetKineticEnergy(fsEnergy);
634 G4double theta = std::acos(cosTh);
635 G4double sinth = std::sin(theta);
636 G4double mtot = result->GetTotalMomentum();
637 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
638 result->SetMomentum(tempVector);
639 return result;
640}
G4InterpolationScheme
static constexpr double twopi
Definition: G4SIunits.hh:56
const G4int Z[17]
const G4double A[17]
#define G4UniformRand()
Definition: Randomize.hh:52
static G4Alpha * Alpha()
Definition: G4Alpha.cc:88
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:93
static G4Electron * Electron()
Definition: G4Electron.cc:93
static G4Gamma * Gamma()
Definition: G4Gamma.cc:85
static G4He3 * He3()
Definition: G4He3.cc:93
void Init(G4int aScheme, G4int aRange)
G4InterpolationScheme GetInverseScheme(G4int index)
static G4IonTable * GetIonTable()
Definition: G4IonTable.cc:170
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103
static G4double GetNuclearMass(const G4double A, const G4double Z)
G4double GetPDGCharge() const
G4double GetWeightedBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double GetBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
void SetY(G4int i, G4double x)
void SetX(G4int i, G4double e)
void SetInterpolationManager(const G4InterpolationManager &aManager)
G4double GetY(G4double x)
G4double GetX(G4int i) const
G4int GetVectorLength() const
static G4Positron * Positron()
Definition: G4Positron.cc:93
static G4Proton * Proton()
Definition: G4Proton.cc:92
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4double GetTotalMomentum() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetKineticEnergy(const G4double en)
G4double GetMass() const
static G4Triton * Triton()
Definition: G4Triton.cc:93
float amu_c2
Definition: hepunit.py:276

References A, adjustResult, G4Alpha::Alpha(), source.hepunit::amu_c2, cacheInit(), G4Deuteron::Deuteron(), e1, e2, G4Electron::Electron(), eV, fCache, G4cout, G4endl, G4UniformRand, G4Gamma::Gamma(), G4ParticleHPInterpolator::GetBinIntegral(), G4ParticleHPManager::GetInstance(), G4InterpolationManager::GetInverseScheme(), G4IonTable::GetIonTable(), G4ParticleHPList::GetLabel(), G4ReactionProduct::GetMass(), G4NucleiProperties::GetNuclearMass(), G4ParticleDefinition::GetPDGCharge(), G4ParticleDefinition::GetPDGMass(), G4InterpolationManager::GetScheme(), G4ReactionProduct::GetTotalMomentum(), G4ParticleHPList::GetValue(), G4ParticleHPVector::GetVectorLength(), G4ParticleHPInterpolator::GetWeightedBinIntegral(), G4ParticleHPVector::GetX(), G4ParticleHPVector::GetY(), G4He3::He3(), G4InterpolationManager::Init(), G4ParticleHPLegendreStore::Init(), G4ParticleHPInterpolator::Interpolate(), G4INCL::Math::max(), G4INCL::Math::min(), nAngularParameters, nDiscreteEnergies, nEnergies, G4Neutron::Neutron(), G4Positron::Positron(), G4Proton::Proton(), G4ParticleHPVector::Sample(), G4ParticleHPKallbachMannSyst::Sample(), G4ParticleHPLegendreStore::SampleMax(), G4ParticleHPLegendreStore::SetCoeff(), G4ReactionProduct::SetDefinition(), G4ParticleHPVector::SetInterpolationManager(), G4ReactionProduct::SetKineticEnergy(), G4ParticleHPLegendreStore::SetManager(), G4ReactionProduct::SetMomentum(), G4ParticleHPVector::SetX(), G4ParticleHPVector::SetY(), theAngular, theInt, theManager, theProjectile, G4Triton::Triton(), twopi, and Z.

Referenced by G4ParticleHPContEnergyAngular::Sample().

◆ SetInterpolation()

void G4ParticleHPContAngularPar::SetInterpolation ( G4int  theInterpolation)
inline

Definition at line 143 of file G4ParticleHPContAngularPar.hh.

144 {
145 theManager.Init(theInterpolation, nEnergies); // one range only
146 }

References G4InterpolationManager::Init(), nEnergies, and theManager.

Referenced by G4ParticleHPContEnergyAngular::Init(), and G4ParticleHPContEnergyAngular::Sample().

◆ SetPrimary()

void G4ParticleHPContAngularPar::SetPrimary ( G4ReactionProduct aPrimary)
inline

Definition at line 128 of file G4ParticleHPContAngularPar.hh.

129 {
130 fCache.Get()->thePrimary = aPrimary;
131 }

References fCache.

Referenced by G4ParticleHPContEnergyAngular::Sample().

◆ SetTarget()

void G4ParticleHPContAngularPar::SetTarget ( G4ReactionProduct aTarget)
inline

Definition at line 133 of file G4ParticleHPContAngularPar.hh.

134 {
135 fCache.Get()->theTarget = aTarget;
136 }

References fCache.

Referenced by G4ParticleHPContEnergyAngular::Sample().

◆ SetTargetCode()

void G4ParticleHPContAngularPar::SetTargetCode ( G4double  aTargetCode)
inline

Definition at line 138 of file G4ParticleHPContAngularPar.hh.

139 {
140 fCache.Get()->theTargetCode = aTargetCode;
141 }

References fCache.

Referenced by G4ParticleHPContEnergyAngular::Sample().

Field Documentation

◆ adjustResult

G4bool G4ParticleHPContAngularPar::adjustResult
private

Definition at line 243 of file G4ParticleHPContAngularPar.hh.

Referenced by G4ParticleHPContAngularPar(), Init(), and Sample().

◆ fCache

G4Cache< toBeCached* > G4ParticleHPContAngularPar::fCache
private

◆ nAngularParameters

G4int G4ParticleHPContAngularPar::nAngularParameters
private

◆ nDiscreteEnergies

G4int G4ParticleHPContAngularPar::nDiscreteEnergies
private

◆ nEnergies

G4int G4ParticleHPContAngularPar::nEnergies
private

◆ theAngular

G4ParticleHPList* G4ParticleHPContAngularPar::theAngular
private

◆ theDiscreteEnergies

std::set<G4double> G4ParticleHPContAngularPar::theDiscreteEnergies
private

◆ theDiscreteEnergiesOwn

std::map<G4double,G4int> G4ParticleHPContAngularPar::theDiscreteEnergiesOwn
private

◆ theEnergiesTransformed

std::set<G4double> G4ParticleHPContAngularPar::theEnergiesTransformed
private

◆ theEnergy

G4double G4ParticleHPContAngularPar::theEnergy
private

◆ theInt

G4ParticleHPInterpolator G4ParticleHPContAngularPar::theInt
private

◆ theManager

G4InterpolationManager G4ParticleHPContAngularPar::theManager
private

◆ theMaxEner

G4double G4ParticleHPContAngularPar::theMaxEner
private

◆ theMinEner

G4double G4ParticleHPContAngularPar::theMinEner
private

◆ theProjectile

G4ParticleDefinition* G4ParticleHPContAngularPar::theProjectile
private

Definition at line 241 of file G4ParticleHPContAngularPar.hh.

Referenced by G4ParticleHPContAngularPar(), Init(), and Sample().


The documentation for this class was generated from the following files: