Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-16 08:08:49

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 //  Author: F. Poignant, floriane.poignant@gmail.com
0027 //
0028 // file STCyclotronRunAction.cc
0029 //
0030 #include "STCyclotronRunAction.hh"
0031 #include "STCyclotronRunActionMessenger.hh"
0032 #include "STCyclotronPrimaryGeneratorAction.hh"
0033 #include "STCyclotronSensitiveTarget.hh"
0034 #include "STCyclotronRun.hh"
0035 #include "STCyclotronDetectorConstruction.hh"
0036 #include "G4AnalysisManager.hh"
0037 #include "G4GeneralParticleSource.hh"
0038 #include "G4UserRunAction.hh"
0039 #include "G4Run.hh"
0040 #include "G4RunManager.hh"
0041 #include "G4LogicalVolumeStore.hh"
0042 #include "G4LogicalVolume.hh"
0043 #include "G4UnitsTable.hh"
0044 #include "G4PhysicalConstants.hh"
0045 #include "G4SystemOfUnits.hh"
0046 
0047 #include <iomanip>
0048 #include <cmath>
0049 
0050 
0051 STCyclotronRunAction::STCyclotronRunAction(STCyclotronDetectorConstruction*)
0052 { 
0053 
0054   //----------------------------------------------
0055   //Set printing event number per each 100 events
0056   //G4RunManager::GetRunManager()->SetPrintProgress(100);
0057   //----------------------------------------------
0058   fMessenger = new STCyclotronRunActionMessenger(this);
0059   fIrradiationTime = 3.; //in hour
0060   fIn = 185; //in mm
0061   fOut = 188; //in mm
0062   
0063   //----------------------------------------------
0064   // Analysis Manager for storage of data in histograms
0065   //----------------------------------------------
0066 
0067   auto analysisManager = G4AnalysisManager::Instance();
0068   analysisManager->SetDefaultFileType("root");
0069   G4cout << "Using " << analysisManager->GetType() << G4endl;
0070   analysisManager->SetVerboseLevel(1);
0071   
0072   //The edges/bin are default value that may be modified in the file 'Macro/init_parameters.mac'
0073   //Create TH1D histograms
0074   analysisManager->CreateH1("H10","Energy of the primary particles when reaching the target (MeV)", 500,12.,19.); //in MeV
0075   analysisManager->CreateH1("H11","Energy of the primary particle when reaching the foil (MeV)",100,12.,19.); //in MeV
0076   analysisManager->CreateH1("H12","Energy spectrum of primaries going out from the target (MeV)", 100, 0., 19.); //in MeV
0077   analysisManager->CreateH1("H13","Energy of the primary particle when going out from the foil (MeV)",100,0,19);
0078   analysisManager->CreateH1("H14","Depth of isotope creation in the target (mm)", 300, fIn, fOut);
0079   analysisManager->CreateH1("H15","Energy spectrum of the positrons created in the target by the beam and secondaries (MeV)", 100, 0., 17.); 
0080   analysisManager->CreateH1("H16","Energy spectrum of the electrons created in the target by the beam and secondaries (MeV)", 100, 0., 17.); //in MeV
0081   analysisManager->CreateH1("H17","Energy spectrum of the gammas created in the target by the beam and secondaries (MeV)", 100, 0., 17.); //in MeV
0082   analysisManager->CreateH1("H18","Energy spectrum of the neutrons created in the target by the beam and secondaries (MeV)", 100, 0., 17.); //in MeV
0083   analysisManager->CreateH1("H19","Energy spectrum of the positrons created in the target by the decay (MeV)", 100, 0., 17.);//, MeV);
0084   analysisManager->CreateH1("H110","Energy spectrum of the electrons created in the target by the decay (MeV)", 100, 0., 17.);
0085   analysisManager->CreateH1("H111","Energy spectrum of the gammas created in the target (MeV) by the decay", 100, 0., 17.);
0086   analysisManager->CreateH1("H112","Energy spectrum of the neutrons created in the target (MeV) by the decay", 100, 0., 17.);
0087   analysisManager->CreateH1("H113","Energy spectrum of the nu_e created in the target (MeV) by the decay", 100, 0., 17.);
0088   analysisManager->CreateH1("H114","Energy spectrum of the anti_nu_e created in the target (MeV) by the decay", 100, 0., 17.);
0089 
0090   //Create TH2D histograms
0091   
0092   analysisManager->CreateH2("H20", "Beam intensity before hiting the target (mm)",100, -7.5 , 7.5, 100, -7.5, 7.5);
0093   analysisManager->CreateH2("H21", "Beam intensity before hiting the foil (mm)",100, -7.5 , 7.5, 100, -7.5, 7.5);
0094   analysisManager->CreateH2("H22", "Radioisotopes produced", 11, 24.5, 35.5, 20, 54.5, 74.5);
0095   analysisManager->CreateH2("H23", "Energy (MeV) = f(depth (mm))", 100, fIn, fOut,100,0.,16.);
0096   analysisManager->CreateH2("H24", "Beam intensity going out from the target (mm)",100, -7.5 , 7.5, 100, -7.5, 7.5);
0097   analysisManager->CreateH2("H25", "Beam intensity going out from the foil (mm)", 100, -7.5 , 7.5, 100, -7.5, 7.5);
0098 }
0099 
0100 STCyclotronRunAction::~STCyclotronRunAction()
0101 {
0102   delete fMessenger;
0103 }
0104 
0105 G4Run* STCyclotronRunAction::GenerateRun()
0106 { 
0107   fRun = new STCyclotronRun();
0108   return fRun;
0109 }
0110 
0111 void STCyclotronRunAction::BeginOfRunAction(const G4Run*)
0112 { 
0113   //----------------------------------------------
0114   //     Inform the runManager to save random number seed
0115   //----------------------------------------------
0116   G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0117   auto analysisManager = G4AnalysisManager::Instance();
0118   analysisManager->OpenFile("SolidTargetCyclotron");
0119 }
0120 
0121 void STCyclotronRunAction::EndOfRunAction(const G4Run*)
0122 {
0123   if(isMaster)fRun->EndOfRun(fIrradiationTime);
0124   auto analysisManager = G4AnalysisManager::Instance();
0125   analysisManager->Write();
0126   analysisManager->CloseFile();
0127  
0128 }
0129 
0130 void STCyclotronRunAction::SetIrradiationTime(G4double time)
0131 {
0132   if(fIrradiationTime != time){
0133     fIrradiationTime = time;
0134     G4cout << "The time of irradiation is now the following : " << fIrradiationTime << " hour(s)." << G4endl;
0135   }
0136 }