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