Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PSTrackLength.cc
Go to the documentation of this file.
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//
28// G4PSTrackLength
29#include "G4PSTrackLength.hh"
30#include "G4SystemOfUnits.hh"
31#include "G4UnitsTable.hh"
32////////////////////////////////////////////////////////////////////////////////
33// (Description)
34// This is a primitive scorer class for scoring sum of track length.
35//
36//
37// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
38// 2010-07-22 Introduce Unit specification.
39// 2011-09-09 Modify comment in PrintAll().
40//
41///////////////////////////////////////////////////////////////////////////////
42
44 :G4VPrimitiveScorer(name,depth),HCID(-1),EvtMap(0),weighted(false),
45 multiplyKinE(false),divideByVelocity(false)
46{
48 SetUnit("mm");
49}
50
52 G4int depth)
53 :G4VPrimitiveScorer(name,depth),HCID(-1),EvtMap(0),weighted(false),
54 multiplyKinE(false),divideByVelocity(false)
55{
57 SetUnit(unit);
58}
59
61{;}
62
64{
65 multiplyKinE = flg;
66 // Default unit is set according to flags.
67 SetUnit("");
68}
69
71{
72 divideByVelocity = flg;
73 // Default unit is set according to flags.
74 SetUnit("");
75}
76
78{
79 G4double trklength = aStep->GetStepLength();
80 if ( trklength == 0. ) return FALSE;
81 if(weighted) trklength *= aStep->GetPreStepPoint()->GetWeight();
82 if(multiplyKinE) trklength *= aStep->GetPreStepPoint()->GetKineticEnergy();
83 if(divideByVelocity) trklength /= aStep->GetPreStepPoint()->GetVelocity();
84 G4int index = GetIndex(aStep);
85 EvtMap->add(index,trklength);
86 return TRUE;
87}
88
90{
92 if(HCID < 0) {HCID = GetCollectionID(0);}
93 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
94}
95
97{;}
98
100 EvtMap->clear();
101}
102
104{;}
105
107{
108 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
109 G4cout << " PrimitiveScorer " << GetName() << G4endl;
110 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
111 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
112 for(; itr != EvtMap->GetMap()->end(); itr++) {
113 G4cout << " copy no.: " << itr->first ;
114 if ( multiplyKinE ){
115 if ( divideByVelocity ) G4cout << " EnergyFlux: ";
116 else G4cout << " EnergyFlow: ";
117 }else{
118 if ( divideByVelocity ) G4cout << " Time: ";
119 else G4cout << " Length: ";
120 }
121 G4cout << *(itr->second)/GetUnitValue()
122 << " ["<< GetUnit() << "]";
123 G4cout << G4endl;
124 }
125}
126
128{
129 if ( multiplyKinE ){
130 if ( divideByVelocity ){
131 if ( unit == "" ) {
132 CheckAndSetUnit("MeV_second","EnergyFlux");
133 } else {
134 CheckAndSetUnit(unit,"EnergyFlux");
135 }
136 }else {
137 if ( unit == "" ) {
138 CheckAndSetUnit("MeV_mm","EnergyFlow");
139 } else {
140 CheckAndSetUnit(unit,"EnergyFlow");
141 }
142 }
143 }else {
144 if ( divideByVelocity ){
145 if ( unit == "" ) {
146 CheckAndSetUnit("second","Time");
147 } else {
148 CheckAndSetUnit(unit,"Time");
149 }
150 }else {
151 if ( unit == "") {
152 CheckAndSetUnit("mm","Length");
153 } else {
154 CheckAndSetUnit(unit,"Length");
155 }
156 }
157 }
158}
159
161 // EnergyFlux
162 new G4UnitDefinition("eV_second","eV_s","EnergyFlux",(eV*second));
163 new G4UnitDefinition("keV_second","keV_s","EnergyFlux",(keV*second));
164 new G4UnitDefinition("MeV_second","MeV_s","EnergyFlux",(MeV*second));
165 new G4UnitDefinition("eV_millisecond","eV_ms","EnergyFlux",(eV*ms));
166 new G4UnitDefinition("keV_millisecond","keV_ms","EnergyFlux",(keV*ms));
167 new G4UnitDefinition("MeV_millisecond","MeV_ms","EnergyFlux",(MeV*ms));
168 //EnergyFlow
169 new G4UnitDefinition("eV_millimeter","eV_mm","EnergyFlow",(eV*mm));
170 new G4UnitDefinition("keV_millimeter","keV_mm","EnergyFlow",(keV*mm));
171 new G4UnitDefinition("MeV_millimeter","MeV_mm","EnergyFlow",(MeV*mm));
172 new G4UnitDefinition("eV_centimeter","eV_cm","EnergyFlow",(eV*cm));
173 new G4UnitDefinition("keV_centimeter","keV_cm","EnergyFlow",(keV*cm));
174 new G4UnitDefinition("MeV_centimeter","MeV_cm","EnergyFlow",(MeV*cm));
175 new G4UnitDefinition("eV_meter","eV_m","EnergyFlow",(eV*m));
176 new G4UnitDefinition("keV_meter","keV_m","EnergyFlow",(keV*m));
177 new G4UnitDefinition("MeV_meter","MeV_m","EnergyFlow",(MeV*m));
178}
179
180
181
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define TRUE
Definition: Globals.hh:27
#define FALSE
Definition: Globals.hh:23
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
virtual void DrawAll()
G4PSTrackLength(G4String name, G4int depth=0)
virtual void SetUnit(const G4String &unit)
virtual void Initialize(G4HCofThisEvent *)
virtual void EndOfEvent(G4HCofThisEvent *)
virtual void DefineUnitAndCategory()
void MultiplyKineticEnergy(G4bool flg=true)
virtual void clear()
void DivideByVelocity(G4bool flg=true)
virtual ~G4PSTrackLength()
virtual void PrintAll()
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
G4double GetVelocity() const
G4double GetKineticEnergy() const
G4double GetWeight() const
Definition: G4Step.hh:62
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
virtual G4int GetIndex(G4Step *)
G4String GetName() const
const G4String & GetUnit() const
G4MultiFunctionalDetector * detector
G4int GetCollectionID(G4int)
void CheckAndSetUnit(const G4String &unit, const G4String &category)
G4double GetUnitValue() const
Map_t * GetMap() const
Definition: G4THitsMap.hh:151
size_t entries() const
Definition: G4THitsMap.hh:155
void clear()
Definition: G4THitsMap.hh:537
size_t add(const G4int &key, U *&aHit) const
Definition: G4THitsMap.hh:177