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] [ 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 /examples/advanced/ChargeExchangeMC/src/CexmcRunAction.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcRunAction.cc (Version 5.1)


  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  *       Filename:  CexmcRunAction.cc             
 30  *                                                
 31  *    Description:  run action                    
 32  *                                                
 33  *        Version:  1.0                           
 34  *        Created:  20.12.2009 00:18:05           
 35  *       Revision:  none                          
 36  *       Compiler:  gcc                           
 37  *                                                
 38  *         Author:  Alexey Radkov (),             
 39  *        Company:  PNPI                          
 40  *                                                
 41  * ===========================================    
 42  */                                               
 43                                                   
 44 #include <limits>                                 
 45 #include <vector>                                 
 46 #include <string>                                 
 47 #include <iostream>                               
 48 #include <iomanip>                                
 49 #include "CexmcRunAction.hh"                      
 50 #include "CexmcPhysicsManager.hh"                 
 51 #include "CexmcProductionModel.hh"                
 52 #include "CexmcAngularRange.hh"                   
 53 #include "CexmcException.hh"                      
 54                                                   
 55                                                   
 56 CexmcRunAction::CexmcRunAction( CexmcPhysicsMa    
 57     physicsManager( physicsManager_ )             
 58 {                                                 
 59 }                                                 
 60                                                   
 61                                                   
 62 G4Run *  CexmcRunAction::GenerateRun( void )      
 63 {                                                 
 64     return new CexmcRun;                          
 65 }                                                 
 66                                                   
 67                                                   
 68 void  CexmcRunAction::PrintResults(               
 69                     const CexmcNmbOfHitsInRang    
 70                     const CexmcNmbOfHitsInRang    
 71                     const CexmcNmbOfHitsInRang    
 72                     const CexmcNmbOfHitsInRang    
 73                     const CexmcNmbOfHitsInRang    
 74                     const CexmcAngularRangeLis    
 75                     G4int  nmbOfFalseHitsTrigg    
 76                     G4int  nmbOfFalseHitsTrigg    
 77 {                                                 
 78     /* there are 7 auxiliary columns:             
 79      * 1. acc real, [floating point number]       
 80      * 2. triggered real,                         
 81      * 3. total hits sampled and monitored,       
 82      * 4. acc reconstructed, [floating point n    
 83      * 5. triggered reconstructed,                
 84      * 6. total hits sampled and monitored (id    
 85      * 7. total hits sampled.                     
 86      * As far as #3 and #6 are identical, nmbO    
 87     const size_t                                  
 88     const std::streamsize                         
 89     std::vector< std::vector< std::string > >     
 90     size_t                                        
 91                                                   
 92     for ( size_t  i( 0 ); i < nmbOfAuxColumns;    
 93         maxSize[ i ] = 0;                         
 94                                                   
 95     /* addition of 2 (for '0.') for acceptance    
 96      * numbers, is correct as far as ios::fixe    
 97      * values are expected, and values will be    
 98     maxSize[ 0 ] = prec + 2;                      
 99     maxSize[ 3 ] = prec + 2;                      
100                                                   
101     for ( CexmcAngularRangeList::const_iterato    
102                                                   
103     {                                             
104         G4int     total( 0 );                     
105         G4int     totalFull( 0 );                 
106         G4int     triggered( 0 );                 
107         G4double  acc( std::numeric_limits< G4    
108                                                   
109         CexmcNmbOfHitsInRanges::const_iterator    
110                                         nmbOfH    
111         if ( found != nmbOfHitsSampled.end() )    
112         {                                         
113             total = found->second;                
114             acc = 0;                              
115         }                                         
116                                                   
117         found = nmbOfHitsSampledFull.find( k->    
118         if ( found != nmbOfHitsSampledFull.end    
119         {                                         
120             totalFull = found->second;            
121         }                                         
122                                                   
123         G4double  accSave( acc );                 
124         found = nmbOfHitsTriggeredRealRange.fi    
125         if ( found != nmbOfHitsTriggeredRealRa    
126         {                                         
127             triggered = found->second;            
128             if ( total > 0 )                      
129                 acc = G4double( triggered ) /     
130         }                                         
131                                                   
132         std::ostringstream  auxStringStream[ n    
133                                                   
134         for ( size_t  i( 0 ); i < nmbOfAuxColu    
135         {                                         
136             auxStringStream[ i ].precision( pr    
137             auxStringStream[ i ].flags( std::i    
138         }                                         
139                                                   
140         G4int  i( 0 );                            
141                                                   
142         auxStringStream[ i ] << acc;              
143         auxStringStream[ ++i ] << triggered;      
144         size_t  size( auxStringStream[ i ].str    
145         maxSize[ i ] = maxSize[ i ] > size ? m    
146         auxStringStream[ ++i ] << total;          
147         size = auxStringStream[ i ].str().size    
148         maxSize[ i ] = maxSize[ i ] > size ? m    
149                                                   
150         triggered = 0;                            
151         acc = accSave;                            
152         found = nmbOfHitsTriggeredRecRange.fin    
153         if ( found != nmbOfHitsTriggeredRecRan    
154         {                                         
155             triggered = found->second;            
156             if ( total > 0 )                      
157                 acc = G4double( triggered ) /     
158         }                                         
159                                                   
160         auxStringStream[ ++i ] << acc;            
161         auxStringStream[ ++i ] << triggered;      
162         size = auxStringStream[ i ].str().size    
163         maxSize[ i ] = maxSize[ i ] > size ? m    
164         auxStringStream[ ++i ] << totalFull;      
165         size = auxStringStream[ i ].str().size    
166         maxSize[ i ] = maxSize[ i ] > size ? m    
167                                                   
168         std::vector< std::string >  auxString(    
169                                                   
170         for ( size_t  j( 0 ); j < nmbOfAuxColu    
171             auxString[ j ] = auxStringStream[     
172                                                   
173         auxStrings.push_back( auxString );        
174     }                                             
175                                                   
176     G4cout << " --- Setup acceptances (range |    
177               "rec (trg / mon / all)):" << G4e    
178                                                   
179     G4int  i( 0 );                                
180     for ( CexmcAngularRangeList::const_iterato    
181                                                   
182     {                                             
183         G4cout << "       " << *k;                
184         G4int  j( 0 );                            
185         G4cout << "  | " << std::setw( maxSize    
186         G4cout << auxStrings[ i ][ j++ ];         
187         G4cout << " ( " << std::setw( maxSize[    
188         G4cout << auxStrings[ i ][ j++ ];         
189         G4cout << " / " << std::setw( maxSize[    
190         G4cout << auxStrings[ i ][ j++ ];         
191         G4cout << " )  | " << std::setw( maxSi    
192         G4cout << auxStrings[ i ][ j++ ];         
193         G4cout << " ( " << std::setw( maxSize[    
194         G4cout << auxStrings[ i ][ j++ ];         
195         G4cout << " / " << std::setw( maxSize[    
196         G4cout << auxStrings[ i ][ 2 ];           
197         G4cout << " / " << std::setw( maxSize[    
198         G4cout << auxStrings[ i++ ][ j++ ] <<     
199     }                                             
200                                                   
201     CexmcAngularRangeList  angularGaps;           
202     GetAngularGaps( angularRanges, angularGaps    
203                                                   
204     if ( ! angularGaps.empty() )                  
205     {                                             
206         G4cout << "    orphans detected: " <<     
207         for ( CexmcAngularRangeList::const_ite    
208                                                   
209         {                                         
210             G4cout << "       " << *k;            
211             G4int     total( 0 );                 
212                                                   
213             CexmcNmbOfHitsInRanges::const_iter    
214                                             nm    
215             if ( found != nmbOfHitsSampled.end    
216             {                                     
217                 total = found->second;            
218             }                                     
219             G4cout << " " << total << G4endl;     
220         }                                         
221     }                                             
222                                                   
223     G4cout << "       ---" << G4endl;             
224     G4cout << "       False hits (edt | rec):     
225         nmbOfFalseHitsTriggeredEDT << " | " <<    
226         G4endl;                                   
227 }                                                 
228                                                   
229                                                   
230 void  CexmcRunAction::EndOfRunAction( const G4    
231 {                                                 
232     const CexmcRun *  theRun( static_cast< con    
233                                                   
234     const CexmcNmbOfHitsInRanges &  nmbOfHitsS    
235                                         theRun    
236     const CexmcNmbOfHitsInRanges &  nmbOfHitsS    
237                                         theRun    
238     const CexmcNmbOfHitsInRanges &  nmbOfHitsT    
239                                     theRun->Ge    
240     const CexmcNmbOfHitsInRanges &  nmbOfHitsT    
241                                     theRun->Ge    
242     const CexmcNmbOfHitsInRanges &  nmbOfOrpha    
243                                         theRun    
244                                                   
245     CexmcProductionModel *          production    
246                                         physic    
247     if ( ! productionModel )                      
248             throw CexmcException( CexmcWeirdEx    
249                                                   
250     const CexmcAngularRangeList &  angularRang    
251                                         produc    
252                                                   
253     G4cout << G4endl;                             
254     PrintResults( nmbOfHitsSampled, nmbOfHitsS    
255                   nmbOfHitsTriggeredRealRange,    
256                   nmbOfOrphanHits, angularRang    
257                   theRun->GetNmbOfFalseHitsTri    
258                   theRun->GetNmbOfFalseHitsTri    
259     G4cout << G4endl;                             
260 }                                                 
261                                                   
262