Import Geant4 10.0.0 source tree
This commit is contained in:
+45
-43
@@ -23,63 +23,65 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm5/src/EventMessenger.cc
|
||||
/// \brief Implementation of the EventMessenger class
|
||||
// $Id: ActionInitialization.cc 76346 2013-11-08 15:48:19Z maire $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "EventMessenger.hh"
|
||||
/// \file ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "StackingAction.hh"
|
||||
#include "SteppingVerbose.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventMessenger::EventMessenger(EventAction* EvAct)
|
||||
:fEventAction(EvAct)
|
||||
ActionInitialization::ActionInitialization(DetectorConstruction* det)
|
||||
: G4VUserActionInitialization(),fDetector(det)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
fEventDir = new G4UIdirectory("/testem/event/");
|
||||
fEventDir->SetGuidance("event control");
|
||||
|
||||
fDrawCmd = new G4UIcmdWithAString("/testem/event/drawTracks",this);
|
||||
fDrawCmd->SetGuidance("Draw the tracks in the event");
|
||||
fDrawCmd->SetGuidance(" Choice : none,charged,neutral,all");
|
||||
fDrawCmd->SetParameterName("choice",true);
|
||||
fDrawCmd->SetDefaultValue("all");
|
||||
fDrawCmd->SetCandidates("none charged neutral all");
|
||||
fDrawCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
|
||||
fPrintCmd->SetGuidance("Print events modulo n");
|
||||
fPrintCmd->SetParameterName("EventNb",false);
|
||||
fPrintCmd->SetRange("EventNb>0");
|
||||
fPrintCmd->AvailableForStates(G4State_Idle);
|
||||
SetUserAction(new RunAction(fDetector));
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventMessenger::~EventMessenger()
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
delete fDrawCmd;
|
||||
delete fPrintCmd;
|
||||
delete fEventDir;
|
||||
}
|
||||
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(fDetector);
|
||||
SetUserAction(primary);
|
||||
|
||||
RunAction* runaction = new RunAction(fDetector,primary);
|
||||
SetUserAction(runaction);
|
||||
|
||||
EventAction* eventaction = new EventAction();
|
||||
SetUserAction(eventaction);
|
||||
|
||||
SetUserAction(new TrackingAction(fDetector,eventaction));
|
||||
|
||||
SetUserAction(new SteppingAction(fDetector,eventaction));
|
||||
|
||||
SetUserAction(new StackingAction(eventaction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
if(command == fDrawCmd)
|
||||
{fEventAction->SetDrawFlag(newValue);}
|
||||
|
||||
if(command == fPrintCmd)
|
||||
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
|
||||
}
|
||||
G4VSteppingVerbose* ActionInitialization::InitializeSteppingVerbose() const
|
||||
{
|
||||
return new SteppingVerbose();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/DetectorConstruction.cc
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: DetectorConstruction.cc 77600 2013-11-26 17:07:41Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -52,13 +52,18 @@
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
:fAbsorberMaterial(0),fWorldMaterial(0),fDefaultWorld(true),
|
||||
:G4VUserDetectorConstruction(),
|
||||
fAbsorberMaterial(0),fWorldMaterial(0),fDefaultWorld(true),
|
||||
fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
|
||||
fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
|
||||
fMagField(0)
|
||||
fDetectorMessenger(0)
|
||||
{
|
||||
// default parameter values of the calorimeter
|
||||
fAbsorberThickness = 1.*cm;
|
||||
@@ -140,12 +145,12 @@ void DetectorConstruction::DefineMaterials()
|
||||
// define a material from elements. case 1: chemical molecule
|
||||
//
|
||||
|
||||
G4Material* H2O = new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
|
||||
G4Material* H2O = new G4Material("Water",density= 1.000*g/cm3,ncomponents=2);
|
||||
H2O->AddElement(H, natoms=2);
|
||||
H2O->AddElement(O, natoms=1);
|
||||
H2O->GetIonisation()->SetMeanExcitationEnergy(78*eV);
|
||||
|
||||
G4Material* CH = new G4Material("Plastic", density= 1.04*g/cm3, ncomponents=2);
|
||||
G4Material* CH = new G4Material("Plastic",density= 1.04*g/cm3,ncomponents=2);
|
||||
CH->AddElement(C, natoms=1);
|
||||
CH->AddElement(H, natoms=1);
|
||||
|
||||
@@ -269,30 +274,27 @@ G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
// complete the Calor parameters definition
|
||||
ComputeCalorParameters();
|
||||
|
||||
// World
|
||||
//
|
||||
fSolidWorld = new G4Box("World", //its name
|
||||
fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
|
||||
|
||||
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
|
||||
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
|
||||
fWorldMaterial, //its material
|
||||
"World"); //its name
|
||||
"World"); //its name
|
||||
|
||||
fPhysiWorld = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
fLogicWorld, //its logical volume
|
||||
"World", //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
fPhysiWorld = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
fLogicWorld, //its logical volume
|
||||
"World", //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
// Absorber
|
||||
//
|
||||
fSolidAbsorber = new G4Box("Absorber",
|
||||
fAbsorberThickness/2,fAbsorberSizeYZ/2,fAbsorberSizeYZ/2);
|
||||
fAbsorberThickness/2,fAbsorberSizeYZ/2,fAbsorberSizeYZ/2);
|
||||
|
||||
fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid
|
||||
fAbsorberMaterial, //its material
|
||||
@@ -369,16 +371,18 @@ void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
|
||||
void DetectorConstruction::SetAbsorberThickness(G4double val)
|
||||
{
|
||||
fAbsorberThickness = val;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
ComputeCalorParameters();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetAbsorberSizeYZ(G4double val)
|
||||
{
|
||||
fAbsorberSizeYZ = val;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
ComputeCalorParameters();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -386,8 +390,9 @@ void DetectorConstruction::SetWorldSizeX(G4double val)
|
||||
{
|
||||
fWorldSizeX = val;
|
||||
fDefaultWorld = false;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
ComputeCalorParameters();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -395,46 +400,36 @@ void DetectorConstruction::SetWorldSizeYZ(G4double val)
|
||||
{
|
||||
fWorldSizeYZ = val;
|
||||
fDefaultWorld = false;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
ComputeCalorParameters();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetAbsorberXpos(G4double val)
|
||||
{
|
||||
fXposAbs = val;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
ComputeCalorParameters();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
G4FieldManager* fieldMgr
|
||||
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
if(fMagField) delete fMagField; //delete the existing magn field
|
||||
|
||||
if(fieldValue!=0.) // create a new one if non nul
|
||||
{ fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
|
||||
fieldMgr->SetDetectorField(fMagField);
|
||||
fieldMgr->CreateChordFinder(fMagField);
|
||||
} else {
|
||||
fMagField = NULL;
|
||||
fieldMgr->SetDetectorField(fMagField);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
|
||||
if ( fFieldMessenger.Get() == 0 ) {
|
||||
// Create global magnetic field messenger.
|
||||
// Uniform magnetic field is then created automatically if
|
||||
// the field value is not zero.
|
||||
G4ThreeVector fieldValue = G4ThreeVector();
|
||||
G4GlobalMagFieldMessenger* msg =
|
||||
new G4GlobalMagFieldMessenger(fieldValue);
|
||||
//msg->SetVerboseLevel(1);
|
||||
G4AutoDelete::Register(msg);
|
||||
fFieldMessenger.Put( msg );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: DetectorMessenger.cc 77083 2013-11-21 10:35:55Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -43,7 +43,16 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
:fDetector(Det)
|
||||
:G4UImessenger(),fDetector(Det),
|
||||
fTestemDir(0),
|
||||
fDetDir(0),
|
||||
fAbsMaterCmd(0),
|
||||
fAbsThickCmd(0),
|
||||
fAbsSizYZCmd(0),
|
||||
fAbsXposCmd(0),
|
||||
fWorldMaterCmd(0),
|
||||
fWorldXCmd(0),
|
||||
fWorldYZCmd(0)
|
||||
{
|
||||
fTestemDir = new G4UIdirectory("/testem/");
|
||||
fTestemDir->SetGuidance("UI commands specific to this example.");
|
||||
@@ -55,18 +64,21 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
|
||||
fAbsMaterCmd->SetParameterName("choice",false);
|
||||
fAbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fAbsMaterCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fWorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
|
||||
fWorldMaterCmd->SetGuidance("Select Material of the World.");
|
||||
fWorldMaterCmd->SetParameterName("wchoice",false);
|
||||
fWorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fWorldMaterCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this);
|
||||
fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
|
||||
fAbsThickCmd->SetParameterName("SizeZ",false);
|
||||
fAbsThickCmd->SetRange("SizeZ>0.");
|
||||
fAbsThickCmd->SetUnitCategory("Length");
|
||||
fAbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fAbsThickCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this);
|
||||
fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
|
||||
@@ -74,12 +86,14 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fAbsSizYZCmd->SetRange("SizeYZ>0.");
|
||||
fAbsSizYZCmd->SetUnitCategory("Length");
|
||||
fAbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fAbsSizYZCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this);
|
||||
fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
|
||||
fAbsXposCmd->SetParameterName("Xpos",false);
|
||||
fAbsXposCmd->SetUnitCategory("Length");
|
||||
fAbsXposCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fAbsXposCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this);
|
||||
fWorldXCmd->SetGuidance("Set X size of the World");
|
||||
@@ -87,6 +101,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fWorldXCmd->SetRange("WSizeX>0.");
|
||||
fWorldXCmd->SetUnitCategory("Length");
|
||||
fWorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fWorldXCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this);
|
||||
fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
|
||||
@@ -94,19 +109,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fWorldYZCmd->SetRange("WSizeYZ>0.");
|
||||
fWorldYZCmd->SetUnitCategory("Length");
|
||||
fWorldYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
|
||||
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
|
||||
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
fUpdateCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
|
||||
fMagFieldCmd->SetGuidance("Define magnetic field.");
|
||||
fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
|
||||
fMagFieldCmd->SetParameterName("Bz",false);
|
||||
fMagFieldCmd->SetUnitCategory("Magnetic flux density");
|
||||
fMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fWorldYZCmd->SetToBeBroadcasted(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -121,8 +124,6 @@ DetectorMessenger::~DetectorMessenger()
|
||||
delete fWorldMaterCmd;
|
||||
delete fWorldXCmd;
|
||||
delete fWorldYZCmd;
|
||||
delete fUpdateCmd;
|
||||
delete fMagFieldCmd;
|
||||
delete fDetDir;
|
||||
delete fTestemDir;
|
||||
}
|
||||
@@ -152,11 +153,6 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
if ( command == fWorldYZCmd )
|
||||
{fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if ( command == fUpdateCmd )
|
||||
{fDetector->UpdateGeometry(); }
|
||||
|
||||
if( command == fMagFieldCmd )
|
||||
{fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,45 +26,38 @@
|
||||
/// \file electromagnetic/TestEm5/src/EventAction.cc
|
||||
/// \brief Implementation of the EventAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: EventAction.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "EventAction.hh"
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "EventMessenger.hh"
|
||||
#include "Run.hh"
|
||||
#include "HistoManager.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventAction::EventAction(RunAction* RA)
|
||||
:fRunAction(RA),
|
||||
fDrawFlag("none"),fPrintModulo(10000)
|
||||
{
|
||||
fEventMessenger = new EventMessenger(this);
|
||||
}
|
||||
EventAction::EventAction()
|
||||
:G4UserEventAction(),
|
||||
fEnergyDeposit(0.),
|
||||
fTrakLenCharged(0.), fTrakLenNeutral(0.),
|
||||
fNbStepsCharged(0), fNbStepsNeutral(0),
|
||||
fTransmitFlag(0), fReflectFlag(0)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventAction::~EventAction()
|
||||
{
|
||||
delete fEventMessenger;
|
||||
}
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventAction::BeginOfEventAction(const G4Event* evt)
|
||||
void EventAction::BeginOfEventAction(const G4Event* )
|
||||
{
|
||||
G4int evtNb = evt->GetEventID();
|
||||
|
||||
//printing survey
|
||||
if (evtNb%fPrintModulo == 0)
|
||||
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
|
||||
|
||||
// initialisation per event
|
||||
fEnergyDeposit = 0.;
|
||||
fTrakLenCharged = fTrakLenNeutral = 0.;
|
||||
@@ -76,15 +69,18 @@ void EventAction::BeginOfEventAction(const G4Event* evt)
|
||||
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
fRunAction->AddEnergy(fEnergyDeposit);
|
||||
fRunAction->AddTrakLenCharg(fTrakLenCharged);
|
||||
fRunAction->AddTrakLenNeutr(fTrakLenNeutral);
|
||||
Run* run = static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
|
||||
run->AddEnergy(fEnergyDeposit);
|
||||
run->AddTrakLenCharg(fTrakLenCharged);
|
||||
run->AddTrakLenNeutr(fTrakLenNeutral);
|
||||
|
||||
fRunAction->CountStepsCharg(fNbStepsCharged);
|
||||
fRunAction->CountStepsNeutr(fNbStepsNeutral);
|
||||
run->CountStepsCharg(fNbStepsCharged);
|
||||
run->CountStepsNeutr(fNbStepsNeutral);
|
||||
|
||||
fRunAction->CountTransmit (fTransmitFlag);
|
||||
fRunAction->CountReflect (fReflectFlag);
|
||||
run->CountTransmit (fTransmitFlag);
|
||||
run->CountReflect (fReflectFlag);
|
||||
|
||||
G4AnalysisManager::Instance()->FillH1(1,fEnergyDeposit);
|
||||
}
|
||||
|
||||
@@ -1,805 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm5/src/ExG4HbookAnalysisManager.cc
|
||||
/// \brief Implementation of the ExG4HbookAnalysisManager class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
/// \file ExG4HbookAnalysisManager.cc
|
||||
/// \brief Implementation of the ExG4HbookAnalysisManager class
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifdef G4_USE_HBOOK
|
||||
|
||||
#include "ExG4HbookAnalysisManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern "C" int setpawc();
|
||||
extern "C" int setntuc();
|
||||
|
||||
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::fgInstance = 0;
|
||||
const G4int ExG4HbookAnalysisManager::fgkDefaultH2HbookIdOffset = 100;
|
||||
const G4int ExG4HbookAnalysisManager::fgkDefaultNtupleHbookId = 1;
|
||||
const G4String ExG4HbookAnalysisManager::fgkDefaultNtupleDirectoryName = "ntuple";
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Instance()
|
||||
{
|
||||
if ( fgInstance == 0 ) {
|
||||
fgInstance = new ExG4HbookAnalysisManager();
|
||||
}
|
||||
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
|
||||
: G4VAnalysisManager("Hbook"),
|
||||
fH1HbookIdOffset(-1),
|
||||
fH2HbookIdOffset(-1),
|
||||
fNtupleHbookId(-1),
|
||||
fFile(0),
|
||||
fH1Vector(),
|
||||
fH1MapByName(),
|
||||
fH2Vector(),
|
||||
fH2MapByName(),
|
||||
fNtupleName(),
|
||||
fNtupleTitle(),
|
||||
fNtuple(0),
|
||||
fNtupleIColumnMap(),
|
||||
fNtupleFColumnMap(),
|
||||
fNtupleDColumnMap()
|
||||
{
|
||||
if ( fgInstance ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "G4HbookAnalysisManager already exists."
|
||||
<< "Cannot create another instance.";
|
||||
G4Exception("G4HbookAnalysisManager::G4HbookAnalysisManager()",
|
||||
"Analysis_F001", FatalException, description);
|
||||
}
|
||||
|
||||
fgInstance = this;
|
||||
|
||||
// Initialize HBOOK :
|
||||
tools::hbook::CHLIMIT(setpawc());
|
||||
setntuc(); //for ntuple.
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager::~ExG4HbookAnalysisManager()
|
||||
{
|
||||
std::vector<tools::hbook::h1*>::iterator it;
|
||||
for ( it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
|
||||
delete *it;
|
||||
}
|
||||
std::vector<tools::hbook::h2*>::iterator it2;
|
||||
for ( it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
|
||||
delete *it2;
|
||||
}
|
||||
delete fNtuple;
|
||||
delete fFile;
|
||||
|
||||
fgInstance = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<int>*
|
||||
ExG4HbookAnalysisManager::GetNtupleIColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
|
||||
= fNtupleIColumnMap.find(id);
|
||||
if ( it == fNtupleIColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<float>*
|
||||
ExG4HbookAnalysisManager::GetNtupleFColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
|
||||
= fNtupleFColumnMap.find(id);
|
||||
if ( it == fNtupleFColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<double>*
|
||||
ExG4HbookAnalysisManager::GetNtupleDColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
|
||||
= fNtupleDColumnMap.find(id);
|
||||
if ( it == fNtupleDColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::OpenFile(const G4String& fileName)
|
||||
{
|
||||
G4String name(fileName);
|
||||
if ( name.find(".") == std::string::npos ) {
|
||||
name.append(".");
|
||||
name.append(GetFileType());
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("open", "analysis file", name);
|
||||
#endif
|
||||
|
||||
tools::hbook::CHCDIR("//PAWC"," ");
|
||||
|
||||
unsigned int unit = 1;
|
||||
fFile = new tools::hbook::wfile(std::cout, name, unit);
|
||||
if ( ! fFile->is_valid() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Cannot open file " << fileName;
|
||||
G4Exception("G4HbookAnalysisManager::OpenFile()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point, in HBOOK, we should have :
|
||||
// - created a //LUN1 directory attached to the file
|
||||
// - created a //PAWC/LUN1 in memory
|
||||
// - be in the directory //PAWC/LUN1.
|
||||
|
||||
// create an "histo" HBOOK directory both in memory and in the file :
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
|
||||
tools::hbook::CHCDIR("//LUN1"," ");
|
||||
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
|
||||
}
|
||||
|
||||
fLockHistoDirectoryName = true;
|
||||
|
||||
// the five upper lines could have been done with :
|
||||
//fFile->cd_home();
|
||||
//fFile->mkcd("histo");
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("open", "analysis file", name);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::Write()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("write", "file", "");
|
||||
#endif
|
||||
|
||||
// ntuple
|
||||
//if ( fNtuple ) fNtuple->add_row_end();
|
||||
|
||||
G4bool result = fFile->write();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("write", "file", "", result);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::CloseFile()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("close", "file", "");
|
||||
#endif
|
||||
|
||||
//WARNING : have to delete the ntuple before closing the file.
|
||||
delete fNtuple;
|
||||
fNtuple = 0;
|
||||
|
||||
G4bool result = fFile->close();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("close", "file", "", result);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateH1(const G4String& name, const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "H1", name);
|
||||
#endif
|
||||
|
||||
// Go to histograms directory
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
G4String histoPath = "//PAWC/LUN1/";
|
||||
histoPath.append(fHistoDirectoryName.data());
|
||||
tools::hbook::CHCDIR(histoPath.data()," ");
|
||||
}
|
||||
|
||||
// Set fH1HbookIdOffset if needed
|
||||
if ( fH1Vector.size() == 0 ) {
|
||||
if ( fH1HbookIdOffset == -1 ) {
|
||||
if ( fFirstHistoId > 0 )
|
||||
fH1HbookIdOffset = 0;
|
||||
else
|
||||
fH1HbookIdOffset = 1;
|
||||
|
||||
if ( fH1HbookIdOffset > 0 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
|
||||
G4Exception("ExG4HbookAnalysisManager::CreateH1()",
|
||||
"Analysis_W011", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create histogram
|
||||
G4int index = fH1Vector.size();
|
||||
G4int hbookIndex = fH1HbookIdOffset + fH1Vector.size() + fFirstHistoId;
|
||||
tools::hbook::h1* h1 = new tools::hbook::h1(hbookIndex, title, nbins, xmin, xmax);
|
||||
fH1Vector.push_back(h1);
|
||||
fH1MapByName[name] = h1;
|
||||
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
// Return to //PAWC/LUN1 :
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
}
|
||||
|
||||
fLockFirstHistoId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << hbookIndex;
|
||||
fpVerboseL1->Message("create", "H1", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstHistoId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateH2(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "H2", name);
|
||||
#endif
|
||||
|
||||
// Go to histograms directory
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
G4String histoPath = "//PAWC/LUN1/";
|
||||
histoPath.append(fHistoDirectoryName.data());
|
||||
tools::hbook::CHCDIR(histoPath.data()," ");
|
||||
}
|
||||
|
||||
// Set fH2HbookIdOffset if needed
|
||||
if ( fH2Vector.size() == 0 ) {
|
||||
if ( fH2HbookIdOffset == -1 ) {
|
||||
if ( fFirstHistoId > 0 )
|
||||
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
|
||||
else
|
||||
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset + 1;
|
||||
|
||||
if ( fH2HbookIdOffset != fgkDefaultH2HbookIdOffset ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "H2 will be defined in HBOOK with ID = "
|
||||
<< fgkDefaultH2HbookIdOffset << " + G4_firstHistoId + 1";
|
||||
G4Exception("ExG4HbookAnalysisManager::CreateH2()",
|
||||
"Analysis_W011", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4int index = fH2Vector.size();
|
||||
G4int hbookIndex = fH2HbookIdOffset + fH2Vector.size() + fFirstHistoId;
|
||||
tools::hbook::h2* h2
|
||||
= new tools::hbook::h2(hbookIndex, title, nxbins, xmin, xmax, nybins, ymin, ymax);
|
||||
fH2Vector.push_back(h2);
|
||||
fH2MapByName[name] = h2;
|
||||
|
||||
// Return to //PAWC/LUN1 :
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
}
|
||||
|
||||
fLockFirstHistoId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << hbookIndex;
|
||||
fpVerboseL1->Message("create", "H2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstHistoId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ExG4HbookAnalysisManager::CreateNtuple(const G4String& name,
|
||||
const G4String& title)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple", name);
|
||||
#endif
|
||||
|
||||
if ( fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple already exists. "
|
||||
<< "(Only one ntuple is currently supported.)";
|
||||
G4Exception("G4HbookAnalysisManager::CreateNtuple()",
|
||||
"Analysis_W006", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an "ntuple" directory both in memory and in the file
|
||||
fFile->cd_home(); //go under //PAWC/LUN1
|
||||
if ( fNtupleDirectoryName == "" )
|
||||
fFile->mkcd(fgkDefaultNtupleDirectoryName.data());
|
||||
else
|
||||
fFile->mkcd(fNtupleDirectoryName.data());
|
||||
|
||||
// Define ntuple ID in HBOOK
|
||||
if ( fNtupleHbookId == -1 ) fNtupleHbookId = fgkDefaultNtupleHbookId;
|
||||
|
||||
// We should be under //PAWC/LUN1/ntuple
|
||||
fNtuple = new tools::hbook::wntuple(fNtupleHbookId, name);
|
||||
fNtupleName = name;
|
||||
fNtupleTitle = title;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << fNtupleHbookId;
|
||||
fpVerboseL1->Message("create", "ntuple", description);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleIColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple I column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<int>* column = fNtuple->create_column<int>(name);
|
||||
fNtupleIColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple I column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleFColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple F column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<float>* column = fNtuple->create_column<float>(name);
|
||||
fNtupleFColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple F column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleDColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple D column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<double>* column = fNtuple->create_column<double>(name);
|
||||
fNtupleDColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple D column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ExG4HbookAnalysisManager::FinishNtuple()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("finish", "ntuple", fNtupleName);
|
||||
#endif
|
||||
|
||||
// Return to //PAWC/LUN1 :
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
|
||||
//fNtuple->add_row_beg();
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("finish", "ntuple", fNtupleName);
|
||||
#endif
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillH1(G4int id, G4double value, G4double weight)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "H1", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::h1* h1 = GetH1(id);
|
||||
if ( ! h1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histogram " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillH1()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
h1->fill(value, weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "H1", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillH2(G4int id,
|
||||
G4double xvalue, G4double yvalue,
|
||||
G4double weight)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue << " yvalue " << yvalue;
|
||||
fpVerboseL3->Message("fill", "H2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::h2* h2 = GetH2(id);
|
||||
if ( ! h2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histogram " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillH2()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
h2->fill(xvalue, yvalue, weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue << " yvalue " << yvalue;
|
||||
fpVerboseL2->Message("fill", "H2", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleIColumn(G4int id, G4int value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<int>* column = GetNtupleIColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleFColumn(G4int id, G4float value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<float>* column = GetNtupleFColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleDColumn(G4int id, G4double value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<double>* column = GetNtupleDColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::AddNtupleRow()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("add", "ntuple row", "");
|
||||
#endif
|
||||
|
||||
//G4cout << "Hbook: Going to add Ntuple row ..." << G4endl;
|
||||
if ( ! fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple does not exist. ";
|
||||
G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
|
||||
"Analysis_W008", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
//fNtuple->add_row_fast();
|
||||
fNtuple->add_row();
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 )
|
||||
fpVerboseL2->Message("add", "ntuple row", "");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::h1* ExG4HbookAnalysisManager::GetH1(G4int id, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstHistoId;
|
||||
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
|
||||
if ( warn) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histo " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetH1()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fH1Vector[index];
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::h2* ExG4HbookAnalysisManager::GetH2(G4int id, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstHistoId;
|
||||
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
|
||||
if ( warn) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histo " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetH2()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fH2Vector[index];
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple() const
|
||||
{
|
||||
return fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetH1HbookIdOffset(G4int offset)
|
||||
{
|
||||
if ( fH1Vector.size() ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fFirstHistoId + offset < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The first histogram HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fH1HbookIdOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetH2HbookIdOffset(G4int offset)
|
||||
{
|
||||
if ( fH2Vector.size() ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fFirstHistoId + offset < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The first histogram HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fH2HbookIdOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetNtupleHbookId(G4int ntupleId)
|
||||
{
|
||||
if ( fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set NtupleHbookId as an ntuple already exists.";
|
||||
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
|
||||
"Analysis_W010", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ntupleId < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The ntuple HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
|
||||
"Analysis_W010", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fNtupleHbookId = ntupleId;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the HistoManager class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: HistoManager.cc 72235 2013-07-12 08:37:53Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -114,6 +114,6 @@ void HistoManager::Book()
|
||||
// as we have not yet set nbins, vmin, vmax
|
||||
for (G4int k=0; k<kMaxHisto; k++) {
|
||||
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
|
||||
analysisManager->SetActivation(G4VAnalysisManager::kH1, ih, false);
|
||||
analysisManager->SetH1Activation(ih, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandard.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PhysListEmStandard.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "G4KleinNishinaModel.hh"
|
||||
|
||||
#include "G4eMultipleScattering.hh"
|
||||
#include "G4UrbanMscModel96.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
@@ -86,9 +85,9 @@ void PhysListEmStandard::ConstructProcess()
|
||||
|
||||
// Add standard EM Processes
|
||||
//
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
aParticleIterator->reset();
|
||||
while( (*aParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = aParticleIterator->value();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
if (particleName == "gamma") {
|
||||
@@ -96,15 +95,13 @@ void PhysListEmStandard::ConstructProcess()
|
||||
////ph->RegisterProcess(new G4RayleighScattering, particle);
|
||||
ph->RegisterProcess(new G4PhotoElectricEffect, particle);
|
||||
G4ComptonScattering* cs = new G4ComptonScattering;
|
||||
cs->SetModel(new G4KleinNishinaModel());
|
||||
cs->SetEmModel(new G4KleinNishinaModel());
|
||||
ph->RegisterProcess(cs, particle);
|
||||
ph->RegisterProcess(new G4GammaConversion, particle);
|
||||
|
||||
} else if (particleName == "e-") {
|
||||
|
||||
G4eMultipleScattering* msc = new G4eMultipleScattering();
|
||||
msc -> AddEmModel(0, new G4UrbanMscModel96());
|
||||
ph->RegisterProcess(msc, particle);
|
||||
|
||||
ph->RegisterProcess(new G4eMultipleScattering(), particle);
|
||||
//
|
||||
G4eIonisation* eIoni = new G4eIonisation();
|
||||
eIoni->SetStepFunction(0.1, 100*um);
|
||||
@@ -114,9 +111,7 @@ void PhysListEmStandard::ConstructProcess()
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
|
||||
G4eMultipleScattering* msc = new G4eMultipleScattering();
|
||||
msc -> AddEmModel(0, new G4UrbanMscModel96());
|
||||
ph->RegisterProcess(msc, particle);
|
||||
ph->RegisterProcess(new G4eMultipleScattering(), particle);
|
||||
//
|
||||
G4eIonisation* eIoni = new G4eIonisation();
|
||||
eIoni->SetStepFunction(0.1, 100*um);
|
||||
@@ -140,7 +135,7 @@ void PhysListEmStandard::ConstructProcess()
|
||||
particleName == "pi-" ||
|
||||
particleName == "pi+" ) {
|
||||
|
||||
ph->RegisterProcess(new G4hMultipleScattering(), particle);
|
||||
ph->RegisterProcess(new G4hMultipleScattering(), particle);
|
||||
G4hIonisation* hIoni = new G4hIonisation();
|
||||
hIoni->SetStepFunction(0.1, 20*um);
|
||||
ph->RegisterProcess(hIoni, particle);
|
||||
@@ -148,7 +143,7 @@ void PhysListEmStandard::ConstructProcess()
|
||||
ph->RegisterProcess(new G4hPairProduction(), particle);
|
||||
|
||||
} else if( particleName == "alpha" ||
|
||||
particleName == "He3" ) {
|
||||
particleName == "He3" ) {
|
||||
|
||||
ph->RegisterProcess(new G4hMultipleScattering(), particle);
|
||||
G4ionIonisation* ionIoni = new G4ionIonisation();
|
||||
@@ -166,9 +161,9 @@ void PhysListEmStandard::ConstructProcess()
|
||||
ph->RegisterProcess(new G4NuclearStopping(), particle);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
|
||||
//all others charged particles except geantino
|
||||
ph->RegisterProcess(new G4hMultipleScattering(), particle);
|
||||
ph->RegisterProcess(new G4hIonisation(), particle);
|
||||
@@ -184,10 +179,10 @@ void PhysListEmStandard::ConstructProcess()
|
||||
|
||||
//physics tables
|
||||
//
|
||||
emOptions.SetMinEnergy(10*eV); //default 100 eV
|
||||
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
|
||||
emOptions.SetDEDXBinning(12*10); //default=12*7
|
||||
emOptions.SetLambdaBinning(12*10); //default=12*7
|
||||
emOptions.SetMinEnergy(10*eV); //default 100 eV
|
||||
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
|
||||
emOptions.SetDEDXBinning(12*10); //default=12*7
|
||||
emOptions.SetLambdaBinning(12*10); //default=12*7
|
||||
|
||||
//multiple coulomb scattering
|
||||
//
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysListEmStandardGS.cc
|
||||
/// \brief Implementation of the PhysListEmStandardGS class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandardGS.cc 68585 2013-04-01 23:35:07Z adotti $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -82,9 +82,9 @@ void PhysListEmStandardGS::ConstructProcess()
|
||||
// Add standard EM Processes
|
||||
//
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
aParticleIterator->reset();
|
||||
while( (*aParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = aParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysListEmStandardSS.cc
|
||||
/// \brief Implementation of the PhysListEmStandardSS class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandardSS.cc 68585 2013-04-01 23:35:07Z adotti $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -75,9 +75,9 @@ void PhysListEmStandardSS::ConstructProcess()
|
||||
{
|
||||
// Add standard EM Processes
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
aParticleIterator->reset();
|
||||
while( (*aParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = aParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysListEmStandardSSM.cc
|
||||
/// \brief Implementation of the PhysListEmStandardSSM class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandardSSM.cc 68585 2013-04-01 23:35:07Z adotti $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -77,9 +77,9 @@ void PhysListEmStandardSSM::ConstructProcess()
|
||||
{
|
||||
// Add standard EM Processes
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
aParticleIterator->reset();
|
||||
while( (*aParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = aParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysListEmStandardWVI.cc
|
||||
/// \brief Implementation of the PhysListEmStandardWVI class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandardWVI.cc 68585 2013-04-01 23:35:07Z adotti $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -86,9 +86,9 @@ void PhysListEmStandardWVI::ConstructProcess()
|
||||
// Add standard EM Processes
|
||||
//
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
aParticleIterator->reset();
|
||||
while( (*aParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = aParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysicsList.cc
|
||||
/// \brief Implementation of the PhysicsList class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysicsList.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -81,7 +81,8 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::PhysicsList() : G4VModularPhysicsList()
|
||||
PhysicsList::PhysicsList() : G4VModularPhysicsList(),
|
||||
fMessenger(0),fEmPhysicsList(0)
|
||||
{
|
||||
fMessenger = new PhysicsListMessenger(this);
|
||||
|
||||
@@ -291,7 +292,11 @@ void PhysicsList::SetCuts()
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
}
|
||||
|
||||
|
||||
// fixe lower limit for cut
|
||||
///G4ProductionCutsTable::GetProductionCutsTable()
|
||||
/// ->SetEnergyRange(10*eV, 1*GeV);
|
||||
|
||||
// set cut values for gamma at first and for e- second and next for e+,
|
||||
// because some processes for e+/e- need cut values for gamma
|
||||
SetCutValue(fCutForGamma, "gamma");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PhysicsListMessenger.cc
|
||||
/// \brief Implementation of the PhysicsListMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysicsListMessenger.cc 77083 2013-11-21 10:35:55Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -41,7 +41,13 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
:fPhysicsList(pPhys)
|
||||
:G4UImessenger(),fPhysicsList(pPhys),
|
||||
fPhysDir(0),
|
||||
fListCmd(0),
|
||||
fGammaCutCmd(0),
|
||||
fElectCutCmd(0),
|
||||
fProtoCutCmd(0),
|
||||
fAllCutCmd(0)
|
||||
{
|
||||
fPhysDir = new G4UIdirectory("/testem/phys/");
|
||||
fPhysDir->SetGuidance("physics list commands");
|
||||
@@ -50,6 +56,7 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
fListCmd->SetGuidance("Add modula physics list.");
|
||||
fListCmd->SetParameterName("PList",false);
|
||||
fListCmd->AvailableForStates(G4State_PreInit);
|
||||
fListCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
|
||||
fGammaCutCmd->SetGuidance("Set gamma cut.");
|
||||
@@ -57,6 +64,7 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
fGammaCutCmd->SetUnitCategory("Length");
|
||||
fGammaCutCmd->SetRange("Gcut>0.0");
|
||||
fGammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fGammaCutCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
|
||||
fElectCutCmd->SetGuidance("Set electron cut.");
|
||||
@@ -64,13 +72,15 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
fElectCutCmd->SetUnitCategory("Length");
|
||||
fElectCutCmd->SetRange("Ecut>0.0");
|
||||
fElectCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fElectCutCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fProtoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
|
||||
fProtoCutCmd->SetGuidance("Set positron cut.");
|
||||
fProtoCutCmd->SetParameterName("Pcut",false);
|
||||
fProtoCutCmd->SetUnitCategory("Length");
|
||||
fProtoCutCmd->SetRange("Pcut>0.0");
|
||||
fProtoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fProtoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fProtoCutCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
|
||||
fAllCutCmd->SetGuidance("Set cut for all.");
|
||||
@@ -78,7 +88,7 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
fAllCutCmd->SetUnitCategory("Length");
|
||||
fAllCutCmd->SetRange("cut>0.0");
|
||||
fAllCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fAllCutCmd->SetToBeBroadcasted(false);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -102,12 +112,14 @@ void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
|
||||
if( command == fGammaCutCmd )
|
||||
{ fPhysicsList->SetCutForGamma(fGammaCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == fElectCutCmd ) {
|
||||
fPhysicsList->SetCutForElectron(fElectCutCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
|
||||
if( command == fElectCutCmd )
|
||||
{ fPhysicsList->SetCutForElectron(fElectCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == fProtoCutCmd )
|
||||
{ fPhysicsList->SetCutForPositron(fProtoCutCmd->GetNewDoubleValue(newValue));}
|
||||
if( command == fProtoCutCmd ) {
|
||||
fPhysicsList->SetCutForPositron(fProtoCutCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
|
||||
if( command == fAllCutCmd )
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction.cc 77583 2013-11-26 10:28:15Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -44,14 +44,13 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction(
|
||||
DetectorConstruction* DC)
|
||||
:fDetector(DC)
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* DC)
|
||||
:G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),fDetector(DC),fRndmBeam(0),fGunMessenger(0)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
SetDefaultKinematic();
|
||||
fRndmBeam = 0.;
|
||||
|
||||
//create a messenger for this class
|
||||
fGunMessenger = new PrimaryGeneratorMessenger(this);
|
||||
@@ -78,7 +77,7 @@ void PrimaryGeneratorAction::SetDefaultKinematic()
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
|
||||
fParticleGun->SetParticleEnergy(30.*MeV);
|
||||
G4double x0 = -0.5*(fDetector->GetWorldSizeX());
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0, 0*cm, 0*cm));
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0, 0.0, 0.0));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/PrimaryGeneratorMessenger.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -42,7 +42,10 @@
|
||||
|
||||
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
|
||||
PrimaryGeneratorAction* Gun)
|
||||
:fAction(Gun)
|
||||
:G4UImessenger(),fAction(Gun),
|
||||
fGunDir(0),
|
||||
fDefaultCmd(0),
|
||||
fRndmCmd(0)
|
||||
{
|
||||
fGunDir = new G4UIdirectory("/testem/gun/");
|
||||
fGunDir->SetGuidance("gun control");
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm11/src/Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4EmCalculator.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run(DetectorConstruction* det)
|
||||
: G4Run(),
|
||||
fDetector(det),
|
||||
fParticle(0), fEkin(0.)
|
||||
{
|
||||
fEnergyDeposit = fEnergyDeposit2 = 0.;
|
||||
fTrakLenCharged = fTrakLenCharged2 = 0.;
|
||||
fTrakLenNeutral = fTrakLenNeutral2 = 0.;
|
||||
fNbStepsCharged = fNbStepsCharged2 = 0.;
|
||||
fNbStepsNeutral = fNbStepsNeutral2 = 0.;
|
||||
fMscProjecTheta = fMscProjecTheta2 = 0.;
|
||||
fMscThetaCentral = 0.;
|
||||
|
||||
fNbGamma = fNbElect = fNbPosit = 0;
|
||||
|
||||
fTransmit[0] = fTransmit[1] = fReflect[0] = fReflect[1] = 0;
|
||||
|
||||
fMscEntryCentral = 0;
|
||||
|
||||
fEnergyLeak[0] = fEnergyLeak[1] = fEnergyLeak2[0] = fEnergyLeak2[1] = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
|
||||
{
|
||||
fParticle = particle;
|
||||
fEkin = energy;
|
||||
|
||||
//compute theta0
|
||||
fMscThetaCentral = 3*ComputeMscHighland();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge(const G4Run* run)
|
||||
{
|
||||
const Run* localRun = static_cast<const Run*>(run);
|
||||
|
||||
// pass information about primary particle
|
||||
fParticle = localRun->fParticle;
|
||||
fEkin = localRun->fEkin;
|
||||
|
||||
fMscThetaCentral = localRun->fMscThetaCentral;
|
||||
|
||||
// accumulate sums
|
||||
//
|
||||
fEnergyDeposit += localRun->fEnergyDeposit;
|
||||
fEnergyDeposit2 += localRun->fEnergyDeposit2;
|
||||
fTrakLenCharged += localRun->fTrakLenCharged;
|
||||
fTrakLenCharged2 += localRun->fTrakLenCharged2;
|
||||
fTrakLenNeutral += localRun->fTrakLenNeutral;
|
||||
fTrakLenNeutral2 += localRun->fTrakLenNeutral2;
|
||||
fNbStepsCharged += localRun->fNbStepsCharged;
|
||||
fNbStepsCharged2 += localRun->fNbStepsCharged2;
|
||||
fNbStepsNeutral += localRun->fNbStepsNeutral;
|
||||
fNbStepsNeutral2 += localRun->fNbStepsNeutral2;
|
||||
|
||||
fNbGamma += localRun->fNbGamma;
|
||||
fNbElect += localRun->fNbElect;
|
||||
fNbPosit += localRun->fNbPosit;
|
||||
|
||||
fTransmit[0] += localRun->fTransmit[0];
|
||||
fTransmit[1] += localRun->fTransmit[1];
|
||||
fReflect[0] += localRun->fReflect[0];
|
||||
fReflect[1] += localRun->fReflect[1];
|
||||
|
||||
fMscEntryCentral += localRun->fMscEntryCentral;
|
||||
|
||||
fEnergyLeak[0] += localRun->fEnergyLeak[0];
|
||||
fEnergyLeak[1] += localRun->fEnergyLeak[1];
|
||||
fEnergyLeak2[0] += localRun->fEnergyLeak2[0];
|
||||
fEnergyLeak2[1] += localRun->fEnergyLeak2[1];
|
||||
|
||||
G4Run::Merge(run);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::PrintSummary()
|
||||
{
|
||||
// compute mean and rms
|
||||
//
|
||||
G4int TotNbofEvents = numberOfEvent;
|
||||
if (TotNbofEvents == 0) return;
|
||||
|
||||
G4double EnergyBalance = fEnergyDeposit + fEnergyLeak[0] + fEnergyLeak[1];
|
||||
EnergyBalance /= TotNbofEvents;
|
||||
|
||||
fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents;
|
||||
G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit;
|
||||
if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep/TotNbofEvents);
|
||||
else rmsEdep = 0.;
|
||||
|
||||
fTrakLenCharged /= TotNbofEvents; fTrakLenCharged2 /= TotNbofEvents;
|
||||
G4double rmsTLCh = fTrakLenCharged2 - fTrakLenCharged*fTrakLenCharged;
|
||||
if (rmsTLCh>0.) rmsTLCh = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsTLCh = 0.;
|
||||
|
||||
fTrakLenNeutral /= TotNbofEvents; fTrakLenNeutral2 /= TotNbofEvents;
|
||||
G4double rmsTLNe = fTrakLenNeutral2 - fTrakLenNeutral*fTrakLenNeutral;
|
||||
if (rmsTLNe>0.) rmsTLNe = std::sqrt(rmsTLNe/TotNbofEvents);
|
||||
else rmsTLNe = 0.;
|
||||
|
||||
fNbStepsCharged /= TotNbofEvents; fNbStepsCharged2 /= TotNbofEvents;
|
||||
G4double rmsStCh = fNbStepsCharged2 - fNbStepsCharged*fNbStepsCharged;
|
||||
if (rmsStCh>0.) rmsStCh = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsStCh = 0.;
|
||||
|
||||
fNbStepsNeutral /= TotNbofEvents; fNbStepsNeutral2 /= TotNbofEvents;
|
||||
G4double rmsStNe = fNbStepsNeutral2 - fNbStepsNeutral*fNbStepsNeutral;
|
||||
if (rmsStNe>0.) rmsStNe = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsStNe = 0.;
|
||||
|
||||
G4double Gamma = (G4double)fNbGamma/TotNbofEvents;
|
||||
G4double Elect = (G4double)fNbElect/TotNbofEvents;
|
||||
G4double Posit = (G4double)fNbPosit/TotNbofEvents;
|
||||
|
||||
G4double transmit[2];
|
||||
transmit[0] = 100.*fTransmit[0]/TotNbofEvents;
|
||||
transmit[1] = 100.*fTransmit[1]/TotNbofEvents;
|
||||
|
||||
G4double reflect[2];
|
||||
reflect[0] = 100.*fReflect[0]/TotNbofEvents;
|
||||
reflect[1] = 100.*fReflect[1]/TotNbofEvents;
|
||||
|
||||
G4double rmsMsc = 0., tailMsc = 0.;
|
||||
if (fMscEntryCentral > 0) {
|
||||
fMscProjecTheta /= fMscEntryCentral; fMscProjecTheta2 /= fMscEntryCentral;
|
||||
rmsMsc = fMscProjecTheta2 - fMscProjecTheta*fMscProjecTheta;
|
||||
if (rmsMsc > 0.) { rmsMsc = std::sqrt(rmsMsc); }
|
||||
if(fTransmit[1] > 0.0) {
|
||||
tailMsc = 100.- (100.*fMscEntryCentral)/(2*fTransmit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
fEnergyLeak[0] /= TotNbofEvents; fEnergyLeak2[0] /= TotNbofEvents;
|
||||
G4double rmsEl0 = fEnergyLeak2[0] - fEnergyLeak[0]*fEnergyLeak[0];
|
||||
if (rmsEl0>0.) rmsEl0 = std::sqrt(rmsEl0/TotNbofEvents);
|
||||
else rmsEl0 = 0.;
|
||||
|
||||
fEnergyLeak[1] /= TotNbofEvents; fEnergyLeak2[1] /= TotNbofEvents;
|
||||
G4double rmsEl1 = fEnergyLeak2[1] - fEnergyLeak[1]*fEnergyLeak[1];
|
||||
if (rmsEl1>0.) rmsEl1 = std::sqrt(rmsEl1/TotNbofEvents);
|
||||
else rmsEl1 = 0.;
|
||||
|
||||
|
||||
//Stopping Power from input Table.
|
||||
//
|
||||
G4Material* material = fDetector->GetAbsorberMaterial();
|
||||
G4double length = fDetector->GetAbsorberThickness();
|
||||
G4double density = material->GetDensity();
|
||||
G4String partName = fParticle->GetParticleName();
|
||||
|
||||
G4EmCalculator emCalculator;
|
||||
G4double dEdxTable = 0., dEdxFull = 0.;
|
||||
if (fParticle->GetPDGCharge()!= 0.) {
|
||||
dEdxTable = emCalculator.GetDEDX(fEkin,fParticle,material);
|
||||
dEdxFull = emCalculator.ComputeTotalDEDX(fEkin,fParticle,material);
|
||||
}
|
||||
G4double stopTable = dEdxTable/density;
|
||||
G4double stopFull = dEdxFull /density;
|
||||
|
||||
//Stopping Power from simulation.
|
||||
//
|
||||
G4double meandEdx = fEnergyDeposit/length;
|
||||
G4double stopPower = meandEdx/density;
|
||||
|
||||
G4cout << "\n ======================== run summary ======================\n";
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
G4cout << "\n The run was " << TotNbofEvents << " " << partName << " of "
|
||||
<< G4BestUnit(fEkin,"Energy") << " through "
|
||||
<< G4BestUnit(length,"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
|
||||
G4cout.precision(4);
|
||||
|
||||
G4cout << "\n Total energy deposit in absorber per event = "
|
||||
<< G4BestUnit(fEnergyDeposit,"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEdep, "Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n -----> Mean dE/dx = " << meandEdx/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopPower/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n From formulas :" << G4endl;
|
||||
G4cout << " restricted dEdx = " << dEdxTable/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopTable/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << " full dEdx = " << dEdxFull/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopFull/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n Leakage : primary = "
|
||||
<< G4BestUnit(fEnergyLeak[0],"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEl0, "Energy")
|
||||
<< " secondaries = "
|
||||
<< G4BestUnit(fEnergyLeak[1],"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEl1, "Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << " Energy balance : edep + eleak = "
|
||||
<< G4BestUnit(EnergyBalance,"Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n Total track length (charged) in absorber per event = "
|
||||
<< G4BestUnit(fTrakLenCharged,"Length") << " +- "
|
||||
<< G4BestUnit(rmsTLCh, "Length") << G4endl;
|
||||
|
||||
G4cout << " Total track length (neutral) in absorber per event = "
|
||||
<< G4BestUnit(fTrakLenNeutral,"Length") << " +- "
|
||||
<< G4BestUnit(rmsTLNe, "Length") << G4endl;
|
||||
|
||||
G4cout << "\n Number of steps (charged) in absorber per event = "
|
||||
<< fNbStepsCharged << " +- " << rmsStCh << G4endl;
|
||||
|
||||
G4cout << " Number of steps (neutral) in absorber per event = "
|
||||
<< fNbStepsNeutral << " +- " << rmsStNe << G4endl;
|
||||
|
||||
G4cout << "\n Number of secondaries per event : Gammas = " << Gamma
|
||||
<< "; electrons = " << Elect
|
||||
<< "; positrons = " << Posit << G4endl;
|
||||
|
||||
G4cout << "\n Number of events with the primary particle transmitted = "
|
||||
<< transmit[1] << " %" << G4endl;
|
||||
|
||||
G4cout << " Number of events with at least 1 particle transmitted "
|
||||
<< "(same charge as primary) = " << transmit[0] << " %" << G4endl;
|
||||
|
||||
G4cout << "\n Number of events with the primary particle reflected = "
|
||||
<< reflect[1] << " %" << G4endl;
|
||||
|
||||
G4cout << " Number of events with at least 1 particle reflected "
|
||||
<< "(same charge as primary) = " << reflect[0] << " %" << G4endl;
|
||||
|
||||
// compute width of the Gaussian central part of the MultipleScattering
|
||||
//
|
||||
G4cout << "\n MultipleScattering:"
|
||||
<< "\n rms proj angle of transmit primary particle = "
|
||||
<< rmsMsc/mrad << " mrad (central part only)" << G4endl;
|
||||
|
||||
G4cout << " computed theta0 (Highland formula) = "
|
||||
<< ComputeMscHighland()/mrad << " mrad" << G4endl;
|
||||
|
||||
G4cout << " central part defined as +- "
|
||||
<< fMscThetaCentral/mrad << " mrad; "
|
||||
<< " Tail ratio = " << tailMsc << " %" << G4endl;
|
||||
|
||||
// reset default precision
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4double Run::ComputeMscHighland()
|
||||
{
|
||||
//compute the width of the Gaussian central part of the MultipleScattering
|
||||
//projected angular distribution.
|
||||
//Eur. Phys. Jour. C15 (2000) page 166, formule 23.9
|
||||
|
||||
G4double t = (fDetector->GetAbsorberThickness())
|
||||
/(fDetector->GetAbsorberMaterial()->GetRadlen());
|
||||
if (t < DBL_MIN) return 0.;
|
||||
|
||||
G4double T = fEkin;
|
||||
G4double M = fParticle->GetPDGMass();
|
||||
G4double z = std::abs(fParticle->GetPDGCharge()/eplus);
|
||||
|
||||
G4double bpc = T*(T+2*M)/(T+M);
|
||||
G4double teta0 = 13.6*MeV*z*std::sqrt(t)*(1.+0.038*std::log(t))/bpc;
|
||||
return teta0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: RunAction.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
@@ -48,7 +49,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
|
||||
:fDetector(det), fPrimary(kin), fHistoManager(0)
|
||||
:G4UserRunAction(),fDetector(det), fPrimary(kin), fRun(0), fHistoManager(0)
|
||||
{
|
||||
// Book predefined histograms
|
||||
fHistoManager = new HistoManager();
|
||||
@@ -63,218 +64,46 @@ RunAction::~RunAction()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
G4Run* RunAction::GenerateRun()
|
||||
{
|
||||
fRun = new Run(fDetector);
|
||||
return fRun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
|
||||
//initialisation
|
||||
fEnergyDeposit = fEnergyDeposit2 = 0.;
|
||||
fTrakLenCharged = fTrakLenCharged2 = 0.;
|
||||
fTrakLenNeutral = fTrakLenNeutral2 = 0.;
|
||||
fNbStepsCharged = fNbStepsCharged2 = 0.;
|
||||
fNbStepsNeutral = fNbStepsNeutral2 = 0.;
|
||||
fMscProjecTheta = fMscProjecTheta2 = 0.;
|
||||
fMscThetaCentral = 3*ComputeMscHighland();
|
||||
|
||||
fNbGamma = fNbElect = fNbPosit = 0;
|
||||
|
||||
fTransmit[0] = fTransmit[1] = fReflect[0] = fReflect[1] = 0;
|
||||
// save Rndm status
|
||||
//// G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
G4Random::showEngineStatus();
|
||||
|
||||
// keep run condition
|
||||
if ( fPrimary ) {
|
||||
G4ParticleDefinition* particle
|
||||
= fPrimary->GetParticleGun()->GetParticleDefinition();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
fRun->SetPrimary(particle, energy);
|
||||
}
|
||||
|
||||
fMscEntryCentral = 0;
|
||||
|
||||
fEnergyLeak[0] = fEnergyLeak[1] = fEnergyLeak2[0] = fEnergyLeak2[1] = 0.;
|
||||
|
||||
//histograms
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->OpenFile();
|
||||
}
|
||||
|
||||
// save Rndm status
|
||||
//// G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
// compute mean and rms
|
||||
//
|
||||
G4int TotNbofEvents = aRun->GetNumberOfEvent();
|
||||
if (TotNbofEvents == 0) return;
|
||||
|
||||
G4double EnergyBalance = fEnergyDeposit + fEnergyLeak[0] + fEnergyLeak[1];
|
||||
EnergyBalance /= TotNbofEvents;
|
||||
|
||||
fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents;
|
||||
G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit;
|
||||
if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep/TotNbofEvents);
|
||||
else rmsEdep = 0.;
|
||||
|
||||
fTrakLenCharged /= TotNbofEvents; fTrakLenCharged2 /= TotNbofEvents;
|
||||
G4double rmsTLCh = fTrakLenCharged2 - fTrakLenCharged*fTrakLenCharged;
|
||||
if (rmsTLCh>0.) rmsTLCh = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsTLCh = 0.;
|
||||
|
||||
fTrakLenNeutral /= TotNbofEvents; fTrakLenNeutral2 /= TotNbofEvents;
|
||||
G4double rmsTLNe = fTrakLenNeutral2 - fTrakLenNeutral*fTrakLenNeutral;
|
||||
if (rmsTLNe>0.) rmsTLNe = std::sqrt(rmsTLNe/TotNbofEvents);
|
||||
else rmsTLNe = 0.;
|
||||
|
||||
fNbStepsCharged /= TotNbofEvents; fNbStepsCharged2 /= TotNbofEvents;
|
||||
G4double rmsStCh = fNbStepsCharged2 - fNbStepsCharged*fNbStepsCharged;
|
||||
if (rmsStCh>0.) rmsStCh = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsStCh = 0.;
|
||||
|
||||
fNbStepsNeutral /= TotNbofEvents; fNbStepsNeutral2 /= TotNbofEvents;
|
||||
G4double rmsStNe = fNbStepsNeutral2 - fNbStepsNeutral*fNbStepsNeutral;
|
||||
if (rmsStNe>0.) rmsStNe = std::sqrt(rmsTLCh/TotNbofEvents);
|
||||
else rmsStNe = 0.;
|
||||
|
||||
G4double Gamma = (G4double)fNbGamma/TotNbofEvents;
|
||||
G4double Elect = (G4double)fNbElect/TotNbofEvents;
|
||||
G4double Posit = (G4double)fNbPosit/TotNbofEvents;
|
||||
|
||||
G4double transmit[2];
|
||||
transmit[0] = 100.*fTransmit[0]/TotNbofEvents;
|
||||
transmit[1] = 100.*fTransmit[1]/TotNbofEvents;
|
||||
|
||||
G4double reflect[2];
|
||||
reflect[0] = 100.*fReflect[0]/TotNbofEvents;
|
||||
reflect[1] = 100.*fReflect[1]/TotNbofEvents;
|
||||
|
||||
G4double rmsMsc = 0., tailMsc = 0.;
|
||||
if (fMscEntryCentral > 0) {
|
||||
fMscProjecTheta /= fMscEntryCentral; fMscProjecTheta2 /= fMscEntryCentral;
|
||||
rmsMsc = fMscProjecTheta2 - fMscProjecTheta*fMscProjecTheta;
|
||||
if (rmsMsc > 0.) { rmsMsc = std::sqrt(rmsMsc); }
|
||||
if(fTransmit[1] > 0.0) {
|
||||
tailMsc = 100.- (100.*fMscEntryCentral)/(2*fTransmit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
fEnergyLeak[0] /= TotNbofEvents; fEnergyLeak2[0] /= TotNbofEvents;
|
||||
G4double rmsEl0 = fEnergyLeak2[0] - fEnergyLeak[0]*fEnergyLeak[0];
|
||||
if (rmsEl0>0.) rmsEl0 = std::sqrt(rmsEl0/TotNbofEvents);
|
||||
else rmsEl0 = 0.;
|
||||
|
||||
fEnergyLeak[1] /= TotNbofEvents; fEnergyLeak2[1] /= TotNbofEvents;
|
||||
G4double rmsEl1 = fEnergyLeak2[1] - fEnergyLeak[1]*fEnergyLeak[1];
|
||||
if (rmsEl1>0.) rmsEl1 = std::sqrt(rmsEl1/TotNbofEvents);
|
||||
else rmsEl1 = 0.;
|
||||
|
||||
|
||||
//Stopping Power from input Table.
|
||||
// print Run summary
|
||||
//
|
||||
G4Material* material = fDetector->GetAbsorberMaterial();
|
||||
G4double length = fDetector->GetAbsorberThickness();
|
||||
G4double density = material->GetDensity();
|
||||
|
||||
G4ParticleDefinition* particle = fPrimary->GetParticleGun()
|
||||
->GetParticleDefinition();
|
||||
G4String partName = particle->GetParticleName();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
|
||||
G4EmCalculator emCalculator;
|
||||
G4double dEdxTable = 0., dEdxFull = 0.;
|
||||
if (particle->GetPDGCharge()!= 0.) {
|
||||
dEdxTable = emCalculator.GetDEDX(energy,particle,material);
|
||||
dEdxFull = emCalculator.ComputeTotalDEDX(energy,particle,material);
|
||||
}
|
||||
G4double stopTable = dEdxTable/density;
|
||||
G4double stopFull = dEdxFull /density;
|
||||
|
||||
//Stopping Power from simulation.
|
||||
//
|
||||
G4double meandEdx = fEnergyDeposit/length;
|
||||
G4double stopPower = meandEdx/density;
|
||||
|
||||
G4cout << "\n ======================== run summary ======================\n";
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
G4cout << "\n The run was " << TotNbofEvents << " " << partName << " of "
|
||||
<< G4BestUnit(energy,"Energy") << " through "
|
||||
<< G4BestUnit(length,"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
|
||||
G4cout.precision(4);
|
||||
|
||||
G4cout << "\n Total energy deposit in absorber per event = "
|
||||
<< G4BestUnit(fEnergyDeposit,"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEdep, "Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n -----> Mean dE/dx = " << meandEdx/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopPower/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n From formulas :" << G4endl;
|
||||
G4cout << " restricted dEdx = " << dEdxTable/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopTable/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << " full dEdx = " << dEdxFull/(MeV/cm) << " MeV/cm"
|
||||
<< "\t(" << stopFull/(MeV*cm2/g) << " MeV*cm2/g)"
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n Leakage : primary = "
|
||||
<< G4BestUnit(fEnergyLeak[0],"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEl0, "Energy")
|
||||
<< " secondaries = "
|
||||
<< G4BestUnit(fEnergyLeak[1],"Energy") << " +- "
|
||||
<< G4BestUnit(rmsEl1, "Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << " Energy balance : edep + eleak = "
|
||||
<< G4BestUnit(EnergyBalance,"Energy")
|
||||
<< G4endl;
|
||||
|
||||
G4cout << "\n Total track length (charged) in absorber per event = "
|
||||
<< G4BestUnit(fTrakLenCharged,"Length") << " +- "
|
||||
<< G4BestUnit(rmsTLCh, "Length") << G4endl;
|
||||
|
||||
G4cout << " Total track length (neutral) in absorber per event = "
|
||||
<< G4BestUnit(fTrakLenNeutral,"Length") << " +- "
|
||||
<< G4BestUnit(rmsTLNe, "Length") << G4endl;
|
||||
|
||||
G4cout << "\n Number of steps (charged) in absorber per event = "
|
||||
<< fNbStepsCharged << " +- " << rmsStCh << G4endl;
|
||||
|
||||
G4cout << " Number of steps (neutral) in absorber per event = "
|
||||
<< fNbStepsNeutral << " +- " << rmsStNe << G4endl;
|
||||
|
||||
G4cout << "\n Number of secondaries per event : Gammas = " << Gamma
|
||||
<< "; electrons = " << Elect
|
||||
<< "; positrons = " << Posit << G4endl;
|
||||
|
||||
G4cout << "\n Number of events with the primary particle transmitted = "
|
||||
<< transmit[1] << " %" << G4endl;
|
||||
|
||||
G4cout << " Number of events with at least 1 particle transmitted "
|
||||
<< "(same charge as primary) = " << transmit[0] << " %" << G4endl;
|
||||
|
||||
G4cout << "\n Number of events with the primary particle reflected = "
|
||||
<< reflect[1] << " %" << G4endl;
|
||||
|
||||
G4cout << " Number of events with at least 1 particle reflected "
|
||||
<< "(same charge as primary) = " << reflect[0] << " %" << G4endl;
|
||||
|
||||
// compute width of the Gaussian central part of the MultipleScattering
|
||||
//
|
||||
G4cout << "\n MultipleScattering:"
|
||||
<< "\n rms proj angle of transmit primary particle = "
|
||||
<< rmsMsc/mrad << " mrad (central part only)" << G4endl;
|
||||
|
||||
G4cout << " computed theta0 (Highland formula) = "
|
||||
<< ComputeMscHighland()/mrad << " mrad" << G4endl;
|
||||
|
||||
G4cout << " central part defined as +- "
|
||||
<< fMscThetaCentral/mrad << " mrad; "
|
||||
<< " Tail ratio = " << tailMsc << " %" << G4endl;
|
||||
|
||||
G4cout.precision(prec);
|
||||
fRun->PrintSummary();
|
||||
|
||||
// normalize histograms
|
||||
//
|
||||
@@ -302,29 +131,7 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
}
|
||||
|
||||
// show Rndm status
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4double RunAction::ComputeMscHighland()
|
||||
{
|
||||
//compute the width of the Gaussian central part of the MultipleScattering
|
||||
//projected angular distribution.
|
||||
//Eur. Phys. Jour. C15 (2000) page 166, formule 23.9
|
||||
|
||||
G4double t = (fDetector->GetAbsorberThickness())
|
||||
/(fDetector->GetAbsorberMaterial()->GetRadlen());
|
||||
if (t < DBL_MIN) return 0.;
|
||||
|
||||
G4ParticleGun* particle = fPrimary->GetParticleGun();
|
||||
G4double T = particle->GetParticleEnergy();
|
||||
G4double M = particle->GetParticleDefinition()->GetPDGMass();
|
||||
G4double z = std::abs(particle->GetParticleDefinition()->GetPDGCharge()/eplus);
|
||||
|
||||
G4double bpc = T*(T+2*M)/(T+M);
|
||||
G4double teta0 = 13.6*MeV*z*std::sqrt(t)*(1.+0.038*std::log(t))/bpc;
|
||||
return teta0;
|
||||
G4Random::showEngineStatus();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,26 +26,27 @@
|
||||
/// \file electromagnetic/TestEm5/src/StackingAction.cc
|
||||
/// \brief Implementation of the StackingAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: StackingAction.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "StackingAction.hh"
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "Run.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "StackingMessenger.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
StackingAction::StackingAction(RunAction* RA, EventAction* EA)
|
||||
:fRunAction(RA), fEventAction(EA)
|
||||
StackingAction::StackingAction(EventAction* EA)
|
||||
:G4UserStackingAction(), fEventAction(EA),
|
||||
fKillSecondary(0),fStackMessenger(0)
|
||||
{
|
||||
fKillSecondary = 0;
|
||||
fStackMessenger = new StackingMessenger(this);
|
||||
}
|
||||
|
||||
@@ -67,7 +68,10 @@ StackingAction::ClassifyNewTrack(const G4Track* aTrack)
|
||||
if (aTrack->GetParentID() == 0) return fUrgent;
|
||||
|
||||
//count secondary particles
|
||||
fRunAction->CountParticles(aTrack->GetDefinition());
|
||||
|
||||
Run* run = static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->CountParticles(aTrack->GetDefinition());
|
||||
|
||||
//
|
||||
//energy spectrum of secondaries
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/StackingMessenger.cc
|
||||
/// \brief Implementation of the StackingMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: StackingMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -40,7 +40,9 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
StackingMessenger::StackingMessenger(StackingAction* stack)
|
||||
:fStackAction(stack)
|
||||
:G4UImessenger(),fStackAction(stack),
|
||||
fStackDir(0),
|
||||
fKillCmd(0)
|
||||
{
|
||||
fStackDir = new G4UIdirectory("/testem/stack/");
|
||||
fStackDir->SetGuidance("stacking control");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/StepMax.cc
|
||||
/// \brief Implementation of the StepMax class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: StepMax.cc 67268 2013-02-13 11:38:40Z ihrivnac $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -37,7 +37,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
StepMax::StepMax(const G4String& processName)
|
||||
: G4VDiscreteProcess(processName),fMaxChargedStep(DBL_MAX)
|
||||
: G4VDiscreteProcess(processName),fMaxChargedStep(DBL_MAX),fMess(0)
|
||||
{
|
||||
fMess = new StepMaxMessenger(this);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/StepMaxMessenger.cc
|
||||
/// \brief Implementation of the StepMaxMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: StepMaxMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,7 +39,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
|
||||
:fStepMax(stepM)
|
||||
:G4UImessenger(),fStepMax(stepM),fStepMaxCmd(0)
|
||||
{
|
||||
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
|
||||
fStepMaxCmd->SetGuidance("Set max allowed step length");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm5/src/SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: SteppingAction.cc 77083 2013-11-21 10:35:55Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -42,9 +42,9 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction(DetectorConstruction* DET, RunAction* RA,
|
||||
SteppingAction::SteppingAction(DetectorConstruction* DET,
|
||||
EventAction* EA)
|
||||
:fDetector(DET), fRunAction(RA), fEventAction(EA)
|
||||
:G4UserSteppingAction(),fDetector(DET), fEventAction(EA)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -58,7 +58,7 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
if (aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume()
|
||||
!= fDetector->GetAbsorber()) return;
|
||||
|
||||
|
||||
fEventAction->AddEnergy (aStep->GetTotalEnergyDeposit());
|
||||
|
||||
G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
|
||||
|
||||
@@ -23,24 +23,26 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm5/src/SteppingVerbose.cc
|
||||
/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc
|
||||
/// \brief Implementation of the SteppingVerbose class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: SteppingVerbose.cc 71602 2013-06-19 08:14:25Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingVerbose.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingVerbose::SteppingVerbose()
|
||||
{}
|
||||
: G4SteppingVerbose()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -49,10 +51,46 @@ SteppingVerbose::~SteppingVerbose()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::StepInfo()
|
||||
{
|
||||
void SteppingVerbose::TrackingStarted()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
//Step zero
|
||||
//
|
||||
if( verboseLevel > 0 ){
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::StepInfo()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
if( verboseLevel >= 1 ){
|
||||
@@ -89,30 +127,27 @@ void SteppingVerbose::StepInfo()
|
||||
G4cout << " " << std::setw(10) << procName;
|
||||
G4cout << G4endl;
|
||||
|
||||
if( verboseLevel == 2 ){
|
||||
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
|
||||
fN2ndariesAlongStepDoIt +
|
||||
fN2ndariesPostStepDoIt;
|
||||
if(tN2ndariesTot>0){
|
||||
G4cout << "\n :----- List of secondaries ----------------"
|
||||
<< G4endl;
|
||||
if (verboseLevel == 2) {
|
||||
const std::vector<const G4Track*>* secondary
|
||||
= fStep->GetSecondaryInCurrentStep();
|
||||
size_t nbtrk = (*secondary).size();
|
||||
if (nbtrk) {
|
||||
G4cout << "\n :----- List of secondaries ----------------" << G4endl;
|
||||
G4cout.precision(4);
|
||||
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
|
||||
lp1<(*fSecondary).size(); lp1++){
|
||||
for (size_t lp=0; lp<(*secondary).size(); lp++) {
|
||||
G4cout << " "
|
||||
<< std::setw(13)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
|
||||
<< (*secondary)[lp]->GetDefinition()->GetParticleName()
|
||||
<< ": energy ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< G4BestUnit((*secondary)[lp]->GetKineticEnergy(),"Energy")
|
||||
<< " time ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
|
||||
<< G4BestUnit((*secondary)[lp]->GetGlobalTime(),"Time");
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
G4cout << " :------------------------------------------\n"
|
||||
<< G4endl;
|
||||
G4cout << " :------------------------------------------\n" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,37 +156,3 @@ void SteppingVerbose::StepInfo()
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::TrackingStarted()
|
||||
{
|
||||
|
||||
CopyState();
|
||||
G4int prec = G4cout.precision(3);
|
||||
if( verboseLevel > 0 ){
|
||||
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the TrackingAction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: TrackingAction.cc 76464 2013-11-11 10:22:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -35,19 +35,19 @@
|
||||
#include "TrackingAction.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "Run.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction(DetectorConstruction* DET,RunAction* RA,
|
||||
EventAction* EA)
|
||||
:fDetector(DET), fRunAction(RA), fEventAction(EA)
|
||||
TrackingAction::TrackingAction(DetectorConstruction* DET, EventAction* EA)
|
||||
:G4UserTrackingAction(),fDetector(DET), fEventAction(EA)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -68,6 +68,9 @@ void TrackingAction::PreUserTrackingAction(const G4Track* aTrack )
|
||||
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
Run* run = static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
|
||||
G4ThreeVector position = aTrack->GetPosition();
|
||||
G4ThreeVector vertex = aTrack->GetVertexPosition();
|
||||
@@ -110,7 +113,7 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
G4double eleak = aTrack->GetKineticEnergy();
|
||||
if ((aTrack->GetDefinition() == G4Positron::Positron()) && (trackID > 1))
|
||||
eleak += 2*electron_mass_c2;
|
||||
fRunAction->AddEnergyLeak(eleak,index);
|
||||
run->AddEnergyLeak(eleak,index);
|
||||
}
|
||||
|
||||
//space angle distribution at exit : dN/dOmega
|
||||
@@ -170,11 +173,11 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
if (direction.x() != 0.0) {
|
||||
G4double tet = std::atan(direction.y()/std::fabs(direction.x()));
|
||||
analysisManager->FillH1(id,tet);
|
||||
if (transmit && (flag == 2)) fRunAction->AddMscProjTheta(tet);
|
||||
if (transmit && (flag == 2)) run->AddMscProjTheta(tet);
|
||||
|
||||
tet = std::atan(direction.z()/std::fabs(direction.x()));
|
||||
analysisManager->FillH1(id,tet);
|
||||
if (transmit && (flag == 2)) fRunAction->AddMscProjTheta(tet);
|
||||
if (transmit && (flag == 2)) run->AddMscProjTheta(tet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user