/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Attributes
DsG4NNDCCaptureGammas Class Reference

#include <DsG4NNDCCaptureGammas.h>

List of all members.

Public Member Functions

 DsG4NNDCCaptureGammas ()
 ~DsG4NNDCCaptureGammas ()
void Init (int A, int Z)
G4ReactionProductVector * GetGammas ()
std::vector< double > GetEnergy ()
bool hasData ()

Private Attributes

bool m_hasData
std::vector< double > m_probabilities
std::vector< std::vector
< double > > 
m_gammaEnergies

Detailed Description

Definition at line 15 of file DsG4NNDCCaptureGammas.h.


Constructor & Destructor Documentation

DsG4NNDCCaptureGammas::DsG4NNDCCaptureGammas ( )

Definition at line 23 of file DsG4NNDCCaptureGammas.cc.

                                             :
  m_hasData(false)
{
}
DsG4NNDCCaptureGammas::~DsG4NNDCCaptureGammas ( )

Definition at line 28 of file DsG4NNDCCaptureGammas.cc.

{
}

Member Function Documentation

void DsG4NNDCCaptureGammas::Init ( int  A,
int  Z 
)

Definition at line 32 of file DsG4NNDCCaptureGammas.cc.

{
   // Gamma files should be placed in $DAYA_DATA_DIR directory.

   // To use the old spectra from nuclear data tables for Gd (gdcap_spec.root)
   // generated with unbiased sampling (see Doc-5750),
   // set the following boolean to true
   // (see also 'useNNDC_GdCapture' in DsG4NeutronHPCapture.cc)
   bool useOldNdtGdSpectra = true; 

   // define a map for Z
   map<int, string> elementName;
   elementName[64] = "Gd";
   elementName[26] = "Fe";
   elementName[28] = "Ni";
   elementName[14] = "Si";
   elementName[15] = "P";
   elementName[25] = "Mn";
   elementName[16] = "S";
   elementName[24] = "Cr";
   elementName[8] = "O";
   elementName[7] = "N";
   elementName[6] = "C";

   string fileName;
   fileName.append(elementName[Z]);
   ostringstream strA;
   strA << A;
   fileName.append(strA.str());
   if( Z == 64 && useOldNdtGdSpectra){
       //fileName.append("NDT");
       fileName.append("G4");
   }
   fileName.append("NeutronCaptureGammas.txt");

   const char* prefix = getenv("DAYA_DATA_DIR");
   if(prefix) {
       if(strlen(prefix)>0) { 
           std::string newname = prefix;
           newname += "/";
           newname += fileName;
           fileName = newname;
       }
   }

   ifstream file(fileName.c_str()); 

   //read data file
   string line;
   double totalProbability = 0;
   while(getline(file,line))
   {
       stringstream streamLine(line);
       double probability = 0.0;
       int numGammas = 0;
       if(streamLine.peek() != '#')
       {
           streamLine >> probability >> numGammas;
           m_probabilities.push_back(probability);
           totalProbability += probability;
           vector<double> gammas;
           for(int i = 1; i <= numGammas; i++)
           {
               double gammaEnergy = 0.0;
               streamLine >> gammaEnergy;
               gammas.push_back(gammaEnergy/1000.0); // Convert to MeV
           }
           m_gammaEnergies.push_back(gammas);
       }
   }
   file.close();

   if( m_probabilities.size() > 0){
     std::cout << "Loaded " << m_probabilities.size() 
               << " gamma decay combinations from file " << fileName << endl;
     std::cout << "Rescaling all gamma lines by total probability: " 
               << totalProbability << endl;
     for(unsigned int i=0; i<m_probabilities.size(); i++){
       m_probabilities[i] /= totalProbability;
     }
     m_hasData = true;
   }else{
     std::cout << "DsG4NNDCCaptureGammas  WARNING: No data loaded for isotope "
               << "A=" << A << " Z=" << Z 
               << ".  Cross section will be set to zero."
               << endl;
     m_hasData = false;
   }
}
G4ReactionProductVector * DsG4NNDCCaptureGammas::GetGammas ( )

Definition at line 122 of file DsG4NNDCCaptureGammas.cc.

{
   G4ReactionProductVector* theGammas = new G4ReactionProductVector;
   vector<double> energy = GetEnergy();
   for(unsigned int i=0; i<energy.size(); i++) {

       G4ReactionProduct* theOne = new G4ReactionProduct;
       theOne->SetDefinition( G4Gamma::Gamma() );

       // Get the gammas direction. 
       // Isotropic emission.
       G4double costheta = 2.*G4UniformRand()-1;
       G4double theta = acos(costheta);
       G4double phi = twopi*G4UniformRand();
       G4double sinth = sin(theta);
       theOne->SetTotalEnergy( energy[i] );
       G4ThreeVector temp(energy[i]*sinth*cos(phi), 
                          energy[i]*sinth*sin(phi),
                          energy[i]*cos(theta) );
       theOne->SetMomentum( temp ) ;
       theGammas->push_back(theOne);
   }
   return theGammas;
}
vector< double > DsG4NNDCCaptureGammas::GetEnergy ( )

Definition at line 147 of file DsG4NNDCCaptureGammas.cc.

{
   //pick a decay scheme
   G4double random = G4UniformRand();
   double sum = 0.0;
   unsigned int i = 0;
   while(i < m_probabilities.size() )
   {
       sum += m_probabilities[i];
       if(sum >= random)
       {
         // cout << "Returning gamma branch " << i << endl;
           return m_gammaEnergies[i];
       }
       i++;
   }
   std::cerr << "Failed to generate gammas!" << endl;
   return vector<double>(0);
}
bool DsG4NNDCCaptureGammas::hasData ( ) [inline]

Definition at line 24 of file DsG4NNDCCaptureGammas.h.

{ return m_hasData; }

Member Data Documentation

Definition at line 28 of file DsG4NNDCCaptureGammas.h.

std::vector<double> DsG4NNDCCaptureGammas::m_probabilities [private]

Definition at line 29 of file DsG4NNDCCaptureGammas.h.

std::vector< std::vector<double> > DsG4NNDCCaptureGammas::m_gammaEnergies [private]

Definition at line 30 of file DsG4NNDCCaptureGammas.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:17:58 for DetSim by doxygen 1.7.4