G4PSCellCharge.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 // $Id$
00027 //
00028 // G4PSCellCharge
00029 #include "G4PSCellCharge.hh"
00030 #include "G4Track.hh"
00031 
00032 
00034 // (Description)
00035 //   This is a primitive scorer class for scoring cell charge.
00036 //   The Cell Charge is defined by  a sum of deposited charge inside the cell.
00037 //
00038 // Created: 2006-08-20  Tsukasa ASO
00039 // 2010-07-22   Introduce Unit specification.
00040 // 
00042 
00043 G4PSCellCharge::G4PSCellCharge(G4String name, G4int depth)
00044     :G4VPrimitiveScorer(name,depth),HCID(-1)
00045 {
00046     SetUnit("e+");
00047 }
00048 
00049 G4PSCellCharge::G4PSCellCharge(G4String name, const G4String& unit, 
00050                                G4int depth)
00051     :G4VPrimitiveScorer(name,depth),HCID(-1)
00052 {
00053     SetUnit(unit);
00054 }
00055 
00056 G4PSCellCharge::~G4PSCellCharge()
00057 {;}
00058 
00059 G4bool G4PSCellCharge::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00060 {
00061 
00062     // Enter or First step of primary.
00063     if( aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary 
00064         || ( aStep->GetTrack()->GetParentID() == 0 &&
00065              aStep->GetTrack()->GetCurrentStepNumber() == 1 ) ){
00066         G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
00067         CellCharge *= aStep->GetPreStepPoint()->GetWeight();
00068         G4int index = GetIndex(aStep);
00069         EvtMap->add(index,CellCharge);
00070     }
00071 
00072     // Exit
00073     if( aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary){
00074         G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
00075         CellCharge *= aStep->GetPreStepPoint()->GetWeight();
00076         G4int index = GetIndex(aStep);
00077         CellCharge *= -1.0;
00078         EvtMap->add(index,CellCharge);
00079     }
00080 
00081   return TRUE;
00082 }
00083 
00084 void G4PSCellCharge::Initialize(G4HCofThisEvent* HCE)
00085 {
00086   EvtMap = new G4THitsMap<G4double>(detector->GetName(),
00087                                     GetName());
00088   if ( HCID < 0 ) HCID = GetCollectionID(0);
00089   HCE->AddHitsCollection(HCID,EvtMap);
00090 }
00091 
00092 void G4PSCellCharge::EndOfEvent(G4HCofThisEvent*)
00093 {;}
00094 
00095 void G4PSCellCharge::clear(){
00096   EvtMap->clear();
00097 }
00098 
00099 void G4PSCellCharge::DrawAll()
00100 {;}
00101 
00102 void G4PSCellCharge::PrintAll()
00103 {
00104   G4cout << " MultiFunctionalDet  " << detector->GetName() << G4endl;
00105   G4cout << " PrimitiveScorer " << GetName() <<G4endl; 
00106   G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00107   std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00108   for(; itr != EvtMap->GetMap()->end(); itr++) {
00109     G4cout << "  copy no.: " << itr->first
00110            << "  cell charge : " << *(itr->second)/GetUnitValue()
00111            << " [" << GetUnit() << "]"
00112            << G4endl;
00113   }
00114 }
00115 
00116 void G4PSCellCharge::SetUnit(const G4String& unit)
00117 {
00118     CheckAndSetUnit(unit,"Electric charge");
00119 }
00120 
00121 

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