source: trunk/source/digits_hits/scorer/src/G4PSTrackCounter.cc@ 1181

Last change on this file since 1181 was 1012, checked in by garnier, 17 years ago

update

File size: 4.2 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4PSTrackCounter.cc,v 1.1 2007/07/11 01:31:03 asaim Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// G4PSTrackCounter
31#include "G4PSTrackCounter.hh"
32
33
34///////////////////////////////////////////////////////////////////////////////
35// (Description)
36// This is a primitive scorer class for scoring number of tracks in a cell.
37//
38// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
39//
40///////////////////////////////////////////////////////////////////////////////
41
42G4PSTrackCounter::G4PSTrackCounter(G4String name, G4int direction, G4int depth)
43 :G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction),weighted(false)
44{;}
45
46G4PSTrackCounter::~G4PSTrackCounter()
47{;}
48
49G4bool G4PSTrackCounter::ProcessHits(G4Step* aStep,G4TouchableHistory*)
50{
51
52 G4StepPoint* preStep = aStep->GetPreStepPoint();
53 G4StepPoint* posStep = aStep->GetPostStepPoint();
54 G4bool IsEnter = preStep->GetStepStatus()==fGeomBoundary;
55 G4bool IsExit = posStep->GetStepStatus()==fGeomBoundary;
56
57 // Regular : count in prestep volume.
58 G4int index = GetIndex(aStep);
59
60 // G4cout << " trk " << aStep->GetTrack()->GetTrackID()
61 // << " index " << index << " In " << IsEnter << " Out " <<IsExit
62 // << " PreStatus " << preStep->GetStepStatus()
63 // << " PostStatus " << posStep->GetStepStatus()
64 // << " w " << aStep->GetPreStepPoint()->GetWeight()
65 // << G4endl;
66
67 G4bool flag = FALSE;
68
69 if ( IsEnter && fDirection == fCurrent_In ) flag = TRUE;
70 else if ( IsExit && fDirection == fCurrent_Out ) flag = TRUE;
71 else if ( (IsExit||IsEnter) && fDirection == fCurrent_InOut ) flag = TRUE;
72
73 if ( flag ){
74 //G4cout << " Count " << G4endl;
75 G4double val = 1.0;
76 if(weighted) val *= aStep->GetPreStepPoint()->GetWeight();
77 EvtMap->add(index,val);
78 }
79
80 return TRUE;
81}
82
83void G4PSTrackCounter::Initialize(G4HCofThisEvent* HCE)
84{
85 EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
86 if(HCID < 0) {HCID = GetCollectionID(0);}
87 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
88 //G4cout << "----- PS Initialize " << G4endl;
89}
90
91void G4PSTrackCounter::EndOfEvent(G4HCofThisEvent*)
92{;}
93
94void G4PSTrackCounter::clear(){
95 EvtMap->clear();
96}
97
98void G4PSTrackCounter::DrawAll()
99{;}
100
101void G4PSTrackCounter::PrintAll()
102{
103 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
104 G4cout << " PrimitiveScorer " << GetName() << G4endl;
105 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
106 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
107 for(; itr != EvtMap->GetMap()->end(); itr++) {
108 G4cout << " copy no.: " << itr->first
109 << " track count: " << *(itr->second)
110 << G4endl;
111 }
112}
Note: See TracBrowser for help on using the repository browser.