Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ActionInitialization.cc 66241 2012-12-13 18:34:42Z gunter $
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "SteppingVerbose.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization(DetectorConstruction* det)
|
||||
: fDetector(det)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
|
||||
PrimaryGeneratorAction* kin = new PrimaryGeneratorAction(fDetector);
|
||||
SetUserAction(kin);
|
||||
|
||||
SetUserAction(new RunAction(fDetector, kin));
|
||||
SetUserAction(new EventAction());
|
||||
SetUserAction(new TrackingAction());
|
||||
SetUserAction(new SteppingAction(fDetector));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
SetUserAction(
|
||||
new RunAction(fDetector, new PrimaryGeneratorAction(fDetector)));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VSteppingVerbose* ActionInitialization::InitializeSteppingVerbose() const
|
||||
{
|
||||
return (new SteppingVerbose());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: DetectorConstruction.cc 77305 2013-11-22 11:16:19Z gcosmo $
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -45,8 +45,7 @@
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
@@ -54,14 +53,17 @@
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4AutoDelete.hh"
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
:fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
|
||||
:G4VUserDetectorConstruction(),
|
||||
fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
|
||||
fDLlength(0.),fDRlength(0.),
|
||||
fMaterial(0),fMagField(0),
|
||||
fMaterial(0),
|
||||
fEcalLength(0.),fEcalRadius(0.),
|
||||
fSolidEcal(0),fLogicEcal(0),fPhysiEcal(0)
|
||||
fSolidEcal(0),fLogicEcal(0),fPhysiEcal(0),
|
||||
fDetectorMessenger(0)
|
||||
{
|
||||
DefineMaterials();
|
||||
SetMaterial("G4_PbWO4");
|
||||
@@ -112,7 +114,7 @@ void DetectorConstruction::DefineMaterials()
|
||||
new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
|
||||
new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
|
||||
new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
|
||||
new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
|
||||
new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
|
||||
new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
|
||||
new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
|
||||
|
||||
@@ -122,8 +124,6 @@ void DetectorConstruction::DefineMaterials()
|
||||
BGO->AddElement(O , natoms=12);
|
||||
BGO->AddElement(Ge, natoms= 3);
|
||||
BGO->AddElement(Bi, natoms= 4);
|
||||
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -149,10 +149,10 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
|
||||
fPhysiEcal = new G4PVPlacement(0,G4ThreeVector(),
|
||||
fLogicEcal,"Ecal",0,false,0);
|
||||
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
G4cout << "Absorber is " << G4BestUnit(fEcalLength,"Length")
|
||||
<< " of " << fMaterial->GetName() << G4endl;
|
||||
G4cout << fMaterial << G4endl;
|
||||
|
||||
//
|
||||
//always return the physical World
|
||||
//
|
||||
@@ -167,9 +167,9 @@ void DetectorConstruction::SetMaterial(const G4String& materialChoice)
|
||||
G4Material* pttoMaterial =
|
||||
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
|
||||
|
||||
if (pttoMaterial) {
|
||||
if(pttoMaterial && fMaterial != pttoMaterial) {
|
||||
fMaterial = pttoMaterial;
|
||||
if(fLogicEcal) fLogicEcal->SetMaterial(fMaterial);
|
||||
if(fLogicEcal) { fLogicEcal->SetMaterial(fMaterial); }
|
||||
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,7 @@ void DetectorConstruction::SetLBining(G4ThreeVector Value)
|
||||
fNLtot = MaxBin;
|
||||
}
|
||||
fDLradl = Value(1);
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -198,33 +199,24 @@ void DetectorConstruction::SetRBining(G4ThreeVector Value)
|
||||
fNRtot = MaxBin;
|
||||
}
|
||||
fDRradl = Value(1);
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
G4FieldManager* fieldMgr
|
||||
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
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 );
|
||||
|
||||
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 = 0;
|
||||
fieldMgr->SetDetectorField(fMagField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: DetectorMessenger.cc 77897 2013-11-29 09:23:56Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -43,7 +43,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
:fDetector(Det)
|
||||
:G4UImessenger(),fDetector(Det)
|
||||
{
|
||||
fTestemDir = new G4UIdirectory("/testem/");
|
||||
fTestemDir->SetGuidance(" detector control.");
|
||||
@@ -55,6 +55,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fMaterCmd->SetGuidance("Select Material.");
|
||||
fMaterCmd->SetParameterName("material",false);
|
||||
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fMaterCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fLBinCmd = new G4UIcmdWith3Vector("/testem/det/setLbin",this);
|
||||
fLBinCmd->SetGuidance("set longitudinal bining");
|
||||
@@ -62,6 +63,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fLBinCmd->SetParameterName("nLtot","dLradl"," ",true);
|
||||
fLBinCmd->SetRange("nLtot>=1 && dLradl>0");
|
||||
fLBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fLBinCmd->SetToBeBroadcasted(false);
|
||||
|
||||
fRBinCmd = new G4UIcmdWith3Vector("/testem/det/setRbin",this);
|
||||
fRBinCmd->SetGuidance("set radial bining");
|
||||
@@ -69,19 +71,8 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
fRBinCmd->SetParameterName("nRtot","dRradl"," ",true);
|
||||
fRBinCmd->SetRange("nRtot>=1 && dRradl>0");
|
||||
fRBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
|
||||
fFieldCmd->SetGuidance("Define magnetic field.");
|
||||
fFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
|
||||
fFieldCmd->SetParameterName("Bz",false);
|
||||
fFieldCmd->SetUnitCategory("Magnetic flux density");
|
||||
fFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
|
||||
fUpdateCmd->SetGuidance("Update geometry.");
|
||||
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
fUpdateCmd->AvailableForStates(G4State_Idle);
|
||||
fRBinCmd->SetToBeBroadcasted(false);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -91,8 +82,6 @@ DetectorMessenger::~DetectorMessenger()
|
||||
delete fMaterCmd;
|
||||
delete fLBinCmd;
|
||||
delete fRBinCmd;
|
||||
delete fFieldCmd;
|
||||
delete fUpdateCmd;
|
||||
delete fDetDir;
|
||||
delete fTestemDir;
|
||||
}
|
||||
@@ -110,11 +99,6 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
if( command == fRBinCmd )
|
||||
{ fDetector->SetRBining(fRBinCmd->GetNew3VectorValue(newValue));}
|
||||
|
||||
if( command == fFieldCmd )
|
||||
{ fDetector->SetMagField(fFieldCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == fUpdateCmd )
|
||||
{ fDetector->UpdateGeometry();}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/EmAcceptance.cc
|
||||
/// \brief Implementation of the Emeptance class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: EmAcceptance.cc 74994 2013-10-25 10:47:45Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -36,6 +36,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EmAcceptance::EmAcceptance()
|
||||
: fIsAccepted(false)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -65,8 +66,8 @@ void EmAcceptance::EndOfAcceptance()
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EmAcceptance::EmAcceptanceGauss(const G4String& title, G4int stat,
|
||||
G4double avr, G4double avr0,
|
||||
G4double rms, G4double limit)
|
||||
G4double avr, G4double avr0,
|
||||
G4double rms, G4double limit)
|
||||
{
|
||||
G4double x = std::sqrt((G4double)stat);
|
||||
G4double dde = avr - avr0;
|
||||
@@ -74,7 +75,7 @@ void EmAcceptance::EmAcceptanceGauss(const G4String& title, G4int stat,
|
||||
if(std::fabs(de) > limit) fIsAccepted = false;
|
||||
|
||||
G4cout << title << ": " << avr << " del" << title << "= " << dde
|
||||
<< " nrms= " << de << G4endl;
|
||||
<< " nrms= " << de << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/EventAction.cc
|
||||
/// \brief Implementation of the EventAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: EventAction.cc 76259 2013-11-08 11:37:28Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -34,14 +34,16 @@
|
||||
#include "EventAction.hh"
|
||||
|
||||
#include "EventActionMessenger.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "Run.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventAction::EventAction(RunAction* run)
|
||||
:fRun(run),fDrawFlag("none"),fPrintModulo(10000)
|
||||
EventAction::EventAction()
|
||||
:G4UserEventAction(),
|
||||
fPrintModulo(10000),fEventMessenger(0)
|
||||
{
|
||||
fEventMessenger = new EventActionMessenger(this);
|
||||
}
|
||||
@@ -64,14 +66,20 @@ void EventAction::BeginOfEventAction(const G4Event* evt)
|
||||
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
|
||||
|
||||
//additional initializations
|
||||
fRun->InitializePerEvent();
|
||||
Run* run
|
||||
= static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->InitializePerEvent();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventAction::EndOfEventAction(const G4Event*)
|
||||
{
|
||||
fRun->FillPerEvent();
|
||||
Run* run
|
||||
= static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->FillPerEvent();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the EventActionMessenger class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: EventActionMessenger.cc 76259 2013-11-08 11:37:28Z gcosmo $
|
||||
//
|
||||
//
|
||||
|
||||
@@ -44,19 +44,13 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
|
||||
:fEventAction(EvAct)
|
||||
:G4UImessenger(),fEventAction(EvAct),
|
||||
fEventDir(0),
|
||||
fPrintCmd(0)
|
||||
{
|
||||
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, all");
|
||||
fDrawCmd->SetParameterName("choice",true);
|
||||
fDrawCmd->SetDefaultValue("all");
|
||||
fDrawCmd->SetCandidates("none charged all");
|
||||
fDrawCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
|
||||
fPrintCmd->SetGuidance("Print events modulo n");
|
||||
fPrintCmd->SetParameterName("EventNb",false);
|
||||
@@ -68,7 +62,6 @@ EventActionMessenger::EventActionMessenger(EventAction* EvAct)
|
||||
|
||||
EventActionMessenger::~EventActionMessenger()
|
||||
{
|
||||
delete fDrawCmd;
|
||||
delete fPrintCmd;
|
||||
delete fEventDir;
|
||||
}
|
||||
@@ -78,9 +71,6 @@ EventActionMessenger::~EventActionMessenger()
|
||||
void EventActionMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
if(command == fDrawCmd)
|
||||
{fEventAction->SetDrawFlag(newValue);}
|
||||
|
||||
if(command == fPrintCmd)
|
||||
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
|
||||
|
||||
|
||||
@@ -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/TestEm2/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
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysListEmStandard.cc 68528 2013-04-01 21:22:23Z adotti $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -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);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/PhysicsList.cc
|
||||
/// \brief Implementation of the PhysicsList class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysicsList.cc 75118 2013-10-28 09:40:24Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "G4EmLivermorePhysics.hh"
|
||||
#include "G4EmPenelopePhysics.hh"
|
||||
|
||||
#include "G4Decay.hh"
|
||||
#include "G4DecayPhysics.hh"
|
||||
#include "StepMax.hh"
|
||||
|
||||
#include "G4LossTableManager.hh"
|
||||
@@ -53,70 +53,23 @@
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
// Bosons
|
||||
#include "G4ChargedGeantino.hh"
|
||||
#include "G4Geantino.hh"
|
||||
#include "G4Gamma.hh"
|
||||
|
||||
// leptons
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4MuonPlus.hh"
|
||||
#include "G4MuonMinus.hh"
|
||||
#include "G4NeutrinoMu.hh"
|
||||
#include "G4AntiNeutrinoMu.hh"
|
||||
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4NeutrinoE.hh"
|
||||
#include "G4AntiNeutrinoE.hh"
|
||||
|
||||
// Mesons
|
||||
#include "G4PionPlus.hh"
|
||||
#include "G4PionMinus.hh"
|
||||
#include "G4PionZero.hh"
|
||||
#include "G4Eta.hh"
|
||||
#include "G4EtaPrime.hh"
|
||||
|
||||
#include "G4KaonPlus.hh"
|
||||
#include "G4KaonMinus.hh"
|
||||
#include "G4KaonZero.hh"
|
||||
#include "G4AntiKaonZero.hh"
|
||||
#include "G4KaonZeroLong.hh"
|
||||
#include "G4KaonZeroShort.hh"
|
||||
|
||||
// Baryons
|
||||
#include "G4Proton.hh"
|
||||
#include "G4AntiProton.hh"
|
||||
#include "G4Neutron.hh"
|
||||
#include "G4AntiNeutron.hh"
|
||||
|
||||
// Nuclei
|
||||
#include "G4Alpha.hh"
|
||||
#include "G4Deuteron.hh"
|
||||
#include "G4Triton.hh"
|
||||
#include "G4He3.hh"
|
||||
#include "G4GenericIon.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::PhysicsList() : G4VModularPhysicsList()
|
||||
PhysicsList::PhysicsList()
|
||||
: G4VModularPhysicsList(),fEmPhysicsList(0),fMessenger(0)
|
||||
{
|
||||
G4LossTableManager::Instance();
|
||||
defaultCutValue = 1.*mm;
|
||||
fCutForGamma = defaultCutValue;
|
||||
fCutForElectron = defaultCutValue;
|
||||
fCutForPositron = defaultCutValue;
|
||||
SetDefaultCutValue(1*mm);
|
||||
|
||||
fMessenger = new PhysicsListMessenger(this);
|
||||
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// EM physics
|
||||
///fEmName = "emstandard_opt0";
|
||||
///fEmPhysicsList = new G4EmStandardPhysics();
|
||||
fEmName = "local";
|
||||
fEmPhysicsList = new PhysListEmStandard(fEmName);
|
||||
fEmName = "emstandard_opt0";
|
||||
fEmPhysicsList = new G4EmStandardPhysics();
|
||||
fDecay = new G4DecayPhysics();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -125,61 +78,24 @@ PhysicsList::~PhysicsList()
|
||||
{
|
||||
delete fMessenger;
|
||||
delete fEmPhysicsList;
|
||||
delete fDecay;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructParticle()
|
||||
{
|
||||
// pseudo-particles
|
||||
G4Geantino::GeantinoDefinition();
|
||||
G4ChargedGeantino::ChargedGeantinoDefinition();
|
||||
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
|
||||
// leptons
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
|
||||
G4NeutrinoE::NeutrinoEDefinition();
|
||||
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
|
||||
G4NeutrinoMu::NeutrinoMuDefinition();
|
||||
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
|
||||
|
||||
// mesons
|
||||
G4PionPlus::PionPlusDefinition();
|
||||
G4PionMinus::PionMinusDefinition();
|
||||
G4PionZero::PionZeroDefinition();
|
||||
G4Eta::EtaDefinition();
|
||||
G4EtaPrime::EtaPrimeDefinition();
|
||||
G4KaonPlus::KaonPlusDefinition();
|
||||
G4KaonMinus::KaonMinusDefinition();
|
||||
G4KaonZero::KaonZeroDefinition();
|
||||
G4AntiKaonZero::AntiKaonZeroDefinition();
|
||||
G4KaonZeroLong::KaonZeroLongDefinition();
|
||||
G4KaonZeroShort::KaonZeroShortDefinition();
|
||||
|
||||
// barions
|
||||
G4Proton::ProtonDefinition();
|
||||
G4AntiProton::AntiProtonDefinition();
|
||||
G4Neutron::NeutronDefinition();
|
||||
G4AntiNeutron::AntiNeutronDefinition();
|
||||
|
||||
// ions
|
||||
G4Deuteron::DeuteronDefinition();
|
||||
G4Triton::TritonDefinition();
|
||||
G4He3::He3Definition();
|
||||
G4Alpha::AlphaDefinition();
|
||||
G4GenericIon::GenericIonDefinition();
|
||||
fEmPhysicsList->ConstructParticle();
|
||||
fDecay->ConstructParticle();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructProcess()
|
||||
{
|
||||
if (verboseLevel>-1) {
|
||||
G4cout << "PhysicsList::ConstructProcess start" << G4endl;
|
||||
}
|
||||
// transportation
|
||||
//
|
||||
AddTransportation();
|
||||
@@ -190,7 +106,7 @@ void PhysicsList::ConstructProcess()
|
||||
|
||||
// decay process
|
||||
//
|
||||
AddDecay();
|
||||
fDecay->ConstructProcess();
|
||||
|
||||
// step limitation (as a full process)
|
||||
//
|
||||
@@ -201,7 +117,7 @@ void PhysicsList::ConstructProcess()
|
||||
|
||||
void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
{
|
||||
if (verboseLevel>-1) {
|
||||
if (verboseLevel>0) {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
|
||||
}
|
||||
|
||||
@@ -263,31 +179,6 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::AddDecay()
|
||||
{
|
||||
// decay process
|
||||
//
|
||||
G4Decay* fDecayProcess = new G4Decay();
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
|
||||
if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived()) {
|
||||
|
||||
pmanager ->AddProcess(fDecayProcess);
|
||||
|
||||
// set ordering for PostStepDoIt and AtRestDoIt
|
||||
pmanager ->SetProcessOrdering(fDecayProcess, idxPostStep);
|
||||
pmanager ->SetProcessOrdering(fDecayProcess, idxAtRest);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::AddStepMax()
|
||||
{
|
||||
// Step limitation seen as a process
|
||||
@@ -309,43 +200,15 @@ void PhysicsList::AddStepMax()
|
||||
|
||||
void PhysicsList::SetCuts()
|
||||
{
|
||||
if (verboseLevel >0) {
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
#ifdef G4MULTITHREADED
|
||||
if(G4Threading::IsWorkerThread()) {
|
||||
if(verboseLevel>1) { DumpCutValuesTable(); }
|
||||
} else {
|
||||
if(verboseLevel>0) { DumpCutValuesTable(); }
|
||||
}
|
||||
|
||||
// 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");
|
||||
SetCutValue(fCutForElectron, "e-");
|
||||
SetCutValue(fCutForPositron, "e+");
|
||||
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
#else
|
||||
if(verboseLevel>0) { DumpCutValuesTable(); }
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForGamma(G4double cut)
|
||||
{
|
||||
fCutForGamma = cut;
|
||||
SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForElectron(G4double cut)
|
||||
{
|
||||
fCutForElectron = cut;
|
||||
SetParticleCuts(fCutForElectron, G4Electron::Electron());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForPositron(G4double cut)
|
||||
{
|
||||
fCutForPositron = cut;
|
||||
SetParticleCuts(fCutForPositron, G4Positron::Positron());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/PhysicsListMessenger.cc
|
||||
/// \brief Implementation of the PhysicsListMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysicsListMessenger.cc 75118 2013-10-28 09:40:24Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -41,39 +41,11 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
:fPhysicsList(pPhys)
|
||||
:G4UImessenger(),fPhysicsList(pPhys)
|
||||
{
|
||||
fPhysDir = new G4UIdirectory("/testem/phys/");
|
||||
fPhysDir->SetGuidance("physics list commands");
|
||||
|
||||
fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
|
||||
fGammaCutCmd->SetGuidance("Set gamma cut.");
|
||||
fGammaCutCmd->SetParameterName("Gcut",false);
|
||||
fGammaCutCmd->SetUnitCategory("Length");
|
||||
fGammaCutCmd->SetRange("Gcut>0.0");
|
||||
fGammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
|
||||
fElectCutCmd->SetGuidance("Set electron cut.");
|
||||
fElectCutCmd->SetParameterName("Ecut",false);
|
||||
fElectCutCmd->SetUnitCategory("Length");
|
||||
fElectCutCmd->SetRange("Ecut>0.0");
|
||||
fElectCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
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);
|
||||
|
||||
fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
|
||||
fAllCutCmd->SetGuidance("Set cut for all.");
|
||||
fAllCutCmd->SetParameterName("cut",false);
|
||||
fAllCutCmd->SetUnitCategory("Length");
|
||||
fAllCutCmd->SetRange("cut>0.0");
|
||||
fAllCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
|
||||
fListCmd->SetGuidance("Add modula physics list.");
|
||||
fListCmd->SetParameterName("PList",false);
|
||||
@@ -84,36 +56,14 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
|
||||
PhysicsListMessenger::~PhysicsListMessenger()
|
||||
{
|
||||
delete fGammaCutCmd;
|
||||
delete fElectCutCmd;
|
||||
delete fProtoCutCmd;
|
||||
delete fAllCutCmd;
|
||||
delete fListCmd;
|
||||
delete fPhysDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
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 == fProtoCutCmd )
|
||||
{ fPhysicsList->SetCutForPositron(fProtoCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == fAllCutCmd )
|
||||
{
|
||||
G4double cut = fAllCutCmd->GetNewDoubleValue(newValue);
|
||||
fPhysicsList->SetCutForGamma(cut);
|
||||
fPhysicsList->SetCutForElectron(cut);
|
||||
fPhysicsList->SetCutForPositron(cut);
|
||||
}
|
||||
|
||||
if( command == fListCmd )
|
||||
{ fPhysicsList->AddPhysicsList(newValue);}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction.cc 75597 2013-11-04 12:41:21Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -42,16 +42,17 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction (DetectorConstruction* det)
|
||||
:fDetector(det)
|
||||
:G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),fDetector(det),fInitPos(true)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
G4ParticleDefinition* particle
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
fParticleGun->SetParticleEnergy(5.*GeV);
|
||||
fParticleGun->SetParticlePosition(fInitPos = G4ThreeVector(-1*cm,-1*cm,-1*cm));
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-1*cm));
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
}
|
||||
|
||||
@@ -68,7 +69,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begin of event
|
||||
//
|
||||
if (fParticleGun->GetParticlePosition() == fInitPos) {
|
||||
if (fInitPos) {
|
||||
fInitPos = false;
|
||||
G4double position = -0.5*(fDetector->GetfullLength());
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,position));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,376 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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/TestEm2/src/Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
// $Id: Run.cc 75577 2013-11-04 12:03:26Z vnivanch $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunActionMessenger.hh"
|
||||
#include "EmAcceptance.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include <iomanip>
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run(DetectorConstruction* det, PrimaryGeneratorAction* kin)
|
||||
:G4Run(),fDet(det),fKin(kin),
|
||||
f_nLbin(MaxBin),f_nRbin(MaxBin)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Reset()
|
||||
{
|
||||
f_nLbin = fDet->GetnLtot();
|
||||
f_dEdL.resize(f_nLbin);
|
||||
fSumELongit.resize(f_nLbin);
|
||||
fSumELongitCumul.resize(f_nLbin);
|
||||
fSumE2Longit.resize(f_nLbin);
|
||||
fSumE2LongitCumul.resize(f_nLbin);
|
||||
|
||||
f_nRbin = fDet->GetnRtot();
|
||||
f_dEdR.resize(f_nRbin);
|
||||
fSumERadial.resize(f_nRbin);
|
||||
fSumERadialCumul.resize(f_nRbin);
|
||||
fSumE2Radial.resize(f_nRbin);
|
||||
fSumE2RadialCumul.resize(f_nRbin);
|
||||
|
||||
fChargedStep = 0.0;
|
||||
fNeutralStep = 0.0;
|
||||
|
||||
fVerbose = 0;
|
||||
|
||||
//initialize arrays of cumulative energy deposition
|
||||
//
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
fSumELongit[i]=fSumE2Longit[i]=fSumELongitCumul[i]=fSumE2LongitCumul[i]=0.;
|
||||
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
fSumERadial[j]=fSumE2Radial[j]=fSumERadialCumul[j]=fSumE2RadialCumul[j]=0.;
|
||||
|
||||
//initialize track length
|
||||
fSumChargTrLength=fSum2ChargTrLength=fSumNeutrTrLength=fSum2NeutrTrLength=0.;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::InitializePerEvent()
|
||||
{
|
||||
//initialize arrays of energy deposit per bin
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
{ f_dEdL[i] = 0.; }
|
||||
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
{ f_dEdR[j] = 0.; }
|
||||
|
||||
//initialize tracklength
|
||||
fChargTrLength = fNeutrTrLength = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::FillPerEvent()
|
||||
{
|
||||
//accumulate statistic
|
||||
//
|
||||
G4double dLCumul = 0.;
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
{
|
||||
fSumELongit[i] += f_dEdL[i];
|
||||
fSumE2Longit[i] += f_dEdL[i]*f_dEdL[i];
|
||||
dLCumul += f_dEdL[i];
|
||||
fSumELongitCumul[i] += dLCumul;
|
||||
fSumE2LongitCumul[i] += dLCumul*dLCumul;
|
||||
}
|
||||
|
||||
G4double dRCumul = 0.;
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
{
|
||||
fSumERadial[j] += f_dEdR[j];
|
||||
fSumE2Radial[j] += f_dEdR[j]*f_dEdR[j];
|
||||
dRCumul += f_dEdR[j];
|
||||
fSumERadialCumul[j] += dRCumul;
|
||||
fSumE2RadialCumul[j] += dRCumul*dRCumul;
|
||||
}
|
||||
|
||||
fSumChargTrLength += fChargTrLength;
|
||||
fSum2ChargTrLength += fChargTrLength*fChargTrLength;
|
||||
fSumNeutrTrLength += fNeutrTrLength;
|
||||
fSum2NeutrTrLength += fNeutrTrLength*fNeutrTrLength;
|
||||
|
||||
//fill histograms
|
||||
//
|
||||
|
||||
G4double Ekin=fKin->GetParticleGun()->GetParticleEnergy();
|
||||
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
|
||||
G4double radl=fDet->GetMaterial()->GetRadlen();
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillH1(1, 100.*dLCumul/(Ekin+mass));
|
||||
analysisManager->FillH1(2, fChargTrLength/radl);
|
||||
analysisManager->FillH1(3, fNeutrTrLength/radl);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge(const G4Run* run)
|
||||
{
|
||||
const Run* localRun = static_cast<const Run*>(run);
|
||||
|
||||
fChargedStep += localRun->fChargedStep;
|
||||
fNeutralStep += localRun->fNeutralStep;
|
||||
|
||||
for (G4int i=0; i<f_nLbin; i++) {
|
||||
fSumELongit[i] += localRun->fSumELongit[i];
|
||||
fSumE2Longit[i] += localRun->fSumE2Longit[i];
|
||||
fSumELongitCumul[i] += localRun->fSumELongitCumul[i];
|
||||
fSumE2LongitCumul[i] += localRun->fSumE2LongitCumul[i];
|
||||
}
|
||||
|
||||
for (G4int j=0; j<f_nRbin; j++) {
|
||||
fSumERadial[j] += localRun->fSumERadial[j];
|
||||
fSumE2Radial[j] += localRun->fSumE2Radial[j];
|
||||
fSumERadialCumul[j] += localRun->fSumERadialCumul[j];
|
||||
fSumE2RadialCumul[j] += localRun->fSumE2RadialCumul[j];
|
||||
}
|
||||
|
||||
fSumChargTrLength += localRun->fSumChargTrLength;
|
||||
fSum2ChargTrLength += localRun->fSum2ChargTrLength;
|
||||
fSumNeutrTrLength += localRun->fSumNeutrTrLength;
|
||||
fSum2NeutrTrLength += localRun->fSum2NeutrTrLength;
|
||||
|
||||
G4Run::Merge(run);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::ComputeStatistics(G4double edep, G4double rms, G4double& limit)
|
||||
{
|
||||
G4int NbOfEvents = GetNumberOfEvent();
|
||||
|
||||
G4double kinEnergy = fKin->GetParticleGun()->GetParticleEnergy();
|
||||
assert(NbOfEvents*kinEnergy > 0);
|
||||
|
||||
fChargedStep /= G4double(NbOfEvents);
|
||||
fNeutralStep /= G4double(NbOfEvents);
|
||||
|
||||
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
|
||||
G4double norme = 100./(NbOfEvents*(kinEnergy+mass));
|
||||
|
||||
//longitudinal
|
||||
//
|
||||
G4double dLradl = fDet->GetdLradl();
|
||||
|
||||
MyVector MeanELongit(f_nLbin), rmsELongit(f_nLbin);
|
||||
MyVector MeanELongitCumul(f_nLbin), rmsELongitCumul(f_nLbin);
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
G4int i;
|
||||
for (i=0; i<f_nLbin; i++) {
|
||||
MeanELongit[i] = norme*fSumELongit[i];
|
||||
rmsELongit[i] =
|
||||
norme*std::sqrt(std::abs(NbOfEvents*fSumE2Longit[i]
|
||||
- fSumELongit[i]*fSumELongit[i]));
|
||||
|
||||
MeanELongitCumul[i] = norme*fSumELongitCumul[i];
|
||||
rmsELongitCumul[i] = norme*std::sqrt(std::abs(NbOfEvents*
|
||||
fSumE2LongitCumul[i] - fSumELongitCumul[i]*fSumELongitCumul[i]));
|
||||
G4double bin = (i+0.5)*dLradl;
|
||||
analysisManager->FillH1(4, bin,MeanELongit[i]/dLradl);
|
||||
analysisManager->FillH1(5, bin, rmsELongit[i]/dLradl);
|
||||
bin = (i+1)*dLradl;
|
||||
analysisManager->FillH1(6, bin,MeanELongitCumul[i]);
|
||||
analysisManager->FillH1(7, bin, rmsELongitCumul[i]);
|
||||
}
|
||||
|
||||
//radial
|
||||
//
|
||||
G4double dRradl = fDet->GetdRradl();
|
||||
|
||||
MyVector MeanERadial(f_nRbin), rmsERadial(f_nRbin);
|
||||
MyVector MeanERadialCumul(f_nRbin), rmsERadialCumul(f_nRbin);
|
||||
|
||||
for (i=0; i<f_nRbin; i++) {
|
||||
MeanERadial[i] = norme*fSumERadial[i];
|
||||
rmsERadial[i] = norme*std::sqrt(std::abs(NbOfEvents*fSumE2Radial[i]
|
||||
- fSumERadial[i]*fSumERadial[i]));
|
||||
|
||||
MeanERadialCumul[i] = norme*fSumERadialCumul[i];
|
||||
rmsERadialCumul[i] =
|
||||
norme*std::sqrt(std::abs(NbOfEvents*fSumE2RadialCumul[i]
|
||||
- fSumERadialCumul[i]*fSumERadialCumul[i]));
|
||||
|
||||
G4double bin = (i+0.5)*dRradl;
|
||||
analysisManager->FillH1(8, bin,MeanERadial[i]/dRradl);
|
||||
analysisManager->FillH1(9, bin, rmsERadial[i]/dRradl);
|
||||
bin = (i+1)*dRradl;
|
||||
analysisManager->FillH1(10, bin,MeanERadialCumul[i]);
|
||||
analysisManager->FillH1(11, bin, rmsERadialCumul[i]);
|
||||
}
|
||||
|
||||
//find Moliere confinement
|
||||
//
|
||||
const G4double EMoliere = 90.;
|
||||
G4double iMoliere = 0.;
|
||||
if ((MeanERadialCumul[0] <= EMoliere) &&
|
||||
(MeanERadialCumul[f_nRbin-1] >= EMoliere)) {
|
||||
G4int imin = 0;
|
||||
while( (imin < f_nRbin-1) && (MeanERadialCumul[imin] < EMoliere) )
|
||||
{ ++imin; }
|
||||
G4double ratio = (EMoliere - MeanERadialCumul[imin]) /
|
||||
(MeanERadialCumul[imin+1] - MeanERadialCumul[imin]);
|
||||
iMoliere = 1. + imin + ratio;
|
||||
}
|
||||
|
||||
//track length
|
||||
//
|
||||
norme = 1./(NbOfEvents*(fDet->GetMaterial()->GetRadlen()));
|
||||
G4double MeanChargTrLength = norme*fSumChargTrLength;
|
||||
G4double rmsChargTrLength =
|
||||
norme*std::sqrt(std::fabs(NbOfEvents*fSum2ChargTrLength
|
||||
- fSumChargTrLength*fSumChargTrLength));
|
||||
|
||||
G4double MeanNeutrTrLength = norme*fSumNeutrTrLength;
|
||||
G4double rmsNeutrTrLength =
|
||||
norme*std::sqrt(std::fabs(NbOfEvents*fSum2NeutrTrLength
|
||||
- fSumNeutrTrLength*fSumNeutrTrLength));
|
||||
|
||||
//print
|
||||
std::ios::fmtflags mode = G4cout.flags();
|
||||
G4cout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
G4int prec = G4cout.precision(2);
|
||||
|
||||
if (fVerbose) {
|
||||
|
||||
G4cout << " LOGITUDINAL PROFILE "
|
||||
<< " CUMULATIVE LOGITUDINAL PROFILE" << G4endl << G4endl;
|
||||
|
||||
G4cout << " bin " << " Mean rms "
|
||||
<< " bin " << " Mean rms \n" << G4endl;
|
||||
|
||||
for (i=0; i<f_nLbin; i++) {
|
||||
G4double inf=i*dLradl, sup=inf+dLradl;
|
||||
|
||||
G4cout << std::setw(8) << inf << "->"
|
||||
<< std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanELongit[i] << "% "
|
||||
<< std::setw(9) << rmsELongit[i] << "% "
|
||||
<< " 0->" << std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanELongitCumul[i] << "% "
|
||||
<< std::setw(7) << rmsELongitCumul[i] << "% "
|
||||
<<G4endl;
|
||||
}
|
||||
|
||||
G4cout << G4endl << G4endl << G4endl;
|
||||
|
||||
G4cout << " RADIAL PROFILE "
|
||||
<< " CUMULATIVE RADIAL PROFILE" << G4endl << G4endl;
|
||||
|
||||
G4cout << " bin " << " Mean rms "
|
||||
<< " bin " << " Mean rms \n" << G4endl;
|
||||
|
||||
for (i=0; i<f_nRbin; i++) {
|
||||
G4double inf=i*dRradl, sup=inf+dRradl;
|
||||
|
||||
G4cout << std::setw(8) << inf << "->"
|
||||
<< std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanERadial[i] << "% "
|
||||
<< std::setw(9) << rmsERadial[i] << "% "
|
||||
<< " 0->" << std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanERadialCumul[i] << "% "
|
||||
<< std::setw(7) << rmsERadialCumul[i] << "% "
|
||||
<<G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4cout << "\n ===== SUMMARY ===== \n" << G4endl;
|
||||
|
||||
G4cout << " Total number pf events: " << NbOfEvents << "\n"
|
||||
<< " Mean number of charged steps: " << fChargedStep << G4endl;
|
||||
G4cout << " Mean number of neutral steps: " << fNeutralStep
|
||||
<< "\n" << G4endl;
|
||||
|
||||
G4cout << " energy deposit : "
|
||||
<< std::setw(7) << MeanELongitCumul[f_nLbin-1] << " % E0 +- "
|
||||
<< std::setw(7) << rmsELongitCumul[f_nLbin-1] << " % E0" << G4endl;
|
||||
G4cout << " charged traklen: "
|
||||
<< std::setw(7) << MeanChargTrLength << " radl +- "
|
||||
<< std::setw(7) << rmsChargTrLength << " radl" << G4endl;
|
||||
G4cout << " neutral traklen: "
|
||||
<< std::setw(7) << MeanNeutrTrLength << " radl +- "
|
||||
<< std::setw(7) << rmsNeutrTrLength << " radl" << G4endl;
|
||||
|
||||
if (iMoliere > 0. ) {
|
||||
G4double RMoliere1 = iMoliere*fDet->GetdRradl();
|
||||
G4double RMoliere2 = iMoliere*fDet->GetdRlength();
|
||||
G4cout << "\n " << EMoliere << " % confinement: radius = "
|
||||
<< RMoliere1 << " radl ("
|
||||
<< G4BestUnit( RMoliere2, "Length") << ")" << "\n" << G4endl;
|
||||
}
|
||||
|
||||
G4cout.setf(mode,std::ios::floatfield);
|
||||
G4cout.precision(prec);
|
||||
|
||||
// Acceptance
|
||||
|
||||
G4int nLbin = fDet->GetnLtot();
|
||||
if (limit < DBL_MAX) {
|
||||
EmAcceptance acc;
|
||||
acc.BeginOfAcceptance("Total Energy in Absorber",NbOfEvents);
|
||||
G4double e = MeanELongitCumul[nLbin-1]/100.;
|
||||
G4double r = rmsELongitCumul[nLbin-1]/100.;
|
||||
acc.EmAcceptanceGauss("Edep",NbOfEvents,e,edep,rms,limit);
|
||||
acc.EmAcceptanceGauss("Erms",NbOfEvents,r,rms,rms,2.0*limit);
|
||||
acc.EndOfAcceptance();
|
||||
}
|
||||
limit = DBL_MAX;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: RunAction.cc 76259 2013-11-08 11:37:28Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -36,11 +36,13 @@
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunActionMessenger.hh"
|
||||
#include "Run.hh"
|
||||
#include "EmAcceptance.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include <iomanip>
|
||||
@@ -50,32 +52,11 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
|
||||
:fDet(det),fKin(kin)
|
||||
:G4UserRunAction(),
|
||||
fDet(det),fKin(kin),fRunMessenger(0), fAnalysisManager(0),fRun(0),
|
||||
fVerbose(0), fEdeptrue(1.), fRmstrue(1.), fLimittrue(DBL_MAX)
|
||||
{
|
||||
fRunMessenger = new RunActionMessenger(this);
|
||||
|
||||
f_nLbin = f_nRbin = MaxBin;
|
||||
|
||||
f_dEdL.resize(f_nLbin, 0.0);
|
||||
fSumELongit.resize(f_nLbin, 0.0);
|
||||
fSumELongitCumul.resize(f_nLbin, 0.0);
|
||||
fSumE2Longit.resize(f_nLbin, 0.0);
|
||||
fSumE2LongitCumul.resize(f_nLbin, 0.0);
|
||||
|
||||
f_dEdR.resize(f_nRbin, 0.0);
|
||||
fSumERadial.resize(f_nRbin, 0.0);
|
||||
fSumERadialCumul.resize(f_nRbin, 0.0);
|
||||
fSumE2Radial.resize(f_nRbin, 0.0);
|
||||
fSumE2RadialCumul.resize(f_nRbin, 0.0);
|
||||
|
||||
fEdeptrue = 1.;
|
||||
fRmstrue = 1.;
|
||||
fLimittrue = DBL_MAX;
|
||||
|
||||
fChargedStep = 0.0;
|
||||
fNeutralStep = 0.0;
|
||||
|
||||
fVerbose = 0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -92,356 +73,115 @@ void RunAction::BookHisto()
|
||||
// Create analysis manager
|
||||
// The choice of analysis technology is done via selection of a namespace
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
fAnalysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
fHistoName[0] = "testem2";
|
||||
analysisManager->OpenFile(fHistoName[0]);
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
G4String extension = analysisManager->GetFileType();
|
||||
|
||||
fAnalysisManager->OpenFile(fHistoName[0]);
|
||||
|
||||
fAnalysisManager->SetVerboseLevel(1);
|
||||
G4String extension = fAnalysisManager->GetFileType();
|
||||
fHistoName[1] = fHistoName[0] + "." + extension;
|
||||
|
||||
// Creating histograms
|
||||
//
|
||||
G4double Ekin = fKin->GetParticleGun()->GetParticleEnergy();
|
||||
G4int nLbin = fDet->GetnLtot();
|
||||
G4int nRbin = fDet->GetnRtot();
|
||||
G4double dLradl = fDet->GetdLradl();
|
||||
G4double dRradl = fDet->GetdRradl();
|
||||
|
||||
analysisManager->SetFirstHistoId(1);
|
||||
analysisManager->CreateH1( "1","total energy deposit(percent of Einc)",
|
||||
fAnalysisManager->SetFirstHistoId(1);
|
||||
fAnalysisManager->CreateH1( "h1","total energy deposit(percent of Einc)",
|
||||
110,0.,110.);
|
||||
|
||||
analysisManager->CreateH1( "2","total charged tracklength (radl)",
|
||||
fAnalysisManager->CreateH1( "h2","total charged tracklength (radl)",
|
||||
110,0.,110.*Ekin/GeV);
|
||||
|
||||
analysisManager->CreateH1( "3","total neutral tracklength (radl)",
|
||||
fAnalysisManager->CreateH1( "h3","total neutral tracklength (radl)",
|
||||
110,0.,1100.*Ekin/GeV);
|
||||
|
||||
analysisManager->CreateH1( "4","longit energy profile (% of E inc)",
|
||||
f_nLbin,0.,f_nLbin*dLradl);
|
||||
fAnalysisManager->CreateH1( "h4","longit energy profile (% of E inc)",
|
||||
nLbin,0.,nLbin*dLradl);
|
||||
|
||||
analysisManager->CreateH1( "5","rms on longit Edep (% of E inc)",
|
||||
f_nLbin,0.,f_nLbin*dLradl);
|
||||
fAnalysisManager->CreateH1( "h5","rms on longit Edep (% of E inc)",
|
||||
nLbin,0.,nLbin*dLradl);
|
||||
|
||||
G4double Zmin=0.5*dLradl, Zmax=Zmin+f_nLbin*dLradl;
|
||||
analysisManager->CreateH1( "6","cumul longit energy dep (% of E inc)",
|
||||
f_nLbin,Zmin,Zmax);
|
||||
G4double Zmin=0.5*dLradl, Zmax=Zmin+nLbin*dLradl;
|
||||
fAnalysisManager->CreateH1( "h6","cumul longit energy dep (% of E inc)",
|
||||
nLbin,Zmin,Zmax);
|
||||
|
||||
analysisManager->CreateH1( "7","rms on cumul longit Edep (% of E inc)",
|
||||
f_nLbin,Zmin,Zmax);
|
||||
fAnalysisManager->CreateH1( "h7","rms on cumul longit Edep (% of E inc)",
|
||||
nLbin,Zmin,Zmax);
|
||||
|
||||
analysisManager->CreateH1( "8","radial energy profile (% of E inc)",
|
||||
f_nRbin,0.,f_nRbin*dRradl);
|
||||
fAnalysisManager->CreateH1( "h8","radial energy profile (% of E inc)",
|
||||
nRbin,0.,nRbin*dRradl);
|
||||
|
||||
analysisManager->CreateH1( "9","rms on radial Edep (% of E inc)",
|
||||
f_nRbin,0.,f_nRbin*dRradl);
|
||||
fAnalysisManager->CreateH1( "h9","rms on radial Edep (% of E inc)",
|
||||
nRbin,0.,nRbin*dRradl);
|
||||
|
||||
G4double Rmin=0.5*dRradl, Rmax=Rmin+f_nRbin*dRradl;
|
||||
analysisManager->CreateH1("10","cumul radial energy dep (% of E inc)",
|
||||
f_nRbin,Rmin,Rmax);
|
||||
G4double Rmin=0.5*dRradl, Rmax=Rmin+nRbin*dRradl;
|
||||
fAnalysisManager->CreateH1("h10","cumul radial energy dep (% of E inc)",
|
||||
nRbin,Rmin,Rmax);
|
||||
|
||||
analysisManager->CreateH1("11","rms on cumul radial Edep (% of E inc)",
|
||||
f_nRbin,Rmin,Rmax);
|
||||
fAnalysisManager->CreateH1("h11","rms on cumul radial Edep (% of E inc)",
|
||||
nRbin,Rmin,Rmax);
|
||||
|
||||
G4cout << "\n----> Histogram file is opened in " << fHistoName[1] << G4endl;
|
||||
G4cout << "\n----> Histogram file is opened in " << fHistoName[1] << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::CleanHisto()
|
||||
void RunAction::SaveHisto()
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
fAnalysisManager->Write();
|
||||
fAnalysisManager->CloseFile();
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
delete fAnalysisManager;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
G4Run* RunAction::GenerateRun()
|
||||
{
|
||||
fRun = new Run(fDet, fKin);
|
||||
fRun->SetVerbose(fVerbose);
|
||||
return fRun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
//fRun->Reset();
|
||||
// not needed as a new Run object is created with each run
|
||||
|
||||
// save Rndm status
|
||||
////G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
|
||||
fChargedStep = 0.0;
|
||||
fNeutralStep = 0.0;
|
||||
|
||||
f_nLbin = fDet->GetnLtot();
|
||||
f_nRbin = fDet->GetnRtot();
|
||||
|
||||
//initialize arrays of cumulative energy deposition
|
||||
//
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
fSumELongit[i]=fSumE2Longit[i]=fSumELongitCumul[i]=fSumE2LongitCumul[i]=0.;
|
||||
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
fSumERadial[j]=fSumE2Radial[j]=fSumERadialCumul[j]=fSumE2RadialCumul[j]=0.;
|
||||
|
||||
//initialize track length
|
||||
fSumChargTrLength=fSum2ChargTrLength=fSumNeutrTrLength=fSum2NeutrTrLength=0.;
|
||||
// show Rndm status
|
||||
if (isMaster) {
|
||||
G4Random::showEngineStatus();
|
||||
}
|
||||
|
||||
//histograms
|
||||
//
|
||||
if (aRun->GetRunID() == 0) BookHisto();
|
||||
BookHisto();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::InitializePerEvent()
|
||||
{
|
||||
//initialize arrays of energy deposit per bin
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
{ f_dEdL[i] = 0.; }
|
||||
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
{ f_dEdR[j] = 0.; }
|
||||
|
||||
//initialize tracklength
|
||||
fChargTrLength = fNeutrTrLength = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::FillPerEvent()
|
||||
{
|
||||
//accumulate statistic
|
||||
//
|
||||
G4double dLCumul = 0.;
|
||||
for (G4int i=0; i<f_nLbin; i++)
|
||||
{
|
||||
fSumELongit[i] += f_dEdL[i];
|
||||
fSumE2Longit[i] += f_dEdL[i]*f_dEdL[i];
|
||||
dLCumul += f_dEdL[i];
|
||||
fSumELongitCumul[i] += dLCumul;
|
||||
fSumE2LongitCumul[i] += dLCumul*dLCumul;
|
||||
}
|
||||
|
||||
G4double dRCumul = 0.;
|
||||
for (G4int j=0; j<f_nRbin; j++)
|
||||
{
|
||||
fSumERadial[j] += f_dEdR[j];
|
||||
fSumE2Radial[j] += f_dEdR[j]*f_dEdR[j];
|
||||
dRCumul += f_dEdR[j];
|
||||
fSumERadialCumul[j] += dRCumul;
|
||||
fSumE2RadialCumul[j] += dRCumul*dRCumul;
|
||||
}
|
||||
|
||||
fSumChargTrLength += fChargTrLength;
|
||||
fSum2ChargTrLength += fChargTrLength*fChargTrLength;
|
||||
fSumNeutrTrLength += fNeutrTrLength;
|
||||
fSum2NeutrTrLength += fNeutrTrLength*fNeutrTrLength;
|
||||
|
||||
//fill histograms
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
G4double Ekin=fKin->GetParticleGun()->GetParticleEnergy();
|
||||
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
|
||||
G4double radl=fDet->GetMaterial()->GetRadlen();
|
||||
|
||||
analysisManager->FillH1(1, 100.*dLCumul/(Ekin+mass));
|
||||
analysisManager->FillH1(2, fChargTrLength/radl);
|
||||
analysisManager->FillH1(3, fNeutrTrLength/radl);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
void RunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
//compute and print statistic
|
||||
//
|
||||
G4int NbOfEvents = aRun->GetNumberOfEvent();
|
||||
G4double kinEnergy = fKin->GetParticleGun()->GetParticleEnergy();
|
||||
assert(NbOfEvents*kinEnergy > 0);
|
||||
if (isMaster) fRun->ComputeStatistics(fEdeptrue, fRmstrue, fLimittrue);
|
||||
|
||||
fChargedStep /= G4double(NbOfEvents);
|
||||
fNeutralStep /= G4double(NbOfEvents);
|
||||
|
||||
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
|
||||
G4double norme = 100./(NbOfEvents*(kinEnergy+mass));
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
//longitudinal
|
||||
//
|
||||
G4double dLradl = fDet->GetdLradl();
|
||||
|
||||
MyVector MeanELongit(f_nLbin), rmsELongit(f_nLbin);
|
||||
MyVector MeanELongitCumul(f_nLbin), rmsELongitCumul(f_nLbin);
|
||||
|
||||
G4int i;
|
||||
for (i=0; i<f_nLbin; i++)
|
||||
{
|
||||
MeanELongit[i] = norme*fSumELongit[i];
|
||||
rmsELongit[i] = norme*std::sqrt(std::fabs(NbOfEvents*fSumE2Longit[i]
|
||||
- fSumELongit[i]*fSumELongit[i]));
|
||||
|
||||
MeanELongitCumul[i] = norme*fSumELongitCumul[i];
|
||||
rmsELongitCumul[i] = norme*std::sqrt(std::fabs(NbOfEvents*fSumE2LongitCumul[i]
|
||||
- fSumELongitCumul[i]*fSumELongitCumul[i]));
|
||||
|
||||
G4double bin = (i+0.5)*dLradl;
|
||||
analysisManager->FillH1(4, bin,MeanELongit[i]/dLradl);
|
||||
analysisManager->FillH1(5, bin, rmsELongit[i]/dLradl);
|
||||
bin = (i+1)*dLradl;
|
||||
analysisManager->FillH1(6, bin,MeanELongitCumul[i]);
|
||||
analysisManager->FillH1(7, bin, rmsELongitCumul[i]);
|
||||
}
|
||||
|
||||
//radial
|
||||
//
|
||||
G4double dRradl = fDet->GetdRradl();
|
||||
|
||||
MyVector MeanERadial(f_nRbin), rmsERadial(f_nRbin);
|
||||
MyVector MeanERadialCumul(f_nRbin), rmsERadialCumul(f_nRbin);
|
||||
|
||||
for (i=0; i<f_nRbin; i++)
|
||||
{
|
||||
MeanERadial[i] = norme*fSumERadial[i];
|
||||
rmsERadial[i] = norme*std::sqrt(std::fabs(NbOfEvents*fSumE2Radial[i]
|
||||
- fSumERadial[i]*fSumERadial[i]));
|
||||
|
||||
MeanERadialCumul[i] = norme*fSumERadialCumul[i];
|
||||
rmsERadialCumul[i] = norme*std::sqrt(std::fabs(NbOfEvents*fSumE2RadialCumul[i]
|
||||
- fSumERadialCumul[i]*fSumERadialCumul[i]));
|
||||
|
||||
|
||||
G4double bin = (i+0.5)*dRradl;
|
||||
analysisManager->FillH1(8, bin,MeanERadial[i]/dRradl);
|
||||
analysisManager->FillH1(9, bin, rmsERadial[i]/dRradl);
|
||||
bin = (i+1)*dRradl;
|
||||
analysisManager->FillH1(10, bin,MeanERadialCumul[i]);
|
||||
analysisManager->FillH1(11, bin, rmsERadialCumul[i]);
|
||||
}
|
||||
|
||||
//find Moliere confinement
|
||||
//
|
||||
const G4double EMoliere = 90.;
|
||||
G4double iMoliere = 0.;
|
||||
if ((MeanERadialCumul[0] <= EMoliere) &&
|
||||
(MeanERadialCumul[f_nRbin-1] >= EMoliere)) {
|
||||
G4int imin = 0;
|
||||
while( (imin < f_nRbin-1) && (MeanERadialCumul[imin] < EMoliere) ) imin++;
|
||||
G4double ratio = (EMoliere - MeanERadialCumul[imin]) /
|
||||
(MeanERadialCumul[imin+1] - MeanERadialCumul[imin]);
|
||||
iMoliere = 1. + imin + ratio;
|
||||
}
|
||||
|
||||
//track length
|
||||
//
|
||||
norme = 1./(NbOfEvents*(fDet->GetMaterial()->GetRadlen()));
|
||||
G4double MeanChargTrLength = norme*fSumChargTrLength;
|
||||
G4double rmsChargTrLength =
|
||||
norme*std::sqrt(std::fabs(NbOfEvents*fSum2ChargTrLength
|
||||
- fSumChargTrLength*fSumChargTrLength));
|
||||
|
||||
G4double MeanNeutrTrLength = norme*fSumNeutrTrLength;
|
||||
G4double rmsNeutrTrLength =
|
||||
norme*std::sqrt(std::fabs(NbOfEvents*fSum2NeutrTrLength
|
||||
- fSumNeutrTrLength*fSumNeutrTrLength));
|
||||
|
||||
//print
|
||||
//
|
||||
|
||||
std::ios::fmtflags mode = G4cout.flags();
|
||||
G4cout.setf(std::ios::fixed,std::ios::floatfield);
|
||||
G4int prec = G4cout.precision(2);
|
||||
|
||||
if (fVerbose) {
|
||||
|
||||
G4cout << " LOGITUDINAL PROFILE "
|
||||
<< " CUMULATIVE LOGITUDINAL PROFILE" << G4endl << G4endl;
|
||||
|
||||
G4cout << " bin " << " Mean rms "
|
||||
<< " bin " << " Mean rms \n" << G4endl;
|
||||
|
||||
for (i=0; i<f_nLbin; i++)
|
||||
{
|
||||
G4double inf=i*dLradl, sup=inf+dLradl;
|
||||
|
||||
G4cout << std::setw(8) << inf << "->"
|
||||
<< std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanELongit[i] << "% "
|
||||
<< std::setw(9) << rmsELongit[i] << "% "
|
||||
<< " 0->" << std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanELongitCumul[i] << "% "
|
||||
<< std::setw(7) << rmsELongitCumul[i] << "% "
|
||||
<<G4endl;
|
||||
}
|
||||
|
||||
G4cout << G4endl << G4endl << G4endl;
|
||||
|
||||
G4cout << " RADIAL PROFILE "
|
||||
<< " CUMULATIVE RADIAL PROFILE" << G4endl << G4endl;
|
||||
|
||||
G4cout << " bin " << " Mean rms "
|
||||
<< " bin " << " Mean rms \n" << G4endl;
|
||||
|
||||
for (i=0; i<f_nRbin; i++)
|
||||
{
|
||||
G4double inf=i*dRradl, sup=inf+dRradl;
|
||||
|
||||
G4cout << std::setw(8) << inf << "->"
|
||||
<< std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanERadial[i] << "% "
|
||||
<< std::setw(9) << rmsERadial[i] << "% "
|
||||
<< " 0->" << std::setw(5) << sup << " radl: "
|
||||
<< std::setw(7) << MeanERadialCumul[i] << "% "
|
||||
<< std::setw(7) << rmsERadialCumul[i] << "% "
|
||||
<<G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4cout << "\n SUMMARY \n" << G4endl;
|
||||
|
||||
G4cout << "\n"
|
||||
<< " Mean number of charged steps: " << fChargedStep << G4endl;
|
||||
G4cout << " Mean number of neutral steps: " << fNeutralStep
|
||||
<< "\n" << G4endl;
|
||||
|
||||
G4cout << " energy deposit : "
|
||||
<< std::setw(7) << MeanELongitCumul[f_nLbin-1] << " % E0 +- "
|
||||
<< std::setw(7) << rmsELongitCumul[f_nLbin-1] << " % E0" << G4endl;
|
||||
G4cout << " charged traklen: "
|
||||
<< std::setw(7) << MeanChargTrLength << " radl +- "
|
||||
<< std::setw(7) << rmsChargTrLength << " radl" << G4endl;
|
||||
G4cout << " neutral traklen: "
|
||||
<< std::setw(7) << MeanNeutrTrLength << " radl +- "
|
||||
<< std::setw(7) << rmsNeutrTrLength << " radl" << G4endl;
|
||||
|
||||
if (iMoliere > 0. ) {
|
||||
G4double RMoliere1 = iMoliere*fDet->GetdRradl();
|
||||
G4double RMoliere2 = iMoliere*fDet->GetdRlength();
|
||||
G4cout << "\n " << EMoliere << " % confinement: radius = "
|
||||
<< RMoliere1 << " radl ("
|
||||
<< G4BestUnit( RMoliere2, "Length") << ")" << "\n" << G4endl;
|
||||
}
|
||||
|
||||
G4cout.setf(mode,std::ios::floatfield);
|
||||
G4cout.precision(prec);
|
||||
|
||||
// save histos and close AnalysisFactory
|
||||
CleanHisto();
|
||||
|
||||
// show Rndm status
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
G4Random::showEngineStatus();
|
||||
|
||||
// Acceptance
|
||||
if(fLimittrue < DBL_MAX) {
|
||||
EmAcceptance acc;
|
||||
acc.BeginOfAcceptance("Total Energy in Absorber",NbOfEvents);
|
||||
G4double e = MeanELongitCumul[f_nLbin-1]/100.;
|
||||
G4double r = rmsELongitCumul[f_nLbin-1]/100.;
|
||||
acc.EmAcceptanceGauss("Edep",NbOfEvents,e,fEdeptrue,fRmstrue,fLimittrue);
|
||||
acc.EmAcceptanceGauss("Erms",NbOfEvents,r,fRmstrue,fRmstrue,2.0*fLimittrue);
|
||||
acc.EndOfAcceptance();
|
||||
}
|
||||
// save histos and close analysis
|
||||
SaveHisto();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -452,5 +192,12 @@ void RunAction::SetEdepAndRMS(G4ThreeVector Value)
|
||||
fRmstrue = Value(1);
|
||||
fLimittrue= Value(2);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::SetVerbose(G4int val)
|
||||
{
|
||||
fVerbose = val;
|
||||
if ( fRun ) fRun->SetVerbose(val);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/RunActionMessenger.cc
|
||||
/// \brief Implementation of the RunActionMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: RunActionMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -42,7 +42,12 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunActionMessenger::RunActionMessenger(RunAction* run)
|
||||
:fRun(run)
|
||||
:G4UImessenger(),fRun(run),
|
||||
fRunDir(0),
|
||||
fAccCmd(0),
|
||||
fVerbCmd(0),
|
||||
fHistoDir(0),
|
||||
factoryCmd(0)
|
||||
{
|
||||
fRunDir = new G4UIdirectory("/testem/run/");
|
||||
fRunDir->SetGuidance("run control");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/src/StepMax.cc
|
||||
/// \brief Implementation of the StepMax class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: StepMax.cc 74994 2013-10-25 10:47:45Z gcosmo $
|
||||
//
|
||||
//....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);
|
||||
}
|
||||
@@ -55,7 +55,10 @@ G4bool StepMax::IsApplicable(const G4ParticleDefinition& particle)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void StepMax::SetMaxStep(G4double step) {fMaxChargedStep = step;}
|
||||
void StepMax::SetMaxStep(G4double step)
|
||||
{
|
||||
fMaxChargedStep = step;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file electromagnetic/TestEm2/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,48 +26,52 @@
|
||||
/// \file electromagnetic/TestEm2/src/SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: SteppingAction.cc 76259 2013-11-08 11:37:28Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction(DetectorConstruction* det, RunAction* run)
|
||||
:fDetector(det),fRun(run)
|
||||
{ }
|
||||
SteppingAction::SteppingAction(DetectorConstruction* det)
|
||||
:G4UserSteppingAction(),fDetector(det)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction()
|
||||
{ }
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
// energy deposit
|
||||
//
|
||||
G4double dEStep = step->GetTotalEnergyDeposit();
|
||||
fRun->AddStep(step->GetTrack()->GetDefinition()->GetPDGCharge());
|
||||
if (dEStep > 0.) {
|
||||
G4ThreeVector prePoint = step->GetPreStepPoint()->GetPosition();
|
||||
G4ThreeVector postPoint = step->GetPostStepPoint()->GetPosition();
|
||||
G4ThreeVector position = prePoint + G4UniformRand()*(postPoint - prePoint);
|
||||
G4double x = position.x(), y = position.y(), z = position.z();
|
||||
G4double radius = std::sqrt(x*x + y*y);
|
||||
G4double offset = 0.5*fDetector->GetfullLength();
|
||||
G4int SlideNb = G4int((z + offset)/fDetector->GetdLlength());
|
||||
G4int RingNb = G4int(radius/fDetector->GetdRlength());
|
||||
fRun->FillPerStep(dEStep,SlideNb,RingNb);
|
||||
}
|
||||
// energy deposit
|
||||
//
|
||||
G4double dEStep = step->GetTotalEnergyDeposit();
|
||||
Run* run
|
||||
= static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->AddStep(step->GetTrack()->GetDefinition()->GetPDGCharge());
|
||||
if (dEStep > 0.) {
|
||||
G4ThreeVector prePoint = step->GetPreStepPoint()->GetPosition();
|
||||
G4ThreeVector delta = step->GetPostStepPoint()->GetPosition() - prePoint;
|
||||
prePoint += G4UniformRand()*delta;
|
||||
G4double x = prePoint.x(), y = prePoint.y(), z = prePoint.z();
|
||||
G4double radius = std::sqrt(x*x + y*y);
|
||||
G4double offset = 0.5*fDetector->GetfullLength();
|
||||
G4int SlideNb = G4int((z + offset)/fDetector->GetdLlength());
|
||||
G4int RingNb = G4int(radius/fDetector->GetdRlength());
|
||||
run->FillPerStep(dEStep,SlideNb,RingNb);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,23 +23,25 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm2/src/SteppingVerbose.cc
|
||||
/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc
|
||||
/// \brief Implementation of the SteppingVerbose class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: SteppingVerbose.cc 74994 2013-10-25 10:47:45Z 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......
|
||||
|
||||
@@ -26,21 +26,22 @@
|
||||
/// \file electromagnetic/TestEm2/src/TrackingAction.cc
|
||||
/// \brief Implementation of the TrackingAction class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: TrackingAction.cc 76259 2013-11-08 11:37:28Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "TrackingAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction(RunAction* run)
|
||||
:fRun(run)
|
||||
TrackingAction::TrackingAction()
|
||||
:G4UserTrackingAction()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -51,7 +52,10 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
G4double charge = aTrack->GetDefinition()->GetPDGCharge();
|
||||
G4double TrLeng = aTrack->GetTrackLength();
|
||||
|
||||
fRun->FillPerTrack(charge,TrLeng);
|
||||
Run* run
|
||||
= static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
run->FillPerTrack(charge,TrLeng);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user