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: G4PSTrackLength.cc,v 1.1 2007/07/11 01:31:03 asaim Exp $ |
---|
28 | // GEANT4 tag $Name: HEAD $ |
---|
29 | // |
---|
30 | // G4PSTrackLength |
---|
31 | #include "G4PSTrackLength.hh" |
---|
32 | #include "G4UnitsTable.hh" |
---|
33 | //////////////////////////////////////////////////////////////////////////////// |
---|
34 | // (Description) |
---|
35 | // This is a primitive scorer class for scoring sum of track length. |
---|
36 | // |
---|
37 | // |
---|
38 | // Created: 2007-02-02 Tsukasa ASO, Akinori Kimura. |
---|
39 | // |
---|
40 | /////////////////////////////////////////////////////////////////////////////// |
---|
41 | |
---|
42 | G4PSTrackLength::G4PSTrackLength(G4String name, G4int depth) |
---|
43 | :G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false),multiplyKinE(false), |
---|
44 | divideByVelocity(false) |
---|
45 | {;} |
---|
46 | |
---|
47 | G4PSTrackLength::~G4PSTrackLength() |
---|
48 | {;} |
---|
49 | |
---|
50 | G4bool G4PSTrackLength::ProcessHits(G4Step* aStep,G4TouchableHistory*) |
---|
51 | { |
---|
52 | G4double trklength = aStep->GetStepLength(); |
---|
53 | if ( trklength == 0. ) return FALSE; |
---|
54 | if(weighted) trklength *= aStep->GetPreStepPoint()->GetWeight(); |
---|
55 | if(multiplyKinE) trklength *= aStep->GetPreStepPoint()->GetKineticEnergy(); |
---|
56 | if(divideByVelocity) trklength /= aStep->GetPreStepPoint()->GetVelocity(); |
---|
57 | G4int index = GetIndex(aStep); |
---|
58 | EvtMap->add(index,trklength); |
---|
59 | return TRUE; |
---|
60 | } |
---|
61 | |
---|
62 | void G4PSTrackLength::Initialize(G4HCofThisEvent* HCE) |
---|
63 | { |
---|
64 | EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName()); |
---|
65 | if(HCID < 0) {HCID = GetCollectionID(0);} |
---|
66 | HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); |
---|
67 | } |
---|
68 | |
---|
69 | void G4PSTrackLength::EndOfEvent(G4HCofThisEvent*) |
---|
70 | {;} |
---|
71 | |
---|
72 | void G4PSTrackLength::clear(){ |
---|
73 | EvtMap->clear(); |
---|
74 | } |
---|
75 | |
---|
76 | void G4PSTrackLength::DrawAll() |
---|
77 | {;} |
---|
78 | |
---|
79 | void G4PSTrackLength::PrintAll() |
---|
80 | { |
---|
81 | G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; |
---|
82 | G4cout << " PrimitiveScorer " << GetName() << G4endl; |
---|
83 | G4cout << " Number of entries " << EvtMap->entries() << G4endl; |
---|
84 | std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin(); |
---|
85 | for(; itr != EvtMap->GetMap()->end(); itr++) { |
---|
86 | G4cout << " copy no.: " << itr->first << " track length: " ; |
---|
87 | if ( multiplyKinE && !divideByVelocity ){ |
---|
88 | G4cout << *(itr->second)/(mm*MeV) <<" mm*MeV"; |
---|
89 | } else if ( !multiplyKinE && divideByVelocity ){ |
---|
90 | G4cout << *(itr->second)*second <<" /second"; |
---|
91 | } else if ( multiplyKinE && divideByVelocity) { |
---|
92 | G4cout << *(itr->second)/MeV*second <<" MeV/second"; |
---|
93 | } else { |
---|
94 | G4cout << G4BestUnit(*(itr->second),"Length"); |
---|
95 | } |
---|
96 | G4cout << G4endl; |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|