G4PSDoseDeposit.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 // GEANT4 tag $Name: geant4-09-04 $
00029 //
00030 // G4PSDoseDeposit
00031 #include "G4PSDoseDeposit.hh"
00032 #include "G4VSolid.hh"
00033 #include "G4VPhysicalVolume.hh"
00034 #include "G4VPVParameterisation.hh"
00035 #include "G4UnitsTable.hh"
00036 
00038 // (Description)
00039 //   This is a primitive scorer class for scoring only energy deposit.
00040 // 
00041 //
00042 // Created: 2005-11-14  Tsukasa ASO, Akinori Kimura.
00043 // 2010-07-22   Introduce Unit specification.
00044 // 
00046 
00047 G4PSDoseDeposit::G4PSDoseDeposit(G4String name, G4int depth)
00048   :G4VPrimitiveScorer(name,depth),HCID(-1)
00049 {
00050     SetUnit("Gy");
00051 }
00052 
00053 G4PSDoseDeposit::G4PSDoseDeposit(G4String name, const G4String& unit,
00054                                  G4int depth)
00055   :G4VPrimitiveScorer(name,depth),HCID(-1)
00056 {
00057     SetUnit(unit);
00058 }
00059 
00060 G4PSDoseDeposit::~G4PSDoseDeposit()
00061 {;}
00062 
00063 G4bool G4PSDoseDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00064 {
00065   G4double edep = aStep->GetTotalEnergyDeposit();
00066   if ( edep == 0. ) return FALSE;
00067 
00068   G4int idx = ((G4TouchableHistory*)
00069                (aStep->GetPreStepPoint()->GetTouchable()))
00070                ->GetReplicaNumber(indexDepth);
00071   G4double cubicVolume = ComputeVolume(aStep, idx);
00072 
00073 
00074   G4double density = aStep->GetTrack()->GetStep()->GetPreStepPoint()->GetMaterial()->GetDensity();
00075   G4double dose    = edep / ( density * cubicVolume );
00076   dose *= aStep->GetPreStepPoint()->GetWeight(); 
00077   G4int  index = GetIndex(aStep);
00078   EvtMap->add(index,dose);  
00079   return TRUE;
00080 }
00081 
00082 void G4PSDoseDeposit::Initialize(G4HCofThisEvent* HCE)
00083 {
00084   EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
00085                                     GetName());
00086   if(HCID < 0) {HCID = GetCollectionID(0);}
00087   HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00088 }
00089 
00090 void G4PSDoseDeposit::EndOfEvent(G4HCofThisEvent*)
00091 {;}
00092 
00093 void G4PSDoseDeposit::clear()
00094 {
00095   EvtMap->clear();
00096 }
00097 
00098 void G4PSDoseDeposit::DrawAll()
00099 {;}
00100 
00101 void G4PSDoseDeposit::PrintAll()
00102 {
00103   G4cout << " MultiFunctionalDet  " << detector->GetName() << G4endl;
00104   G4cout << " PrimitiveScorer " << GetName() << G4endl;
00105   G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00106   std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00107   for(; itr != EvtMap->GetMap()->end(); itr++) {
00108     G4cout << "  copy no.: " << itr->first
00109            << "  dose deposit: " 
00110            << *(itr->second)/GetUnitValue()
00111            << " ["<<GetUnit() <<"]"
00112            << G4endl;
00113   }
00114 }
00115 
00116 void G4PSDoseDeposit::SetUnit(const G4String& unit)
00117 {
00118         CheckAndSetUnit(unit,"Dose");
00119 }
00120 
00121 G4double G4PSDoseDeposit::ComputeVolume(G4Step* aStep, G4int idx){
00122 
00123   G4VPhysicalVolume* physVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
00124   G4VPVParameterisation* physParam = physVol->GetParameterisation();
00125   G4VSolid* solid = 0;
00126   if(physParam)
00127   { // for parameterized volume
00128     if(idx<0)
00129     {
00130       G4ExceptionDescription ED;
00131       ED << "Incorrect replica number --- GetReplicaNumber : " << idx << G4endl;
00132       G4Exception("G4PSDoseDeposit::ComputeVolume","DetPS0004",JustWarning,ED);
00133     }
00134     solid = physParam->ComputeSolid(idx, physVol);
00135     solid->ComputeDimensions(physParam,idx,physVol);
00136   }
00137   else
00138   { // for ordinary volume
00139     solid = physVol->GetLogicalVolume()->GetSolid();
00140   }
00141   
00142   return solid->GetCubicVolume();
00143 }
00144 
00145 
00146 

Generated on Mon May 27 17:49:28 2013 for Geant4 by  doxygen 1.4.7