G4FluoData Class Reference

#include <G4FluoData.hh>


Public Member Functions

 G4FluoData ()
 ~G4FluoData ()
size_t NumberOfVacancies () const
G4int VacancyId (G4int vacancyIndex) const
size_t NumberOfTransitions (G4int vacancyIndex) const
G4int StartShellId (G4int initIndex, G4int vacancyIndex) const
G4double StartShellEnergy (G4int initIndex, G4int vacancyIndex) const
G4double StartShellProb (G4int initIndex, G4int vacancyIndex) const
void LoadData (G4int Z)
void PrintData ()


Detailed Description

Definition at line 52 of file G4FluoData.hh.


Constructor & Destructor Documentation

G4FluoData::G4FluoData (  ) 

Definition at line 44 of file G4FluoData.cc.

00045 {
00046   numberOfVacancies=0; 
00047 }

G4FluoData::~G4FluoData (  ) 

Definition at line 49 of file G4FluoData.cc.

00050 { 
00051  std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
00052 
00053   for (pos = idMap.begin(); pos != idMap.end(); ++pos)
00054     {
00055       G4DataVector* dataSet = (*pos).second;
00056       delete dataSet;
00057     }
00058   for (pos = energyMap.begin(); pos != energyMap.end(); ++pos)
00059     {
00060       G4DataVector* dataSet = (*pos).second;
00061       delete dataSet;
00062     }
00063  for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos)
00064     {
00065       G4DataVector* dataSet = (*pos).second;
00066       delete dataSet;
00067     }
00068 }


Member Function Documentation

void G4FluoData::LoadData ( G4int  Z  ) 

Definition at line 188 of file G4FluoData.cc.

References FatalException, G4Exception(), and CLHEP::detail::n.

00189 { 
00190   // Build the complete string identifying the file with the data set
00191   
00192   std::ostringstream ost;
00193   if(Z != 0){
00194     ost << "fl-tr-pr-"<< Z << ".dat";
00195   }
00196   else{
00197     ost << "fl-tr-pr-"<<".dat"; 
00198   }
00199   G4String name(ost.str());
00200   
00201   char* path = getenv("G4LEDATA");
00202   if (!path)
00203     { 
00204       G4String excep("G4FluoData::LoadData()");
00205       G4Exception(excep,"em0006",FatalException,"Please set G4LEDATA");
00206       return;
00207     }
00208   
00209   G4String pathString(path);
00210   G4String fluor("/fluor/");
00211   G4String dirFile = pathString + fluor + name;
00212   std::ifstream file(dirFile);
00213   std::filebuf* lsdp = file.rdbuf();
00214   
00215   if (! (lsdp->is_open()) )
00216     {
00217       G4String excep = "G4FluoData::LoadData()";
00218       G4String msg = "data file: " + dirFile + " not found";
00219       G4Exception(excep, "em0003",FatalException, msg );
00220       return;
00221     }
00222   
00223   G4double a = 0;
00224   G4int k = 1;
00225   G4int sLocal = 0;
00226   
00227   G4int vacIndex = 0;
00228   G4DataVector* initIds = new G4DataVector;
00229   G4DataVector* transEnergies = new G4DataVector;
00230   G4DataVector* transProbabilities = new G4DataVector;
00231   
00232   do {
00233     file >> a;
00234     G4int nColumns = 3;
00235     if (a == -1)
00236       {
00237         if (sLocal == 0)
00238           {
00239             // End of a shell data set
00240             idMap[vacIndex] = initIds;
00241             energyMap[vacIndex] = transEnergies;
00242             probabilityMap[vacIndex] = transProbabilities;
00243             //      G4double size=transProbabilities->size();
00244             G4int n = initIds->size();
00245             
00246             nInitShells.push_back(n);
00247             numberOfVacancies++;
00248             // Start of new shell data set
00249             initIds = new G4DataVector;
00250             transEnergies = new G4DataVector;
00251             transProbabilities = new G4DataVector;
00252             vacIndex++; 
00253           }      
00254         sLocal++;
00255         if (sLocal == nColumns)
00256           {
00257             sLocal = 0;
00258           }
00259       }
00260     // moved to the end in order to avoid possible leak
00261     /*    else if (a == -2)
00262       {
00263         // End of file; delete the empty vectors created 
00264         //when encountering the last -1 -1 row
00265         delete initIds;
00266         delete transEnergies;
00267         delete transProbabilities;
00268         }*/ 
00269     else
00270       {
00271         
00272         if(k%nColumns == 2)
00273           {      
00274             // 2nd column is transition  probabilities
00275 
00276            if (a != -1) transProbabilities->push_back(a);
00277             
00278             k++;
00279           }
00280         else if (k%nColumns == 1)
00281           {
00282             // 1st column is shell id
00283             // if this is the first data of the shell, all the colums are equal 
00284             // to the shell Id; so we skip the next colums ang go to the next row
00285             if(initIds->size() == 0) {
00286               if (a != -1) initIds->push_back((G4int)a);
00287               file >> a;
00288               file >> a;
00289               k=k+2;
00290             } 
00291             else{ 
00292               if (a != -1) initIds->push_back(a);
00293             }
00294             k++;    
00295           }
00296         else if (k%nColumns == 0)
00297 
00298           {//third column is transition energies
00299 
00300             if (a != -1) 
00301               {G4double e = a * MeV;
00302               transEnergies->push_back(e);}
00303            
00304             k=1;
00305           }
00306       }
00307   } 
00308   while (a != -2); // end of file
00309   file.close();    
00310   delete initIds;
00311   delete transEnergies;
00312   delete transProbabilities;
00313 }

