| 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.2 2010/07/22 07:23:45 taso Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 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 | // 2010-07-22 Introduce Unit specification.
|
|---|
| 40 | //
|
|---|
| 41 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 |
|
|---|
| 43 | G4PSTrackLength::G4PSTrackLength(G4String name, G4int depth)
|
|---|
| 44 | :G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false),multiplyKinE(false),
|
|---|
| 45 | divideByVelocity(false)
|
|---|
| 46 | {
|
|---|
| 47 | DefineUnitAndCategory();
|
|---|
| 48 | SetUnit("mm");
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | G4PSTrackLength::G4PSTrackLength(G4String name, const G4String& unit,
|
|---|
| 52 | G4int depth)
|
|---|
| 53 | :G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false),multiplyKinE(false),
|
|---|
| 54 | divideByVelocity(false)
|
|---|
| 55 | {
|
|---|
| 56 | DefineUnitAndCategory();
|
|---|
| 57 | SetUnit(unit);
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | G4PSTrackLength::~G4PSTrackLength()
|
|---|
| 61 | {;}
|
|---|
| 62 |
|
|---|
| 63 | void G4PSTrackLength::MultiplyKineticEnergy(G4bool flg)
|
|---|
| 64 | {
|
|---|
| 65 | multiplyKinE = flg;
|
|---|
| 66 | // Default unit is set according to flags.
|
|---|
| 67 | SetUnit("");
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | void G4PSTrackLength::DivideByVelocity(G4bool flg)
|
|---|
| 71 | {
|
|---|
| 72 | divideByVelocity = flg;
|
|---|
| 73 | // Default unit is set according to flags.
|
|---|
| 74 | SetUnit("");
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | G4bool G4PSTrackLength::ProcessHits(G4Step* aStep,G4TouchableHistory*)
|
|---|
| 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 |
|
|---|
| 89 | void G4PSTrackLength::Initialize(G4HCofThisEvent* HCE)
|
|---|
| 90 | {
|
|---|
| 91 | EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
|
|---|
| 92 | if(HCID < 0) {HCID = GetCollectionID(0);}
|
|---|
| 93 | HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | void G4PSTrackLength::EndOfEvent(G4HCofThisEvent*)
|
|---|
| 97 | {;}
|
|---|
| 98 |
|
|---|
| 99 | void G4PSTrackLength::clear(){
|
|---|
| 100 | EvtMap->clear();
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | void G4PSTrackLength::DrawAll()
|
|---|
| 104 | {;}
|
|---|
| 105 |
|
|---|
| 106 | void G4PSTrackLength::PrintAll()
|
|---|
| 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 << " value ";
|
|---|
| 114 | G4cout << *(itr->second)/GetUnitValue()
|
|---|
| 115 | << " ["<< GetUnit() << "]";
|
|---|
| 116 | G4cout << G4endl;
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | void G4PSTrackLength::SetUnit(const G4String& unit)
|
|---|
| 121 | {
|
|---|
| 122 | if ( multiplyKinE ){
|
|---|
| 123 | if ( divideByVelocity ){
|
|---|
| 124 | if ( unit == "" ) {
|
|---|
| 125 | CheckAndSetUnit("MeV_second","EnergyFlux");
|
|---|
| 126 | } else {
|
|---|
| 127 | CheckAndSetUnit(unit,"EnergyFlux");
|
|---|
| 128 | }
|
|---|
| 129 | }else {
|
|---|
| 130 | if ( unit == "" ) {
|
|---|
| 131 | CheckAndSetUnit("MeV_mm","EnergyFlow");
|
|---|
| 132 | } else {
|
|---|
| 133 | CheckAndSetUnit(unit,"EnergyFlow");
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 | }else {
|
|---|
| 137 | if ( divideByVelocity ){
|
|---|
| 138 | if ( unit == "" ) {
|
|---|
| 139 | CheckAndSetUnit("second","Time");
|
|---|
| 140 | } else {
|
|---|
| 141 | CheckAndSetUnit(unit,"Time");
|
|---|
| 142 | }
|
|---|
| 143 | }else {
|
|---|
| 144 | if ( unit == "") {
|
|---|
| 145 | CheckAndSetUnit("mm","Length");
|
|---|
| 146 | } else {
|
|---|
| 147 | CheckAndSetUnit(unit,"Length");
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | void G4PSTrackLength::DefineUnitAndCategory(){
|
|---|
| 154 | // EnergyFlux
|
|---|
| 155 | new G4UnitDefinition("eV_second","eV_s","EnergyFlux",(eV*second));
|
|---|
| 156 | new G4UnitDefinition("keV_second","keV_s","EnergyFlux",(keV*second));
|
|---|
| 157 | new G4UnitDefinition("MeV_second","MeV_s","EnergyFlux",(MeV*second));
|
|---|
| 158 | new G4UnitDefinition("eV_millisecond","eV_ms","EnergyFlux",(eV*ms));
|
|---|
| 159 | new G4UnitDefinition("keV_millisecond","keV_ms","EnergyFlux",(keV*ms));
|
|---|
| 160 | new G4UnitDefinition("MeV_millisecond","MeV_ms","EnergyFlux",(MeV*ms));
|
|---|
| 161 | //EnergyFlow
|
|---|
| 162 | new G4UnitDefinition("eV_millimeter","eV_mm","EnergyFlow",(eV*mm));
|
|---|
| 163 | new G4UnitDefinition("keV_millimeter","keV_mm","EnergyFlow",(keV*mm));
|
|---|
| 164 | new G4UnitDefinition("MeV_millimeter","MeV_mm","EnergyFlow",(MeV*mm));
|
|---|
| 165 | new G4UnitDefinition("eV_centimeter","eV_cm","EnergyFlow",(eV*cm));
|
|---|
| 166 | new G4UnitDefinition("keV_centimeter","keV_cm","EnergyFlow",(keV*cm));
|
|---|
| 167 | new G4UnitDefinition("MeV_centimeter","MeV_cm","EnergyFlow",(MeV*cm));
|
|---|
| 168 | new G4UnitDefinition("eV_meter","eV_m","EnergyFlow",(eV*m));
|
|---|
| 169 | new G4UnitDefinition("keV_meter","keV_m","EnergyFlow",(keV*m));
|
|---|
| 170 | new G4UnitDefinition("MeV_meter","MeV_m","EnergyFlow",(MeV*m));
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|