G4Physics2DVector.hh

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: not supported by cvs2svn $
00029 //
00030 // 
00031 //---------------------------------------------------------------
00032 //      GEANT 4 class header file
00033 //
00034 //  G4Physics2DVector.hh 
00035 //
00036 //  Class description:
00037 //
00038 //  A 2-dimentional vector with linear interpolation.
00039 
00040 //  Author:        Vladimir Ivanchenko
00041 //
00042 //  Creation date: 25.09.2011
00043 //---------------------------------------------------------------
00044 
00045 #ifndef G4Physics2DVector_h
00046 #define G4Physics2DVector_h 1
00047 
00048 #include "globals.hh"
00049 #include "G4ios.hh"
00050 
00051 #include <iostream>
00052 #include <fstream>
00053 #include <vector>
00054 
00055 #include "G4Physics2DVectorCache.hh"
00056 #include "G4PhysicsVectorType.hh"
00057 
00058 typedef std::vector<G4double> G4PV2DDataVector;
00059 
00060 class G4Physics2DVector 
00061 {
00062 public:  // with description
00063 
00064   G4Physics2DVector();
00065   G4Physics2DVector(size_t nx, size_t ny);
00066   // constructors
00067 
00068   G4Physics2DVector(const G4Physics2DVector&);
00069   G4Physics2DVector& operator=(const G4Physics2DVector&);
00070   // Copy constructor and assignment operator.
00071 
00072   ~G4Physics2DVector();
00073   // destructor
00074 
00075   inline G4double Value(G4double x, G4double y);
00076   // Main method to interpolate 2D vector
00077 
00078   inline void PutX(size_t idx, G4double value);
00079   inline void PutY(size_t idy, G4double value);
00080   inline void PutValue(size_t idx, size_t idy, G4double value);
00081   void PutVectors(const std::vector<G4double>& vecX,
00082                   const std::vector<G4double>& vecY);
00083   // Methods to fill vector 
00084   // Take note that the 'index' starts from '0'.
00085 
00086   void ScaleVector(G4double factor);
00087   // Scale all values of the vector by factor, 
00088   // This method may be applied 
00089   // for example after Retrieve a vector from an external file to 
00090   // convert values into Geant4 units
00091 
00092   inline G4double GetX(size_t index) const;
00093   inline G4double GetY(size_t index) const;
00094   inline G4double GetValue(size_t idx, size_t idy) const;
00095   // Returns simply the values of the vector by index
00096   // of the energy vector. The boundary check will not be done. 
00097 
00098   inline size_t GetLengthX() const;
00099   inline size_t GetLengthY() const;
00100   // Get the lengths of the vector. 
00101 
00102   inline G4PhysicsVectorType GetType() const;
00103   // Get physics vector type
00104 
00105   inline void SetBicubicInterpolation(G4bool);
00106   // Activate/deactivate bicubic interpolation.
00107 
00108   void Store(std::ofstream& fOut);
00109   G4bool Retrieve(std::ifstream& fIn);
00110   // To store/retrieve persistent data to/from file streams.
00111 
00112   inline G4double GetLastX() const;
00113   inline G4double GetLastY() const;
00114   inline G4double GetLastValue() const;
00115   inline size_t GetLastBinX() const;
00116   inline size_t GetLastBinY() const;
00117   // Get cache values 
00118 
00119   inline void SetVerboseLevel(G4int value);
00120   inline G4int GetVerboseLevel() const;
00121   // Set/Get Verbose level
00122 
00123 protected:
00124 
00125   void PrepareVectors();
00126 
00127   void ClearVectors();
00128 
00129   void CopyData(const G4Physics2DVector& vec);
00130 
00131   void ComputeValue(G4double x, G4double y);
00132   // Main method to interpolate 2D vector 
00133   //   by default by linear interpolation
00134 
00135   void BicubicInterpolation(size_t idx, size_t idy);
00136   // Bicubic interpolation of 2D vector  
00137 
00138   size_t FindBinLocation(G4double z, const G4PV2DDataVector&);
00139   // Main method to local bin
00140 
00141   inline void FindBin(G4double z, const G4PV2DDataVector&, 
00142                         size_t& lastidx);
00143   inline void FindBinLocationX(G4double x);
00144   inline void FindBinLocationY(G4double y);
00145   // Find the bin# in which theEnergy belongs
00146   // Starting from 0 
00147 
00148 private:
00149 
00150   inline G4double DerivativeX(size_t idx, size_t idy, G4double fac);
00151   inline G4double DerivativeY(size_t idx, size_t idy, G4double fac);
00152   inline G4double DerivativeXY(size_t idx, size_t idy, G4double fac);
00153   // computation of derivatives
00154 
00155   G4int operator==(const G4Physics2DVector &right) const ;
00156   G4int operator!=(const G4Physics2DVector &right) const ;
00157 
00158   G4PhysicsVectorType type;   // The type of PhysicsVector (enumerator)    
00159 
00160   size_t numberOfXNodes;
00161   size_t numberOfYNodes;
00162 
00163   G4Physics2DVectorCache*  cache;
00164 
00165   G4PV2DDataVector  xVector;
00166   G4PV2DDataVector  yVector;
00167   std::vector<G4PV2DDataVector*> value;
00168 
00169   G4int  verboseLevel;
00170   G4bool useBicubic;
00171 };
00172 
00173 #include "G4Physics2DVector.icc"
00174 
00175 #endif

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