Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/digits_hits/scorer/src/G4PSTrackLength.cc

    r1337 r1340  
    2525//
    2626//
    27 // $Id: G4PSTrackLength.cc,v 1.1 2007/07/11 01:31:03 asaim Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4PSTrackLength.cc,v 1.2 2010/07/22 07:23:45 taso Exp $
     28// GEANT4 tag $Name: $
    2929//
    3030// G4PSTrackLength
     
    3737//
    3838// Created: 2007-02-02  Tsukasa ASO, Akinori Kimura.
     39//          2010-07-22   Introduce Unit specification.
    3940//
    4041///////////////////////////////////////////////////////////////////////////////
     
    4344    :G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false),multiplyKinE(false),
    4445     divideByVelocity(false)
    45 {;}
     46{
     47    DefineUnitAndCategory();
     48    SetUnit("mm");
     49}
     50
     51G4PSTrackLength::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}
    4659
    4760G4PSTrackLength::~G4PSTrackLength()
    4861{;}
     62
     63void G4PSTrackLength::MultiplyKineticEnergy(G4bool flg)
     64{
     65    multiplyKinE = flg;
     66    // Default unit is set according to flags.
     67    SetUnit("");
     68}
     69
     70void G4PSTrackLength::DivideByVelocity(G4bool flg)
     71{
     72    divideByVelocity = flg;
     73    // Default unit is set according to flags.
     74    SetUnit("");
     75}
    4976
    5077G4bool G4PSTrackLength::ProcessHits(G4Step* aStep,G4TouchableHistory*)
     
    84111  std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
    85112  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       }
     113      G4cout << "  copy no.: " << itr->first << " value ";
     114      G4cout << *(itr->second)/GetUnitValue()
     115             << " ["<< GetUnit() << "]";
    96116      G4cout << G4endl;
    97117  }
    98118}
    99119
     120void 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
     153void 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
Note: See TracChangeset for help on using the changeset viewer.