Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Previous authors: G. Guerrieri, S. Guatelli and M. G. Pia, INFN Genova, Italy
0027 // Authors (since 2007): S. Guatelli, University of Wollongong, Australia
0028 //
0029 
0030 #include "G4HumanPhantomRunAction.hh"
0031 #include "G4HumanPhantomAnalysisManager.hh"
0032 #include "G4SystemOfUnits.hh"
0033 #include "G4UnitsTable.hh"
0034 #include "G4ios.hh"
0035 #include "G4Run.hh"
0036 
0037 G4HumanPhantomRunAction::G4HumanPhantomRunAction(G4HumanPhantomAnalysisManager* analysis) :fAnalysisMan(analysis)
0038  { }
0039 
0040 G4HumanPhantomRunAction::~G4HumanPhantomRunAction()
0041 {}
0042 
0043 void G4HumanPhantomRunAction::BeginOfRunAction(const G4Run* aRun)
0044 {
0045  G4int run_number = aRun->GetRunID();
0046  G4cout << "### Run " << run_number << " start." << G4endl;
0047  fEnergyTotal["logicalHead"]=0.;
0048  fEnergyTotal["logicalTrunk"]=0.;
0049  fEnergyTotal["logicalLeftLeg"]=0.;
0050  fEnergyTotal["logicalRightLeg"]=0.;
0051  fEnergyTotal["logicalSkull"]=0.;
0052  fEnergyTotal["logicalLeftArmBone"]=0.;
0053  fEnergyTotal["logicalRightArmBone"]=0.;
0054  fEnergyTotal["logicalUpperSpine"]=0.;
0055  fEnergyTotal["logicalMiddleLowerSpine"]=0.;
0056  fEnergyTotal["logicalPelvis"]=0.;
0057  fEnergyTotal["logicalRibCage"]=0.;
0058  fEnergyTotal["logicalLeftClavicle"]=0.;
0059  fEnergyTotal["logicalRightClavicle"]=0.;
0060  fEnergyTotal["logicalLeftLegBone"]=0.;
0061  fEnergyTotal["logicalRightLegBone"]=0.;
0062  fEnergyTotal["logicalLeftScapula"]=0.; 
0063  fEnergyTotal["logicalRightScapula"]=0.;
0064  fEnergyTotal["logicalHeart"]=0.;
0065  fEnergyTotal["logicalThyroid"]=0.;
0066  fEnergyTotal["logicalThymus"]=0.;
0067  fEnergyTotal["logicalMaleGenitalia"]=0.;
0068  fEnergyTotal["logicalBrain"]=0.;
0069  fEnergyTotal["logicalStomach"]=0.;
0070  fEnergyTotal["logicalUpperLargeIntestine"]=0.;
0071  fEnergyTotal["logicalLowerLargeIntestine"]=0.;
0072  fEnergyTotal["logicalSmallIntestine"]=0;
0073  fEnergyTotal["logicalSpleen"]=0.;
0074  fEnergyTotal["logicalPancreas"]=0.;
0075  fEnergyTotal["logicalLeftKidney"]=0.;
0076  fEnergyTotal["logicalRightKidney"]=0.;
0077  fEnergyTotal["logicalUrinaryBladder"]=0.;
0078  fEnergyTotal["logicalUterus"]=0.;
0079  fEnergyTotal["logicalLeftLung"]=0.;
0080  fEnergyTotal["logicalRightLung"]=0.;
0081  fEnergyTotal["logicalLeftOvary"]=0.;
0082  fEnergyTotal["logicalRightOvary"]=0.;
0083  fEnergyTotal["logicalLeftTeste"]=0;
0084  fEnergyTotal["logicalRightTeste"]=0;
0085  fEnergyTotal["logicalLeftBreast"]=0.;
0086  fEnergyTotal["logicalRightBreast"]=0.; 
0087  fEnergyTotal["logicalLeftAdrenal"]=0.; 
0088  fEnergyTotal["logicalRightAdrenal"]=0.;
0089 
0090  // Create ROOT file, histograms and ntuple
0091  fAnalysisMan -> book();
0092 }
0093 
0094 void G4HumanPhantomRunAction::EndOfRunAction(const G4Run* aRun)
0095 {
0096   G4cout << "Number of events = " << aRun->GetNumberOfEvent() << G4endl;
0097   totalRunEnergyDeposit();
0098 
0099 // Close the output ROOT file with the results
0100    fAnalysisMan -> save(); 
0101 }
0102 
0103 void G4HumanPhantomRunAction::Fill(G4String bName, 
0104                       G4double energyDeposit)
0105 {
0106  fEnergyTotal[bName] += energyDeposit;
0107 }
0108 
0109 void G4HumanPhantomRunAction::totalRunEnergyDeposit() 
0110 {
0111  std::map<std::string,G4double>::iterator i = fEnergyTotal.begin();
0112   std::map<std::string,G4double>::iterator end = fEnergyTotal.end();
0113 
0114   G4double totalEnergyDepositInPhantom =0.;
0115   G4int k=0;
0116   while(i!=end)
0117     {
0118       G4String bodypart = i->first;
0119       G4double energyDep = i->second;
0120       //  if(energyDep != 0.)
0121       //    {
0122      
0123       G4cout << "Energy Total in Run:" << bodypart << ", ID: "  << k 
0124              << ", Energy Deposition (MeV): "  
0125          << energyDep/MeV
0126          << G4endl;
0127 
0128      // Fill Ntuple
0129      fAnalysisMan -> FillNtupleWithEnergyDeposition(k, energyDep/MeV);
0130 
0131      i++;
0132      k++;
0133 
0134      totalEnergyDepositInPhantom += energyDep;
0135     }
0136   
0137  G4cout << "Total Energy deposit in the body is: " 
0138     << totalEnergyDepositInPhantom/MeV << " MeV" <<G4endl; 
0139 }