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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/cuts/src/G4PhysicsTableHelper.cc (Version 11.3.0) and /processes/cuts/src/G4PhysicsTableHelper.cc (Version 7.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4PhysicsTableHelper class implementation   <<  23 // $Id: G4PhysicsTableHelper.cc,v 1.3 2004/12/15 15:42:37 gunter Exp $
                                                   >>  24 // GEANT4 tag $Name: geant4-07-00-patch-01 $
 27 //                                                 25 //
 28 // Author: H.Kurashige, 20 August 2004 - First <<  26 // 
 29 // ------------------------------------------- <<  27 // ------------------------------------------------------------
                                                   >>  28 //  GEANT 4 class header file 
                                                   >>  29 //
                                                   >>  30 // Class Description
                                                   >>  31 //  G4PhysicsTableHelper is a static utility class 
                                                   >>  32 //  for helping proceeses to build their physics table
                                                   >>  33 //
                                                   >>  34 // ------------------------------------------------------------
                                                   >>  35 //   First Implementation          20 Aug. 2004   H.Kurashige
                                                   >>  36 //
                                                   >>  37 // ------------------------------------------------------------
 30                                                    38 
 31 #include "G4PhysicsTableHelper.hh"                 39 #include "G4PhysicsTableHelper.hh" 
 32 #include "G4ProductionCutsTable.hh"            <<  40 #include  "G4ProductionCutsTable.hh"
 33 #include "G4MCCIndexConversionTable.hh"        << 
 34 #include "G4Threading.hh"                      << 
 35 #include "G4ios.hh"                            << 
 36                                                    41 
 37 G4int G4PhysicsTableHelper::verboseLevel = 1;      42 G4int G4PhysicsTableHelper::verboseLevel = 1; 
 38                                                    43 
 39 // ------------------------------------------- << 
 40 G4PhysicsTableHelper::G4PhysicsTableHelper()       44 G4PhysicsTableHelper::G4PhysicsTableHelper()
 41 {                                                  45 {
 42 }                                                  46 }
 43                                                    47 
 44 // ------------------------------------------- << 
 45 G4PhysicsTableHelper::~G4PhysicsTableHelper()      48 G4PhysicsTableHelper::~G4PhysicsTableHelper()
 46 {                                                  49 {
 47 }                                                  50 }
 48                                                    51 
 49 // ------------------------------------------- <<  52 G4PhysicsTableHelper::G4PhysicsTableHelper(const G4PhysicsTableHelper&)
 50 G4PhysicsTable*                                <<  53 {
 51 G4PhysicsTableHelper::PreparePhysicsTable(G4Ph <<  54 }
 52 {                                              <<  55 
 53   G4ProductionCutsTable* cutTable              <<  56 G4PhysicsTableHelper& G4PhysicsTableHelper::operator=(const G4PhysicsTableHelper&)
 54     = G4ProductionCutsTable::GetProductionCuts <<  57 {
 55   std::size_t numberOfMCC = cutTable->GetTable <<  58   return *this;
                                                   >>  59 }
                                                   >>  60 
 56                                                    61 
 57   if ( physTable != nullptr )                  <<  62 G4PhysicsTable* G4PhysicsTableHelper::PreparePhysicsTable(G4PhysicsTable* physTable)
 58   {                                            <<  63 {
                                                   >>  64   G4ProductionCutsTable* cutTable = G4ProductionCutsTable::GetProductionCutsTable();  
                                                   >>  65   size_t numberOfMCC = cutTable->GetTableSize(); 
                                                   >>  66 
                                                   >>  67   if ( physTable !=0) {
 59     // compare size of physics table and numbe     68     // compare size of physics table and number of material-cuts-couple
 60     if ( physTable->size() < numberOfMCC )     <<  69     if ( physTable->size() < numberOfMCC) {
 61     {                                          <<  70       // enlarge physcis table
                                                   >>  71       physTable->resize(numberOfMCC, (G4PhysicsVector*)(0));
                                                   >>  72     } else if ( physTable->size() > numberOfMCC){
                                                   >>  73       // ERROR: this situation should not occur  
                                                   >>  74       //  size of physics table is shorter than  number of material-cuts-couple
                                                   >>  75       physTable->resize(numberOfMCC);
 62 #ifdef G4VERBOSE                                   76 #ifdef G4VERBOSE  
 63       if (verboseLevel>2)                      <<  77       if (verboseLevel>0) {
 64       {                                        <<  78   G4cerr << "G4PhysicsTableHelper::PreparePhysicsTable  ";
 65         G4cout << "G4PhysicsTableHelper::Prepa <<  79   G4cerr << "Physics Table "<< physTable ;
 66                << " the table " << physTable < <<  80   G4cerr << " is longer than number of material-cuts-couple " << G4endl;
 67          << physTable->size()                  << 
 68                << " will be is resized to " << << 
 69       }                                            81       }
 70 #endif                                             82 #endif 
 71       // enlarge physics table                 << 
 72       physTable->resize(numberOfMCC, nullptr); << 
 73     }                                          << 
 74     else if ( physTable->size() > numberOfMCC  << 
 75     {                                          << 
 76       // ERROR: this situation should not occu << 
 77       // size of physics table is larger than  << 
 78       G4ExceptionDescription ed;               << 
 79       ed << "table " << physTable << " size="  << 
 80    << " is longer than number of material-cuts << 
 81       G4Exception( "G4PhysicsTableHelper::Prep << 
 82                    "ProcCuts001", FatalExcepti << 
 83     }                                              83     } 
 84   }                                            <<  84   } else {
 85   else                                         << 
 86   {                                            << 
 87     // create PhysicsTable is given poitner is     85     // create PhysicsTable is given poitner is null
 88     physTable = new G4PhysicsTable();          <<  86     physTable = new G4PhysicsTable(numberOfMCC);
 89     physTable->resize(numberOfMCC, nullptr);   <<  87     physTable->resize(numberOfMCC, (G4PhysicsVector*)(0));
                                                   >>  88 
 90   }                                                89   }
 91                                                    90 
 92 #ifdef G4VERBOSE                                   91 #ifdef G4VERBOSE  
 93   if (verboseLevel>2)                          <<  92   if (verboseLevel>2) {
 94   {                                            <<  93     if ( physTable !=0) { 
 95     G4cout << "G4PhysicsTableHelper::PreparePh <<  94       G4cerr << "Physics Table size "<< physTable->size();
 96      << " the table "<< physTable              <<  95     } else {
 97      << " size=" << numberOfMCC << G4endl;     <<  96       G4cerr << "Physics Table does not exist   ";
                                                   >>  97     }
                                                   >>  98     G4cerr << ": number of material-cuts-couple " << numberOfMCC << G4endl;
 98   }                                                99   }
 99 #endif                                            100 #endif 
100                                                   101 
101   // Reset recal-needed flag for all physics v    102   // Reset recal-needed flag for all physics vectors
102   physTable->ResetFlagArray();                    103   physTable->ResetFlagArray();
103                                                   104 
104   for (std::size_t idx = 0; idx <numberOfMCC;  << 105   for (size_t idx = 0; idx <numberOfMCC; idx +=1){
105   {                                            << 106     const G4MaterialCutsCouple* mcc = cutTable->GetMaterialCutsCouple(idx);
106     const G4MaterialCutsCouple* mcc = cutTable << 107     //check if re-calculation of the physics vector is needed 
107                                                << 
108     // check if re-calculation of the physics  << 
109     // MCC is not used                            108     // MCC is not used
110     if ( !mcc->IsUsed() ) physTable->ClearFlag    109     if ( !mcc->IsUsed() ) physTable->ClearFlag(idx);
111                                                   110 
112     // RecalcNeeded flag of MCC is not asserte    111     // RecalcNeeded flag of MCC is not asserted 
113     if ( !mcc->IsRecalcNeeded() ) physTable->C    112     if ( !mcc->IsRecalcNeeded() ) physTable->ClearFlag(idx);
114   }                                               113   }
115                                                   114   
116   return physTable;                               115   return physTable;
117 }                                                 116 }
118                                                   117 
119 // ------------------------------------------- << 118 
                                                   >> 119 
120 G4bool G4PhysicsTableHelper::RetrievePhysicsTa    120 G4bool G4PhysicsTableHelper::RetrievePhysicsTable(G4PhysicsTable* physTable,
121                                                << 121               const G4String& fileName,
122                                                << 122               G4bool ascii              )
123 {                                                 123 {
124   if (physTable == nullptr ) return false;     << 124   if (physTable == 0) return false;
125                                                   125   
126   // retrieve physics table from the given fil    126   // retrieve physics table from the given file
127   G4PhysicsTable* tempTable = new G4PhysicsTab    127   G4PhysicsTable* tempTable = new G4PhysicsTable();
128   if (! tempTable->RetrievePhysicsTable(fileNa << 128   if (! tempTable->RetrievePhysicsTable(fileName,ascii) ){
129   {                                            << 129 #ifdef G4VERBOSE  
130     G4ExceptionDescription ed;                 << 130     if (verboseLevel>1) {
131     ed << "Cannot retrieve physics table from  << 131       G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable  ";
132     G4Exception( "G4ProductionCutsTable::Retri << 132       G4cerr << "Fail to retreive from "<< fileName << G4endl;
133                  "ProcCuts105", JustWarning, e << 133     }
134     delete tempTable;                          << 134 #endif 
135     return false;                                 135     return false;
136   }                                               136   } 
137                                                   137 
138   G4ProductionCutsTable* cutTable              << 138   G4ProductionCutsTable* cutTable = G4ProductionCutsTable::GetProductionCutsTable();  
139     = G4ProductionCutsTable::GetProductionCuts << 139   const G4MCCIndexConversionTable* converter = cutTable->GetMCCIndexConversionTable();
140   const G4MCCIndexConversionTable* converter   << 
141     = cutTable->GetMCCIndexConversionTable();  << 
142                                                   140 
143   // check physics table size                     141   // check physics table size
144   if ( tempTable->size() != converter->size()) << 142   if ( tempTable->size() != converter->size()){
145   {                                            << 143 #ifdef G4VERBOSE  
146     G4ExceptionDescription ed;                 << 144     if (verboseLevel>0) {
147     ed << "Physics table in " << fileName      << 145       G4cerr << "G4PhysicsTableHelper::RetrievePhysicsTable  ";
148        << "\n   size=" << tempTable->size() << << 146       G4cerr << "Size of the physics table in "<< fileName;
149        << " is inconsistent with material-cut- << 147       G4cerr << "( size =" << tempTable->size() << ")";
150        << "size=" << converter->size() << " th << 148       G4cerr << " is inconsistent with material-cut info";
151     G4Exception("G4ProductionCutsTable::Retrie << 149       G4cerr << "( size =" << converter->size() << ")";
152                 "ProcCuts106", JustWarning, ed << 150       G4cerr << G4endl;
153     delete tempTable;                          << 151     }
                                                   >> 152 #endif
154     return false;                                 153     return false;
155   }                                               154   }
156                                                   155   
157   // fill the given physics table with retriev << 156   // fill the given physics table with retrived physics vectors 
158   for (std::size_t idx=0; idx<converter->size( << 157   for (size_t idx=0; idx<converter->size(); idx++){
159   {                                            << 158     if (converter->IsUsed(idx)){
160     if (converter->IsUsed(idx))                << 159       size_t i = converter->GetIndex(idx);
161     {                                          << 
162       G4int i = converter->GetIndex(idx);      << 
163       if(i < 0)                                << 
164       {                                        << 
165         tempTable->clearAndDestroy();          << 
166   delete tempTable;                            << 
167   return false;                                << 
168       }                                        << 
169       G4PhysicsVector* vec = (*physTable)[i];     160       G4PhysicsVector* vec = (*physTable)[i];
170       if (vec != nullptr ) delete vec;         << 161       if (vec !=0 ) delete vec;
171       (*physTable)[i] = (*tempTable)[idx];     << 162       (*physTable)[i] =  (*tempTable)[idx];
172       physTable->ClearFlag(i);                    163       physTable->ClearFlag(i);
173     }                                             164     }
174   }                                               165   }
175   tempTable->clear();                          << 
176   delete tempTable;                            << 
177                                                   166 
178   return true;                                    167   return true;
179 }                                                 168 }
180                                                   169 
181 // ------------------------------------------- << 170 
182 void G4PhysicsTableHelper::SetPhysicsVector(G4    171 void G4PhysicsTableHelper::SetPhysicsVector(G4PhysicsTable* physTable,
183                                             st << 172               size_t idx,
184                                             G4 << 173               G4PhysicsVector* vec)
185 {                                                 174 {
186   if ( physTable == nullptr) {  return;  }     << 175   if ( physTable ==0) {  return;  }
187                                                   176 
188   if ( physTable->size() <= idx)               << 177   if ( physTable->size() <= idx) {
189   {                                            << 178 #ifdef G4VERBOSE  
190     G4ExceptionDescription ed;                 << 179     if (verboseLevel>0) {
191     ed << "Given index (" << idx << ")  exceed << 180       G4cerr << "G4PhysicsTableHelper::SetPhysicsVector   ";
192        << "the size of the physics table "     << 181       G4cerr << "Given index (" << idx << ")  exceeds ";
193        << "( size =" << physTable->size() << " << 182       G4cerr << "size of the physics table ";
194     G4Exception("G4ProductionCutsTable::SetPhy << 183       G4cerr << "( size =" << physTable->size()<< ")";
195                 "ProcCuts107",                 << 184       G4cerr << G4endl;
196                 JustWarning, ed);              << 185     }
                                                   >> 186 #endif
197     return;                                       187     return;
198   }                                               188   } 
199                                                   189 
200   // set physics vector                           190   // set physics vector 
201   (*physTable)[idx] = vec;                        191   (*physTable)[idx] = vec;
202   // clear flag                                   192   // clear flag
203   physTable->ClearFlag(idx);                      193   physTable->ClearFlag(idx);
204 }                                              << 194  
205                                                   195 
206 // ------------------------------------------- << 
207 void G4PhysicsTableHelper::SetVerboseLevel(G4i << 
208 {                                              << 
209   if( !G4Threading::IsWorkerThread() ) verbose << 
210 }                                                 196 }
211                                                   197 
212 // ------------------------------------------- << 198 
213 G4int G4PhysicsTableHelper::GetVerboseLevel()  << 199 
214 {                                              << 200 
215   return verboseLevel;                         << 
216 }                                              << 
217                                                   201