G4ProductionCuts.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 // $Id$
00028 // GEANT4 tag $Name: geant4-09-04-ref-00 $
00029 //
00030 //
00031 // --------------------------------------------------------------
00032 //      GEANT 4 class implementation file/  History:
00033 //    18 Sep. 2002, H.Kuirashige : Structure created based on object model
00034 // --------------------------------------------------------------
00035 
00036 #include "G4ProductionCuts.hh"
00037 #include "G4ProductionCutsTable.hh"
00038 #include <iomanip>
00039 
00040 const G4ParticleDefinition* G4ProductionCuts::gammaDef = 0;
00041 const G4ParticleDefinition* G4ProductionCuts::electDef = 0;
00042 const G4ParticleDefinition* G4ProductionCuts::positDef = 0;
00043 const G4ParticleDefinition* G4ProductionCuts::protonDef = 0;
00044 
00045 G4ProductionCuts::G4ProductionCuts() :
00046   isModified(true)
00047 {
00048   for (G4int i=0; i< NumberOfG4CutIndex; i++) {
00049     fRangeCuts.push_back(0.0);
00050   }
00051 }
00052 
00053 G4ProductionCuts::G4ProductionCuts(const G4ProductionCuts& right) 
00054 {
00055   *this = right;
00056 }
00057 
00058 G4ProductionCuts::~G4ProductionCuts()
00059 {
00060   fRangeCuts.clear();
00061 }
00062 
00063 G4ProductionCuts & G4ProductionCuts::operator=(const G4ProductionCuts &right)
00064 {
00065   if (&right==this) return *this;
00066 
00067   for (G4int i=0; i< NumberOfG4CutIndex; i++) {
00068     fRangeCuts[i] = right.fRangeCuts[i];
00069   }
00070   isModified = right.isModified;
00071   return *this;
00072 }
00073 
00074 
00075 
00076 G4int G4ProductionCuts::operator==(const G4ProductionCuts &right) const
00077 {
00078   return (this == &right);
00079 }
00080 
00081 
00082 G4int G4ProductionCuts::operator!=(const G4ProductionCuts &right) const
00083 {
00084   return (this !=  &right);
00085 }
00086 
00087 
00088 G4int  G4ProductionCuts::GetIndex(const G4String& name)
00089 {
00090   static G4String gamma("gamma");
00091   static G4String electron("e-");
00092   static G4String positron("e+");
00093   static G4String proton("proton");
00094   
00095   G4int index;
00096   if       ( name == gamma )        { index =  0; }
00097   else  if ( name == electron )     { index =  1; }
00098   else  if ( name == positron )     { index =  2; }
00099   else  if ( name == proton )       { index =  3; }
00100   else                              { index = -1; }
00101 
00102   return index;
00103 }
00104 
00105 
00106 G4int  G4ProductionCuts::GetIndex(const G4ParticleDefinition* ptcl)
00107 { 
00108   if(!ptcl) return -1;
00109   // In the first call, pointers are set 
00110   if(gammaDef==0  && ptcl->GetParticleName()=="gamma")  { gammaDef = ptcl; }
00111   if(electDef==0  && ptcl->GetParticleName()=="e-")     { electDef = ptcl; }
00112   if(positDef==0  && ptcl->GetParticleName()=="e+")     { positDef = ptcl; }
00113   if(protonDef==0 && ptcl->GetParticleName()=="proton") { protonDef = ptcl; }
00114 
00115   G4int index;
00116   if(ptcl==gammaDef)       { index = 0;  }
00117   else if(ptcl==electDef)  { index = 1;  }
00118   else if(ptcl==positDef)  { index = 2;  }
00119   else if(ptcl==protonDef) { index = 3;  }
00120   else                     { index = -1; }
00121 
00122   return index;
00123 }
00124 
00125 
00126 void  G4ProductionCuts::SetProductionCuts(std::vector<G4double>& cut)
00127 {  
00128   G4int vSize = cut.size();
00129   if (vSize != NumberOfG4CutIndex) {
00130 #ifdef G4VERBOSE
00131     if ( G4ProductionCutsTable::GetProductionCutsTable()->GetVerboseLevel()>1) {
00132       G4cerr << "G4ProductionCuts::SetProductionCuts ";
00133       G4cerr << " The size of given cut value vector [=" << vSize << "]  "
00134              << " is not consitent with number of CutIndex [="  
00135              << NumberOfG4CutIndex << G4endl;
00136     }
00137 #endif
00138     G4Exception( "G4ProductionCuts::SetProductionCuts ",
00139                  "ProcCuts108",
00140                  JustWarning, "Given vector size is inconsitent ");
00141     if (NumberOfG4CutIndex<vSize) vSize = NumberOfG4CutIndex;
00142   }
00143   for(G4int i = 0; (i<vSize ); i++) {
00144     fRangeCuts[i] = cut[i];
00145   }
00146   isModified = true;
00147 }

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