00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "G4PSPassageCellCurrent.hh"
00031 #include "G4StepStatus.hh"
00032 #include "G4Track.hh"
00033 #include "G4VSolid.hh"
00034 #include "G4UnitsTable.hh"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00046
00047 G4PSPassageCellCurrent::G4PSPassageCellCurrent(G4String name, G4int depth)
00048 :G4VPrimitiveScorer(name,depth),HCID(-1),fCurrentTrkID(-1),fCurrent(0),
00049 weighted(true)
00050 {
00051 SetUnit("");
00052 }
00053
00054 G4PSPassageCellCurrent::~G4PSPassageCellCurrent()
00055 {;}
00056
00057 G4bool G4PSPassageCellCurrent::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00058 {
00059
00060 if ( IsPassed(aStep) ) {
00061 if(weighted) fCurrent = aStep->GetPreStepPoint()->GetWeight();
00062 G4int index = GetIndex(aStep);
00063 EvtMap->add(index,fCurrent);
00064 }
00065
00066 return TRUE;
00067 }
00068
00069 G4bool G4PSPassageCellCurrent::IsPassed(G4Step* aStep){
00070 G4bool Passed = FALSE;
00071
00072 G4bool IsEnter = aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary;
00073 G4bool IsExit = aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary;
00074
00075 G4int trkid = aStep->GetTrack()->GetTrackID();
00076
00077 if ( IsEnter &&IsExit ){
00078 Passed = TRUE;
00079 }else if ( IsEnter ){
00080 fCurrentTrkID = trkid;
00081 }else if ( IsExit ){
00082 if ( fCurrentTrkID == trkid ) {
00083 Passed = TRUE;
00084 }
00085 }else{
00086 if ( fCurrentTrkID == trkid ){
00087 }
00088 }
00089 return Passed;
00090 }
00091
00092 void G4PSPassageCellCurrent::Initialize(G4HCofThisEvent* HCE)
00093 {
00094 fCurrentTrkID = -1;
00095
00096 EvtMap = new G4THitsMap<G4double>(detector->GetName(),
00097 GetName());
00098 if ( HCID < 0 ) HCID = GetCollectionID(0);
00099 HCE->AddHitsCollection(HCID,EvtMap);
00100
00101 }
00102
00103 void G4PSPassageCellCurrent::EndOfEvent(G4HCofThisEvent*)
00104 {
00105 }
00106
00107 void G4PSPassageCellCurrent::clear(){
00108 EvtMap->clear();
00109 }
00110
00111 void G4PSPassageCellCurrent::DrawAll()
00112 {;}
00113
00114 void G4PSPassageCellCurrent::PrintAll()
00115 {
00116 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
00117 G4cout << " PrimitiveScorer " << GetName() <<G4endl;
00118 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00119 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00120 for(; itr != EvtMap->GetMap()->end(); itr++) {
00121 G4cout << " copy no.: " << itr->first
00122 << " cell current : " << *(itr->second)
00123 << " [tracks] "
00124 << G4endl;
00125 }
00126 }
00127
00128 void G4PSPassageCellCurrent::SetUnit(const G4String& unit)
00129 {
00130 if (unit == "" ){
00131 unitName = unit;
00132 unitValue = 1.0;
00133 }else{
00134 G4String msg = "Invalid unit ["+unit+"] (Current unit is [" +GetUnit()+"] ) for " + GetName();
00135 G4Exception("G4PSPassageCellCurrent::SetUnit","DetPS0012",JustWarning,msg);
00136 }
00137 }
00138
00139