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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/electromagnetic/TestEm2/src/RunAction.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm2/src/RunAction.cc (Version 10.2.p3)


  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 electromagnetic/TestEm2/src/RunActio     26 /// \file electromagnetic/TestEm2/src/RunAction.cc
 27 /// \brief Implementation of the RunAction cla     27 /// \brief Implementation of the RunAction class
 28 //                                                 28 //
 29 //                                             <<  29 // $Id: RunAction.cc 83431 2014-08-21 15:49:56Z gcosmo $
                                                   >>  30 // 
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32                                                    33 
 33 #include "RunAction.hh"                            34 #include "RunAction.hh"
 34                                                    35 
 35 #include "DetectorConstruction.hh"                 36 #include "DetectorConstruction.hh"
 36 #include "EmAcceptance.hh"                     << 
 37 #include "PrimaryGeneratorAction.hh"               37 #include "PrimaryGeneratorAction.hh"
 38 #include "Run.hh"                              << 
 39 #include "RunActionMessenger.hh"                   38 #include "RunActionMessenger.hh"
                                                   >>  39 #include "Run.hh"
                                                   >>  40 #include "EmAcceptance.hh"
 40                                                    41 
 41 #include "G4Run.hh"                                42 #include "G4Run.hh"
 42 #include "G4RunManager.hh"                         43 #include "G4RunManager.hh"
 43 #include "G4SystemOfUnits.hh"                      44 #include "G4SystemOfUnits.hh"
                                                   >>  45 
 44 #include "Randomize.hh"                            46 #include "Randomize.hh"
 45                                                    47 
 46 //....oooOO0OOooo........oooOO0OOooo........oo     48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 47                                                    49 
 48 RunAction::RunAction(DetectorConstruction* det <<  50 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
                                                   >>  51  :G4UserRunAction(),
                                                   >>  52   fDet(det),fKin(kin),fRunMessenger(0), fAnalysisManager(0),fRun(0),
                                                   >>  53   fVerbose(0), fEdeptrue(1.), fRmstrue(1.), fLimittrue(DBL_MAX)
 49 {                                                  54 {
 50   fRunMessenger = new RunActionMessenger(this)     55   fRunMessenger = new RunActionMessenger(this);
 51                                                <<  56   fHistoName[0] = "testem2";
 52   // Create analysis manager                   << 
 53   // The choice of analysis technology is done << 
 54   fAnalysisManager = G4AnalysisManager::Instan << 
 55   fAnalysisManager->SetDefaultFileType("root") << 
 56                                                << 
 57   // Set the default file name "testem2"       << 
 58   // which can be then redefine in a macro via << 
 59   fAnalysisManager->SetFileName("testem2");    << 
 60 }                                                  57 }
 61                                                    58 
 62 //....oooOO0OOooo........oooOO0OOooo........oo     59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 63                                                    60 
 64 RunAction::~RunAction()                            61 RunAction::~RunAction()
 65 {                                                  62 {
 66   delete fRunMessenger;                            63   delete fRunMessenger;
 67 }                                                  64 }
 68                                                    65 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    67 
 71 void RunAction::BookHisto()                        68 void RunAction::BookHisto()
 72 {                                                  69 {
 73   // Get analysis manager                      <<  70   // Create analysis manager
 74   fAnalysisManager = G4AnalysisManager::Instan <<  71   // The choice of analysis technology is done via selection of a namespace
                                                   >>  72   //
 75                                                    73 
                                                   >>  74   fAnalysisManager = G4AnalysisManager::Instance();
                                                   >>  75     
 76   // Open an output file                           76   // Open an output file
 77   fAnalysisManager->OpenFile();                <<  77   //
                                                   >>  78   ///fHistoName[0] = "testem2";
                                                   >>  79 
                                                   >>  80   fAnalysisManager->OpenFile(fHistoName[0]); 
                                                   >>  81 
 78   fAnalysisManager->SetVerboseLevel(1);            82   fAnalysisManager->SetVerboseLevel(1);
                                                   >>  83   G4String extension = fAnalysisManager->GetFileType();
                                                   >>  84   fHistoName[1] = fHistoName[0] + "." + extension;  
 79                                                    85 
 80   // Creating histograms                           86   // Creating histograms
 81   //                                               87   //
 82   G4double Ekin = fKin->GetParticleGun()->GetP     88   G4double Ekin = fKin->GetParticleGun()->GetParticleEnergy();
 83   G4int nLbin = fDet->GetnLtot();              <<  89   G4int    nLbin = fDet->GetnLtot();
 84   G4int nRbin = fDet->GetnRtot();              <<  90   G4int    nRbin = fDet->GetnRtot();
 85   G4double dLradl = fDet->GetdLradl();             91   G4double dLradl = fDet->GetdLradl();
 86   G4double dRradl = fDet->GetdRradl();             92   G4double dRradl = fDet->GetdRradl();
                                                   >>  93   
                                                   >>  94   fAnalysisManager->SetFirstHistoId(1);   
                                                   >>  95   fAnalysisManager->CreateH1( "h1","total energy deposit(percent of Einc)",
                                                   >>  96                                   110,0.,110.);
                                                   >>  97 
                                                   >>  98   fAnalysisManager->CreateH1( "h2","total charged tracklength (radl)",
                                                   >>  99                                   110,0.,110.*Ekin/GeV);
                                                   >> 100 
                                                   >> 101   fAnalysisManager->CreateH1( "h3","total neutral tracklength (radl)",
                                                   >> 102                                   110,0.,1100.*Ekin/GeV);
                                                   >> 103 
                                                   >> 104   fAnalysisManager->CreateH1( "h4","longit energy profile (% of E inc)",
                                                   >> 105                                     nLbin,0.,nLbin*dLradl);
                                                   >> 106                                     
                                                   >> 107   fAnalysisManager->CreateP1( "p4","longit energy profile (% of E inc)",
                                                   >> 108                                     nLbin,0.,nLbin*dLradl, 0., 1000.);
                                                   >> 109                                     
                                                   >> 110   fAnalysisManager->CreateH1( "h5","rms on longit Edep (% of E inc)",
                                                   >> 111                                     nLbin,0.,nLbin*dLradl);
                                                   >> 112 
                                                   >> 113   G4double Zmin=0.5*dLradl, Zmax=Zmin+nLbin*dLradl;
                                                   >> 114   fAnalysisManager->CreateH1( "h6","cumul longit energy dep (% of E inc)",
                                                   >> 115                                   nLbin,Zmin,Zmax);                          
                                                   >> 116                                     
                                                   >> 117   fAnalysisManager->CreateH1( "h7","rms on cumul longit Edep (% of E inc)",
                                                   >> 118                                   nLbin,Zmin,Zmax);
                                                   >> 119 
                                                   >> 120   fAnalysisManager->CreateH1( "h8","radial energy profile (% of E inc)",
                                                   >> 121                                   nRbin,0.,nRbin*dRradl);
                                                   >> 122                                   
                                                   >> 123   fAnalysisManager->CreateP1( "p8","radial energy profile (% of E inc)",
                                                   >> 124                                   nRbin,0.,nRbin*dRradl, 0., 1000.);
                                                   >> 125                                   
                                                   >> 126   fAnalysisManager->CreateH1( "h9","rms on radial Edep (% of E inc)",
                                                   >> 127                                   nRbin,0.,nRbin*dRradl);            
                                                   >> 128 
                                                   >> 129   G4double Rmin=0.5*dRradl, Rmax=Rmin+nRbin*dRradl;
                                                   >> 130   fAnalysisManager->CreateH1("h10","cumul radial energy dep (% of E inc)",
                                                   >> 131                                   nRbin,Rmin,Rmax);
                                                   >> 132 
                                                   >> 133   fAnalysisManager->CreateH1("h11","rms on cumul radial Edep (% of E inc)",
                                                   >> 134                                   nRbin,Rmin,Rmax);                    
                                                   >> 135                                     
                                                   >> 136   G4cout << "\n----> Histogram file is opened in " << fHistoName[1] << G4endl;
                                                   >> 137 }
 87                                                   138 
 88   fAnalysisManager->SetFirstHistoId(1);        << 139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 89   fAnalysisManager->CreateH1("h1", "total ener << 
 90                                                << 
 91   fAnalysisManager->CreateH1("h2", "total char << 
 92                                                << 
 93   fAnalysisManager->CreateH1("h3", "total neut << 
 94                                                << 
 95   fAnalysisManager->CreateH1("h4", "longit ene << 
 96                                                << 
 97   fAnalysisManager->CreateP1("p4", "longit ene << 
 98                              0., 1000.);       << 
 99                                                << 
100   fAnalysisManager->CreateH1("h5", "rms on lon << 
101                                                << 
102   G4double Zmin = 0.5 * dLradl, Zmax = Zmin +  << 
103   fAnalysisManager->CreateH1("h6", "cumul long << 
104                                                << 
105   fAnalysisManager->CreateH1("h7", "rms on cum << 
106                                                << 
107   fAnalysisManager->CreateH1("h8", "radial ene << 
108                                                << 
109   fAnalysisManager->CreateP1("p8", "radial ene << 
110                              0., 1000.);       << 
111                                                << 
112   fAnalysisManager->CreateH1("h9", "rms on rad << 
113                                                << 
114   G4double Rmin = 0.5 * dRradl, Rmax = Rmin +  << 
115   fAnalysisManager->CreateH1("h10", "cumul rad << 
116                                                << 
117   fAnalysisManager->CreateH1("h11", "rms on cu << 
118                                                   140 
119   G4String fileName = fAnalysisManager->GetFil << 141 void RunAction::SetHistoName(G4String& val)
120   G4String extension = fAnalysisManager->GetFi << 142 {
121   G4String fullFileName = fileName + "." + ext << 143   fHistoName[0] = val;
122   G4cout << "\n----> Histogram file is opened  << 
123 }                                                 144 }
124                                                   145 
125 //....oooOO0OOooo........oooOO0OOooo........oo    146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126                                                   147 
127 G4Run* RunAction::GenerateRun()                   148 G4Run* RunAction::GenerateRun()
128 {                                              << 149 { 
129   fRun = new Run(fDet, fKin);                  << 150   fRun = new Run(fDet, fKin); 
130   fRun->SetVerbose(fVerbose);                     151   fRun->SetVerbose(fVerbose);
131   return fRun;                                    152   return fRun;
132 }                                                 153 }
133                                                   154 
134 //....oooOO0OOooo........oooOO0OOooo........oo    155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135                                                   156 
136 void RunAction::BeginOfRunAction(const G4Run*)    157 void RunAction::BeginOfRunAction(const G4Run*)
137 {                                                 158 {
138   // show Rndm status                             159   // show Rndm status
139   if (isMaster) G4Random::showEngineStatus();  << 160   if (isMaster) G4Random::showEngineStatus(); 
140                                                   161 
141   // histograms                                << 162   //histograms
142   //                                              163   //
143   BookHisto();                                    164   BookHisto();
144 }                                                 165 }
145                                                   166 
146 //....oooOO0OOooo........oooOO0OOooo........oo    167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147                                                   168 
148 void RunAction::EndOfRunAction(const G4Run*)      169 void RunAction::EndOfRunAction(const G4Run*)
149 {                                                 170 {
150   // compute and print statistic               << 171  //compute and print statistic
151   //                                           << 172  //
152   if (isMaster) fRun->EndOfRun(fEdeptrue, fRms << 173  if (isMaster) fRun->EndOfRun(fEdeptrue, fRmstrue, fLimittrue);    
153                                                << 174 
154   // show Rndm status                          << 175  // show Rndm status
155   if (isMaster) G4Random::showEngineStatus();  << 176  if (isMaster) G4Random::showEngineStatus();
156                                                << 177 
157   // save histos and close analysis            << 178  // save histos and close analysis
158   fAnalysisManager->Write();                   << 179  fAnalysisManager->Write();
159   fAnalysisManager->CloseFile();               << 180  fAnalysisManager->CloseFile(); 
160   fAnalysisManager->Clear();                   << 
161 }                                                 181 }
162                                                   182 
163 //....oooOO0OOooo........oooOO0OOooo........oo    183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164                                                   184 
165 void RunAction::SetEdepAndRMS(G4ThreeVector Va    185 void RunAction::SetEdepAndRMS(G4ThreeVector Value)
166 {                                                 186 {
167   fEdeptrue = Value(0);                           187   fEdeptrue = Value(0);
168   fRmstrue = Value(1);                         << 188   fRmstrue  = Value(1);
169   fLimittrue = Value(2);                       << 189   fLimittrue= Value(2);
170 }                                                 190 }
171 //....oooOO0OOooo........oooOO0OOooo........oo    191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172                                                   192 
173 void RunAction::SetVerbose(G4int val)          << 193 void RunAction::SetVerbose(G4int val)  
174 {                                                 194 {
175   fVerbose = val;                                 195   fVerbose = val;
176   if (fRun) fRun->SetVerbose(val);                196   if (fRun) fRun->SetVerbose(val);
177 }                                                 197 }
178                                                << 198      
179 //....oooOO0OOooo........oooOO0OOooo........oo    199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180                                                   200