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p3 ] [ 10.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/hadronic/cross_sections/src/G4ComponentSAIDTotalXS.cc (Version 11.3.0) and /processes/hadronic/cross_sections/src/G4ComponentSAIDTotalXS.cc (Version 4.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 // -------------------------------------------    
 28 //                                                
 29 // GEANT4 Class file                              
 30 //                                                
 31 //                                                
 32 // File name:    G4ComponentSAIDTotalXS           
 33 //                                                
 34 // Authors:  G.Folger, V.Ivanchenko, D.Wright     
 35 //                                                
 36 // Modifications:                                 
 37 //                                                
 38                                                   
 39 #include "G4ComponentSAIDTotalXS.hh"              
 40 #include "G4PhysicsVector.hh"                     
 41 #include "G4PhysicsFreeVector.hh"                 
 42                                                   
 43 const G4String G4ComponentSAIDTotalXS::fnames[    
 44   "","pp","np","pip","pim",                       
 45   "pin","pie",                                    
 46   "gp_pi0p","gp_pi+n","gn_pi-p","gn_pi0n","gp_    
 47 };                                                
 48                                                   
 49 #ifdef G4MULTITHREADED                            
 50   G4Mutex G4ComponentSAIDTotalXS::saidXSMutex     
 51 #endif                                            
 52                                                   
 53 G4ComponentSAIDTotalXS::G4ComponentSAIDTotalXS    
 54   : G4VComponentCrossSection("xsSAID")            
 55 {                                                 
 56   for(G4int i=0; i<numberOfSaidXS; ++i) {         
 57     elastdata[i] = nullptr;                       
 58     inelastdata[i] = nullptr;                     
 59   }                                               
 60 }                                                 
 61                                                   
 62 G4ComponentSAIDTotalXS::~G4ComponentSAIDTotalX    
 63 {                                                 
 64   for(G4int i=0; i<numberOfSaidXS; ++i) {         
 65     if(elastdata[i]) {                            
 66       delete elastdata[i];                        
 67       elastdata[i] = nullptr;                     
 68     }                                             
 69     if(inelastdata[i]) {                          
 70       delete inelastdata[i];                      
 71       inelastdata[i] = nullptr;                   
 72     }                                             
 73   }                                               
 74 }                                                 
 75                                                   
 76 G4double                                          
 77 G4ComponentSAIDTotalXS::GetTotalElementCrossSe    
 78       const G4ParticleDefinition* part,           
 79       G4double, G4int Z, G4double N)              
 80 {                                                 
 81   PrintWarning(part,0,Z,G4lrint(N),               
 82          "G4ComponentSAIDTotalXS::GetTotalElem    
 83          "Method is not implemented");            
 84   return 0.0;                                     
 85 }                                                 
 86                                                   
 87 G4double                                          
 88 G4ComponentSAIDTotalXS::GetTotalIsotopeCrossSe    
 89       const G4ParticleDefinition* part,           
 90       G4double kinEnergy, G4int Z, G4int N)       
 91 {                                                 
 92   return GetInelasticIsotopeCrossSection(part,    
 93     + GetElasticIsotopeCrossSection(part,kinEn    
 94 }                                                 
 95                                                   
 96 G4double                                          
 97 G4ComponentSAIDTotalXS::GetInelasticElementCro    
 98       const G4ParticleDefinition* part,           
 99       G4double, G4int Z, G4double N)              
100 {                                                 
101   PrintWarning(part,0,Z,G4lrint(N),               
102          "G4ComponentSAIDTotalXS::GetTotalElem    
103          "Method is not implemented");            
104   return 0.0;                                     
105 }                                                 
106                                                   
107 G4double                                          
108 G4ComponentSAIDTotalXS::GetInelasticIsotopeCro    
109       const G4ParticleDefinition* part,           
110       G4double kinEnergy, G4int Z, G4int N)       
111 {                                                 
112   G4double cross = 0.0;                           
113   G4SAIDCrossSectionType tp = GetType(part,0,Z    
114   if(saidUnknown != tp) {                         
115     G4int idx = G4int(tp);                        
116     if(!inelastdata[idx]) { Initialise(tp); }     
117     if(inelastdata[idx]) {                        
118       cross = (inelastdata[idx])->Value(kinEne    
119     }                                             
120   }                                               
121   return cross;                                   
122 }                                                 
123                                                   
124 G4double                                          
125 G4ComponentSAIDTotalXS::GetElasticElementCross    
126       const G4ParticleDefinition* part,           
127       G4double, G4int Z, G4double N)              
128 {                                                 
129   PrintWarning(part,0,Z,G4lrint(N),               
130          "G4ComponentSAIDTotalXS::GetTotalElem    
131          "Method is not implemented");            
132   return 0.0;                                     
133 }                                                 
134                                                   
135 G4double                                          
136 G4ComponentSAIDTotalXS::GetElasticIsotopeCross    
137       const G4ParticleDefinition* part,           
138       G4double kinEnergy, G4int Z, G4int N)       
139 {                                                 
140   G4double cross = 0.0;                           
141   G4SAIDCrossSectionType tp = GetType(part,0,Z    
142   if(saidUnknown != tp) {                         
143     G4int idx = G4int(tp);                        
144     if(!elastdata[idx]) { Initialise(tp); }       
145     if(elastdata[idx]) {                          
146       cross = (elastdata[idx])->Value(kinEnerg    
147     }                                             
148   }                                               
149   return cross;                                   
150 }                                                 
151                                                   
152 G4double                                          
153 G4ComponentSAIDTotalXS::GetChargeExchangeCross    
154      const G4ParticleDefinition* prim,            
155      const G4ParticleDefinition* sec,             
156      G4double kinEnergy, G4int Z, G4int N)        
157 {                                                 
158   G4double cross = 0.0;                           
159   G4SAIDCrossSectionType tp = GetType(prim,sec    
160   if(saidUnknown != tp) {                         
161     G4int idx = G4int(tp);                        
162     if(!inelastdata[idx]) { Initialise(tp); }     
163     if(inelastdata[idx]) {                        
164       cross = (inelastdata[idx])->Value(kinEne    
165     }                                             
166   }                                               
167   return cross;                                   
168 }                                                 
169                                                   
170 void G4ComponentSAIDTotalXS::Description(std::    
171 {                                                 
172 }                                                 
173                                                   
174 G4SAIDCrossSectionType                            
175 G4ComponentSAIDTotalXS::GetType(const G4Partic    
176         const G4ParticleDefinition* sec,          
177         G4int Z, G4int N)                         
178 {                                                 
179   G4SAIDCrossSectionType type = saidUnknown;      
180   if(1 == N && prim) {                            
181     G4int code = prim->GetPDGEncoding();          
182                                                   
183     // only gamma + N x-sections available        
184     if(0 == Z && sec && 22 == code) {             
185       G4int code1 = sec->GetPDGEncoding();        
186       if(-211 == code1)     { type = saidGN_PI    
187       else if(111 == code1) { type = saidGN_PI    
188                                                   
189       // x-sections off proton                    
190     } else if(1 == Z) {                           
191       if(sec) {                                   
192   G4int code1 = sec->GetPDGEncoding();            
193         if(-211 == code) {                        
194           if(111 == code1)      { type = saidP    
195           else if(221 == code1) { type = saidP    
196                                                   
197   } else if(22 == code) {                         
198           if(111 == code1)      { type = saidG    
199           else if(211 == code1) { type = saidG    
200           else if(221 == code1) { type = saidG    
201           else if(331 == code1) { type = saidG    
202   }                                               
203       } else {                                    
204         if(2212 == code)        { type = saidP    
205         else if(2112 == code)   { type = saidN    
206         else if(211 == code)    { type = saidP    
207         else if(-211 == code)   { type = saidP    
208       }                                           
209     }                                             
210   }                                               
211   //G4cout << "G4ComponentSAIDTotalXS::Type= "    
212   return type;                                    
213 }                                                 
214                                                   
215 void G4ComponentSAIDTotalXS::Initialise(G4SAID    
216 {                                                 
217   G4int idx = G4int(tp);                          
218 #ifdef G4MULTITHREADED                            
219   G4MUTEXLOCK(&saidXSMutex);                      
220   if(!inelastdata[idx]) {                         
221 #endif                                            
222     // check environment variable                 
223     // Build the complete string identifying t    
224     const char* path = G4FindDataDir("G4SAIDXS    
225     if (!path){                                   
226       G4Exception("G4ComponentSAIDTotalXS::Ini    
227       FatalException,                             
228       "Environment variable G4SAIDXSDATA is no    
229       return;                                     
230     }                                             
231     if(idx <= 4) {                                
232       elastdata[idx] = new G4PhysicsFreeVector    
233       inelastdata[idx] = new G4PhysicsFreeVect    
234       ReadData(idx,elastdata[idx],path,"_el.da    
235       ReadData(idx,inelastdata[idx],path,"_in.    
236     } else {                                      
237       inelastdata[idx] = new G4PhysicsFreeVect    
238       ReadData(idx,inelastdata[idx],path,".dat    
239     }                                             
240 #ifdef G4MULTITHREADED                            
241   }                                               
242   G4MUTEXUNLOCK(&saidXSMutex);                    
243 #endif                                            
244 }                                                 
245                                                   
246 void G4ComponentSAIDTotalXS::ReadData(G4int in    
247               G4PhysicsVector* v,                 
248               const G4String& ss1,                
249               const G4String& ss2)                
250 {                                                 
251   std::ostringstream ost;                         
252   ost << ss1 << "/" << fnames[index] << ss2;      
253   std::ifstream filein(ost.str().c_str());        
254   if (!(filein)) {                                
255     G4ExceptionDescription ed;                    
256     ed << "Data file <" << ost.str().c_str()      
257        << "> is not opened!";                     
258     G4Exception("G4ComponentSAIDTotalXS::ReadD    
259                 FatalException, ed, "Check G4S    
260   } else {                                        
261     if(GetVerboseLevel() > 1) {                   
262       G4cout << "File " << ost.str()              
263              << " is opened by G4ComponentSAID    
264     }                                             
265     // retrieve data from DB                      
266     v->Retrieve(filein, true);                    
267     v->ScaleVector(CLHEP::MeV,CLHEP::millibarn    
268     v->FillSecondDerivatives();                   
269   }                                               
270 }                                                 
271                                                   
272 void                                              
273 G4ComponentSAIDTotalXS::PrintWarning(const G4P    
274              const G4ParticleDefinition* sec,     
275              G4int Z, G4int N,                    
276              const G4String& ss1,                 
277              const G4String& ss2)                 
278 {                                                 
279   G4cout << ss1 << ": " << ss2 << G4endl;         
280   G4cout << "For Z= " << Z << " N= " << N << "    
281   if(prim) { G4cout << prim->GetParticleName()    
282   if(sec) { G4cout << " x-section to " << sec-    
283   G4cout << G4endl;                               
284 }                                                 
285