Import Geant4 9.6.0 source tree
This commit is contained in:
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc,v 1.4 2006-06-29 16:45:33 gunter Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/DetectorConstruction.cc
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -43,22 +45,23 @@
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
:pBox(0), lBox(0), aMaterial(0)
|
||||
:fPBox(0), fLBox(0), fMaterial(0)
|
||||
{
|
||||
BoxSize = 100*m;
|
||||
fBoxSize = 100*m;
|
||||
DefineMaterials();
|
||||
SetMaterial("Water");
|
||||
detectorMessenger = new DetectorMessenger(this);
|
||||
fDetectorMessenger = new DetectorMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction()
|
||||
{ delete detectorMessenger;}
|
||||
{ delete fDetectorMessenger;}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -115,6 +118,8 @@ void DetectorConstruction::DefineMaterials()
|
||||
|
||||
new G4Material("Silicon" , z=14., a= 28.09*g/mole, density= 2.330*g/cm3);
|
||||
|
||||
new G4Material("Chromium" , z=24., a= 51.99*g/mole, density= 7.140*g/cm3);
|
||||
|
||||
new G4Material("Copper" , z=29., a= 63.55*g/mole, density= 8.920*g/cm3);
|
||||
|
||||
new G4Material("Germanium" , z=32., a= 72.61*g/mole, density= 5.323*g/cm3);
|
||||
@@ -161,34 +166,34 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
G4Box*
|
||||
sBox = new G4Box("Container", //its name
|
||||
BoxSize/2,BoxSize/2,BoxSize/2); //its dimensions
|
||||
sBox = new G4Box("Container", //its name
|
||||
fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
|
||||
|
||||
lBox = new G4LogicalVolume(sBox, //its shape
|
||||
aMaterial, //its material
|
||||
aMaterial->GetName()); //its name
|
||||
fLBox = new G4LogicalVolume(sBox, //its shape
|
||||
fMaterial, //its material
|
||||
fMaterial->GetName()); //its name
|
||||
|
||||
pBox = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
lBox, //its logical volume
|
||||
aMaterial->GetName(), //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
fPBox = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
fLBox, //its logical volume
|
||||
fMaterial->GetName(), //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
PrintParameters();
|
||||
|
||||
//always return the root volume
|
||||
//
|
||||
return pBox;
|
||||
return fPBox;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::PrintParameters()
|
||||
{
|
||||
G4cout << "\n The Box is " << G4BestUnit(BoxSize,"Length")
|
||||
<< " of " << aMaterial->GetName() << G4endl;
|
||||
G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
|
||||
<< " of " << fMaterial->GetName() << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -198,7 +203,7 @@ void DetectorConstruction::SetMaterial(G4String materialChoice)
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
|
||||
if (pttoMaterial) {
|
||||
aMaterial = pttoMaterial;
|
||||
fMaterial = pttoMaterial;
|
||||
UpdateGeometry();
|
||||
} else {
|
||||
G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
|
||||
@@ -210,7 +215,7 @@ void DetectorConstruction::SetMaterial(G4String materialChoice)
|
||||
|
||||
void DetectorConstruction::SetSize(G4double value)
|
||||
{
|
||||
BoxSize = value;
|
||||
fBoxSize = value;
|
||||
UpdateGeometry();
|
||||
}
|
||||
|
||||
@@ -220,7 +225,7 @@ void DetectorConstruction::SetSize(G4double value)
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
if (pBox)
|
||||
if (fPBox)
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorMessenger.cc,v 1.3 2006-06-29 16:45:35 gunter Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -40,56 +42,56 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
|
||||
:Detector(Det)
|
||||
:fDetector(Det)
|
||||
{
|
||||
testemDir = new G4UIdirectory("/testem/");
|
||||
testemDir->SetGuidance("commands specific to this example");
|
||||
fTestemDir = new G4UIdirectory("/testem/");
|
||||
fTestemDir->SetGuidance("commands specific to this example");
|
||||
|
||||
detDir = new G4UIdirectory("/testem/det/");
|
||||
detDir->SetGuidance("detector construction");
|
||||
fDetDir = new G4UIdirectory("/testem/det/");
|
||||
fDetDir->SetGuidance("detector construction");
|
||||
|
||||
MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
|
||||
MaterCmd->SetGuidance("Select material of the box.");
|
||||
MaterCmd->SetParameterName("choice",false);
|
||||
MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
|
||||
fMaterCmd->SetGuidance("Select material of the box.");
|
||||
fMaterCmd->SetParameterName("choice",false);
|
||||
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
SizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
|
||||
SizeCmd->SetGuidance("Set size of the box");
|
||||
SizeCmd->SetParameterName("Size",false);
|
||||
SizeCmd->SetRange("Size>0.");
|
||||
SizeCmd->SetUnitCategory("Length");
|
||||
SizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
|
||||
fSizeCmd->SetGuidance("Set size of the box");
|
||||
fSizeCmd->SetParameterName("Size",false);
|
||||
fSizeCmd->SetRange("Size>0.");
|
||||
fSizeCmd->SetUnitCategory("Length");
|
||||
fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
|
||||
UpdateCmd->SetGuidance("Update calorimeter geometry.");
|
||||
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
UpdateCmd->AvailableForStates(G4State_Idle);
|
||||
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
|
||||
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
|
||||
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
fUpdateCmd->AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::~DetectorMessenger()
|
||||
{
|
||||
delete MaterCmd;
|
||||
delete SizeCmd;
|
||||
delete UpdateCmd;
|
||||
delete detDir;
|
||||
delete testemDir;
|
||||
delete fMaterCmd;
|
||||
delete fSizeCmd;
|
||||
delete fUpdateCmd;
|
||||
delete fDetDir;
|
||||
delete fTestemDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if( command == MaterCmd )
|
||||
{ Detector->SetMaterial(newValue);}
|
||||
if( command == fMaterCmd )
|
||||
{ fDetector->SetMaterial(newValue);}
|
||||
|
||||
if( command == SizeCmd )
|
||||
{ Detector->SetSize(SizeCmd->GetNewDoubleValue(newValue));}
|
||||
if( command == fSizeCmd )
|
||||
{ fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == UpdateCmd )
|
||||
{ Detector->UpdateGeometry(); }
|
||||
if( command == fUpdateCmd )
|
||||
{ fDetector->UpdateGeometry(); }
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.cc,v 1.6 2010-06-07 05:40:46 perl Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/EventAction.cc
|
||||
/// \brief Implementation of the EventAction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,16 +41,16 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventAction::EventAction()
|
||||
:printModulo(100000),eventMessenger(0)
|
||||
:fPrintModulo(100000),fEventMessenger(0)
|
||||
{
|
||||
eventMessenger = new EventActionMessenger(this);
|
||||
fEventMessenger = new EventActionMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventAction::~EventAction()
|
||||
{
|
||||
delete eventMessenger;
|
||||
delete fEventMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -58,7 +60,7 @@ void EventAction::BeginOfEventAction(const G4Event* evt)
|
||||
G4int evtNb = evt->GetEventID();
|
||||
|
||||
//printing survey
|
||||
if (evtNb%printModulo == 0)
|
||||
if (evtNb%fPrintModulo == 0)
|
||||
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventActionMessenger.cc,v 1.3 2006-06-29 16:45:39 gunter Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/EventActionMessenger.cc
|
||||
/// \brief Implementation of the EventActionMessenger class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,32 +41,32 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
|
||||
:eventAction(EvAct)
|
||||
:fEventAction(EvAct)
|
||||
{
|
||||
eventDir = new G4UIdirectory("/testem/event/");
|
||||
eventDir ->SetGuidance("event control");
|
||||
fEventDir = new G4UIdirectory("/testem/event/");
|
||||
fEventDir ->SetGuidance("event control");
|
||||
|
||||
PrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
|
||||
PrintCmd->SetGuidance("Print events modulo n");
|
||||
PrintCmd->SetParameterName("EventNb",false);
|
||||
PrintCmd->SetRange("EventNb>0");
|
||||
PrintCmd->AvailableForStates(G4State_Idle);
|
||||
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
|
||||
fPrintCmd->SetGuidance("Print events modulo n");
|
||||
fPrintCmd->SetParameterName("EventNb",false);
|
||||
fPrintCmd->SetRange("EventNb>0");
|
||||
fPrintCmd->AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
EventActionMessenger::~EventActionMessenger()
|
||||
{
|
||||
delete PrintCmd;
|
||||
delete eventDir;
|
||||
delete fPrintCmd;
|
||||
delete fEventDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == PrintCmd)
|
||||
{eventAction->SetPrintModulo(PrintCmd->GetNewIntValue(newValue));}
|
||||
if (command == fPrintCmd)
|
||||
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,805 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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/TestEm14/src/ExG4HbookAnalysisManager.cc
|
||||
/// \brief Implementation of the ExG4HbookAnalysisManager class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
/// \file ExG4HbookAnalysisManager.cc
|
||||
/// \brief Implementation of the ExG4HbookAnalysisManager class
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifdef G4_USE_HBOOK
|
||||
|
||||
#include "ExG4HbookAnalysisManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern "C" int setpawc();
|
||||
extern "C" int setntuc();
|
||||
|
||||
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::fgInstance = 0;
|
||||
const G4int ExG4HbookAnalysisManager::fgkDefaultH2HbookIdOffset = 100;
|
||||
const G4int ExG4HbookAnalysisManager::fgkDefaultNtupleHbookId = 1;
|
||||
const G4String ExG4HbookAnalysisManager::fgkDefaultNtupleDirectoryName = "ntuple";
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Instance()
|
||||
{
|
||||
if ( fgInstance == 0 ) {
|
||||
fgInstance = new ExG4HbookAnalysisManager();
|
||||
}
|
||||
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
|
||||
: G4VAnalysisManager("Hbook"),
|
||||
fH1HbookIdOffset(-1),
|
||||
fH2HbookIdOffset(-1),
|
||||
fNtupleHbookId(-1),
|
||||
fFile(0),
|
||||
fH1Vector(),
|
||||
fH1MapByName(),
|
||||
fH2Vector(),
|
||||
fH2MapByName(),
|
||||
fNtupleName(),
|
||||
fNtupleTitle(),
|
||||
fNtuple(0),
|
||||
fNtupleIColumnMap(),
|
||||
fNtupleFColumnMap(),
|
||||
fNtupleDColumnMap()
|
||||
{
|
||||
if ( fgInstance ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "G4HbookAnalysisManager already exists."
|
||||
<< "Cannot create another instance.";
|
||||
G4Exception("G4HbookAnalysisManager::G4HbookAnalysisManager()",
|
||||
"Analysis_F001", FatalException, description);
|
||||
}
|
||||
|
||||
fgInstance = this;
|
||||
|
||||
// Initialize HBOOK :
|
||||
tools::hbook::CHLIMIT(setpawc());
|
||||
setntuc(); //for ntuple.
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
ExG4HbookAnalysisManager::~ExG4HbookAnalysisManager()
|
||||
{
|
||||
std::vector<tools::hbook::h1*>::iterator it;
|
||||
for ( it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
|
||||
delete *it;
|
||||
}
|
||||
std::vector<tools::hbook::h2*>::iterator it2;
|
||||
for ( it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
|
||||
delete *it2;
|
||||
}
|
||||
delete fNtuple;
|
||||
delete fFile;
|
||||
|
||||
fgInstance = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<int>*
|
||||
ExG4HbookAnalysisManager::GetNtupleIColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
|
||||
= fNtupleIColumnMap.find(id);
|
||||
if ( it == fNtupleIColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<float>*
|
||||
ExG4HbookAnalysisManager::GetNtupleFColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
|
||||
= fNtupleFColumnMap.find(id);
|
||||
if ( it == fNtupleFColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple::column<double>*
|
||||
ExG4HbookAnalysisManager::GetNtupleDColumn(G4int id) const
|
||||
{
|
||||
std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
|
||||
= fNtupleDColumnMap.find(id);
|
||||
if ( it == fNtupleDColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::OpenFile(const G4String& fileName)
|
||||
{
|
||||
G4String name(fileName);
|
||||
if ( name.find(".") == std::string::npos ) {
|
||||
name.append(".");
|
||||
name.append(GetFileType());
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("open", "analysis file", name);
|
||||
#endif
|
||||
|
||||
tools::hbook::CHCDIR("//PAWC"," ");
|
||||
|
||||
unsigned int unit = 1;
|
||||
fFile = new tools::hbook::wfile(std::cout, name, unit);
|
||||
if ( ! fFile->is_valid() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Cannot open file " << fileName;
|
||||
G4Exception("G4HbookAnalysisManager::OpenFile()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point, in HBOOK, we should have :
|
||||
// - created a //LUN1 directory attached to the file
|
||||
// - created a //PAWC/LUN1 in memory
|
||||
// - be in the directory //PAWC/LUN1.
|
||||
|
||||
// create an "histo" HBOOK directory both in memory and in the file :
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
|
||||
tools::hbook::CHCDIR("//LUN1"," ");
|
||||
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
|
||||
}
|
||||
|
||||
fLockHistoDirectoryName = true;
|
||||
|
||||
// the five upper lines could have been done with :
|
||||
//fFile->cd_home();
|
||||
//fFile->mkcd("histo");
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("open", "analysis file", name);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::Write()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("write", "file", "");
|
||||
#endif
|
||||
|
||||
// ntuple
|
||||
//if ( fNtuple ) fNtuple->add_row_end();
|
||||
|
||||
G4bool result = fFile->write();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("write", "file", "", result);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::CloseFile()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("close", "file", "");
|
||||
#endif
|
||||
|
||||
//WARNING : have to delete the ntuple before closing the file.
|
||||
delete fNtuple;
|
||||
fNtuple = 0;
|
||||
|
||||
G4bool result = fFile->close();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("close", "file", "", result);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateH1(const G4String& name, const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "H1", name);
|
||||
#endif
|
||||
|
||||
// Go to histograms directory
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
G4String histoPath = "//PAWC/LUN1/";
|
||||
histoPath.append(fHistoDirectoryName.data());
|
||||
tools::hbook::CHCDIR(histoPath.data()," ");
|
||||
}
|
||||
|
||||
// Set fH1HbookIdOffset if needed
|
||||
if ( fH1Vector.size() == 0 ) {
|
||||
if ( fH1HbookIdOffset == -1 ) {
|
||||
if ( fFirstHistoId > 0 )
|
||||
fH1HbookIdOffset = 0;
|
||||
else
|
||||
fH1HbookIdOffset = 1;
|
||||
|
||||
if ( fH1HbookIdOffset > 0 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
|
||||
G4Exception("ExG4HbookAnalysisManager::CreateH1()",
|
||||
"Analysis_W011", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create histogram
|
||||
G4int index = fH1Vector.size();
|
||||
G4int hbookIndex = fH1HbookIdOffset + fH1Vector.size() + fFirstHistoId;
|
||||
tools::hbook::h1* h1 = new tools::hbook::h1(hbookIndex, title, nbins, xmin, xmax);
|
||||
fH1Vector.push_back(h1);
|
||||
fH1MapByName[name] = h1;
|
||||
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
// Return to //PAWC/LUN1 :
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
}
|
||||
|
||||
fLockFirstHistoId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << hbookIndex;
|
||||
fpVerboseL1->Message("create", "H1", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstHistoId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateH2(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "H2", name);
|
||||
#endif
|
||||
|
||||
// Go to histograms directory
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
G4String histoPath = "//PAWC/LUN1/";
|
||||
histoPath.append(fHistoDirectoryName.data());
|
||||
tools::hbook::CHCDIR(histoPath.data()," ");
|
||||
}
|
||||
|
||||
// Set fH2HbookIdOffset if needed
|
||||
if ( fH2Vector.size() == 0 ) {
|
||||
if ( fH2HbookIdOffset == -1 ) {
|
||||
if ( fFirstHistoId > 0 )
|
||||
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
|
||||
else
|
||||
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset + 1;
|
||||
|
||||
if ( fH2HbookIdOffset != fgkDefaultH2HbookIdOffset ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "H2 will be defined in HBOOK with ID = "
|
||||
<< fgkDefaultH2HbookIdOffset << " + G4_firstHistoId + 1";
|
||||
G4Exception("ExG4HbookAnalysisManager::CreateH2()",
|
||||
"Analysis_W011", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4int index = fH2Vector.size();
|
||||
G4int hbookIndex = fH2HbookIdOffset + fH2Vector.size() + fFirstHistoId;
|
||||
tools::hbook::h2* h2
|
||||
= new tools::hbook::h2(hbookIndex, title, nxbins, xmin, xmax, nybins, ymin, ymax);
|
||||
fH2Vector.push_back(h2);
|
||||
fH2MapByName[name] = h2;
|
||||
|
||||
// Return to //PAWC/LUN1 :
|
||||
if ( fHistoDirectoryName != "" ) {
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
}
|
||||
|
||||
fLockFirstHistoId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << hbookIndex;
|
||||
fpVerboseL1->Message("create", "H2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstHistoId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ExG4HbookAnalysisManager::CreateNtuple(const G4String& name,
|
||||
const G4String& title)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple", name);
|
||||
#endif
|
||||
|
||||
if ( fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple already exists. "
|
||||
<< "(Only one ntuple is currently supported.)";
|
||||
G4Exception("G4HbookAnalysisManager::CreateNtuple()",
|
||||
"Analysis_W006", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create an "ntuple" directory both in memory and in the file
|
||||
fFile->cd_home(); //go under //PAWC/LUN1
|
||||
if ( fNtupleDirectoryName == "" )
|
||||
fFile->mkcd(fgkDefaultNtupleDirectoryName.data());
|
||||
else
|
||||
fFile->mkcd(fNtupleDirectoryName.data());
|
||||
|
||||
// Define ntuple ID in HBOOK
|
||||
if ( fNtupleHbookId == -1 ) fNtupleHbookId = fgkDefaultNtupleHbookId;
|
||||
|
||||
// We should be under //PAWC/LUN1/ntuple
|
||||
fNtuple = new tools::hbook::wntuple(fNtupleHbookId, name);
|
||||
fNtupleName = name;
|
||||
fNtupleTitle = title;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " name : " << name << " hbook index : " << fNtupleHbookId;
|
||||
fpVerboseL1->Message("create", "ntuple", description);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleIColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple I column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<int>* column = fNtuple->create_column<int>(name);
|
||||
fNtupleIColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple I column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleFColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple F column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<float>* column = fNtuple->create_column<float>(name);
|
||||
fNtupleFColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple F column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int ExG4HbookAnalysisManager::CreateNtupleDColumn(const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("create", "ntuple D column", name);
|
||||
#endif
|
||||
|
||||
G4int index = fNtuple->columns().size();
|
||||
tools::hbook::wntuple::column<double>* column = fNtuple->create_column<double>(name);
|
||||
fNtupleDColumnMap[index] = column;
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("create", "ntuple D column", name);
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ExG4HbookAnalysisManager::FinishNtuple()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("finish", "ntuple", fNtupleName);
|
||||
#endif
|
||||
|
||||
// Return to //PAWC/LUN1 :
|
||||
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
|
||||
|
||||
//fNtuple->add_row_beg();
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL1 )
|
||||
fpVerboseL1->Message("finish", "ntuple", fNtupleName);
|
||||
#endif
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillH1(G4int id, G4double value, G4double weight)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "H1", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::h1* h1 = GetH1(id);
|
||||
if ( ! h1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histogram " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillH1()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
h1->fill(value, weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "H1", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillH2(G4int id,
|
||||
G4double xvalue, G4double yvalue,
|
||||
G4double weight)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue << " yvalue " << yvalue;
|
||||
fpVerboseL3->Message("fill", "H2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::h2* h2 = GetH2(id);
|
||||
if ( ! h2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histogram " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillH2()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
h2->fill(xvalue, yvalue, weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue << " yvalue " << yvalue;
|
||||
fpVerboseL2->Message("fill", "H2", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleIColumn(G4int id, G4int value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<int>* column = GetNtupleIColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleFColumn(G4int id, G4float value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<float>* column = GetNtupleFColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::FillNtupleDColumn(G4int id, G4double value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL3->Message("fill", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
tools::hbook::wntuple::column<double>* column = GetNtupleDColumn(id);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "column " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value;
|
||||
fpVerboseL2->Message("fill", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::AddNtupleRow()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL3 )
|
||||
fpVerboseL3->Message("add", "ntuple row", "");
|
||||
#endif
|
||||
|
||||
//G4cout << "Hbook: Going to add Ntuple row ..." << G4endl;
|
||||
if ( ! fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple does not exist. ";
|
||||
G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
|
||||
"Analysis_W008", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
//fNtuple->add_row_fast();
|
||||
fNtuple->add_row();
|
||||
#ifdef G4VERBOSE
|
||||
if ( fpVerboseL2 )
|
||||
fpVerboseL2->Message("add", "ntuple row", "");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::h1* ExG4HbookAnalysisManager::GetH1(G4int id, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstHistoId;
|
||||
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
|
||||
if ( warn) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histo " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetH1()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fH1Vector[index];
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::h2* ExG4HbookAnalysisManager::GetH2(G4int id, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstHistoId;
|
||||
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
|
||||
if ( warn) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "histo " << id << " does not exist.";
|
||||
G4Exception("G4HbookAnalysisManager::GetH2()",
|
||||
"Analysis_W007", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fH2Vector[index];
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple() const
|
||||
{
|
||||
return fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetH1HbookIdOffset(G4int offset)
|
||||
{
|
||||
if ( fH1Vector.size() ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fFirstHistoId + offset < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The first histogram HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fH1HbookIdOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetH2HbookIdOffset(G4int offset)
|
||||
{
|
||||
if ( fH2Vector.size() ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fFirstHistoId + offset < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The first histogram HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fH2HbookIdOffset = offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool ExG4HbookAnalysisManager::SetNtupleHbookId(G4int ntupleId)
|
||||
{
|
||||
if ( fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set NtupleHbookId as an ntuple already exists.";
|
||||
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
|
||||
"Analysis_W010", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ntupleId < 1 ) {
|
||||
G4ExceptionDescription description;
|
||||
description << "The ntuple HBOOK id must be >= 1.";
|
||||
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
|
||||
"Analysis_W010", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fNtupleHbookId = ntupleId;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,236 +23,66 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: HistoManager.cc,v 1.8 2010-11-09 20:36:27 asaim Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoManager.hh"
|
||||
#include "HistoMessenger.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include "AIDA/AIDA.h"
|
||||
#endif
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::HistoManager()
|
||||
:af(0),tree(0),factoryOn(false)
|
||||
: fFileName("testem14")
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
// Creating the analysis factory
|
||||
af = AIDA_createAnalysisFactory();
|
||||
if(!af) {
|
||||
G4cout << " HistoManager::HistoManager() :"
|
||||
<< " problem creating the AIDA analysis factory."
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
fileName[0] = "testem14";
|
||||
fileType = "root";
|
||||
fileOption = "";
|
||||
// histograms
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
histo[k] = 0;
|
||||
exist[k] = false;
|
||||
Unit[k] = 1.0;
|
||||
Width[k] = 1.0;
|
||||
ascii[k] = false;
|
||||
}
|
||||
|
||||
histoMessenger = new HistoMessenger(this);
|
||||
Book();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::~HistoManager()
|
||||
{
|
||||
delete histoMessenger;
|
||||
delete G4AnalysisManager::Instance();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
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
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
delete af;
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::book()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(!af) return;
|
||||
|
||||
// Creating a tree mapped to an hbook file.
|
||||
fileName[1] = fileName[0] + "." + fileType;
|
||||
G4bool readOnly = false;
|
||||
G4bool createNew = true;
|
||||
AIDA::ITreeFactory* tf = af->createTreeFactory();
|
||||
tree = tf->create(fileName[1], fileType, readOnly, createNew, fileOption);
|
||||
delete tf;
|
||||
if(!tree) {
|
||||
G4cout << "HistoManager::book() :"
|
||||
<< " problem creating the AIDA tree with "
|
||||
<< " storeName = " << fileName[1]
|
||||
<< " storeType = " << fileType
|
||||
<< " readOnly = " << readOnly
|
||||
<< " createNew = " << createNew
|
||||
<< " options = " << fileOption
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Creating a histogram factory, whose histograms will be handled by the tree
|
||||
AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
|
||||
|
||||
// create selected histograms
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
if (exist[k]) {
|
||||
histo[k] = hf->createHistogram1D( Label[k], Title[k],
|
||||
Nbins[k], Vmin[k], Vmax[k]);
|
||||
factoryOn = true;
|
||||
}
|
||||
}
|
||||
delete hf;
|
||||
if(factoryOn)
|
||||
G4cout << "\n----> Histogram Tree is opened " << fileName[1] << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::save()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if (factoryOn) {
|
||||
saveAscii(); // Write ascii file, if any
|
||||
tree->commit(); // Writing the histograms to the file
|
||||
tree->close(); // and closing the tree (and the file)
|
||||
G4cout << "\n----> Histogram Tree is saved in " << fileName[1] << G4endl;
|
||||
|
||||
delete tree;
|
||||
tree = 0;
|
||||
factoryOn = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....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;
|
||||
}
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(exist[ih]) histo[ih]->fill(e/Unit[ih], weight);
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::SetHisto(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"};
|
||||
// Define histograms start values
|
||||
const G4int kMaxHisto = 7;
|
||||
const G4String id[] = { "0", "1", "2", "3" , "4", "5", "6"};
|
||||
const G4String title[] =
|
||||
{ "dummy", //0
|
||||
"scattered primary particle: energy spectrum", //1
|
||||
"scattered primary particle: costheta distribution", //2
|
||||
"charged secondaries: energy spectrum", //3
|
||||
"charged secondaries: costheta distribution", //4
|
||||
"neutral secondaries: energy spectrum", //5
|
||||
"neutral secondaries: costheta distribution" //6
|
||||
};
|
||||
{ "dummy", //0
|
||||
"scattered primary particle: energy spectrum", //1
|
||||
"scattered primary particle: costheta distribution", //2
|
||||
"charged secondaries: energy spectrum", //3
|
||||
"charged secondaries: costheta distribution", //4
|
||||
"neutral secondaries: energy spectrum", //5
|
||||
"neutral secondaries: costheta distribution" //6
|
||||
};
|
||||
|
||||
// Default values (to be reset via /analysis/h1/set command)
|
||||
G4int nbins = 100;
|
||||
G4double vmin = 0.;
|
||||
G4double vmax = 100.;
|
||||
|
||||
G4String titl = title[ih];
|
||||
G4double vmin = valmin, vmax = valmax;
|
||||
Unit[ih] = 1.;
|
||||
|
||||
if (unit != "none") {
|
||||
titl = title[ih] + " (" + unit + ")";
|
||||
Unit[ih] = G4UnitDefinition::GetValueOf(unit);
|
||||
vmin = valmin/Unit[ih]; vmax = valmax/Unit[ih];
|
||||
// Create all histograms as inactivated
|
||||
// as we have not yet set nbins, vmin, vmax
|
||||
for (G4int k=0; k<kMaxHisto; k++) {
|
||||
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
|
||||
analysisManager->SetActivation(G4VAnalysisManager::kH1, ih, false);
|
||||
}
|
||||
|
||||
exist[ih] = true;
|
||||
Label[ih] = id[ih];
|
||||
Title[ih] = titl;
|
||||
Nbins[ih] = nbins;
|
||||
Vmin[ih] = vmin;
|
||||
Vmax[ih] = vmax;
|
||||
Width[ih] = (valmax-valmin)/nbins;
|
||||
|
||||
G4cout << "----> SetHisto " << ih << ": " << titl << "; "
|
||||
<< nbins << " bins from "
|
||||
<< vmin << " " << unit << " to " << vmax << " " << unit << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::RemoveHisto(G4int ih)
|
||||
{
|
||||
if (ih > MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::RemoveHisto() : histo " << ih
|
||||
<< "does not exist" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
histo[ih] = 0; exist[ih] = false;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::PrintHisto(G4int ih)
|
||||
{
|
||||
if (ih < MaxHisto) { ascii[ih] = true; ascii[0] = true; }
|
||||
else
|
||||
G4cout << "---> warning from HistoManager::PrintHisto() : histo " << ih
|
||||
<< "does not exist" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void HistoManager::saveAscii()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
if (!ascii[0]) return;
|
||||
|
||||
G4String name = fileName[0] + ".ascii";
|
||||
std::ofstream File(name, std::ios::out);
|
||||
File.setf( std::ios::scientific, std::ios::floatfield );
|
||||
|
||||
//write selected histograms
|
||||
for (G4int ih=0; ih<MaxHisto; ih++) {
|
||||
if (exist[ih] && ascii[ih]) {
|
||||
File << "\n 1D histogram " << ih << ": " << Title[ih]
|
||||
<< "\n \n \t X \t\t Y" << G4endl;
|
||||
|
||||
for (G4int iBin=0; iBin<Nbins[ih]; iBin++) {
|
||||
File << " " << iBin << "\t"
|
||||
<< histo[ih]->binMean(iBin) << "\t"
|
||||
<< histo[ih]->binHeight(iBin)
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: HistoMessenger.cc,v 1.4 2007-11-13 12:17:07 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoMessenger.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "HistoManager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoMessenger::HistoMessenger(HistoManager* manager)
|
||||
:histoManager (manager)
|
||||
{
|
||||
histoDir = new G4UIdirectory("/testem/histo/");
|
||||
histoDir->SetGuidance("histograms control");
|
||||
|
||||
factoryCmd = new G4UIcmdWithAString("/testem/histo/setFileName",this);
|
||||
factoryCmd->SetGuidance("set name for the histograms file");
|
||||
|
||||
typeCmd = new G4UIcmdWithAString("/testem/histo/setFileType",this);
|
||||
typeCmd->SetGuidance("set histograms file type: hbook, root, XML");
|
||||
typeCmd->SetCandidates("hbook root XML");
|
||||
|
||||
optionCmd = new G4UIcmdWithAString("/testem/histo/setFileOption",this);
|
||||
optionCmd->SetGuidance("set option for the histograms file");
|
||||
|
||||
histoCmd = new G4UIcommand("/testem/histo/setHisto",this);
|
||||
histoCmd->SetGuidance("Set bining of the histo number ih :");
|
||||
histoCmd->SetGuidance(" nbBins; valMin; valMax; unit (of vmin and vmax)");
|
||||
//
|
||||
G4UIparameter* ih = new G4UIparameter("ih",'i',false);
|
||||
ih->SetGuidance("histo number : from 1 to MaxHisto");
|
||||
ih->SetParameterRange("ih>0");
|
||||
histoCmd->SetParameter(ih);
|
||||
//
|
||||
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
|
||||
nbBins->SetGuidance("number of bins");
|
||||
nbBins->SetParameterRange("nbBins>0");
|
||||
histoCmd->SetParameter(nbBins);
|
||||
//
|
||||
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
|
||||
valMin->SetGuidance("valMin, expressed in unit");
|
||||
histoCmd->SetParameter(valMin);
|
||||
//
|
||||
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
|
||||
valMax->SetGuidance("valMax, expressed in unit");
|
||||
histoCmd->SetParameter(valMax);
|
||||
//
|
||||
G4UIparameter* unit = new G4UIparameter("unit",'s',true);
|
||||
unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
|
||||
unit->SetDefaultValue("none");
|
||||
histoCmd->SetParameter(unit);
|
||||
|
||||
prhistoCmd = new G4UIcmdWithAnInteger("/testem/histo/printHisto",this);
|
||||
prhistoCmd->SetGuidance("print histo #id on ascii file");
|
||||
prhistoCmd->SetParameterName("id",false);
|
||||
prhistoCmd->SetRange("id>0");
|
||||
|
||||
rmhistoCmd = new G4UIcmdWithAnInteger("/testem/histo/removeHisto",this);
|
||||
rmhistoCmd->SetGuidance("desactivate histo #id");
|
||||
rmhistoCmd->SetParameterName("id",false);
|
||||
rmhistoCmd->SetRange("id>0");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoMessenger::~HistoMessenger()
|
||||
{
|
||||
delete rmhistoCmd;
|
||||
delete prhistoCmd;
|
||||
delete histoCmd;
|
||||
delete optionCmd;
|
||||
delete typeCmd;
|
||||
delete factoryCmd;
|
||||
delete histoDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
{
|
||||
if (command == factoryCmd)
|
||||
histoManager->SetFileName(newValues);
|
||||
|
||||
if (command == typeCmd)
|
||||
histoManager->SetFileType(newValues);
|
||||
|
||||
if (command == optionCmd)
|
||||
histoManager->SetFileOption(newValues);
|
||||
|
||||
if (command == histoCmd)
|
||||
{ G4int ih,nbBins; G4double vmin,vmax; char unts[30];
|
||||
const char* t = newValues;
|
||||
std::istringstream is(t);
|
||||
is >> ih >> nbBins >> vmin >> vmax >> unts;
|
||||
G4String unit = unts;
|
||||
G4double vUnit = 1. ;
|
||||
if (unit != "none") vUnit = G4UIcommand::ValueOf(unit);
|
||||
histoManager->SetHisto (ih,nbBins,vmin*vUnit,vmax*vUnit,unit);
|
||||
}
|
||||
|
||||
if (command == prhistoCmd)
|
||||
histoManager->PrintHisto(prhistoCmd->GetNewIntValue(newValues));
|
||||
|
||||
if (command == rmhistoCmd)
|
||||
histoManager->RemoveHisto(rmhistoCmd->GetNewIntValue(newValues));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm14/src/PhysListEmLivermore.cc
|
||||
/// \brief Implementation of the PhysListEmLivermore class
|
||||
//
|
||||
// $Id: PhysListEmLivermore.cc,v 1.5 2010-04-02 13:22:02 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -72,6 +74,7 @@
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4ionIonisation.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -147,7 +150,7 @@ void PhysListEmLivermore::ConstructProcess()
|
||||
eBremModel->SetHighEnergyLimit(highEnergyLimit);
|
||||
eBrem->AddEmModel(0, eBremModel);
|
||||
pmanager->AddProcess(eBrem, -1,-1, 2);
|
||||
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
pmanager->AddProcess(new G4eIonisation, -1,-1, 1);
|
||||
@@ -165,8 +168,8 @@ void PhysListEmLivermore::ConstructProcess()
|
||||
pmanager->AddProcess(new G4ionIonisation, -1,-1, 1);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
pmanager->AddProcess(new G4hIonisation, -1,-1, 1);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm14/src/PhysListEmPenelope.cc
|
||||
/// \brief Implementation of the PhysListEmPenelope class
|
||||
//
|
||||
// $Id: PhysListEmPenelope.cc,v 1.5 2010-04-02 13:22:02 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -73,6 +75,7 @@
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4ionIonisation.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -148,7 +151,7 @@ void PhysListEmPenelope::ConstructProcess()
|
||||
eBremModel->SetHighEnergyLimit(highEnergyLimit);
|
||||
eBrem->AddEmModel(0, eBremModel);
|
||||
pmanager->AddProcess(eBrem, -1,-1, 2);
|
||||
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
G4eIonisation* eIoni = new G4eIonisation();
|
||||
@@ -183,8 +186,8 @@ void PhysListEmPenelope::ConstructProcess()
|
||||
pmanager->AddProcess(new G4ionIonisation, -1,-1, 1);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
pmanager->AddProcess(new G4hIonisation, -1,-1, 1);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm14/src/PhysListEmStandard.cc
|
||||
/// \brief Implementation of the PhysListEmStandard class
|
||||
//
|
||||
// $Id: PhysListEmStandard.cc,v 1.6 2011-01-07 14:19:59 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -55,6 +57,8 @@
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4UAtomicDeexcitation.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysListEmStandard::PhysListEmStandard(const G4String& name)
|
||||
@@ -91,7 +95,7 @@ void PhysListEmStandard::ConstructProcess()
|
||||
//electron
|
||||
pmanager->AddProcess(new G4eIonisation, -1,-1,1);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1,-1,2);
|
||||
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
pmanager->AddProcess(new G4eIonisation, -1,-1,1);
|
||||
@@ -109,8 +113,8 @@ void PhysListEmStandard::ConstructProcess()
|
||||
pmanager->AddProcess(new G4ionIonisation, -1,-1,1);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
pmanager->AddProcess(new G4hIonisation, -1,-1,1);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm14/src/PhysicsList.cc
|
||||
/// \brief Implementation of the PhysicsList class
|
||||
//
|
||||
//
|
||||
// $Id: PhysicsList.cc,v 1.8 2010-04-05 18:02:39 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,6 +41,7 @@
|
||||
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -47,26 +50,30 @@ PhysicsList::PhysicsList()
|
||||
{
|
||||
G4LossTableManager::Instance();
|
||||
|
||||
currentDefaultCut = 1.0*mm;
|
||||
cutForGamma = currentDefaultCut;
|
||||
cutForElectron = currentDefaultCut;
|
||||
cutForPositron = currentDefaultCut;
|
||||
fCurrentDefaultCut = 1.0*mm;
|
||||
fCutForGamma = fCurrentDefaultCut;
|
||||
fCutForElectron = fCurrentDefaultCut;
|
||||
fCutForPositron = fCurrentDefaultCut;
|
||||
|
||||
pMessenger = new PhysicsListMessenger(this);
|
||||
fMessenger = new PhysicsListMessenger(this);
|
||||
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// EM physics
|
||||
emName = G4String("standard");
|
||||
emPhysicsList = new PhysListEmStandard(emName);
|
||||
|
||||
fEmName = G4String("standard");
|
||||
fEmPhysicsList = new PhysListEmStandard(fEmName);
|
||||
|
||||
//add new units for cross sections
|
||||
//
|
||||
new G4UnitDefinition( "mm2/g", "mm2/g","Surface/Mass", mm2/g);
|
||||
new G4UnitDefinition( "um2/mg", "um2/mg","Surface/Mass", um*um/mg);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::~PhysicsList()
|
||||
{
|
||||
delete pMessenger;
|
||||
delete fMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -177,7 +184,7 @@ void PhysicsList::ConstructProcess()
|
||||
|
||||
// Electromagnetic physics list
|
||||
//
|
||||
emPhysicsList->ConstructProcess();
|
||||
fEmPhysicsList->ConstructProcess();
|
||||
|
||||
// Em options
|
||||
//
|
||||
@@ -193,22 +200,22 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
|
||||
}
|
||||
|
||||
if (name == emName) return;
|
||||
if (name == fEmName) return;
|
||||
|
||||
if (name == "standard") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new PhysListEmStandard(name);
|
||||
fEmName = name;
|
||||
delete fEmPhysicsList;
|
||||
fEmPhysicsList = new PhysListEmStandard(name);
|
||||
|
||||
} else if (name == "livermore") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new PhysListEmLivermore(name);
|
||||
fEmName = name;
|
||||
delete fEmPhysicsList;
|
||||
fEmPhysicsList = new PhysListEmLivermore(name);
|
||||
|
||||
} else if (name == "penelope") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new PhysListEmPenelope(name);
|
||||
fEmName = name;
|
||||
delete fEmPhysicsList;
|
||||
fEmPhysicsList = new PhysListEmPenelope(name);
|
||||
|
||||
} else {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
|
||||
@@ -230,33 +237,33 @@ void PhysicsList::SetCuts()
|
||||
|
||||
// set cut values for gamma at first and for e- second and next for e+,
|
||||
// because some processes for e+/e- need cut values for gamma
|
||||
SetCutValue(cutForGamma, "gamma");
|
||||
SetCutValue(cutForElectron, "e-");
|
||||
SetCutValue(cutForPositron, "e+");
|
||||
SetCutValue(fCutForGamma, "gamma");
|
||||
SetCutValue(fCutForElectron, "e-");
|
||||
SetCutValue(fCutForPositron, "e+");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForGamma(G4double cut)
|
||||
{
|
||||
cutForGamma = cut;
|
||||
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
|
||||
fCutForGamma = cut;
|
||||
SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForElectron(G4double cut)
|
||||
{
|
||||
cutForElectron = cut;
|
||||
SetParticleCuts(cutForElectron, G4Electron::Electron());
|
||||
fCutForElectron = cut;
|
||||
SetParticleCuts(fCutForElectron, G4Electron::Electron());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCutForPositron(G4double cut)
|
||||
{
|
||||
cutForPositron = cut;
|
||||
SetParticleCuts(cutForPositron, G4Positron::Positron());
|
||||
fCutForPositron = cut;
|
||||
SetParticleCuts(fCutForPositron, G4Positron::Positron());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsListMessenger.cc,v 1.3 2006-06-29 16:45:55 gunter Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/PhysicsListMessenger.cc
|
||||
/// \brief Implementation of the PhysicsListMessenger class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,55 +41,55 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
|
||||
:pPhysicsList(pPhys)
|
||||
:fPhysicsList(pPhys)
|
||||
{
|
||||
physDir = new G4UIdirectory("/testem/phys/");
|
||||
physDir->SetGuidance("physics list commands");
|
||||
fPhysDir = new G4UIdirectory("/testem/phys/");
|
||||
fPhysDir->SetGuidance("physics list commands");
|
||||
|
||||
gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
|
||||
gammaCutCmd->SetGuidance("Set gamma cut.");
|
||||
gammaCutCmd->SetParameterName("Gcut",false);
|
||||
gammaCutCmd->SetUnitCategory("Length");
|
||||
gammaCutCmd->SetRange("Gcut>0.0");
|
||||
gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
|
||||
fGammaCutCmd->SetGuidance("Set gamma cut.");
|
||||
fGammaCutCmd->SetParameterName("Gcut",false);
|
||||
fGammaCutCmd->SetUnitCategory("Length");
|
||||
fGammaCutCmd->SetRange("Gcut>0.0");
|
||||
fGammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
electCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
|
||||
electCutCmd->SetGuidance("Set electron cut.");
|
||||
electCutCmd->SetParameterName("Ecut",false);
|
||||
electCutCmd->SetUnitCategory("Length");
|
||||
electCutCmd->SetRange("Ecut>0.0");
|
||||
electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
|
||||
fElectCutCmd->SetGuidance("Set electron cut.");
|
||||
fElectCutCmd->SetParameterName("Ecut",false);
|
||||
fElectCutCmd->SetUnitCategory("Length");
|
||||
fElectCutCmd->SetRange("Ecut>0.0");
|
||||
fElectCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
protoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
|
||||
protoCutCmd->SetGuidance("Set positron cut.");
|
||||
protoCutCmd->SetParameterName("Pcut",false);
|
||||
protoCutCmd->SetUnitCategory("Length");
|
||||
protoCutCmd->SetRange("Pcut>0.0");
|
||||
protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fProtoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
|
||||
fProtoCutCmd->SetGuidance("Set positron cut.");
|
||||
fProtoCutCmd->SetParameterName("Pcut",false);
|
||||
fProtoCutCmd->SetUnitCategory("Length");
|
||||
fProtoCutCmd->SetRange("Pcut>0.0");
|
||||
fProtoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
allCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
|
||||
allCutCmd->SetGuidance("Set cut for all.");
|
||||
allCutCmd->SetParameterName("cut",false);
|
||||
allCutCmd->SetUnitCategory("Length");
|
||||
allCutCmd->SetRange("cut>0.0");
|
||||
allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
|
||||
fAllCutCmd->SetGuidance("Set cut for all.");
|
||||
fAllCutCmd->SetParameterName("cut",false);
|
||||
fAllCutCmd->SetUnitCategory("Length");
|
||||
fAllCutCmd->SetRange("cut>0.0");
|
||||
fAllCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
pListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
|
||||
pListCmd->SetGuidance("Add modula physics list.");
|
||||
pListCmd->SetParameterName("PList",false);
|
||||
pListCmd->AvailableForStates(G4State_PreInit);
|
||||
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
|
||||
fListCmd->SetGuidance("Add modula physics list.");
|
||||
fListCmd->SetParameterName("PList",false);
|
||||
fListCmd->AvailableForStates(G4State_PreInit);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsListMessenger::~PhysicsListMessenger()
|
||||
{
|
||||
delete gammaCutCmd;
|
||||
delete electCutCmd;
|
||||
delete protoCutCmd;
|
||||
delete allCutCmd;
|
||||
delete pListCmd;
|
||||
delete physDir;
|
||||
delete fGammaCutCmd;
|
||||
delete fElectCutCmd;
|
||||
delete fProtoCutCmd;
|
||||
delete fAllCutCmd;
|
||||
delete fListCmd;
|
||||
delete fPhysDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -95,25 +97,25 @@ PhysicsListMessenger::~PhysicsListMessenger()
|
||||
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
if( command == gammaCutCmd )
|
||||
{ pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));}
|
||||
if( command == fGammaCutCmd )
|
||||
{ fPhysicsList->SetCutForGamma(fGammaCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == electCutCmd )
|
||||
{ pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));}
|
||||
if( command == fElectCutCmd )
|
||||
{ fPhysicsList->SetCutForElectron(fElectCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == protoCutCmd )
|
||||
{ pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));}
|
||||
if( command == fProtoCutCmd )
|
||||
{ fPhysicsList->SetCutForPositron(fProtoCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == allCutCmd )
|
||||
if( command == fAllCutCmd )
|
||||
{
|
||||
G4double cut = allCutCmd->GetNewDoubleValue(newValue);
|
||||
pPhysicsList->SetCutForGamma(cut);
|
||||
pPhysicsList->SetCutForElectron(cut);
|
||||
pPhysicsList->SetCutForPositron(cut);
|
||||
G4double cut = fAllCutCmd->GetNewDoubleValue(newValue);
|
||||
fPhysicsList->SetCutForGamma(cut);
|
||||
fPhysicsList->SetCutForElectron(cut);
|
||||
fPhysicsList->SetCutForPositron(cut);
|
||||
}
|
||||
|
||||
if( command == pListCmd )
|
||||
{ pPhysicsList->AddPhysicsList(newValue);}
|
||||
if( command == fListCmd )
|
||||
{ fPhysicsList->AddPhysicsList(newValue);}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc,v 1.3 2006-06-29 16:45:57 gunter Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -36,26 +38,27 @@
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
|
||||
:detector(det)
|
||||
:fDetector(det)
|
||||
{
|
||||
particleGun = new G4ParticleGun(1);
|
||||
fParticleGun = new G4ParticleGun(1);
|
||||
G4ParticleDefinition* particle
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("gamma");
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleEnergy(1*MeV);
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
fParticleGun->SetParticleEnergy(1*MeV);
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -64,7 +67,7 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
//this function is called at the begining of event
|
||||
//
|
||||
G4double halfSize = 0.5*(detector->GetSize());
|
||||
G4double halfSize = 0.5*(fDetector->GetSize());
|
||||
G4double x0 = - halfSize;
|
||||
|
||||
//randomize (y0,z0)
|
||||
@@ -73,8 +76,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
G4double y0 = (2*G4UniformRand()-1.)*beam;
|
||||
G4double z0 = (2*G4UniformRand()-1.)*beam;
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.cc,v 1.5 2010-04-05 18:02:39 maire Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -41,20 +43,24 @@
|
||||
#include "G4EmCalculator.hh"
|
||||
#include "G4Gamma.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
#include <iomanip>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim,
|
||||
HistoManager* histo)
|
||||
: detector(det), primary(prim), histoManager(histo)
|
||||
{ }
|
||||
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
|
||||
: fDetector(det), fPrimary(prim)
|
||||
{
|
||||
fHistoManager = new HistoManager();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction()
|
||||
{ }
|
||||
{
|
||||
delete fHistoManager;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -66,11 +72,16 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
|
||||
totalCount = 0;
|
||||
sumTrack = sumTrack2 = 0.;
|
||||
eTransfer = 0.;
|
||||
|
||||
histoManager->book();
|
||||
fTotalCount = 0;
|
||||
fSumTrack = fSumTrack2 = 0.;
|
||||
fEnTransfer = 0.;
|
||||
|
||||
//histograms
|
||||
//
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->OpenFile();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -82,24 +93,24 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
|
||||
G4int prec = G4cout.precision(5);
|
||||
|
||||
G4Material* material = detector->GetMaterial();
|
||||
G4Material* material = fDetector->GetMaterial();
|
||||
G4double density = material->GetDensity();
|
||||
G4int survive = 0;
|
||||
|
||||
G4ParticleDefinition* particle =
|
||||
primary->GetParticleGun()->GetParticleDefinition();
|
||||
fPrimary->GetParticleGun()->GetParticleDefinition();
|
||||
G4String Particle = particle->GetParticleName();
|
||||
G4double energy = primary->GetParticleGun()->GetParticleEnergy();
|
||||
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
|
||||
G4cout << "\n The run consists of " << NbOfEvents << " "<< Particle << " of "
|
||||
<< G4BestUnit(energy,"Energy") << " through "
|
||||
<< G4BestUnit(detector->GetSize(),"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
<< G4BestUnit(fDetector->GetSize(),"Length") << " of "
|
||||
<< material->GetName() << " (density: "
|
||||
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
|
||||
|
||||
//frequency of processes
|
||||
G4cout << "\n Process calls frequency --->";
|
||||
std::map<G4String,G4int>::iterator it;
|
||||
for (it = procCounter.begin(); it != procCounter.end(); it++) {
|
||||
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
|
||||
G4String procName = it->first;
|
||||
G4int count = it->second;
|
||||
G4cout << "\t" << procName << " = " << count;
|
||||
@@ -108,16 +119,16 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
|
||||
if (survive > 0) {
|
||||
G4cout << "\n\n Nb of incident particles surviving after "
|
||||
<< G4BestUnit(detector->GetSize(),"Length") << " of "
|
||||
<< material->GetName() << " : " << survive << G4endl;
|
||||
<< G4BestUnit(fDetector->GetSize(),"Length") << " of "
|
||||
<< material->GetName() << " : " << survive << G4endl;
|
||||
}
|
||||
|
||||
if (totalCount == 0) totalCount = 1; //force printing anyway
|
||||
if (fTotalCount == 0) fTotalCount = 1; //force printing anyway
|
||||
|
||||
//compute mean free path and related quantities
|
||||
//
|
||||
G4double MeanFreePath = sumTrack /totalCount;
|
||||
G4double MeanTrack2 = sumTrack2/totalCount;
|
||||
G4double MeanFreePath = fSumTrack /fTotalCount;
|
||||
G4double MeanTrack2 = fSumTrack2/fTotalCount;
|
||||
G4double rms = std::sqrt(std::fabs(MeanTrack2 - MeanFreePath*MeanFreePath));
|
||||
G4double CrossSection = 1./MeanFreePath;
|
||||
G4double massicMFP = MeanFreePath*density;
|
||||
@@ -127,16 +138,16 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
<< " +- " << G4BestUnit( rms,"Length")
|
||||
<< "\tmassic: " << G4BestUnit(massicMFP, "Mass/Surface")
|
||||
<< "\n CrossSection:\t" << CrossSection*cm << " cm^-1 "
|
||||
<< "\t\t\tmassic: " << G4BestUnit(massicCS, "Surface/Mass")
|
||||
<< "\t\t\tmassic: " << G4BestUnit(massicCS, "Surface/Mass")
|
||||
<< G4endl;
|
||||
|
||||
|
||||
//compute energy transfer coefficient
|
||||
//
|
||||
G4double MeanTransfer = eTransfer/totalCount;
|
||||
G4double MeanTransfer = fEnTransfer/fTotalCount;
|
||||
G4double massTransfCoef = massicCS*MeanTransfer/energy;
|
||||
|
||||
G4cout << "\n mean energy of charged secondaries: " << G4BestUnit(MeanTransfer, "Energy")
|
||||
<< "\tmass_energy_transfer coef: " << G4BestUnit(massTransfCoef, "Surface/Mass")
|
||||
<< "\tmass_energy_transfer coef: " << G4BestUnit(massTransfCoef, "Surface/Mass")
|
||||
<< G4endl;
|
||||
|
||||
//check cross section from G4EmCalculator
|
||||
@@ -146,7 +157,7 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
|
||||
G4EmCalculator emCalculator;
|
||||
G4double sumc = 0.0;
|
||||
for (it = procCounter.begin(); it != procCounter.end(); it++) {
|
||||
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
|
||||
G4String procName = it->first;
|
||||
G4double massSigma =
|
||||
emCalculator.GetCrossSectionPerVolume(energy,particle,
|
||||
@@ -154,21 +165,26 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
if (particle == G4Gamma::Gamma())
|
||||
massSigma =
|
||||
emCalculator.ComputeCrossSectionPerVolume(energy,particle,
|
||||
procName,material)/density;
|
||||
procName,material)/density;
|
||||
sumc += massSigma;
|
||||
G4cout << "\t" << procName << "= "
|
||||
<< G4BestUnit(massSigma, "Surface/Mass");
|
||||
}
|
||||
}
|
||||
G4cout << "\ttotal= "
|
||||
<< G4BestUnit(sumc, "Surface/Mass") << G4endl;
|
||||
|
||||
//restore default format
|
||||
|
||||
//restore default format
|
||||
G4cout.precision(prec);
|
||||
|
||||
// remove all contents in procCounter
|
||||
procCounter.clear();
|
||||
|
||||
histoManager->save();
|
||||
// remove all contents in fProcCounter
|
||||
fProcCounter.clear();
|
||||
|
||||
//save histograms
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
}
|
||||
|
||||
// show Rndm status
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: SteppingAction.cc,v 1.7 2010-10-13 13:42:33 vnivanch Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
/// \file electromagnetic/TestEm14/src/SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -37,9 +39,8 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction(PrimaryGeneratorAction* prim,
|
||||
RunAction* RuAct, HistoManager* Hist)
|
||||
:primary(prim),runAction(RuAct), histoManager(Hist)
|
||||
SteppingAction::SteppingAction(PrimaryGeneratorAction* prim, RunAction* RuAct)
|
||||
:fPrimary(prim),fRunAction(RuAct)
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -54,28 +55,29 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
const G4StepPoint* endPoint = aStep->GetPostStepPoint();
|
||||
G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
|
||||
G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary);
|
||||
if (transmit) { runAction->CountProcesses(procName); }
|
||||
if (transmit) { fRunAction->CountProcesses(procName); }
|
||||
else {
|
||||
//count real processes and sum track length
|
||||
G4double stepLength = aStep->GetStepLength();
|
||||
runAction->CountProcesses(procName);
|
||||
runAction->SumTrack(stepLength);
|
||||
fRunAction->CountProcesses(procName);
|
||||
fRunAction->SumTrack(stepLength);
|
||||
}
|
||||
|
||||
//plot final state (only if continuous energy loss is small enough)
|
||||
//plot final state
|
||||
//
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
//scattered primary particle
|
||||
//
|
||||
G4int id = 1;
|
||||
if (aStep->GetTrack()->GetTrackStatus() == fAlive) {
|
||||
G4double energy = endPoint->GetKineticEnergy();
|
||||
histoManager->FillHisto(id,energy);
|
||||
analysisManager->FillH1(id,energy);
|
||||
|
||||
id = 2;
|
||||
G4ThreeVector direction = endPoint->GetMomentumDirection();
|
||||
G4double costeta = direction.x();
|
||||
histoManager->FillHisto(id,costeta);
|
||||
analysisManager->FillH1(id,costeta);
|
||||
}
|
||||
|
||||
//secondaries
|
||||
@@ -85,15 +87,15 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge();
|
||||
if (charge != 0.) { id = 3; } else { id = 5; }
|
||||
G4double energy = (*secondary)[lp]->GetKineticEnergy();
|
||||
histoManager->FillHisto(id,energy);
|
||||
analysisManager->FillH1(id,energy);
|
||||
|
||||
++id;
|
||||
G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection();
|
||||
G4double costeta = direction.x();
|
||||
histoManager->FillHisto(id,costeta);
|
||||
analysisManager->FillH1(id,costeta);
|
||||
|
||||
//energy tranferred to charged secondaries
|
||||
if (charge != 0.) { runAction->SumeTransf(energy); }
|
||||
if (charge != 0.) { fRunAction->SumeTransf(energy); }
|
||||
}
|
||||
|
||||
// kill event after first interaction
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file electromagnetic/TestEm14/src/SteppingVerbose.cc
|
||||
/// \brief Implementation of the SteppingVerbose class
|
||||
//
|
||||
// $Id: SteppingVerbose.cc,v 1.1 2010-09-16 16:26:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -58,26 +60,26 @@ void SteppingVerbose::StepInfo()
|
||||
if( verboseLevel >= 3 ){
|
||||
G4cout << G4endl;
|
||||
G4cout << std::setw( 5) << "#Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
}
|
||||
|
||||
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName();
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName();
|
||||
|
||||
const G4VProcess* process
|
||||
= fStep->GetPostStepPoint()->GetProcessDefinedStep();
|
||||
@@ -89,28 +91,28 @@ void SteppingVerbose::StepInfo()
|
||||
|
||||
if( verboseLevel == 2 ){
|
||||
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
|
||||
fN2ndariesAlongStepDoIt +
|
||||
fN2ndariesPostStepDoIt;
|
||||
fN2ndariesAlongStepDoIt +
|
||||
fN2ndariesPostStepDoIt;
|
||||
if(tN2ndariesTot>0){
|
||||
G4cout << "\n :----- List of secondaries ----------------"
|
||||
<< G4endl;
|
||||
G4cout << "\n :----- List of secondaries ----------------"
|
||||
<< G4endl;
|
||||
G4cout.precision(4);
|
||||
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
|
||||
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
|
||||
lp1<(*fSecondary).size(); lp1++){
|
||||
G4cout << " "
|
||||
<< std::setw(13)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
|
||||
<< ": energy ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< " time ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
|
||||
G4cout << G4endl;
|
||||
}
|
||||
G4cout << " "
|
||||
<< std::setw(13)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
|
||||
<< ": energy ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< " time ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
G4cout << " :------------------------------------------\n"
|
||||
<< G4endl;
|
||||
G4cout << " :------------------------------------------\n"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,25 +131,25 @@ G4int prec = G4cout.precision(3);
|
||||
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user