G4PartialWidthTable.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:     G4PartialWidthTable
00033 //
00034 //      Author:        
00035 // 
00036 //      Creation date: 15 April 1999
00037 //
00038 //      Modifications: 
00039 //      
00040 // -------------------------------------------------------------------
00041 
00042 #include "globals.hh"
00043 #include "G4SystemOfUnits.hh"
00044 #include "G4HadronicException.hh"
00045 #include "G4ios.hh"
00046 #include "G4PartialWidthTable.hh"
00047 #include "G4KineticTrack.hh"
00048 
00049 G4PartialWidthTable::G4PartialWidthTable(const G4double* energies, G4int entries) : nEnergies(entries)
00050 { 
00051   // Fill the vector with tabulated energies
00052   G4int i;
00053   for (i=0; i<entries; i++)
00054     {
00055       G4double e = *(energies + i) * GeV;
00056       energy.push_back(e);
00057     }
00058 }
00059 
00060 
00061 G4PartialWidthTable::~G4PartialWidthTable()
00062 { }
00063 
00064 
00065 G4bool G4PartialWidthTable::operator==(const G4PartialWidthTable &right) const
00066 {
00067   return (this == (G4PartialWidthTable *) &right);
00068 }
00069 
00070 
00071 G4bool G4PartialWidthTable::operator!=(const G4PartialWidthTable &right) const
00072 {
00073   return (this != (G4PartialWidthTable *) &right);
00074 }
00075 
00076 
00077 G4int G4PartialWidthTable::NumberOfChannels() const
00078 {
00079   return widths.size();
00080 }
00081 
00082 
00083 const G4PhysicsVector* G4PartialWidthTable::Width(const G4String& name1, const G4String& name2) const
00084 {
00085   // Returned pointer is not owned by the client
00086   G4int i;
00087   G4PhysicsVector* width = 0;
00088   G4int n = 0;
00089   G4int entries = widths.size();
00090   for (i=0; i<entries; i++)
00091     {
00092       if ( (daughter1[i] == name1 && daughter2[i] == name2) ||
00093            (daughter2[i] == name1 && daughter1[i] == name2) )
00094         {
00095           width = (G4PhysicsVector*) (widths[i]);
00096           n++;
00097         }
00098     }
00099   if (n > 1) throw G4HadronicException(__FILE__, __LINE__, "G4PartialWidthTable::Width - ambiguity");
00100 
00101   return width;
00102 }
00103 
00104 
00105 void G4PartialWidthTable::AddWidths(const G4double* channelWidth, 
00106                                     const G4String& name1, const G4String& name2)
00107 {
00108   G4PhysicsFreeVector* width = new G4PhysicsFreeVector(nEnergies);
00109   G4int i;
00110   for (i=0; i<nEnergies; i++)
00111     {
00112       G4double value = *(channelWidth+ i) * GeV;
00113       G4double e = energy[i];
00114       width->PutValue(i,e,value);
00115     }               
00116 
00117   widths.push_back(width);
00118   daughter1.push_back(name1);
00119   daughter2.push_back(name2);
00120 
00121   return;
00122 }
00123 
00124 
00125 void G4PartialWidthTable::Dump() const
00126 {
00127   G4int entries = widths.size();
00128 
00129   G4int i;
00130   for (i=0; i<entries; i++)
00131     {
00132       G4cout << " Channel " << i  << ": " 
00133            << daughter1[i] << " " << daughter2[i] << G4endl;
00134       G4PhysicsFreeVector* width = widths[i];
00135       G4int j;
00136       for (j=0; j<nEnergies; j++)
00137         {
00138           G4bool dummy = false;
00139           G4double e = energy[i];
00140           G4double w = width->GetValue(e,dummy);
00141           G4cout << j << ") Energy = " << e << ", Width = " << w << G4endl;
00142         }
00143     }
00144   return;
00145 }

Generated on Mon May 27 17:49:15 2013 for Geant4 by  doxygen 1.4.7