Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -28,6 +28,7 @@
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "SteppingAction.hh"
@@ -36,13 +37,12 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization()
: G4VUserActionInitialization()
: G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{}
ActionInitialization::~ActionInitialization() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -63,4 +63,3 @@ void ActionInitialization::Build() const
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,6 +32,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4NistManager.hh"
@@ -49,11 +50,11 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
: G4VUserDetectorConstruction(),
fDetectorMessenger(nullptr)
: G4VUserDetectorConstruction()
, fDetectorMessenger(nullptr)
{
fExpHall_x = fExpHall_y = fExpHall_z = 10.0*m;
fTank_x = fTank_y = fTank_z = 1.0*m;
fExpHall_x = fExpHall_y = fExpHall_z = 10.0 * m;
fTank_x = fTank_y = fTank_z = 1.0 * m;
fTank = nullptr;
@@ -78,8 +79,11 @@ DetectorConstruction::DetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
DetectorConstruction::~DetectorConstruction() {
delete fTankMPT;
delete fWorldMPT;
delete fSurfaceMPT;
delete fSurface;
delete fDetectorMessenger;
}
@@ -88,7 +92,7 @@ DetectorConstruction::~DetectorConstruction()
G4VPhysicalVolume* DetectorConstruction::Construct()
{
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
@@ -96,39 +100,39 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
// The experimental Hall
G4Box* world_box = new G4Box("World", fExpHall_x, fExpHall_y, fExpHall_z);
fWorld_LV
= new G4LogicalVolume(world_box, fWorldMaterial, "World", 0, 0, 0);
fWorld_LV = new G4LogicalVolume(world_box, fWorldMaterial, "World", 0, 0, 0);
G4VPhysicalVolume* world_PV
= new G4PVPlacement(0, G4ThreeVector(), fWorld_LV, "World", 0, false, 0);
G4VPhysicalVolume* world_PV =
new G4PVPlacement(0, G4ThreeVector(), fWorld_LV, "World", 0, false, 0);
// The tank
G4Box* tank_box = new G4Box("Tank", fTank_x, fTank_y, fTank_z);
fTank_LV
= new G4LogicalVolume(tank_box, fTankMaterial, "Tank", 0, 0, 0);
fTank_LV = new G4LogicalVolume(tank_box, fTankMaterial, "Tank", 0, 0, 0);
fTank
= new G4PVPlacement(0, G4ThreeVector(), fTank_LV, "Tank",
fWorld_LV, false, 0);
fTank = new G4PVPlacement(0, G4ThreeVector(), fTank_LV, "Tank", fWorld_LV,
false, 0);
// ------------- Surface --------------
G4LogicalBorderSurface* surface =
new G4LogicalBorderSurface("Surface",
fTank, world_PV, fSurface);
new G4LogicalBorderSurface("Surface", fTank, world_PV, fSurface);
G4OpticalSurface* opticalSurface = dynamic_cast <G4OpticalSurface*>
(surface->GetSurface(fTank,world_PV)->GetSurfaceProperty());
G4OpticalSurface* opticalSurface = dynamic_cast<G4OpticalSurface*>(
surface->GetSurface(fTank, world_PV)->GetSurfaceProperty());
G4cout << "****** opticalSurface->DumpInfo:" << G4endl;
if (opticalSurface) { opticalSurface->DumpInfo(); }
if(opticalSurface)
{
opticalSurface->DumpInfo();
}
G4cout << "****** end of opticalSurface->DumpInfo" << G4endl;
return world_PV;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v) {
void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v)
{
fSurface->SetSigmaAlpha(v);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
@@ -137,91 +141,101 @@ void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v) {
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetSurfacePolish(G4double v) {
void DetectorConstruction::SetSurfacePolish(G4double v)
{
fSurface->SetPolish(v);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
G4cout << "Surface polish set to: " << fSurface->GetPolish()
<< G4endl;
G4cout << "Surface polish set to: " << fSurface->GetPolish() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddTankMPV(const char* c,
G4MaterialPropertyVector* mpv) {
fTankMPT->AddProperty(c, mpv);
void DetectorConstruction::AddTankMPV(const G4String& prop,
G4MaterialPropertyVector* mpv)
{
fTankMPT->AddProperty(prop, mpv);
G4cout << "The MPT for the box is now: " << G4endl;
fTankMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddWorldMPV(const char* c,
G4MaterialPropertyVector* mpv) {
fWorldMPT->AddProperty(c, mpv);
void DetectorConstruction::AddWorldMPV(const G4String& prop,
G4MaterialPropertyVector* mpv)
{
fWorldMPT->AddProperty(prop, mpv);
G4cout << "The MPT for the world is now: " << G4endl;
fWorldMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddSurfaceMPV(const char* c,
G4MaterialPropertyVector* mpv) {
fSurfaceMPT->AddProperty(c, mpv);
void DetectorConstruction::AddSurfaceMPV(const G4String& prop,
G4MaterialPropertyVector* mpv)
{
fSurfaceMPT->AddProperty(prop, mpv);
G4cout << "The MPT for the surface is now: " << G4endl;
fSurfaceMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddTankMPC(const char* c, G4double v) {
fTankMPT->AddConstProperty(c, v);
void DetectorConstruction::AddTankMPC(const G4String& prop, G4double v)
{
fTankMPT->AddConstProperty(prop, v);
G4cout << "The MPT for the box is now: " << G4endl;
fTankMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddWorldMPC(const char* c, G4double v) {
fWorldMPT->AddConstProperty(c, v);
void DetectorConstruction::AddWorldMPC(const G4String& prop, G4double v)
{
fWorldMPT->AddConstProperty(prop, v);
G4cout << "The MPT for the world is now: " << G4endl;
fWorldMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddSurfaceMPC(const char* c, G4double v) {
fSurfaceMPT->AddConstProperty(c, v);
void DetectorConstruction::AddSurfaceMPC(const G4String& prop, G4double v)
{
fSurfaceMPT->AddConstProperty(prop, v);
G4cout << "The MPT for the surface is now: " << G4endl;
fSurfaceMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldMaterial(const G4String& mat) {
void DetectorConstruction::SetWorldMaterial(const G4String& mat)
{
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
if (pmat && fWorldMaterial != pmat) {
if(pmat && fWorldMaterial != pmat)
{
fWorldMaterial = pmat;
if (fWorld_LV) {
if(fWorld_LV)
{
fWorld_LV->SetMaterial(fWorldMaterial);
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
G4cout << "World material set to " << fWorldMaterial->GetName()
<< G4endl;
G4cout << "World material set to " << fWorldMaterial->GetName() << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetTankMaterial(const G4String& mat) {
void DetectorConstruction::SetTankMaterial(const G4String& mat)
{
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
if (pmat && fTankMaterial != pmat) {
if(pmat && fTankMaterial != pmat)
{
fTankMaterial = pmat;
if (fTank_LV) {
if(fTank_LV)
{
fTank_LV->SetMaterial(fTankMaterial);
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
G4cout << "Tank material set to " << fTankMaterial->GetName()
<< G4endl;
G4cout << "Tank material set to " << fTankMaterial->GetName() << G4endl;
}
}
@@ -32,25 +32,26 @@
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4OpticalSurface.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcommand.hh"
#include "G4UIdirectory.hh"
#include "G4UIparameter.hh"
#include <sstream>
#include <iostream>
#include "G4OpticalSurface.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:G4UImessenger(),fDetector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
: G4UImessenger()
, fDetector(Det)
{
fOpticalDir = new G4UIdirectory("/opnovice2/");
fOpticalDir->SetGuidance("Parameters for optical simulation.");
@@ -65,8 +66,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceFinishCmd->SetToBeBroadcasted(false);
fSurfaceModelCmd =
new G4UIcmdWithAString("/opnovice2/surfaceModel", this);
fSurfaceModelCmd = new G4UIcmdWithAString("/opnovice2/surfaceModel", this);
fSurfaceModelCmd->SetGuidance("surface model.");
fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceModelCmd->SetToBeBroadcasted(false);
@@ -78,8 +78,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false);
fSurfacePolishCmd =
new G4UIcmdWithADouble("/opnovice2/surfacePolish", this);
fSurfacePolishCmd = new G4UIcmdWithADouble("/opnovice2/surfacePolish", this);
fSurfacePolishCmd->SetGuidance("surface polish");
fSurfacePolishCmd->SetGuidance(" parameter (for Glisur model).");
fSurfacePolishCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -129,21 +128,20 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
new G4UIcmdWithAString("/opnovice2/worldConstProperty", this);
fWorldMatPropConstCmd->SetGuidance("Set material constant property");
fWorldMatPropConstCmd->SetGuidance(" for the world.");
fWorldMatPropConstCmd->
AvailableForStates(G4State_PreInit, G4State_Idle);
fWorldMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWorldMatPropConstCmd->SetToBeBroadcasted(false);
fWorldMaterialCmd = new G4UIcmdWithAString("/opnovice2/worldMaterial", this);
fWorldMaterialCmd->SetGuidance("Set material of world.");
fWorldMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWorldMaterialCmd->SetToBeBroadcasted(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete fOpticalDir;
delete fSurfaceFinishCmd;
delete fSurfaceTypeCmd;
delete fSurfaceModelCmd;
@@ -161,189 +159,245 @@ DetectorMessenger::~DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
// FINISH
if (command == fSurfaceFinishCmd) {
if (newValue == "polished") {
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
// FINISH
if(command == fSurfaceFinishCmd)
{
if(newValue == "polished")
{
fDetector->SetSurfaceFinish(polished);
}
else if (newValue == "polishedfrontpainted") {
else if(newValue == "polishedfrontpainted")
{
fDetector->SetSurfaceFinish(polishedfrontpainted);
}
else if (newValue == "polishedbackpainted") {
else if(newValue == "polishedbackpainted")
{
fDetector->SetSurfaceFinish(polishedbackpainted);
}
else if (newValue == "ground") {
else if(newValue == "ground")
{
fDetector->SetSurfaceFinish(ground);
}
else if (newValue == "groundfrontpainted") {
else if(newValue == "groundfrontpainted")
{
fDetector->SetSurfaceFinish(groundfrontpainted);
}
else if (newValue == "groundbackpainted") {
else if(newValue == "groundbackpainted")
{
fDetector->SetSurfaceFinish(groundbackpainted);
}
else if (newValue == "polishedlumirrorair") {
else if(newValue == "polishedlumirrorair")
{
fDetector->SetSurfaceFinish(polishedlumirrorair);
}
else if (newValue == "polishedlumirrorglue") {
else if(newValue == "polishedlumirrorglue")
{
fDetector->SetSurfaceFinish(polishedlumirrorglue);
}
else if (newValue == "polishedair") {
else if(newValue == "polishedair")
{
fDetector->SetSurfaceFinish(polishedair);
}
else if (newValue == "polishedteflonair") {
else if(newValue == "polishedteflonair")
{
fDetector->SetSurfaceFinish(polishedteflonair);
}
else if (newValue == "polishedtioair") {
else if(newValue == "polishedtioair")
{
fDetector->SetSurfaceFinish(polishedtioair);
}
else if (newValue == "polishedtyvekair") {
else if(newValue == "polishedtyvekair")
{
fDetector->SetSurfaceFinish(polishedtyvekair);
}
else if (newValue == "polishedvm2000air") {
else if(newValue == "polishedvm2000air")
{
fDetector->SetSurfaceFinish(polishedvm2000air);
}
else if (newValue == "polishedvm2000glue") {
else if(newValue == "polishedvm2000glue")
{
fDetector->SetSurfaceFinish(polishedvm2000glue);
}
else if (newValue == "etchedlumirrorair") {
else if(newValue == "etchedlumirrorair")
{
fDetector->SetSurfaceFinish(etchedlumirrorair);
}
else if (newValue == "etchedlumirrorglue") {
else if(newValue == "etchedlumirrorglue")
{
fDetector->SetSurfaceFinish(etchedlumirrorglue);
}
else if (newValue == "etchedair") {
else if(newValue == "etchedair")
{
fDetector->SetSurfaceFinish(etchedair);
}
else if (newValue == "etchedteflonair") {
else if(newValue == "etchedteflonair")
{
fDetector->SetSurfaceFinish(etchedteflonair);
}
else if (newValue == "etchedtioair") {
else if(newValue == "etchedtioair")
{
fDetector->SetSurfaceFinish(etchedtioair);
}
else if (newValue == "etchedtyvekair") {
else if(newValue == "etchedtyvekair")
{
fDetector->SetSurfaceFinish(etchedtyvekair);
}
else if (newValue == "etchedvm2000air") {
else if(newValue == "etchedvm2000air")
{
fDetector->SetSurfaceFinish(etchedvm2000air);
}
else if (newValue == "etchedvm2000glue") {
else if(newValue == "etchedvm2000glue")
{
fDetector->SetSurfaceFinish(etchedvm2000glue);
}
else if (newValue == "groundlumirrorair") {
else if(newValue == "groundlumirrorair")
{
fDetector->SetSurfaceFinish(groundlumirrorair);
}
else if (newValue == "groundlumirrorglue") {
else if(newValue == "groundlumirrorglue")
{
fDetector->SetSurfaceFinish(groundlumirrorglue);
}
else if (newValue == "groundair") {
else if(newValue == "groundair")
{
fDetector->SetSurfaceFinish(groundair);
}
else if (newValue == "groundteflonair") {
else if(newValue == "groundteflonair")
{
fDetector->SetSurfaceFinish(groundteflonair);
}
else if (newValue == "groundtioair") {
else if(newValue == "groundtioair")
{
fDetector->SetSurfaceFinish(groundtioair);
}
else if (newValue == "groundtyvekair") {
else if(newValue == "groundtyvekair")
{
fDetector->SetSurfaceFinish(groundtyvekair);
}
else if (newValue == "groundvm2000air") {
else if(newValue == "groundvm2000air")
{
fDetector->SetSurfaceFinish(groundvm2000air);
}
else if (newValue == "groundvm2000glue") {
else if(newValue == "groundvm2000glue")
{
fDetector->SetSurfaceFinish(groundvm2000glue);
}
// for Davis model
else if (newValue == "Rough_LUT") {
else if(newValue == "Rough_LUT")
{
fDetector->SetSurfaceFinish(Rough_LUT);
}
else if (newValue == "RoughTeflon_LUT") {
else if(newValue == "RoughTeflon_LUT")
{
fDetector->SetSurfaceFinish(RoughTeflon_LUT);
}
else if (newValue == "RoughESR_LUT") {
else if(newValue == "RoughESR_LUT")
{
fDetector->SetSurfaceFinish(RoughESR_LUT);
}
else if (newValue == "RoughESRGrease_LUT") {
else if(newValue == "RoughESRGrease_LUT")
{
fDetector->SetSurfaceFinish(RoughESRGrease_LUT);
}
else if (newValue == "Polished_LUT") {
else if(newValue == "Polished_LUT")
{
fDetector->SetSurfaceFinish(Polished_LUT);
}
else if (newValue == "PolishedTeflon_LUT") {
else if(newValue == "PolishedTeflon_LUT")
{
fDetector->SetSurfaceFinish(PolishedTeflon_LUT);
}
else if (newValue == "PolishedESR_LUT") {
else if(newValue == "PolishedESR_LUT")
{
fDetector->SetSurfaceFinish(PolishedESR_LUT);
}
else if (newValue == "PolishedESRGrease_LUT") {
else if(newValue == "PolishedESRGrease_LUT")
{
fDetector->SetSurfaceFinish(PolishedESRGrease_LUT);
}
else if (newValue == "Detector_LUT") {
else if(newValue == "Detector_LUT")
{
fDetector->SetSurfaceFinish(Detector_LUT);
}
else {
else
{
G4ExceptionDescription ed;
ed << "Invalid surface finish: " << newValue;
G4Exception("DetectorMessenger", "OpNovice2_003", FatalException,ed);
G4Exception("DetectorMessenger", "OpNovice2_003", FatalException, ed);
}
}
// MODEL
else if (command == fSurfaceModelCmd) {
if (newValue == "glisur") {
else if(command == fSurfaceModelCmd)
{
if(newValue == "glisur")
{
fDetector->SetSurfaceModel(glisur);
}
else if (newValue == "unified") {
else if(newValue == "unified")
{
fDetector->SetSurfaceModel(unified);
}
else if (newValue == "LUT") {
else if(newValue == "LUT")
{
fDetector->SetSurfaceModel(LUT);
}
else if (newValue == "DAVIS") {
else if(newValue == "DAVIS")
{
fDetector->SetSurfaceModel(DAVIS);
}
else if (newValue == "dichroic") {
else if(newValue == "dichroic")
{
fDetector->SetSurfaceModel(dichroic);
}
else {
else
{
G4ExceptionDescription ed;
ed << "Invalid surface model: " << newValue;
G4Exception("DetectorMessenger", "ONovice2_001",
FatalException,ed);
G4Exception("DetectorMessenger", "ONovice2_001", FatalException, ed);
}
}
// TYPE
else if (command == fSurfaceTypeCmd) {
if (newValue == "dielectric_metal") {
else if(command == fSurfaceTypeCmd)
{
if(newValue == "dielectric_metal")
{
fDetector->SetSurfaceType(dielectric_metal);
}
else if (newValue == "dielectric_dielectric") {
else if(newValue == "dielectric_dielectric")
{
fDetector->SetSurfaceType(dielectric_dielectric);
}
else if (newValue == "dielectric_LUT") {
else if(newValue == "dielectric_LUT")
{
fDetector->SetSurfaceType(dielectric_LUT);
}
else if (newValue == "dielectric_LUTDAVIS") {
else if(newValue == "dielectric_LUTDAVIS")
{
fDetector->SetSurfaceType(dielectric_LUTDAVIS);
}
else {
else
{
G4ExceptionDescription ed;
ed << "Invalid surface type: " << newValue;
G4Exception("DetectorMessenger", "OpNovice2_002", FatalException,ed);
G4Exception("DetectorMessenger", "OpNovice2_002", FatalException, ed);
}
}
else if (command == fSurfaceSigmaAlphaCmd) {
else if(command == fSurfaceSigmaAlphaCmd)
{
fDetector->SetSurfaceSigmaAlpha(
G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
else if (command == fSurfacePolishCmd) {
else if(command == fSurfacePolishCmd)
{
fDetector->SetSurfacePolish(
G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
else if (command == fTankMatPropVectorCmd) {
else if(command == fTankMatPropVectorCmd)
{
// got a string. need to convert it to physics vector.
// string format is property name, then pairs of energy, value
// specify units for each value, eg 3.0*eV
@@ -352,64 +406,73 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
std::istringstream instring(newValue);
G4String prop;
instring >> prop;
while (instring) {
while(instring)
{
G4String tmp;
instring >> tmp;
if (tmp == "") { break; }
if(tmp == "")
{
break;
}
G4double en = G4UIcommand::ConvertToDouble(tmp);
instring >> tmp;
G4double val;
val = G4UIcommand::ConvertToDouble(tmp);
G4double val = G4UIcommand::ConvertToDouble(tmp);
mpv->InsertValues(en, val);
}
const char* c = prop.c_str();
fDetector->AddTankMPV(c, mpv);
fDetector->AddTankMPV(prop, mpv);
}
else if (command == fWorldMatPropVectorCmd) {
else if(command == fWorldMatPropVectorCmd)
{
// Convert string to physics vector
// string format is property name, then pairs of energy, value
G4MaterialPropertyVector* mpv = new G4MaterialPropertyVector();
std::istringstream instring(newValue);
G4String prop;
instring >> prop;
while (instring) {
while(instring)
{
G4String tmp;
instring >> tmp;
if (tmp == "") { break; }
if(tmp == "")
{
break;
}
G4double en = G4UIcommand::ConvertToDouble(tmp);
instring >> tmp;
G4double val;
val = G4UIcommand::ConvertToDouble(tmp);
G4double val = G4UIcommand::ConvertToDouble(tmp);
mpv->InsertValues(en, val);
}
const char* c = prop.c_str();
fDetector->AddWorldMPV(c, mpv);
}
fDetector->AddWorldMPV(prop, mpv);
}
else if (command == fSurfaceMatPropVectorCmd) {
else if(command == fSurfaceMatPropVectorCmd)
{
// Convert string to physics vector
// string format is property name, then pairs of energy, value
// string format is property name, then pairs of energy, value
// space delimited
G4MaterialPropertyVector* mpv = new G4MaterialPropertyVector();
G4cout << newValue << G4endl;
std::istringstream instring(newValue);
G4String prop;
instring >> prop;
while (instring) {
while(instring)
{
G4String tmp;
instring >> tmp;
if (tmp == "") { break; }
if(tmp == "")
{
break;
}
G4double en = G4UIcommand::ConvertToDouble(tmp);
instring >> tmp;
G4double val;
val = G4UIcommand::ConvertToDouble(tmp);
G4double val = G4UIcommand::ConvertToDouble(tmp);
mpv->InsertValues(en, val);
}
const char* c = prop.c_str();
fDetector->AddSurfaceMPV(c, mpv);
}
fDetector->AddSurfaceMPV(prop, mpv);
}
else if (command == fTankMatPropConstCmd) {
else if(command == fTankMatPropConstCmd)
{
// Convert string to physics vector
// string format is property name, then value
// space delimited
@@ -419,10 +482,10 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
instring >> prop;
instring >> tmp;
G4double val = G4UIcommand::ConvertToDouble(tmp);
const char* c = prop.c_str();
fDetector->AddTankMPC(c, val);
fDetector->AddTankMPC(prop, val);
}
else if (command == fWorldMatPropConstCmd) {
else if(command == fWorldMatPropConstCmd)
{
// Convert string to physics vector
// string format is property name, then value
// space delimited
@@ -432,10 +495,10 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
instring >> prop;
instring >> tmp;
G4double val = G4UIcommand::ConvertToDouble(tmp);
const char* c = prop.c_str();
fDetector->AddTankMPC(c, val);
fDetector->AddWorldMPC(prop, val);
}
else if (command == fSurfaceMatPropConstCmd) {
else if(command == fSurfaceMatPropConstCmd)
{
// Convert string to physics vector
// string format is property name, then value
// space delimited
@@ -445,13 +508,14 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
instring >> prop;
instring >> tmp;
G4double val = G4UIcommand::ConvertToDouble(tmp);
const char* c = prop.c_str();
fDetector->AddSurfaceMPC(c, val);
fDetector->AddSurfaceMPC(prop, val);
}
else if (command == fWorldMaterialCmd) {
else if(command == fWorldMaterialCmd)
{
fDetector->SetWorldMaterial(newValue);
}
else if (command == fTankMaterialCmd) {
else if(command == fTankMaterialCmd)
{
fDetector->SetTankMaterial(newValue);
}
}
@@ -27,11 +27,12 @@
/// \brief Implementation of the HistoManager class
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -44,10 +45,7 @@ HistoManager::HistoManager()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
delete G4AnalysisManager::Instance();
}
HistoManager::~HistoManager() { delete G4AnalysisManager::Instance(); }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -56,48 +54,75 @@ void HistoManager::Book()
// Create or get analysis manager
// The choice of analysis technology is done via selection of a namespace
// in HistoManager.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetFileName(fFileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetActivation(true); // enable inactivation of histograms
G4AnalysisManager* analysisMan = G4AnalysisManager::Instance();
analysisMan->SetFileName(fFileName);
analysisMan->SetVerboseLevel(1);
analysisMan->SetActivation(true); // enable inactivation of histograms
// Define histogram indices, titles
G4int maxHisto = 15;
G4String id[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10","11","12","13","14","15","16","17","18","19" };
// TODO change throughout code
G4String title[] = {
"dummy", // 0
"Cerenkov spectrum", // 1
"scintillation spectrum", // 2
"scintillation photons creation time", // 3
"WLS absorption spectrum", // 4
"WLS emission spectrum", // 5
"WLS emission time", // 6
"WLS2 absorption spectrum", // 7
"WLS2 emission spectrum", // 8
"WLS2 emission time", // 9
"boundary process status", //10
"X momentum dir of backward-going photons", //11
"Y momentum dir of backward-going photons", //12
"Z momentum dir of backward-going photons", //13
"X momentum dir of forward-going photons", //14
"Y momentum dir of forward-going photons", //15
"Z momentum dir of forward-going photons", //16
"X momentum dir of Fresnel-refracted photons", //17
"Y momentum dir of Fresnel-refracted photons", //18
"Z momentum dir of Fresnel-refracted photons", //19
};
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
G4double vmin = 0.;
G4double vmax = 100.;
// Define histograms
// Default values (to be reset via /analysis/h1/set command)
G4int n = 100;
G4double xmn = 0.;
G4double xmx = 100.;
// Create all histograms as inactivated
for (G4int k=0; k <= maxHisto; ++k) {
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
analysisManager->SetH1Activation(ih, false);
// 0
analysisMan->CreateH1("0", "dummy", n, xmn, xmx);
// 1
analysisMan->CreateH1("Cerenkov spectrum", "Cerenkov spectrum", n, xmn, xmx);
// 2
analysisMan->CreateH1("Scintillation spectrum", "Scintillation spectrum", n,
xmn, xmx);
// 3
analysisMan->CreateH1("Scintillation time",
"scintillation photons creation time", n, xmn, xmx);
// 4
analysisMan->CreateH1("WLS abs", "WLS absorption spectrum", n, xmn, xmx);
// 5
analysisMan->CreateH1("WLS em", "WLS emission spectrum", n, xmn, xmx);
// 6
analysisMan->CreateH1("WLS time", "WLS emission time", n, xmn, xmx);
// 7
analysisMan->CreateH1("WLS2 abs", "WLS2 absorption spectrum", n, xmn, xmx);
// 8
analysisMan->CreateH1("WLS2 em", "WLS2 emission spectrum", n, xmn, xmx);
// 9
analysisMan->CreateH1("WLS2 time", "WLS2 emission time", n, xmn, xmx);
// 10
analysisMan->CreateH1("bdry status", "boundary process status", n, xmn, xmx);
// 11
analysisMan->CreateH1(
"x_backward", "X momentum dir of backward-going photons", n, xmn, xmx);
// 12
analysisMan->CreateH1(
"y_backward", "Y momentum dir of backward-going photons", n, xmn, xmx);
// 13
analysisMan->CreateH1(
"z_backward", "Z momentum dir of backward-going photons", n, xmn, xmx);
// 14
analysisMan->CreateH1("x_forward", "X momentum dir of forward-going photons",
n, xmn, xmx);
// 15
analysisMan->CreateH1("y_forward", "Y momentum dir of forward-going photons",
n, xmn, xmx);
// 16
analysisMan->CreateH1("z_forward", "Z momentum dir of forward-going photons",
n, xmn, xmx);
// 17
analysisMan->CreateH1(
"x_fresnel", "X momentum dir of Fresnel-refracted photons", n, xmn, xmx);
// 18
analysisMan->CreateH1(
"y_fresnel", "Y momentum dir of Fresnel-refracted photons", n, xmn, xmx);
// 19
analysisMan->CreateH1(
"z_fresnel", "Z momentum dir of Fresnel-refracted photons", n, xmn, xmx);
// 20
analysisMan->CreateH1("Transmitted", "Transmitted photons", n, xmn, xmx);
// 21
analysisMan->CreateH1("Reflected", "Reflected photons", n, xmn, xmx);
for(G4int i = 0; i < analysisMan->GetNofH1s(); ++i)
{
analysisMan->SetH1Activation(i, false);
}
}
@@ -32,38 +32,43 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PrimaryGeneratorAction.hh"
#include "PrimaryGeneratorMessenger.hh"
#include "Randomize.hh"
#include "G4Event.hh"
#include "G4OpticalPhoton.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0)
: G4VUserPrimaryGeneratorAction()
, fParticleGun(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
fParticleGun = new G4ParticleGun(n_particle);
//create a messenger for this class
// create a messenger for this class
fGunMessenger = new PrimaryGeneratorMessenger(this);
//default kinematic
fRandomDirection = false;
fPolarized = false;
fPolarization = 0.;
// default kinematic
//
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle = particleTable->FindParticle("e+");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleTime(0.0*ns);
fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm,0.0*cm,0.0*cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
fParticleGun->SetParticleEnergy(500.0*keV);
fParticleGun->SetParticleTime(0.0 * ns);
fParticleGun->SetParticlePosition(
G4ThreeVector(0.0 * cm, 0.0 * cm, 0.0 * cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1., 0., 0.));
fParticleGun->SetParticleEnergy(500.0 * keV);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -78,6 +83,24 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
if(fRandomDirection)
{
G4double theta = CLHEP::halfpi * G4UniformRand();
G4double phi = CLHEP::twopi * G4UniformRand();
G4double x = std::cos(theta);
G4double y = std::sin(theta) * std::sin(phi);
G4double z = std::sin(theta) * std::cos(phi);
G4ThreeVector dir(x, y, z);
fParticleGun->SetParticleMomentumDirection(dir);
}
if(fParticleGun->GetParticleDefinition() ==
G4OpticalPhoton::OpticalPhotonDefinition())
{
if(fPolarized)
SetOptPhotonPolar(fPolarization);
else
SetOptPhotonPolar();
}
fParticleGun->GeneratePrimaryVertex(anEvent);
}
@@ -85,32 +108,44 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
void PrimaryGeneratorAction::SetOptPhotonPolar()
{
G4double angle = G4UniformRand() * 360.0*deg;
SetOptPhotonPolar(angle);
G4double angle = G4UniformRand() * 360.0 * deg;
SetOptPhotonPolar(angle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::SetOptPhotonPolar(G4double angle)
{
if (fParticleGun->GetParticleDefinition()->GetParticleName()!="opticalphoton")
{
G4cout << "--> warning from PrimaryGeneratorAction::SetOptPhotonPolar() :"
"the particleGun is not an opticalphoton" << G4endl;
return;
}
if(fParticleGun->GetParticleDefinition() !=
G4OpticalPhoton::OpticalPhotonDefinition())
{
G4ExceptionDescription ed;
ed << "The particleGun is not an opticalphoton.";
G4Exception("PrimaryGeneratorAction::SetOptPhotonPolar", "OpNovice2_004",
JustWarning, ed);
return;
}
G4ThreeVector normal (1., 0., 0.);
G4ThreeVector kphoton = fParticleGun->GetParticleMomentumDirection();
G4ThreeVector product = normal.cross(kphoton);
G4double modul2 = product*product;
G4ThreeVector e_perpend (0., 0., 1.);
if (modul2 > 0.) e_perpend = (1./std::sqrt(modul2))*product;
G4ThreeVector e_paralle = e_perpend.cross(kphoton);
G4ThreeVector polar = std::cos(angle)*e_paralle + std::sin(angle)*e_perpend;
fParticleGun->SetParticlePolarization(polar);
fPolarized = true;
fPolarization = angle;
G4ThreeVector normal(1., 0., 0.);
G4ThreeVector kphoton = fParticleGun->GetParticleMomentumDirection();
G4ThreeVector product = normal.cross(kphoton);
G4double modul2 = product * product;
G4ThreeVector e_perpend(0., 0., 1.);
if(modul2 > 0.)
e_perpend = (1. / std::sqrt(modul2)) * product;
G4ThreeVector e_paralle = e_perpend.cross(kphoton);
G4ThreeVector polar =
std::cos(angle) * e_paralle + std::sin(angle) * e_perpend;
fParticleGun->SetParticlePolarization(polar);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::SetRandomDirection(G4bool val)
{
fRandomDirection = val;
}
@@ -35,27 +35,32 @@
#include "PrimaryGeneratorAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithABool.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorMessenger::
PrimaryGeneratorMessenger(PrimaryGeneratorAction* Gun)
: G4UImessenger(),
fPrimaryAction(Gun)
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
PrimaryGeneratorAction* Gun)
: G4UImessenger()
, fPrimaryAction(Gun)
{
fGunDir = new G4UIdirectory("/opnovice2/gun/");
fGunDir->SetGuidance("PrimaryGenerator control");
fPolarCmd =
new G4UIcmdWithADoubleAndUnit("/opnovice2/gun/optPhotonPolar",this);
new G4UIcmdWithADoubleAndUnit("/opnovice2/gun/optPhotonPolar", this);
fPolarCmd->SetGuidance("Set linear polarization");
fPolarCmd->SetGuidance(" angle w.r.t. (k,n) plane");
fPolarCmd->SetParameterName("angle",true);
fPolarCmd->SetParameterName("angle", true);
fPolarCmd->SetUnitCategory("Angle");
fPolarCmd->SetDefaultValue(-360.0);
fPolarCmd->SetDefaultUnit("deg");
fPolarCmd->AvailableForStates(G4State_Idle);
fRandomDirectionCmd =
new G4UIcmdWithABool("/opnovice2/gun/randomDirection", this);
fRandomDirectionCmd->AvailableForStates(G4State_Idle, G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -64,20 +69,29 @@ PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
{
delete fPolarCmd;
delete fGunDir;
delete fRandomDirectionCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorMessenger::SetNewValue(
G4UIcommand* command, G4String newValue)
void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if (command == fPolarCmd) {
G4double angle = fPolarCmd->GetNewDoubleValue(newValue);
if (angle == -360.0*deg) {
fPrimaryAction->SetOptPhotonPolar();
} else {
fPrimaryAction->SetOptPhotonPolar(angle);
}
if(command == fPolarCmd)
{
G4double angle = fPolarCmd->GetNewDoubleValue(newValue);
if(angle == -360.0 * deg)
{
fPrimaryAction->SetOptPhotonPolar();
}
else
{
fPrimaryAction->SetOptPhotonPolar(angle);
}
}
else if(command == fRandomDirectionCmd)
{
fPrimaryAction->SetRandomDirection(true);
}
}
+404 -134
View File
@@ -26,62 +26,69 @@
/// \file optical/OpNovice2/src/Run.cc
/// \brief Implementation of the Run class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include <numeric>
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "HistoManager.hh"
#include "G4OpBoundaryProcess.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include <numeric>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run()
: G4Run()
Run::Run()
: G4Run()
{
fParticle = nullptr;
fEkin = -1.;
fCerenkovEnergy = 0.0;
fScintEnergy = 0.0;
fParticle = nullptr;
fEkin = -1.;
fPolarized = false;
fPolarization = 0.;
fCerenkovEnergy = 0.0;
fScintEnergy = 0.0;
fWLSAbsorptionEnergy = 0.0;
fWLSEmissionEnergy = 0.0;
fWLS2AbsorptionEnergy = 0.0;
fWLS2EmissionEnergy = 0.0;
fCerenkovCount = 0;
fScintCount = 0;
fCerenkovCount = 0;
fScintCount = 0;
fWLSAbsorptionCount = 0;
fWLSEmissionCount = 0;
fWLS2AbsorptionCount = 0;
fWLS2EmissionCount = 0;
fRayleighCount = 0;
fRayleighCount = 0;
fOpAbsorption = 0;
fOpAbsorption = 0;
fOpAbsorptionPrior = 0;
fTotalSurface = 0;
fBoundaryProcs.clear();
fBoundaryProcs.resize(40);
for (G4int i = 0; i < 40; ++i) {
for(G4int i = 0; i < 40; ++i)
{
fBoundaryProcs[i] = 0;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::~Run()
{}
Run::~Run() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy,
G4bool polarized, G4double polarization)
{
fParticle = particle;
fEkin = energy;
fParticle = particle;
fEkin = energy;
fPolarized = polarized;
fPolarization = polarization;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -90,30 +97,33 @@ void Run::Merge(const G4Run* run)
const Run* localRun = static_cast<const Run*>(run);
// pass information about primary particle
fParticle = localRun->fParticle;
fEkin = localRun->fEkin;
fParticle = localRun->fParticle;
fEkin = localRun->fEkin;
fPolarized = localRun->fPolarized;
fPolarization = localRun->fPolarization;
fCerenkovEnergy += localRun->fCerenkovEnergy;
fScintEnergy += localRun->fScintEnergy;
fWLSAbsorptionEnergy += localRun->fWLSAbsorptionEnergy;
fWLSEmissionEnergy += localRun->fWLSEmissionEnergy;
fScintEnergy += localRun->fScintEnergy;
fWLSAbsorptionEnergy += localRun->fWLSAbsorptionEnergy;
fWLSEmissionEnergy += localRun->fWLSEmissionEnergy;
fWLS2AbsorptionEnergy += localRun->fWLS2AbsorptionEnergy;
fWLS2EmissionEnergy += localRun->fWLS2EmissionEnergy;
fWLS2EmissionEnergy += localRun->fWLS2EmissionEnergy;
fCerenkovCount += localRun->fCerenkovCount;
fScintCount += localRun->fScintCount;
fWLSAbsorptionCount += localRun->fWLSAbsorptionCount;
fWLSEmissionCount += localRun->fWLSEmissionCount;
fCerenkovCount += localRun->fCerenkovCount;
fScintCount += localRun->fScintCount;
fWLSAbsorptionCount += localRun->fWLSAbsorptionCount;
fWLSEmissionCount += localRun->fWLSEmissionCount;
fWLS2AbsorptionCount += localRun->fWLS2AbsorptionCount;
fWLS2EmissionCount += localRun->fWLS2EmissionCount;
fRayleighCount += localRun->fRayleighCount;
fTotalSurface += localRun->fTotalSurface;
fOpAbsorption += localRun->fOpAbsorption;
fWLS2EmissionCount += localRun->fWLS2EmissionCount;
fRayleighCount += localRun->fRayleighCount;
fTotalSurface += localRun->fTotalSurface;
fOpAbsorption += localRun->fOpAbsorption;
fOpAbsorptionPrior += localRun->fOpAbsorptionPrior;
for (size_t i = 0; i < fBoundaryProcs.size(); ++i) {
for(size_t i = 0; i < fBoundaryProcs.size(); ++i)
{
fBoundaryProcs[i] += localRun->fBoundaryProcs[i];
}
@@ -123,82 +133,177 @@ void Run::Merge(const G4Run* run)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::EndOfRun()
{
if (numberOfEvent == 0) return;
G4double TotNbofEvents = (G4double)numberOfEvent;
if(numberOfEvent == 0)
return;
G4double TotNbofEvents = (G4double) numberOfEvent;
const DetectorConstruction* det = (const DetectorConstruction*)
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4AnalysisManager* analysisMan = G4AnalysisManager::Instance();
G4int id = analysisMan->GetH1Id("Cerenkov spectrum");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("Scintillation spectrum");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("Scintillation time");
analysisMan->SetH1XAxisTitle(id, "Creation time [ns]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS abs");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS em");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS time");
analysisMan->SetH1XAxisTitle(id, "Creation time [ns]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS2 abs");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS2 em");
analysisMan->SetH1XAxisTitle(id, "Energy [eV]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("WLS2 time");
analysisMan->SetH1XAxisTitle(id, "Creation time [ns]");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("bdry status");
analysisMan->SetH1XAxisTitle(id, "Status code");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("x_backward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("y_backward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("z_backward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("x_forward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("y_forward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("z_forward");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("x_fresnel");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("y_fresnel");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("z_fresnel");
analysisMan->SetH1XAxisTitle(id, "Direction cosine");
analysisMan->SetH1YAxisTitle(id, "Number of photons");
id = analysisMan->GetH1Id("Transmitted");
analysisMan->SetH1XAxisTitle(id, "Angle [deg]");
analysisMan->SetH1YAxisTitle(id, "Fraction of photons");
id = analysisMan->GetH1Id("Reflected");
analysisMan->SetH1XAxisTitle(id, "Angle [deg]");
analysisMan->SetH1YAxisTitle(id, "Fraction of photons");
const DetectorConstruction* det =
(const DetectorConstruction*) (G4RunManager::GetRunManager()
->GetUserDetectorConstruction());
std::ios::fmtflags mode = G4cout.flags();
G4int prec = G4cout.precision(2);
G4int prec = G4cout.precision(2);
G4cout << "\n Run Summary\n";
G4cout << "---------------------------------\n";
G4cout << "Primary particle was: " << fParticle->GetParticleName()
G4cout << "---------------------------------\n";
G4cout << "Primary particle was: " << fParticle->GetParticleName()
<< " with energy " << G4BestUnit(fEkin, "Energy") << "." << G4endl;
G4cout << "Number of events: " << numberOfEvent << G4endl;
G4cout << "Material of world: " << det->GetWorldMaterial()->GetName()
<< G4endl;
G4cout << "Material of tank: " << det->GetTankMaterial()->GetName()
<< G4endl << G4endl;
G4cout << "Material of tank: " << det->GetTankMaterial()->GetName() << G4endl
<< G4endl;
if (fParticle->GetParticleName() != "opticalphoton") {
G4cout << "Average energy of Cerenkov photons created per event: "
<< (fCerenkovEnergy/eV)/TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of Cerenkov photons created per event: "
<< fCerenkovCount/TotNbofEvents << G4endl;
if (fCerenkovCount > 0) {
G4cout << " Average energy per photon: "
<< (fCerenkovEnergy/eV)/fCerenkovCount << " eV." << G4endl;
if(fParticle->GetParticleName() != "opticalphoton")
{
G4cout << "Average energy of Cerenkov photons created per event: "
<< (fCerenkovEnergy / eV) / TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of Cerenkov photons created per event: "
<< fCerenkovCount / TotNbofEvents << G4endl;
if(fCerenkovCount > 0)
{
G4cout << " Average energy per photon: "
<< (fCerenkovEnergy / eV) / fCerenkovCount << " eV." << G4endl;
}
G4cout << "Average energy of scintillation photons created per event: "
<< (fScintEnergy/eV)/TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of scintillation photons created per event: "
<< fScintCount/TotNbofEvents << G4endl;
if (fScintCount > 0) {
G4cout << " Average energy per photon: "
<< (fScintEnergy/eV)/fScintCount << " eV." << G4endl;
G4cout << "Average energy of scintillation photons created per event: "
<< (fScintEnergy / eV) / TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of scintillation photons created per event: "
<< fScintCount / TotNbofEvents << G4endl;
if(fScintCount > 0)
{
G4cout << " Average energy per photon: "
<< (fScintEnergy / eV) / fScintCount << " eV." << G4endl;
}
}
G4cout << "Average number of photons absorbed by WLS per event: "
<< fWLSAbsorptionCount/G4double(TotNbofEvents) << " " << G4endl;
if (fWLSAbsorptionCount > 0) {
G4cout << " Average energy per photon: "
<< (fWLSAbsorptionEnergy/eV)/fWLSAbsorptionCount << " eV." <<G4endl;
G4cout << "Average number of photons absorbed by WLS per event: "
<< fWLSAbsorptionCount / G4double(TotNbofEvents) << " " << G4endl;
if(fWLSAbsorptionCount > 0)
{
G4cout << " Average energy per photon: "
<< (fWLSAbsorptionEnergy / eV) / fWLSAbsorptionCount << " eV."
<< G4endl;
}
G4cout << "Average number of photons created by WLS per event: "
<< fWLSEmissionCount/TotNbofEvents << G4endl;
if (fWLSEmissionCount > 0) {
G4cout << " Average energy per photon: "
<< (fWLSEmissionEnergy/eV)/fWLSEmissionCount << " eV." << G4endl;
G4cout << "Average number of photons created by WLS per event: "
<< fWLSEmissionCount / TotNbofEvents << G4endl;
if(fWLSEmissionCount > 0)
{
G4cout << " Average energy per photon: "
<< (fWLSEmissionEnergy / eV) / fWLSEmissionCount << " eV." << G4endl;
}
G4cout << "Average energy of WLS photons created per event: "
<< (fWLSEmissionEnergy/eV)/TotNbofEvents << " eV." << G4endl;
G4cout << "Average energy of WLS photons created per event: "
<< (fWLSEmissionEnergy / eV) / TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of photons absorbed by WLS2 per event: "
<< fWLS2AbsorptionCount/G4double(TotNbofEvents) << " " << G4endl;
if (fWLS2AbsorptionCount > 0) {
G4cout << " Average energy per photon: "
<< (fWLS2AbsorptionEnergy/eV)/fWLS2AbsorptionCount << " eV." <<G4endl;
G4cout << "Average number of photons absorbed by WLS2 per event: "
<< fWLS2AbsorptionCount / G4double(TotNbofEvents) << " " << G4endl;
if(fWLS2AbsorptionCount > 0)
{
G4cout << " Average energy per photon: "
<< (fWLS2AbsorptionEnergy / eV) / fWLS2AbsorptionCount << " eV."
<< G4endl;
}
G4cout << "Average number of photons created by WLS2 per event: "
<< fWLS2EmissionCount/TotNbofEvents << G4endl;
if (fWLS2EmissionCount > 0) {
G4cout << " Average energy per photon: "
<< (fWLS2EmissionEnergy/eV)/fWLS2EmissionCount << " eV." << G4endl;
G4cout << "Average number of photons created by WLS2 per event: "
<< fWLS2EmissionCount / TotNbofEvents << G4endl;
if(fWLS2EmissionCount > 0)
{
G4cout << " Average energy per photon: "
<< (fWLS2EmissionEnergy / eV) / fWLS2EmissionCount << " eV."
<< G4endl;
}
G4cout << "Average energy of WLS2 photons created per event: "
<< (fWLS2EmissionEnergy/eV)/TotNbofEvents << " eV." << G4endl;
G4cout << "Average energy of WLS2 photons created per event: "
<< (fWLS2EmissionEnergy / eV) / TotNbofEvents << " eV." << G4endl;
G4cout << "Average number of OpRayleigh per event: "
<< fRayleighCount/TotNbofEvents << G4endl;
<< fRayleighCount / TotNbofEvents << G4endl;
G4cout << "Average number of OpAbsorption per event: "
<< fOpAbsorption/TotNbofEvents << G4endl;
G4cout <<
"\nSurface events (on +X surface, maximum one per photon) this run:"
<< fOpAbsorption / TotNbofEvents << G4endl;
G4cout << "\nSurface events (on +X surface, maximum one per photon) this run:"
<< G4endl;
G4cout << "# of primary particles: " << std::setw(8) << TotNbofEvents
<< G4endl;
@@ -206,163 +311,202 @@ void Run::EndOfRun()
<< fOpAbsorptionPrior << G4endl;
G4cout << "Total # of surface events: " << std::setw(8) << fTotalSurface
<< G4endl;
if (fParticle->GetParticleName() == "opticalphoton") {
if(fParticle->GetParticleName() == "opticalphoton")
{
G4cout << "Unaccounted for: " << std::setw(8)
<< fTotalSurface + fOpAbsorptionPrior - TotNbofEvents << G4endl;
<< fTotalSurface + fOpAbsorptionPrior - TotNbofEvents << G4endl;
}
G4cout << "\nSurface events by process:" << G4endl;
if (fBoundaryProcs[Transmission] > 0) {
if(fBoundaryProcs[Transmission] > 0)
{
G4cout << " Transmission: " << std::setw(8)
<< fBoundaryProcs[Transmission] << G4endl;
}
if (fBoundaryProcs[FresnelRefraction] > 0) {
if(fBoundaryProcs[FresnelRefraction] > 0)
{
G4cout << " Fresnel refraction: " << std::setw(8)
<< fBoundaryProcs[FresnelRefraction] << G4endl;
}
if (fBoundaryProcs[FresnelReflection] > 0) {
if(fBoundaryProcs[FresnelReflection] > 0)
{
G4cout << " Fresnel reflection: " << std::setw(8)
<< fBoundaryProcs[FresnelReflection] << G4endl;
<< fBoundaryProcs[FresnelReflection] << G4endl;
}
if (fBoundaryProcs[TotalInternalReflection] > 0) {
if(fBoundaryProcs[TotalInternalReflection] > 0)
{
G4cout << " Total internal reflection: " << std::setw(8)
<< fBoundaryProcs[TotalInternalReflection] << G4endl;
}
if (fBoundaryProcs[LambertianReflection] > 0) {
if(fBoundaryProcs[LambertianReflection] > 0)
{
G4cout << " Lambertian reflection: " << std::setw(8)
<< fBoundaryProcs[LambertianReflection] << G4endl;
}
if (fBoundaryProcs[LobeReflection] > 0) {
if(fBoundaryProcs[LobeReflection] > 0)
{
G4cout << " Lobe reflection: " << std::setw(8)
<< fBoundaryProcs[LobeReflection] << G4endl;
}
if (fBoundaryProcs[SpikeReflection] > 0) {
if(fBoundaryProcs[SpikeReflection] > 0)
{
G4cout << " Spike reflection: " << std::setw(8)
<< fBoundaryProcs[SpikeReflection] << G4endl;
}
if (fBoundaryProcs[BackScattering] > 0) {
if(fBoundaryProcs[BackScattering] > 0)
{
G4cout << " Backscattering: " << std::setw(8)
<< fBoundaryProcs[BackScattering] << G4endl;
}
if (fBoundaryProcs[Absorption] > 0) {
if(fBoundaryProcs[Absorption] > 0)
{
G4cout << " Absorption: " << std::setw(8)
<< fBoundaryProcs[Absorption] << G4endl;
}
if (fBoundaryProcs[Detection] > 0) {
if(fBoundaryProcs[Detection] > 0)
{
G4cout << " Detection: " << std::setw(8)
<< fBoundaryProcs[Detection] << G4endl;
}
if (fBoundaryProcs[NotAtBoundary] > 0) {
if(fBoundaryProcs[NotAtBoundary] > 0)
{
G4cout << " Not at boundary: " << std::setw(8)
<< fBoundaryProcs[NotAtBoundary] << G4endl;
}
if (fBoundaryProcs[SameMaterial] > 0) {
if(fBoundaryProcs[SameMaterial] > 0)
{
G4cout << " Same material: " << std::setw(8)
<< fBoundaryProcs[SameMaterial] << G4endl;
}
if (fBoundaryProcs[StepTooSmall] > 0) {
if(fBoundaryProcs[StepTooSmall] > 0)
{
G4cout << " Step too small: " << std::setw(8)
<< fBoundaryProcs[StepTooSmall] << G4endl;
}
if (fBoundaryProcs[NoRINDEX] > 0) {
if(fBoundaryProcs[NoRINDEX] > 0)
{
G4cout << " No RINDEX: " << std::setw(8)
<< fBoundaryProcs[NoRINDEX] << G4endl;
}
// LBNL polished
if (fBoundaryProcs[PolishedLumirrorAirReflection] > 0) {
if(fBoundaryProcs[PolishedLumirrorAirReflection] > 0)
{
G4cout << " Polished Lumirror Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedLumirrorAirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedLumirrorGlueReflection] > 0) {
if(fBoundaryProcs[PolishedLumirrorGlueReflection] > 0)
{
G4cout << " Polished Lumirror Glue reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedLumirrorGlueReflection] << G4endl;
}
if (fBoundaryProcs[PolishedAirReflection] > 0) {
if(fBoundaryProcs[PolishedAirReflection] > 0)
{
G4cout << " Polished Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedAirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedTeflonAirReflection] > 0) {
if(fBoundaryProcs[PolishedTeflonAirReflection] > 0)
{
G4cout << " Polished Teflon Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedTeflonAirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedTiOAirReflection] > 0) {
if(fBoundaryProcs[PolishedTiOAirReflection] > 0)
{
G4cout << " Polished TiO Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedTiOAirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedTyvekAirReflection] > 0) {
if(fBoundaryProcs[PolishedTyvekAirReflection] > 0)
{
G4cout << " Polished Tyvek Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedTyvekAirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedVM2000AirReflection] > 0) {
if(fBoundaryProcs[PolishedVM2000AirReflection] > 0)
{
G4cout << " Polished VM2000 Air reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedVM2000AirReflection] << G4endl;
}
if (fBoundaryProcs[PolishedVM2000GlueReflection] > 0) {
if(fBoundaryProcs[PolishedVM2000GlueReflection] > 0)
{
G4cout << " Polished VM2000 Glue reflection: " << std::setw(8)
<< fBoundaryProcs[PolishedVM2000GlueReflection] << G4endl;
}
// LBNL etched
if (fBoundaryProcs[EtchedLumirrorAirReflection] > 0) {
if(fBoundaryProcs[EtchedLumirrorAirReflection] > 0)
{
G4cout << " Etched Lumirror Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedLumirrorAirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedLumirrorGlueReflection] > 0) {
if(fBoundaryProcs[EtchedLumirrorGlueReflection] > 0)
{
G4cout << " Etched Lumirror Glue reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedLumirrorGlueReflection] << G4endl;
}
if (fBoundaryProcs[EtchedAirReflection] > 0) {
if(fBoundaryProcs[EtchedAirReflection] > 0)
{
G4cout << " Etched Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedAirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedTeflonAirReflection] > 0) {
if(fBoundaryProcs[EtchedTeflonAirReflection] > 0)
{
G4cout << " Etched Teflon Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedTeflonAirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedTiOAirReflection] > 0) {
if(fBoundaryProcs[EtchedTiOAirReflection] > 0)
{
G4cout << " Etched TiO Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedTiOAirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedTyvekAirReflection] > 0) {
if(fBoundaryProcs[EtchedTyvekAirReflection] > 0)
{
G4cout << " Etched Tyvek Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedTyvekAirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedVM2000AirReflection] > 0) {
if(fBoundaryProcs[EtchedVM2000AirReflection] > 0)
{
G4cout << " Etched VM2000 Air reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedVM2000AirReflection] << G4endl;
}
if (fBoundaryProcs[EtchedVM2000GlueReflection] > 0) {
if(fBoundaryProcs[EtchedVM2000GlueReflection] > 0)
{
G4cout << " Etched VM2000 Glue reflection: " << std::setw(8)
<< fBoundaryProcs[EtchedVM2000GlueReflection] << G4endl;
}
// LBNL ground
if (fBoundaryProcs[GroundLumirrorAirReflection] > 0) {
if(fBoundaryProcs[GroundLumirrorAirReflection] > 0)
{
G4cout << " Ground Lumirror Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundLumirrorAirReflection] << G4endl;
}
if (fBoundaryProcs[GroundLumirrorGlueReflection] > 0) {
if(fBoundaryProcs[GroundLumirrorGlueReflection] > 0)
{
G4cout << " Ground Lumirror Glue reflection: " << std::setw(8)
<< fBoundaryProcs[GroundLumirrorGlueReflection] << G4endl;
}
if (fBoundaryProcs[GroundAirReflection] > 0) {
if(fBoundaryProcs[GroundAirReflection] > 0)
{
G4cout << " Ground Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundAirReflection] << G4endl;
}
if (fBoundaryProcs[GroundTeflonAirReflection] > 0) {
if(fBoundaryProcs[GroundTeflonAirReflection] > 0)
{
G4cout << " Ground Teflon Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundTeflonAirReflection] << G4endl;
}
if (fBoundaryProcs[GroundTiOAirReflection] > 0) {
if(fBoundaryProcs[GroundTiOAirReflection] > 0)
{
G4cout << " Ground TiO Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundTiOAirReflection] << G4endl;
}
if (fBoundaryProcs[GroundTyvekAirReflection] > 0) {
if(fBoundaryProcs[GroundTyvekAirReflection] > 0)
{
G4cout << " Ground Tyvek Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundTyvekAirReflection] << G4endl;
}
if (fBoundaryProcs[GroundVM2000AirReflection] > 0) {
if(fBoundaryProcs[GroundVM2000AirReflection] > 0)
{
G4cout << " Ground VM2000 Air reflection: " << std::setw(8)
<< fBoundaryProcs[GroundVM2000AirReflection] << G4endl;
}
if (fBoundaryProcs[GroundVM2000GlueReflection] > 0) {
if(fBoundaryProcs[GroundVM2000GlueReflection] > 0)
{
G4cout << " Ground VM2000 Glue reflection: " << std::setw(8)
<< fBoundaryProcs[GroundVM2000GlueReflection] << G4endl;
}
@@ -372,8 +516,134 @@ void Run::EndOfRun()
G4cout << " Unaccounted for: " << std::setw(8)
<< fTotalSurface - sum << G4endl;
G4cout << "---------------------------------\n";
G4cout << "---------------------------------\n";
G4cout.setf(mode, std::ios::floatfield);
G4cout.precision(prec);
G4int histo_id_trans = analysisMan->GetH1Id("Transmitted");
G4int histo_id_refl = analysisMan->GetH1Id("Reflected");
if(analysisMan->GetH1Activation(histo_id_trans))
{
if(fPolarized)
{
G4double rindex1 = det->GetTankMaterial()
->GetMaterialPropertiesTable()
->GetProperty(kRINDEX)
->Value(fEkin);
G4double rindex2 = det->GetWorldMaterial()
->GetMaterialPropertiesTable()
->GetProperty(kRINDEX)
->Value(fEkin);
G4H1* histo_trans = analysisMan->GetH1(histo_id_trans);
G4H1* histo_refl = analysisMan->GetH1(histo_id_refl);
std::vector<G4double> trans;
std::vector<G4double> refl;
std::vector<G4double> tot;
for(size_t i = 0; i < histo_trans->axis().bins(); ++i)
{
trans.push_back(histo_trans->bin_height(i));
refl.push_back(histo_refl->bin_height(i));
tot.push_back(histo_trans->bin_height(i) + histo_refl->bin_height(i));
}
// find Brewster angle: Rp = 0
// need enough statistics for this method to work
G4double min_angle = -1.;
G4double min_val = DBL_MAX;
G4double bin_width = 0.;
for(size_t i = 0; i < refl.size(); ++i)
{
if(refl[i] < min_val)
{
min_val = refl[i];
min_angle = histo_refl->axis().bin_lower_edge(i);
bin_width = histo_refl->axis().bin_upper_edge(i) -
histo_refl->axis().bin_lower_edge(i);
min_angle += bin_width / 2.;
}
}
G4cout << "Polarization of primary optical photons: "
<< fPolarization / deg << " deg." << G4endl;
if(fPolarization == 0.0)
{
G4cout << "Reflectance shows a minimum at: " << min_angle << " +/- "
<< bin_width / 2;
G4cout << " deg. Expected Brewster angle: "
<< (360. / CLHEP::twopi) * std::atan(rindex2 / rindex1)
<< " deg. " << G4endl;
}
// find angle of total internal reflection: T -> 0
// last bin for T > 0
min_angle = -1.;
min_val = DBL_MAX;
for(size_t i = 0; i < histo_trans->axis().bins() - 1; ++i)
{
if(histo_trans->bin_height(i) > 0. &&
histo_trans->bin_height(i + 1) == 0.)
{
min_angle = histo_trans->axis().bin_lower_edge(i);
bin_width = histo_refl->axis().bin_upper_edge(i) -
histo_refl->axis().bin_lower_edge(i);
min_angle += bin_width / 2.;
break;
}
}
G4cout << "Transmission goes to 0 at: " << min_angle << " +/- "
<< bin_width / 2. << " deg."
<< " Expected: "
<< (360. / CLHEP::twopi) * std::asin(rindex2 / rindex1) << " deg."
<< G4endl;
// Normalize the transmission/reflection histos so that max is 1.
// Only if x values are the same
if((analysisMan->GetH1Nbins(histo_id_trans) ==
analysisMan->GetH1Nbins(histo_id_refl)) &&
(analysisMan->GetH1Xmin(histo_id_trans) ==
analysisMan->GetH1Xmin(histo_id_refl)) &&
(analysisMan->GetH1Xmax(histo_id_trans) ==
analysisMan->GetH1Xmax(histo_id_refl)))
{
unsigned int ent;
G4double sw;
G4double sw2;
G4double sx2;
G4double sx2w;
for(size_t bin = 0; bin < histo_trans->axis().bins(); ++bin)
{
// "bin+1" below because bin 0 is underflow bin
// NB. We are ignoring underflow/overflow bins
histo_trans->get_bin_content(bin + 1, ent, sw, sw2, sx2, sx2w);
if(tot[bin] > 0)
{
sw /= tot[bin];
// bin error is sqrt(sw2)
sw2 /= (tot[bin] * tot[bin]);
sx2 /= (tot[bin] * tot[bin]);
sx2w /= (tot[bin] * tot[bin]);
histo_trans->set_bin_content(bin + 1, ent, sw, sw2, sx2, sx2w);
}
}
for(size_t bin = 0; bin < histo_refl->axis().bins(); ++bin)
{
histo_refl->get_bin_content(bin + 1, ent, sw, sw2, sx2, sx2w);
if(tot[bin] > 0)
{
sw /= tot[bin];
// bin error is sqrt(sw2)
sw2 /= (tot[bin] * tot[bin]);
sx2 /= (tot[bin] * tot[bin]);
sx2w /= (tot[bin] * tot[bin]);
histo_refl->set_bin_content(bin + 1, ent, sw, sw2, sx2, sx2w);
}
}
}
else
{
G4cout << "Not going to normalize transmission and reflection "
<< "histograms because bins are not the same." << G4endl;
}
}
}
}
@@ -26,40 +26,33 @@
/// \file optical/OpNovice2/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Make this appear first!
#include "G4Timer.hh"
#include "RunAction.hh"
#include "HistoManager.hh"
#include "PrimaryGeneratorAction.hh"
#include "Run.hh"
#include "G4Run.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(PrimaryGeneratorAction* prim)
: G4UserRunAction(),
fTimer(nullptr),
fRun(nullptr),
fHistoManager(nullptr),
fPrimary(prim)
: G4UserRunAction()
, fRun(nullptr)
, fHistoManager(nullptr)
, fPrimary(prim)
{
fTimer = new G4Timer;
fHistoManager = new HistoManager();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{
delete fTimer;
delete fHistoManager;
}
RunAction::~RunAction() { delete fHistoManager; }
G4Run* RunAction::GenerateRun()
{
@@ -69,39 +62,198 @@ G4Run* RunAction::GenerateRun()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run* aRun)
void RunAction::BeginOfRunAction(const G4Run*)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
if (fPrimary) {
G4ParticleDefinition* particle =
if(fPrimary)
{
G4ParticleDefinition* particle =
fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
fRun->SetPrimary(particle, energy);
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
G4bool polarized = fPrimary->GetPolarized();
G4double polarization = fPrimary->GetPolarization();
fRun->SetPrimary(particle, energy, polarized, polarization);
}
//histograms
// histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if (analysisManager->IsActive()) {
if(analysisManager->IsActive())
{
analysisManager->OpenFile();
}
fTimer->Start();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* aRun)
void RunAction::EndOfRunAction(const G4Run*)
{
fTimer->Stop();
G4cout << "number of event = " << aRun->GetNumberOfEvent()
<< " " << *fTimer << G4endl;
if(isMaster)
fRun->EndOfRun();
if (isMaster) fRun->EndOfRun();
// save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if (analysisManager->IsActive()) {
G4cout << G4endl << " Histogram statistics for the ";
if(isMaster)
{
G4cout << "entire run:" << G4endl << G4endl;
}
else
{
G4cout << "local thread:" << G4endl << G4endl;
}
G4int id = analysisManager->GetH1Id("Cerenkov spectrum");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Cerenkov spectrum: mean = "
<< analysisManager->GetH1(id)->mean()
<< " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV."
<< G4endl;
}
id = analysisManager->GetH1Id("Scintillation spectrum");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Scintillation spectrum: mean = "
<< analysisManager->GetH1(id)->mean()
<< " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV."
<< G4endl;
}
id = analysisManager->GetH1Id("Scintillation time");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Scintillation time: mean = "
<< analysisManager->GetH1(id)->mean()
<< " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS abs");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS absorption spectrum: mean = "
<< analysisManager->GetH1(id)->mean()
<< " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS em");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS emission spectrum: mean = "
<< analysisManager->GetH1(id)->mean()
<< " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS time");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS emission time: mean = "
<< analysisManager->GetH1(id)->mean()
<< " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS2 abs");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS emission time: mean = "
<< analysisManager->GetH1(id)->mean()
<< " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS2 em");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS2 emission spectrum: mean = "
<< analysisManager->GetH1(id)->mean()
<< " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV."
<< G4endl;
}
id = analysisManager->GetH1Id("WLS2 time");
if(analysisManager->GetH1Activation(id))
{
G4cout << " WLS2 emission time: mean = "
<< analysisManager->GetH1(id)->mean()
<< " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns."
<< G4endl;
}
id = analysisManager->GetH1Id("x_backward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " X momentum dir of backward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("y_backward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Y momentum dir of backward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("z_backward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Z momentum dir of backward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("x_forward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " X momentum dir of forward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("y_forward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Y momentum dir of forward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("z_forward");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Z momentum dir of forward-going photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("x_fresnel");
if(analysisManager->GetH1Activation(id))
{
G4cout << " X momentum dir of Fresnel-refracted photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("y_fresnel");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Y momentum dir of Fresnel-refracted photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("z_fresnel");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Z momentum dir of Fresnel-refracted photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("Transmitted");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Angle of transmitted photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
id = analysisManager->GetH1Id("Reflected");
if(analysisManager->GetH1Activation(id))
{
G4cout << " Angle of reflected photons: mean = "
<< analysisManager->GetH1(id)->mean()
<< "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
}
G4cout << G4endl;
if(analysisManager->IsActive())
{
analysisManager->Write();
analysisManager->CloseFile();
}
@@ -30,333 +30,358 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
//#include "EventAction.hh"
#include "HistoManager.hh"
#include "TrackInformation.hh"
#include "Run.hh"
#include "TrackInformation.hh"
#include "G4Cerenkov.hh"
#include "G4Scintillation.hh"
#include "G4OpBoundaryProcess.hh"
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4OpticalPhoton.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4SteppingManager.hh"
#include "G4RunManager.hh"
#include "G4Scintillation.hh"
#include "G4OpBoundaryProcess.hh"
#include "G4OpticalPhoton.hh"
#include "G4ProcessManager.hh"
#include "G4Step.hh"
#include "G4SteppingManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction()
: G4UserSteppingAction(),
fVerbose(0)
: G4UserSteppingAction()
, fVerbose(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::~SteppingAction()
{}
SteppingAction::~SteppingAction() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* step)
{
static G4ParticleDefinition* opticalphoton =
G4OpticalPhoton::OpticalPhotonDefinition();
G4OpticalPhoton::OpticalPhotonDefinition();
G4AnalysisManager* analysisMan = G4AnalysisManager::Instance();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
Run* run =
static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
G4Track* track = step->GetTrack();
G4Track* track = step->GetTrack();
G4StepPoint* endPoint = step->GetPostStepPoint();
G4StepPoint* startPoint = step->GetPreStepPoint();
const G4DynamicParticle* theParticle = track->GetDynamicParticle();
const G4ParticleDefinition* particleDef = theParticle->
GetParticleDefinition();
const G4ParticleDefinition* particleDef =
theParticle->GetParticleDefinition();
TrackInformation* trackInfo =
(TrackInformation*)(track->GetUserInformation());
(TrackInformation*) (track->GetUserInformation());
if (particleDef == opticalphoton) {
if(particleDef == opticalphoton)
{
const G4VProcess* pds = endPoint->GetProcessDefinedStep();
G4String procname = pds->GetProcessName();
if (procname.compare("OpAbsorption") == 0) {
G4String procname = pds->GetProcessName();
if(procname.compare("OpAbsorption") == 0)
{
run->AddOpAbsorption();
if (trackInfo->GetIsFirstTankX()) {
if(trackInfo->GetIsFirstTankX())
{
run->AddOpAbsorptionPrior();
}
}
else if (procname.compare("OpRayleigh") == 0) {
}
else if(procname.compare("OpRayleigh") == 0)
{
run->AddRayleigh();
}
else if (procname.compare("OpWLS") == 0) {
else if(procname.compare("OpWLS") == 0)
{
G4double en = track->GetKineticEnergy();
run->AddWLSAbsorption();
run->AddWLSAbsorptionEnergy(en);
analysisMan->FillH1(4, en/eV); //absorption energy
analysisMan->FillH1(4, en / eV); // absorption energy
// loop over secondaries, create statistics
//const std::vector<const G4Track*>* secondaries =
// const std::vector<const G4Track*>* secondaries =
auto secondaries = step->GetSecondaryInCurrentStep();
for (auto sec : *secondaries) {
for(auto sec : *secondaries)
{
en = sec->GetKineticEnergy();
run->AddWLSEmission();
run->AddWLSEmissionEnergy(en);
analysisMan->FillH1(5, en/eV); // emission energy
analysisMan->FillH1(5, en / eV); // emission energy
G4double time = sec->GetGlobalTime();
analysisMan->FillH1(6, time/ns);
analysisMan->FillH1(6, time / ns);
}
}
else if (procname.compare("OpWLS2") == 0) {
else if(procname.compare("OpWLS2") == 0)
{
G4double en = track->GetKineticEnergy();
run->AddWLS2Absorption();
run->AddWLS2AbsorptionEnergy(en);
analysisMan->FillH1(7, en/eV); //absorption energy
analysisMan->FillH1(7, en / eV); // absorption energy
// loop over secondaries, create statistics
//const std::vector<const G4Track*>* secondaries =
// const std::vector<const G4Track*>* secondaries =
auto secondaries = step->GetSecondaryInCurrentStep();
for (auto sec : *secondaries) {
for(auto sec : *secondaries)
{
en = sec->GetKineticEnergy();
run->AddWLS2Emission();
run->AddWLS2EmissionEnergy(en);
analysisMan->FillH1(8, en/eV); // emission energy
analysisMan->FillH1(8, en / eV); // emission energy
G4double time = sec->GetGlobalTime();
analysisMan->FillH1(9, time/ns);
analysisMan->FillH1(9, time / ns);
}
}
// optical process has endpt on bdry,
if (endPoint->GetStepStatus() == fGeomBoundary) {
// optical process has endpt on bdry,
if(endPoint->GetStepStatus() == fGeomBoundary)
{
G4ThreeVector m0 = startPoint->GetMomentumDirection();
G4ThreeVector m1 = endPoint->GetMomentumDirection();
G4OpBoundaryProcessStatus theStatus = Undefined;
G4ProcessManager* OpManager = opticalphoton->GetProcessManager();
G4int MAXofPostStepLoops =
OpManager->GetPostStepProcessVector()->entries();
G4ProcessVector* postStepDoItVector =
G4ProcessVector* postStepDoItVector =
OpManager->GetPostStepProcessVector(typeDoIt);
G4int n_proc = postStepDoItVector->entries();
if (trackInfo->GetIsFirstTankX()) {
if(trackInfo->GetIsFirstTankX())
{
G4ThreeVector momdir = endPoint->GetMomentumDirection();
G4double px1 = momdir.x();
G4double py1 = momdir.y();
G4double pz1 = momdir.z();
if (px1 < 0.) {
G4double px1 = momdir.x();
G4double py1 = momdir.y();
G4double pz1 = momdir.z();
if(px1 < 0.)
{
analysisMan->FillH1(11, px1);
analysisMan->FillH1(12, py1);
analysisMan->FillH1(13, pz1);
} else {
}
else
{
analysisMan->FillH1(14, px1);
analysisMan->FillH1(15, py1);
analysisMan->FillH1(16, pz1);
}
trackInfo->SetIsFirstTankX(false);
run->AddTotalSurface();
run->AddTotalSurface();
for (G4int i=0; i<MAXofPostStepLoops; ++i) {
for(G4int i = 0; i < n_proc; ++i)
{
G4VProcess* currentProcess = (*postStepDoItVector)[i];
G4OpBoundaryProcess* opProc =
G4OpBoundaryProcess* opProc =
dynamic_cast<G4OpBoundaryProcess*>(currentProcess);
if (opProc) {
theStatus = opProc->GetStatus();
if(opProc)
{
G4double angle = std::acos(startPoint->GetMomentumDirection().x());
theStatus = opProc->GetStatus();
analysisMan->FillH1(10, theStatus);
if (theStatus == Transmission) {
run->AddTransmission();
}
else if (theStatus == FresnelRefraction) {
run->AddFresnelRefraction();
analysisMan->FillH1(17, px1);
analysisMan->FillH1(18, py1);
analysisMan->FillH1(19, pz1);
}
else if (theStatus == FresnelReflection) {
run->AddFresnelReflection();
}
else if (theStatus == TotalInternalReflection) {
run->AddTotalInternalReflection();
}
else if (theStatus == LambertianReflection) {
run->AddLambertianReflection();
}
else if (theStatus == LobeReflection) {
run->AddLobeReflection();
}
else if (theStatus == SpikeReflection) {
run->AddSpikeReflection();
}
else if (theStatus == BackScattering) {
run->AddBackScattering();
}
else if (theStatus == Absorption) {
run->AddAbsorption();
}
else if (theStatus == Detection) {
run->AddDetection();
}
else if (theStatus == NotAtBoundary) {
run->AddNotAtBoundary();
}
else if (theStatus == SameMaterial) {
run->AddSameMaterial();
}
else if (theStatus == StepTooSmall) {
run->AddStepTooSmall();
}
else if (theStatus == NoRINDEX) {
run->AddNoRINDEX();
}
else if (theStatus == PolishedLumirrorAirReflection) {
run->AddPolishedLumirrorAirReflection();
}
else if (theStatus == PolishedLumirrorGlueReflection) {
run->AddPolishedLumirrorGlueReflection();
}
else if (theStatus == PolishedAirReflection) {
run->AddPolishedAirReflection();
}
else if (theStatus == PolishedTeflonAirReflection) {
run->AddPolishedTeflonAirReflection();
}
else if (theStatus == PolishedTiOAirReflection) {
run->AddPolishedTiOAirReflection();
}
else if (theStatus == PolishedTyvekAirReflection) {
run->AddPolishedTyvekAirReflection();
}
else if (theStatus == PolishedVM2000AirReflection) {
run->AddPolishedVM2000AirReflection();
}
else if (theStatus == PolishedVM2000GlueReflection) {
run->AddPolishedVM2000AirReflection();
}
else if (theStatus == EtchedLumirrorAirReflection) {
run->AddEtchedLumirrorAirReflection();
}
else if (theStatus == EtchedLumirrorGlueReflection) {
run->AddEtchedLumirrorGlueReflection();
}
else if (theStatus == EtchedAirReflection) {
run->AddEtchedAirReflection();
}
else if (theStatus == EtchedTeflonAirReflection) {
run->AddEtchedTeflonAirReflection();
}
else if (theStatus == EtchedTiOAirReflection) {
run->AddEtchedTiOAirReflection();
}
else if (theStatus == EtchedTyvekAirReflection) {
run->AddEtchedTyvekAirReflection();
}
else if (theStatus == EtchedVM2000AirReflection) {
run->AddEtchedVM2000AirReflection();
}
else if (theStatus == EtchedVM2000GlueReflection) {
run->AddEtchedVM2000AirReflection();
}
else if (theStatus == GroundLumirrorAirReflection) {
run->AddGroundLumirrorAirReflection();
}
else if (theStatus == GroundLumirrorGlueReflection) {
run->AddGroundLumirrorGlueReflection();
}
else if (theStatus == GroundAirReflection) {
run->AddGroundAirReflection();
}
else if (theStatus == GroundTeflonAirReflection) {
run->AddGroundTeflonAirReflection();
}
else if (theStatus == GroundTiOAirReflection) {
run->AddGroundTiOAirReflection();
}
else if (theStatus == GroundTyvekAirReflection) {
run->AddGroundTyvekAirReflection();
}
else if (theStatus == GroundVM2000AirReflection) {
run->AddGroundVM2000AirReflection();
}
else if (theStatus == GroundVM2000GlueReflection) {
run->AddGroundVM2000AirReflection();
}
else if (theStatus == Dichroic) {
run->AddDichroic();
}
else {
G4cout << "theStatus: " << theStatus
<< " was none of the above." << G4endl;
}
switch(theStatus)
{
case Transmission:
run->AddTransmission();
break;
case FresnelRefraction:
run->AddFresnelRefraction();
analysisMan->FillH1(17, px1);
analysisMan->FillH1(18, py1);
analysisMan->FillH1(19, pz1);
// transmission
analysisMan->FillH1(20, angle / deg);
break;
case FresnelReflection:
run->AddFresnelReflection();
analysisMan->FillH1(21, angle / deg);
break;
case TotalInternalReflection:
run->AddTotalInternalReflection();
analysisMan->FillH1(21, angle / deg);
break;
case LambertianReflection:
run->AddLambertianReflection();
break;
case LobeReflection:
run->AddLobeReflection();
break;
case SpikeReflection:
run->AddSpikeReflection();
break;
case BackScattering:
run->AddBackScattering();
break;
case Absorption:
run->AddAbsorption();
break;
case Detection:
run->AddDetection();
break;
case NotAtBoundary:
run->AddNotAtBoundary();
break;
case SameMaterial:
run->AddSameMaterial();
break;
case StepTooSmall:
run->AddStepTooSmall();
break;
case NoRINDEX:
run->AddNoRINDEX();
break;
case PolishedLumirrorAirReflection:
run->AddPolishedLumirrorAirReflection();
break;
case PolishedLumirrorGlueReflection:
run->AddPolishedLumirrorGlueReflection();
break;
case PolishedAirReflection:
run->AddPolishedAirReflection();
break;
case PolishedTeflonAirReflection:
run->AddPolishedTeflonAirReflection();
break;
case PolishedTiOAirReflection:
run->AddPolishedTiOAirReflection();
break;
case PolishedTyvekAirReflection:
run->AddPolishedTyvekAirReflection();
break;
case PolishedVM2000AirReflection:
run->AddPolishedVM2000AirReflection();
break;
case PolishedVM2000GlueReflection:
run->AddPolishedVM2000AirReflection();
break;
case EtchedLumirrorAirReflection:
run->AddEtchedLumirrorAirReflection();
break;
case EtchedLumirrorGlueReflection:
run->AddEtchedLumirrorGlueReflection();
break;
case EtchedAirReflection:
run->AddEtchedAirReflection();
break;
case EtchedTeflonAirReflection:
run->AddEtchedTeflonAirReflection();
break;
case EtchedTiOAirReflection:
run->AddEtchedTiOAirReflection();
break;
case EtchedTyvekAirReflection:
run->AddEtchedTyvekAirReflection();
break;
case EtchedVM2000AirReflection:
run->AddEtchedVM2000AirReflection();
break;
case EtchedVM2000GlueReflection:
run->AddEtchedVM2000AirReflection();
break;
case GroundLumirrorAirReflection:
run->AddGroundLumirrorAirReflection();
break;
case GroundLumirrorGlueReflection:
run->AddGroundLumirrorGlueReflection();
break;
case GroundAirReflection:
run->AddGroundAirReflection();
break;
case GroundTeflonAirReflection:
run->AddGroundTeflonAirReflection();
break;
case GroundTiOAirReflection:
run->AddGroundTiOAirReflection();
break;
case GroundTyvekAirReflection:
run->AddGroundTyvekAirReflection();
break;
case GroundVM2000AirReflection:
run->AddGroundVM2000AirReflection();
break;
case GroundVM2000GlueReflection:
run->AddGroundVM2000AirReflection();
break;
case Dichroic:
run->AddDichroic();
break;
default:
G4cout << "theStatus: " << theStatus
<< " was none of the above." << G4endl;
break;
}
}
}
}
}
}
else { // particle != opticalphoton
else
{ // particle != opticalphoton
// print how many Cerenkov and scint photons produced this step
// this demonstrates use of GetNumPhotons()
auto proc_man = track->GetDynamicParticle()->GetParticleDefinition()
->GetProcessManager();
G4int n_proc = proc_man->GetPostStepProcessVector()->entries();
auto proc_man =
track->GetDynamicParticle()->GetParticleDefinition()->GetProcessManager();
G4ProcessVector* proc_vec = proc_man->GetPostStepProcessVector(typeDoIt);
G4int n_proc = proc_vec->entries();
G4int n_scint = 0;
G4int n_cer = 0;
for (G4int i = 0; i < n_proc; ++i) {
for(G4int i = 0; i < n_proc; ++i)
{
G4String proc_name = (*proc_vec)[i]->GetProcessName();
if (proc_name.compare("Cerenkov") == 0) {
auto cer = (G4Cerenkov*)(*proc_vec)[i];
n_cer = cer->GetNumPhotons();
if(proc_name.compare("Cerenkov") == 0)
{
auto cer = (G4Cerenkov*) (*proc_vec)[i];
n_cer = cer->GetNumPhotons();
}
else if (proc_name.compare("Scintillation") == 0) {
auto scint = (G4Scintillation*)(*proc_vec)[i];
n_scint = scint->GetNumPhotons();
else if(proc_name.compare("Scintillation") == 0)
{
auto scint = (G4Scintillation*) (*proc_vec)[i];
n_scint = scint->GetNumPhotons();
}
}
if (fVerbose > 0) {
if (n_cer > 0 || n_scint > 0) {
G4cout << "In this step, " << n_cer
<< " Cerenkov and " << n_scint
if(fVerbose > 0)
{
if(n_cer > 0 || n_scint > 0)
{
G4cout << "In this step, " << n_cer << " Cerenkov and " << n_scint
<< " scintillation photons were produced." << G4endl;
}
}
// loop over secondaries, create statistics
const std::vector<const G4Track*>* secondaries =
step->GetSecondaryInCurrentStep();
step->GetSecondaryInCurrentStep();
for (auto sec : *secondaries) {
if (sec->GetDynamicParticle()->GetParticleDefinition() == opticalphoton){
for(auto sec : *secondaries)
{
if(sec->GetDynamicParticle()->GetParticleDefinition() == opticalphoton)
{
G4String creator_process = sec->GetCreatorProcess()->GetProcessName();
if (creator_process.compare("Cerenkov") == 0){
if(creator_process.compare("Cerenkov") == 0)
{
G4double en = sec->GetKineticEnergy();
run->AddCerenkovEnergy(en);
run->AddCerenkov();
analysisMan->FillH1(1, en/eV);
analysisMan->FillH1(1, en / eV);
}
else if (creator_process.compare("Scintillation") == 0) {
else if(creator_process.compare("Scintillation") == 0)
{
G4double en = sec->GetKineticEnergy();
run->AddScintillationEnergy(en);
run->AddScintillation();
analysisMan->FillH1(2, en/eV);
analysisMan->FillH1(2, en / eV);
G4double time = sec->GetGlobalTime();
analysisMan->FillH1(3, time/ns);
analysisMan->FillH1(3, time / ns);
}
}
}
}
}
return;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -30,11 +30,13 @@
//
#include "TrackInformation.hh"
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
G4ThreadLocal G4Allocator<TrackInformation> *
aTrackInformationAllocator = 0;
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
G4ThreadLocal G4Allocator<TrackInformation>* aTrackInformationAllocator =
nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackInformation::TrackInformation()
@@ -51,19 +53,18 @@ TrackInformation::TrackInformation(const G4Track*)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackInformation ::TrackInformation(const TrackInformation* aTrackInfo)
TrackInformation::TrackInformation(const TrackInformation* aTrackInfo)
: G4VUserTrackInformation()
{
fFirstTankX = aTrackInfo->fFirstTankX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackInformation::~TrackInformation()
{;}
TrackInformation::~TrackInformation() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackInformation& TrackInformation::operator=
(const TrackInformation& aTrackInfo)
TrackInformation& TrackInformation::operator=(
const TrackInformation& aTrackInfo)
{
fFirstTankX = aTrackInfo.fFirstTankX;
@@ -79,8 +80,7 @@ void TrackInformation::SetSourceTrackInformation(const G4Track*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackInformation::Print() const
{
G4cout
<< "first time track incident on X: " << fFirstTankX << G4endl;
G4cout << "first time track incident on X: " << fFirstTankX << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -29,45 +29,45 @@
//
#include "TrackingAction.hh"
#include "TrackInformation.hh"
#include "G4TrackingManager.hh"
#include "G4Track.hh"
#include "G4TrackingManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction()
:G4UserTrackingAction()
{;}
: G4UserTrackingAction()
{}
void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{
// Create trajectory only for track in tracking region
TrackInformation* trackInfo =
(TrackInformation*)(aTrack->GetUserInformation());
TrackInformation* trackInfo =
(TrackInformation*) (aTrack->GetUserInformation());
if (!trackInfo) {
trackInfo = new TrackInformation(aTrack);
if(!trackInfo)
{
trackInfo = new TrackInformation(aTrack);
trackInfo->SetIsFirstTankX(true);
aTrack->SetUserInformation(trackInfo);
}
trackInfo->SetIsFirstTankX(true);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
G4TrackVector* secondaries = fpTrackingManager->GimmeSecondaries();
if (secondaries)
if(secondaries)
{
TrackInformation* info =
(TrackInformation*)(aTrack->GetUserInformation());
size_t nSeco = secondaries->size();
if (nSeco > 0)
TrackInformation* info = (TrackInformation*) (aTrack->GetUserInformation());
size_t nSeco = secondaries->size();
if(nSeco > 0)
{
for(size_t i=0; i < nSeco; i++)
{
for(size_t i = 0; i < nSeco; ++i)
{
TrackInformation* infoNew = new TrackInformation(info);
(*secondaries)[i]->SetUserInformation(infoNew);
}