size_t G4FluoData::NumberOfTransitions ( G4int  vacancyIndex  )  const

Definition at line 93 of file G4FluoData.cc.

References G4Exception(), JustWarning, and CLHEP::detail::n.

Referenced by PrintData().

00094 {
00095   G4int n = 0;
00096   if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
00097     {
00098       G4Exception("G4FluoData::NumberOfTransitions()","de0002",JustWarning,"vacancyIndex outside boundaries, energy deposited locally");
00099       return 0;
00100     }
00101   else
00102     {
00103       n = nInitShells[vacancyIndex]-1;
00104       //-1 is necessary because the elements of the vector nInitShells
00105       //include also the vacancy shell:
00106       // -1 subtracts this last one
00107   }
00108  return n;
00109 }

size_t G4FluoData::NumberOfVacancies (  )  const

Definition at line 70 of file G4FluoData.cc.

00071 {
00072   return numberOfVacancies;
00073 }

void G4FluoData::PrintData (  ) 

Definition at line 316 of file G4FluoData.cc.

References G4cout, G4endl, NumberOfTransitions(), StartShellEnergy(), StartShellId(), and StartShellProb().

00317 {
00318   
00319   for (G4int i = 0; i <numberOfVacancies; i++)
00320     {
00321       G4cout << "---- TransitionData for the vacancy nb "
00322              <<i
00323              <<" ----- "
00324              <<G4endl;
00325       
00326       for (size_t k = 0; k<NumberOfTransitions(i); k++)
00327         { 
00328           G4int id = StartShellId(k,i);
00329         // let's start from 1 because the first (index = 0) element of the vector
00330         // is the id of the intial vacancy
00331           G4double e = StartShellEnergy(k,i) /MeV;
00332           G4double p = StartShellProb(k,i); 
00333           G4cout << k <<") Shell id: " << id <<G4endl;
00334           G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
00335           G4cout   << " - Transition probability = " << p <<G4endl;
00336           
00337         }
00338       G4cout << "-------------------------------------------------" 
00339              << G4endl;
00340     }
00341 }

G4double G4FluoData::StartShellEnergy ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 137 of file G4FluoData.cc.

References FatalErrorInArgument, G4Exception(), and CLHEP::detail::n.

Referenced by PrintData().

00138 {
00139   G4double n = -1;
00140   
00141   if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
00142     {G4Exception("G4FluoData::StartShellEnergy()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");}
00143  else
00144    {
00145      std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
00146      
00147      pos = energyMap.find(vacancyIndex);
00148      
00149      G4DataVector dataSet = *((*pos).second);
00150      
00151      G4int nData = dataSet.size();
00152      if (initIndex >= 0 && initIndex < nData)
00153        {
00154          n =  dataSet[initIndex];
00155          
00156        }
00157    }
00158   return n;
00159 }

G4int G4FluoData::StartShellId ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 110 of file G4FluoData.cc.

References FatalErrorInArgument, G4Exception(), and CLHEP::detail::n.

Referenced by PrintData().

00111 {
00112  G4int n = -1;
00113 
00114  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
00115     {G4Exception("G4FluoData::StartShellId()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");
00116     }
00117  else
00118    {
00119      std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
00120     
00121      pos = idMap.find(vacancyIndex);
00122      
00123      G4DataVector dataSet = *((*pos).second);
00124    
00125      G4int nData = dataSet.size();
00126      //The first Element of idMap's dataSets is the original shell of the vacancy, 
00127      //so we must start from the first element of dataSet
00128  if (initIndex >= 0 && initIndex < nData)
00129             {
00130               n =  (G4int) dataSet[initIndex+1];
00131             
00132             }
00133    }
00134  return n;
00135 }

G4double G4FluoData::StartShellProb ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 161 of file G4FluoData.cc.

References G4Exception(), JustWarning, and CLHEP::detail::n.

Referenced by PrintData().

00162 {
00163   G4double n = -1;
00164 
00165   if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
00166     {
00167       G4Exception("G4FluoData::StartShellEnergy()","de0002",JustWarning,"vacancyIndex outside boundaries, energy deposited locally");
00168       return 0;
00169 }
00170   else
00171     {
00172      std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
00173      
00174      pos = probabilityMap.find(vacancyIndex);
00175      
00176      G4DataVector dataSet = *((*pos).second);
00177      
00178      G4int nData = dataSet.size();
00179      if (initIndex >= 0 && initIndex < nData)
00180        {
00181          n =  dataSet[initIndex];
00182          
00183        }
00184     }
00185   return n;
00186 }

G4int G4FluoData::VacancyId ( G4int  vacancyIndex  )  const

Definition at line 75 of file G4FluoData.cc.

References FatalErrorInArgument, G4Exception(), and CLHEP::detail::n.

00076 {
00077   G4int n = -1;
00078   if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
00079     {G4Exception("G4FluoData::vacancyId()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");}
00080   else
00081     {
00082       std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
00083       pos = idMap.find(vacancyIndex);
00084       if (pos!= idMap.end())
00085         { G4DataVector dataSet = (*(*pos).second);
00086         n = (G4int) dataSet[0];
00087         
00088         }
00089     }
00090   return n;
00091 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:00 2013 for Geant4 by  doxygen 1.4.7