G4CrossSectionPatch.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // -------------------------------------------------------------------
00028 //      GEANT4 Class file
00029 //
00030 //      For information related to this code contact:
00031 //
00032 //      File name:     G4CrossSectionPatch
00033 //
00034 //      Author:        
00035 // 
00036 //      Creation date: 15 April 1999
00037 //
00038 //      Modifications: 
00039 //      
00040 // -------------------------------------------------------------------
00041 
00042 #include "globals.hh"
00043 #include "G4CrossSectionPatch.hh"
00044 #include "G4VCrossSectionSource.hh"
00045 #include "G4KineticTrack.hh"
00046 #include "G4CrossSectionVector.hh"
00047 
00048 G4CrossSectionPatch::G4CrossSectionPatch()
00049 { }
00050 
00051 
00052 G4CrossSectionPatch::~G4CrossSectionPatch()
00053 { }
00054 
00055 
00056 G4bool G4CrossSectionPatch::operator==(const G4CrossSectionPatch &right) const
00057 {
00058   return (this == (G4CrossSectionPatch*) &right);
00059 }
00060 
00061 
00062 G4bool G4CrossSectionPatch::operator!=(const G4CrossSectionPatch &right) const
00063 {
00064   return (this != (G4CrossSectionPatch*) &right);
00065 }
00066 
00067 
00068 G4double G4CrossSectionPatch::CrossSection(const G4KineticTrack& trk1, 
00069                                            const G4KineticTrack& trk2) const
00070 {
00071   // The cross section is provided by one of the components, according to their energy
00072   // validity range
00073 
00074   G4double crossSection = 0.;
00075   G4double ecm = (trk1.Get4Momentum() + trk2.Get4Momentum()).mag();
00076 
00077   const G4CrossSectionVector* components = GetComponents();
00078   if (components != 0)
00079     {
00080       G4int nComponents = this->GetComponents()->size();
00081 //      G4int nValid = 0;
00082       
00083       G4int i;
00084       for (i=0; i<nComponents; i++)
00085         {
00086           G4CrossSectionSourcePtr componentPtr = (*components)[i];
00087           G4VCrossSectionSource* component = componentPtr();
00088           if (component->IsValid(ecm))
00089             {
00090               crossSection = component->CrossSection(trk1,trk2);
00091             }
00092           else if (i < (nComponents - 1) )
00093             {
00094               G4CrossSectionSourcePtr nextPtr = (*components)[i+1];
00095               G4VCrossSectionSource* next = nextPtr();
00096               if (ecm > component->HighLimit() && ecm < next->LowLimit())
00097                 {
00098                   // Merge cross-sections in transition region between two validity ranges
00099                   crossSection = Transition(trk1,trk2,component,next);
00100                 }
00101             }
00102         }
00103     }
00104 
00105   return crossSection;
00106 }
00107 
00108 
00109 G4bool G4CrossSectionPatch::IsValid(G4double e) const
00110 {
00111   // The Patch is valid if any of its components are valid
00112   G4bool answer = false;
00113   const G4CrossSectionVector* components = GetComponents();
00114   if (components != 0)
00115     {
00116       G4int n = components->size();
00117       G4int i;
00118       for (i=0; i<n; i++)
00119         {
00120           G4CrossSectionSourcePtr componentPtr = (*components)[i];
00121           G4VCrossSectionSource* component = componentPtr();
00122           if (component->IsValid(e)) 
00123             {
00124               answer = true;
00125               break;
00126             }
00127         }
00128     }
00129   return answer;
00130 }
00131 
00132 
00133 G4double G4CrossSectionPatch::Transition(const G4KineticTrack& trk1, const G4KineticTrack& trk2,
00134                                               const G4VCrossSectionSource* comp1, 
00135                                               const G4VCrossSectionSource* comp2) const
00136 {
00137   //Merge two cross sections in the transition region between their validity ranges
00138 
00139   G4double crossSection = 0.;
00140 
00141   G4double ecm = (trk1.Get4Momentum() + trk2.Get4Momentum()).mag();
00142   G4double sigma1 = comp1->CrossSection(trk1,trk2);
00143   G4double sigma2 = comp2->CrossSection(trk1,trk2);
00144   G4double denom = comp2->LowLimit() - comp1->HighLimit();
00145   G4double diff = ecm - comp1->HighLimit();
00146   if (denom > 0. && diff > 0.)
00147     {
00148       G4double ratio = diff / denom;
00149       crossSection = (1.- ratio) * sigma1 + ratio * sigma2;
00150     }
00151 
00152   return crossSection;
00153 }
00154 
00155 
00156 G4double G4CrossSectionPatch::Transition(G4double ecm, 
00157                                          G4double sigma1, G4double sigma2, 
00158                                          G4double e1, G4double e2) const
00159 {
00160   //Merge two cross sections in the transition region between their validity ranges
00161 
00162   G4double crossSection = 0.;
00163   
00164   G4double denom = e2 - e1;
00165   G4double diff = ecm - e1;
00166   if (denom > 0. && diff > 0.)
00167     {
00168       G4double ratio = diff / denom;
00169       crossSection = (1.- ratio) * sigma1 + ratio * sigma2;
00170     }
00171 
00172   return crossSection;
00173 }
00174 

Generated on Mon May 27 17:47:58 2013 for Geant4 by  doxygen 1.4.7