Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4MCCIndexConversionTable.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4MCCIndexConversionTable
0027 //
0028 // Class description:
0029 //
0030 // G4MCCIndexConversionTable is used by G4ProductionTable 
0031 // when the cut table is retrieved from the file. 
0032 // An index pointing to a Material-Cut-Couple can be different 
0033 // from the index pointing to the same MCC in the file. This class
0034 // has a map between them.
0035 
0036 // Author: H.Kurashige, 20 August 2004 - First implementation
0037 // --------------------------------------------------------------------
0038 #ifndef G4MCCIndexConversionTable_hh
0039 #define G4MCCIndexConversionTable_hh 1
0040 
0041 #include <vector>
0042 #include "globals.hh"
0043 #include "G4ios.hh"
0044 
0045 class G4MCCIndexConversionTable
0046 {
0047   public:
0048 
0049     G4MCCIndexConversionTable();
0050       // Default constructor.
0051 
0052     virtual ~G4MCCIndexConversionTable();
0053       // Destructor.
0054 
0055     void Reset(std::size_t size);
0056       // reset conversion table 
0057  
0058     G4bool IsUsed(std::size_t index) const;
0059       // returns 'true' if the indicated MCC in the file 
0060       // is used in the current production cut table
0061   
0062     void SetNewIndex(std::size_t index, std::size_t new_value);   
0063       // set the index in the current production cut table
0064       // for the indicated MCC in the file
0065 
0066     G4int GetIndex(std::size_t index) const;
0067       // get the index in the current production cut table
0068       // for the indicated MCC in the file
0069  
0070     std::size_t size() const;
0071 
0072   protected:
0073 
0074    std::vector<G4int> vecNewIndex;
0075 };
0076 
0077 // ------------------
0078 // Inline methods
0079 // ------------------
0080 
0081 inline
0082 G4bool G4MCCIndexConversionTable::IsUsed(std::size_t index) const
0083 {
0084   // returns 'true' if the indicated MCC in the file 
0085   // is used in the current production cut table
0086   return ((index < vecNewIndex.size()) && (vecNewIndex[index] >= 0)); 
0087 }
0088 
0089 inline
0090 void G4MCCIndexConversionTable::SetNewIndex(std::size_t index,
0091                                             std::size_t new_value)
0092 {
0093   // set the index in the current production cut table
0094   // for the indicated MCC in the file
0095   if (index < vecNewIndex.size()) vecNewIndex[index] = (G4int)new_value;  
0096 }  
0097 
0098 inline
0099 G4int G4MCCIndexConversionTable::GetIndex(std::size_t index) const
0100 {
0101   // get the index in the current production cut table
0102   // for the indicated MCC in the file
0103   return (index < vecNewIndex.size()) ? vecNewIndex[index] : -1;  
0104 }
0105 
0106 inline
0107 std::size_t G4MCCIndexConversionTable::size() const
0108 {
0109   return vecNewIndex.size();
0110 }
0111 
0112 #endif