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 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 /analysis/management/src/G4HnInformation.cc (Version 11.3.0) and /analysis/management/src/G4HnInformation.cc (Version 10.3.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 // Author: Ivana Hrivnacova,  10/08/2022  (iva    
 28                                                   
 29 #include "G4HnInformation.hh"                     
 30 #include "G4AnalysisUtilities.hh"                 
 31                                                   
 32                                                   
 33 //____________________________________________    
 34 void G4HnDimension::Print() const                 
 35 {                                                 
 36   G4cout                                          
 37     << "NBins: " << fNBins << " minValue: " <<    
 38     << fMaxValue << ";" << " edges: ";            
 39   for ( auto value : fEdges ) {                   
 40     G4cout << value << ", ";                      
 41   }                                               
 42   G4cout << G4endl;                               
 43 }                                                 
 44                                                   
 45 //____________________________________________    
 46 void G4HnDimensionInformation::Print() const      
 47 {                                                 
 48   G4cout                                          
 49     << "Unit name: " << fUnitName << " Fcn Nam    
 50     << fBinSchemeName << " Unit: " << fUnit <<    
 51     << G4endl;                                    
 52 }                                                 
 53                                                   
 54 namespace G4Analysis                              
 55 {                                                 
 56                                                   
 57 //____________________________________________    
 58 void Update(G4double& value, const G4HnDimensi    
 59 {                                                 
 60 // Apply hnInfo to a value                        
 61                                                   
 62   auto unit = hnInfo.fUnit;                       
 63   auto fcn = hnInfo.fFcn;                         
 64                                                   
 65   if (unit == 0.) {                               
 66     // Should never happen                        
 67     Warn("Illegal unit value (0), 1. will be u    
 68       kNamespaceName, "UpdateBins");              
 69     unit = 1.;                                    
 70   }                                               
 71   value = fcn(value/unit);                        
 72 }                                                 
 73                                                   
 74 //____________________________________________    
 75 void UpdateValues(                                
 76   G4HnDimension& bins, const G4HnDimensionInfo    
 77 {                                                 
 78 // Apply hnInfo to bins min and max value         
 79                                                   
 80   auto unit = hnInfo.fUnit;                       
 81   auto fcn = hnInfo.fFcn;                         
 82                                                   
 83   if (unit == 0.) {                               
 84     // Should never happen                        
 85     Warn("Illegal unit value (0), 1. will be u    
 86       kNamespaceName, "UpdateBins");              
 87     unit = 1.;                                    
 88   }                                               
 89   // Update min/max values                        
 90   bins.fMinValue = fcn(bins.fMinValue/unit);      
 91   bins.fMaxValue = fcn(bins.fMaxValue/unit);      
 92 }                                                 
 93                                                   
 94 //____________________________________________    
 95 void Update(                                      
 96   G4HnDimension& bins, const G4HnDimensionInfo    
 97 {                                                 
 98 // Apply hnInfo to bins, compute edges            
 99                                                   
100   auto unit = hnInfo.fUnit;                       
101   auto fcn = hnInfo.fFcn;                         
102   auto binScheme = hnInfo.fBinScheme;             
103                                                   
104   if (binScheme == G4BinScheme::kLinear) {        
105     // Compute edges, as they may be needed in    
106     // with log binning in other dimension        
107     G4Analysis::ComputeEdges(                     
108       bins.fNBins, bins.fMinValue, bins.fMaxVa    
109                                                   
110     // Update min/max Values                      
111     UpdateValues(bins, hnInfo);                   
112                                                   
113     return;                                       
114   }                                               
115                                                   
116   if (binScheme == G4BinScheme::kLog) {           
117     // Logarithmic bin scheme                     
118     // compute edges from parameters              
119     G4Analysis::ComputeEdges(                     
120       bins.fNBins, bins.fMinValue, bins.fMaxVa    
121   }                                               
122                                                   
123   if (binScheme == G4BinScheme::kUser) {          
124     std::vector<G4double> edges = bins.fEdges;    
125     bins.fEdges.clear();                          
126     G4Analysis::ComputeEdges(edges, unit, fcn,    
127   }                                               
128 }                                                 
129                                                   
130 //____________________________________________    
131 void UpdateTitle(G4String& title, const G4HnDi    
132 {                                                 
133   if ( hnInfo.fFcnName != "none" )  { title +=    
134   if ( hnInfo.fUnitName != "none" ) { title +=    
135   if ( hnInfo.fFcnName != "none" )  { title +=    
136 }                                                 
137                                                   
138 //____________________________________________    
139 G4bool CheckMinMax(G4double minValue, G4double    
140 {                                                 
141   auto result = true;                             
142                                                   
143   // Do not check default values                  
144   if ( minValue == 0. && maxValue == 0. ) retu    
145                                                   
146   if ( maxValue <= minValue ) {                   
147     Warn("Illegal value of (minValue >= maxMax    
148     result = false;                               
149   }                                               
150                                                   
151   return result;                                  
152 }                                                 
153                                                   
154 //____________________________________________    
155 G4bool CheckDimension(unsigned int idim,          
156          const G4HnDimension& dimension, const    
157 {                                                 
158   auto result = true;                             
159   G4String xyz {"xyz"};                           
160                                                   
161   // Check nbins                                  
162   if ( (dimension.fNBins <= 0) && (info.fBinSc    
163     Warn("Illegal value of number of " + xyz.s    
164       kNamespaceName, "CheckDimension");          
165     result = false;                               
166   }                                               
167                                                   
168   // Check min/max                                
169   if ( (dimension.fMaxValue <= dimension.fMinV    
170        (info.fBinScheme != G4BinScheme::kUser)    
171     Warn("Illegal value of " + xyz.substr(idim    
172       kNamespaceName, "CheckDimension");          
173     result = false;                               
174   }                                               
175                                                   
176   // Check edges                                  
177   if (info.fBinScheme == G4BinScheme::kUser) {    
178     if ( dimension.fEdges.empty() ) {             
179       Warn(xyz.substr(idim,1) + " edges vector    
180         kNamespaceName, "CheckDimension");        
181       result = false;                             
182     }                                             
183     // the edges values must be defined in inc    
184     for (size_t i = 1; i < dimension.fEdges.si    
185       if (dimension.fEdges[i-1] >= dimension.f    
186         Warn(xyz.substr(idim,1) +                 
187           " edges vector values must be define    
188           kNamespaceName, "CheckDimension");      
189         result = false;                           
190       }                                           
191     }                                             
192   }                                               
193                                                   
194   // Check function                               
195   if ( ( info.fFcnName != "none" ) && ( info.f    
196     Warn("Combining  " + xyz.substr(idim,1) +     
197       kNamespaceName, "CheckDimension");          
198     result = false;                               
199   }                                               
200                                                   
201   // Check minValue if log binning or log func    
202   if ( ( info.fBinScheme == G4BinScheme::kLog     
203          info.fFcnName == "log" || info.fFcnNa    
204     Warn("Illegal value of " + xyz.substr(idim    
205       kNamespaceName, "CheckDimension");          
206     result = false;                               
207   }                                               
208                                                   
209   return result;                                  
210 }                                                 
211                                                   
212 }                                                 
213