Import Geant4 9.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:37:50 +02:00
parent a8e9364cea
commit 96c8bcd0af
6923 changed files with 198390 additions and 41849 deletions
@@ -24,36 +24,56 @@
// ********************************************************************
//
//
// $Id: G4SDChargedFilter.cc,v 1.3 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4DefaultLinearColorMap.cc,v 1.2 2007/11/06 17:17:14 asaim Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// G4VSensitiveDetector
#include "G4SDChargedFilter.hh"
#include "G4Step.hh"
#include "G4TouchableHistory.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
////////////////////////////////////////////////////////////////////////////////
// class description:
//
// This is the class of a filter to be associated with a
// sensitive detector.
//
// Created: 2005-11-14 Tsukasa ASO.
//
///////////////////////////////////////////////////////////////////////////////
#include "G4DefaultLinearColorMap.hh"
G4SDChargedFilter::G4SDChargedFilter(G4String name)
:G4VSDFilter(name)
G4DefaultLinearColorMap::G4DefaultLinearColorMap(G4String mName)
:G4VScoreColorMap(mName)
{;}
G4SDChargedFilter::~G4SDChargedFilter()
G4DefaultLinearColorMap::~G4DefaultLinearColorMap()
{;}
G4bool G4SDChargedFilter::Accept(const G4Step* aStep) const
void G4DefaultLinearColorMap::GetMapColor(G4double val, G4double color[4])
{
if (aStep->GetPreStepPoint()->GetCharge() != 0. ) return TRUE;
return FALSE;
G4double value = (val-fMinVal)/(fMaxVal-fMinVal);
if(value > 1.) {value=1.;}
if(value < 0.) {value=0.;}
// color map
const int NCOLOR = 6;
struct ColorMap {
G4double val;
G4double rgb[4];
} colormap[NCOLOR] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
{0.2, {0., 0., 1., 1.}},
{0.4, {0., 1., 1., 1.}},
{0.6, {0., 1., 0., 1.}},
{0.8, {1., 1., 0., 1.}},
{1.0, {1., 0., 0., 1.}}};
// search
G4int during[2] = {0, 0};
for(int i = 1; i < NCOLOR; i++) {
if(colormap[i].val >= value) {
during[0] = i-1;
during[1] = i;
break;
}
}
// interpolate
G4double a = std::fabs(value - colormap[during[0]].val);
G4double b = std::fabs(value - colormap[during[1]].val);
for(int i = 0; i < 4; i++) {
color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
/(colormap[during[1]].val - colormap[during[0]].val);
}
}
@@ -1,105 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PSCellCharge.cc,v 1.3 2007/05/18 00:00:37 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSCellCharge
#include "G4PSCellCharge.hh"
#include "G4Track.hh"
///////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring cell charge.
// The Cell Charge is defined by a sum of deposited charge inside the cell.
//
// Created: 2006-08-20 Tsukasa ASO
//
///////////////////////////////////////////////////////////////////////////////
G4PSCellCharge::G4PSCellCharge(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSCellCharge::~G4PSCellCharge()
{;}
G4bool G4PSCellCharge::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
// Enter or First step of primary.
if( aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary
|| ( aStep->GetTrack()->GetParentID() == 0 &&
aStep->GetTrack()->GetCurrentStepNumber() == 1 ) ){
G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
CellCharge *= aStep->GetPreStepPoint()->GetWeight();
G4int index = GetIndex(aStep);
EvtMap->add(index,CellCharge);
}
// Exit
if( aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary){
G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
CellCharge *= aStep->GetPreStepPoint()->GetWeight();
G4int index = GetIndex(aStep);
CellCharge *= -1.0;
EvtMap->add(index,CellCharge);
}
return TRUE;
}
void G4PSCellCharge::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),
GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID,EvtMap);
}
void G4PSCellCharge::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSCellCharge::clear(){
EvtMap->clear();
}
void G4PSCellCharge::DrawAll()
{;}
void G4PSCellCharge::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " cell charge : " << *(itr->second) << " [e]"
<< G4endl;
}
}
@@ -1,102 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSCellFlux.cc,v 1.5 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSCellFlux
#include "G4PSCellFlux.hh"
#include "G4Track.hh"
#include "G4VSolid.hh"
#include "G4UnitsTable.hh"
///////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring cell flux.
// The Cell Flux is defined by a sum of track length divided
// by the geometry volume, where all of the tracks in the geometry
// are taken into account.
//
// If you want to score only tracks passing through the geometry volume,
// please use G4PSPassageCellFlux.
//
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSCellFlux::G4PSCellFlux(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSCellFlux::~G4PSCellFlux()
{;}
G4bool G4PSCellFlux::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4double stepLength = aStep->GetStepLength();
if ( stepLength == 0. ) return FALSE;
G4double volume = aStep->GetPreStepPoint()->GetPhysicalVolume()
->GetLogicalVolume()->GetSolid()->GetCubicVolume();
G4double CellFlux = stepLength / volume ;
CellFlux *= aStep->GetPreStepPoint()->GetWeight();
G4int index = GetIndex(aStep);
EvtMap->add(index,CellFlux);
return TRUE;
}
void G4PSCellFlux::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),
GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID,EvtMap);
}
void G4PSCellFlux::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSCellFlux::clear(){
EvtMap->clear();
}
void G4PSCellFlux::DrawAll()
{;}
void G4PSCellFlux::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " cell flux : " << *(itr->second)*cm*cm << " [cm^-2]"
<< G4endl;
}
}
@@ -1,96 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSDoseDeposit.cc,v 1.5 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSDoseDeposit
#include "G4PSDoseDeposit.hh"
#include "G4VSolid.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring only energy deposit.
//
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSDoseDeposit::G4PSDoseDeposit(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSDoseDeposit::~G4PSDoseDeposit()
{;}
G4bool G4PSDoseDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if ( edep == 0. ) return FALSE;
G4double volume = aStep->GetPreStepPoint()->GetPhysicalVolume()
->GetLogicalVolume()->GetSolid()->GetCubicVolume();
G4double density = aStep->GetTrack()->GetMaterial()->GetDensity();
G4double dose = edep / ( density * volume );
dose *= aStep->GetPreStepPoint()->GetWeight();
G4int index = GetIndex(aStep);
EvtMap->add(index,dose);
return TRUE;
}
void G4PSDoseDeposit::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSDoseDeposit::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSDoseDeposit::clear()
{
EvtMap->clear();
}
void G4PSDoseDeposit::DrawAll()
{;}
void G4PSDoseDeposit::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " dose deposit: " << G4BestUnit(*(itr->second),"Dose")
<< G4endl;
}
}
@@ -1,88 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSEnergyDeposit.cc,v 1.5 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSEnergyDeposit
#include "G4PSEnergyDeposit.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// Description:
// This is a primitive scorer class for scoring energy deposit.
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSEnergyDeposit::G4PSEnergyDeposit(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSEnergyDeposit::~G4PSEnergyDeposit()
{;}
G4bool G4PSEnergyDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if ( edep == 0. ) return FALSE;
edep *= aStep->GetPreStepPoint()->GetWeight(); // (Particle Weight)
G4int index = GetIndex(aStep);
EvtMap->add(index,edep);
return TRUE;
}
void G4PSEnergyDeposit::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSEnergyDeposit::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSEnergyDeposit::clear()
{
EvtMap->clear();
}
void G4PSEnergyDeposit::DrawAll()
{;}
void G4PSEnergyDeposit::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " energy deposit: " << G4BestUnit(*(itr->second),"Energy")
<< G4endl;
}
}
@@ -1,149 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSFlatSurfaceCurrent.cc,v 1.7 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSFlatSurfaceCurrent
#include "G4PSFlatSurfaceCurrent.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4GeometryTolerance.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring only Surface Flux.
// Current version assumes only for G4Box shape.
//
// Surface is defined at the -Z surface.
// Direction -Z +Z
// 0 IN || OUT ->|<- |
// 1 IN ->| |
// 2 OUT |<- |
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSFlatSurfaceCurrent::G4PSFlatSurfaceCurrent(G4String name,
G4int direction, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction)
{;}
G4PSFlatSurfaceCurrent::~G4PSFlatSurfaceCurrent()
{;}
G4bool G4PSFlatSurfaceCurrent::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4StepPoint* preStep = aStep->GetPreStepPoint();
G4VSolid * solid =
preStep->GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
if( solid->GetEntityType() != "G4Box" ){
G4Exception("G4PSFlatSurfaceCurrentScorer. - Solid type is not supported.");
return FALSE;
}
G4Box* boxSolid = (G4Box*)(solid);
G4int dirFlag =IsSelectedSurface(aStep,boxSolid);
if ( dirFlag > 0 ) {
G4int index = GetIndex(aStep);
G4double square = 4.*boxSolid->GetXHalfLength()*boxSolid->GetYHalfLength();
G4TouchableHandle theTouchable = preStep->GetTouchableHandle();
G4ThreeVector pdirection = preStep->GetMomentumDirection();
G4ThreeVector localdir =
theTouchable->GetHistory()->GetTopTransform().TransformAxis(pdirection);
G4double current = preStep->GetWeight(); // Current (Particle Weight)
current = current/square; // Current with angle.
if ( fDirection == fCurrent_InOut || fDirection == dirFlag ){
EvtMap->add(index,current);
}
}
return TRUE;
}
G4int G4PSFlatSurfaceCurrent::IsSelectedSurface(G4Step* aStep, G4Box* boxSolid){
G4TouchableHandle theTouchable =
aStep->GetPreStepPoint()->GetTouchableHandle();
G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
// Entering Geometry
G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
G4ThreeVector localpos1 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
if(std::fabs( localpos1.z() + boxSolid->GetZHalfLength())<kCarTolerance ){
return fCurrent_In;
}
}
if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
// Exiting Geometry
G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
G4ThreeVector localpos2 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
if(std::fabs( localpos2.z() + boxSolid->GetZHalfLength())<kCarTolerance ){
return fCurrent_Out;
}
}
return -1;
}
void G4PSFlatSurfaceCurrent::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSFlatSurfaceCurrent::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSFlatSurfaceCurrent::clear(){
EvtMap->clear();
}
void G4PSFlatSurfaceCurrent::DrawAll()
{;}
void G4PSFlatSurfaceCurrent::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " current : " << *(itr->second)*cm*cm << " [cm^-2]"
<< G4endl;
}
}
@@ -1,170 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSFlatSurfaceFlux.cc,v 1.8 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSFlatSurfaceFlux
#include "G4PSFlatSurfaceFlux.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4GeometryTolerance.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring Surface Flux.
// Current version assumes only for G4Box shape, and the surface
// is fixed on -Z plane.
//
// Surface is defined at the -Z surface.
// Direction -Z +Z
// 0 IN || OUT ->|<- |
// 1 IN ->| |
// 2 OUT |<- |
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
// 18-Nov-2005 T.Aso, To use always positive value for anglefactor.
// 29-Mar-2007 T.Aso, Bug fix for momentum direction at outgoing flux.
///////////////////////////////////////////////////////////////////////////////
G4PSFlatSurfaceFlux::G4PSFlatSurfaceFlux(G4String name,
G4int direction, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction)
{;}
G4PSFlatSurfaceFlux::~G4PSFlatSurfaceFlux()
{;}
G4bool G4PSFlatSurfaceFlux::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4StepPoint* preStep = aStep->GetPreStepPoint();
G4VSolid * solid =
preStep->GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
if( solid->GetEntityType() != "G4Box" ){
G4Exception("G4PSFlatSurfaceFluxScorer. - Solid type is not supported.");
return FALSE;
}
G4Box* boxSolid = (G4Box*)(solid);
G4int dirFlag =IsSelectedSurface(aStep,boxSolid);
if ( dirFlag > 0 ) {
if ( fDirection == fFlux_InOut || fDirection == dirFlag ){
G4StepPoint* thisStep=0;
if ( dirFlag == fFlux_In ){
thisStep = preStep;
}else if ( dirFlag == fFlux_Out ){
thisStep = aStep->GetPostStepPoint();
}else{
return FALSE;
}
G4TouchableHandle theTouchable = thisStep->GetTouchableHandle();
G4ThreeVector pdirection = thisStep->GetMomentumDirection();
G4ThreeVector localdir =
theTouchable->GetHistory()->GetTopTransform().TransformAxis(pdirection);
//
G4double angleFactor = localdir.z();
if ( angleFactor < 0 ) angleFactor *= -1.;
G4double flux = preStep->GetWeight(); // Current (Particle Weight)
//
G4double square = 4.*boxSolid->GetXHalfLength()*boxSolid->GetYHalfLength();
//
flux = flux/angleFactor/square; // Flux with angle.
//
G4int index = GetIndex(aStep);
EvtMap->add(index,flux);
}
}
#ifdef debug
G4cout << " PASSED vol "
<< index << " trk "<<trkid<<" len " << fFlatSurfaceFlux<<G4endl;
#endif
return TRUE;
}
G4int G4PSFlatSurfaceFlux::IsSelectedSurface(G4Step* aStep, G4Box* boxSolid){
G4TouchableHandle theTouchable =
aStep->GetPreStepPoint()->GetTouchableHandle();
G4double kCarTolerance=G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
// Entering Geometry
G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
G4ThreeVector localpos1 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
if(std::fabs( localpos1.z() + boxSolid->GetZHalfLength())<kCarTolerance ){
return fFlux_In;
}
}
if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
// Exiting Geometry
G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
G4ThreeVector localpos2 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
if(std::fabs( localpos2.z() + boxSolid->GetZHalfLength())<kCarTolerance ){
return fFlux_Out;
}
}
return -1;
}
void G4PSFlatSurfaceFlux::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSFlatSurfaceFlux::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSFlatSurfaceFlux::clear(){
EvtMap->clear();
}
void G4PSFlatSurfaceFlux::DrawAll()
{;}
void G4PSFlatSurfaceFlux::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer" << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " flux : " << *(itr->second)*cm*cm << " [cm^-2]"
<< G4endl;
}
}
@@ -1,116 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSMinKinEAtGeneration.cc,v 1.6 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSMinKinEAtGeneration
#include "G4PSMinKinEAtGeneration.hh"
#include "G4UnitsTable.hh"
// (Description)
// This is a primitive scorer class for scoring minimum energy of
// newly produced particles in the geometry.
//
// Created: 2005-11-17 Tsukasa ASO, Akinori Kimura.
//
G4PSMinKinEAtGeneration::G4PSMinKinEAtGeneration(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSMinKinEAtGeneration::~G4PSMinKinEAtGeneration()
{;}
G4bool G4PSMinKinEAtGeneration::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
// ===============
// First Step,
// Confirm this is a newly produced secondary.
//
//- check for newly produced particle. e.g. Step number is 1.
if ( aStep->GetTrack()->GetCurrentStepNumber() != 1) return FALSE;
//- check for this is not a primary particle. e.g. ParentID != 0 .
if ( aStep->GetTrack()->GetParentID() == 0 ) return FALSE;
//===============================================
//- This is a newly produced secondary particle.
//===============================================
// ===============
// Second Step,
// Confirm this track has lower energy than previous one.
//
// -Kinetic energy of this particle at the starting point.
G4double kinetic = aStep->GetPreStepPoint()->GetKineticEnergy();
// -Stored value in the current HitsMap.
G4int index = GetIndex(aStep);
G4double* mapValue= ((*EvtMap)[index]);
// -
// If mapValue exits (e.g not NULL ), compare it with
// current track's kinetic energy.
if ( mapValue && ( kinetic > *mapValue ) ) return FALSE;
// -
// Current Track is a newly produced secondary and has lower
// kinetic energy than previous one in this geometry.
//
EvtMap->set(index, kinetic);
return TRUE;
}
void G4PSMinKinEAtGeneration::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSMinKinEAtGeneration::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSMinKinEAtGeneration::clear(){
EvtMap->clear();
}
void G4PSMinKinEAtGeneration::DrawAll()
{;}
void G4PSMinKinEAtGeneration::PrintAll()
{
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " num of step: " << G4BestUnit(*(itr->second),"Energy")
<< G4endl;
}
}
@@ -1,89 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSNofCollision.cc,v 1.2 2007/06/21 15:03:58 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSNofCollision
#include "G4PSNofCollision.hh"
///////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring number of collisions inside a
// Cell.
//
// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSNofCollision::G4PSNofCollision(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false)
{;}
G4PSNofCollision::~G4PSNofCollision()
{;}
G4bool G4PSNofCollision::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
if ( aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ) return TRUE;
G4int index = GetIndex(aStep);
G4double val = 1.0;
if(weighted) val *= aStep->GetPreStepPoint()->GetWeight();
EvtMap->add(index,val);
return TRUE;
}
void G4PSNofCollision::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSNofCollision::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSNofCollision::clear(){
EvtMap->clear();
}
void G4PSNofCollision::DrawAll()
{;}
void G4PSNofCollision::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " collisions: " << *(itr->second)
<< G4endl;
}
}
@@ -1,89 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSNofSecondary.cc,v 1.4 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSNofSecondary
#include "G4PSNofSecondary.hh"
// (Description)
// This is a primitive scorer class for scoring number of steps in the
// Cell.
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
G4PSNofSecondary::G4PSNofSecondary(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSNofSecondary::~G4PSNofSecondary()
{;}
G4bool G4PSNofSecondary::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
//- check for newly produced particle. e.g. first step.
if ( aStep->GetTrack()->GetCurrentStepNumber() != 1) return FALSE;
//- check for this is not a primary particle. e.g. ParentID > 0 .
if ( aStep->GetTrack()->GetParentID() == 0 ) return FALSE;
//
//- This is a newly produced secondary particle.
G4int index = GetIndex(aStep);
G4double weight = aStep->GetPreStepPoint()->GetWeight();
EvtMap->add(index,weight);
return TRUE;
}
void G4PSNofSecondary::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSNofSecondary::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSNofSecondary::clear(){
EvtMap->clear();
}
void G4PSNofSecondary::DrawAll()
{;}
void G4PSNofSecondary::PrintAll()
{
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " num of step: " << *(itr->second)
<< G4endl;
}
}
@@ -1,84 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSNofStep.cc,v 1.6 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSNofStep
#include "G4PSNofStep.hh"
// (Description)
// This is a primitive scorer class for scoring number of steps in the
// Cell.
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
G4PSNofStep::G4PSNofStep(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1)
{;}
G4PSNofStep::~G4PSNofStep()
{;}
G4bool G4PSNofStep::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4int index = GetIndex(aStep);
G4double val = 1.0;
EvtMap->add(index,val);
return TRUE;
}
void G4PSNofStep::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSNofStep::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSNofStep::clear(){
EvtMap->clear();
}
void G4PSNofStep::DrawAll()
{;}
void G4PSNofStep::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " num of step: " << *(itr->second)
<< G4endl;
}
}
@@ -1,134 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSPassageCellFlux.cc,v 1.6 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSPassageCellFlux
#include "G4PSPassageCellFlux.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4VSolid.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring cell flux.
// The Cell Flux is defined by a track length divided by a geometry
// volume, where only tracks passing through the geometry are taken
// into account. e.g. the unit of Cell Flux is mm/mm3.
//
// If you want to score all tracks in the geometry volume,
// please use G4PSCellFlux.
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSPassageCellFlux::G4PSPassageCellFlux(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fCurrentTrkID(-1),fCellFlux(0)
{;}
G4PSPassageCellFlux::~G4PSPassageCellFlux()
{;}
G4bool G4PSPassageCellFlux::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
if ( IsPassed(aStep) ) {
fCellFlux /=
aStep->GetPreStepPoint()->GetPhysicalVolume()
->GetLogicalVolume()->GetSolid()->GetCubicVolume();
G4int index = GetIndex(aStep);
EvtMap->add(index,fCellFlux);
}
return TRUE;
}
G4bool G4PSPassageCellFlux::IsPassed(G4Step* aStep){
G4bool Passed = FALSE;
G4bool IsEnter = aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary;
G4bool IsExit = aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary;
G4int trkid = aStep->GetTrack()->GetTrackID();
G4double trklength = aStep->GetStepLength();
trklength *= aStep->GetPreStepPoint()->GetWeight();
if ( IsEnter &&IsExit ){ // Passed at one step
fCellFlux = trklength; // Track length is absolutely given.
Passed = TRUE;
}else if ( IsEnter ){ // Enter a new geometry
fCurrentTrkID = trkid; // Resetting the current track.
fCellFlux = trklength;
}else if ( IsExit ){ // Exit a current geometry
if ( fCurrentTrkID == trkid ) {// if the track is same as entered,
fCellFlux += trklength; // add the track length to current one.
Passed = TRUE;
}
}else{ // Inside geometry
if ( fCurrentTrkID == trkid ){ // if the track is same as entered,
fCellFlux += trklength; // adding the track length to current one.
}
}
return Passed;
}
void G4PSPassageCellFlux::Initialize(G4HCofThisEvent* HCE)
{
fCurrentTrkID = -1;
EvtMap = new G4THitsMap<G4double>(detector->GetName(),
GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID,EvtMap);
}
void G4PSPassageCellFlux::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSPassageCellFlux::clear(){
EvtMap->clear();
}
void G4PSPassageCellFlux::DrawAll()
{;}
void G4PSPassageCellFlux::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " cell flux : " << *(itr->second)*cm*cm << " [cm^-2]"
<< G4endl;
}
}
@@ -1,122 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSPassageCurrent.cc,v 1.5 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSPassageCurrent
#include "G4PSPassageCurrent.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4VSolid.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring number of tracks,
// where only tracks passing through the geometry are taken
// into account.
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSPassageCurrent::G4PSPassageCurrent(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fCurrentTrkID(-1),fCurrent(0)
{;}
G4PSPassageCurrent::~G4PSPassageCurrent()
{;}
G4bool G4PSPassageCurrent::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
if ( IsPassed(aStep) ) {
fCurrent = aStep->GetPreStepPoint()->GetWeight();
G4int index = GetIndex(aStep);
EvtMap->add(index,fCurrent);
}
return TRUE;
}
G4bool G4PSPassageCurrent::IsPassed(G4Step* aStep){
G4bool Passed = FALSE;
G4bool IsEnter = aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary;
G4bool IsExit = aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary;
G4int trkid = aStep->GetTrack()->GetTrackID();
if ( IsEnter &&IsExit ){ // Passed at one step
Passed = TRUE;
}else if ( IsEnter ){ // Enter a new geometry
fCurrentTrkID = trkid; // Resetting the current track.
}else if ( IsExit ){ // Exit a current geometry
if ( fCurrentTrkID == trkid ) {
Passed = TRUE; // if the track is same as entered.
}
}else{ // Inside geometry
if ( fCurrentTrkID == trkid ){ // Adding the track length to current one ,
}
}
return Passed;
}
void G4PSPassageCurrent::Initialize(G4HCofThisEvent* HCE)
{
fCurrentTrkID = -1;
EvtMap = new G4THitsMap<G4double>(detector->GetName(),
GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID,EvtMap);
}
void G4PSPassageCurrent::EndOfEvent(G4HCofThisEvent*)
{
}
void G4PSPassageCurrent::clear(){
EvtMap->clear();
}
void G4PSPassageCurrent::DrawAll()
{;}
void G4PSPassageCurrent::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " cell current : " << *(itr->second)
<< G4endl;
}
}
@@ -1,126 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSPassageTrackLength.cc,v 1.4 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSPassageTrackLength
#include "G4PSPassageTrackLength.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring only track length.
// The tracks which passed a geometry is taken into account.
//
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSPassageTrackLength::G4PSPassageTrackLength(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fCurrentTrkID(-1),fTrackLength(0.),
weighted(false)
{;}
G4PSPassageTrackLength::~G4PSPassageTrackLength()
{;}
G4bool G4PSPassageTrackLength::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
if ( IsPassed(aStep) ) {
G4int index = GetIndex(aStep);
EvtMap->add(index,fTrackLength);
}
return TRUE;
}
G4bool G4PSPassageTrackLength::IsPassed(G4Step* aStep){
G4bool Passed = FALSE;
G4bool IsEnter = aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary;
G4bool IsExit = aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary;
G4int trkid = aStep->GetTrack()->GetTrackID();
G4double trklength = aStep->GetStepLength();
if(weighted) trklength *= aStep->GetPreStepPoint()->GetWeight();
if ( IsEnter &&IsExit ){ // Passed at one step
fTrackLength = trklength; // Track length is absolutely given.
Passed = TRUE;
}else if ( IsEnter ){ // Enter a new geometry
fCurrentTrkID = trkid; // Resetting the current track.
fTrackLength = trklength;
}else if ( IsExit ){ // Exit a current geometry
if ( fCurrentTrkID == trkid ) {
fTrackLength += trklength; // Adding the track length to current one,
Passed = TRUE; // if the track is same as entered.
}
}else{ // Inside geometry
if ( fCurrentTrkID == trkid ){ // Adding the track length to current one ,
fTrackLength += trklength; // if the track is same as entered.
}
}
return Passed;
}
void G4PSPassageTrackLength::Initialize(G4HCofThisEvent* HCE)
{
fCurrentTrkID = -1;
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID,EvtMap);
}
void G4PSPassageTrackLength::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSPassageTrackLength::clear(){
EvtMap->clear();
}
void G4PSPassageTrackLength::DrawAll()
{;}
void G4PSPassageTrackLength::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveSenstivity " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " track length : " << G4BestUnit(*(itr->second),"Length")
<< G4endl;
}
}
@@ -1,95 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSPopulation.cc,v 1.3 2007/06/21 15:04:00 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSPopulation
#include "G4PSPopulation.hh"
///////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring population in a cell.
//
// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSPopulation::G4PSPopulation(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false)
{;}
G4PSPopulation::~G4PSPopulation()
{;}
G4bool G4PSPopulation::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4int index = GetIndex(aStep);
G4TrackLogger& tlog = fCellTrackLogger[index];
if (tlog.FirstEnterance(aStep->GetTrack()->GetTrackID())) {
G4double val = 1.0;
if(weighted) val *= aStep->GetPreStepPoint()->GetWeight();
EvtMap->add(index,val);
}
return TRUE;
}
void G4PSPopulation::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSPopulation::EndOfEvent(G4HCofThisEvent*)
{
fCellTrackLogger.clear();
}
void G4PSPopulation::clear(){
EvtMap->clear();
fCellTrackLogger.clear();
}
void G4PSPopulation::DrawAll()
{;}
void G4PSPopulation::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " population: " << *(itr->second)
<< G4endl;
}
}
@@ -1,158 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSSphereSurfaceCurrent.cc,v 1.7 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSSphereSurfaceCurrent
#include "G4PSSphereSurfaceCurrent.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4GeometryTolerance.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring only Surface Current.
// Current version assumes only for G4Sphere shape.
//
// Surface is defined at the inside of sphere.
// Direction -Rmin +Rmax
// 0 IN || OUT ->|<- |
// 1 IN ->| |
// 2 OUT |<- |
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSSphereSurfaceCurrent::G4PSSphereSurfaceCurrent(G4String name,
G4int direction, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction)
{;}
G4PSSphereSurfaceCurrent::~G4PSSphereSurfaceCurrent()
{;}
G4bool G4PSSphereSurfaceCurrent::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4StepPoint* preStep = aStep->GetPreStepPoint();
G4VSolid * solid =
preStep->GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
if( solid->GetEntityType() != "G4Sphere" ){
G4Exception("G4PSSphereSurfaceCurrentScorer. - Solid type is not supported.");
return FALSE;
}
G4Sphere* sphereSolid = (G4Sphere*)(solid);
G4int dirFlag =IsSelectedSurface(aStep,sphereSolid);
if ( dirFlag > 0 ) {
G4double radi = sphereSolid->GetInsideRadius();
G4double dph = sphereSolid->GetDeltaPhiAngle()/radian;
G4double stth = sphereSolid->GetStartThetaAngle()/radian;
G4double enth = stth+sphereSolid->GetDeltaThetaAngle()/radian;
G4double square = radi*radi*dph*( -std::cos(enth) + std::cos(stth) );
G4double current = preStep->GetWeight(); // Current (Particle Weight)
current = current/square; // Current with angle.
if ( fDirection == fCurrent_InOut || fDirection == dirFlag ){
G4int index = GetIndex(aStep);
EvtMap->add(index,current);
}
}
return TRUE;
}
G4int G4PSSphereSurfaceCurrent::IsSelectedSurface(G4Step* aStep, G4Sphere* sphereSolid){
G4TouchableHandle theTouchable =
aStep->GetPreStepPoint()->GetTouchableHandle();
G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
// Entering Geometry
G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
G4ThreeVector localpos1 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
G4double localR2 = localpos1.x()*localpos1.x()
+localpos1.y()*localpos1.y()
+localpos1.z()*localpos1.z();
G4double InsideRadius2 =
sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
return fCurrent_In;
}
}
if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
// Exiting Geometry
G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
G4ThreeVector localpos2 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
G4double localR2 = localpos2.x()*localpos2.x()
+localpos2.y()*localpos2.y()
+localpos2.z()*localpos2.z();
G4double InsideRadius2 =
sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
return fCurrent_Out;
}
}
return -1;
}
void G4PSSphereSurfaceCurrent::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSSphereSurfaceCurrent::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSSphereSurfaceCurrent::clear(){
EvtMap->clear();
}
void G4PSSphereSurfaceCurrent::DrawAll()
{;}
void G4PSSphereSurfaceCurrent::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " current : " << *(itr->second)
<< G4endl;
}
}
@@ -1,189 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSSphereSurfaceFlux.cc,v 1.3 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSSphereSurfaceFlux
#include "G4PSSphereSurfaceFlux.hh"
#include "G4StepStatus.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4GeometryTolerance.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring only Surface Flux.
// Flux version assumes only for G4Sphere shape.
//
// Surface is defined at the inside of sphere.
// Direction -Rmin +Rmax
// 0 IN || OUT ->|<- |
// 1 IN ->| |
// 2 OUT |<- |
//
// Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
// 29-Mar-2007 T.Aso, Bug fix for momentum direction at outgoing flux.
//
///////////////////////////////////////////////////////////////////////////////
G4PSSphereSurfaceFlux::G4PSSphereSurfaceFlux(G4String name,
G4int direction, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction)
{;}
G4PSSphereSurfaceFlux::~G4PSSphereSurfaceFlux()
{;}
G4bool G4PSSphereSurfaceFlux::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4StepPoint* preStep = aStep->GetPreStepPoint();
G4VSolid * solid =
preStep->GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
if( solid->GetEntityType() != "G4Sphere" ){
G4Exception("G4PSSphereSurfaceFluxScorer. - Solid type is not supported.");
return FALSE;
}
G4Sphere* sphereSolid = (G4Sphere*)(solid);
G4int dirFlag =IsSelectedSurface(aStep,sphereSolid);
if ( dirFlag > 0 ) {
if ( fDirection == fFlux_InOut || fDirection == dirFlag ){
G4StepPoint* thisStep=0;
if ( dirFlag == fFlux_In ){
thisStep = preStep;
}else if ( dirFlag == fFlux_Out ){
thisStep = aStep->GetPreStepPoint();
}else{
return FALSE;
}
G4TouchableHandle theTouchable = thisStep->GetTouchableHandle();
G4ThreeVector pdirection = thisStep->GetMomentumDirection();
G4ThreeVector localdir =
theTouchable->GetHistory()->GetTopTransform().TransformAxis(pdirection);
G4double localdirL2 = localdir.x()*localdir.x()
+localdir.y()*localdir.y()
+localdir.z()*localdir.z();
G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
G4ThreeVector localpos1 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
G4double localR2 = localpos1.x()*localpos1.x()
+localpos1.y()*localpos1.y()
+localpos1.z()*localpos1.z();
G4double anglefactor = (localdir.x()*localpos1.x()
+localdir.y()*localpos1.y()
+localdir.z()*localpos1.z())
/std::sqrt(localdirL2)/std::sqrt(localR2);
G4double radi = sphereSolid->GetInsideRadius();
G4double dph = sphereSolid->GetDeltaPhiAngle()/radian;
G4double stth = sphereSolid->GetStartThetaAngle()/radian;
G4double enth = stth+sphereSolid->GetDeltaThetaAngle()/radian;
G4double square = radi*radi*dph*( -std::cos(enth) + std::cos(stth) );
G4double current = thisStep->GetWeight(); // Flux (Particle Weight)
current = current/square; // Flux with angle.
current /= anglefactor;
G4int index = GetIndex(aStep);
EvtMap->add(index,current);
}
}
return TRUE;
}
G4int G4PSSphereSurfaceFlux::IsSelectedSurface(G4Step* aStep, G4Sphere* sphereSolid){
G4TouchableHandle theTouchable =
aStep->GetPreStepPoint()->GetTouchableHandle();
G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
if (aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary ){
// Entering Geometry
G4ThreeVector stppos1= aStep->GetPreStepPoint()->GetPosition();
G4ThreeVector localpos1 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
G4double localR2 = localpos1.x()*localpos1.x()
+localpos1.y()*localpos1.y()
+localpos1.z()*localpos1.z();
G4double InsideRadius2 =
sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
return fFlux_In;
}
}
if (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary ){
// Exiting Geometry
G4ThreeVector stppos2= aStep->GetPostStepPoint()->GetPosition();
G4ThreeVector localpos2 =
theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
G4double localR2 = localpos2.x()*localpos2.x()
+localpos2.y()*localpos2.y()
+localpos2.z()*localpos2.z();
G4double InsideRadius2 =
sphereSolid->GetInsideRadius()*sphereSolid->GetInsideRadius();
if(std::fabs( localR2 - InsideRadius2 ) < kCarTolerance ){
return fFlux_Out;
}
}
return -1;
}
void G4PSSphereSurfaceFlux::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
if ( HCID < 0 ) HCID = GetCollectionID(0);
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSSphereSurfaceFlux::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSSphereSurfaceFlux::clear(){
EvtMap->clear();
}
void G4PSSphereSurfaceFlux::DrawAll()
{;}
void G4PSSphereSurfaceFlux::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() <<G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " current : " << *(itr->second)
<< G4endl;
}
}
@@ -1,112 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSTrackCounter.cc,v 1.2 2007/06/21 15:04:02 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSTrackCounter
#include "G4PSTrackCounter.hh"
///////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring number of tracks in a cell.
//
// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSTrackCounter::G4PSTrackCounter(G4String name, G4int direction, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),fDirection(direction),weighted(false)
{;}
G4PSTrackCounter::~G4PSTrackCounter()
{;}
G4bool G4PSTrackCounter::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4StepPoint* preStep = aStep->GetPreStepPoint();
G4StepPoint* posStep = aStep->GetPostStepPoint();
G4bool IsEnter = preStep->GetStepStatus()==fGeomBoundary;
G4bool IsExit = posStep->GetStepStatus()==fGeomBoundary;
// Regular : count in prestep volume.
G4int index = GetIndex(aStep);
// G4cout << " trk " << aStep->GetTrack()->GetTrackID()
// << " index " << index << " In " << IsEnter << " Out " <<IsExit
// << " PreStatus " << preStep->GetStepStatus()
// << " PostStatus " << posStep->GetStepStatus()
// << " w " << aStep->GetPreStepPoint()->GetWeight()
// << G4endl;
G4bool flag = FALSE;
if ( IsEnter && fDirection == fCurrent_In ) flag = TRUE;
else if ( IsExit && fDirection == fCurrent_Out ) flag = TRUE;
else if ( (IsExit||IsEnter) && fDirection == fCurrent_InOut ) flag = TRUE;
if ( flag ){
//G4cout << " Count " << G4endl;
G4double val = 1.0;
if(weighted) val *= aStep->GetPreStepPoint()->GetWeight();
EvtMap->add(index,val);
}
return TRUE;
}
void G4PSTrackCounter::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
//G4cout << "----- PS Initialize " << G4endl;
}
void G4PSTrackCounter::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSTrackCounter::clear(){
EvtMap->clear();
}
void G4PSTrackCounter::DrawAll()
{;}
void G4PSTrackCounter::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " track count: " << *(itr->second)
<< G4endl;
}
}
@@ -1,99 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PSTrackLength.cc,v 1.6 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4PSTrackLength
#include "G4PSTrackLength.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// (Description)
// This is a primitive scorer class for scoring sum of track length.
//
//
// Created: 2007-02-02 Tsukasa ASO, Akinori Kimura.
//
///////////////////////////////////////////////////////////////////////////////
G4PSTrackLength::G4PSTrackLength(G4String name, G4int depth)
:G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false),multiplyKinE(false),
divideByVelocity(false)
{;}
G4PSTrackLength::~G4PSTrackLength()
{;}
G4bool G4PSTrackLength::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4double trklength = aStep->GetStepLength();
if ( trklength == 0. ) return FALSE;
if(weighted) trklength *= aStep->GetPreStepPoint()->GetWeight();
if(multiplyKinE) trklength *= aStep->GetPreStepPoint()->GetKineticEnergy();
if(divideByVelocity) trklength /= aStep->GetPreStepPoint()->GetVelocity();
G4int index = GetIndex(aStep);
EvtMap->add(index,trklength);
return TRUE;
}
void G4PSTrackLength::Initialize(G4HCofThisEvent* HCE)
{
EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
if(HCID < 0) {HCID = GetCollectionID(0);}
HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
}
void G4PSTrackLength::EndOfEvent(G4HCofThisEvent*)
{;}
void G4PSTrackLength::clear(){
EvtMap->clear();
}
void G4PSTrackLength::DrawAll()
{;}
void G4PSTrackLength::PrintAll()
{
G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
G4cout << " PrimitiveScorer " << GetName() << G4endl;
G4cout << " Number of entries " << EvtMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
for(; itr != EvtMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first << " track length: " ;
if ( multiplyKinE && !divideByVelocity ){
G4cout << *(itr->second)/(mm*MeV) <<" mm*MeV";
} else if ( !multiplyKinE && divideByVelocity ){
G4cout << *(itr->second)*second <<" /second";
} else if ( multiplyKinE && divideByVelocity) {
G4cout << *(itr->second)/MeV*second <<" MeV/second";
} else {
G4cout << G4BestUnit(*(itr->second),"Length");
}
G4cout << G4endl;
}
}
@@ -1,74 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4SDKineticEnergyFilter.cc,v 1.6 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4VSensitiveDetector
#include "G4SDKineticEnergyFilter.hh"
#include "G4Step.hh"
#include "G4UnitsTable.hh"
////////////////////////////////////////////////////////////////////////////////
// class description:
//
// This is the class of a filter to be associated with a
// sensitive detector.
//
//
// Created: 2005-11-14 Tsukasa ASO.
//
///////////////////////////////////////////////////////////////////////////////
G4SDKineticEnergyFilter::G4SDKineticEnergyFilter(G4String name,
G4double elow,
G4double ehigh)
:G4VSDFilter(name),fLowEnergy(elow),fHighEnergy(ehigh)
{;}
G4SDKineticEnergyFilter::~G4SDKineticEnergyFilter()
{;}
G4bool G4SDKineticEnergyFilter::Accept(const G4Step* aStep) const
{
G4double kinetic = aStep->GetPreStepPoint()->GetKineticEnergy();
if ( kinetic < fLowEnergy ) return FALSE;
if ( kinetic >= fHighEnergy ) return FALSE;
return TRUE;
}
void G4SDKineticEnergyFilter::SetKineticEnergy(G4double elow, G4double ehigh){
fLowEnergy = elow;
fHighEnergy = ehigh;
}
void G4SDKineticEnergyFilter::show() {
G4cout << " G4SDKineticEnergyFilter:: " << GetName()
<< " LowE " << G4BestUnit(fLowEnergy,"Energy")
<< " HighE " << G4BestUnit(fHighEnergy,"Energy")
<<G4endl;
}
@@ -1,139 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4SDParticleFilter.cc,v 1.4 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4VSensitiveDetector
#include "G4SDParticleFilter.hh"
#include "G4Step.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
////////////////////////////////////////////////////////////////////////////////
// class description:
//
// This is the class of a filter to be associated with a
// sensitive detector.
// This class filters steps by partilce definition.
//
// Created: 2005-11-14 Tsukasa ASO.
//
///////////////////////////////////////////////////////////////////////////////
G4SDParticleFilter::G4SDParticleFilter(G4String name)
:G4VSDFilter(name)
{
thePdef.clear();
}
G4SDParticleFilter::G4SDParticleFilter(G4String name,
const G4String& particleName)
:G4VSDFilter(name)
{
thePdef.clear();
G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(particleName);
if(!pd)
{
G4String msg = "Particle <";
msg += particleName;
msg += "> not found.";
G4Exception("G4SDParticleFilter::G4SDParticleFilter()",
"DetUtil0000",FatalException,msg);
}
thePdef.push_back(pd);
}
G4SDParticleFilter::G4SDParticleFilter(G4String name,
const std::vector<G4String>& particleNames)
:G4VSDFilter(name)
{
thePdef.clear();
for ( size_t i = 0; i < particleNames.size(); i++){
G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->FindParticle(particleNames[i]);
if(!pd)
{
G4String msg = "Particle <";
msg += particleNames[i];
msg += "> not found.";
G4Exception("G4SDParticleFilter::G4SDParticleFilter()",
"DetUtil0000",FatalException,msg);
}
thePdef.push_back(pd);
}
}
G4SDParticleFilter::G4SDParticleFilter(G4String name,
const std::vector<G4ParticleDefinition*>& particleDef)
:G4VSDFilter(name), thePdef(particleDef)
{
for ( size_t i = 0; i < particleDef.size(); i++){
if(!particleDef[i]) G4Exception("G4SDParticleFilter::G4SDParticleFilter()","DetUtil0001",FatalException,
"NULL pointer is found in the given particleDef vector.");
}
}
G4SDParticleFilter::~G4SDParticleFilter()
{
thePdef.clear();
}
G4bool G4SDParticleFilter::Accept(const G4Step* aStep) const
{
for ( size_t i = 0; i < thePdef.size(); i++){
if ( thePdef[i] == aStep->GetTrack()->GetDefinition() ) return TRUE;
}
return FALSE;
}
void G4SDParticleFilter::add(const G4String& particleName)
{
G4ParticleDefinition* pd =
G4ParticleTable::GetParticleTable()->FindParticle(particleName);
if(!pd)
{
G4String msg = "Particle <";
msg += particleName;
msg += "> not found.";
G4Exception("G4SDParticleFilter::add()",
"DetUtil0002",FatalException,msg);
}
for ( size_t i = 0; i < thePdef.size(); i++){
if ( thePdef[i] == pd ) return;
}
thePdef.push_back(pd);
}
void G4SDParticleFilter::show(){
G4cout << "----G4SDParticleFileter particle list------"<<G4endl;
for ( size_t i = 0; i < thePdef.size(); i++){
G4cout << thePdef[i]->GetParticleName() << G4endl;
}
G4cout << "-------------------------------------------"<<G4endl;
}
@@ -1,83 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4SDParticleWithEnergyFilter.cc,v 1.3 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// G4VSensitiveDetector
#include "G4SDParticleWithEnergyFilter.hh"
#include "G4Step.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
////////////////////////////////////////////////////////////////////////////////
// class description:
//
// This is the class of a filter to be associated with a
// sensitive detector.
// This class filters steps by partilce definition and kinetic energy.
//
// Created: 2005-11-14 Tsukasa ASO.
//
///////////////////////////////////////////////////////////////////////////////
G4SDParticleWithEnergyFilter::G4SDParticleWithEnergyFilter(G4String name,
G4double elow,
G4double ehigh)
:G4VSDFilter(name)
{
fParticleFilter = new G4SDParticleFilter(name);
fKineticFilter = new G4SDKineticEnergyFilter(name,elow,ehigh);
}
G4SDParticleWithEnergyFilter::~G4SDParticleWithEnergyFilter()
{
delete fParticleFilter;
delete fKineticFilter;
}
G4bool G4SDParticleWithEnergyFilter::Accept(const G4Step* aStep) const
{
if ( ! fParticleFilter->Accept(aStep) ) return FALSE;
if ( ! fKineticFilter->Accept(aStep) ) return FALSE;
return TRUE;
}
void G4SDParticleWithEnergyFilter::add(const G4String& particleName)
{
fParticleFilter->add(particleName);
}
void G4SDParticleWithEnergyFilter::SetKineticEnergy(G4double elow,
G4double ehigh)
{
fKineticFilter->SetKineticEnergy(elow,ehigh);
}
void G4SDParticleWithEnergyFilter::show(){
fParticleFilter->show();
fKineticFilter->show();
}
@@ -0,0 +1,490 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4ScoreQuantityMessenger.cc,v 1.8 2007/11/07 04:12:07 akimura Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// ---------------------------------------------------------------------
#include "G4ScoreQuantityMessenger.hh"
#include "G4ScoringManager.hh"
#include "G4VScoringMesh.hh"
#include "G4PSCellCharge3D.hh"
#include "G4PSCellFlux3D.hh"
#include "G4PSPassageCellFlux3D.hh"
#include "G4PSEnergyDeposit3D.hh"
#include "G4PSDoseDeposit3D.hh"
#include "G4PSNofStep3D.hh"
#include "G4PSNofSecondary3D.hh"
//
#include "G4PSTrackLength3D.hh"
#include "G4PSPassageCellCurrent3D.hh"
#include "G4PSPassageTrackLength3D.hh"
#include "G4PSFlatSurfaceCurrent3D.hh"
#include "G4PSFlatSurfaceFlux3D.hh"
#include "G4PSSphereSurfaceCurrent3D.hh"
#include "G4PSSphereSurfaceFlux3D.hh"
#include "G4PSCylinderSurfaceCurrent3D.hh"
#include "G4PSCylinderSurfaceFlux3D.hh"
#include "G4PSNofCollision3D.hh"
#include "G4PSPopulation3D.hh"
#include "G4PSTrackCounter3D.hh"
#include "G4PSTermination3D.hh"
#include "G4SDChargedFilter.hh"
#include "G4SDNeutralFilter.hh"
#include "G4SDKineticEnergyFilter.hh"
#include "G4SDParticleFilter.hh"
#include "G4SDParticleWithEnergyFilter.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcommand.hh"
#include "G4Tokenizer.hh"
#include "G4UnitsTable.hh"
G4ScoreQuantityMessenger::G4ScoreQuantityMessenger(G4ScoringManager* SManager)
:fSMan(SManager)
{
QuantityCommands();
FilterCommands();
}
void G4ScoreQuantityMessenger::FilterCommands()
{
G4UIparameter* param;
//
// Filter commands
filterDir = new G4UIdirectory("/score/filter/");
filterDir->SetGuidance(" Scoring filter commands.");
//
fchargedCmd = new G4UIcmdWithAString("/score/filter/charged",this);
fchargedCmd->SetGuidance("Charged particle filter.");
fchargedCmd->SetParameterName("fname",false);
//
fneutralCmd = new G4UIcmdWithAString("/score/filter/neutral",this);
fneutralCmd->SetGuidance("Neutral particle filter.");
fneutralCmd->SetParameterName("fname",false);
//
fkinECmd = new G4UIcommand("/score/filter/kineticEnergy",this);
fkinECmd->SetGuidance("Kinetic energy filter.");
fkinECmd->SetGuidance("[usage] /score/filter/kineticEnergy fname Elow Ehigh unit");
fkinECmd->SetGuidance(" fname :(String) Filter Name ");
fkinECmd->SetGuidance(" Elow :(Double) Lower edge of kinetic energy");
fkinECmd->SetGuidance(" Ehigh :(Double) Higher edge of kinetic energy");
fkinECmd->SetGuidance(" unit :(String) unit of given kinetic energy");
param = new G4UIparameter("fname",'s',false);
fkinECmd->SetParameter(param);
param = new G4UIparameter("elow",'d',true);
param->SetDefaultValue("0.0");
fkinECmd->SetParameter(param);
param = new G4UIparameter("ehigh",'d',false);
fkinECmd->SetParameter(param);
G4String smax = DtoS(DBL_MAX);
param->SetDefaultValue(smax);
param = new G4UIparameter("unit",'s',false);
param->SetDefaultValue("keV");
fkinECmd->SetParameter(param);
//
fparticleCmd = new G4UIcommand("/score/filter/particle",this);
fparticleCmd->SetGuidance("Particle filter.");
fparticleCmd->SetGuidance("[usage] /score/filter/particle fname p0 .. pn");
fparticleCmd->SetGuidance(" fname :(String) Filter Name ");
fparticleCmd->SetGuidance(" p0 .. pn :(String) particle names");
param = new G4UIparameter("fname",'s',false);
fparticleCmd->SetParameter(param);
param = new G4UIparameter("particlelist",'s',false);
param->SetDefaultValue("");
fparticleCmd->SetParameter(param);
//
//
//
fparticleKinECmd = new G4UIcommand("/score/filter/particleWithKineticEnergy",this);
fparticleKinECmd->SetGuidance("Particle with kinetic energy filter.");
fparticleKinECmd->SetGuidance("[usage] /score/filter/particleWithKineticEnergy fname Elow Ehigh unit p0 .. pn");
fparticleKinECmd->SetGuidance(" fname :(String) Filter Name ");
fparticleKinECmd->SetGuidance(" Elow :(Double) Lower edge of kinetic energy");
fparticleKinECmd->SetGuidance(" Ehigh :(Double) Higher edge of kinetic energy");
fparticleKinECmd->SetGuidance(" unit :(String) unit of given kinetic energy");
fparticleKinECmd->SetGuidance(" p0 .. pn :(String) particle names");
param = new G4UIparameter("fname",'s',false);
fparticleKinECmd->SetParameter(param);
param = new G4UIparameter("elow",'d',false);
param->SetDefaultValue("0.0");
fparticleKinECmd->SetParameter(param);
param = new G4UIparameter("ehigh",'d',true);
param->SetDefaultValue(smax);
fparticleKinECmd->SetParameter(param);
param = new G4UIparameter("unit",'s',true);
param->SetDefaultValue("keV");
fparticleKinECmd->SetParameter(param);
param = new G4UIparameter("particlelist",'s',false);
param->SetDefaultValue("");
fparticleKinECmd->SetParameter(param);
//
//
}
G4ScoreQuantityMessenger::~G4ScoreQuantityMessenger()
{
delete quantityDir;
delete qTouchCmd;
//
delete qCellChgCmd;
delete qCellFluxCmd;
delete qPassCellFluxCmd;
delete qeDepCmd;
delete qdoseDepCmd;
delete qnOfStepCmd;
delete qnOfSecondaryCmd;
//
delete qTrackLengthCmd;
delete qPassCellCurrCmd;
delete qPassTrackLengthCmd;
delete qFlatSurfCurrCmd;
delete qFlatSurfFluxCmd;
// delete qSphereSurfCurrCmd;
// delete qSphereSurfFluxCmd;
// delete qCylSurfCurrCmd;
// delete qCylSurfFluxCmd;
delete qNofCollisionCmd;
delete qPopulationCmd;
delete qTrackCountCmd;
delete qTerminationCmd;
//
delete filterDir;
delete fchargedCmd;
delete fneutralCmd;
delete fkinECmd;
delete fparticleCmd;
delete fparticleKinECmd;
}
void G4ScoreQuantityMessenger::SetNewValue(G4UIcommand * command,G4String newVal)
{
//
// Get Current Mesh
//
G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
if(!mesh)
{
G4cerr << "ERROR : No mesh is currently open. Open/create a mesh first. Command ignored." << G4endl;
return;
}
// Tokens
G4TokenVec token;
FillTokenVec(newVal,token);
//
// Commands for Current Mesh
if(command==qTouchCmd) {
mesh->SetCurrentPrimitiveScorer(newVal);
} else if(command== qCellChgCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSCellCharge3D(newVal));
} else {
G4cout << "WARNING[" << qTouchCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qCellFluxCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSCellFlux3D(newVal));
} else {
G4cout << "WARNING[" << qCellFluxCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qPassCellFluxCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSPassageCellFlux3D(newVal));
} else {
G4cout << "WARNING[" << qPassCellFluxCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command==qeDepCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSEnergyDeposit3D(newVal));
} else {
G4cout << "WARNING[" << qeDepCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qdoseDepCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSDoseDeposit3D(newVal));
} else {
G4cout << "WARNING[" << qdoseDepCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qnOfStepCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSNofStep3D(newVal));
} else {
G4cout << "WARNING[" << qnOfStepCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qnOfSecondaryCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(new G4PSNofSecondary3D(newVal));
} else {
G4cout << "WARNING[" << qnOfSecondaryCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qTrackLengthCmd) {
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSTrackLength3D* ps = new G4PSTrackLength3D(token[0]);
ps->Weighted(StoB(token[1]));
ps->MultiplyKineticEnergy(StoB(token[2]));
ps->DivideByVelocity(StoB(token[3]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qTrackLengthCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qPassCellCurrCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSPassageCellCurrent* ps = new G4PSPassageCellCurrent3D(token[0]);
ps->Weighted(StoB(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qPassCellCurrCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qPassTrackLengthCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSPassageTrackLength* ps = new G4PSPassageTrackLength3D(token[0]);
ps->Weighted(StoB(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qPassTrackLengthCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qFlatSurfCurrCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSFlatSurfaceCurrent3D* ps =
new G4PSFlatSurfaceCurrent3D(token[0],StoI(token[1]));
ps->Weighted(StoB(token[2]));
ps->DivideByArea(StoB(token[3]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qFlatSurfCurrCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qFlatSurfFluxCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
mesh->SetPrimitiveScorer(
new G4PSFlatSurfaceFlux3D(token[0],StoI(token[1])));
} else {
G4cout << "WARNING[" << qFlatSurfFluxCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
// } else if(command== qSphereSurfCurrCmd){
// if(!mesh->FindPrimitiveScorer(newVal)) {
// G4PSSphereSurfaceCurrent3D* ps =
// new G4PSSphereSurfaceCurrent3D(token[0],StoI(token[1]));
// ps->Weighted(StoB(token[2]));
// ps->DivideByArea(StoB(token[3]));
// mesh->SetPrimitiveScorer(ps);
// } else {
// G4cout << "WARNING[" << qSphereSurfCurrCmd->GetCommandPath()
// << "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
// mesh->SetNullToCurrentPrimitiveScorer();
// }
// } else if(command== qSphereSurfFluxCmd){
// if(!mesh->FindPrimitiveScorer(newVal)) {
// mesh->SetPrimitiveScorer(
// new G4PSSphereSurfaceFlux3D(token[0], StoI(token[1])));
// } else {
// G4cout << "WARNING[" << qSphereSurfFluxCmd->GetCommandPath()
// << "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
// mesh->SetNullToCurrentPrimitiveScorer();
// }
// } else if(command== qCylSurfCurrCmd){
// if(!mesh->FindPrimitiveScorer(newVal)) {
// G4PSCylinderSurfaceCurrent3D* ps =
// new G4PSCylinderSurfaceCurrent3D(token[0],StoI(token[1]));
// ps->Weighted(StoB(token[2]));
// ps->DivideByArea(StoB(token[3]));
// mesh->SetPrimitiveScorer(ps);
// } else {
// G4cout << "WARNING[" << qCylSurfCurrCmd->GetCommandPath()
// << "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
// mesh->SetNullToCurrentPrimitiveScorer();
// }
// } else if(command== qCylSurfFluxCmd){
// if(!mesh->FindPrimitiveScorer(newVal)) {
// mesh->SetPrimitiveScorer(
// new G4PSCylinderSurfaceFlux3D(token[0], StoI(token[1])));
// } else {
// G4cout << "WARNING[" << qCylSurfFluxCmd->GetCommandPath()
// << "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
// mesh->SetNullToCurrentPrimitiveScorer();
// }
} else if(command== qNofCollisionCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSNofCollision3D* ps =new G4PSNofCollision3D(token[0]);
ps->Weighted(StoB(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qNofCollisionCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qPopulationCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSPopulation3D* ps =new G4PSPopulation3D(token[0]);
ps->Weighted(StoB(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qPopulationCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qTrackCountCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSTrackCounter3D* ps =new G4PSTrackCounter3D(token[0],StoI(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qTrackCountCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
} else if(command== qTerminationCmd){
if(!mesh->FindPrimitiveScorer(newVal)) {
G4PSTermination3D* ps =new G4PSTermination3D(token[0]);
ps->Weighted(StoB(token[1]));
mesh->SetPrimitiveScorer(ps);
} else {
G4cout << "WARNING[" << qTerminationCmd->GetCommandPath()
<< "] : Quantity name, \"" << newVal << "\", is already existing." << G4endl;
mesh->SetNullToCurrentPrimitiveScorer();
}
//
// Filters
//
}else if(command== fchargedCmd){
if(!mesh->IsCurrentPrimitiveScorerNull()) {
mesh->SetFilter(new G4SDChargedFilter(token[0]));
} else {
G4cout << "WARNING[" << fchargedCmd->GetCommandPath()
<< "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
}
}else if(command== fneutralCmd){
if(!mesh->IsCurrentPrimitiveScorerNull()) {
mesh->SetFilter(new G4SDNeutralFilter(token[0]));
} else {
G4cout << "WARNING[" << fneutralCmd->GetCommandPath()
<< "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
}
}else if(command== fkinECmd){
if(!mesh->IsCurrentPrimitiveScorerNull()) {
G4String& name = token[0];
G4double elow = StoD(token[1]);
G4double ehigh = StoD(token[2]);
mesh->SetFilter(new G4SDKineticEnergyFilter(name,elow,ehigh));
} else {
G4cout << "WARNING[" << fkinECmd->GetCommandPath()
<< "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
}
}else if(command== fparticleKinECmd){
if(!mesh->IsCurrentPrimitiveScorerNull()) {
FParticleWithEnergyCommand(mesh,token);
} else {
G4cout << "WARNING[" << fparticleKinECmd->GetCommandPath()
<< "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
}
} else if(command==fparticleCmd) {
if(!mesh->IsCurrentPrimitiveScorerNull()) {
FParticleCommand(mesh,token);
} else {
G4cout << "WARNING[" << fparticleCmd->GetCommandPath()
<< "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
}
}
}
G4String G4ScoreQuantityMessenger::GetCurrentValue(G4UIcommand * /*command*/)
{
G4String val;
return val;
}
void G4ScoreQuantityMessenger::FillTokenVec(G4String newValues, G4TokenVec& token){
G4Tokenizer next(newValues);
G4String val;
while ( !(val = next()).isNull() ) {
token.push_back(val);
}
}
void G4ScoreQuantityMessenger::FParticleCommand(G4VScoringMesh* mesh, G4TokenVec& token){
//
// Filter name
G4String name = token[0];
//
// particle list
std::vector<G4String> pnames;
for ( G4int i = 1; i<(G4int)token.size(); i++){
pnames.push_back(token[i]);
}
//
// Attach Filter
mesh->SetFilter(new G4SDParticleFilter(name,pnames));
}
void G4ScoreQuantityMessenger::FParticleWithEnergyCommand(G4VScoringMesh* mesh,G4TokenVec& token){
G4String& name = token[0];
G4double elow = StoD(token[1]);
G4double ehigh= StoD(token[2]);
G4double unitVal = G4UnitDefinition::GetValueOf(token[3]);
G4SDParticleWithEnergyFilter* filter =
new G4SDParticleWithEnergyFilter(name,elow*unitVal,ehigh*unitVal);
for ( G4int i = 4; i < (G4int)token.size(); i++){
filter->add(token[i]);
}
mesh->SetFilter(filter);
}
@@ -0,0 +1,333 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4ScoreQuantityMessengerQCmd.cc,v 1.6 2007/11/07 04:12:07 akimura Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// ---------------------------------------------------------------------
#include "G4ScoreQuantityMessenger.hh"
#include "G4ScoringManager.hh"
#include "G4VScoringMesh.hh"
#include "G4PSCellCharge3D.hh"
#include "G4PSCellFlux3D.hh"
#include "G4PSPassageCellFlux3D.hh"
#include "G4PSEnergyDeposit3D.hh"
#include "G4PSDoseDeposit3D.hh"
#include "G4PSNofStep3D.hh"
#include "G4PSNofSecondary3D.hh"
//
#include "G4PSTrackLength3D.hh"
#include "G4PSPassageCellCurrent3D.hh"
#include "G4PSPassageTrackLength3D.hh"
#include "G4PSFlatSurfaceCurrent3D.hh"
#include "G4PSFlatSurfaceFlux3D.hh"
#include "G4PSSphereSurfaceCurrent3D.hh"
#include "G4PSSphereSurfaceFlux3D.hh"
#include "G4PSCylinderSurfaceCurrent3D.hh"
#include "G4PSCylinderSurfaceFlux3D.hh"
#include "G4PSNofCollision3D.hh"
#include "G4PSPopulation3D.hh"
#include "G4PSTrackCounter3D.hh"
#include "G4PSTermination3D.hh"
#include "G4SDChargedFilter.hh"
#include "G4SDNeutralFilter.hh"
#include "G4SDKineticEnergyFilter.hh"
#include "G4SDParticleFilter.hh"
#include "G4SDParticleWithEnergyFilter.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcommand.hh"
#include "G4Tokenizer.hh"
#include "G4UnitsTable.hh"
void G4ScoreQuantityMessenger::QuantityCommands()
{
G4UIparameter* param;
//
// Quantity commands
quantityDir = new G4UIdirectory("/score/quantity/");
quantityDir->SetGuidance("Scoring quantity of the mesh.");
//
qTouchCmd= new G4UIcmdWithAString("/score/quantity/touch",this);
qTouchCmd->SetGuidance("Assign previously defined quantity to the current quantity.");
qTouchCmd->SetParameterName("qname",false);
//
qeDepCmd = new G4UIcmdWithAString("/score/quantity/energyDeposit",this);
qeDepCmd->SetGuidance("Energy deposit scorer.");
qeDepCmd->SetParameterName("qname",false);
//
qCellChgCmd = new G4UIcmdWithAString("/score/quantity/cellCharge",this);
qCellChgCmd->SetGuidance("Cell charge scorer.");
qCellChgCmd->SetParameterName("qname",false);
//
qCellFluxCmd = new G4UIcmdWithAString("/score/quantity/cellFlux",this);
qCellFluxCmd->SetGuidance("Cell flux scorer.");
qCellFluxCmd->SetParameterName("qname",false);
//
qPassCellFluxCmd = new G4UIcmdWithAString("/score/quantity/passageCellFlux",this);
qPassCellFluxCmd->SetGuidance("Passage cell flux scorer");
qPassCellFluxCmd->SetParameterName("qname",false);
//
qdoseDepCmd = new G4UIcmdWithAString("/score/quantity/doseDeposit",this);
qdoseDepCmd->SetGuidance("Dose deposit scorer.");
qdoseDepCmd->SetParameterName("qname",false);
//
qnOfStepCmd = new G4UIcmdWithAString("/score/quantity/nOfStep",this);
qnOfStepCmd->SetGuidance("Number of step scorer.");
qnOfStepCmd->SetParameterName("qname",false);
//
qnOfSecondaryCmd = new G4UIcmdWithAString("/score/quantity/nOfSecondary",this);
qnOfSecondaryCmd->SetGuidance("Number of secondary scorer.");
qnOfSecondaryCmd->SetParameterName("qname",false);
//
qTrackLengthCmd = new G4UIcommand("/score/quantity/trackLength",this);
qTrackLengthCmd->SetGuidance("Track length scorer.");
qTrackLengthCmd->
SetGuidance("[usage] /score/quantiy/trackLength qname wflag kflag vflag ");
qTrackLengthCmd->SetGuidance(" qname :(String) scorer name");
qTrackLengthCmd->SetGuidance(" wflag :(Bool) weighted");
qTrackLengthCmd->SetGuidance(" kflag :(Bool) multiply kinetic energy");
qTrackLengthCmd->SetGuidance(" vflag :(Bool) divide by velocity");
param = new G4UIparameter("qname",'s',false);
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("kflag",'b',true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("vflag",'b',true);
param->SetDefaultValue("false");
qTrackLengthCmd->SetParameter(param);
//
qPassCellCurrCmd = new G4UIcommand("/score/quantity/passageCellCurrent",this);
qPassCellCurrCmd->SetGuidance("Passage cell current scorer.");
qPassCellCurrCmd->
SetGuidance("[usage] /score/quantiy/passageCellCurrent qname wflag");
qPassCellCurrCmd->SetGuidance(" qname :(String) scorer name");
qPassCellCurrCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qPassCellCurrCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("true");
qPassCellCurrCmd->SetParameter(param);
//
qPassTrackLengthCmd = new G4UIcommand("/score/quantity/passageTrackLength",this);
qPassTrackLengthCmd->SetGuidance("Passage track length scorer.");
qPassTrackLengthCmd->
SetGuidance("[usage] /score/quantiy/passageTrackLength qname wflag");
qPassTrackLengthCmd->SetGuidance(" qname :(String) scorer name");
qPassTrackLengthCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qPassTrackLengthCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("true");
qPassTrackLengthCmd->SetParameter(param);
//
qFlatSurfCurrCmd = new G4UIcommand("/score/quantity/flatSurfaceCurrent",this);
qFlatSurfCurrCmd->SetGuidance("Flat surface current Scorer.");
qFlatSurfCurrCmd->
SetGuidance("[usage] /score/quantiy/flatSurfaceCurrent qname dflag wflag aflag");
qFlatSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
qFlatSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
qFlatSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
qFlatSurfCurrCmd->SetGuidance(" : 1 = In only");
qFlatSurfCurrCmd->SetGuidance(" : 2 = Out only");
qFlatSurfCurrCmd->SetGuidance(" wflag :(Bool) weighted");
qFlatSurfCurrCmd->SetGuidance(" aflag :(Bool) divide by area");
param = new G4UIparameter("qname",'s',false);
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param->SetDefaultValue("0");
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("true");
qFlatSurfCurrCmd->SetParameter(param);
param = new G4UIparameter("aflag",'b',true);
param->SetDefaultValue("true");
qFlatSurfCurrCmd->SetParameter(param);
//
qFlatSurfFluxCmd = new G4UIcommand("/score/quantity/flatSurfaceFlux",this);
qFlatSurfFluxCmd->SetGuidance("Flat surface flux scorer.");
qFlatSurfFluxCmd->
SetGuidance("[usage] /score/quantiy/flatSurfaceFlux qname dflag");
qFlatSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
qFlatSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
qFlatSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
qFlatSurfFluxCmd->SetGuidance(" : 1 = In only");
qFlatSurfFluxCmd->SetGuidance(" : 2 = Out only");
param = new G4UIparameter("qname",'s',false);
qFlatSurfFluxCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param->SetDefaultValue("0");
qFlatSurfFluxCmd->SetParameter(param);
//
// qSphereSurfCurrCmd = new G4UIcommand("/score/quantity/sphereSurfaceCurrent",this);
// qSphereSurfCurrCmd->SetGuidance("Sphere surface current Scorer.");
// qSphereSurfCurrCmd->
// SetGuidance("[usage] /score/quantiy/sphereSurfaceCurrent qname dflag wflag aflag");
// qSphereSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfCurrCmd->SetGuidance(" : 1 = In only");
// qSphereSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qSphereSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qSphereSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qSphereSurfCurrCmd->SetParameter(param);
//
// qSphereSurfFluxCmd = new G4UIcommand("/score/quantity/sphereSurfaceFlux",this);
// qSphereSurfFluxCmd->SetGuidance("Sphere surface Flux Scorer.");
// qSphereSurfFluxCmd->
// SetGuidance("[usage] /score/quantiy/sphereSurfaceFlux qname dflag");
// qSphereSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qSphereSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qSphereSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qSphereSurfFluxCmd->SetGuidance(" : 1 = In only");
// qSphereSurfFluxCmd->SetGuidance(" : 2 = Out only");
// param = new G4UIparameter("qname",'s',false);
// qSphereSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qSphereSurfFluxCmd->SetParameter(param);
//
// qCylSurfCurrCmd = new G4UIcommand("/score/quantity/cylinderSurfaceCurrent",this);
// qCylSurfCurrCmd->SetGuidance("Cylinder surface current Scorer.");
// qCylSurfCurrCmd->
// SetGuidance("[usage] /score/quantiy/cylinderSurfaceCurrent qname dflag wflag aflag");
// qCylSurfCurrCmd->SetGuidance(" qname :(String) scorer name");
// qCylSurfCurrCmd->SetGuidance(" dflag :(Int) direction flag");
// qCylSurfCurrCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfCurrCmd->SetGuidance(" : 1 = In only");
// qCylSurfCurrCmd->SetGuidance(" : 2 = Out only");
// qCylSurfCurrCmd->SetGuidance(" wflag :(Bool) Weighted");
// qCylSurfCurrCmd->SetGuidance(" aflag :(Bool) DivideByArea");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("wflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
// param = new G4UIparameter("aflag",'b',true);
// param->SetDefaultValue("true");
// qCylSurfCurrCmd->SetParameter(param);
//
// qCylSurfFluxCmd = new G4UIcommand("/score/quantity/cylinderSurfaceFlux",this);
// qCylSurfFluxCmd->SetGuidance("Cylinder surface Flux Scorer.");
// qCylSurfFluxCmd->
// SetGuidance("[usage] /score/quantiy/cylinderSurfaceFlux qname dflag");
// qCylSurfFluxCmd->SetGuidance(" qname :(String) scorer name");
// qCylSurfFluxCmd->SetGuidance(" dflag :(Int) direction flag");
// qCylSurfFluxCmd->SetGuidance(" : 0 = Both In and Out");
// qCylSurfFluxCmd->SetGuidance(" : 1 = In only");
// qCylSurfFluxCmd->SetGuidance(" : 2 = Out only");
// param = new G4UIparameter("qname",'s',false);
// qCylSurfFluxCmd->SetParameter(param);
// param = new G4UIparameter("dflag",'i',true);
// param->SetDefaultValue("0");
// qCylSurfFluxCmd->SetParameter(param);
//
qNofCollisionCmd = new G4UIcommand("/score/quantity/nOfCollision",this);
qNofCollisionCmd->SetGuidance("Number of collision scorer.");
qNofCollisionCmd->
SetGuidance("[usage] /score/quantiy/nOfCollision qname wflag");
qNofCollisionCmd->SetGuidance(" qname :(String) scorer name");
qNofCollisionCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qNofCollisionCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("false");
qNofCollisionCmd->SetParameter(param);
//
qPopulationCmd = new G4UIcommand("/score/quantity/population",this);
qPopulationCmd->SetGuidance("Population scorer.");
qPopulationCmd->
SetGuidance("[usage] /score/quantiy/population qname wflag");
qPopulationCmd->SetGuidance(" qname :(String) scorer name");
qPopulationCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qPopulationCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("false");
qPopulationCmd->SetParameter(param);
//
qTrackCountCmd = new G4UIcommand("/score/quantity/nOfTrack",this);
qTrackCountCmd->SetGuidance("Number of track scorer.");
qTrackCountCmd->
SetGuidance("[usage] /score/quantiy/nOfTrack qname dflag wflag");
qTrackCountCmd->SetGuidance(" qname :(String) scorer name");
qTrackCountCmd->SetGuidance(" dflag :(Int) direction");
qTrackCountCmd->SetGuidance(" : 0 = Both In and Out");
qTrackCountCmd->SetGuidance(" : 1 = In only");
qTrackCountCmd->SetGuidance(" : 2 = Out only");
qTrackCountCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qTrackCountCmd->SetParameter(param);
param = new G4UIparameter("dflag",'i',true);
param->SetDefaultValue("0");
qTrackCountCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("false");
qTrackCountCmd->SetParameter(param);
//
qTerminationCmd = new G4UIcommand("/score/quantity/nOfTerminatedTrack",this);
qTerminationCmd->SetGuidance("Number of terminated tracks scorer.");
qTerminationCmd->
SetGuidance("[usage] /score/quantiy/nOfTerminatedTrack qname wflag");
qTerminationCmd->SetGuidance(" qname :(String) scorer name");
qTerminationCmd->SetGuidance(" wflag :(Bool) weighted");
param = new G4UIparameter("qname",'s',false);
qTerminationCmd->SetParameter(param);
param = new G4UIparameter("wflag",'b',true);
param->SetDefaultValue("false");
qTerminationCmd->SetParameter(param);
}
@@ -0,0 +1,546 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4ScoringBox.cc,v 1.48 2007/11/14 20:41:17 asaim Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
#include "G4ScoringBox.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4PVDivision.hh"
#include "G4PVParameterised.hh"
#include "G4VisAttributes.hh"
#include "G4ScoringBoxParameterisation.hh"
#include "G4VVisManager.hh"
#include "G4VScoreColorMap.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4ScoringManager.hh"
#include <map>
#include <fstream>
G4ScoringBox::G4ScoringBox(G4String wName)
:G4VScoringMesh(wName), fSegmentDirection(-1),
fMeshElementLogical(0)
{
fShape = boxMesh;
}
G4ScoringBox::~G4ScoringBox()
{
}
void G4ScoringBox::Construct(G4VPhysicalVolume* fWorldPhys)
{
if(fConstructed) {
if(verboseLevel > 0)
G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl;
ResetScore();
} else {
fConstructed = true;
SetupGeometry(fWorldPhys);
}
}
void G4ScoringBox::SetupGeometry(G4VPhysicalVolume * fWorldPhys) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::SetupGeometry() ..." << G4endl;
// World
G4VPhysicalVolume * scoringWorld = fWorldPhys;
G4LogicalVolume * worldLogical = scoringWorld->GetLogicalVolume();
// Scoring Mesh
if(verboseLevel > 9) G4cout << fWorldName << G4endl;
G4String boxName = fWorldName;
if(verboseLevel > 9) G4cout << fSize[0] << ", " << fSize[1] << ", " << fSize[2] << G4endl;
G4VSolid * boxSolid = new G4Box(boxName+"0", fSize[0], fSize[1], fSize[2]);
G4LogicalVolume * boxLogical = new G4LogicalVolume(boxSolid, 0, boxName);
new G4PVPlacement(fRotationMatrix, fCenterPosition,
boxLogical, boxName+"0", worldLogical, false, 0);
//G4double fsegment[3][3];
//G4int segOrder[3];
//GetSegmentOrder(fSegmentDirection, fNSegment, segOrder, fsegment);
//EAxis axis[3] = {kXAxis, kYAxis, kZAxis};
G4String layerName[2] = {boxName + "1", boxName + "2"};
G4VSolid * layerSolid[2];
G4LogicalVolume * layerLogical[2];
// fisrt nested layer (replicated to x direction)
if(verboseLevel > 9) G4cout << "layer 1 :" << G4endl;
layerSolid[0] = new G4Box(layerName[0],
fSize[0]/fNSegment[0],
fSize[1],
fSize[2]);
layerLogical[0] = new G4LogicalVolume(layerSolid[0], 0, layerName[0]);
if(fNSegment[0] > 1) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to x direction" << G4endl;
if(G4ScoringManager::GetReplicaLevel()>0)
{
new G4PVReplica(layerName[0], layerLogical[0], boxLogical, kXAxis,
fNSegment[0], fSize[0]/fNSegment[0]*2.);
}
else
{
new G4PVDivision(layerName[0], layerLogical[0], boxLogical, kXAxis,
fNSegment[0], fSize[0]/fNSegment[0]*2.);
}
} else if(fNSegment[0] == 1) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[0], layerName[0], boxLogical, false, 0);
} else
G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : invalid parameter ("
<< fNSegment[0] << ") "
<< "in placement of the first nested layer." << G4endl;
if(verboseLevel > 9) {
G4cout << fSize[0]/fNSegment[0] << ", "
<< fSize[1] << ", "
<< fSize[2] << G4endl;
G4cout << layerName[0] << ": kXAxis, "
<< fNSegment[0] << ", "
<< 2.*fSize[0]/fNSegment[0] << G4endl;
}
// second nested layer (replicated to y direction)
if(verboseLevel > 9) G4cout << "layer 2 :" << G4endl;
layerSolid[1] = new G4Box(layerName[1],
fSize[0]/fNSegment[0],
fSize[1]/fNSegment[1],
fSize[2]);
layerLogical[1] = new G4LogicalVolume(layerSolid[1], 0, layerName[1]);
if(fNSegment[1] > 1) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to y direction" << G4endl;
if(G4ScoringManager::GetReplicaLevel()>1)
{
new G4PVReplica(layerName[1], layerLogical[1], layerLogical[0], kYAxis,
fNSegment[1], fSize[1]/fNSegment[1]*2.);
}
else
{
new G4PVDivision(layerName[1], layerLogical[1], layerLogical[0], kYAxis,
fNSegment[1], fSize[1]/fNSegment[1]*2.);
}
} else if(fNSegment[1] == 1) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[1], layerName[1], layerLogical[0], false, 0);
} else
G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : invalid parameter ("
<< fNSegment[1] << ") "
<< "in placement of the second nested layer." << G4endl;
if(verboseLevel > 9) {
G4cout << fSize[0]/fNSegment[0] << ", "
<< fSize[1]/fNSegment[1] << ", "
<< fSize[2] << G4endl;
G4cout << layerName[1] << ": kYAxis, "
<< fNSegment[1] << ", "
<< 2.*fSize[1]/fNSegment[1] << G4endl;
}
// mesh elements (replicated to z direction)
if(verboseLevel > 9) G4cout << "mesh elements :" << G4endl;
G4String elementName = boxName +"3";
G4VSolid * elementSolid = new G4Box(elementName,
fSize[0]/fNSegment[0],
fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
fMeshElementLogical = new G4LogicalVolume(elementSolid, 0, elementName);
if(fNSegment[2] > 1)
if(fSegmentPositions.size() > 0) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Parameterise to z direction" << G4endl;
G4double motherDims[3] ={fSize[0]/fNSegment[0],
fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]};
G4int nelement = fNSegment[2];
fSegmentPositions.push_back(fSize[2]*2.);
//G4ScoringBoxParameterisation * param =
G4VPVParameterisation * param =
new G4ScoringBoxParameterisation(kZAxis, motherDims, fSegmentPositions);
new G4PVParameterised(elementName,
fMeshElementLogical,
layerLogical[1],
kZAxis,
nelement,
param);
if(verboseLevel > 9) {
G4cout << motherDims[0] << ", " << motherDims[1] << ", " << motherDims[2] << G4endl;
for(int i = 0; i < (int)fSegmentPositions.size(); i++)
G4cout << fSegmentPositions[i] << ", ";
G4cout << G4endl;
}
} else {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to z direction" << G4endl;
if(G4ScoringManager::GetReplicaLevel()>2)
{
new G4PVReplica(elementName, fMeshElementLogical, layerLogical[1], kZAxis,
fNSegment[2], 2.*fSize[2]/fNSegment[2]);
}
else
{
new G4PVDivision(elementName, fMeshElementLogical, layerLogical[1], kZAxis,
fNSegment[2], 2.*fSize[2]/fNSegment[2]);
}
}
else if(fNSegment[2] == 1) {
if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), fMeshElementLogical, elementName, layerLogical[1], false, 0);
} else
G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : "
<< "invalid parameter (" << fNSegment[2] << ") "
<< "in mesh element placement." << G4endl;
if(verboseLevel > 9) {
G4cout << fSize[0]/fNSegment[0] << ", "
<< fSize[1]/fNSegment[1] << ", "
<< fSize[2]/fNSegment[2] << G4endl;
G4cout << elementName << ": kZAxis, "
<< fNSegment[2] << ", "
<< 2.*fSize[2]/fNSegment[2] << G4endl;
}
// set the sensitive detector
fMeshElementLogical->SetSensitiveDetector(fMFD);
// vis. attributes
G4VisAttributes * visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
visatt->SetVisibility(false);
layerLogical[0]->SetVisAttributes(visatt);
layerLogical[1]->SetVisAttributes(visatt);
visatt->SetVisibility(true);
fMeshElementLogical->SetVisAttributes(visatt);
}
void G4ScoringBox::List() const {
G4cout << "G4ScoringBox : " << fWorldName << " --- Shape: Box mesh" << G4endl;
G4VScoringMesh::List();
}
void G4ScoringBox::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg) {
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
// cell vectors
std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
std::vector<double> ez;
for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
std::vector<std::vector<double> > eyz;
for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
std::vector<std::vector<double> > xycell; // xycell[X][Y]
std::vector<double> ey;
for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
G4double xymax = 0., yzmax = 0., xzmax = 0.;
G4int q[3];
std::map<G4int, G4double*>::iterator itr = map->begin();
for(; itr != map->end(); itr++) {
GetXYZ(itr->first, q);
xycell[q[0]][q[1]] += *(itr->second);
if(xymax < xycell[q[0]][q[1]]) xymax = xycell[q[0]][q[1]];
yzcell[q[1]][q[2]] += *(itr->second);
if(yzmax < yzcell[q[1]][q[2]]) yzmax = yzcell[q[1]][q[2]];
xzcell[q[0]][q[2]] += *(itr->second);
if(xzmax < xzcell[q[0]][q[2]]) xzmax = xzcell[q[0]][q[2]];
}
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
G4Scale3D scale;
if(axflg/100==1) {
// xy plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,xymax); }
G4ThreeVector zhalf(0., 0., fSize[2]/fNSegment[2]*0.98);
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]*0.01);
for(int x = 0; x < fNSegment[0]; x++) {
for(int y = 0; y < fNSegment[1]; y++) {
G4ThreeVector pos(GetReplicaPosition(x, y, 0) - zhalf);
G4ThreeVector pos2(GetReplicaPosition(x, y, fNSegment[2]-1) + zhalf);
G4Transform3D trans, trans2;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
trans2 = G4Translate3D(fCenterPosition)*trans2;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(xycell[x][y], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xyplate, att, trans);
pVisManager->Draw(xyplate, att, trans2);
}
}
}
axflg = axflg%100;
if(axflg/10==1) {
// yz plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,yzmax); }
G4ThreeVector xhalf(fSize[0]/fNSegment[0]*0.98, 0., 0.);
G4Box yzplate("yz", fSize[0]/fNSegment[0]*0.01, fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
for(int y = 0; y < fNSegment[1]; y++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(0, y, z) - xhalf);
G4ThreeVector pos2(GetReplicaPosition(fNSegment[0]-1, y, z) + xhalf);
G4Transform3D trans, trans2;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
trans2 = G4Translate3D(fCenterPosition)*trans2;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(yzcell[y][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(yzplate, att, trans);
pVisManager->Draw(yzplate, att, trans2);
}
}
}
axflg = axflg%10;
if(axflg==1) {
// xz plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,xzmax); }
G4ThreeVector yhalf(0., fSize[1]/fNSegment[1]*0.98, 0.);
G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1]*0.01, fSize[2]/fNSegment[2]);
for(int x = 0; x < fNSegment[0]; x++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(x, 0, z) - yhalf);
G4ThreeVector pos2(GetReplicaPosition(x, fNSegment[1]-1, z) + yhalf);
G4Transform3D trans, trans2;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
trans2 = G4Translate3D(fCenterPosition)*trans2;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(xzcell[x][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xzplate, att, trans);
pVisManager->Draw(xzplate, att, trans2);
}
}
}
}
}
G4ThreeVector G4ScoringBox::GetReplicaPosition(G4int x, G4int y, G4int z) {
G4ThreeVector width(fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
G4ThreeVector pos(-fSize[0] + 2*(x+0.5)*width.x(),
-fSize[1] + 2*(y+0.5)*width.y(),
-fSize[2] + 2*(z+0.5)*width.z());
return pos;
}
void G4ScoringBox::GetXYZ(G4int index, G4int q[3]) const {
q[0] = index/(fNSegment[2]*fNSegment[1]);
q[1] = (index - q[0]*fNSegment[2]*fNSegment[1])/fNSegment[2];
q[2] = index - q[1]*fNSegment[2] - q[0]*fNSegment[2]*fNSegment[1];
}
G4int G4ScoringBox::GetIndex(G4int x, G4int y, G4int z) const {
return x + y*fNSegment[0] + z*fNSegment[0]*fNSegment[1];
}
void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap,
G4int idxProj, G4int idxColumn)
{
if(idxColumn<0 || idxColumn>=fNSegment[idxProj])
{
G4cerr << "ERROR : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[idxProj]-1 <<
"]. Method ignored." << G4endl;
return;
}
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
// cell vectors
std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
std::vector<double> ez;
for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
std::vector<std::vector<double> > eyz;
for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
std::vector<std::vector<double> > xycell; // xycell[X][Y]
std::vector<double> ey;
for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
G4double xymax = 0., yzmax = 0., xzmax = 0.;
G4int q[3];
std::map<G4int, G4double*>::iterator itr = map->begin();
for(; itr != map->end(); itr++) {
GetXYZ(itr->first, q);
if(idxProj == 0 && q[2] == idxColumn) { // xy plane
xycell[q[0]][q[1]] += *(itr->second);
if(xymax < xycell[q[0]][q[1]]) xymax = xycell[q[0]][q[1]];
}
if(idxProj == 1 && q[0] == idxColumn) { // yz plane
yzcell[q[1]][q[2]] += *(itr->second);
if(yzmax < yzcell[q[1]][q[2]]) yzmax = yzcell[q[1]][q[2]];
}
if(idxProj == 2 && q[1] == idxColumn) { // zx plane
xzcell[q[0]][q[2]] += *(itr->second);
if(xzmax < xzcell[q[0]][q[2]]) xzmax = xzcell[q[0]][q[2]];
}
}
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
G4Scale3D scale;
// xy plane
if(idxProj == 0) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,xymax); }
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
for(int x = 0; x < fNSegment[0]; x++) {
for(int y = 0; y < fNSegment[1]; y++) {
G4ThreeVector pos(GetReplicaPosition(x, y, idxColumn));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(xycell[x][y], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xyplate, att, trans);
}
}
} else
// yz plane
if(idxProj == 1) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,yzmax); }
G4Box yzplate("yz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
for(int y = 0; y < fNSegment[1]; y++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(idxColumn, y, z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(yzcell[y][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(yzplate, att, trans);
}
}
} else
// xz plane
if(idxProj == 2) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,xzmax);}
G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
for(int x = 0; x < fNSegment[0]; x++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(x, idxColumn, z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(xzcell[x][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xzplate, att, trans);
}
}
}
}
}
@@ -0,0 +1,94 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "G4ScoringBoxParameterisation.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4Box.hh"
G4ScoringBoxParameterisation::G4ScoringBoxParameterisation(EAxis segaxis,
G4double motherDimension[3],
std::vector<G4double> & segpos)
: fSegmentAxis(segaxis), fSegmentPositions(segpos) {
for(int i = 0; i < 3; i++) fMotherDimensions[i] = motherDimension[i];
}
G4ScoringBoxParameterisation::~G4ScoringBoxParameterisation() {
;
}
void G4ScoringBoxParameterisation::ComputeTransformation(const G4int copyNo,
G4VPhysicalVolume *physVol) const {
G4ThreeVector trans;
G4double pos;
if(copyNo == 0)
pos = fSegmentPositions[copyNo]/2.;
else
pos = (fSegmentPositions[copyNo-1] + fSegmentPositions[copyNo])/2.;
if(fSegmentAxis == kXAxis) {
trans[0] = pos - fMotherDimensions[0];
}
if(fSegmentAxis == kYAxis) {
trans[1] = pos - fMotherDimensions[1];
}
if(fSegmentAxis == kZAxis) {
trans[2] = pos - fMotherDimensions[2];
}
physVol->SetTranslation(trans);
}
void G4ScoringBoxParameterisation::ComputeDimensions(G4Box & meshElement,
const G4int copyNo,
const G4VPhysicalVolume*) const {
G4double dims[3] = {fMotherDimensions[0],fMotherDimensions[1],fMotherDimensions[2]};
G4double dim;
if(copyNo == 0)
dim = fSegmentPositions[copyNo]/2.;
else
dim = (fSegmentPositions[copyNo] - fSegmentPositions[copyNo-1])/2.;
if(fSegmentAxis == kXAxis) {
dims[0] = dim;
}
if(fSegmentAxis == kYAxis) {
dims[1] = dim;
}
if(fSegmentAxis == kZAxis) {
dims[2] = dim;
}
meshElement.SetXHalfLength(dims[0]);
meshElement.SetYHalfLength(dims[1]);
meshElement.SetZHalfLength(dims[2]);
}
@@ -0,0 +1,209 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4ScoringManager.cc,v 1.30 2007/11/14 22:08:15 asaim Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
#include "G4ScoringManager.hh"
#include "G4ScoringMessenger.hh"
#include "G4ScoreQuantityMessenger.hh"
#include "G4VScoringMesh.hh"
#include "G4THitsMap.hh"
#include "G4VScoreColorMap.hh"
#include "G4DefaultLinearColorMap.hh"
G4ScoringManager* G4ScoringManager::fSManager = 0;
G4int G4ScoringManager::replicaLevel = 2;
G4ScoringManager* G4ScoringManager::GetScoringManager()
{
if(!fSManager)
{
fSManager = new G4ScoringManager;
}
return fSManager;
}
G4ScoringManager* G4ScoringManager::GetScoringManagerIfExist()
{ return fSManager; }
G4ScoringManager::G4ScoringManager()
:verboseLevel(0),fCurrentMesh(0)
{
fMessenger = new G4ScoringMessenger(this);
fQuantityMessenger = new G4ScoreQuantityMessenger(this);
fColorMapDict = new ColorMapDict();
fDefaultLinearColorMap = new G4DefaultLinearColorMap("defaultLinearColorMap");
(*fColorMapDict)[fDefaultLinearColorMap->GetName()] = fDefaultLinearColorMap;
writer = new G4VScoreWriter();
}
G4ScoringManager::~G4ScoringManager()
{
delete fMessenger;
fSManager = 0;
if(writer) delete writer;
}
void G4ScoringManager::SetReplicaLevel(G4int lvl)
{ replicaLevel = lvl; }
G4int G4ScoringManager::GetReplicaLevel()
{ return replicaLevel; }
void G4ScoringManager::Accumulate(G4VHitsCollection* map)
{
G4String wName = map->GetSDname();
G4VScoringMesh* sm = FindMesh(wName);
if(sm == NULL) return;
if(verboseLevel>9)
{ G4cout << "G4ScoringManager::Accumulate() for " << map->GetSDname() << " / " << map->GetName() << G4endl;
G4cout << " is calling G4VScoringMesh::Accumulate() of " << sm->GetWorldName() << G4endl; }
sm->Accumulate(static_cast<G4THitsMap<double>*>(map));
}
G4VScoringMesh* G4ScoringManager::FindMesh(G4String wName)
{
G4VScoringMesh* sm = 0;
for(MeshVecItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
G4String smName = (*itr)->GetWorldName();
if(wName == smName) {
sm = *itr;
break;
}
}
if(!sm && verboseLevel>9)
{ G4cout << "WARNING : G4ScoringManager::FindMesh() --- <" << wName << "> is not found. Null returned." << G4endl; }
return sm;
}
void G4ScoringManager::List() const
{
G4cout << "G4ScoringManager has " << GetNumberOfMesh() << " scoring meshes." << G4endl;
for(MeshVecConstItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
(*itr)->List();
}
}
void G4ScoringManager::Dump() const
{
for(MeshVecConstItr itr = fMeshVec.begin(); itr != fMeshVec.end(); itr++) {
(*itr)->Dump();
}
}
void G4ScoringManager::DrawMesh(G4String meshName,G4String psName,G4String colorMapName,G4int axflg)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh)
{
G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
if(!colorMap)
{
G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
colorMap = fDefaultLinearColorMap;
}
mesh->DrawMesh(psName,colorMap,axflg);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
}
}
void G4ScoringManager::DrawMesh(G4String meshName,G4String psName,G4int idxPlane,G4int iColumn,G4String colorMapName)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh)
{
G4VScoreColorMap* colorMap = GetScoreColorMap(colorMapName);
if(!colorMap)
{
G4cerr << "WARNING : Score color map <" << colorMapName << "> is not found. Default linear color map is used." << G4endl;
colorMap = fDefaultLinearColorMap;
}
mesh->DrawMesh(psName,idxPlane,iColumn,colorMap);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawMesh() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
}
}
void G4ScoringManager::DumpQuantityToFile(G4String meshName,G4String psName,G4String fileName, G4String option)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh) {
writer->SetScoringMesh(mesh);
writer->DumpQuantityToFile(psName, fileName, option);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawQuantityToFile() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
}
}
void G4ScoringManager::DumpAllQuantitiesToFile(G4String meshName,G4String fileName, G4String option)
{
G4VScoringMesh* mesh = FindMesh(meshName);
if(mesh) {
writer->SetScoringMesh(mesh);
writer->DumpAllQuantitiesToFile(fileName, option);
} else {
G4cerr << "ERROR : G4ScoringManager::DrawAllQuantitiesToFile() --- <"
<< meshName << "> is not found. Nothing is done." << G4endl;
}
}
void G4ScoringManager::RegisterScoreColorMap(G4VScoreColorMap* colorMap)
{
if(fColorMapDict->find(colorMap->GetName()) != fColorMapDict->end())
{
G4cerr << "ERROR : G4ScoringManager::RegisterScoreColorMap -- "
<< colorMap->GetName() << " has already been registered. Method ignored." << G4endl;
}
else
{
(*fColorMapDict)[colorMap->GetName()] = colorMap;
}
}
G4VScoreColorMap* G4ScoringManager::GetScoreColorMap(G4String mapName)
{
ColorMapDictItr mItr = fColorMapDict->find(mapName);
if(mItr == fColorMapDict->end()) { return 0; }
return (mItr->second);
}
void G4ScoringManager::ListScoreColorMaps()
{
G4cout << "Registered Score Color Maps -------------------------------------------------------" << G4endl;
ColorMapDictItr mItr = fColorMapDict->begin();
for(;mItr!=fColorMapDict->end();mItr++)
{ G4cout << " " << mItr->first; }
G4cout << G4endl;
}
@@ -0,0 +1,465 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4ScoringMessenger.cc,v 1.36 2007/11/12 13:27:31 asaim Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// ---------------------------------------------------------------------
#include "G4ScoringMessenger.hh"
#include "G4ScoringManager.hh"
#include "G4VScoringMesh.hh"
#include "G4ScoringBox.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcommand.hh"
#include "G4Tokenizer.hh"
#include "G4UnitsTable.hh"
#include "G4VScoreColorMap.hh"
G4ScoringMessenger::G4ScoringMessenger(G4ScoringManager* SManager)
:fSMan(SManager)
{
G4UIparameter* param;
scoreDir = new G4UIdirectory("/score/");
scoreDir->SetGuidance("Interactive scoring commands.");
listCmd = new G4UIcmdWithoutParameter("/score/list",this);
listCmd->SetGuidance("List scoring worlds.");
dumpCmd = new G4UIcmdWithoutParameter("/score/dump",this);
dumpCmd->SetGuidance("Dump results of scorers.");
verboseCmd = new G4UIcmdWithAnInteger("/score/verbose",this);
verboseCmd->SetGuidance("Verbosity.");
verboseCmd->SetGuidance(" 0) errors or warnings,");
verboseCmd->SetGuidance(" 1) information with 0)");
meshDir = new G4UIdirectory("/score/mesh/");
meshDir->SetGuidance(" Mesh processing commands.");
meshCreateDir = new G4UIdirectory("/score/create/");
meshCreateDir->SetGuidance(" Mesh creation commands.");
//
// Mesh commands
meshBoxCreateCmd = new G4UIcmdWithAString("/score/create/boxMesh",this);
meshBoxCreateCmd->SetGuidance("Create scoring box mesh.");
meshBoxCreateCmd->SetParameterName("MeshName",false);
//
// meshTubsCreateCmd = new G4UIcmdWithAString("/score/create/tubsMesh",this);
// meshTubsCreateCmd->SetGuidance("Create scoring mesh.");
// meshTubsCreateCmd->SetParameterName("MeshName",false);
//
// meshSphereCreateCmd = new G4UIcmdWithAString("/score/create/sphereMesh",this);
// meshSphereCreateCmd->SetGuidance("Create scoring mesh.");
// meshSphereCreateCmd->SetParameterName("MeshName",false);
//
meshOpnCmd = new G4UIcmdWithAString("/score/open",this);
meshOpnCmd->SetGuidance("Open scoring mesh.");
meshOpnCmd->SetParameterName("MeshName",false);
//
meshClsCmd = new G4UIcmdWithoutParameter("/score/close",this);
meshClsCmd->SetGuidance("Close scoring mesh.");
//
// meshActCmd = new G4UIcmdWithABool("/score/mesh/activate",this);
// meshActCmd->SetGuidance("Activate scoring mesh.");
// meshActCmd->SetParameterName("MeshName",false);
//
mBoxSizeCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/boxSize",this);
mBoxSizeCmd->SetGuidance("Define size of the scoring mesh.");
mBoxSizeCmd->SetParameterName("Di","Dj","Dk",false,false);
mBoxSizeCmd->SetRange("Di>0. && Dj>0. && Dk>0.");
mBoxSizeCmd->SetDefaultUnit("mm");
//
// Division command
mBinCmd = new G4UIcommand("/score/mesh/nBin",this);
mBinCmd->SetGuidance("Define segments of the scoring mesh.");
mBinCmd->SetGuidance("[usage] /score/mesh/nBin");
mBinCmd->SetGuidance(" Ni :(int) Number of bins i ");
mBinCmd->SetGuidance(" Nj :(int) Number of bins j ");
mBinCmd->SetGuidance(" Nk :(int) Number of bins k ");
//mBinCmd->SetGuidance(" Axis:(int) Axis of division ");
// mBinCmd->SetGuidance(" P1..Pn-1 :(double) \"paramter from P1 to Pn-1 for division.\"");
param = new G4UIparameter("Ni",'i',false);
param->SetDefaultValue("1");
param->SetParameterRange("Ni>0");
mBinCmd->SetParameter(param);
param = new G4UIparameter("Nj",'i',false);
param->SetDefaultValue("1");
param->SetParameterRange("Nj>0");
mBinCmd->SetParameter(param);
param = new G4UIparameter("Nk",'i',false);
param->SetDefaultValue("1");
mBinCmd->SetParameter(param);
param->SetParameterRange("Nk>0");
//param = new G4UIparameter("Axis",'i',true);
//param->SetDefaultValue("3");
//mBinCmd->SetParameter(param);
//
// Placement command
mTransDir = new G4UIdirectory("/score/mesh/translate/");
mTransDir->SetGuidance("Mesh translation commands.");
//
mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset",this);
mTResetCmd->SetGuidance("Reset translated position of the scoring mesh.");
//
mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz",this);
mTXyzCmd->SetGuidance("Translate the scoring mesh.");
mTXyzCmd->SetParameterName("X","Y","Z",false,false);
mTXyzCmd->SetDefaultUnit("mm");
//
mRotDir = new G4UIdirectory("/score/mesh/rotate/");
mRotDir->SetGuidance("Mesh rotation commands.");
//
mRResetCmd = new G4UIcmdWithoutParameter("/score/mesh/rotate/reset",this);
mRResetCmd->SetGuidance("Reset rotation angles of the scoring mesh.");
//
mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX",this);
mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis.");
mRotXCmd->SetParameterName("Rx",false);
mRotXCmd->SetDefaultUnit("deg");
//
mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY",this);
mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis.");
mRotYCmd->SetParameterName("Ry",false);
mRotYCmd->SetDefaultUnit("deg");
//
mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ",this);
mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis.");
mRotZCmd->SetParameterName("Rz",false);
mRotZCmd->SetDefaultUnit("deg");
//
// Draw Scoring result
drawCmd = new G4UIcommand("/score/drawProjection",this);
drawCmd->SetGuidance("Draw projection(s) of scored quantities.");
drawCmd->SetGuidance("Parameter <proj> specified which projection(s) to be drawn.");
drawCmd->SetGuidance(" 100 : xy-plane, 010 : yz-place, 001 : zx-plane -- default 111");
param = new G4UIparameter("meshName",'s',false);
drawCmd->SetParameter(param);
param = new G4UIparameter("psName",'s',false);
drawCmd->SetParameter(param);
param = new G4UIparameter("colorMapName",'s',true);
param->SetDefaultValue("defaultLinearColorMap");
drawCmd->SetParameter(param);
param = new G4UIparameter("proj",'i',true);
param->SetDefaultValue(111);
drawCmd->SetParameter(param);
// Draw column
drawColumnCmd = new G4UIcommand("/score/drawColumn",this);
drawColumnCmd->SetGuidance("Draw a cell column.");
drawColumnCmd->SetGuidance(" plane = 0 : xy, 1: yz, 2: zx");
param = new G4UIparameter("meshName",'s',false);
drawColumnCmd->SetParameter(param);
param = new G4UIparameter("psName",'s',false);
drawColumnCmd->SetParameter(param);
param = new G4UIparameter("plane",'i',false);
param->SetParameterRange("plane>=0 && plane<=2");
drawColumnCmd->SetParameter(param);
param = new G4UIparameter("column",'i',false);
drawColumnCmd->SetParameter(param);
param = new G4UIparameter("colorMapName",'s',true);
param->SetDefaultValue("defaultLinearColorMap");
drawColumnCmd->SetParameter(param);
colorMapDir = new G4UIdirectory("/score/colorMap/");
colorMapDir->SetGuidance("Color map commands.");
listColorMapCmd = new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps",this);
listColorMapCmd->SetGuidance("List registered score color maps.");
floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax",this);
floatMinMaxCmd->SetGuidance("Min/Max of the color map is calculated accorging to the actual scores.");
floatMinMaxCmd->SetParameterName("colorMapName",true,false);
floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap");
colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax",this);
colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map.");
param = new G4UIparameter("colorMapMame",'s',true);
param->SetDefaultValue("defaultLinearColorMap");
colorMapMinMaxCmd->SetParameter(param);
param = new G4UIparameter("minValue",'d',false);
colorMapMinMaxCmd->SetParameter(param);
param = new G4UIparameter("maxValue",'d',false);
colorMapMinMaxCmd->SetParameter(param);
// Dump a scored quantity
dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this);
dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file.");
param = new G4UIparameter("meshName", 's', false);
dumpQtyToFileCmd->SetParameter(param);
param = new G4UIparameter("psName", 's', false);
dumpQtyToFileCmd->SetParameter(param);
param = new G4UIparameter("fileName", 's', false);
dumpQtyToFileCmd->SetParameter(param);
param = new G4UIparameter("option", 's', true);
dumpQtyToFileCmd->SetParameter(param);
// Dump all scored quantities
dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this);
dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file.");
param = new G4UIparameter("meshName", 's', false);
dumpAllQtsToFileCmd->SetParameter(param);
param = new G4UIparameter("fileName", 's', false);
dumpAllQtsToFileCmd->SetParameter(param);
param = new G4UIparameter("option", 's', true);
dumpAllQtsToFileCmd->SetParameter(param);
}
G4ScoringMessenger::~G4ScoringMessenger()
{
delete listCmd;
delete verboseCmd;
//
delete meshCreateDir;
delete meshBoxCreateCmd;
// delete meshTubsCreateCmd;
// delete meshSphereCreateCmd;
//
delete meshOpnCmd;
//
delete meshClsCmd;
// delete meshActCmd;
delete meshDir;
//
delete mBoxSizeCmd;
delete mTubsSizeCmd;
delete mSphereSizeCmd;
//
delete mBinCmd;
//
delete mTResetCmd;
delete mTXyzCmd;
delete mTransDir;
delete mRResetCmd;
delete mRotXCmd;
delete mRotYCmd;
delete mRotZCmd;
delete mRotDir;
//
delete dumpCmd;
delete drawCmd;
delete drawColumnCmd;
delete listColorMapCmd;
delete floatMinMaxCmd;
delete colorMapMinMaxCmd;
delete colorMapDir;
delete dumpQtyToFileCmd;
delete dumpAllQtsToFileCmd;
//
delete scoreDir;
}
void G4ScoringMessenger::SetNewValue(G4UIcommand * command,G4String newVal)
{
if(command==listCmd) {
fSMan->List();
} else if(command==dumpCmd) {
fSMan->Dump();
} else if(command==drawCmd) {
G4Tokenizer next(newVal);
G4String meshName = next();
G4String psName = next();
G4String colorMapName = next();
G4int axflg = StoI(next());
fSMan->DrawMesh(meshName,psName,colorMapName,axflg);
} else if(command==drawColumnCmd) {
G4Tokenizer next(newVal);
G4String meshName = next();
G4String psName = next();
G4int iPlane = StoI(next());
G4int iColumn = StoI(next());
G4String colorMapName = next();
fSMan->DrawMesh(meshName,psName,iPlane,iColumn,colorMapName);
} else if(command==dumpQtyToFileCmd) {
G4Tokenizer next(newVal);
G4String meshName = next();
G4String psName = next();
G4String fileName = next();
G4String option = next("\n");
fSMan->DumpQuantityToFile(meshName, psName, fileName, option);
} else if(command==dumpAllQtsToFileCmd) {
G4Tokenizer next(newVal);
G4String meshName = next();
G4String fileName = next();
G4String option = next("\n");
fSMan->DumpAllQuantitiesToFile(meshName, fileName, option);
} else if(command==verboseCmd) {
fSMan->SetVerboseLevel(verboseCmd->GetNewIntValue(newVal));
} else if(command==meshBoxCreateCmd) {
G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
if ( currentmesh ){
G4cerr << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
<< "] : Mesh <" << currentmesh->GetWorldName() << "> is still open. Close it first. Command ignored." << G4endl;
} else {
G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
if ( !mesh ){
mesh = new G4ScoringBox(newVal);
fSMan->RegisterScoringMesh(mesh);
}else{
G4cerr << "ERROR[" << meshBoxCreateCmd->GetCommandPath()
<< "] : Scoring mesh <" << newVal
<< "> already exists. Command ignored." << G4endl;
}
}
} else if(command==listColorMapCmd) {
fSMan->ListScoreColorMaps();
} else if(command==floatMinMaxCmd) {
G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal);
if(colorMap)
{ colorMap->SetFloatingMinMax(true); }
else
{ G4cerr << "ERROR[" << floatMinMaxCmd->GetCommandPath()
<< "] : color map <" << newVal << "> is not defined. Command ignored." << G4endl; }
} else if(command==colorMapMinMaxCmd) {
G4Tokenizer next(newVal);
G4String mapName = next();
G4double minVal = StoD(next());
G4double maxVal = StoD(next());
G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName);
if(colorMap)
{ colorMap->SetFloatingMinMax(false);
colorMap->SetMinMax(minVal,maxVal); }
else
{ G4cerr << "ERROR[" << colorMapMinMaxCmd->GetCommandPath()
<< "] : color map <" << newVal << "> is not defined. Command ignored." << G4endl; }
} else if(command==meshOpnCmd) {
G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh();
if ( currentmesh ){
G4cerr << "ERROR[" << meshOpnCmd->GetCommandPath()
<< "] : Mesh <" << currentmesh->GetWorldName() << "> is still open. Close it first. Command ignored." << G4endl;
} else {
G4VScoringMesh* mesh = fSMan->FindMesh(newVal);
if ( !mesh ){
G4cerr << "ERROR[" << meshOpnCmd->GetCommandPath()
<< "] : Scoring mesh <" << newVal << "> does not exist. Command ignored." << G4endl;
} else {
fSMan->SetCurrentMesh(mesh);
}
}
} else if(command==meshClsCmd) {
fSMan->CloseCurrentMesh();
} else {
//
// Get Current Mesh
//
G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
//
// Commands for Current Mesh
if ( mesh ){
// Tokens
G4TokenVec token;
FillTokenVec(newVal,token);
//
// Mesh Geometry
//
// if(command==meshActCmd) {
// mesh->Activate(meshActCmd->GetNewBoolValue(newVal));
// } else
if(command==mBoxSizeCmd) {
MeshShape shape = mesh->GetShape();
if ( shape == boxMesh ){
G4ThreeVector size = mBoxSizeCmd->GetNew3VectorValue(newVal);
G4double vsize[3];
vsize[0] = size.x();
vsize[1] = size.y();
vsize[2] = size.z();
mesh->SetSize(vsize);
} else {
G4cerr << "ERROR[" << mBoxSizeCmd->GetCommandPath()
<< "] : This mesh is not Box. Command ignored." << G4endl;
}
} else if(command==mBinCmd) {
MeshBinCommand(mesh,token);
} else if(command==mTResetCmd) {
G4double centerPosition[3] ={ 0., 0., 0.};
mesh->SetCenterPosition(centerPosition);
} else if(command==mTXyzCmd) {
G4ThreeVector xyz = mTXyzCmd->GetNew3VectorValue(newVal);
G4double centerPosition[3];
centerPosition[0] = xyz.x();
centerPosition[1] = xyz.y();
centerPosition[2] = xyz.z();
mesh->SetCenterPosition(centerPosition);
} else if(command==mRResetCmd) {
} else if(command==mRotXCmd) {
G4double value = mRotXCmd->GetNewDoubleValue(newVal);
mesh->RotateX(value);
} else if(command==mRotYCmd) {
G4double value = mRotYCmd->GetNewDoubleValue(newVal);
mesh->RotateY(value);
} else if(command==mRotZCmd) {
G4double value = mRotZCmd->GetNewDoubleValue(newVal);
mesh->RotateZ(value);
}
}else{
G4cerr << "ERROR: No mesh is currently open. Open/create a mesh first. Command ignored." << G4endl;
}
}
}
G4String G4ScoringMessenger::GetCurrentValue(G4UIcommand * command)
{
G4String val;
if(command==verboseCmd)
{ val = verboseCmd->ConvertToString(fSMan->GetVerboseLevel()); }
return val;
}
void G4ScoringMessenger::FillTokenVec(G4String newValues, G4TokenVec& token){
G4Tokenizer next(newValues);
G4String val;
while ( !(val = next()).isNull() ) {
token.push_back(val);
}
}
void G4ScoringMessenger::MeshBinCommand(G4VScoringMesh* mesh,G4TokenVec& token){
G4int Ni = StoI(token[0]);
G4int Nj = StoI(token[1]);
G4int Nk = StoI(token[2]);
G4int nSegment[3];
nSegment[0] = Ni;
nSegment[1] = Nj;
nSegment[2] = Nk;
//
mesh->SetNumberOfSegments(nSegment);
}
@@ -24,36 +24,16 @@
// ********************************************************************
//
//
// $Id: G4SDNeutralFilter.cc,v 1.3 2007/05/18 00:00:38 asaim Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4VScoreColorMap.cc,v 1.1 2007/11/04 04:06:09 asaim Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// G4VSensitiveDetector
#include "G4SDNeutralFilter.hh"
#include "G4Step.hh"
#include "G4TouchableHistory.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
////////////////////////////////////////////////////////////////////////////////
// class description:
//
// This is the class of a filter to be associated with a
// sensitive detector.
//
// Created: 2005-11-14 Tsukasa ASO.
//
///////////////////////////////////////////////////////////////////////////////
#include "G4VScoreColorMap.hh"
G4SDNeutralFilter::G4SDNeutralFilter(G4String name)
:G4VSDFilter(name)
G4VScoreColorMap::G4VScoreColorMap(G4String mName)
:fName(mName),ifFloat(true),fMinVal(0.),fMaxVal(DBL_MAX)
{;}
G4SDNeutralFilter::~G4SDNeutralFilter()
G4VScoreColorMap::~G4VScoreColorMap()
{;}
G4bool G4SDNeutralFilter::Accept(const G4Step* aStep) const
{
if (aStep->GetPreStepPoint()->GetCharge()== 0. ) return TRUE;
return FALSE;
}
@@ -0,0 +1,211 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VScoreWriter.cc,v 1.4 2007/11/11 01:00:44 akimura Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
#include "G4VScoreWriter.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4VScoringMesh.hh"
#include <map>
#include <fstream>
G4VScoreWriter::G4VScoreWriter()
: fScoringMesh(0), verboseLevel(0) {
;
}
G4VScoreWriter::~G4VScoreWriter() {
}
void G4VScoreWriter::SetScoringMesh(G4VScoringMesh * sm) {
fScoringMesh = sm;
fScoringMesh->GetNumberOfSegments(fNMeshSegments);
}
void G4VScoreWriter::DumpQuantityToFile(G4String & psName, G4String & fileName, G4String & option) {
// change the option string into lowercase to the case-insensitive.
G4String opt = option;
std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
// confirm the option
if(opt.size() == 0) opt = "csv";
if(opt.find("csv") == std::string::npos &&
opt.find("sequence") == std::string::npos) {
G4cerr << "ERROR : DumpToFile : Unknown option -> "
<< option << G4endl;
return;
}
// open the file
std::ofstream ofile(fileName);
if(!ofile) {
G4cerr << "ERROR : DumpToFile : File open error -> "
<< fileName << G4endl;
return;
}
ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
// retrieve the map
MeshScoreMap fSMap = fScoringMesh->GetScoreMap();
MeshScoreMap::const_iterator msMapItr = fSMap.find(psName);
if(msMapItr == fSMap.end()) {
G4cerr << "ERROR : DumpToFile : Unknown quantity, \""
<< psName << "\"." << G4endl;
return;
}
std::map<G4int, G4double*> * score = msMapItr->second->GetMap();
ofile << "# primitive scorer name: " << msMapItr->first << G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos) {
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " " << fNMeshSegments[2]
<< G4endl;
}
// write quantity
long count = 0;
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++) {
for(int y = 0; y < fNMeshSegments[1]; y++) {
for(int z = 0; z < fNMeshSegments[2]; z++) {
G4int idx = GetIndex(x, y, z);
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
std::map<G4int, G4double*>::iterator value = score->find(idx);
if(value == score->end()) {
ofile << 0.;
} else {
ofile << *(value->second);
}
if(opt.find("csv") != std::string::npos) {
ofile << G4endl;
} else if(opt.find("sequence") != std::string::npos) {
ofile << " ";
if(count++%5 == 4) ofile << G4endl;
}
} // z
} // y
} // x
ofile << std::setprecision(6);
// close the file
ofile.close();
}
void G4VScoreWriter::DumpAllQuantitiesToFile(G4String & fileName, G4String & option) {
// change the option string into lowercase to the case-insensitive.
G4String opt = option;
std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
// confirm the option
if(opt.size() == 0) opt = "csv";
if(opt.find("csv") == std::string::npos &&
opt.find("sequence") == std::string::npos) {
G4cerr << "ERROR : DumpToFile : Unknown option -> "
<< option << G4endl;
return;
}
// open the file
std::ofstream ofile(fileName);
if(!ofile) {
G4cerr << "ERROR : DumpToFile : File open error -> "
<< fileName << G4endl;
return;
}
ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
// retrieve the map
MeshScoreMap fSMap = fScoringMesh->GetScoreMap();
MeshScoreMap::const_iterator msMapItr = fSMap.begin();
std::map<G4int, G4double*> * score;
for(; msMapItr != fSMap.end(); msMapItr++) {
score = msMapItr->second->GetMap();
ofile << "# primitive scorer name: " << msMapItr->first << G4endl;
// "sequence" option: write header info
if(opt.find("sequence") != std::string::npos) {
ofile << fNMeshSegments[0] << " " << fNMeshSegments[1] << " " << fNMeshSegments[2]
<< G4endl;
}
// write quantity
long count = 0;
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++) {
for(int y = 0; y < fNMeshSegments[1]; y++) {
for(int z = 0; z < fNMeshSegments[2]; z++) {
G4int idx = GetIndex(x, y, z);
if(opt.find("csv") != std::string::npos)
ofile << x << "," << y << "," << z << ",";
std::map<G4int, G4double*>::iterator value = score->find(idx);
if(value == score->end()) {
ofile << 0.;
} else {
ofile << *(value->second);
}
if(opt.find("csv") != std::string::npos) {
ofile << G4endl;
} else if(opt.find("sequence") != std::string::npos) {
ofile << " ";
if(count++%5 == 4) ofile << G4endl;
}
} // z
} // y
} // x
ofile << std::setprecision(6);
} // for(; msMapItr ....)
// close the file
ofile.close();
}
G4int G4VScoreWriter::GetIndex(G4int x, G4int y, G4int z) const {
return x + y*fNMeshSegments[0] + z*fNMeshSegments[0]*fNMeshSegments[1];
}
@@ -0,0 +1,216 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VScoringMesh.cc,v 1.34 2007/11/07 04:12:07 akimura Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
#include "G4VScoringMesh.hh"
#include "G4VPhysicalVolume.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4VSDFilter.hh"
#include "G4SDManager.hh"
G4VScoringMesh::G4VScoringMesh(G4String wName)
: fWorldName(wName),fConstructed(false),fActive(true),
fRotationMatrix(NULL), fMFD(new G4MultiFunctionalDetector(wName)),
verboseLevel(0),sizeIsSet(false),nMeshIsSet(false)
{
G4SDManager::GetSDMpointer()->AddNewDetector(fMFD);
fSize[0] = fSize[1] = fSize[2] = 0.;
fNSegment[0] = fNSegment[1] = fNSegment[2] = 1;
}
G4VScoringMesh::~G4VScoringMesh()
{
;
}
void G4VScoringMesh::ResetScore() {
if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore() is called." << G4endl;
std::map<G4String, G4THitsMap<G4double>* >::iterator itr = fMap.begin();
for(; itr != fMap.end(); itr++) {
if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore()" << itr->first << G4endl;
itr->second->clear();
}
}
void G4VScoringMesh::SetSize(G4double size[3]) {
for(int i = 0; i < 3; i++) fSize[i] = size[i];
sizeIsSet = true;
}
void G4VScoringMesh::SetCenterPosition(G4double centerPosition[3]) {
fCenterPosition = G4ThreeVector(centerPosition[0], centerPosition[1], centerPosition[2]);
}
void G4VScoringMesh::SetNumberOfSegments(G4int nSegment[3]) {
for(int i = 0; i < 3; i++) fNSegment[i] = nSegment[i];
nMeshIsSet = true;
}
void G4VScoringMesh::GetNumberOfSegments(G4int nSegment[3]) {
for(int i = 0; i < 3; i++) nSegment[i] = fNSegment[i];
}
void G4VScoringMesh::RotateX(G4double delta) {
if(fRotationMatrix == NULL) fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateX(delta);
}
void G4VScoringMesh::RotateY(G4double delta) {
if(fRotationMatrix == NULL) fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateY(delta);
}
void G4VScoringMesh::RotateZ(G4double delta) {
if(fRotationMatrix == NULL) fRotationMatrix = new G4RotationMatrix();
fRotationMatrix->rotateZ(delta);
}
void G4VScoringMesh::SetPrimitiveScorer(G4VPrimitiveScorer * ps) {
if(!ReadyForQuantity())
{
G4cerr << "ERROR : G4VScoringMesh::SetPrimitiveScorer() : " << ps->GetName()
<< " does not yet have mesh size or number of bins. Set them first." << G4endl
<< "This Method is ignored." << G4endl;
return;
}
if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetPrimitiveScorer() : "
<< ps->GetName() << " is registered."
<< " 3D size: ("
<< fNSegment[0] << ", "
<< fNSegment[1] << ", "
<< fNSegment[2] << ")" << G4endl;
ps->SetNijk(fNSegment[0], fNSegment[1], fNSegment[2]);
fCurrentPS = ps;
fMFD->RegisterPrimitive(ps);
G4THitsMap<G4double> * map = new G4THitsMap<G4double>(fWorldName, ps->GetName());
fMap[ps->GetName()] = map;
}
void G4VScoringMesh::SetFilter(G4VSDFilter * filter) {
if(fCurrentPS == NULL) {
G4cerr << "ERROR : G4VScoringMesh::SetSDFilter() : a quantity must be defined first. This method is ignored." << G4endl;
return;
}
if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetFilter() : "
<< filter->GetName()
<< " is set to "
<< fCurrentPS->GetName() << G4endl;
G4VSDFilter* oldFilter = fCurrentPS->GetFilter();
if(oldFilter)
{
G4cout << "WARNING : G4VScoringMesh::SetFilter() : " << oldFilter->GetName()
<< " is overwritten by " << filter->GetName() << G4endl;
}
fCurrentPS->SetFilter(filter);
}
void G4VScoringMesh::SetCurrentPrimitiveScorer(G4String & name) {
fCurrentPS = GetPrimitiveScorer(name);
if(fCurrentPS == NULL) {
G4cerr << "ERROR : G4VScoringMesh::SetCurrentPrimitiveScorer() : The primitive scorer <"
<< name << "> does not found." << G4endl;
}
}
G4bool G4VScoringMesh::FindPrimitiveScorer(G4String & psname) {
std::map<G4String, G4THitsMap<G4double>* >::iterator itr = fMap.find(psname);;
if(itr == fMap.end()) return false;
return true;
}
G4VPrimitiveScorer * G4VScoringMesh::GetPrimitiveScorer(G4String & name) {
if(fMFD == NULL) return NULL;
G4int nps = fMFD->GetNumberOfPrimitives();
for(G4int i = 0; i < nps; i++) {
G4VPrimitiveScorer * ps = fMFD->GetPrimitive(i);
if(name == ps->GetName()) return ps;
}
return NULL;
}
void G4VScoringMesh::List() const {
G4cout << " Size: ("
<< fSize[0]/cm << ", "
<< fSize[1]/cm << ", "
<< fSize[2]/cm << ") [cm]"
<< G4endl;
G4cout << " # of segments: ("
<< fNSegment[0] << ", "
<< fNSegment[1] << ", "
<< fNSegment[2] << ")"
<< G4endl;
G4cout << " displacement: ("
<< fCenterPosition.x()/cm << ", "
<< fCenterPosition.y()/cm << ", "
<< fCenterPosition.z()/cm << ") [cm]"
<< G4endl;
if(fRotationMatrix != 0) {
G4cout << " rotation matrix: "
<< fRotationMatrix->xx() << " "
<< fRotationMatrix->xy() << " "
<< fRotationMatrix->xz() << G4endl
<< " "
<< fRotationMatrix->yx() << " "
<< fRotationMatrix->yy() << " "
<< fRotationMatrix->yz() << G4endl
<< " "
<< fRotationMatrix->zx() << " "
<< fRotationMatrix->zy() << " "
<< fRotationMatrix->zz() << G4endl;
}
G4cout << " registered primitve scorers : " << G4endl;
G4int nps = fMFD->GetNumberOfPrimitives();
G4VPrimitiveScorer * ps;
for(int i = 0; i < nps; i++) {
ps = fMFD->GetPrimitive(i);
G4cout << " " << i << " " << ps->GetName();
if(ps->GetFilter() != NULL) G4cout << " with " << ps->GetFilter()->GetName();
G4cout << G4endl;
}
}
void G4VScoringMesh::Dump() {
G4cout << "scoring mesh name: " << fWorldName << G4endl;
G4cout << "# of G4THitsMap : " << fMap.size() << G4endl;
std::map<G4String, G4THitsMap<G4double>* >::iterator itr = fMap.begin();
for(; itr != fMap.end(); itr++) {
G4cout << "[" << itr->first << "]" << G4endl;
itr->second->PrintAllHits();
}
G4cout << G4endl;
}