Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:26

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