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 #include "G4HumanPhantomEventAction.hh"
0030 #include "G4HumanPhantomHit.hh"
0031 #include "G4Event.hh"
0032 #include "G4EventManager.hh"
0033 #include "G4ios.hh"
0034 #include "G4SDManager.hh"
0035 #include "G4UnitsTable.hh"
0036 #include "G4HumanPhantomRunAction.hh"
0037 #include "G4RunManager.hh"
0038 
0039 G4HumanPhantomEventAction::G4HumanPhantomEventAction():
0040 fHitCollectionID(-1)
0041 { 
0042  
0043 }
0044 
0045 void G4HumanPhantomEventAction::BeginOfEventAction(const G4Event*)
0046 {
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  G4SDManager * SDman = G4SDManager::GetSDMpointer();  
0091 
0092   if (fHitCollectionID==-1) {
0093     fHitCollectionID = SDman->GetCollectionID("HumanPhantomCollection");
0094   }
0095 }
0096  
0097 void G4HumanPhantomEventAction::EndOfEventAction(const G4Event* evt)
0098 {  
0099 
0100  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0101  
0102  G4HumanPhantomHitsCollection* HC = nullptr;
0103 
0104  if (HCE)
0105      HC = (G4HumanPhantomHitsCollection*)(HCE->GetHC(fHitCollectionID));
0106 
0107  if (HC)
0108     {
0109       G4int hitNumber = HC->entries();
0110           G4double edep =0;
0111           G4String bodyPart;
0112           for (G4int i=0;i<hitNumber;i++) 
0113         {
0114           edep = (*HC)[i]->GetEdep();
0115           bodyPart = (*HC)[i]->GetBodyPartID();
0116               Fill(bodyPart, edep);
0117           //          if(edep !=0.) G4cout << bodyPart <<": "<< edep/MeV << G4endl; 
0118         }
0119     }
0120 
0121  totalEventEnergyDeposit();
0122 }
0123 
0124 void G4HumanPhantomEventAction:: Fill(G4String bName, 
0125                       G4double energyDeposit)
0126 
0127 {
0128  fEnergyTotal[bName] += energyDeposit;
0129 }
0130 
0131 void G4HumanPhantomEventAction::totalEventEnergyDeposit() 
0132 {
0133 
0134  G4RunManager* runManager = G4RunManager::GetRunManager();
0135  auto* pointerRun = (G4HumanPhantomRunAction*)(runManager->GetUserRunAction());
0136 
0137  std::map<std::string,G4double>::iterator i = fEnergyTotal.begin();
0138   std::map<std::string,G4double>::iterator end = fEnergyTotal.end();
0139 
0140   while(i!=end)
0141     {
0142 
0143       G4String bodypart = i->first;
0144       G4double energyDep = i->second;
0145       
0146       if(energyDep != 0.)
0147     {
0148       pointerRun->Fill(bodypart, energyDep);
0149     }
0150       i++;
0151     }
0152   
0153 }