Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file exoticphysics/monopole/src/RunAction.cc
0027 /// \brief Implementation of the RunAction class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "RunAction.hh"
0034 
0035 #include "DetectorConstruction.hh"
0036 #include "PrimaryGeneratorAction.hh"
0037 #include "Run.hh"
0038 #include "RunActionMessenger.hh"
0039 
0040 #include "G4AnalysisManager.hh"
0041 #include "G4EmCalculator.hh"
0042 #include "G4ProductionCutsTable.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4UnitsTable.hh"
0045 #include "G4ios.hh"
0046 #include "Randomize.hh"
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
0051   : fDetector(det), fKinematic(kin)
0052 {
0053   fMessenger = new RunActionMessenger(this);
0054   fBinLength = 5 * CLHEP::mm;
0055   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0056   analysisManager->SetFileName("monopole.root");
0057   analysisManager->SetVerboseLevel(1);
0058   analysisManager->SetActivation(true);
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 RunAction::~RunAction()
0064 {
0065   if (isMaster && G4Threading::IsMultithreadedApplication()) delete fKinematic;
0066 
0067   delete fMessenger;
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 G4Run* RunAction::GenerateRun()
0073 {
0074   fRun = new Run(fDetector, fKinematic);
0075   return fRun;
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 void RunAction::BeginOfRunAction(const G4Run* aRun)
0081 {
0082   // Dump production cuts
0083   G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples();
0084 
0085   G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
0086   // histograms
0087   //
0088   Book();
0089 }
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 
0093 void RunAction::EndOfRunAction(const G4Run*)
0094 {
0095   // print Run summary
0096   //
0097   if (isMaster) fRun->EndOfRun(fBinLength);
0098 
0099   // save histograms
0100   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0101   if (analysisManager->IsActive()) {
0102     analysisManager->Write();
0103     analysisManager->CloseFile();
0104     analysisManager->Clear();
0105   }
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 void RunAction::SetBinSize(G4double size)
0111 {
0112   fBinLength = size;
0113   if (fBinLength > fDetector->GetMaxStepSize()) {
0114     fBinLength = fDetector->GetMaxStepSize();
0115   }
0116 }
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0119 
0120 void RunAction::Book()
0121 {
0122   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0123   analysisManager->SetFirstHistoId(1);
0124 
0125   G4double length = fDetector->GetAbsorSizeX();
0126   G4int nbBins = G4lrint(length / fBinLength);
0127 
0128   // Create histograms
0129   analysisManager->CreateH1("h1", "Edep (MeV/mm) along absorber (mm)", nbBins, 0, length);
0130   analysisManager->CreateH1("h2", "Total DEDX (MeV/mm) of proton", 100, -3., 7.);
0131   analysisManager->CreateH1("h3", "Total DEDX (MeV/mm) of monopole", 100, -3., 7.);
0132   analysisManager->CreateH1("h4", "Range(mm) of proton", 100, -3., 7., "mm");
0133   analysisManager->CreateH1("h5", "Range(mm) of monopole", 100, -3., 7., "mm");
0134   analysisManager->CreateH1("h6", "Restricted DEDX (MeV/mm) of proton", 100, -3., 7.);
0135   analysisManager->CreateH1("h7", "Restricted DEDX (MeV/mm) of monopole", 100, -3., 7.);
0136   analysisManager->CreateH1("h8", "Delta-electron x-section (1/mm) of proton", 100, -3., 7., "mm");
0137   analysisManager->CreateH1("h9", "Delta-electron x-section (1/mm) of monopole", 100, -3., 7.,
0138                             "mm");
0139   analysisManager->OpenFile();
0140 }
0141 
0142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......