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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/extended/exoticphysics/dmparticle/src/Run.cc (Version 11.3.0) and /examples/extended/exoticphysics/dmparticle/src/Run.cc (Version 11.0.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /// \file exoticphysics/dmparticle/src/Run.cc      26 /// \file exoticphysics/dmparticle/src/Run.cc
 27 /// \brief Implementation of the Run class         27 /// \brief Implementation of the Run class
 28 //                                                 28 //
 29                                                    29 
 30 #include "Run.hh"                                  30 #include "Run.hh"
 31                                                << 
 32 #include "TestParameters.hh"                   << 
 33                                                << 
 34 #include "G4ElectronIonPair.hh"                << 
 35 #include "G4LossTableManager.hh"               << 
 36 #include "G4PhysicalConstants.hh"              << 
 37 #include "G4Run.hh"                            << 
 38 #include "G4Step.hh"                               31 #include "G4Step.hh"
                                                   >>  32 #include "G4Run.hh"
                                                   >>  33 #include "G4LossTableManager.hh"
                                                   >>  34 #include "G4ElectronIonPair.hh"
 39 #include "G4SystemOfUnits.hh"                      35 #include "G4SystemOfUnits.hh"
                                                   >>  36 #include "G4PhysicalConstants.hh"
                                                   >>  37 #include "TestParameters.hh"
 40 #include "Randomize.hh"                            38 #include "Randomize.hh"
 41                                                    39 
 42 //....oooOO0OOooo........oooOO0OOooo........oo     40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 43                                                    41 
 44 Run::Run() : G4Run(), fParam(TestParameters::G <<  42 Run::Run()
                                                   >>  43  : G4Run(), fParam(TestParameters::GetPointer())
 45 {                                                  44 {
 46   fTotStepGas = fOverflow = fTotEdep = fStepGa <<  45   fTotStepGas = fOverflow = fTotEdep = fStepGas = fMaxEnergy = 0.0; 
 47   fEvt = fNbins = 0;                               46   fEvt = fNbins = 0;
 48 }                                                  47 }
 49                                                    48 
 50 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 51                                                    50 
 52 Run::~Run() {}                                 <<  51 Run::~Run()
                                                   >>  52 {}
 53                                                    53 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    55 
 56 void Run::BeginOfRun()                             56 void Run::BeginOfRun()
 57 {                                                  57 {
 58   // initilise scoring                             58   // initilise scoring
 59   fTotStepGas = fOverflow = fTotEdep = fStepGa <<  59   fTotStepGas = fOverflow = fTotEdep = fStepGas = fMaxEnergy = 0.0; 
 60   fEvt = 0;                                        60   fEvt = 0;
 61                                                    61 
 62   SetVerbose(1);                                   62   SetVerbose(1);
 63                                                    63 
 64   fNbins = fParam->GetNumberBins();                64   fNbins = fParam->GetNumberBins();
 65   fMaxEnergy = fParam->GetMaxEnergy();             65   fMaxEnergy = fParam->GetMaxEnergy();
 66                                                <<  66   
 67   fEgas.resize(fNbins, 0.0);                   <<  67   fEgas.resize(fNbins,0.0);
 68   fEdep.reset();                                   68   fEdep.reset();
 69                                                    69 
 70   if (fVerbose > 0) {                          <<  70   if(fVerbose > 0) 
 71     G4cout << "    BinsE= " << fNbins << "   E <<  71   {
                                                   >>  72     G4cout << "    BinsE= " <<  fNbins
                                                   >>  73            << "   Emax(keV)= " << fMaxEnergy/keV << G4endl;
 72   }                                                74   }
 73 }                                                  75 }
 74                                                    76 
 75 //....oooOO0OOooo........oooOO0OOooo........oo     77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 76                                                    78 
 77 void Run::EndOfRun()                               79 void Run::EndOfRun()
 78 {                                                  80 {
 79   G4int nEvt = GetNumberOfEvent();                 81   G4int nEvt = GetNumberOfEvent();
 80                                                    82 
 81   G4double norm = (nEvt > 0) ? 1.0 / (G4double <<  83   G4double norm = (nEvt > 0) ? 1.0/(G4double)nEvt : 0.0; 
 82                                                    84 
 83   fTotStepGas *= norm;                         <<  85   fTotStepGas  *= norm;
 84   fOverflow *= norm;                           <<  86   fOverflow    *= norm;
 85                                                    87 
 86   G4double y1 = fEdep.mean();                      88   G4double y1 = fEdep.mean();
 87   G4double y2 = fEdep.rms();                       89   G4double y2 = fEdep.rms();
 88                                                    90 
 89   // G4double de = fMaxEnergy/G4double(fNbins) <<  91   //G4double de = fMaxEnergy/G4double(fNbins);  
 90   // G4double x1 = -de*0.5;                    <<  92   //G4double x1 = -de*0.5; 
 91                                                    93 
 92   G4cout << " ================================     94   G4cout << " ====================================================" << G4endl;
 93   G4cout << "   Beam Particle: " << fParam->Ge <<  95   G4cout << "   Beam Particle: " 
 94          << "   Ekin(GeV)    = " << fParam->Ge <<  96          << fParam->GetBeamParticle()->GetParticleName() << G4endl
 95          << "   Z(mm)        = " << fParam->Ge <<  97          << "   Ekin(GeV)    = " << fParam->GetBeamEnergy()/GeV
                                                   >>  98          << G4endl
                                                   >>  99          << "   Z(mm)        = " << fParam->GetPositionZ()/mm 
                                                   >> 100          << G4endl;
 96   G4cout << " ================== run summary =    101   G4cout << " ================== run summary =====================" << G4endl;
 97   G4int prec = G4cout.precision(5);               102   G4int prec = G4cout.precision(5);
 98   G4cout << "   End of Run TotNbofEvents    =  << 103   G4cout << "   End of Run TotNbofEvents    = " 
                                                   >> 104          << nEvt << G4endl;
 99                                                   105 
100   G4cout << G4endl;                               106   G4cout << G4endl;
101   G4cout << "   Mean energy deposit in absorbe << 107   G4cout << "   Mean energy deposit in absorber = " <<
102          << y2 * std::sqrt(norm) / GeV << " Ge << 108     y1/GeV << " +- " << y2*std::sqrt(norm)/GeV << " GeV; ";
103   if (y1 > 0.0) {                              << 109   if(y1 > 0.0) { G4cout << "   RMS/Emean = " << y2/y1; }
104     G4cout << "   RMS/Emean = " << y2 / y1;    << 
105   }                                            << 
106   G4cout << G4endl;                               110   G4cout << G4endl;
107   G4cout << "   Mean number of steps in absorb << 111   G4cout << "   Mean number of steps in absorber= " 
                                                   >> 112          << fTotStepGas 
                                                   >> 113          << G4endl;
108   G4cout << G4endl;                               114   G4cout << G4endl;
109   /*                                              115   /*
110   G4cout << " ====== Energy deposit distributi << 116   G4cout << " ====== Energy deposit distribution   Noverflows= " << fOverflow 
111          << " ====== " << G4endl ;                117          << " ====== " << G4endl ;
112   G4cout << " bin nb      Elow      entries       118   G4cout << " bin nb      Elow      entries     normalized " << G4endl;
113                                                   119 
114   x1 = 0.0;                                       120   x1 = 0.0;
115                                                << 121  
116   for(G4int j=0; j<fNbins; ++j)                << 122   for(G4int j=0; j<fNbins; ++j) 
117   {                                               123   {
118     G4cout << std::setw(5) << j << std::setw(1 << 124     G4cout << std::setw(5) << j << std::setw(10) << x1/keV 
119            << std::setw(12) << fEgas[j] << std << 125            << std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm 
120            << G4endl ;                            126            << G4endl ;
121     x1 += de;                                     127     x1 += de;
122   }                                               128   }
123   */                                              129   */
124   G4cout.precision(prec);                         130   G4cout.precision(prec);
125                                                << 131  
126   G4AnalysisManager* analysisManager = G4Analy    132   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
127                                                   133 
128   // normalize histograms                         134   // normalize histograms
129                                                   135 
130   analysisManager->ScaleH1(1, norm);           << 136   analysisManager->ScaleH1(1,norm);
131                                                << 137  
132   G4cout << " ================== run end =====    138   G4cout << " ================== run end ==========================" << G4endl;
133 }                                                 139 }
134                                                   140 
135 //....oooOO0OOooo........oooOO0OOooo........oo    141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136                                                   142 
137 void Run::BeginOfEvent()                          143 void Run::BeginOfEvent()
138 {                                                 144 {
139   fTotEdep = 0.0;                                 145   fTotEdep = 0.0;
140   fStepGas = 0;                                   146   fStepGas = 0;
141   ++fEvt;                                         147   ++fEvt;
142 }                                                 148 }
143                                                   149 
144 //....oooOO0OOooo........oooOO0OOooo........oo    150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145                                                   151 
146 void Run::EndOfEvent()                            152 void Run::EndOfEvent()
147 {                                                 153 {
148   /*                                              154   /*
149   G4cout << "fStepGas = " << fStepGas << " fTo    155   G4cout << "fStepGas = " << fStepGas << " fTotStepGas= " << fTotStepGas
150          << " fTotEdep= " << fTotEdep << "  fN    156          << " fTotEdep= " << fTotEdep << "  fNbins= " << fNbins
151          << " fMaxEnergy= " << fMaxEnergy << G    157          << " fMaxEnergy= " << fMaxEnergy << G4endl;
152   */                                              158   */
153   fTotStepGas += fStepGas;                        159   fTotStepGas += fStepGas;
154                                                   160 
155   G4int idx = G4lrint(fTotEdep * fNbins / fMax << 161   G4int idx = G4lrint(fTotEdep*fNbins/fMaxEnergy);
156                                                << 
157   if (idx < 0) {                               << 
158     fEgas[0] += 1.0;                           << 
159   }                                            << 
160   if (idx >= fNbins) {                         << 
161     fOverflow += 1.0;                          << 
162   }                                            << 
163   else {                                       << 
164     fEgas[idx] += 1.0;                         << 
165   }                                            << 
166                                                   162 
                                                   >> 163   if(idx < 0) { fEgas[0] += 1.0; }
                                                   >> 164   if(idx >= fNbins) { fOverflow += 1.0; }
                                                   >> 165   else { fEgas[idx] += 1.0; }
                                                   >> 166   
167   G4AnalysisManager* analysisManager = G4Analy    167   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
168                                                   168 
169   // fill histo                                   169   // fill histo
170                                                   170 
171   analysisManager->FillH1(1, fTotEdep / GeV, 1 << 171   analysisManager->FillH1(1,fTotEdep/GeV,1.0);
172   fEdep.fill(fTotEdep, 1.0);                      172   fEdep.fill(fTotEdep, 1.0);
173 }                                                 173 }
174                                                   174 
175 //....oooOO0OOooo........oooOO0OOooo........oo    175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 //                                                176 //
177 // Allows one to accumulate data from differen    177 // Allows one to accumulate data from different threads
178                                                   178 
179 void Run::Merge(const G4Run* run)              << 179 void Run::Merge( const G4Run* run )
180 {                                                 180 {
181   const Run* localRun = static_cast<const Run*    181   const Run* localRun = static_cast<const Run*>(run);
182                                                   182 
183   fTotStepGas += localRun->fTotStepGas;        << 183   fTotStepGas  += localRun->fTotStepGas;
184   fOverflow += localRun->fOverflow;            << 184   fOverflow    += localRun->fOverflow;
185                                                   185 
186   G4StatDouble* stat = const_cast<G4StatDouble    186   G4StatDouble* stat = const_cast<G4StatDouble*>(localRun->GetStat());
187                                                   187 
188   fEdep.add(stat);                                188   fEdep.add(stat);
189                                                << 189  
190   for (G4int j = 0; j < fNbins; ++j) {         << 190   for( G4int j = 0; j < fNbins; ++j )
191     fEgas[j] += localRun->fEgas[j];            << 191   {
                                                   >> 192     fEgas[j] += localRun->fEgas[j]; 
192   }                                               193   }
193                                                << 194   
194   G4Run::Merge(run);                              195   G4Run::Merge(run);
195 }                                                 196 }
196                                                   197 
197 //....oooOO0OOooo........oooOO0OOooo........oo    198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
198 //                                                199 //
199 // Is called from TargetSD                        200 // Is called from TargetSD
200                                                   201 
201 void Run::AddEnergy(G4double edep, const G4Ste << 202 void Run::AddEnergy( G4double edep, const G4Step* step )
202 {                                                 203 {
203   if (1 < fVerbose) {                          << 204   if( 1 < fVerbose ) 
204     G4cout << "Run::AddEnergy: e(keV)= " << ed << 205   {
                                                   >> 206     G4cout << "Run::AddEnergy: e(keV)= " << edep/keV
                                                   >> 207            << G4endl;
205   }                                               208   }
206   fTotEdep += edep;                               209   fTotEdep += edep;
207                                                   210 
208   if (step) {                                  << 211   if( step ) 
209     if (1 == step->GetTrack()->GetTrackID()) { << 212   {
210       fStepGas += 1.0;                         << 213     if( 1 == step->GetTrack()->GetTrackID()) 
                                                   >> 214     { 
                                                   >> 215       fStepGas += 1.0; 
211     }                                             216     }
212   }                                               217   }
213 }                                                 218 }
214                                                   219 
215 //....oooOO0OOooo........oooOO0OOooo........oo    220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 221 
216                                                   222