Ignore:
Timestamp:
May 28, 2009, 4:26:57 PM (15 years ago)
Author:
garnier
Message:

maj sur la beta de geant 4.9.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/utils/src/G4EmElementSelector.cc

    r1007 r1055  
    2424// ********************************************************************
    2525//
    26 // $Id: G4EmElementSelector.cc,v 1.4 2008/08/21 18:53:32 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-02 $
     26// $Id: G4EmElementSelector.cc,v 1.10 2009/05/26 16:59:35 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-beta-cand-01 $
    2828//
    2929// -------------------------------------------------------------------
     
    5858                                         G4double emin,
    5959                                         G4double emax,
    60                                          G4bool spline):
     60                                         G4bool /*spline*/):
    6161  model(mod), material(mat), nbins(bins), cutEnergy(-1.0),
    6262  lowEnergy(emin), highEnergy(emax)
     
    6565  nElmMinusOne = n - 1;
    6666  theElementVector = material->GetElementVector();
     67  element = (*theElementVector)[0];
    6768  if(nElmMinusOne > 0) {
    68     for(G4int i=0; i<nElmMinusOne; i++) {
     69    xSections.reserve(n);
     70    for(G4int i=0; i<n; i++) {
    6971      G4PhysicsLogVector* v = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins);
    70       v->SetSpline(spline);
     72      //v->SetSpline(spline);
    7173      xSections.push_back(v);
    7274    }
     
    8082{
    8183  if(nElmMinusOne > 0) {
    82     for(G4int i=0; i<nElmMinusOne; i++) {
     84    for(G4int i=0; i<=nElmMinusOne; i++) {
    8385      delete xSections[i];
    8486    }
     
    101103
    102104  G4int i;
    103   G4int n = nElmMinusOne + 1;
    104   G4double* xsec = new G4double[n]; 
    105105
    106106  // loop over bins
     
    110110    cross = 0.0;
    111111    //G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl;
    112     for (i=0; i<n; i++) {
     112    for (i=0; i<=nElmMinusOne; i++) {
    113113      cross += theAtomNumDensityVector[i]*     
    114114        model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e,
    115115                                          cutEnergy, e);
    116       xsec[i] = cross;
    117     }
    118     if(DBL_MIN >= cross) cross = 1.0;
    119     // normalise cross section sum
    120     for (i=0; i<nElmMinusOne; i++) {
    121       xSections[i]->PutValue(j, xsec[i]/cross);
    122       //G4cout << "i= " << i << " xs= " << xsec[i]/cross << G4endl;
     116      xSections[i]->PutValue(j, cross);
    123117    }
    124118  }
    125   delete [] xsec;
     119
     120  // xSections start from null, so use probabilities from the next bin
     121  if(DBL_MIN >= (*xSections[nElmMinusOne])[0]) {
     122    for (i=0; i<=nElmMinusOne; i++) {
     123      xSections[i]->PutValue(0, (*xSections[i])[1]);
     124    }
     125  }
     126  // xSections ends with null, so use probabilities from the previous bin
     127  if(DBL_MIN >= (*xSections[nElmMinusOne])[nbins-1]) {
     128    for (i=0; i<=nElmMinusOne; i++) {
     129      xSections[i]->PutValue(nbins-1, (*xSections[i])[nbins-2]);
     130    }
     131  }
     132  // perform normalization
     133  for(G4int j=0; j<nbins; j++) {
     134    cross = (*xSections[nElmMinusOne])[j];
     135    // only for positive X-section
     136    if(cross > DBL_MIN) {
     137      for (i=0; i<nElmMinusOne; i++) {
     138        xSections[i]->PutValue(j, (*xSections[i])[j]/cross);
     139      }
     140    }
     141  }
    126142}
    127143
     
    139155    }
    140156  } 
    141   G4cout << "Last Element in element vector"
     157  G4cout << "Last Element in element vector "
    142158         << (*theElementVector)[nElmMinusOne]->GetName()
    143159         << G4endl;
Note: See TracChangeset for help on using the changeset viewer.