Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: DetectorConstruction.cc 68734 2013-04-05 09:47:02Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -43,6 +43,7 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(),fWorldSizeXY(0),fWorldSizeZ(0)
|
||||
{
|
||||
fWorldSizeXY = 2*cm;
|
||||
fWorldSizeZ = 2*cm;
|
||||
|
||||
@@ -23,128 +23,46 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file eventgenerator/particleGun/src/HistoManager.cc
|
||||
/// \file hadronic/Hadr03/src/HistoManager.cc
|
||||
/// \brief Implementation of the HistoManager class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: HistoManager.cc 72243 2013-07-12 08:45:36Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoManager.hh"
|
||||
#include "HistoMessenger.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::HistoManager()
|
||||
: fFileName("particleGun")
|
||||
{
|
||||
fileName[0] = "particleGun";
|
||||
factoryOn = false;
|
||||
fNbHist = 0;
|
||||
|
||||
// histograms
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
fHistId[k] = 0;
|
||||
fHistPt[k] = 0;
|
||||
fExist[k] = false;
|
||||
fUnit[k] = 1.0;
|
||||
fWidth[k] = 1.0;
|
||||
fAscii[k] = false;
|
||||
}
|
||||
|
||||
fHistoMessenger = new HistoMessenger(this);
|
||||
Book();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoManager::~HistoManager()
|
||||
{
|
||||
delete fHistoMessenger;
|
||||
delete G4AnalysisManager::Instance();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::book()
|
||||
void HistoManager::Book()
|
||||
{
|
||||
// if no histos, do nothing
|
||||
if (fNbHist == 0) return;
|
||||
|
||||
// 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);
|
||||
G4String extension = analysisManager->GetType();
|
||||
fileName[1] = fileName[0] + "." + extension;
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
|
||||
if (!fileOpen) {
|
||||
G4cout << "\n---> HistoManager::book(): cannot open " << fileName[1]
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// create selected histograms
|
||||
//
|
||||
analysisManager->SetFirstHistoId(1);
|
||||
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
if (fExist[k]) {
|
||||
fHistId[k] = analysisManager->CreateH1( fLabel[k], fTitle[k],
|
||||
fNbins[k], fVmin[k], fVmax[k]);
|
||||
fHistPt[k] = analysisManager->GetH1(fHistId[k]);
|
||||
factoryOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (factoryOn)
|
||||
G4cout << "\n----> Histogram file is opened in " << fileName[1] << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::save()
|
||||
{
|
||||
if (factoryOn) {
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
saveAscii(); // Write fAscii file, if any
|
||||
G4cout << "\n----> Histograms are saved in " << fileName[1] << G4endl;
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
factoryOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
//....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 fExist; e= " << e << " w= " << weight << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fHistPt[ih]) fHistPt[ih]->fill(e/fUnit[ih], weight);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::SetHisto(G4int ih,
|
||||
G4int nbins, G4double vmin, G4double vmax, const G4String& unit)
|
||||
{
|
||||
if (ih > MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::SetHisto() : histo " << ih
|
||||
<< "does not fExist" << G4endl;
|
||||
return;
|
||||
}
|
||||
analysisManager->SetActivation(true); //enable inactivation of histograms
|
||||
|
||||
// Define histograms start values
|
||||
const G4int kMaxHisto = 9;
|
||||
const G4String id[] = { "0", "1", "2", "3", "4", "5", "6", "7" , "8" };
|
||||
const G4String title[] =
|
||||
{ "dummy", //0
|
||||
@@ -158,87 +76,17 @@ void HistoManager::SetHisto(G4int ih,
|
||||
"moment dir: angular distr dN/dOmega = f(psi) " //8 for GunAction#3
|
||||
};
|
||||
|
||||
G4String titl = title[ih];
|
||||
fUnit[ih] = 1.;
|
||||
// Default values (to be reset via /analysis/h1/set command)
|
||||
G4int nbins = 100;
|
||||
G4double vmin = 0.;
|
||||
G4double vmax = 100.;
|
||||
|
||||
if (unit != "none") {
|
||||
titl = title[ih] + " (" + unit + ")";
|
||||
fUnit[ih] = G4UnitDefinition::GetValueOf(unit);
|
||||
// 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->SetH1Activation(ih, false);
|
||||
}
|
||||
|
||||
fExist[ih] = true;
|
||||
fLabel[ih] = id[ih];
|
||||
fTitle[ih] = titl;
|
||||
fNbins[ih] = nbins;
|
||||
fVmin[ih] = vmin;
|
||||
fVmax[ih] = vmax;
|
||||
fWidth[ih] = fUnit[ih]*(vmax-vmin)/nbins;
|
||||
|
||||
fNbHist++;
|
||||
|
||||
G4cout << "----> SetHisto " << ih << ": " << titl << "; "
|
||||
<< nbins << " bins from "
|
||||
<< vmin << " " << unit << " to " << vmax << " " << unit << G4endl;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::Normalize(G4int ih, G4double fac)
|
||||
{
|
||||
if (ih >= MaxHisto) {
|
||||
G4cout << "---> warning from HistoManager::Normalize() : histo " << ih
|
||||
<< " fac= " << fac << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fHistPt[ih]) fHistPt[ih]->scale(fac);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::PrintHisto(G4int ih)
|
||||
{
|
||||
if (ih < MaxHisto) { fAscii[ih] = true; fAscii[0] = true; }
|
||||
else
|
||||
G4cout << "---> warning from HistoManager::PrintHisto() : histo " << ih
|
||||
<< "does not exist" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void HistoManager::saveAscii()
|
||||
{
|
||||
if (!fAscii[0]) return;
|
||||
|
||||
G4String name = fileName[0] + ".ascii";
|
||||
std::ofstream File(name, std::ios::out);
|
||||
if (!File) {
|
||||
G4cout
|
||||
<< "\n---> HistoManager::saveAscii(): cannot open " << name << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
File.setf( std::ios::scientific, std::ios::floatfield );
|
||||
|
||||
//write selected histograms
|
||||
for (G4int ih=0; ih<MaxHisto; ih++) {
|
||||
if (fHistPt[ih] && fAscii[ih]) {
|
||||
|
||||
File << "\n 1D histogram " << ih << ": " << fTitle[ih]
|
||||
<< "\n \n \t X \t\t Y" << G4endl;
|
||||
|
||||
for (G4int iBin=0; iBin<fNbins[ih]; iBin++) {
|
||||
File << " " << iBin << "\t"
|
||||
<< fHistPt[ih]->axis().bin_center(iBin) << "\t"
|
||||
<< fHistPt[ih]->bin_height(iBin)
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file eventgenerator/particleGun/src/HistoMessenger.cc
|
||||
/// \brief Implementation of the HistoMessenger class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//....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)
|
||||
:fHistoManager (manager)
|
||||
{
|
||||
fHistoDir = new G4UIdirectory("/gunExample/histo/");
|
||||
fHistoDir->SetGuidance("histograms control");
|
||||
|
||||
fFileNameCmd = new G4UIcmdWithAString("/gunExample/histo/setFileName",this);
|
||||
fFileNameCmd->SetGuidance("set name for the histograms file");
|
||||
|
||||
fHistoCmd = new G4UIcommand("/gunExample/histo/setHisto",this);
|
||||
fHistoCmd->SetGuidance("Set bining of the histo number ih :");
|
||||
fHistoCmd->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");
|
||||
fHistoCmd->SetParameter(ih);
|
||||
//
|
||||
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
|
||||
nbBins->SetGuidance("number of bins");
|
||||
nbBins->SetParameterRange("nbBins>0");
|
||||
fHistoCmd->SetParameter(nbBins);
|
||||
//
|
||||
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
|
||||
valMin->SetGuidance("valMin, expressed in unit");
|
||||
fHistoCmd->SetParameter(valMin);
|
||||
//
|
||||
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
|
||||
valMax->SetGuidance("valMax, expressed in unit");
|
||||
fHistoCmd->SetParameter(valMax);
|
||||
//
|
||||
G4UIparameter* unit = new G4UIparameter("unit",'s',true);
|
||||
unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
|
||||
unit->SetDefaultValue("none");
|
||||
fHistoCmd->SetParameter(unit);
|
||||
|
||||
fPrtHistoCmd = new G4UIcmdWithAnInteger("/gunExample/histo/printHisto",this);
|
||||
fPrtHistoCmd->SetGuidance("print histo #id on ascii file");
|
||||
fPrtHistoCmd->SetParameterName("id",false);
|
||||
fPrtHistoCmd->SetRange("id>0");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoMessenger::~HistoMessenger()
|
||||
{
|
||||
delete fPrtHistoCmd;
|
||||
delete fHistoCmd;
|
||||
delete fFileNameCmd;
|
||||
delete fHistoDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
{
|
||||
if (command == fFileNameCmd)
|
||||
fHistoManager->SetFileName(newValues);
|
||||
|
||||
if (command == fHistoCmd)
|
||||
{ G4int ih,nbBins; G4double vmin,vmax; G4String unit;
|
||||
const char* t = newValues;
|
||||
std::istringstream is(t);
|
||||
is >> ih >> nbBins >> vmin >> vmax >> unit;
|
||||
fHistoManager->SetHisto (ih,nbBins,vmin,vmax,unit);
|
||||
}
|
||||
|
||||
if (command == fPrtHistoCmd)
|
||||
fHistoManager->PrintHisto(fPrtHistoCmd->GetNewIntValue(newValues));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the PhysicsList class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PhysicsList.cc 68024 2013-03-13 13:42:01Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file eventgenerator/particleGun/src/PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
/// \file eventgenerator/fParticleGun/src/PrimaryGeneratorfAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorfAction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction.cc 68734 2013-04-05 09:47:02Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -48,61 +48,67 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fAction1(0),
|
||||
fAction2(0),
|
||||
fAction3(0),
|
||||
fAction4(0),
|
||||
fSelectedAction(1),
|
||||
fGunMessenger(0)
|
||||
{
|
||||
// default particle kinematic
|
||||
//
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
G4ParticleDefinition* particle
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("geantino");
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
fParticleGun->SetParticleDefinition(particle);
|
||||
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
|
||||
|
||||
action1 = new PrimaryGeneratorAction1(particleGun);
|
||||
action2 = new PrimaryGeneratorAction2(particleGun);
|
||||
action3 = new PrimaryGeneratorAction3(particleGun);
|
||||
action4 = new PrimaryGeneratorAction4(particleGun);
|
||||
|
||||
selectedAction = 1;
|
||||
fAction1 = new PrimaryGeneratorAction1(fParticleGun);
|
||||
fAction2 = new PrimaryGeneratorAction2(fParticleGun);
|
||||
fAction3 = new PrimaryGeneratorAction3(fParticleGun);
|
||||
fAction4 = new PrimaryGeneratorAction4(fParticleGun);
|
||||
|
||||
//create a messenger for this class
|
||||
gunMessenger = new PrimaryGeneratorMessenger(this);
|
||||
fGunMessenger = new PrimaryGeneratorMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete action1;
|
||||
delete action2;
|
||||
delete action3;
|
||||
delete action4;
|
||||
delete particleGun;
|
||||
delete gunMessenger;
|
||||
delete fAction1;
|
||||
delete fAction2;
|
||||
delete fAction3;
|
||||
delete fAction4;
|
||||
delete fParticleGun;
|
||||
delete fGunMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
switch(selectedAction)
|
||||
switch(fSelectedAction)
|
||||
{
|
||||
case 1:
|
||||
action1->GeneratePrimaries(anEvent);
|
||||
fAction1->GeneratePrimaries(anEvent);
|
||||
break;
|
||||
case 2:
|
||||
action2->GeneratePrimaries(anEvent);
|
||||
fAction2->GeneratePrimaries(anEvent);
|
||||
break;
|
||||
case 3:
|
||||
action3->GeneratePrimaries(anEvent);
|
||||
fAction3->GeneratePrimaries(anEvent);
|
||||
break;
|
||||
case 4:
|
||||
action4->GeneratePrimaries(anEvent);
|
||||
fAction4->GeneratePrimaries(anEvent);
|
||||
break;
|
||||
default:
|
||||
G4cerr << "Invalid generator action" << G4endl;
|
||||
G4cerr << "Invalid generator fAction" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the PrimaryGeneratorAction1 class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction1.cc 68024 2013-03-13 13:42:01Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the PrimaryGeneratorAction2 class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction2.cc 68024 2013-03-13 13:42:01Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the PrimaryGeneratorAction3 class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction3.cc 68024 2013-03-13 13:42:01Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the PrimaryGeneratorAction4 class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorAction4.cc 68024 2013-03-13 13:42:01Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// \file eventgenerator/particleGun/src/PrimaryGeneratorMessenger.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorMessenger class
|
||||
//
|
||||
// $Id$
|
||||
// $Id: PrimaryGeneratorMessenger.cc 68734 2013-04-05 09:47:02Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -40,17 +40,20 @@
|
||||
|
||||
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
|
||||
PrimaryGeneratorAction* Gun)
|
||||
:Action(Gun)
|
||||
:G4UImessenger(),
|
||||
Action(Gun),
|
||||
fDir(0),
|
||||
fSelectActionCmd(0)
|
||||
{
|
||||
fDir = new G4UIdirectory("/gunExample/");
|
||||
fDir->SetGuidance("this example");
|
||||
|
||||
fSelectActionCmd = new G4UIcmdWithAnInteger("/gunExample/selectGunAction",this);
|
||||
fSelectActionCmd->SetGuidance("Select primary generator action");
|
||||
fSelectActionCmd->SetGuidance(" id = 1 : Generate several vertices and particles per event");
|
||||
fSelectActionCmd->SetGuidance(" id = 2 : Show how to sample a tabulated function");
|
||||
fSelectActionCmd->SetGuidance(" id = 3 : Divergent beam in an arbitrary direction");
|
||||
fSelectActionCmd->SetGuidance(" id = 4 : In spherical coordinates with rotation matrix");
|
||||
fSelectActionCmd->SetGuidance("id=1 Generate several vertices and particles per event");
|
||||
fSelectActionCmd->SetGuidance("id=2 Show how to sample a tabulated function");
|
||||
fSelectActionCmd->SetGuidance("id=3 Divergent beam in an arbitrary direction");
|
||||
fSelectActionCmd->SetGuidance("id=4 In spherical coordinates with rotation matrix");
|
||||
fSelectActionCmd->SetParameterName("id",false);
|
||||
fSelectActionCmd->SetRange("id>0 && id<5");
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: RunAction.cc 68734 2013-04-05 09:47:02Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -39,14 +39,18 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(HistoManager* histo)
|
||||
:fHistoManager(histo)
|
||||
{ }
|
||||
RunAction::RunAction()
|
||||
:G4UserRunAction(), fHistoManager(0)
|
||||
{
|
||||
fHistoManager = new HistoManager();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction()
|
||||
{ }
|
||||
{
|
||||
delete fHistoManager;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -54,7 +58,10 @@ void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
//histograms
|
||||
//
|
||||
fHistoManager->book();
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->OpenFile();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -63,7 +70,11 @@ void RunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
//save histograms
|
||||
//
|
||||
fHistoManager->save();
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->IsActive() ) {
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,24 +23,26 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file eventgenerator/particleGun/src/SteppingVerbose.cc
|
||||
/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc
|
||||
/// \brief Implementation of the SteppingVerbose class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: SteppingVerbose.cc 71030 2013-06-10 09:07:23Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingVerbose.hh"
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingVerbose::SteppingVerbose()
|
||||
{}
|
||||
: G4SteppingVerbose()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -49,10 +51,46 @@ SteppingVerbose::~SteppingVerbose()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::StepInfo()
|
||||
{
|
||||
void SteppingVerbose::TrackingStarted()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
//Step zero
|
||||
//
|
||||
if( verboseLevel > 0 ){
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::StepInfo()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
G4int prec = G4cout.precision(3);
|
||||
|
||||
if( verboseLevel >= 1 ){
|
||||
@@ -101,13 +139,13 @@ void SteppingVerbose::StepInfo()
|
||||
lp1<(*fSecondary).size(); lp1++){
|
||||
G4cout << " "
|
||||
<< std::setw(13)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
|
||||
<< ": energy ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
|
||||
<< " time ="
|
||||
<< std::setw(6)
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
|
||||
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
@@ -121,37 +159,3 @@ void SteppingVerbose::StepInfo()
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingVerbose::TrackingStarted()
|
||||
{
|
||||
|
||||
CopyState();
|
||||
G4int prec = G4cout.precision(3);
|
||||
if( verboseLevel > 0 ){
|
||||
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 6) << "X" << " "
|
||||
<< std::setw( 6) << "Y" << " "
|
||||
<< std::setw( 6) << "Z" << " "
|
||||
<< std::setw( 9) << "KineE" << " "
|
||||
<< std::setw( 9) << "dEStep" << " "
|
||||
<< std::setw(10) << "StepLeng"
|
||||
<< std::setw(10) << "TrakLeng"
|
||||
<< std::setw(10) << "Volume" << " "
|
||||
<< std::setw(10) << "Process" << G4endl;
|
||||
|
||||
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
|
||||
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
|
||||
<< std::setw(10) << fTrack->GetVolume()->GetName()
|
||||
<< " initStep" << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the TrackingAction class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: TrackingAction.cc 68734 2013-04-05 09:47:02Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -45,8 +45,8 @@
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction(PrimaryGeneratorAction* prim,HistoManager* histo)
|
||||
:fPrimary(prim),fHistoManager(histo)
|
||||
TrackingAction::TrackingAction(PrimaryGeneratorAction* prim)
|
||||
:G4UserTrackingAction(), fPrimary(prim)
|
||||
{
|
||||
// parameters for generator action #3
|
||||
fNewUz = fPrimary->GetAction3()->GetNewUz();
|
||||
@@ -63,6 +63,7 @@ TrackingAction::TrackingAction(PrimaryGeneratorAction* prim,HistoManager* histo)
|
||||
void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
{
|
||||
G4int selectedGeneratorAction = fPrimary->GetSelectedAction();
|
||||
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
|
||||
G4int id = 0;
|
||||
|
||||
if(selectedGeneratorAction==2)
|
||||
@@ -70,7 +71,7 @@ void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
//energy spectrum
|
||||
//
|
||||
id = 1;
|
||||
fHistoManager->FillHisto(id, track->GetKineticEnergy());
|
||||
analysis->FillH1(id, track->GetKineticEnergy());
|
||||
}
|
||||
else if(selectedGeneratorAction==3)
|
||||
{
|
||||
@@ -79,9 +80,9 @@ void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
id = 2;
|
||||
G4ThreeVector um = track->GetMomentumDirection();
|
||||
G4double alpha = std::acos(fNewUz*um);
|
||||
G4double dalfa = fHistoManager->GetBinWidth(id);
|
||||
G4double dalfa = analysis->GetH1Width(id);
|
||||
G4double dOmega = twopi*std::sin(alpha)*dalfa;
|
||||
if (dOmega > 0.) fHistoManager->FillHisto(id, alpha, 1./dOmega);
|
||||
if (dOmega > 0.) analysis->FillH1(id, alpha, 1./dOmega);
|
||||
|
||||
//momentum direction : angular distr dN/dOmega = f(psi)
|
||||
//
|
||||
@@ -92,10 +93,10 @@ void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
//
|
||||
G4double psi = std::atan2(u2*um, u1*um);
|
||||
if (psi < 0.) psi += twopi;
|
||||
G4double dpsi = fHistoManager->GetBinWidth(id);
|
||||
G4double dpsi = analysis->GetH1Width(id);
|
||||
G4double alphaMax = fPrimary->GetAction3()->GetAlphaMax();
|
||||
dOmega = (1. - std::cos(alphaMax))*dpsi;
|
||||
if (dOmega > 0.) fHistoManager->FillHisto(id, psi, 1./dOmega);
|
||||
if (dOmega > 0.) analysis->FillH1(id, psi, 1./dOmega);
|
||||
}
|
||||
else if(selectedGeneratorAction==4)
|
||||
{
|
||||
@@ -108,35 +109,35 @@ void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
//vertex position: radial distribution : dN/dv = f(r)
|
||||
//
|
||||
id = 4;
|
||||
G4double dr = fHistoManager->GetBinWidth(id);
|
||||
G4double dr = analysis->GetH1Width(id);
|
||||
G4double dv = 2*twopi*r*r*dr;
|
||||
if (dv > 0.) fHistoManager->FillHisto(id, r, 1./dv);
|
||||
if (dv > 0.) analysis->FillH1(id, r, 1./dv);
|
||||
|
||||
//vertex position: angular distribution : dN/dv = f(theta)
|
||||
//
|
||||
id = 5;
|
||||
G4double theta = std::acos(ur.z());
|
||||
G4double dteta = fHistoManager->GetBinWidth(id);
|
||||
G4double dteta = analysis->GetH1Width(id);
|
||||
dv = fDeltaR3*twopi*std::sin(theta)*dteta;
|
||||
if (dv > 0.) fHistoManager->FillHisto(id, theta, 1./dv);
|
||||
if (dv > 0.) analysis->FillH1(id, theta, 1./dv);
|
||||
|
||||
//vertex position: angular distribution : dN/dv = f(phi)
|
||||
//
|
||||
id = 6;
|
||||
G4double phi = std::atan2(ur.y(), ur.x());
|
||||
if (phi < 0.) phi += twopi;
|
||||
G4double dphi = fHistoManager->GetBinWidth(id);
|
||||
G4double dphi = analysis->GetH1Width(id);
|
||||
dv = 2*fDeltaR3*dphi;
|
||||
if (dv > 0.) fHistoManager->FillHisto(id, phi, 1./dv);
|
||||
if (dv > 0.) analysis->FillH1(id, phi, 1./dv);
|
||||
|
||||
//momentum direction : angular distr dN/dOmega = f(alpha)
|
||||
//
|
||||
id = 7;
|
||||
G4ThreeVector um = track->GetMomentumDirection();
|
||||
G4double alpha = std::acos(ur*um);
|
||||
G4double dalfa = fHistoManager->GetBinWidth(id);
|
||||
G4double dalfa = analysis->GetH1Width(id);
|
||||
G4double dOmega = twopi*std::sin(alpha)*dalfa;
|
||||
if (dOmega > 0.) fHistoManager->FillHisto(id, alpha, 1./dOmega);
|
||||
if (dOmega > 0.) analysis->FillH1(id, alpha, 1./dOmega);
|
||||
|
||||
//momentum direction : angular distr dN/dOmega = f(psi)
|
||||
//
|
||||
@@ -147,9 +148,9 @@ void TrackingAction::PreUserTrackingAction(const G4Track* track)
|
||||
//
|
||||
G4double psi = std::atan2(u2*um, u1*um);
|
||||
if (psi < 0.) psi += twopi;
|
||||
G4double dpsi = fHistoManager->GetBinWidth(id);
|
||||
G4double dpsi = analysis->GetH1Width(id);
|
||||
dOmega = (fCosAlphaMin - fCosAlphaMax)*dpsi;
|
||||
if (dOmega > 0.) fHistoManager->FillHisto(id, psi, 1./dOmega);
|
||||
if (dOmega > 0.) analysis->FillH1(id, psi, 1./dOmega);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user