Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:34

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 #include "Par03RunAction.hh"
0027 
0028 #include "Par03DetectorConstruction.hh"
0029 
0030 #include "G4AnalysisManager.hh"
0031 
0032 Par03RunAction::Par03RunAction(Par03DetectorConstruction* aDetector)
0033   : G4UserRunAction(), fDetector(aDetector)
0034 {
0035   // Create analysis manager
0036   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0037   analysisManager->SetDefaultFileType("root");
0038 
0039   // Default filename, can be overriden with /analysis/setFileName
0040   analysisManager->SetFileName("Par03Output");
0041 }
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 Par03RunAction::~Par03RunAction() = default;
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 void Par03RunAction::BeginOfRunAction(const G4Run*)
0050 {
0051   // Get detector dimensions
0052   G4int cellNumZ = fDetector->GetNbOfLayers();
0053   G4int cellNumRho = fDetector->GetNbOfRhoCells();
0054   G4double cellSizeZ = fDetector->GetLength() / cellNumZ;
0055   G4double cellSizeRho = fDetector->GetRadius() / cellNumRho;
0056   // Default max value of energy stored in histogram (in GeV)
0057   G4double maxEnergy = 100;
0058 
0059   // Get analysis manager
0060   auto analysisManager = G4AnalysisManager::Instance();
0061 
0062   // Creating control histograms
0063   analysisManager->CreateH1("energyParticle", "Primary energy;E_{MC} (GeV);Entries", 256, 0,
0064                             1.1 * maxEnergy);
0065   analysisManager->CreateH1("energyDeposited", "Deposited energy;E_{MC} (GeV);Entries", 256, 0,
0066                             1.1 * maxEnergy);
0067   analysisManager->CreateH1(
0068     "energyRatio", "Ratio of energy deposited to primary;E_{dep} /  E_{MC};Entries", 1024, 0, 1);
0069   analysisManager->CreateH1("time", "Simulation time; time (s);Entries", 2048, 0, 30);
0070   analysisManager->CreateH1("longProfile", "Longitudinal profile;t (mm);#LTE#GT (MeV)", cellNumZ,
0071                             -0.5 * cellSizeZ, (cellNumZ - 0.5) * cellSizeZ);
0072   analysisManager->CreateH1("transProfile", "Transverse profile;r (mm);#LTE#GT (MeV)", cellNumRho,
0073                             -0.5 * cellSizeRho, (cellNumRho - 0.5) * cellSizeRho);
0074   analysisManager->CreateH1("longFirstMoment",
0075                             "First moment of longitudinal distribution;#LT#lambda#GT (mm);Entries",
0076                             1024, -0.5 * cellSizeZ,
0077                             cellNumZ * cellSizeZ / 2);  // arbitrary scaling of max value on axis
0078   analysisManager->CreateH1("transFirstMoment",
0079                             "First moment of transverse distribution;#LTr#GT "
0080                             "(mm);Entries",
0081                             1024, -0.5 * cellSizeRho,
0082                             cellNumRho * cellSizeRho
0083                               / 10);  // arbitrary scaling of max value on axis
0084   analysisManager->CreateH1(
0085     "longSecondMoment",
0086     "Second moment of longitudinal distribution;#LT#lambda^{2}#GT "
0087     "(mm^{2});Entries",
0088     1024, 0, std::pow(cellNumZ * cellSizeZ, 2) / 25);  // arbitrary scaling of max value on axis
0089   analysisManager->CreateH1(
0090     "transSecondMoment", "Second moment of transverse distribution;#LTr^{2}#GT (mm^{2});Entries",
0091     1024, 0, std::pow(cellNumRho * cellSizeRho, 2) / 25);  // arbitrary scaling of max value on axis
0092   analysisManager->CreateH1("hitType", "hit type;type (0=full, 1= fast);Entries", 2, -0.5, 1.5);
0093 
0094   // Open an output file
0095   analysisManager->OpenFile();
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 void Par03RunAction::EndOfRunAction(const G4Run*)
0101 {
0102   auto analysisManager = G4AnalysisManager::Instance();
0103   analysisManager->Write();
0104   analysisManager->CloseFile();
0105   analysisManager->Clear();
0106 }