Import Geant4 5.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:57:27 +02:00
parent 330b82b769
commit 37fff30d2e
5733 changed files with 263867 additions and 74574 deletions
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4DigitRootIO.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4DigitRootIO.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4DigitRootIO.hh"
// Implementation of Constructor #1
G4DigitRootIO::G4DigitRootIO()
{
f_G4VPDigitIO = (G4VPDigitIO*) this;
}
// Implementation of Destructor #1
G4DigitRootIO::~G4DigitRootIO()
{}
// Implementation of GetDigitRootIO
G4DigitRootIO* G4DigitRootIO::GetDigitRootIO()
{
G4DigitRootIO* dio=0;
if ( f_G4VPDigitIO == 0 ) {
dio = new G4DigitRootIO;
}
return dio;
}
// Implementation of Store
bool G4DigitRootIO::Store(const G4DCofThisEvent* dcevt)
{
return true;
}
// Implementation of Retrieve
bool G4DigitRootIO::Retrieve(G4DCofThisEvent*& dcevt)
{
return true;
}
// End of G4DigitRootIO.cc
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4EventRootIO.cc,v 1.3 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4EventRootIO.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4EventRootIO.hh"
// Implementation of Constructor #1
G4EventRootIO::G4EventRootIO( G4PersistencyManager* pc )
: f_pc(pc), f_hepmcio(0), f_mctruthio(0), f_PHCMan(0), f_PDCMan(0)
{
f_hepmcio = (G4HepMCRootIO*) f_pc->HepMCIO();
f_mctruthio = (G4MCTruthRootIO*) f_pc->MCTruthIO();
f_PHCMan = (G4HitRootIO*) f_pc->HitIO();
f_PDCMan = (G4DigitRootIO*) f_pc->DigitIO();
}
// Implementation of Store
// G4bool G4EventRootIO::Store( HepMC::GenEvent* hepevt, G4MCTEvent* mctevt, const G4Event* g4evt)
G4bool G4EventRootIO::Store( HepMC::GenEvent* hepevt, const G4Event* g4evt)
{
// if (hepevt == 0) return false; // no event generated...
// G4RootEvent* evt = new G4RootEvent();
return true;
}
// Implementation of Store
G4bool G4EventRootIO::Store( const G4Event* anEvent )
{
return true;
}
// Implementation of Retrieve
G4bool G4EventRootIO::Retrieve( G4Pevent*& anEvent )
{
return true;
}
// Implementation of Retrieve
G4bool G4EventRootIO::Retrieve( G4Event*& anEvent )
{
return true;
}
// End of G4EventRootIO.cc
@@ -0,0 +1,61 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4HepMCRootIO.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4HepMCRootIO.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4HepMCRootIO.hh"
// Implementation of Store
bool G4HepMCRootIO::Store(HepMC::GenEvent* evt)
{
// G4RootIOManager* pm =
// (G4RootIOManager*) G4PersistencyCenter::GetPersistencyCenter()
// ->CurrentPersistencyManager();
// actual implementation should come in here
return true;
}
// Implementation of Retrieve
bool G4HepMCRootIO::Retrieve(HepMC::GenEvent*& evt, int id)
{
// bool st = false;
evt = 0;
// G4RootIOManager* pm =
// (G4RootIOManager*) G4PersistencyCenter::GetPersistencyCenter()
// ->CurrentPersistencyManager();
// actual implementation should come in here
return true;
}
// End of G4HepMCRootIO.cc
@@ -0,0 +1,125 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4HitRootIO.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4HitRootIO.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4HitRootIO.hh"
// Addtional Include:
#include "G4VPHitsCollectionIO.hh"
// Implementation of Constructor #1
G4HitRootIO::G4HitRootIO()
{
f_G4VPHitIO = (G4VPHitIO*) this;
}
// Implementation of Destructor #1
G4HitRootIO::~G4HitRootIO()
{}
// Implementation of GetHitRootIO
G4HitRootIO* G4HitRootIO::GetHitRootIO()
{
G4HitRootIO* hio=0;
if ( f_G4VPHitIO == 0 ) {
hio = new G4HitRootIO;
}
return hio;
}
// Implementation of Store
bool G4HitRootIO::Store(const G4HCofThisEvent* hcevt)
{
// cast for non-const transient collection of this event.
G4HCofThisEvent* ahcevt = (G4HCofThisEvent*) hcevt;
if ( m_verbose > 2 ) {
std::cout << "G4HitRootIO: storing G4HCofThisEvent, # of collections: "
<< ahcevt->GetNumberOfCollections() << std::endl;
}
// Loop through hit collections
for (int i=0; i< ahcevt->GetNumberOfCollections(); i++ ) {
// Get hit collection for each sensitive detector
G4VHitsCollection* hc = ahcevt->GetHC(i);
if ( m_verbose > 2 ) {
std::cout << "G4HitRootIO: collection#: " << i
<< ", HitsCollection: " << hc << "." << std::endl;
}
if (hc!=0) {
// find out I/O manager for this hit collection
G4VPHitsCollectionIO* hitIOman =
(G4VPHitsCollectionIO*) f_catalog->GetHCIOmanager(hc->GetSDname());
if ( hitIOman != 0) {
if ( hitIOman->Store(hc) ) {
if ( m_verbose > 2 ) {
std::cout << "G4HitRootIO::Store() #" << i << " storing "
<< hc->GetSDname() << "." << std::endl;
}
} else {
std::cerr << "G4HitRootIO::Store() failed in storing "
<< hc->GetSDname() << "." << std::endl;
}
} else {
std::cerr << "G4HitRootIO::Store(): Hit Collection I/O manager is not"
<< " registered for detector: '" << hc->GetSDname()
<< "', collection name: '" << hc->GetName()
<< "'." << std::endl;
return false;
}
}
}
return true;
}
// Implementation of Retrieve
bool G4HitRootIO::Retrieve(G4HCofThisEvent*& hcevt)
{
// new digits collections for this event
hcevt = new G4HCofThisEvent;
// Loop through the registered IO managers
for (size_t i=0; i< f_catalog->NumberOfHCIOmanager(); i++ ) {
// find out I/O manager for this hit collection
G4VPHitsCollectionIO* hitIOman =
(G4VPHitsCollectionIO*) f_catalog->GetHCIOmanager(i);
if ( hitIOman != 0) {
G4VHitsCollection* hc;
if ( hitIOman->Retrieve(hc) ) {
hcevt->AddHitsCollection(i, hc);
}
}
}
return true;
}
// End of G4HitRootIO.cc
@@ -0,0 +1,54 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4MCTruthRootIO.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4MCTruthRootIO.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4MCTruthRootIO.hh"
G4MCTruthRootIO* G4MCTruthRootIO::thePointer=G4MCTruthRootIO::GetMCTruthRootIO();
// Implementation of Store
bool G4MCTruthRootIO::Store(G4MCTEvent* mctevent)
{
return true;
}
// Implementation of Retrieve
bool G4MCTruthRootIO::Retrieve(G4MCTEvent* & mctevent)
{
return true;
}
// Implementation of GetMCTruthRootIO
G4MCTruthRootIO* G4MCTruthRootIO::GetMCTruthRootIO()
{
return 0;
}
// End of G4MCTruthRootIO.cc
@@ -0,0 +1,57 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4RootEvent.cc,v 1.3 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4RootEvent.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4RootEvent.hh"
// Addtional Include:
#include "G4Event.hh"
#include "CLHEP/HepMC/GenEvent.h"
#include "G4MCTEvent.hh"
#include "G4Pevent.hh"
ClassImp(G4RootEvent)
// Implementation of Destructor #1
G4RootEvent::~G4RootEvent()
{}
// Implementation of MakeTransientObject
G4Pevent* G4RootEvent::MakeTransientObject()
{
HepMC::GenEvent* hepevt = 0;
G4MCTEvent* mctevt = 0;
G4Event* g4evt = 0;
// G4Pevent* anEvt = new G4Pevent(hepevt, mctevt, g4evt);
G4Pevent* anEvt = new G4Pevent(hepevt, g4evt);
return anEvt;
}
// End of G4RootEvent.cc
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4RootIOManager.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4RootIOManager.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4RootIOManager.hh"
// Addtional Include:
#include "G4PersistencyManagerT.hh"
#include <assert.h>
#include "G4RootTransManager.hh"
#include "G4HitRootIO.hh"
#include "G4DigitRootIO.hh"
#include "G4EventRootIO.hh"
#include "G4HepMCRootIO.hh"
#include "G4MCTruthRootIO.hh"
static G4PersistencyManagerT<G4RootIOManager> rootio(G4PersistencyCenter::GetPersistencyCenter(),"ROOT");
// Implementation of Constructor #1
G4RootIOManager::G4RootIOManager(G4PersistencyCenter* pc, std::string n)
: G4PersistencyManager(pc, n)
{
f_G4HepMCRootIO = new G4HepMCRootIO();
f_G4MCTruthRootIO = G4MCTruthRootIO::GetMCTruthRootIO();
f_G4HitRootIO = G4HitRootIO::GetHitRootIO();
f_G4DigitRootIO = G4DigitRootIO::GetDigitRootIO();
f_G4EventRootIO = new G4EventRootIO(this);
f_G4RootTransManager = new G4RootTransManager();
}
// Implementation of Destructor #1
G4RootIOManager::~G4RootIOManager()
{
delete f_G4HitRootIO;
delete f_G4DigitRootIO;
delete f_G4EventRootIO;
delete f_G4HepMCRootIO;
delete f_G4MCTruthRootIO;
delete f_G4RootTransManager;
}
// Implementation of Initialize
void G4RootIOManager::Initialize()
{
// Initialize ROOT files for store
f_G4RootTransManager->Initialize();
if ( m_verbose > 2 ) {
std::cout << " -> Root I/O is initialized." << std::endl;
}
}
// End of G4RootIOManager.cc
@@ -0,0 +1,147 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * 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: G4RootTransManager.cc,v 1.4 2002/12/13 14:45:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// File: G4RootTransManager.cc
//
// History:
// '02.5.7 Youhei Morita Initial creation
#include "G4RootTransManager.hh"
// Addtional Include:
#include "G4RootIOManager.hh"
#include "G4PersistencyCenter.hh"
#include "TFile.h"
#include "TTree.h"
// Implementation of Constructor #1
G4RootTransManager::G4RootTransManager()
: f_lastreadfile(0), f_lastwritefile(0), f_lastreadtree(0), f_lastwritetree(0), f_treeName("Geant4"), f_treeDesc("Geant4 output tree"), f_bufsize(64000), f_split(1), f_comp(1)
{
Initialize();
}
// Implementation of SelectReadFile
bool G4RootTransManager::SelectReadFile(std::string obj, std::string file)
{
// obtain TFile pointer for "file" for reading
TFile* tfile = LookUp(file, "READ");
if ( tfile == 0 ) return false;
// cd to the file
tfile->cd();
// Get the tree "Geant4"
TTree* tree = (TTree*)tfile->Get(f_treeName.c_str());
if ( tree == 0 ) return false;
// cache the pointer to the last write file
f_lastreadfile = tfile;
f_lastreadtree = tree;
return true;
}
// Implementation of SelectWriteFile
bool G4RootTransManager::SelectWriteFile(std::string obj, std::string file)
{
// obtain TFile pointer for "obj" and "file" for writing
TFile* tfile = LookUp(file, "WRITE");
if ( tfile == 0 ) return false;
// cd to the file
tfile->cd();
// Get the tree "Geant4"
TTree* tree = (TTree*)tfile->Get(f_treeName.c_str());
if ( tree == 0 ) {
tree = new TTree(f_treeName.c_str(),f_treeDesc.c_str());
if ( tree == 0 ) return false;
tree->SetAutoSave(1000000000); // autosave when 1 Gbyte written
if ( m_verbose > 2 )
std::cout << "G4RootTransManager: TTree \"" << f_treeName << "\" created."
<< std::endl;
}
// cache the pointer to the last write file
f_lastwritefile = tfile;
f_lastwritetree = tree;
return true;
}
// Implementation of Commit
void G4RootTransManager::Commit()
{
if( f_lastwritefile != 0 ) {
// f_lastwritefile->cd();
// if( f_lastwritetree != 0 ) f_lastwritetree->Fill();
f_lastwritefile->Write();
}
}
// Implementation of Initialize
void G4RootTransManager::Initialize()
{
// Initialize the root file catalog
RootFileCatalog::iterator itr;
for ( itr = f_catalog.begin(); itr != f_catalog.end(); itr++ ) {
(*itr).second = 0;
}
}
// Implementation of BufferSize
int G4RootTransManager::BufferSize()
{
if (f_split) return f_bufsize/4;
return f_bufsize;
}
// Implementation of LookUp
TFile* G4RootTransManager::LookUp(string file, string mode)
{
if ( (*(f_catalog.find(file))).second != 0 ) {
return f_catalog[file];
} else {
if ( mode == "WRITE" ) {
f_catalog[file] = new TFile(file.c_str(), "UPDATE");
cout << "LookUp: File: " << file << " for write" << endl;
f_catalog[file]->SetCompressionLevel(f_comp);
return f_catalog[file];
} else if ( mode == "READ" ) {
f_catalog[file] = new TFile(file.c_str(), "READ");
cout << "LookUp: File: " << file << " for read" << endl;
return f_catalog[file];
} else {
cout << "LookUp: File: " << file << ", f_catalog=0" << endl;
return 0;
}
}
}
// End of G4RootTransManager.cc