Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 76485 2013-11-11 10:54:47Z gcosmo $
|
||||
//
|
||||
/// \file ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
|
||||
//fanoCavity
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization(DetectorConstruction* det)
|
||||
: fDetector(det)
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
RunAction* runAct = new RunAction(fDetector,
|
||||
new PrimaryGeneratorAction(fDetector));
|
||||
SetUserAction(runAct);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
PrimaryGeneratorAction* prim = new PrimaryGeneratorAction(fDetector);
|
||||
SetUserAction(prim);
|
||||
|
||||
RunAction* runAct = new RunAction(fDetector, prim);
|
||||
SetUserAction(runAct);
|
||||
|
||||
TrackingAction *track = new TrackingAction();
|
||||
SetUserAction(track);
|
||||
|
||||
SteppingAction *step = new SteppingAction();
|
||||
SetUserAction(step);
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file exoticphysics/monopole/src/DetectorConstruction.cc
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
// $Id: DetectorConstruction.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: DetectorConstruction.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -50,21 +50,24 @@
|
||||
#include "G4NistManager.hh"
|
||||
|
||||
#include "G4MonopoleFieldSetup.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
//#include "G4FieldManager.hh"
|
||||
//#include "G4TransportationManager.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(),
|
||||
fWorldMaterial(0),
|
||||
fAbsorMaterial(0),
|
||||
fMagField(0),
|
||||
fMonFieldSetup(0),
|
||||
fLogAbsor(0),
|
||||
fMonFieldSetup(0),
|
||||
fZMagFieldValue(0.),
|
||||
fDetectorMessenger(0)
|
||||
{
|
||||
// default parameter values
|
||||
@@ -72,7 +75,8 @@ DetectorConstruction::DetectorConstruction()
|
||||
fWorldSizeX = fWorldSizeYZ = 1.2 * fAbsorSizeX;
|
||||
fMaxStepSize = 5 * mm;
|
||||
|
||||
fMonFieldSetup = G4MonopoleFieldSetup::GetMonopoleFieldSetup();
|
||||
// fMonFieldSetup = G4MonopoleFieldSetup::GetMonopoleFieldSetup();
|
||||
fMonFieldSetup = new G4MonopoleFieldSetup();
|
||||
|
||||
SetMaterial("G4_Al");
|
||||
fWorldMaterial =
|
||||
@@ -87,6 +91,7 @@ DetectorConstruction::DetectorConstruction()
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{
|
||||
delete fDetectorMessenger;
|
||||
// delete fMonFieldSetup;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -106,13 +111,13 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
fWorldMaterial,
|
||||
"world");
|
||||
|
||||
G4VPhysicalVolume * pWorld = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
lWorld, //logical volume
|
||||
"world", //name
|
||||
0, //mother volume
|
||||
G4VPhysicalVolume * pWorld = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
lWorld, //logical volume
|
||||
"world", //name
|
||||
0, //mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
0); //copy number
|
||||
|
||||
|
||||
/************************** Absorber ***************************/
|
||||
@@ -192,27 +197,63 @@ void DetectorConstruction::SetMaterial(const G4String& namemat)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
{
|
||||
fMonFieldSetup->SetMagField(fieldValue);
|
||||
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
G4FieldManager * fieldMgr =
|
||||
G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
// void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
// {
|
||||
// fMonFieldSetup->SetMagField(fieldValue);
|
||||
|
||||
// //apply a global uniform magnetic field along Z axis
|
||||
// G4FieldManager * fieldMgr =
|
||||
// G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
if (fMagField) { delete fMagField; } //delete the existing magn field
|
||||
// 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);
|
||||
}
|
||||
// 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::ConstructSDandField()
|
||||
{
|
||||
|
||||
// Define magnetic field
|
||||
bool bNewFieldValue = false;
|
||||
if ( fFieldMessenger.Get() != 0 ) {
|
||||
G4ThreeVector fieldSet = fFieldMessenger.Get()->GetFieldValue();
|
||||
if(fieldSet.z()!=fZMagFieldValue) bNewFieldValue = true;
|
||||
}
|
||||
else bNewFieldValue = true;
|
||||
|
||||
// Monopole particule specific magnetic field
|
||||
if(bNewFieldValue&&fZMagFieldValue!=0.)
|
||||
fMonFieldSetup->SetMagField(fZMagFieldValue, true);
|
||||
|
||||
if ( bNewFieldValue ) {
|
||||
// Create global magnetic field messenger.
|
||||
// Uniform magnetic field is then created automatically if
|
||||
// the field value is not zero.
|
||||
|
||||
if(fZMagFieldValue!=0.)
|
||||
{
|
||||
G4ThreeVector fieldValue = G4ThreeVector(0.,0.,fZMagFieldValue);
|
||||
G4GlobalMagFieldMessenger* msg =
|
||||
new G4GlobalMagFieldMessenger(fieldValue);
|
||||
msg->SetVerboseLevel(1);
|
||||
G4AutoDelete::Register(msg);
|
||||
fFieldMessenger.Put( msg );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -227,7 +268,7 @@ void DetectorConstruction::SetMaxStepSize(G4double step)
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file exoticphysics/monopole/src/G4MonopoleFieldSetup.cc
|
||||
/// \brief Implementation of the G4MonopoleFieldSetup class
|
||||
//
|
||||
// $Id: G4MonopoleFieldSetup.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: G4MonopoleFieldSetup.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -67,36 +67,41 @@
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0;
|
||||
//G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4MonopoleFieldSetup::G4MonopoleFieldSetup()
|
||||
: fFieldManager(0),
|
||||
fChordFinder(0),
|
||||
fUsualChordFinder(0),
|
||||
fMonopoleChordFinder(0),
|
||||
fEquation(0),
|
||||
fMonopoleEquation(0),
|
||||
fMagneticField(0),
|
||||
fStepper(0),
|
||||
fMonopoleStepper(0),
|
||||
fMinStep(0.0),
|
||||
fZmagFieldValue(0.),
|
||||
fMonopoleFieldMessenger(0)
|
||||
{
|
||||
|
||||
fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this);
|
||||
fFieldManager = GetGlobalFieldManager();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
|
||||
{
|
||||
if (0 == fMonopoleFieldSetup)
|
||||
{
|
||||
static G4MonopoleFieldSetup theInstance;
|
||||
fMonopoleFieldSetup = &theInstance;
|
||||
}
|
||||
// G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup()
|
||||
// {
|
||||
// if (0 == fMonopoleFieldSetup)
|
||||
// {
|
||||
// static G4ThreadLocal G4MonopoleFieldSetup theInstance;
|
||||
// fMonopoleFieldSetup = &theInstance;
|
||||
// }
|
||||
|
||||
return fMonopoleFieldSetup;
|
||||
}
|
||||
// return fMonopoleFieldSetup;
|
||||
// }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -104,46 +109,62 @@ G4MonopoleFieldSetup::~G4MonopoleFieldSetup()
|
||||
{
|
||||
delete fMonopoleFieldMessenger;
|
||||
if(fMagneticField) delete fMagneticField;
|
||||
if(fChordFinder) delete fChordFinder;
|
||||
// if(fChordFinder) delete fChordFinder;
|
||||
if(fUsualChordFinder) delete fUsualChordFinder;
|
||||
if(fMonopoleChordFinder) delete fMonopoleChordFinder;
|
||||
if(fStepper) delete fStepper;
|
||||
if(fMonopoleStepper) delete fMonopoleStepper;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4MonopoleFieldSetup::SetMagField(G4double fieldValue)
|
||||
|
||||
void G4MonopoleFieldSetup::SetMagField(G4double fieldValue,
|
||||
bool checkIfAlreadyDefined)
|
||||
{
|
||||
if(checkIfAlreadyDefined&&fMagneticField){
|
||||
// G4double fieldSet[4], fValue;
|
||||
// fMagneticField->GetFieldValue(fieldSet, &fValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fZmagFieldValue = fieldValue;
|
||||
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
if (fMagneticField) { delete fMagneticField; } //delete the existing magn field
|
||||
|
||||
if (fieldValue != 0.) // create a new one if non nul
|
||||
if (fZmagFieldValue != 0.) // create a new one if non nul
|
||||
{
|
||||
fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., fieldValue));
|
||||
fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0.,
|
||||
fZmagFieldValue));
|
||||
InitialiseAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
fMagneticField = 0;
|
||||
fFieldManager->SetDetectorField(fMagneticField);
|
||||
}
|
||||
|
||||
fFieldManager->SetDetectorField(fMagneticField);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void
|
||||
G4MonopoleFieldSetup::InitialiseAll()
|
||||
void G4MonopoleFieldSetup::InitialiseAll()
|
||||
{
|
||||
fFieldManager = G4TransportationManager::GetTransportationManager()
|
||||
->GetFieldManager();
|
||||
|
||||
fEquation = new G4Mag_UsualEqRhs(fMagneticField);
|
||||
fMonopoleEquation = new G4MonopoleEquation(fMagneticField);
|
||||
|
||||
fMinStep = 0.01*mm ; // minimal step of 1 mm is default
|
||||
|
||||
fMonopoleStepper = new G4ClassicalRK4( fMonopoleEquation, 8 ); // for time information..
|
||||
fMonopoleStepper = new G4ClassicalRK4( fMonopoleEquation, 8 );
|
||||
fStepper = new G4ClassicalRK4( fEquation );
|
||||
|
||||
fUsualChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);
|
||||
fMonopoleChordFinder = new G4ChordFinder( fMagneticField, fMinStep,
|
||||
fMonopoleStepper);
|
||||
|
||||
SetStepperAndChordFinder(0);
|
||||
}
|
||||
|
||||
@@ -151,24 +172,32 @@ G4MonopoleFieldSetup::InitialiseAll()
|
||||
|
||||
void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val)
|
||||
{
|
||||
|
||||
if (fMagneticField)
|
||||
{
|
||||
fFieldManager->SetDetectorField(fMagneticField );
|
||||
|
||||
if(fChordFinder) delete fChordFinder;
|
||||
// if(fChordFinder) delete fChordFinder;
|
||||
|
||||
switch (val)
|
||||
{
|
||||
// case 0:
|
||||
// fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);
|
||||
// break;
|
||||
// case 1:
|
||||
// fChordFinder = new G4ChordFinder( fMagneticField, fMinStep,
|
||||
// fMonopoleStepper);
|
||||
// break;
|
||||
case 0:
|
||||
fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper);
|
||||
fChordFinder = fUsualChordFinder;
|
||||
break;
|
||||
case 1:
|
||||
fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fMonopoleStepper);
|
||||
fChordFinder = fMonopoleChordFinder;
|
||||
break;
|
||||
}
|
||||
|
||||
fFieldManager->SetChordFinder( fChordFinder );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file exoticphysics/monopole/src/G4MonopolePhysics.cc
|
||||
/// \brief Implementation of the G4MonopolePhysics class
|
||||
//
|
||||
// $Id: G4MonopolePhysics.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: G4MonopolePhysics.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
@@ -76,7 +76,6 @@ G4MonopolePhysics::G4MonopolePhysics(const G4String& nam)
|
||||
// fElCharge = -50.0;
|
||||
fElCharge = 0.0;
|
||||
fMonopoleMass = 100.*GeV;
|
||||
fMessenger = new G4MonopolePhysicsMessenger(this);
|
||||
SetPhysicsType(bUnknown);
|
||||
}
|
||||
|
||||
@@ -101,6 +100,8 @@ void G4MonopolePhysics::ConstructProcess()
|
||||
if(verboseLevel > 0) {
|
||||
G4cout << "G4MonopolePhysics::ConstructProcess" << G4endl;
|
||||
}
|
||||
|
||||
fMessenger = new G4MonopolePhysicsMessenger(this);
|
||||
|
||||
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
G4ProcessManager* pmanager = fMpl->GetProcessManager();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file exoticphysics/monopole/src/G4MonopoleTransportation.cc
|
||||
/// \brief Implementation of the G4MonopoleTransportation class
|
||||
//
|
||||
// $Id: G4MonopoleTransportation.cc 84606 2014-10-17 07:50:04Z gcosmo $
|
||||
// $Id: G4MonopoleTransportation.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -53,6 +53,9 @@
|
||||
#include "G4TransportationProcessType.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
class G4VSensitiveDetector;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -81,19 +84,30 @@ G4MonopoleTransportation::G4MonopoleTransportation( const G4Monopole* mpl,
|
||||
// set Process Sub Type
|
||||
SetProcessSubType(TRANSPORTATION);
|
||||
|
||||
fMagSetup = G4MonopoleFieldSetup::GetMonopoleFieldSetup();
|
||||
|
||||
G4TransportationManager* transportMgr ;
|
||||
|
||||
transportMgr = G4TransportationManager::GetTransportationManager() ;
|
||||
#ifdef G4MULTITHREADED
|
||||
// Do not finalize the G4MonopoleTransportation class
|
||||
if (G4Threading::IsMasterThread())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
const DetectorConstruction* detector = static_cast<const DetectorConstruction*>
|
||||
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
|
||||
|
||||
fMagSetup = detector->GetMonopoleFieldSetup();
|
||||
|
||||
G4TransportationManager* transportMgr = G4TransportationManager::GetTransportationManager();
|
||||
|
||||
fLinearNavigator = transportMgr->GetNavigatorForTracking() ;
|
||||
|
||||
// fGlobalFieldMgr = transportMgr->GetFieldManager() ;
|
||||
|
||||
fFieldPropagator = transportMgr->GetPropagatorInField() ;
|
||||
fpSafetyHelper = transportMgr->GetSafetyHelper();
|
||||
|
||||
fpSafetyHelper = transportMgr->GetSafetyHelper(); // New
|
||||
// New
|
||||
|
||||
// Cannot determine whether a field exists here,
|
||||
// because it would only work if the field manager has informed
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: HistoManager.cc 104174 2017-05-15 12:12:45Z selles $
|
||||
// GEANT4 tag $Name: geant4-09-04-cand-00 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoManager.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::HistoManager(DetectorConstruction* det, G4double binLength)
|
||||
: fDetector(det), fBinLength(binLength)
|
||||
|
||||
{
|
||||
fVerbose = true;
|
||||
|
||||
fHistoId.resize(MaxHisto);
|
||||
fExist.resize(MaxHisto);
|
||||
fActive.resize(MaxHisto);
|
||||
fLabel.resize(MaxHisto);
|
||||
fTitle.resize(MaxHisto);
|
||||
fNbins.resize(MaxHisto);
|
||||
fVmin.resize(MaxHisto);
|
||||
fVmax.resize(MaxHisto);
|
||||
fUnit1.resize(MaxHisto);
|
||||
fUnit2.resize(MaxHisto);
|
||||
fWidth.resize(MaxHisto);
|
||||
fIds.resize(MaxHisto);
|
||||
|
||||
// histograms
|
||||
fNbHisto = 0;
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
fHistoId[k] = 0;
|
||||
fExist[k] = false;
|
||||
fActive[k] = false;
|
||||
fUnit1[k] = 1.0;
|
||||
fUnit2[k] = 1.0;
|
||||
fWidth[k] = 1.0;
|
||||
}
|
||||
|
||||
fNtupleActive = false;
|
||||
fTupleName = "tuple";
|
||||
fTupleTitle = "test";
|
||||
|
||||
fTupleI.assign(MaxHisto,-1);
|
||||
fTupleF.assign(MaxHisto,-1);
|
||||
fTupleD.assign(MaxHisto,-1);
|
||||
|
||||
Book();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::~HistoManager()
|
||||
{
|
||||
delete G4AnalysisManager::Instance();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::Book()
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
// Create or get analysis manager
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
analysisManager->SetActivation(false); // enable inactivation of histograms
|
||||
|
||||
// Define the histogramms
|
||||
if(analysisManager->GetNofH1s()==0)
|
||||
{
|
||||
G4double length = fDetector->GetAbsorSizeX();
|
||||
G4int nbBins = G4lrint(length / fBinLength);
|
||||
|
||||
// Create histograms
|
||||
fNbHisto = 0;
|
||||
Add1D(0,"dummy", nbBins, 0, length, "mm");
|
||||
Add1D(1,"Edep (MeV/mm) along absorber (mm)", nbBins, 0, length, "mm");
|
||||
Add1D(2,"DEDX (MeV/mm) of proton", 100, -3., 7.);
|
||||
Add1D(3,"DEDX (MeV/mm) of monopole", 100, -3., 7.);
|
||||
Add1D(4,"Range(mm) of proton", 100, -3., 7., "mm");
|
||||
Add1D(5,"Range(mm) of monopole", 100, -3., 7., "mm");
|
||||
|
||||
// Creating an 1-dimensional histograms in the root directory of the tree
|
||||
for(G4int i=0; i<fNbHisto; i++)
|
||||
{
|
||||
fHistoId[i] = analysisManager->CreateH1(fIds[i], fTitle[i],
|
||||
fNbins[i], fVmin[i], fVmax[i]);
|
||||
analysisManager->SetH1Activation(fHistoId[i],fActive[i]);
|
||||
}
|
||||
|
||||
// Creating a tuple factory, whose tuples will be handled by the tree
|
||||
if(fNtupleActive) {
|
||||
analysisManager->CreateNtuple(fTupleName,fTupleTitle);
|
||||
G4int i;
|
||||
G4int n = fNtupleI.size();
|
||||
for(i=0; i<n; ++i) {
|
||||
if(fTupleI[i] == -1)
|
||||
{ fTupleI[i] = analysisManager->CreateNtupleIColumn(fNtupleI[i]); }
|
||||
}
|
||||
n = fNtupleF.size();
|
||||
for(i=0; i<n; ++i) {
|
||||
if(fTupleF[i] == -1)
|
||||
{ fTupleF[i] = analysisManager->CreateNtupleFColumn(fNtupleF[i]); }
|
||||
}
|
||||
n = fNtupleD.size();
|
||||
for(i=0; i<n; ++i) {
|
||||
if(fTupleD[i] == -1)
|
||||
{ fTupleD[i] = analysisManager->CreateNtupleDColumn(fNtupleD[i]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Added to catch the SetActivation parameters set througj UI interface
|
||||
for (G4int k=0; k<MaxHisto; k++)
|
||||
fExist[k] = analysisManager->GetH1Activation(fHistoId[k]);
|
||||
|
||||
// Check if a filename is set
|
||||
if(analysisManager->GetFileName()=="") return;
|
||||
|
||||
// Activate the analysisManage ronly if a filename is set
|
||||
analysisManager->SetActivation(true); // enable inactivation of histograms
|
||||
|
||||
}
|
||||
|
||||
void HistoManager::SetBinLength(G4double binLength)
|
||||
{
|
||||
fBinLength = binLength;
|
||||
|
||||
G4double length = fDetector->GetAbsorSizeX();
|
||||
G4int nbBins = G4lrint(length / fBinLength);
|
||||
SetHisto1D(1, nbBins, 0., length, "mm");
|
||||
}
|
||||
|
||||
|
||||
void HistoManager::Update(G4double binLength)
|
||||
{
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
G4double histo1_binLength = analysisManager->GetH1Width(fHistoId[1]);
|
||||
if(fabs(histo1_binLength-binLength)>0.01)
|
||||
{
|
||||
G4double length = fDetector->GetAbsorSizeX();
|
||||
G4int nbBins = G4lrint(length / binLength);
|
||||
analysisManager->SetH1(fHistoId[1], nbBins,
|
||||
G4AnalysisManager::Instance()->GetH1Xmin(fHistoId[1]),
|
||||
G4AnalysisManager::Instance()->GetH1Xmax(fHistoId[1]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::Add1D(G4int histoId, const G4String& name, G4int nb,
|
||||
G4double x1, G4double x2,
|
||||
const G4String& u1, const G4String& u2)
|
||||
{
|
||||
std::stringstream sg;
|
||||
sg<<histoId;
|
||||
const G4String id = sg.str();
|
||||
|
||||
if(fVerbose) {
|
||||
G4cout << "New histogram will be booked: #" << id << " <" << name
|
||||
<< " " << nb << " " << x1 << " " << x2 << " " << u1<<" "<<u2
|
||||
<< G4endl;
|
||||
}
|
||||
fNbHisto++;
|
||||
|
||||
double vUnit1= (u1=="none")? 1. : (G4UnitDefinition::GetValueOf(u1));
|
||||
fUnit1[histoId]=vUnit1;
|
||||
double vUnit2= (u2=="none")? 1. : (G4UnitDefinition::GetValueOf(u2));
|
||||
fUnit2[histoId]=vUnit2;
|
||||
|
||||
x1 /= vUnit1;
|
||||
x2 /= vUnit1;
|
||||
fNbins[histoId]=nb;
|
||||
fVmin[histoId]=x1;
|
||||
fVmax[histoId]=x2;
|
||||
fWidth[histoId] = (x2-x1)/nb;
|
||||
fTitle[histoId]=name;
|
||||
fIds[histoId]=id;
|
||||
G4int exist = (name.substr(0,5)=="dummy"||name.substr(0,5)=="Dummy")?false:true;
|
||||
fExist[histoId]=exist;
|
||||
fActive[histoId]=exist;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::SetHisto1D(G4int ih,
|
||||
G4int nbins, G4double valmin, G4double valmax,
|
||||
const G4String& unit)
|
||||
{
|
||||
if (ih > MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::SetHisto() : histo " << ih
|
||||
<< "does not exist" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// const G4String id[] = { "0", "1", "2", "3", "4", "5", "6" };
|
||||
// const G4String title[] =
|
||||
// { "dummy", //0
|
||||
// "continuous energy loss along primary track", //1
|
||||
// "energy from secondaries", //2
|
||||
// "total energy lost by primary track", //3
|
||||
// "energy spectrum of e-+", //4
|
||||
// "energy spectrum of gamma", //5
|
||||
// "step size" //6
|
||||
// };
|
||||
|
||||
// G4String titl = fTitle[ih];
|
||||
G4double vmin = valmin, vmax = valmax;
|
||||
|
||||
if (unit != "none") {
|
||||
fUnit1[ih] = G4UnitDefinition::GetValueOf(unit);
|
||||
}
|
||||
vmin = valmin/fUnit1[ih];
|
||||
vmax = valmax/fUnit1[ih];
|
||||
|
||||
fExist[ih] = true;
|
||||
fNbins[ih] = nbins;
|
||||
fVmin[ih] = vmin;
|
||||
fVmax[ih] = vmax;
|
||||
fWidth[ih] = (valmax-valmin)/nbins;
|
||||
|
||||
if(fTitle[ih].substr(0,5)=="dummy") fExist[ih]=false;
|
||||
if(fTitle[ih].substr(0,5)=="Dummy") fExist[ih]=false;
|
||||
fActive[ih]=fExist[ih];
|
||||
|
||||
G4cout << "----> SetHisto " << ih << ": " << fTitle[ih] << "; "
|
||||
<< nbins << " bins from "
|
||||
<< vmin << " " << unit << " to " << vmax << " " << fUnit1[ih] << " - "
|
||||
<<fExist[ih]<<G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::FillHisto(G4int ih, G4double e, G4double weight)
|
||||
{
|
||||
if (ih > MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::FillHisto() : histo " << ih
|
||||
<< "does not exist; e= " << e << " w= " << weight << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!fExist[ih]) return;
|
||||
G4AnalysisManager::Instance()->FillH1( fHistoId[ih], e/fUnit1[ih], weight);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::Scale(G4int ih, G4double fac)
|
||||
{
|
||||
if (ih > MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::Scale() : histo " << ih
|
||||
<< "does not exist. (fac = " << fac << ")" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!fExist[ih]) return;
|
||||
G4AnalysisManager::Instance()->GetH1(fHistoId[ih])->scale(fac);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file exoticphysics/monopole/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: PrimaryGeneratorAction.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -41,7 +41,8 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
|
||||
:G4VUserPrimaryGeneratorAction(),fParticleGun(0),fDetector(det)
|
||||
:G4VUserPrimaryGeneratorAction(),fParticleGun(0),fDetector(det),
|
||||
bPrimPositionDefined(false)
|
||||
{
|
||||
fParticleGun = new G4ParticleGun(1);
|
||||
fParticleGun->SetParticleEnergy(100 * GeV);
|
||||
@@ -60,10 +61,12 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begining of event
|
||||
if(0 == anEvent->GetEventID()) {
|
||||
if(0 == anEvent->GetEventID() || !bPrimPositionDefined) {
|
||||
G4double x0 = -0.5*(fDetector->GetWorldSizeX()) + 1*um;
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0,0.0,0.0));
|
||||
bPrimPositionDefined = true;
|
||||
}
|
||||
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm5/src/Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
#include "G4EmCalculator.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run(DetectorConstruction* det, PrimaryGeneratorAction* prim,
|
||||
HistoManager* histoMgr)
|
||||
:fDetector(det), fPrimary(prim), fHistoManager(histoMgr)
|
||||
{
|
||||
fAnalysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
G4double length = fDetector->GetAbsorSizeX();
|
||||
fOffsetX = -0.5 * length;
|
||||
|
||||
fVerboseLevel = 1;
|
||||
fNevt = 0;
|
||||
fProjRange = fProjRange2 = 0.;
|
||||
|
||||
fHistoManager->Book();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge(const G4Run* run)
|
||||
{
|
||||
const Run* localRun = static_cast<const Run*>(run);
|
||||
|
||||
fNevt += localRun->GetNumberOfEvent();
|
||||
fProjRange += localRun->fProjRange;
|
||||
fProjRange2 += localRun->fProjRange2;
|
||||
|
||||
G4Run::Merge(run);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::EndOfRun(double binLength)
|
||||
{
|
||||
|
||||
#ifndef G4MULTITHREADED
|
||||
fNevt += this->GetNumberOfEvent();
|
||||
#endif
|
||||
|
||||
G4int nEvents = fNevt;
|
||||
if (nEvents == 0) { return; }
|
||||
|
||||
//run conditions
|
||||
//
|
||||
const G4Material* material = fDetector->GetAbsorMaterial();
|
||||
G4double density = material->GetDensity();
|
||||
G4String matName = material->GetName();
|
||||
const G4ParticleDefinition* part =
|
||||
fPrimary->GetParticleGun()->GetParticleDefinition();
|
||||
G4String particle = part->GetParticleName();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "\n The run consists of " << nEvents << " "<< particle << " of "
|
||||
<< G4BestUnit(energy,"Energy") << " through "
|
||||
<< G4BestUnit(fDetector->GetAbsorSizeX(),"Length") << " of "
|
||||
<< matName << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
G4cout<<"Proj "<<fProjRange<<" "<<fProjRange2<<G4endl;
|
||||
};
|
||||
|
||||
//compute projected range and straggling
|
||||
|
||||
fProjRange /= nEvents; fProjRange2 /= nEvents;
|
||||
G4double rms = fProjRange2 - fProjRange*fProjRange;
|
||||
if (rms>0.) { rms = std::sqrt(rms); }
|
||||
else { rms = 0.; }
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout.precision(5);
|
||||
G4cout << "\n projected Range= " << G4BestUnit(fProjRange, "Length")
|
||||
<< " rms= " << G4BestUnit(rms, "Length")
|
||||
<< G4endl;
|
||||
};
|
||||
|
||||
G4double ekin[100], dedxproton[100], dedxmp[100];
|
||||
G4EmCalculator calc;
|
||||
calc.SetVerbose(2);
|
||||
G4int i;
|
||||
for(i = 0; i < 100; ++i) {
|
||||
ekin[i] = std::pow(10., 0.1*G4double(i)) * keV;
|
||||
dedxproton[i] =
|
||||
calc.ComputeElectronicDEDX(ekin[i], "proton", matName);
|
||||
dedxmp[i] =
|
||||
calc.ComputeElectronicDEDX(ekin[i], "monopole", matName);
|
||||
}
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "### Stopping Powers" << G4endl;
|
||||
for(i=0; i<100; i++) {
|
||||
G4cout << " E(MeV)= " << ekin[i] << " dedxp= " << dedxproton[i]
|
||||
<< " dedxmp= " << dedxmp[i]
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
G4cout << "### End of stopping power table" << G4endl;
|
||||
|
||||
// normalize histogram
|
||||
G4double fac = (mm/MeV) / (nEvents * binLength);
|
||||
fHistoManager->Scale(1,fac);
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "Range table for " << matName << G4endl;
|
||||
}
|
||||
|
||||
for(i=0; i<100; ++i) {
|
||||
G4double e = std::log10(ekin[i] / MeV) + 0.05;
|
||||
fHistoManager->FillHisto(2, e, dedxproton[i]);
|
||||
fHistoManager->FillHisto(3, e, dedxmp[i]);
|
||||
fHistoManager->FillHisto(4, e,
|
||||
std::log10(calc.GetRange(ekin[i],"proton",matName)/mm));
|
||||
fHistoManager->FillHisto(5, e,
|
||||
std::log10(calc.GetRange(ekin[i],"monopole",matName)/mm));
|
||||
}
|
||||
|
||||
|
||||
if(fAnalysisManager) {
|
||||
|
||||
if(fAnalysisManager->IsActive()) {
|
||||
|
||||
// Write histogram file
|
||||
if(!fAnalysisManager->Write()) {
|
||||
G4Exception ("Histo::Save()", "hist01", FatalException,
|
||||
"Cannot write ROOT file.");
|
||||
}
|
||||
G4cout << "### Histo::Save: Histograms are saved" << G4endl;
|
||||
if(fAnalysisManager->CloseFile() && fVerboseLevel) {
|
||||
G4cout << " File is closed" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
delete fAnalysisManager;
|
||||
fAnalysisManager = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
void Run::FillHisto(G4int histoId, G4double v1, G4double v2)
|
||||
{
|
||||
if(fAnalysisManager)
|
||||
fHistoManager->FillHisto(histoId, v1, v2);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -26,170 +26,106 @@
|
||||
/// \file exoticphysics/monopole/src/RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
// $Id: RunAction.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: RunAction.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "RunActionMessenger.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunActionMessenger.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "Histo.hh"
|
||||
#include "G4EmCalculator.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
|
||||
:G4UserRunAction(),
|
||||
fHisto(0),fDetector(det),fKinematic(kin),fRunActionMessenger(0)
|
||||
{
|
||||
fVerboseLevel = 1;
|
||||
fProjRange = fProjRange2 = fBinLength = fOffsetX = 0.;
|
||||
fHisto = new Histo();
|
||||
fHisto->SetFileName("monopole");
|
||||
// create commands for interactive definition of the detector
|
||||
fRunActionMessenger = new RunActionMessenger(this);
|
||||
:fDetector(det),fKinematic(kin)
|
||||
{
|
||||
fMessenger = new RunActionMessenger(this);
|
||||
|
||||
fBinLength = 5 * CLHEP::mm;
|
||||
|
||||
// Book predefined histograms
|
||||
fHistoManager = new HistoManager(det, fBinLength);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction()
|
||||
{
|
||||
delete fHisto;
|
||||
delete fRunActionMessenger;
|
||||
#ifdef G4MULTITHREADED
|
||||
if(isMaster) delete fKinematic;
|
||||
#endif
|
||||
delete fMessenger;
|
||||
delete fHistoManager;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun()
|
||||
{
|
||||
fRun = new Run(fDetector,fKinematic,fHistoManager);
|
||||
return fRun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
if(GetVerbose() > 0) {
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
}
|
||||
|
||||
//initialize projected range, tallies, Ebeam, and book histograms
|
||||
fProjRange = fProjRange2 = 0.;
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
|
||||
// save Rndm status
|
||||
//
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
|
||||
//histograms
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->OpenFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
|
||||
{
|
||||
// print Run summary
|
||||
//
|
||||
if (isMaster) fRun->EndOfRun(fBinLength);
|
||||
|
||||
// save histograms
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
}
|
||||
|
||||
// show Rndm status
|
||||
if (isMaster) G4Random::showEngineStatus();
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::SetBinSize(G4double size)
|
||||
{
|
||||
fBinLength = size;
|
||||
|
||||
G4double length = fDetector->GetAbsorSizeX();
|
||||
if(0.0 == fBinLength) { fBinLength = 5 * mm; }
|
||||
if(fBinLength > fDetector->GetMaxStepSize()) {
|
||||
fBinLength = fDetector->GetMaxStepSize();
|
||||
}
|
||||
fOffsetX = -0.5 * length;
|
||||
|
||||
G4int nbBins = G4lrint(length / fBinLength);
|
||||
|
||||
|
||||
// Create histograms
|
||||
fHisto->Add1D("1","Edep (MeV/mm) along absorber (mm)", nbBins, 0, length, mm);
|
||||
fHisto->Add1D("2","DEDX (MeV/mm) of proton", 100, -3., 7.);
|
||||
fHisto->Add1D("3","DEDX (MeV/mm) of monopole", 100, -3., 7.);
|
||||
fHisto->Add1D("4","Range(mm) of proton", 100, -3., 7., mm);
|
||||
fHisto->Add1D("5","Range(mm) of monopole", 100, -3., 7., mm);
|
||||
|
||||
fHisto->Book();
|
||||
// fHistoManager->SetBinLength(fBinLength);
|
||||
fHistoManager->Update(fBinLength);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
G4int nEvents = aRun->GetNumberOfEvent();
|
||||
if (nEvents == 0) { return; }
|
||||
|
||||
//run conditions
|
||||
//
|
||||
const G4Material* material = fDetector->GetAbsorMaterial();
|
||||
G4double density = material->GetDensity();
|
||||
G4String matName = material->GetName();
|
||||
const G4ParticleDefinition* part =
|
||||
fKinematic->GetParticleGun()->GetParticleDefinition();
|
||||
G4String particle = part->GetParticleName();
|
||||
G4double energy = fKinematic->GetParticleGun()->GetParticleEnergy();
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "\n The run consists of " << nEvents << " "<< particle << " of "
|
||||
<< G4BestUnit(energy,"Energy") << " through "
|
||||
<< G4BestUnit(fDetector->GetAbsorSizeX(),"Length") << " of "
|
||||
<< matName << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
};
|
||||
|
||||
//compute projected range and straggling
|
||||
|
||||
fProjRange /= nEvents; fProjRange2 /= nEvents;
|
||||
G4double rms = fProjRange2 - fProjRange*fProjRange;
|
||||
if (rms>0.) { rms = std::sqrt(rms); }
|
||||
else { rms = 0.; }
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout.precision(5);
|
||||
G4cout << "\n projected Range= " << G4BestUnit(fProjRange, "Length")
|
||||
<< " rms= " << G4BestUnit(rms, "Length")
|
||||
<< G4endl;
|
||||
};
|
||||
|
||||
G4double ekin[100], dedxproton[100], dedxmp[100];
|
||||
G4EmCalculator calc;
|
||||
calc.SetVerbose(0);
|
||||
G4int i;
|
||||
for(i = 0; i < 100; ++i) {
|
||||
ekin[i] = std::pow(10., 0.1*G4double(i)) * keV;
|
||||
dedxproton[i] =
|
||||
calc.ComputeElectronicDEDX(ekin[i], "proton", matName);
|
||||
dedxmp[i] =
|
||||
calc.ComputeElectronicDEDX(ekin[i], "monopole", matName);
|
||||
}
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "### Stopping Powers" << G4endl;
|
||||
for(i=0; i<100; i++) {
|
||||
G4cout << " E(MeV)= " << ekin[i] << " dedxp= " << dedxproton[i]
|
||||
<< " dedxmp= " << dedxmp[i]
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
G4cout << "### End of stopping power table" << G4endl;
|
||||
|
||||
// normalize histogram
|
||||
G4double fac = (mm/MeV) / (nEvents * fBinLength);
|
||||
fHisto->ScaleH1(0,fac);
|
||||
|
||||
if(GetVerbose() > 0){
|
||||
G4cout << "Range table for " << matName << G4endl;
|
||||
}
|
||||
|
||||
for(i=0; i<100; ++i) {
|
||||
G4double e = std::log10(ekin[i] / MeV) + 0.05;
|
||||
fHisto->Fill(1, e, dedxproton[i]);
|
||||
fHisto->Fill(2, e, dedxmp[i]);
|
||||
fHisto->Fill(3, e, std::log10(calc.GetRange(ekin[i],"proton",matName)/mm));
|
||||
fHisto->Fill(4, e, std::log10(calc.GetRange(ekin[i],"monopole",matName)/mm));
|
||||
}
|
||||
|
||||
// save and clean histo
|
||||
fHisto->Save();
|
||||
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::FillHisto(G4int ih, G4double x, G4double weight)
|
||||
{
|
||||
if(GetVerbose() > 1) {
|
||||
G4cout << "FillHisto " << ih << " x=" << x << " weight= " << weight
|
||||
<< G4endl;
|
||||
}
|
||||
fHisto->Fill(ih, x, weight);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,21 +26,22 @@
|
||||
/// \file exoticphysics/monopole/src/SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
// $Id: SteppingAction.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: SteppingAction.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction(RunAction* RuAct)
|
||||
: G4UserSteppingAction(),
|
||||
fRunAction(RuAct)
|
||||
SteppingAction::SteppingAction()
|
||||
: G4UserSteppingAction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -54,12 +55,15 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
if (edep <= 0.) { return; }
|
||||
|
||||
Run* run = static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
|
||||
//Bragg curve
|
||||
G4double x = aStep->GetPreStepPoint()->GetPosition().x();
|
||||
G4double dx = aStep->GetPostStepPoint()->GetPosition().x() - x;
|
||||
x += dx*G4UniformRand() - fRunAction->GetOffsetX();
|
||||
fRunAction->FillHisto(0, x, edep);
|
||||
x += dx*G4UniformRand() - run->GetOffsetX();
|
||||
run->FillHisto(1, x, edep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,20 +26,21 @@
|
||||
/// \file exoticphysics/monopole/src/TrackingAction.cc
|
||||
/// \brief Implementation of the TrackingAction class
|
||||
//
|
||||
// $Id: TrackingAction.cc 68036 2013-03-13 14:13:45Z gcosmo $
|
||||
// $Id: TrackingAction.cc 104872 2017-06-23 14:19:16Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "TrackingAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
#include "G4Track.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction(RunAction* run)
|
||||
: G4UserTrackingAction(),
|
||||
fRunAction(run)
|
||||
TrackingAction::TrackingAction()
|
||||
: G4UserTrackingAction()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -53,9 +54,11 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
// extract Projected Range of primary particle
|
||||
if (aTrack->GetTrackID() == 1) {
|
||||
G4double x = aTrack->GetPosition().x() - fRunAction->GetOffsetX();
|
||||
fRunAction->AddProjRange(x);
|
||||
}
|
||||
Run* run = static_cast<Run*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
G4double x = aTrack->GetPosition().x() - run->GetOffsetX();
|
||||
run->AddProjRange(x);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user