Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: exGPSActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
|
||||
//
|
||||
/// \file exGPSActionInitialization.cc
|
||||
/// \brief Implementation of the exGPSActionInitialization class
|
||||
|
||||
#include "exGPSActionInitialization.hh"
|
||||
#include "exGPSHistoManager.hh"
|
||||
#include "exGPSPrimaryGeneratorAction.hh"
|
||||
#include "exGPSRunAction.hh"
|
||||
#include "exGPSEventAction.hh"
|
||||
#include "exGPSGeometryConstruction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSActionInitialization::exGPSActionInitialization()
|
||||
: G4VUserActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSActionInitialization::~exGPSActionInitialization()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSActionInitialization::BuildForMaster() const
|
||||
{
|
||||
// Histo manager
|
||||
exGPSHistoManager* histo = new exGPSHistoManager();
|
||||
|
||||
// Actions
|
||||
SetUserAction(new exGPSRunAction(histo));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSActionInitialization::Build() const
|
||||
{
|
||||
// Histo manager
|
||||
exGPSHistoManager* histo = new exGPSHistoManager();
|
||||
|
||||
// Actions
|
||||
//
|
||||
SetUserAction(new exGPSPrimaryGeneratorAction());
|
||||
|
||||
exGPSRunAction* runAction = new exGPSRunAction(histo);
|
||||
SetUserAction(runAction);
|
||||
|
||||
exGPSEventAction* eventAction = new exGPSEventAction(histo);
|
||||
SetUserAction(eventAction);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -1,221 +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/exgps/src/exGPSAnalysisManager.cc
|
||||
/// \brief Implementation of the exGPSAnalysisManager class
|
||||
//
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include <AIDA/AIDA.h>
|
||||
#include "exGPSAnalysisManager.hh"
|
||||
#include "exGPSAnalysisMessenger.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
exGPSAnalysisManager* exGPSAnalysisManager::fInstance = 0;
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSAnalysisManager::exGPSAnalysisManager():
|
||||
fIleName("exgps.aida"),fIleType("xml"),fAnalysisFactory(0),
|
||||
fTree(0),fPlotter(0),fMinpos(-10.),fMaxpos(10),fMineng(0.),fMaxeng(1000.),
|
||||
fEnerHisto(0),fPosiXY(0),fPosiXZ(0),fPosiYZ(0),fAnglCTP(0),fAnglTP(0),fTuple(0)
|
||||
{
|
||||
// Define the messenger and the analysis system
|
||||
fAnalysisMessenger = new exGPSAnalysisMessenger(this);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSAnalysisManager::~exGPSAnalysisManager() {
|
||||
delete fAnalysisMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSAnalysisManager* exGPSAnalysisManager::GetInstance ()
|
||||
{
|
||||
if (fInstance == 0) fInstance = new exGPSAnalysisManager();
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void exGPSAnalysisManager::Dispose()
|
||||
{
|
||||
if (fInstance != 0)
|
||||
{
|
||||
delete fInstance;
|
||||
fInstance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void exGPSAnalysisManager::Fill(G4String pname, G4double e,
|
||||
G4double x, G4double y, G4double z,
|
||||
G4double t, G4double p, G4double w)
|
||||
{
|
||||
if(fEnerHisto) {
|
||||
fEnerHisto->fill(e/MeV,w);
|
||||
fPosiXY->fill(x/cm,y/cm,w);
|
||||
fPosiXZ->fill(x/cm,z/cm,w);
|
||||
fPosiYZ->fill(y/cm,z/cm,w);
|
||||
fAnglCTP->fill(p/deg,std::cos(t),w);
|
||||
fAnglTP->fill(p/deg,t/deg,w);
|
||||
}
|
||||
|
||||
if (fPlotter) fPlotter->refresh();
|
||||
|
||||
// Fill the fTuple
|
||||
|
||||
if (fTuple) {
|
||||
fTuple->fill(0,pname);
|
||||
fTuple->fill(1,e/MeV);
|
||||
fTuple->fill(2,x/cm);
|
||||
fTuple->fill(3,y/cm);
|
||||
fTuple->fill(4,z/cm);
|
||||
fTuple->fill(5,t/deg);
|
||||
fTuple->fill(6,p/deg);
|
||||
fTuple->fill(7,w);
|
||||
fTuple->addRow();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
/*
|
||||
This member reset the histograms and it is called at the begin
|
||||
of each run; here we put the initialization so that the histograms have
|
||||
always the right dimensions depending from the detector geometry
|
||||
*/
|
||||
void exGPSAnalysisManager::BeginOfRun()
|
||||
{
|
||||
fTree = 0;
|
||||
fPlotter = 0;
|
||||
fEnerHisto =0;
|
||||
fPosiXY = fPosiXZ = fPosiYZ = fAnglCTP =fAnglTP = 0;
|
||||
fTuple = 0;
|
||||
|
||||
//Hooking an AIDA compliant analysis system.
|
||||
fAnalysisFactory = AIDA_createAnalysisFactory();
|
||||
if(!fAnalysisFactory) //Have to check that, it can fail.
|
||||
{
|
||||
G4cout << "exGPSAnalysisManager::BeginOfRun: can't get AIDA." << G4endl;
|
||||
return;
|
||||
}
|
||||
AIDA::ITreeFactory* treeFactory = fAnalysisFactory->createTreeFactory();
|
||||
if(treeFactory)
|
||||
{
|
||||
fTree = treeFactory->create(fIleName,fIleType,false,true,"compress=yes");
|
||||
if(!fTree) //Have to check that, it can fail.
|
||||
{
|
||||
G4cout << "exGPSAnalysisManager::BeginOfRun:"
|
||||
<< " can't create the AIDA::ITree : " << fIleName << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
delete treeFactory; // Will not delete the ITree.
|
||||
}
|
||||
|
||||
AIDA::IHistogramFactory* hFactory =
|
||||
fAnalysisFactory->createHistogramFactory(*fTree);
|
||||
if (hFactory)
|
||||
{
|
||||
// Create the energy histogram
|
||||
fEnerHisto = hFactory->createHistogram1D("Source Energy Spectrum",100,
|
||||
fMineng,fMaxeng);
|
||||
|
||||
// Create some 2d histos
|
||||
fPosiXY = hFactory->createHistogram2D("Source X-Y distribution",100,
|
||||
fMinpos/cm,fMaxpos/cm,100,fMinpos/cm,fMaxpos/cm);
|
||||
fPosiXZ = hFactory->createHistogram2D("Source X-Z distribution",100,
|
||||
fMinpos/cm,fMaxpos/cm,100,fMinpos/cm,fMaxpos/cm);
|
||||
fPosiYZ = hFactory->createHistogram2D("Source Y-Z distribution",100,
|
||||
fMinpos/cm,fMaxpos/cm,100,fMinpos/cm,fMaxpos/cm);
|
||||
fAnglCTP = hFactory->createHistogram2D("Source phi-std::cos(theta) distribution",
|
||||
360,0,360,100, -1, 1);
|
||||
fAnglTP = hFactory->createHistogram2D("Source phi-theta distribution",
|
||||
360,0,360,180,0,180);
|
||||
delete hFactory;
|
||||
}
|
||||
|
||||
// Create a Tuple
|
||||
|
||||
AIDA::ITupleFactory* tFactory = fAnalysisFactory->createTupleFactory(*fTree);
|
||||
if (tFactory)
|
||||
{
|
||||
fTuple = tFactory->create("MyTuple","MyTuple",
|
||||
"string Pname, double Energy, X, Y, Z, Theta, Phi, Weight","");
|
||||
delete tFactory;
|
||||
}
|
||||
|
||||
AIDA::IPlotterFactory* pf = fAnalysisFactory->createPlotterFactory(0,0);
|
||||
if(pf)
|
||||
{
|
||||
fPlotter = pf->create();
|
||||
if (fPlotter)
|
||||
{
|
||||
fPlotter->createRegions(2,3);
|
||||
if(fEnerHisto) fPlotter->region(0)->plot(*fEnerHisto);
|
||||
if(fPosiXY) fPlotter->region(1)->plot(*fPosiXY);
|
||||
if(fPosiXZ) fPlotter->region(2)->plot(*fPosiXZ);
|
||||
if(fPosiYZ) fPlotter->region(3)->plot(*fPosiYZ);
|
||||
if(fAnglCTP) fPlotter->region(4)->plot(*fAnglCTP);
|
||||
if(fAnglTP) fPlotter->region(5)->plot(*fAnglTP);
|
||||
fPlotter->show();
|
||||
}
|
||||
delete pf;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
/*
|
||||
This member is called at the end of each run
|
||||
*/
|
||||
void exGPSAnalysisManager::EndOfRun()
|
||||
{
|
||||
if (fAnalysisFactory)
|
||||
{
|
||||
if (!fTree->commit()) G4cout << "Commit failed: no AIDA file produced!"
|
||||
<< G4endl;
|
||||
delete fTree;
|
||||
fTree = 0;
|
||||
|
||||
delete fPlotter;
|
||||
fPlotter = 0;
|
||||
|
||||
delete fAnalysisFactory; //cleanup all AIDA related things.
|
||||
fAnalysisFactory = 0;
|
||||
|
||||
fEnerHisto = 0;
|
||||
fPosiXY = fPosiXZ = fPosiYZ = fAnglCTP =fAnglTP = 0;
|
||||
fTuple = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // G4ANALYSIS_USE
|
||||
@@ -23,18 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSEventAction.cc 76468 2013-11-11 10:27:19Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSEventAction.cc
|
||||
/// \brief Implementation of the exGPSEventAction class
|
||||
//
|
||||
|
||||
#include "exGPSEventAction.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include "exGPSAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
#include "exGPSEventActionMessenger.hh"
|
||||
|
||||
#include "exGPSHistoManager.hh"
|
||||
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4ios.hh"
|
||||
@@ -43,10 +43,12 @@
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
exGPSEventAction::exGPSEventAction()
|
||||
:fDrawFlag("all"), fPrintModulo(1000), fEventMessenger(NULL)
|
||||
exGPSEventAction::exGPSEventAction(exGPSHistoManager* histoManager)
|
||||
:G4UserEventAction(),
|
||||
fDrawFlag("all"), fPrintModulo(1000), fEventMessenger(NULL),
|
||||
fexGPSHistoManager(histoManager)
|
||||
{
|
||||
fEventMessenger = new exGPSEventActionMessenger(this);
|
||||
fEventMessenger = new exGPSEventActionMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -71,15 +73,11 @@ void exGPSEventAction::BeginOfEventAction(const G4Event* evt)
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
void exGPSEventAction::EndOfEventAction(const G4Event* evt)
|
||||
#else
|
||||
void exGPSEventAction::EndOfEventAction(const G4Event*)
|
||||
#endif
|
||||
{
|
||||
// G4int evtNb = evt->GetEventID();
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
G4int nVertex = evt->GetNumberOfPrimaryVertex();
|
||||
for ( G4int j = 0; j < nVertex; j++) {
|
||||
G4int nPart = evt->GetPrimaryVertex(j)->GetNumberOfParticle();
|
||||
@@ -93,8 +91,8 @@ void exGPSEventAction::EndOfEventAction(const G4Event*)
|
||||
->GetPDGMass();
|
||||
E=std::sqrt(P*P+E0*E0);
|
||||
E -= E0;
|
||||
G4double pid = G4double(evt->GetPrimaryVertex(j)->GetPrimary(i)
|
||||
->GetPDGcode());
|
||||
G4int pid = evt->GetPrimaryVertex(j)->GetPrimary(i)
|
||||
->GetPDGcode();
|
||||
//
|
||||
direction=direction*(1./direction.mag());
|
||||
direction = -direction; // reverse the direction
|
||||
@@ -106,11 +104,9 @@ void exGPSEventAction::EndOfEventAction(const G4Event*)
|
||||
y=position.y();
|
||||
z=position.z();
|
||||
w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight();
|
||||
// exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w);
|
||||
exGPSAnalysisManager::GetInstance()->Fill(pid,E,x,y,z,Theta,Phi,w);
|
||||
fexGPSHistoManager->Fill(pid,E,x,y,z,Theta,Phi,w);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -23,22 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSEventActionMessenger.cc 70972 2013-06-07 16:12:12Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSEventActionMessenger.cc
|
||||
/// \brief Implementation of the exGPSEventActionMessenger class
|
||||
//
|
||||
// This code implementation is the intellectual property of
|
||||
// the GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "exGPSEventActionMessenger.hh"
|
||||
#include "exGPSEventAction.hh"
|
||||
@@ -47,11 +39,14 @@
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSEventActionMessenger::exGPSEventActionMessenger(
|
||||
exGPSEventAction* EvAct)
|
||||
:fEventAction(EvAct)
|
||||
exGPSEventAction* EvAct)
|
||||
:G4UImessenger(),
|
||||
fEventAction(EvAct),
|
||||
fDrawCmd(0),
|
||||
fPrintCmd(0)
|
||||
{
|
||||
fDrawCmd = new G4UIcmdWithAString("/event/drawTracks",this);
|
||||
fDrawCmd->SetGuidance("Draw the tracks in the event");
|
||||
@@ -68,7 +63,7 @@ exGPSEventActionMessenger::exGPSEventActionMessenger(
|
||||
fPrintCmd->AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSEventActionMessenger::~exGPSEventActionMessenger()
|
||||
{
|
||||
@@ -76,16 +71,16 @@ exGPSEventActionMessenger::~exGPSEventActionMessenger()
|
||||
delete fPrintCmd;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSEventActionMessenger::SetNewValue(G4UIcommand * command,
|
||||
G4String newValue)
|
||||
G4String newValue)
|
||||
{
|
||||
if(command == fDrawCmd)
|
||||
{fEventAction->SetDrawFlag(newValue);}
|
||||
|
||||
if(command == fPrintCmd)
|
||||
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
|
||||
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSGeometryConstruction.cc 68020 2013-03-13 13:34:15Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSGeometryConstruction.cc
|
||||
/// \brief Implementation of the exGPSGeometryConstruction class
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
//
|
||||
|
||||
#include "exGPSGeometryConstruction.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
@@ -47,7 +47,8 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSGeometryConstruction::exGPSGeometryConstruction ()
|
||||
: fUniverse_phys(0),
|
||||
: G4VUserDetectorConstruction(),
|
||||
fUniverse_phys(0),
|
||||
fAl_phys(0),
|
||||
fSphere_phys(0)
|
||||
{;}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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/exgps/src/exGPSHistoManager.cc
|
||||
/// \brief Implementation of the exGPSHistoManager class
|
||||
//
|
||||
//
|
||||
// $Id: exGPSHistoManager.cc 74272 2013-10-02 14:48:50Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "exGPSHistoManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "exGPSHistoMessenger.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSHistoManager::exGPSHistoManager():
|
||||
fMinpos(-10.),fMaxpos(10),fMineng(0.),fMaxeng(1000.),
|
||||
fEnerHisto(0),fPosiXY(0),fPosiZX(0),fPosiYZ(0),fAnglCTP(0),fAnglTP(0)
|
||||
{
|
||||
fFileName[0] = "expGPS";
|
||||
fFactoryOn = false;
|
||||
fMessenger = new exGPSHistoMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSHistoManager::~exGPSHistoManager()
|
||||
{ }
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSHistoManager::book()
|
||||
{
|
||||
// Create or get analysis manager
|
||||
// The choice of analysis technology is done via selection of a namespace
|
||||
// in exGPSHistoManager.hh
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->SetVerboseLevel(2);
|
||||
G4String extension = analysisManager->GetFileType();
|
||||
fFileName[1] = fFileName[0] + "." + extension;
|
||||
|
||||
// Create directories
|
||||
analysisManager->SetHistoDirectoryName("histo");
|
||||
analysisManager->SetNtupleDirectoryName("ntuple");
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
G4bool fileOpen = analysisManager->OpenFile(fFileName[0]);
|
||||
if (!fileOpen) {
|
||||
G4cout << "\n---> exGPSHistoManager::book(): cannot open " << fFileName[1]
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// create selected histograms
|
||||
//
|
||||
analysisManager->SetFirstHistoId(1);
|
||||
analysisManager->SetFirstNtupleId(1);
|
||||
|
||||
G4int id = analysisManager->CreateH1("1","Ekin primary",100,fMineng,fMaxeng);
|
||||
fEnerHisto= analysisManager->GetH1(id);
|
||||
|
||||
id = analysisManager->CreateH2("2","Position XY",100,fMinpos,fMaxpos,
|
||||
100,fMinpos,fMaxpos);
|
||||
fPosiXY= analysisManager->GetH2(id);
|
||||
|
||||
id = analysisManager->CreateH2("3","Position YZ",100,fMinpos,fMaxpos,
|
||||
100,fMinpos,fMaxpos);
|
||||
fPosiYZ= analysisManager->GetH2(id);
|
||||
|
||||
id = analysisManager->CreateH2("4","Position ZX",100,fMinpos,fMaxpos,
|
||||
100,fMinpos,fMaxpos);
|
||||
fPosiZX= analysisManager->GetH2(id);
|
||||
|
||||
id =analysisManager->CreateH2("5","Source phi-std::cos(theta) distribution",
|
||||
360,0,360,100, -1, 1);
|
||||
fAnglCTP =analysisManager->GetH2(id);
|
||||
|
||||
id =analysisManager->CreateH2("6","Source phi-theta distribution",
|
||||
360,0,360,180,0,180);
|
||||
fAnglTP = analysisManager->GetH2(id);
|
||||
|
||||
// Create 1st ntuple (id = 1)
|
||||
//
|
||||
analysisManager->CreateNtuple("MyTuple", "Primary Particle Tuple");
|
||||
id = analysisManager->CreateNtupleIColumn("particleID");
|
||||
id = analysisManager->CreateNtupleDColumn("Ekin");
|
||||
id = analysisManager->CreateNtupleDColumn("posX");
|
||||
id = analysisManager->CreateNtupleDColumn("posY");
|
||||
id = analysisManager->CreateNtupleDColumn("posZ");
|
||||
id = analysisManager->CreateNtupleDColumn("dirTheta");
|
||||
id = analysisManager->CreateNtupleDColumn("dirPhi");
|
||||
id = analysisManager->CreateNtupleDColumn("weight");
|
||||
analysisManager->FinishNtuple();
|
||||
|
||||
fFactoryOn = true;
|
||||
G4cout << "\n----> Histogram Tree is opened in " << fFileName[1] << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSHistoManager::save()
|
||||
{
|
||||
if (fFactoryOn) {
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
G4cout << "\n----> Histogram Tree is saved in " << fFileName[1] << G4endl;
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
fFactoryOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
void exGPSHistoManager::Fill(G4int PDGid, G4double e,
|
||||
G4double x, G4double y, G4double z,
|
||||
G4double t, G4double p, G4double w)
|
||||
{
|
||||
fEnerHisto->fill(e, w);
|
||||
fEnerHisto->fill(e/MeV,w);
|
||||
fPosiXY->fill(x/cm,y/cm,w);
|
||||
fPosiZX->fill(z/cm,x/cm,w);
|
||||
fPosiYZ->fill(y/cm,z/cm,w);
|
||||
fAnglCTP->fill(p/deg,std::cos(t),w);
|
||||
fAnglTP->fill(p/deg,t/deg,w);
|
||||
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillNtupleIColumn(1,0,PDGid);
|
||||
analysisManager->FillNtupleDColumn(1,1,e);
|
||||
analysisManager->FillNtupleDColumn(1,2,x);
|
||||
analysisManager->FillNtupleDColumn(1,3,y);
|
||||
analysisManager->FillNtupleDColumn(1,4,z);
|
||||
analysisManager->FillNtupleDColumn(1,5,t);
|
||||
analysisManager->FillNtupleDColumn(1,6,p);
|
||||
analysisManager->FillNtupleDColumn(1,7,w);
|
||||
analysisManager->AddNtupleRow(1);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSHistoManager::PrintStatistic()
|
||||
{
|
||||
if(fFactoryOn) {
|
||||
G4cout << "\n ----> print histograms statistic \n" << G4endl;
|
||||
|
||||
/*G4cout
|
||||
<< " EAbs : mean = " << G4BestUnit(fHistPt[1]->mean(), "Energy")
|
||||
<< " rms = " << G4BestUnit(fHistPt[1]->rms(), "Energy")
|
||||
<< G4endl;
|
||||
G4cout
|
||||
<< " EGap : mean = " << G4BestUnit(fHistPt[2]->mean(), "Energy")
|
||||
<< " rms = " << G4BestUnit(fHistPt[2]->rms(), "Energy")
|
||||
<< G4endl;
|
||||
G4cout
|
||||
<< " LAbs : mean = " << G4BestUnit(fHistPt[3]->mean(), "Length")
|
||||
<< " rms = " << G4BestUnit(fHistPt[3]->rms(), "Length")
|
||||
<< G4endl;
|
||||
G4cout
|
||||
<< " LGap : mean = " << G4BestUnit(fHistPt[4]->mean(), "Length")
|
||||
<< " rms = " << G4BestUnit(fHistPt[4]->rms(), "Length")
|
||||
<< G4endl;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
+32
-32
@@ -23,36 +23,42 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSAnalysisMessenger.cc
|
||||
/// \brief Implementation of the exGPSAnalysisMessenger class
|
||||
// $Id: exGPSHistoMessenger.cc 70972 2013-06-07 16:12:12Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSHistoMessenger.cc
|
||||
/// \brief Implementation of the exGPSHistoMessenger class
|
||||
//
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
#include "exGPSAnalysisMessenger.hh"
|
||||
#include "exGPSAnalysisManager.hh"
|
||||
|
||||
|
||||
#include "exGPSHistoMessenger.hh"
|
||||
#include "exGPSHistoManager.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSAnalysisMessenger::exGPSAnalysisMessenger(exGPSAnalysisManager* analysisManager)
|
||||
:fExGPSAnalysis(analysisManager)
|
||||
exGPSHistoMessenger::exGPSHistoMessenger
|
||||
(exGPSHistoManager* histoManager)
|
||||
:G4UImessenger(),
|
||||
fExGPSHisto(histoManager),
|
||||
fFileNameCmd(0),
|
||||
fMaxEngCmd(0),
|
||||
fMinEngCmd(0),
|
||||
fMaxPosCmd(0),
|
||||
fMinPosCmd(0)
|
||||
|
||||
{
|
||||
fExGPSAnalysisDir = new G4UIdirectory("/analysis/");
|
||||
fExGPSAnalysisDir->SetGuidance("exGPS analysis control.");
|
||||
fExGPSHistoDir = new G4UIdirectory("/analysis/");
|
||||
fExGPSHistoDir->SetGuidance("exGPS analysis control.");
|
||||
|
||||
fFileNameCmd = new G4UIcmdWithAString("/analysis/filename",this);
|
||||
fFileNameCmd->SetGuidance("Input the name for the AIDA output file.");
|
||||
fFileNameCmd->SetGuidance("Input the name for the ROOT output file.");
|
||||
fFileNameCmd->SetParameterName("filename",true,true);
|
||||
fFileNameCmd->SetDefaultValue("exgps.aida");
|
||||
fFileNameCmd->SetDefaultValue("exgps");
|
||||
|
||||
fFileTypeCmd = new G4UIcmdWithAString("/analysis/filetype",this);
|
||||
fFileTypeCmd->SetGuidance("Input the type (xml/hbook/root) for the AIDA output file.");
|
||||
fFileTypeCmd->SetParameterName("filetype",true,true);
|
||||
fFileTypeCmd->SetDefaultValue("xml");
|
||||
|
||||
fMaxEngCmd = new G4UIcmdWithADoubleAndUnit("/analysis/maxeng",this);
|
||||
fMaxEngCmd->SetGuidance("Sets the maximum energy of histo");
|
||||
@@ -82,51 +88,45 @@ exGPSAnalysisMessenger::exGPSAnalysisMessenger(exGPSAnalysisManager* analysisMan
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSAnalysisMessenger::~exGPSAnalysisMessenger()
|
||||
exGPSHistoMessenger::~exGPSHistoMessenger()
|
||||
{
|
||||
delete fFileNameCmd;
|
||||
delete fFileTypeCmd;
|
||||
delete fMaxEngCmd;
|
||||
delete fMinEngCmd;
|
||||
delete fMaxPosCmd;
|
||||
delete fMinPosCmd;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void exGPSAnalysisMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
void exGPSHistoMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
|
||||
// 1D Histograms
|
||||
|
||||
if( command == fFileNameCmd )
|
||||
{
|
||||
fExGPSAnalysis->SetFileName(newValue);
|
||||
}
|
||||
else if ( command == fFileTypeCmd )
|
||||
{
|
||||
fExGPSAnalysis->SetFileType(newValue);
|
||||
fExGPSHisto->SetFileName(newValue);
|
||||
}
|
||||
else if( command == fMaxPosCmd)
|
||||
{
|
||||
fExGPSAnalysis->SetPosMax(fMaxPosCmd->GetNewDoubleValue(newValue));
|
||||
fExGPSHisto->SetPosMax(fMaxPosCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == fMinPosCmd)
|
||||
{
|
||||
fExGPSAnalysis->SetPosMin(fMinPosCmd->GetNewDoubleValue(newValue));
|
||||
fExGPSHisto->SetPosMin(fMinPosCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == fMaxEngCmd)
|
||||
{
|
||||
fExGPSAnalysis->SetEngMax(fMaxEngCmd->GetNewDoubleValue(newValue));
|
||||
fExGPSHisto->SetEMax(fMaxEngCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == fMinEngCmd)
|
||||
{
|
||||
fExGPSAnalysis->SetEngMin(fMinEngCmd->GetNewDoubleValue(newValue));
|
||||
fExGPSHisto->SetEMin(fMinEngCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
|
||||
#endif // G4ANALYSIS_USE
|
||||
@@ -23,9 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSPhysicsList.cc 68020 2013-03-13 13:34:15Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSPhysicsList.cc
|
||||
/// \brief Implementation of the exGPSPhysicsList class
|
||||
//
|
||||
|
||||
#include "exGPSPhysicsList.hh"
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSPrimaryGeneratorAction.cc 68020 2013-03-13 13:34:15Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSPrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the exGPSPrimaryGeneratorAction class
|
||||
//
|
||||
@@ -38,6 +40,8 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
exGPSPrimaryGeneratorAction::exGPSPrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0)
|
||||
{
|
||||
fParticleGun = new G4GeneralParticleSource();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: exGPSRunAction.cc 76468 2013-11-11 10:27:19Z gcosmo $
|
||||
//
|
||||
/// \file eventgenerator/exgps/src/exGPSRunAction.cc
|
||||
/// \brief Implementation of the exGPSRunAction class
|
||||
//
|
||||
@@ -33,14 +35,14 @@
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "exGPSHistoManager.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include "exGPSAnalysisManager.hh"
|
||||
#endif
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
exGPSRunAction::exGPSRunAction()
|
||||
exGPSRunAction::exGPSRunAction(exGPSHistoManager* histoManager)
|
||||
: G4UserRunAction(),
|
||||
fexGPSHistoManager(histoManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,33 +57,15 @@ void exGPSRunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
|
||||
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
|
||||
fexGPSHistoManager->book();
|
||||
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
if (G4VVisManager::GetConcreteInstance())
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI->ApplyCommand("/vis/scene/notifyHandlers");
|
||||
}
|
||||
#endif
|
||||
#ifdef G4ANALYSIS_USE
|
||||
// If analysis is used reset the histograms
|
||||
exGPSAnalysisManager::GetInstance()->BeginOfRun();
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void exGPSRunAction::EndOfRunAction(const G4Run* )
|
||||
{
|
||||
#ifdef G4VIS_USE
|
||||
if (G4VVisManager::GetConcreteInstance()) {
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
|
||||
}
|
||||
#endif
|
||||
// If analysis is used
|
||||
#ifdef G4ANALYSIS_USE
|
||||
exGPSAnalysisManager::GetInstance()->EndOfRun();
|
||||
#endif
|
||||
{fexGPSHistoManager->save();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
Reference in New Issue
Block a user