Import Geant4 9.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:37:50 +02:00
parent a8e9364cea
commit 96c8bcd0af
6923 changed files with 198390 additions and 41849 deletions
+33
View File
@@ -0,0 +1,33 @@
# $Id: GNUmakefile,v 1.1 2007/10/17 09:33:17 gcosmo Exp $
# -----------------------------------------------------------------------
# GNUmakefile for persistency library. Gabriele Cosmo, 16/11/96.
# -----------------------------------------------------------------------
name := G4mctruth
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -I$(G4INSTALL)/source/global/management/include \
-I$(G4INSTALL)/source/global/HEPGeometry/include \
-I$(G4INSTALL)/source/digits_hits/hits/include \
-I$(G4INSTALL)/source/digits_hits/digits/include \
-I$(G4INSTALL)/source/particles/management/include \
-I$(G4INSTALL)/source/run/include \
-I$(G4INSTALL)/source/event/include \
-I$(G4INSTALL)/source/track/include \
-I$(G4INSTALL)/source/tracking/include \
-I$(G4INSTALL)/source/intercoms/include \
-I$(G4INSTALL)/source/geometry/management/include
ifdef G4LIB_USE_HEPMC
ifndef HEPMC_DIR
@echo HEPMC_DIR not defined!
endif
CPPFLAGS += -I$(HEPMC_DIR)/include
endif
include $(G4INSTALL)/config/common.gmk
@@ -0,0 +1,99 @@
//
// ********************************************************************
// * 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: G4DCIOcatalog.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef DCIO_CATALOG_HH
#define DCIO_CATALOG_HH 1
#include <map>
#include "G4Types.hh"
#include "G4VPDigitsCollectionIO.hh"
class G4VDCIOentry;
typedef std::map<std::string, G4VDCIOentry*, std::less<std::string> > DCIOmap;
typedef std::map<std::string, G4VPDigitsCollectionIO*, std::less<std::string> > DCIOstore;
// Class Description:
// Catalog for the I/O manager of digits collection for each detector.
class G4DCIOcatalog
{
public: // With description
G4DCIOcatalog();
// Constructor
virtual ~G4DCIOcatalog() {};
// Destructor
public: // With description
static G4DCIOcatalog* GetDCIOcatalog();
// Construct G4DCIOcatalog and returns the pointer
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
void RegisterEntry(G4VDCIOentry* d);
// Register I/O manager entry
void RegisterDCIOmanager(G4VPDigitsCollectionIO* d);
// Register I/O manager
G4VDCIOentry* GetEntry(std::string name);
// Returns the I/O manager entry
G4VPDigitsCollectionIO* GetDCIOmanager(std::string name);
// Returns the registered I/O manager entry
void PrintEntries();
// Prints the list of I/O manager entries
std::string CurrentDCIOmanager();
// Returns the list of I/O managers
void PrintDCIOmanager();
// Prints the list of I/O managers
size_t NumberOfDCIOmanager() { return theStore.size(); };
// Returns the number of registered I/O managers.
G4VPDigitsCollectionIO* GetDCIOmanager(int n);
// Returns the n-th registered I/O manager entry
private:
int m_verbose;
static G4DCIOcatalog* f_thePointer;
DCIOmap theCatalog;
DCIOstore theStore;
}; // End of class G4DCIOcatalog
#endif
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * 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: G4DCIOentryT.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef DCIO_ENTRY_T_HH
#define DCIO_ENTRY_T_HH 1
#include <string>
#include "G4Types.hh"
#include "G4VPDigitsCollectionIO.hh"
// Class inherited:
#include "G4VDCIOentry.hh"
// Class Description:
// Template class of DigitsCollection I/O Manager for late binding
template <class T> class G4DCIOentryT
: public G4VDCIOentry
{
public: // With description
G4DCIOentryT<T>(std::string n)
: G4VDCIOentry(n), f_manager(0)
{
if ( m_verbose > 2 ) {
G4cout << "G4DCIOentryT: Registering DigitsCollection IO manager"
<< " for \"" << n << "\"" << G4endl;
}
}
// Constructor
~G4DCIOentryT() {};
// Destructor
public: // With description
void CreateDCIOmanager(std::string detName, std::string colName)
{
if ( f_manager == 0 ) {
f_manager = new T( detName, colName );
if ( m_verbose > 2 ) {
G4cout << "G4DCIOentryT: Constructing DigitsCollection IO manager"
<< " for \"" << detName << "\" " << f_manager << G4endl;
}
G4DCIOcatalog::GetDCIOcatalog()->RegisterDCIOmanager(f_manager);
if ( m_verbose > 2 ) {
G4DCIOcatalog::GetDCIOcatalog()->PrintDCIOmanager();
}
}
}
// Create a new digits collection I/O manager
void DeleteDCIOmanager() { if (f_manager!=0) delete f_manager; };
// Delete a digits collection I/O manager
private:
G4VPDigitsCollectionIO* f_manager;
}; // End of class G4DCIOentryT
#endif
@@ -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. *
// ********************************************************************
//
// File: G4FileUtilities.hh
//
// History:
// 01.08.24 Youhei Morita Initial creation
#ifndef FILE_UTILITIES_HH
#define FILE_UTILITIES_HH 1
#include "G4Types.hh"
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
// Class Description:
// File utilities to access files with POSIX interface.
class G4FileUtilities
{
public: // With description
G4FileUtilities();
// Constructor
~G4FileUtilities();
// Destructor
public: // With description
G4bool FileExists(const std::string file);
// checks if the "file" exists. returns true if it does.
std::string StrErrNo() const { return ::strerror(errno); };
// returns the error message of the last system call as string.
int Shell(std::string s) { return ::system(s.c_str()); };
// execute the shell command. returns zero if success.
int CopyFile(const std::string srcFile, const std::string dstFile);
// copies the "srcFile" to "dstFile". returns zero if success.
int DeleteFile(const std::string file, const std::string option);
// deletes the "file" with the "option". returns zero if success.
std::string GetEnv(const std::string env) { return ::getenv(env.c_str()); };
// retuns the value of environment variable as string.
}; // End of class G4FileUtilities
#endif
@@ -0,0 +1,99 @@
//
// ********************************************************************
// * 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: G4HCIOcatalog.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef HCIO_CATALOG_HH
#define HCIO_CATALOG_HH 1
#include <map>
#include "G4Types.hh"
#include "G4VPHitsCollectionIO.hh"
class G4VHCIOentry;
typedef std::map<std::string, G4VHCIOentry*, std::less<std::string> > HCIOmap;
typedef std::map<std::string, G4VPHitsCollectionIO*, std::less<std::string> > HCIOstore;
// Class Description:
// Catalog for the I/O manager of hits collection for each detector.
class G4HCIOcatalog
{
public: // With description
G4HCIOcatalog();
// Constructor
virtual ~G4HCIOcatalog() {};
// Destructor
public: // With description
static G4HCIOcatalog* GetHCIOcatalog();
// Construct G4HCIOcatalog and returns the pointer
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
void RegisterEntry(G4VHCIOentry* d);
// Register I/O manager entry
void RegisterHCIOmanager(G4VPHitsCollectionIO* d);
// Register I/O manager
G4VHCIOentry* GetEntry(std::string name);
// Returns the I/O manager entry
G4VPHitsCollectionIO* GetHCIOmanager(std::string name);
// Returns the registered I/O manager entry
void PrintEntries();
// Prints the list of I/O manager entries
std::string CurrentHCIOmanager();
// Returns the list of I/O managers
void PrintHCIOmanager();
// Prints the list of I/O managers
size_t NumberOfHCIOmanager() { return theStore.size(); };
// Returns the number of registered I/O managers.
G4VPHitsCollectionIO* GetHCIOmanager(int n);
// Returns the n-th registered I/O manager entry
private:
int m_verbose;
static G4HCIOcatalog* f_thePointer;
HCIOmap theCatalog;
HCIOstore theStore;
}; // End of class G4HCIOcatalog
#endif
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * 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: G4HCIOentryT.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef HCIO_ENTRY_T_HH
#define HCIO_ENTRY_T_HH 1
#include <string>
#include "G4Types.hh"
#include "G4VPHitsCollectionIO.hh"
// Class inherited:
#include "G4VHCIOentry.hh"
// Class Description:
// Template class of HitsCollection I/O Manager for late binding
template <class T> class G4HCIOentryT
: public G4VHCIOentry
{
public: // With description
G4HCIOentryT<T>(std::string n)
: G4VHCIOentry(n), f_manager(0)
{
if ( m_verbose > 2 ) {
G4cout << "G4HCIOentryT: Registering HitsCollection IO manager"
<< " for \"" << n << "\"" << G4endl;
}
}
// Constructor
~G4HCIOentryT() {};
// Destructor
public: // With description
void CreateHCIOmanager(std::string detName, std::string colName)
{
if ( f_manager == 0 ) {
f_manager = new T( detName, colName );
if ( m_verbose > 2 ) {
G4cout << "G4HCIOentryT: Constructing HitsCollection IO manager"
<< " for \"" << detName << "\" " << f_manager << G4endl;
}
G4HCIOcatalog::GetHCIOcatalog()->RegisterHCIOmanager(f_manager);
if ( m_verbose > 2 ) {
G4HCIOcatalog::GetHCIOcatalog()->PrintHCIOmanager();
}
}
}
// Create a new hits collection I/O manager
void DeleteHCIOmanager() { if (f_manager!=0) delete f_manager; };
// Delete a hits collection I/O manager
private:
G4VPHitsCollectionIO* f_manager;
}; // End of class G4HCIOentryT
#endif
@@ -0,0 +1,136 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTEvent.hh
//
// ====================================================================
#ifndef MCT_EVENT_H
#define MCT_EVENT_H
#include "G4Types.hh"
#include <iostream>
#include <map>
#include "G4MCTGenParticle.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4MCTGenEvent;
class G4MCTSimEvent;
class G4MCTSimParticle;
typedef std::map<G4MCTGenParticle, G4MCTSimParticle*> MCTGen2SimParticleMap;
typedef std::map<G4MCTSimParticle*, G4MCTGenParticle> MCTSim2GenParticleMap;
class G4MCTEvent {
protected:
int eventNumber;
G4MCTGenEvent* genEvent;
G4MCTSimEvent* simEvent;
// primary table (bidirectional)
MCTGen2SimParticleMap gen2simParticleMap;
MCTSim2GenParticleMap sim2genParticleMap;
public:
G4MCTEvent();
virtual ~G4MCTEvent();
// copy constructor and assignment operator
G4MCTEvent(const G4MCTEvent& right);
const G4MCTEvent& operator=(const G4MCTEvent& right);
// set/get functions
void SetEventNumber(int n);
int GetEventNumber() const;
G4MCTGenEvent* GetGenEvent() const;
G4MCTSimEvent* GetSimEvent() const;
// methods...
int GetNofPrimaries() const;
G4MCTSimParticle* GetSimParticle(const G4MCTGenParticle& genpart) const;
G4MCTGenParticle GetGenParticle(const G4MCTSimParticle* simpart) const;
int AddPrimaryPair(const G4MCTGenParticle& genp,
const G4MCTSimParticle* simp);
void ClearEvent();
void Print(std::ostream& ostr= std::cout) const;
// iterators
typedef MCTGen2SimParticleMap::const_iterator genprimary_const_iterator;
genprimary_const_iterator genprimaries_begin() const;
genprimary_const_iterator genprimaries_end() const;
typedef MCTSim2GenParticleMap::const_iterator simprimary_const_iterator;
simprimary_const_iterator simprimaries_begin() const;
simprimary_const_iterator simprimaries_end() const;
};
// ====================================================================
// inline functions
// ====================================================================
inline G4MCTEvent::G4MCTEvent(const G4MCTEvent& right)
{
*this= right;
}
inline const G4MCTEvent& G4MCTEvent::operator=(const G4MCTEvent& right)
{
eventNumber= right.eventNumber;
simEvent= right.simEvent; // shallow copy...
genEvent= right.genEvent;
gen2simParticleMap= right.gen2simParticleMap;
sim2genParticleMap= right.sim2genParticleMap;
return *this;
}
inline void G4MCTEvent::SetEventNumber(int n) { eventNumber= n; }
inline int G4MCTEvent::GetEventNumber() const { return eventNumber; }
inline int G4MCTEvent::GetNofPrimaries() const
{ return gen2simParticleMap.size(); }
inline G4MCTSimEvent* G4MCTEvent::GetSimEvent() const { return simEvent; }
inline G4MCTGenEvent* G4MCTEvent::GetGenEvent() const { return genEvent; }
// iterators
inline G4MCTEvent::genprimary_const_iterator G4MCTEvent::genprimaries_begin() const
{ return gen2simParticleMap.begin(); }
inline G4MCTEvent::genprimary_const_iterator G4MCTEvent::genprimaries_end() const
{ return gen2simParticleMap.end(); }
inline G4MCTEvent::simprimary_const_iterator G4MCTEvent::simprimaries_begin() const
{ return sim2genParticleMap.begin(); }
inline G4MCTEvent::simprimary_const_iterator G4MCTEvent::simprimaries_end() const
{ return sim2genParticleMap.end(); }
#endif
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTGenEvent.hh
//
// ====================================================================
#ifndef MCT_GEN_EVENT_H
#define MCT_GEN_EVENT_H
#include "G4Types.hh"
#include <iostream>
#include <vector>
#include "CLHEP/HepMC/GenEvent.h"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4MCTGenEvent {
protected:
std::vector<HepMC::GenEvent*> eventList;
public:
G4MCTGenEvent();
virtual ~G4MCTGenEvent();
// copy constructor and assignment operator
G4MCTGenEvent(const G4MCTGenEvent& right);
const G4MCTGenEvent& operator=(const G4MCTGenEvent& right);
// methods...
int AddGenEvent(const HepMC::GenEvent* genevent);
int GetNofEvents() const;
const HepMC::GenEvent* GetGenEvent(int i);
void ClearEvent();
void Print(std::ostream& ostr= std::cout) const;
};
// ====================================================================
// inline functions
// ====================================================================
inline G4MCTGenEvent::G4MCTGenEvent(const G4MCTGenEvent& right)
{
*this= right;
}
inline const G4MCTGenEvent& G4MCTGenEvent::operator=(const G4MCTGenEvent& right)
{
eventList= right.eventList; // shallow copy
return *this;
}
#endif
@@ -0,0 +1,40 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTGenParticle.hh
//
// ====================================================================
#ifndef MCT_GEN_PARTICLE_H
#define MCT_GEN_PARTICLE_H
#include "G4Types.hh"
#include <algorithm>
#include "CLHEP/HepMC/GenEvent.h"
#include "CLHEP/HepMC/GenParticle.h"
typedef std::pair<HepMC::GenEvent*, HepMC::GenParticle*> G4MCTGenParticle;
#endif
@@ -0,0 +1,142 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimEvent.hh
//
// ====================================================================
#ifndef MCT_SIM_EVENT_H
#define MCT_SIM_EVENT_H
#include "G4Types.hh"
#include <iostream>
#include <vector>
#include <map>
// ====================================================================
//
// class definition
//
// ====================================================================
class G4MCTSimParticle;
class G4MCTSimVertex;
typedef std::map<int, G4MCTSimParticle*> G4MCTSimParticleContainer;
typedef std::vector<G4MCTSimVertex*> G4MCTSimVertexContainer;
class G4MCTSimEvent {
protected:
G4MCTSimParticleContainer particleMap;
G4MCTSimVertexContainer vertexVec;
public:
G4MCTSimEvent();
~G4MCTSimEvent();
// copy constructor and assignment operator
G4MCTSimEvent(const G4MCTSimEvent& right);
const G4MCTSimEvent& operator=(const G4MCTSimEvent& right);
// methods...
G4bool AddParticle(const G4MCTSimParticle* aparticle);
int GetNofParticles() const;
int GetNofVertices() const;
int GetNofStoredParticles() const;
int GetNofStoredVertices() const;
G4MCTSimParticle* FindParticle(int tid) const;
G4MCTSimVertex* GetVertex(int vid) const;
void BuildVertexContainer();
void ClearEvent();
void Print(std::ostream& ostr= std::cout) const;
// iterators
typedef G4MCTSimParticleContainer::iterator particle_iterator;
typedef G4MCTSimParticleContainer::const_iterator particle_const_iterator;
particle_iterator particles_begin();
particle_iterator particles_end();
particle_const_iterator particles_begin() const;
particle_const_iterator particles_end() const;
typedef G4MCTSimVertexContainer::iterator vertex_iterator;
typedef G4MCTSimVertexContainer::const_iterator vertex_const_iterator;
vertex_iterator vertices_begin();
vertex_iterator vertices_end();
vertex_const_iterator vertices_begin() const;
vertex_const_iterator vertices_end() const;
};
// ====================================================================
// inline functions
// ====================================================================
inline G4MCTSimEvent::G4MCTSimEvent(const G4MCTSimEvent& right)
{
*this= right;
}
inline const G4MCTSimEvent& G4MCTSimEvent::operator=(const G4MCTSimEvent& right)
{
particleMap= right.particleMap; // shallow copy
return *this;
}
inline int G4MCTSimEvent::GetNofParticles() const
{
return particleMap.size();
}
inline int G4MCTSimEvent::GetNofVertices() const
{
return vertexVec.size();
}
// iterators
inline G4MCTSimEvent::particle_iterator G4MCTSimEvent::particles_begin()
{ return particleMap.begin(); }
inline G4MCTSimEvent::particle_iterator G4MCTSimEvent::particles_end()
{ return particleMap.end(); }
inline G4MCTSimEvent::particle_const_iterator
G4MCTSimEvent::particles_begin() const
{ return particleMap.begin(); }
inline G4MCTSimEvent::particle_const_iterator G4MCTSimEvent::particles_end() const
{ return particleMap.end(); }
inline G4MCTSimEvent::vertex_iterator G4MCTSimEvent::vertices_begin()
{ return vertexVec.begin(); }
inline G4MCTSimEvent::vertex_iterator G4MCTSimEvent::vertices_end()
{ return vertexVec.end(); }
inline G4MCTSimEvent::vertex_const_iterator G4MCTSimEvent::vertices_begin() const
{ return vertexVec.begin(); }
inline G4MCTSimEvent::vertex_const_iterator G4MCTSimEvent::vertices_end() const
{ return vertexVec.end(); }
#endif
@@ -0,0 +1,184 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimParticle.hh
//
// ====================================================================
#ifndef MCT_SIM_PARTICLE_H
#define MCT_SIM_PARTICLE_H
#include "G4Types.hh"
#include <vector>
#include <string>
#include <iostream>
#include "G4LorentzVector.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4MCTSimVertex;
class G4MCTSimParticle;
typedef std::vector<G4MCTSimParticle*> SimParticleList;
class G4MCTSimParticle {
protected:
G4MCTSimParticle* parentParticle;
std::vector<G4MCTSimParticle*> associatedParticleList;
std::string name;
int pdgID;
int trackID;
int parentTrackID;
G4bool primaryFlag;
G4LorentzVector momentumAtVertex;
G4MCTSimVertex* vertex;
G4bool storeFlag;
public:
G4MCTSimParticle();
G4MCTSimParticle(std::string aname, int apcode, int atid, int ptid,
const G4LorentzVector& p);
G4MCTSimParticle(std::string aname, int apcode, int atid, int ptid,
const G4LorentzVector& p, const G4MCTSimVertex* v);
virtual ~G4MCTSimParticle();
// copy constructor and assignment operator
G4MCTSimParticle(const G4MCTSimParticle& right);
const G4MCTSimParticle& operator=(const G4MCTSimParticle& right);
// set/get functions
void SetParentParticle(const G4MCTSimParticle* p);
G4MCTSimParticle* GetParentParticle() const;
void SetParticleName(std::string aname);
const std::string& GetParticleName() const;
void SetPdgID(int id);
int GetPdgID() const;
void SetTrackID(int id);
int GetTrackID() const;
void SetParentTrackID(int id);
int GetParentTrackID() const;
void SetPrimaryFlag(G4bool q);
G4bool GetPrimaryFlag() const;
void SetMomentumAtVertex(const G4LorentzVector& p);
const G4LorentzVector& GetMomentumAtVertex() const;
void SetVertex(const G4MCTSimVertex* v);
G4MCTSimVertex* GetVertex() const;
void SetStoreFlag(G4bool q);
G4bool GetStoreFlag() const;
// methods...
int AssociateParticle(G4MCTSimParticle* p);
int GetNofAssociatedParticles() const;
G4MCTSimParticle* GetAssociatedParticle(int i) const;
int GetTreeLevel() const;
void SetStoreFlagToParentTree(G4bool q=true);
void Print(std::ostream& ostr= std::cout, G4bool qrevorder=false) const;
void PrintSingle(std::ostream& ostr= std::cout) const;
};
// ====================================================================
// inline functions
// ====================================================================
inline G4MCTSimParticle::G4MCTSimParticle(const G4MCTSimParticle& right)
{
*this= right;
}
inline const G4MCTSimParticle&
G4MCTSimParticle::operator=(const G4MCTSimParticle& right)
{
parentParticle= right.parentParticle;
associatedParticleList= right.associatedParticleList; // shallow copy
name= right.name;
pdgID= right.pdgID;
trackID= right.trackID;
parentTrackID= right.parentTrackID;
primaryFlag= right.primaryFlag;
momentumAtVertex= right.momentumAtVertex;
vertex= right.vertex;
return *this;
}
inline void G4MCTSimParticle::SetParentParticle(const G4MCTSimParticle* p)
{ parentParticle= const_cast<G4MCTSimParticle*>(p); }
inline G4MCTSimParticle* G4MCTSimParticle::GetParentParticle() const
{ return parentParticle; }
inline void G4MCTSimParticle::SetParticleName(std::string aname)
{ name= aname; }
inline const std::string& G4MCTSimParticle::GetParticleName() const
{ return name; }
inline void G4MCTSimParticle::SetPdgID(int id) { pdgID= id; }
inline int G4MCTSimParticle::GetPdgID() const { return pdgID; }
inline void G4MCTSimParticle::SetTrackID(int id) { trackID= id; }
inline int G4MCTSimParticle::GetTrackID() const { return trackID; }
inline void G4MCTSimParticle::SetPrimaryFlag(G4bool q) { primaryFlag= q; }
inline G4bool G4MCTSimParticle::GetPrimaryFlag() const { return primaryFlag; }
inline void G4MCTSimParticle::SetParentTrackID(int id)
{ parentTrackID= id; }
inline int G4MCTSimParticle::GetParentTrackID() const
{ return parentTrackID; }
inline void G4MCTSimParticle::SetMomentumAtVertex(const G4LorentzVector& p)
{ momentumAtVertex= p; }
inline const G4LorentzVector& G4MCTSimParticle::GetMomentumAtVertex() const
{ return momentumAtVertex; }
inline void G4MCTSimParticle::SetVertex(const G4MCTSimVertex* v)
{ vertex= const_cast<G4MCTSimVertex*>(v); }
inline G4MCTSimVertex* G4MCTSimParticle::GetVertex() const
{ return vertex; }
inline void G4MCTSimParticle::SetStoreFlag(G4bool q) { storeFlag= q; }
inline G4bool G4MCTSimParticle::GetStoreFlag() const { return storeFlag; }
#endif
@@ -0,0 +1,196 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimVertex.hh
//
// ====================================================================
#ifndef MCT_SIM_VERTEX_H
#define MCT_SIM_VERTEX_H
#include "G4Types.hh"
#include <iostream>
#include <vector>
#include <string>
#include "G4ThreeVector.hh"
#include "G4MCTSimParticle.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4MCTSimVertex {
private:
int inParticleTrackID;
std::vector<int> outParticleTrackIDList;
int id; // assigned independently from G4
G4ThreeVector position;
double time;
std::string volumeName;
int volumeNumber;
std::string creatorProcessName;
G4bool storeFlag;
public:
G4MCTSimVertex();
G4MCTSimVertex(const G4ThreeVector& x, double t);
G4MCTSimVertex(const G4ThreeVector& x, double t,
std::string vname, int ncopy, std::string pname);
~G4MCTSimVertex();
// copy constructor and assignment operator
G4MCTSimVertex(const G4MCTSimVertex& right);
const G4MCTSimVertex& operator=(const G4MCTSimVertex& right);
// set/get functions
void SetID(int i);
int GetID() const;
void SetPosition(const G4ThreeVector& x);
const G4ThreeVector& GetPosition() const;
void SetTime(double t);
double GetTime() const;
void SetVolumeName(std::string vname);
const std::string& GetVolumeName() const;
void SetVolumeNumber(int n);
int GetVolumeNumber() const;
void SetCreatorProcessName(std::string pname);
const std::string& GetCreatorProcessName() const;
void SetStoreFlag(G4bool q);
G4bool GetStoreFlag() const;
// methods...
void SetInParticle(const G4MCTSimParticle* in);
void SetInParticle(int in);
int GetInParticleTrackID() const;
int GetNofOutParticles() const;
int AddOutParticle(const G4MCTSimParticle* out);
int AddOutParticle(int out);
int GetOutParticleTrackID(int i) const;
void Print(std::ostream& ostr= std::cout) const;
};
// ====================================================================
// inline functions
// ====================================================================
inline G4MCTSimVertex::G4MCTSimVertex(const G4MCTSimVertex& right)
{
*this= right;
}
inline const G4MCTSimVertex&
G4MCTSimVertex::operator=(const G4MCTSimVertex& right)
{
inParticleTrackID= right.inParticleTrackID;
outParticleTrackIDList= right.outParticleTrackIDList;
id= right.id;
position= right.position;
time= right.time;
volumeName= right.volumeName;
volumeNumber= right.volumeNumber;
creatorProcessName= right.creatorProcessName;
return *this;
}
inline void G4MCTSimVertex::SetID(int i) { id= i; }
inline int G4MCTSimVertex::GetID() const { return id; }
inline void G4MCTSimVertex::SetPosition(const G4ThreeVector& x)
{ position= x; }
inline const G4ThreeVector& G4MCTSimVertex::GetPosition() const
{ return position; }
inline void G4MCTSimVertex::SetTime(double t)
{ time= t; }
inline double G4MCTSimVertex::GetTime() const
{ return time; }
inline void G4MCTSimVertex::SetVolumeName(std::string vname)
{ volumeName= vname; }
inline const std::string& G4MCTSimVertex::GetVolumeName() const
{ return volumeName; }
inline void G4MCTSimVertex::SetVolumeNumber(int n)
{ volumeNumber= n; }
inline int G4MCTSimVertex::GetVolumeNumber() const
{ return volumeNumber; }
inline void G4MCTSimVertex::SetCreatorProcessName(std::string pname)
{ creatorProcessName= pname; }
inline const std::string& G4MCTSimVertex::GetCreatorProcessName() const
{ return creatorProcessName; }
inline void G4MCTSimVertex::SetStoreFlag(G4bool q) { storeFlag= q; }
inline G4bool G4MCTSimVertex::GetStoreFlag() const { return storeFlag; }
inline void G4MCTSimVertex::SetInParticle(const G4MCTSimParticle* in)
{ inParticleTrackID= in-> GetTrackID(); }
inline void G4MCTSimVertex::SetInParticle(int in)
{ inParticleTrackID= in; }
inline int G4MCTSimVertex::GetInParticleTrackID() const
{ return inParticleTrackID; }
inline int G4MCTSimVertex::GetNofOutParticles() const
{ return outParticleTrackIDList.size(); }
inline int G4MCTSimVertex::AddOutParticle(const G4MCTSimParticle* out)
{
outParticleTrackIDList.push_back(out->GetTrackID());
return outParticleTrackIDList.size();
}
inline int G4MCTSimVertex::AddOutParticle(int out)
{
outParticleTrackIDList.push_back(out);
return outParticleTrackIDList.size();
}
inline int G4MCTSimVertex::GetOutParticleTrackID(int i) const
{
int size= outParticleTrackIDList.size();
if(i>=0 && i< size) return outParticleTrackIDList[i];
else return 0;
}
#endif
@@ -0,0 +1,180 @@
//
// ********************************************************************
// * 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: G4PersistencyCenter.hh
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#ifndef PERSISTENCY_CENTER_HH
#define PERSISTENCY_CENTER_HH 1
#include "G4Types.hh"
#include <string>
#include <vector>
#include <map>
#include "G4HCIOcatalog.hh"
#include "G4VHCIOentry.hh"
#include "G4DCIOcatalog.hh"
#include "G4VDCIOentry.hh"
#ifndef WIN32
#include "G4FileUtilities.hh"
#endif
// Forward Declaration to avoid circular dependencies.
class G4PersistencyManager;
typedef std::map<std::string, G4PersistencyManager*,std::less<std::string> > PMap;
typedef std::map<int, std::string, std::less<int> > ObjMap;
typedef std::map<std::string, std::string, std::less<std::string> > FileMap;
enum StoreMode { kOn, kOff, kRecycle };
typedef std::map<std::string, StoreMode, std::less<std::string> > StoreMap;
typedef std::map<std::string, G4bool, std::less<std::string> > BoolMap;
// Forward Declarations:
class G4PersistencyCenterMessenger;
// Class Description:
// Class to handle loading of the G4PersistencyManager.
class G4PersistencyCenter
{
public: // With description
G4PersistencyCenter();
G4PersistencyCenter(const G4PersistencyCenter&);
// Constructor
~G4PersistencyCenter();
// Destructor
public: // With description
static G4PersistencyCenter* GetPersistencyCenter();
// returns the pointer of singleton G4PersistencyCenter
void SelectSystem(std::string systemName);
// Select the persistency package
const std::string CurrentSystem() { return f_currentSystemName; };
// returns the current persistent package name
void SetHepMCObjyReaderFile(std::string file);
// Sets the name of HepMCObjyReader file name. To be called by generator.
std::string CurrentHepMCObjyReaderFile();
// Sets the name of HepMCObjyReader file name. To be called by generator.
void SetStoreMode(std::string objName, StoreMode mode);
// Sets the object store mode. Modes are kOn, kOff or kRecycle.
void SetRetrieveMode(std::string objName, G4bool mode);
// Sets the object retrieve mode. Modes are true or false.
StoreMode CurrentStoreMode(std::string objName);
// returns the current object store mode.
G4bool CurrentRetrieveMode(std::string objName);
// returns the current object store mode.
G4bool SetWriteFile(std::string objName, std::string writeFileName);
// Sets the output filename.
G4bool SetReadFile(std::string objName, std::string readFileName);
// Sets the input filename.
std::string CurrentWriteFile(std::string objName);
// returns the current output filename.
std::string CurrentReadFile(std::string objName);
// returns the current input filename.
std::string CurrentObject(std::string file);
// returns the current object type
void AddHCIOmanager(std::string detName, std::string colName);
// add a hits colleciton I/O manager to the catalog
std::string CurrentHCIOmanager();
// Returns a list of registered hits colleciton I/O managers
void AddDCIOmanager(std::string detName);
// add a digits colleciton I/O manager to the catalog
std::string CurrentDCIOmanager();
// Returns a list of registered digits colleciton I/O managers
void PrintAll();
// prints the current G4PersistencyCenter settings.
G4PersistencyManager* CurrentPersistencyManager() { return f_currentManager; };
// returns the pointer of the currnet G4PersistencyManager.
void SetPersistencyManager(G4PersistencyManager* pm, std::string name);
// returns the pointer of the currnet G4PersistencyManager.
G4PersistencyManager* GetPersistencyManager(std::string nam);
// returns the pointer of the currnet G4PersistencyManager with name.
void RegisterPersistencyManager(G4PersistencyManager* pm);
// registers the persistency manager to the runtime catalog.
void DeletePersistencyManager();
// deletes the current G4PersistencyManager.
void SetVerboseLevel(int v);
// Set verbose level.
int VerboseLevel() { return m_verbose; };
// Return verbose level.
private:
std::string PadString(std::string name, unsigned int width);
// truncate or pad a string up to the width.
private:
G4PersistencyCenterMessenger* f_G4PersistencyCenterMessenger;
private:
G4PersistencyCenterMessenger* f_theMessenger;
static G4PersistencyCenter* f_thePointer;
G4PersistencyManager* f_currentManager;
std::string f_currentSystemName;
PMap f_theCatalog;
ObjMap f_wrObj;
ObjMap f_rdObj;
FileMap f_writeFileName;
FileMap f_readFileName;
StoreMap f_writeFileMode;
BoolMap f_readFileMode;
G4int m_verbose;
#ifndef WIN32
G4FileUtilities f_ut;
#endif
}; // End of class G4PersistencyCenter
#endif
@@ -0,0 +1,85 @@
//
// ********************************************************************
// * 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: G4PersistencyCenterMessenger.hh
//
// History:
// 01.07.18 Youhei Morita Initial creation (with "fadsclass")
#ifndef PERSISTENCY_CENTER_MESSENGER_HH
#define PERSISTENCY_CENTER_MESSENGER_HH 1
#include "G4UIcommand.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4PersistencyCenter.hh"
// Class inherited:
#include "G4UImessenger.hh"
// Class Description:
// User interface messenger class to interface G4PersistencyCenter
class G4PersistencyCenterMessenger
: public G4UImessenger
{
public: // With description
G4PersistencyCenterMessenger(G4PersistencyCenter* p);
// Constructor
~G4PersistencyCenterMessenger();
// Destructor
public: // With description
void SetNewValue(G4UIcommand* command, G4String newValues);
// User interface for setting a new value
G4String GetCurrentValue(G4UIcommand* command);
// User interface for getting a value
private:
std::string PopWord(std::string text, int n, std::string delim);
// Parse text and returns the n-th words separated by delim
private:
G4PersistencyCenter* pc;
G4UIdirectory* directory, *subdir1, *subdir2,
*subdir3, *subdir4, *subdir5;
G4UIcmdWithAnInteger* verboseCmd;
G4UIcmdWithAString* select;
G4UIcmdWithAString* regHitIO;
std::vector<std::string> wrObj;
std::vector<std::string> rdObj;
std::vector<G4UIcmdWithAString*> storeObj;
std::vector<G4UIcmdWithAString*> setWrFile;
std::vector<G4UIcmdWithAString*> setRdFile;
G4UIcmdWithoutParameter* printAll;
}; // End of class G4PersistencyCenterMessenger
#endif
@@ -0,0 +1,218 @@
//
// ********************************************************************
// * 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: G4PersistencyManager.hh
//
// History:
// 01.07.17 Youhei Morita Initial creation (with "fadsclass")
#ifndef PERSISTENCY_MANAGER_HH
#define PERSISTENCY_MANAGER_HH 1
#include "G4Event.hh"
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "CLHEP/HepMC/GenEvent.h"
#include "G4VHepMCIO.hh"
#include "G4VMCTruthIO.hh"
#endif
#endif
#include "G4HCIOcatalog.hh"
#include "G4DCIOcatalog.hh"
#include "G4VPEventIO.hh"
#include "G4VPHitIO.hh"
#include "G4VPDigitIO.hh"
#include "G4VTransactionManager.hh"
#include <string>
class G4PersistencyCenter;
// Class inherited:
#include "G4VPersistencyManager.hh"
// Class Description:
// Manager base class to handle event store and retrieve operation.
// Actual persistency implementation should be handled with
// derived classes.
//
// Each persistency package should implement derived classes of
// G4VHepMCIO, G4VMCTruthIO, G4VPHitIO, G4VPDigitIO, G4VPEventIO.
// Concreate G4PersistencyManager should implement the methods
// HepMCIO(), MCTruthIO(), HitIO(), DigitIO() and EventIO() to
// return the pointers of the above classes.
// G4PersistencyManager handles the sequence of the storing and
// retrieving of the persistent object of each type, along with
// the transaction handling.
//
// Retrieving a HepMC event:
//
// G4PersistencyManager::Retrieve( HepMC::GenEvent*& )
// |
// | ... StartRead() ...
// |
// | ... HepMCIO()->Retrieve() ...
// |
// | ... Commit() ...
// V
//
// Storing a Geant4 event:
//
// G4PersistencyManager::Store( G4Pevent* )
// |
// | ... StartUpdate() ...
// |
// | ... HepMCIO()->Store( HepMC event ) ...
// |
// | ... MCTruthIO()->Store( MCTruth event ) ...
// |
// | ... HitIO()->Store( hit_collection_of_event ) ...
// |
// | ... DigitIO()->Store( digit_collection_of_event ) ...
// |
// | ... EventIO()->Store( event with hits and digits ) ...
// |
// | ... Commit() ...
// V
//
// Retrieving a Geant event:
//
// G4PersistencyManager::Retrieve( event )
// |
// | ... StartRead() ...
// |
// | ... EventIO()->Retrieve( event ) ...
// |
// | ... Commit() ...
// V
//
// Hit collection and digit collection of each detector component
// should be handled by detector specific I/O manager, which
// should be registered to the G4PersistencyCenter with
// AddHCIOmanager() and AddDCIOmanager(). Usually this is done
// through a command
//
// /Persistency/Store/Using/HitIO <detector_io_manager_name>
//
// which is handled by G4PersistencyCenterMessenger.
//
// A static template declaration of G4HCIOentryT<class> must be
// implementated for each I/O manager.
class G4PersistencyManager
: public G4VPersistencyManager
{
friend class G4PersistencyCenter;
public: // With description
G4PersistencyManager(G4PersistencyCenter* pc, std::string n);
// Constructor
virtual ~G4PersistencyManager();
// Destructor
public: // With description
virtual G4PersistencyManager* Create() {return 0;};
// Create a new persistency manager. To be used by G4PersistencyManagerT<>.
std::string GetName() {return nameMgr;};
// Get the name of persistency manager
virtual G4VPEventIO* EventIO() { return 0; };
// Returns the current event I/O handling manager
// Each derived class should return the pointer of actual manager.
virtual G4VPHitIO* HitIO() { return 0; };
// Returns the current hit I/O handling manager
// Each derived class should return the pointer of actual manager.
virtual G4VPDigitIO* DigitIO() { return 0; };
// Returns the current digit I/O handling manager
// Each derived class should return the pointer of actual manager.
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
virtual G4VHepMCIO* HepMCIO() { return 0; };
// Returns the current HepMC I/O handling manager
// Each derived class should return the pointer of actual manager.
virtual G4VMCTruthIO* MCTruthIO() { return 0; };
// Returns the current MCTruth I/O handling manager
// Each derived class should return the pointer of actual manager.
#endif
#endif
virtual G4VTransactionManager* TransactionManager() { return 0; };
// Returns the current transaction manager
// Each derived class should return the pointer of actual manager.
virtual void Initialize() {};
// Initialize the persistency package.
// Each derived class should implement the acutal initialization sequence.
void SetVerboseLevel(int v);
// Set verbose level.
G4bool Store(const G4Event* evt);
// Store the G4Event and its associated objects
G4bool Retrieve(G4Event*& evt);
// Retrieve the G4Event and its associated objects
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
G4bool Retrieve(HepMC::GenEvent*& evt, int id=-1);
// retrieves HepMC GenEvent and its associated object.
// To be used by generator/HepMCObjyReader.
#endif
#endif
G4bool Store(const G4Run*) {return false;};
// not used
G4bool Retrieve(G4Run*&) {return false;};
// not used
G4bool Store(const G4VPhysicalVolume*) {return false;};
// not used
G4bool Retrieve(G4VPhysicalVolume*&) {return false;};
// not used
protected:
static G4PersistencyManager* GetPersistencyManager();
// Get the instance of persistency manager
protected:
G4PersistencyCenter* f_pc;
int m_verbose;
private:
std::string nameMgr;
// GeneratorCenter* f_GenCenter;
// G4MCTManager* f_MCTman;
G4bool f_is_initialized;
}; // End of class G4PersistencyManager
#endif
@@ -0,0 +1,130 @@
//
// ********************************************************************
// * 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: G4PersistencyManagerT.hh
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#ifndef PERSISTENCY_MANAGER_T_HH
#define PERSISTENCY_MANAGER_T_HH 1
#include "G4PersistencyCenter.hh"
// Class inherited:
#include "G4PersistencyManager.hh"
// Class Description:
// Template class of G4PersistencyManager for late binding
template <class T> class G4PersistencyManagerT
: public G4PersistencyManager
{
public: // With description
G4PersistencyManagerT(G4PersistencyCenter* pc, std::string n)
: G4PersistencyManager(pc, n), pm(0)
{
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManagerT: Registering G4PersistencyManager \""
<< n << "\"" << G4endl;
}
G4PersistencyCenter::GetPersistencyCenter()->
RegisterPersistencyManager(this);
}
// Constructor
~G4PersistencyManagerT() {};
// Destructor
public: // With description
G4PersistencyManager* Create()
{
pm = new T(f_pc, GetName());
return pm;
}
// Create a new persistency manager
void Delete() { if (pm!=0) delete pm; };
// Delete a persistency mamanger
G4VPEventIO* EventIO()
{
if (pm) return pm->EventIO();
else return 0;
};
// Returns the current event I/O handling manager
G4VPHitIO* HitIO()
{
if (pm) return pm->HitIO();
else return 0;
};
// Returns the current hit I/O handling manager
G4VPDigitIO* DigitIO()
{
if (pm) return pm->DigitIO();
else return 0;
};
// Returns the current digit I/O handling manager
G4VHepMCIO* HepMCIO()
{
if (pm) return pm->HepMCIO();
else return 0;
};
// Returns the current digit I/O handling manager
G4VMCTruthIO* MCTruthIO()
{
if (pm) return pm->MCTruthIO();
else return 0;
};
// Returns the current digit I/O handling manager
G4VTransactionManager* TransactionManager()
{
if (pm) return pm->TransactionManager();
else return 0;
};
// Returns the current transaction manager
void Initialize() {};
// Initialize the persistency package.
void SetVerboseLevel(int v)
{
if (pm) return pm->SetVerboseLevel();
else return 0;
};
// Sets the verbose level to the persistency manager
private:
G4PersistencyManager* pm;
}; // End of class G4PersistencyManagerT
#endif
@@ -0,0 +1,90 @@
//
// ********************************************************************
// * 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: G4Pevent.hh
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef G4PEVENT_HH
#define G4PEVENT_HH 1
#include "G4Event.hh"
// not yet // #include "G4MCTEvent.hh"
#include "CLHEP/HepMC/GenEvent.h"
// Class Description:
// Geant4 event object for store.
//
// This class has pointers to HepMC::GenEvent, MCTruth and G4Event.
//
// In the event store operation, this object will be created in the concrete
// class of G4VPEventIO::Store() method, and will be deleted immediately after
// creating persistent Geant4 event.
//
// In the event retrieve operation, this object will be created in the
// concrete Persistency::Retrieve() method. The retrieved G4Pevent
// has to be deleted by the user method which called the Retrieve().
class G4Pevent
{
public: // With description
// G4Pevent( HepMC::GenEvent* hepevt, G4MCTEvent* mctevt, G4Event* g4evt );
G4Pevent( HepMC::GenEvent* hepevt, G4Event* g4evt );
// Constructor
~G4Pevent();
// Destructor
public: // With description
int GetEventID() { return m_id; };
// returns the event ID.
G4Event* GetEvent() { return f_g4evt; };
// returns the G4Event.
HepMC::GenEvent* GetHepMCGenEvent() { return f_hepevt; };
// returns the HepMC GenEvent.
// G4MCTEvent* GetMCTEvent() { return f_mctevt; };
// returns the MCTruth event.
int GetGenEventID() const { return genEventID; };
// returns the GenEvent ID.
void SetGenEventID(int id) { genEventID=id; };
// set the GenEvent ID.
private:
HepMC::GenEvent* f_hepevt;
int genEventID;
// G4MCTEvent* f_mctevt;
G4Event* f_g4evt;
int m_id;
}; // End of class G4Pevent
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * 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: G4VDCIOentry.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef VDCIO_ENTRY_T_HH
#define VDCIO_ENTRY_T_HH 1
#include "G4Types.hh"
#include <string>
#include "G4PersistencyCenter.hh"
// Class Description:
// Abstract base class for digits collection I/O manager entry
class G4VDCIOentry
{
public: // With description
G4VDCIOentry(std::string n);
// Constructor
virtual ~G4VDCIOentry() {}
// Destructor
public: // With description
void SetVerboseLevel(G4int v) { m_verbose = v; }
// Set verbose level.
std::string GetName() { return m_name; }
// Returns the name of the DC I/O manager entry
virtual void CreateDCIOmanager(std::string, std::string) {}
// virtual method for creating DC I/O manager for the detector
protected:
G4int m_verbose;
private:
std::string m_name;
}; // End of class G4VDCIOentry
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * 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: G4VHCIOentry.hh
//
// History:
// '01.09.12 Youhei Morita Initial creation
#ifndef VHCIO_ENTRY_T_HH
#define VHCIO_ENTRY_T_HH 1
#include "G4Types.hh"
#include <string>
#include "G4PersistencyCenter.hh"
// Class Description:
// Abstract base class for hits collection I/O manager entry
class G4VHCIOentry
{
public: // With description
G4VHCIOentry(std::string n);
// Constructor
virtual ~G4VHCIOentry() {}
// Destructor
public: // With description
void SetVerboseLevel(G4int v) { m_verbose = v; }
// Set verbose level.
std::string GetName() { return m_name; }
// Returns the name of the HC I/O manager entry
virtual void CreateHCIOmanager(std::string, std::string) {}
// virtual method for creating HC I/O manager for the detector
protected:
G4int m_verbose;
private:
std::string m_name;
}; // End of class G4VHCIOentry
#endif
@@ -0,0 +1,72 @@
//
// ********************************************************************
// * 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: G4VHepMCIO.hh
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef G4V_HEPMC_IO_HH
#define G4V_HEPMC_IO_HH 1
#include "G4Types.hh"
#include "CLHEP/HepMC/GenEvent.h"
// Class Description:
// Abstract base class for storing and retrieving HepMC events.
class G4VHepMCIO
{
public: // With description
G4VHepMCIO();
// Constructor
virtual ~G4VHepMCIO() {};
// Destructor
public: // With description
virtual G4bool Store(HepMC::GenEvent*) =0;
// Pure virtual method for storing HepMC GenEvent.
// Each persistency package should implement a concrete method
// of storing the HepMC::GenEvent with this signature.
virtual G4bool Retrieve(HepMC::GenEvent*&, int id=-1) =0;
// Pure virtual method for retrieving HepMC GenEvent.
// Each persistency package should implement a concrete method
// of storing the HepMC::GenEvent with this signature.
virtual int LastEventID() =0;
// Pure virtual method for the event ID
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
protected:
G4int m_verbose;
}; // End of class G4VHepMCIO
#endif
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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: G4VMCTruthIO.hh
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef V_M_C_TRUTH_I_O_HH
#define V_M_C_TRUTH_I_O_HH 1
#include "G4MCTEvent.hh"
// Class Description:
// Abstract base class for storing and retrieving MCTruth events.
class G4VMCTruthIO
{
public: // With description
G4VMCTruthIO();
// Constructor
virtual ~G4VMCTruthIO() {};
// Destructor
public: // With description
virtual G4bool Store(G4MCTEvent*) =0;
// Pure virtual method for storing MCTruth Event.
// Each persistency package should implement a concrete method
// of storing the G4MCTEvent with this signature.
virtual G4bool Retrieve(G4MCTEvent*&) =0;
// Pure virtual method for retrieving MCTruth Event.
// Each persistency package should implement a concrete method
// of storing the G4MCTEvent with this signature.
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
protected:
G4int m_verbose;
}; // End of class G4VMCTruthIO
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// File: G4VPDigitIO.hh
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#ifndef V_P_DIGIT_I_O_HH
#define V_P_DIGIT_I_O_HH 1
#include "G4DCofThisEvent.hh"
#include "G4DCIOcatalog.hh"
#include "G4VPDigitsCollectionIO.hh"
// Class Description:
// Abstract base class for storing and retrieving digit collections
class G4VPDigitIO
{
public: // With description
G4VPDigitIO();
// Constructor
virtual ~G4VPDigitIO() {};
// Destructor
public: // With description
G4VPDigitIO* GetVPDigitIO() { return f_G4VPDigitIO; };
// Returns the pointer of the digit collection I/O manager.
virtual G4bool Store(const G4DCofThisEvent*) =0;
// Pure virtual method for storing digit collections of this event.
// Each persistency package should implement a concrete method
// of storing the digit collection of this event with this signature.
virtual G4bool Retrieve(G4DCofThisEvent*&) =0;
// Pure virtual method for retrieving digit collections of this event.
// Each persistency package should implement a concrete method
// of storing the digit collection of this event with this signature.
void SetVerboseLevel(int v);
// Set verbose level.
protected:
void SetG4VPDigitIO(G4VPDigitIO* digitMan) { f_G4VPDigitIO = digitMan; };
// Registers the digit collection I/O manager.
protected:
G4int m_verbose;
static G4VPDigitIO* f_G4VPDigitIO;
G4DCIOcatalog* f_catalog;
}; // End of class G4VPDigitIO
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// File: G4VPDigitsCollectionIO.hh
//
// History:
// '01.08.16 Youhei Morita Initial creation
#ifndef V_P_DIGITS_COLLECTION_I_O_HH
#define V_P_DIGITS_COLLECTION_I_O_HH 1
#include "G4VDigiCollection.hh"
// Class Description:
// Abstract base class for storing and retrieving digit collections
class G4VPDigitsCollectionIO
{
public: // With description
G4VPDigitsCollectionIO( std::string detName, std::string colName );
// Constructor
virtual ~G4VPDigitsCollectionIO() {};
// Destructor
public: // With description
virtual G4bool Store(const G4VDigiCollection*) =0;
// Pure virtual method for storing the digit collection.
// Each persistency package should implement a concrete method
// with this signature.
virtual G4bool Retrieve(G4VDigiCollection*&) =0;
// Pure virtual method for retrieving the digit collection.
// Each persistency package should implement a concrete method
// with this signature.
G4bool operator== (const G4VPDigitsCollectionIO& right) const;
// virtual operator for comparing digit collections with names.
std::string DMname() { return f_detName; };
// Returns the digitizer module name.
std::string CollectionName() { return f_colName; };
// Returns the digit collection name.
void SetVerboseLevel(int v) { m_verbose = v; };
// Sets the verbose level
protected:
G4int m_verbose;
std::string f_detName;
std::string f_colName;
}; // End of class G4VPDigitsCollectionIO
#endif
@@ -0,0 +1,85 @@
//
// ********************************************************************
// * 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: G4VPEventIO.hh
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#ifndef V_P_EVENT_I_O_HH
#define V_P_EVENT_I_O_HH 1
#include "G4Event.hh"
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "CLHEP/HepMC/GenEvent.h"
// not yet // #include "G4MCTEvent.hh"
#include "G4Pevent.hh"
#endif
#endif
// Class Description:
// Abstract base class for storing and retrieving an event object
class G4VPEventIO
{
public: // With description
G4VPEventIO();
// Constructor
virtual ~G4VPEventIO() {};
// Destructor
public: // With description
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
inline G4int CurrentEventID() { return m_currentEvtID; };
// Returns the current event id.
virtual G4bool Store( const G4Event* anEvent ) =0;
// Store a Geant4 event.
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
// virtual G4bool Store( HepMC::GenEvent* hepevt, G4MCTEvent* mctevt, const G4Event* anEvent ) =0;
virtual G4bool Store( HepMC::GenEvent* hepevt, const G4Event* anEvent ) =0;
// Store a Geant4 event.
virtual G4bool Retrieve( G4Pevent*& anEvent ) =0;
// Retrieve a Geant4 event.
#endif
#endif
virtual G4bool Retrieve( G4Event*& anEvent ) =0;
// Retrieve a Geant4 event.
protected:
G4int m_verbose;
G4int m_currentEvtID;
}; // End of class G4VPEventIO
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// File: G4VPHitIO.hh
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#ifndef V_P_HIT_I_O_HH
#define V_P_HIT_I_O_HH 1
#include "G4HCofThisEvent.hh"
#include "G4HCIOcatalog.hh"
#include "G4VPHitsCollectionIO.hh"
// Class Description:
// Abstract base class for storing and retrieving hit collections
class G4VPHitIO
{
public: // With description
G4VPHitIO();
// Constructor
virtual ~G4VPHitIO() {};
// Destructor
public: // With description
G4VPHitIO* GetVPHitIO() { return f_G4VPHitIO; };
// Returns the pointer of the hit collection I/O manager.
virtual G4bool Store(const G4HCofThisEvent*) =0;
// Pure virtual method for storing hit collections of this event.
// Each persistency package should implement a concrete method
// of storing the hit collection of this event with this signature.
virtual G4bool Retrieve(G4HCofThisEvent*&) =0;
// Pure virtual method for retrieving hit collections of this event.
// Each persistency package should implement a concrete method
// of storing the hit collection of this event with this signature.
void SetVerboseLevel(int v);
// Set verbose level.
protected:
void SetG4VPHitIO(G4VPHitIO* hitMan) { f_G4VPHitIO = hitMan; };
// Registers the hit collection I/O manager.
protected:
G4int m_verbose;
static G4VPHitIO* f_G4VPHitIO;
G4HCIOcatalog* f_catalog;
}; // End of class G4VPHitIO
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// File: G4VPHitsCollectionIO.hh
//
// History:
// '01.08.16 Youhei Morita Initial creation
#ifndef V_P_HITS_COLLECTION_I_O_HH
#define V_P_HITS_COLLECTION_I_O_HH 1
#include "G4VHitsCollection.hh"
// Class Description:
// Abstract base class for storing and retrieving hit collections
class G4VPHitsCollectionIO
{
public: // With description
G4VPHitsCollectionIO( std::string detName, std::string colName );
// Constructor
virtual ~G4VPHitsCollectionIO() {};
// Destructor
public: // With description
virtual G4bool Store(const G4VHitsCollection*) =0;
// Pure virtual method for storing the hit collection.
// Each persistency package should implement a concrete method
// with this signature.
virtual G4bool Retrieve(G4VHitsCollection*&) =0;
// Pure virtual method for retrieving the hit collection.
// Each persistency package should implement a concrete method
// with this signature.
G4bool operator== (const G4VPHitsCollectionIO& right) const;
// virtual operator for comparing hit collections with names.
std::string SDname() { return f_detName; };
// Returns the sensitive detector name.
std::string CollectionName() { return f_colName; };
// Returns the hit collection name.
void SetVerboseLevel(int v) { m_verbose = v; };
// Sets the verbose level
protected:
G4int m_verbose;
std::string f_detName;
std::string f_colName;
}; // End of class G4VPHitsCollectionIO
#endif
@@ -0,0 +1,77 @@
//
// ********************************************************************
// * 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: G4VTransactionManager.hh
//
// History:
// 01.07.18 Youhei Morita Initial creation (with "fadsclass")
#ifndef V_TRANSACTION_MANAGER_HH
#define V_TRANSACTION_MANAGER_HH 1
#include "G4Types.hh"
#include <string>
// Class Description:
// Abstract base class for starting and commiting or aborting data transaction
class G4VTransactionManager
{
public: // With description
G4VTransactionManager() : m_verbose(0) {};
// Constructor
virtual ~G4VTransactionManager() {};
// Destructor
public: // With description
void SetVerboseLevel(int v) { m_verbose = v; };
// Set verbose level.
virtual G4bool SelectReadFile(std::string obj, std::string file)=0;
// Set the input file name and open it for the object type "obj".
virtual G4bool SelectWriteFile(std::string obj, std::string file)=0;
// Set the output file name and open it for the object type "obj".
virtual G4bool StartUpdate()=0;
// Start an update transaction for event store and retrieve
virtual G4bool StartRead()=0;
// Start a read-only transaction for event store and retrieve
virtual void Commit()=0;
// commit the transaction for event store and retrieve
virtual void Abort()=0;
// abort the transaction for event store and retrieve
protected:
G4int m_verbose;
}; // End of class G4VTransactionManager
#endif
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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: G4DCIOcatalog.cc
//
// History:
// '01.09.12 Youhei Morita Initial creation
#include "G4DCIOcatalog.hh"
// Addtional Include:
#include "G4VDCIOentry.hh"
G4DCIOcatalog* G4DCIOcatalog::f_thePointer = 0;
// Implementation of Constructor #1
G4DCIOcatalog::G4DCIOcatalog()
: m_verbose(0)
{}
// Implementation of GetDCIOcatalog
G4DCIOcatalog* G4DCIOcatalog::GetDCIOcatalog()
{
if ( f_thePointer == 0 ) f_thePointer = new G4DCIOcatalog;
return f_thePointer;
}
// Implementation of RegisterEntry
void G4DCIOcatalog::RegisterEntry(G4VDCIOentry* d)
{
if ( m_verbose > 0 ) {
G4cout << "registering I/O manager entry \"" << d->GetName()
<< "\" " << d << "." << G4endl;
}
if ( theCatalog.find(d->GetName()) != theCatalog.end() ) {
G4cout << "Redefining I/O Managers list " << d->GetName() << G4endl;
} else {
theCatalog[d->GetName()] = d;
}
}
// Implementation of RegisterDCIOmanager
void G4DCIOcatalog::RegisterDCIOmanager(G4VPDigitsCollectionIO* d)
{
if ( m_verbose > 0 ) {
G4cout << "registering I/O manager \"" << d->DMname()
<< "\" " << d << "." << G4endl;
}
if ( theStore.find(d->DMname()) != theStore.end() ) {
G4cout << "Redefining I/O Manager " << d->DMname() << G4endl;
} else {
theStore[d->DMname()] = d;
}
}
// Implementation of GetEntry
G4VDCIOentry* G4DCIOcatalog::GetEntry(std::string name)
{
if ( theCatalog.find(name) == theCatalog.end() ) {
G4cout << "Digit Collection I/O manager entry \"" << name
<< "\" not found!" << G4endl;
return 0;
} else {
G4VDCIOentry* ds = theCatalog[name];
return ds;
}
}
// Implementation of GetDCIOmanager
G4VPDigitsCollectionIO* G4DCIOcatalog::GetDCIOmanager(std::string name)
{
if ( theStore.find(name) == theStore.end() ) {
G4cout << "Digit Collection I/O manager \"" << name
<< "\" not found!" << G4endl;
return 0;
} else {
G4VPDigitsCollectionIO* ds = theStore[name];
return ds;
}
}
// Implementation of PrintEntries
void G4DCIOcatalog::PrintEntries()
{
G4cout << "I/O manager entries: ";
G4cout << theCatalog.size() << G4endl;
DCIOmap::const_iterator it;
for ( it=theCatalog.begin(); it != theCatalog.end(); it++ ) {
G4cout << " --- " << (*it).first << G4endl;
}
}
// Implementation of CurrentDCIOmanager
std::string G4DCIOcatalog::CurrentDCIOmanager()
{
std::string list = "";
DCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
list += (*it).first + " ";
}
return list;
}
// Implementation of PrintDCIOmanager
void G4DCIOcatalog::PrintDCIOmanager()
{
G4cout << "I/O managers: ";
G4cout << theStore.size() << G4endl;
DCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
G4cout << " --- " << (*it).first
<< ", " << (*it).second << "." << G4endl;
}
}
// Implementation of GetDCIOmanager
G4VPDigitsCollectionIO* G4DCIOcatalog::GetDCIOmanager(int n)
{
int i = 0;
DCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
if (i++ == n) return (*it).second;
}
return 0;
}
// End of G4DCIOcatalog.cc
@@ -0,0 +1,74 @@
//
// ********************************************************************
// * 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: G4FileUtilities.cc
//
// History:
// 01.08.24 Youhei Morita Initial creation
#ifndef WIN32
#include "G4FileUtilities.hh"
// Implementation of Default Constructor
G4FileUtilities::G4FileUtilities()
{
}
// Implementation of Default Destructor
G4FileUtilities::~G4FileUtilities()
{
}
// Implementation of FileExists
G4bool G4FileUtilities::FileExists(const std::string file)
{
char* c = (char *) file.c_str();
int fd = ::open( c, O_RDONLY );
// int error = errno;
if ( fd != -1 ) {
::close( fd );
return true;
} else {
return false;
}
}
// Implementation of CopyFile
int G4FileUtilities::CopyFile(const std::string srcFile, const std::string dstFile)
{
std::string cmd = "cp " + srcFile + " " + dstFile;
return Shell( cmd );
}
// Implementation of DeleteFile
int G4FileUtilities::DeleteFile(const std::string file, const std::string option)
{
std::string cmd = "rm " + option + " " + file;
return Shell( cmd );
}
#endif
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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: G4HCIOcatalog.cc
//
// History:
// '01.09.12 Youhei Morita Initial creation
#include "G4HCIOcatalog.hh"
// Addtional Include:
#include "G4VHCIOentry.hh"
G4HCIOcatalog* G4HCIOcatalog::f_thePointer = 0;
// Implementation of Constructor #1
G4HCIOcatalog::G4HCIOcatalog()
: m_verbose(0)
{}
// Implementation of GetHCIOcatalog
G4HCIOcatalog* G4HCIOcatalog::GetHCIOcatalog()
{
if ( f_thePointer == 0 ) f_thePointer = new G4HCIOcatalog;
return f_thePointer;
}
// Implementation of RegisterEntry
void G4HCIOcatalog::RegisterEntry(G4VHCIOentry* d)
{
if ( m_verbose > 0 ) {
G4cout << "registering I/O manager entry \"" << d->GetName()
<< "\" " << d << "." << G4endl;
}
if ( theCatalog.find(d->GetName()) != theCatalog.end() ) {
G4cout << "Redefining I/O Managers list " << d->GetName() << G4endl;
} else {
theCatalog[d->GetName()] = d;
}
}
// Implementation of RegisterHCIOmanager
void G4HCIOcatalog::RegisterHCIOmanager(G4VPHitsCollectionIO* d)
{
if ( m_verbose > 0 ) {
G4cout << "registering I/O manager \"" << d->SDname()
<< "\" " << d << "." << G4endl;
}
if ( theStore.find(d->SDname()) != theStore.end() ) {
G4cout << "Redefining I/O Manager " << d->SDname() << G4endl;
} else {
theStore[d->SDname()] = d;
}
}
// Implementation of GetEntry
G4VHCIOentry* G4HCIOcatalog::GetEntry(std::string name)
{
if ( theCatalog.find(name) == theCatalog.end() ) {
G4cout << "Hit Collection I/O manager entry \"" << name
<< "\" not found!" << std::endl;
return 0;
} else {
G4VHCIOentry* ds = theCatalog[name];
return ds;
}
}
// Implementation of GetHCIOmanager
G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(std::string name)
{
if ( theStore.find(name) == theStore.end() ) {
G4cout << "Hit Collection I/O manager \"" << name
<< "\" not found!" << G4endl;
return 0;
} else {
G4VPHitsCollectionIO* ds = theStore[name];
return ds;
}
}
// Implementation of PrintEntries
void G4HCIOcatalog::PrintEntries()
{
G4cout << "I/O manager entries: ";
G4cout << theCatalog.size() << G4endl;
HCIOmap::const_iterator it;
for ( it=theCatalog.begin(); it != theCatalog.end(); it++ ) {
G4cout << " --- " << (*it).first << G4endl;
}
}
// Implementation of CurrentHCIOmanager
std::string G4HCIOcatalog::CurrentHCIOmanager()
{
std::string list = "";
HCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
list += (*it).first + " ";
}
return list;
}
// Implementation of PrintHCIOmanager
void G4HCIOcatalog::PrintHCIOmanager()
{
G4cout << "I/O managers: ";
G4cout << theStore.size() << G4endl;
HCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
G4cout << " --- " << (*it).first
<< ", " << (*it).second << "." << G4endl;
}
}
// Implementation of GetHCIOmanager
G4VPHitsCollectionIO* G4HCIOcatalog::GetHCIOmanager(int n)
{
int i = 0;
HCIOstore::const_iterator it;
for ( it=theStore.begin(); it != theStore.end(); it++ ) {
if (i++ == n) return (*it).second;
}
return 0;
}
// End of G4HCIOcatalog.cc
@@ -0,0 +1,124 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTEvent.cc
//
// ====================================================================
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "G4ios.hh"
#include "G4MCTEvent.hh"
#include "G4MCTGenEvent.hh"
#include "G4MCTSimEvent.hh"
#include "G4MCTSimParticle.hh"
// ====================================================================
//
// class description
//
// ====================================================================
////////////////////
G4MCTEvent::G4MCTEvent()
: eventNumber(0)
////////////////////
{
genEvent= new G4MCTGenEvent(); // will be reused.
simEvent= new G4MCTSimEvent();
}
/////////////////////
G4MCTEvent::~G4MCTEvent()
/////////////////////
{
delete genEvent;
delete simEvent;
}
/////////////////////////////////////////////////////
G4MCTSimParticle* G4MCTEvent::GetSimParticle
(const G4MCTGenParticle& genpart) const
/////////////////////////////////////////////////////
{
MCTGen2SimParticleMap::const_iterator pos= gen2simParticleMap.find(genpart);
if(pos != gen2simParticleMap.end()) {
return pos-> second;
} else {
return 0;
}
}
////////////////////////////////////////////////////
G4MCTGenParticle G4MCTEvent::GetGenParticle
(const G4MCTSimParticle* simpart) const
////////////////////////////////////////////////////
{
MCTSim2GenParticleMap::const_iterator
pos= sim2genParticleMap.find(const_cast<G4MCTSimParticle*>(simpart));
if(pos != sim2genParticleMap.end()) {
return pos-> second;
} else {
return G4MCTGenParticle(0,0);
}
}
////////////////////////////////////////////////////////
int G4MCTEvent::AddPrimaryPair(const G4MCTGenParticle& genp,
const G4MCTSimParticle* simp)
////////////////////////////////////////////////////////
{
gen2simParticleMap.insert(std::make_pair(const_cast<G4MCTGenParticle&>(genp),
const_cast<G4MCTSimParticle*>(simp)));
sim2genParticleMap.insert(std::make_pair(const_cast<G4MCTSimParticle*>(simp),
const_cast<G4MCTGenParticle&>(genp)));
return gen2simParticleMap.size();
}
///////////////////////////
void G4MCTEvent::ClearEvent()
///////////////////////////
{
gen2simParticleMap.clear();
sim2genParticleMap.clear();
genEvent-> ClearEvent();
simEvent-> ClearEvent();
}
//////////////////////////////////////////////
void G4MCTEvent::Print(std::ostream& ostr) const
//////////////////////////////////////////////
{
ostr << "Event#:" << eventNumber << G4endl;
genEvent-> Print(ostr);
simEvent-> Print(ostr);
}
#endif
#endif
@@ -0,0 +1,101 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTGenEvent.cc
//
// ====================================================================
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "G4MCTGenEvent.hh"
#include "CLHEP/HepMC/GenParticle.h"
#include "CLHEP/HepMC/GenVertex.h"
// ====================================================================
//
// class description
//
// ====================================================================
//////////////////////////
G4MCTGenEvent::G4MCTGenEvent()
//////////////////////////
{
}
///////////////////////////
G4MCTGenEvent::~G4MCTGenEvent()
///////////////////////////
{
eventList.clear();
}
/////////////////////////////////////////////////////////////
int G4MCTGenEvent::AddGenEvent(const HepMC::GenEvent* genevent)
/////////////////////////////////////////////////////////////
{
eventList.push_back(const_cast<HepMC::GenEvent*>(genevent));
return eventList.size();
}
/////////////////////////////////////
int G4MCTGenEvent::GetNofEvents() const
/////////////////////////////////////
{
return eventList.size();
}
//////////////////////////////////////////////////////
const HepMC::GenEvent* G4MCTGenEvent::GetGenEvent(int i)
//////////////////////////////////////////////////////
{
int size= eventList.size();
if(i>=0 && i< size) return eventList[i];
else return 0;
}
//////////////////////////////
void G4MCTGenEvent::ClearEvent()
//////////////////////////////
{
eventList.clear();
}
////////////////////////////////////////////////////////////
void G4MCTGenEvent::Print(std::ostream& ostr) const
////////////////////////////////////////////////////////////
{
int nev= eventList.size();
for(int iev=0; iev<nev; iev++) {
eventList[iev]-> print(ostr);
}
}
#endif
#endif
@@ -0,0 +1,177 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimEvent.cc
//
// ====================================================================
#include "G4ios.hh"
#include "G4MCTSimEvent.hh"
#include "G4MCTSimParticle.hh"
#include "G4MCTSimVertex.hh"
// ====================================================================
//
// class description
//
// ====================================================================
//////////////////////////
G4MCTSimEvent::G4MCTSimEvent()
//////////////////////////
{
}
///////////////////////////
G4MCTSimEvent::~G4MCTSimEvent()
///////////////////////////
{
ClearEvent();
}
//////////////////////////////////////////////////////////////
G4bool G4MCTSimEvent::AddParticle(const G4MCTSimParticle* aparticle)
//////////////////////////////////////////////////////////////
{
G4MCTSimParticle* qpart= const_cast<G4MCTSimParticle*>(aparticle);
int trackID= aparticle-> GetTrackID();
int nc= particleMap.count(trackID);
if(nc==0) {
particleMap.insert(std::make_pair(trackID, qpart));
return true;
} else {
return false;
}
}
////////////////////////////////////////////////////////
G4MCTSimParticle* G4MCTSimEvent::FindParticle(int tid) const
////////////////////////////////////////////////////////
{
G4MCTSimParticleContainer::const_iterator pos= particleMap.find(tid);
if(pos != particleMap.end()) {
return pos-> second;
} else {
return 0;
}
}
///////////////////////////////////////////////////
G4MCTSimVertex* G4MCTSimEvent::GetVertex(int vid) const
///////////////////////////////////////////////////
{
int nv= vertexVec.size();
if(vid>=1 && vid<=nv) {
return vertexVec[vid-1];
} else {
return 0;
}
}
////////////////////////////////////////
void G4MCTSimEvent::BuildVertexContainer()
////////////////////////////////////////
{
G4MCTSimParticleContainer::iterator itr;
int vid=1;
for(itr= particleMap.begin(); itr!= particleMap.end(); ++itr) {
G4MCTSimVertex* vertex= itr->second-> GetVertex();
if(vertex) {
if (vertex-> GetID()<0) { // ID not yet assigned
vertex-> SetID(vid);
vid++;
if (vertex) vertexVec.push_back(vertex);
}
}
}
}
//////////////////////////////
void G4MCTSimEvent::ClearEvent()
//////////////////////////////
{
G4MCTSimParticleContainer::iterator itr;
for(itr= particleMap.begin(); itr!= particleMap.end(); ++itr) {
delete itr->second;
}
particleMap.clear();
G4MCTSimVertexContainer::iterator itrv;
for(itrv= vertexVec.begin(); itrv!= vertexVec.end(); ++itrv) {
delete (*itrv);
}
vertexVec.clear();
}
//////////////////////////////////////////////
int G4MCTSimEvent::GetNofStoredParticles() const
//////////////////////////////////////////////
{
int n=0;
G4MCTSimParticleContainer::const_iterator itr;
for(itr= particleMap.begin(); itr!= particleMap.end(); ++itr) {
if(itr-> second-> GetStoreFlag()) n++;
}
return n;
}
/////////////////////////////////////////////
int G4MCTSimEvent::GetNofStoredVertices() const
/////////////////////////////////////////////
{
int n=0;
G4MCTSimVertexContainer::const_iterator itr;
for(itr= vertexVec.begin(); itr!= vertexVec.end(); ++itr) {
if((*itr)->GetStoreFlag()) n++;
}
return n;
}
/////////////////////////////////////////////////
void G4MCTSimEvent::Print(std::ostream& ostr) const
/////////////////////////////////////////////////
{
ostr << "____________________________________________________"
"____________________________" << G4endl;
ostr << "SimEvent:" << G4endl << G4endl;
ostr << "Current Memory Usage: "
<< particleMap.size() << " particles, "
<< vertexVec.size() << " vertices."
<< G4endl;
ostr << "trk#<ptrk#: P(Px(GeV), Py, Pz, E ) @PDG %proc\n"
<< " vtx#- X( X(mm), Y, Z, T(ns)) @vname-#"
<< G4endl;
ostr << "____________________________________________________"
"____________________________" << G4endl;
G4MCTSimParticleContainer::const_iterator itr;
for(itr= particleMap.begin(); itr!= particleMap.end(); ++itr) {
itr-> second-> PrintSingle(ostr);
}
ostr << "____________________________________________________"
"____________________________" << G4endl;
}
@@ -0,0 +1,206 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimParticle.cc
//
// ====================================================================
#include "globals.hh"
#include <sstream>
#include <iomanip>
#include "G4ios.hh"
#include "G4MCTSimParticle.hh"
#include "G4MCTSimVertex.hh"
// ====================================================================
//
// class description
//
// ====================================================================
/////////////////////////////////
G4MCTSimParticle::G4MCTSimParticle()
: parentParticle(0),
trackID(0), parentTrackID(0),
primaryFlag(false),
vertex(0), storeFlag(false)
/////////////////////////////////
{
}
/////////////////////////////////////////////////////////////
G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode,
int atid, int ptid,
const G4LorentzVector& p)
: parentParticle(0),
name(aname), pdgID(apcode),
trackID(atid), parentTrackID(ptid),
primaryFlag(false),momentumAtVertex(p),
vertex(0), storeFlag(false)
///////////////////////////////////////////////////////////////
{
}
/////////////////////////////////////////////////////////////
G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode,
int atid, int ptid,
const G4LorentzVector& p,
const G4MCTSimVertex* v )
: parentParticle(0),
name(aname), pdgID(apcode),
trackID(atid), parentTrackID(ptid),
primaryFlag(false),momentumAtVertex(p),
vertex(const_cast<G4MCTSimVertex*>(v)), storeFlag(false)
///////////////////////////////////////////////////////////////
{
}
/////////////////////////////////
G4MCTSimParticle::~G4MCTSimParticle()
/////////////////////////////////
{
associatedParticleList.clear();
}
////////////////////////////////////////////////////////
int G4MCTSimParticle::AssociateParticle(G4MCTSimParticle* p)
////////////////////////////////////////////////////////
{
associatedParticleList.push_back(p);
p-> SetParentParticle(this);
return associatedParticleList.size();
}
/////////////////////////////////////////////////////
int G4MCTSimParticle::GetNofAssociatedParticles() const
/////////////////////////////////////////////////////
{
return associatedParticleList.size();
}
//////////////////////////////////////////////////////////////////
G4MCTSimParticle* G4MCTSimParticle::GetAssociatedParticle(int i) const
//////////////////////////////////////////////////////////////////
{
int size= associatedParticleList.size();
if(i>=0 && i< size) return associatedParticleList[i];
else return 0;
}
////////////////////////////////////////
int G4MCTSimParticle::GetTreeLevel() const
////////////////////////////////////////
{
const G4MCTSimParticle* p= this;
int nlevel;
for(nlevel=1;;nlevel++) {
p= p-> GetParentParticle();
if(p==0) return nlevel;
}
}
/////////////////////////////////////////////////////
void G4MCTSimParticle::SetStoreFlagToParentTree(G4bool q)
/////////////////////////////////////////////////////
{
storeFlag=q;
if(vertex) vertex-> SetStoreFlag(q);
if(primaryFlag) return;
if(parentParticle) parentParticle-> SetStoreFlagToParentTree(q);
}
//////////////////////////////////////////////////////////
void G4MCTSimParticle::PrintSingle(std::ostream& ostr) const
//////////////////////////////////////////////////////////
{
std::ostringstream os;
char cqp=' ';
if(storeFlag) cqp='+';
os << cqp << trackID << '\0';
std::string stid(os.str());
ostr << std::setw(6) << stid;
//ostr << std::setw(4) << trackID;
if(primaryFlag) ostr << "*";
else ostr << " ";
ostr << "<" << std::setw(5) << parentTrackID;
ostr.setf(std::ios::fixed);
ostr << ": P("
<< std::setw(7) << std::setprecision(3) << momentumAtVertex.x()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.y()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.z()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.e()/GeV << ") @";
ostr << name << "(" << pdgID << ")";
if(vertex) {
ostr << " %" << vertex-> GetCreatorProcessName() << G4endl;
std::ostringstream osv;
char cqv=' ';
if(vertex->GetStoreFlag()) cqv='+';
osv << cqv << vertex-> GetID() << '\0';
std::string svid(osv.str());
ostr << " " << std::setw(6) << svid;
//ostr << " " << std::setw(4) << vertex-> GetID();
ostr.unsetf(std::ios::fixed);
ostr.setf(std::ios::scientific|std::ios::right|std::ios::showpoint);
ostr << "- X(" << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().x()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().y()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().z()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetTime()/ns << ")";
ostr.unsetf(std::ios::scientific);
ostr << " @" << vertex-> GetVolumeName()
<< "-" << vertex-> GetVolumeNumber();
}
ostr << G4endl;
}
////////////////////////////////////////////////////////////////////
void G4MCTSimParticle::Print(std::ostream& ostr, G4bool qrevorder) const
////////////////////////////////////////////////////////////////////
{
PrintSingle(ostr);
// recursively print associated particles
if (!qrevorder) { // parent -> child
SimParticleList::const_iterator itr;
for(itr= associatedParticleList.begin();
itr!= associatedParticleList.end(); ++itr) {
(*itr)-> Print(ostr);
}
} else { // child -> parent
if(parentParticle) parentParticle-> Print(ostr, true);
}
}
@@ -0,0 +1,112 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4MCTSimVertex.cc
//
// ====================================================================
#include "globals.hh"
#include <sstream>
#include <iomanip>
#include "G4ios.hh"
#include "G4MCTSimParticle.hh"
#include "G4MCTSimVertex.hh"
// ====================================================================
//
// class description
//
// ====================================================================
/////////////////////////////////////
G4MCTSimVertex::G4MCTSimVertex()
: inParticleTrackID(0),id(-1),
volumeName(""), volumeNumber(-1),
creatorProcessName("none"),
storeFlag(false)
/////////////////////////////////////
{
}
/////////////////////////////////////////////////////////
G4MCTSimVertex::G4MCTSimVertex(const G4ThreeVector& x, double t)
: inParticleTrackID(0), id(-1), position(x), time(t),
volumeName(""), volumeNumber(-1),
creatorProcessName("none"), storeFlag(false)
/////////////////////////////////////////////////////////
{
}
///////////////////////////////////////////////////////////////
G4MCTSimVertex::G4MCTSimVertex(const G4ThreeVector& x, double t,
std::string vname, int ncopy, std::string pname)
: inParticleTrackID(0), id(-1), position(x), time(t),
volumeName(vname), volumeNumber(ncopy),
creatorProcessName(pname), storeFlag(false)
///////////////////////////////////////////////////////////////
{
}
/////////////////////////////
G4MCTSimVertex::~G4MCTSimVertex()
/////////////////////////////
{
outParticleTrackIDList.clear();
}
//////////////////////////////////////////////////
void G4MCTSimVertex::Print(std::ostream& ostr) const
//////////////////////////////////////////////////
{
std::ostringstream os;
char cq=' ';
if(storeFlag) cq='+';
os << cq << id << '\0';
std::string sid(os.str());
ostr.unsetf(std::ios::fixed);
ostr.setf(std::ios::scientific|std::ios::right|std::ios::showpoint);
//ostr << std::setw(4) << id;
ostr << std::setw(6) << sid;
ostr << " : X(" << std::setw(9) << std::setprecision(2)
<< position.x()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< position.y()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< position.z()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< time/ns << ")";
ostr.unsetf(std::ios::scientific);
ostr << "@" << volumeName
<< "-" << volumeNumber
<< "%" << creatorProcessName
<< G4endl;
ostr << " " << std::setw(4) << inParticleTrackID << "-> ";
size_t np= outParticleTrackIDList.size();
for (size_t i=0; i<np; i++) ostr << outParticleTrackIDList[i] << ", ";
ostr << G4endl;
}
@@ -0,0 +1,426 @@
//
// ********************************************************************
// * 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: G4PersistencyCenter.cc
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#include "G4PersistencyCenter.hh"
// Forward Declarations:
#include "G4PersistencyCenterMessenger.hh"
// Addtional Include:
#include "G4UImanager.hh"
#include "G4PersistencyManager.hh"
G4PersistencyCenter* G4PersistencyCenter::f_thePointer=G4PersistencyCenter::GetPersistencyCenter();
// Implementation of Constructor #1
G4PersistencyCenter::G4PersistencyCenter()
: m_verbose(0)
{
f_wrObj[0] = "HepMC";
f_wrObj[1] = "MCTruth";
f_wrObj[2] = "Hits";
f_wrObj[3] = "Digits";
f_rdObj[0] = "Hits";
f_rdObj[1] = "HitsBG";
ObjMap::iterator itr;
for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
f_writeFileName[(*itr).second] = "G4defaultOutput";
}
for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
f_readFileName[(*itr).second] = "G4defaultInput";
}
f_writeFileMode["HepMC"] = kRecycle;
f_writeFileMode["MCTruth"] = kOn;
f_writeFileMode["Hits"] = kOn;
f_writeFileMode["Digits"] = kOff;
f_readFileMode["Hits"] = false;
f_readFileMode["HitsBG"] = false;
f_theMessenger = new G4PersistencyCenterMessenger(this);
f_currentManager = new G4PersistencyManager(this, "Default");
}
// Implementation of Constructor #2
G4PersistencyCenter::G4PersistencyCenter(const G4PersistencyCenter&)
{}
// Implementation of Destructor #1
G4PersistencyCenter::~G4PersistencyCenter()
{
delete f_theMessenger;
delete f_currentManager;
}
// Implementation of GetPersistencyCenter
G4PersistencyCenter* G4PersistencyCenter::GetPersistencyCenter()
{
if ( f_thePointer == 0 ) f_thePointer = new G4PersistencyCenter;
return f_thePointer;
}
// Implementation of SelectSystem
void G4PersistencyCenter::SelectSystem(std::string systemName)
{
int st = 0;
if (f_currentManager!=0) delete f_currentManager;
G4PersistencyManager* pm = 0;
if (systemName=="None")
{
G4cout<<" G4PersistencyCenter: Default is selected."<< G4endl;
pm = new G4PersistencyManager(this, "Default");
}
else if (systemName=="ROOT")
{
G4cout<<" G4PersistencyCenter: \"ROOT\" Persistency Package is selected."
<<G4endl;
// G4UImanager *man=G4UImanager::GetUIpointer();
// std::string libs="Cint:Core:Tree:Rint:Matrix:Physics:fadsROOT";
// st = man->ApplyCommand("/load "+libs);
if ( st == 0 ) {
pm = GetPersistencyManager("ROOT");
}
}
else if (systemName=="ODBMS")
{
G4cout<<" G4PersistencyCenter: \"ODBMS\" package is selected."<<G4endl;
// G4UImanager *man=G4UImanager::GetUIpointer();
// std::string libs="fadsODBMS";
// st = man->ApplyCommand("/load "+libs);
if ( st == 0 ) {
pm = GetPersistencyManager("ODBMS");
}
}
if ( st == 0 ) {
f_currentManager = pm->Create();
if (f_currentManager!=0) f_currentManager->SetVerboseLevel(m_verbose);
f_currentSystemName = systemName;
}
}
// Implementation of SetHepMCObjyReaderFile
void G4PersistencyCenter::SetHepMCObjyReaderFile(std::string file)
{
if ( SetReadFile("HepMC", file) ) {
SetRetrieveMode("HepMC", true);
}
}
// Implementation of CurrentHepMCObjyReaderFile
std::string G4PersistencyCenter::CurrentHepMCObjyReaderFile()
{
if ( CurrentRetrieveMode("HepMC") ) {
return CurrentReadFile("HepMC");
} else {
return "";
}
}
// Implementation of SetStoreMode
void G4PersistencyCenter::SetStoreMode(std::string objName, StoreMode mode)
{
if ( (*(f_writeFileName.find(objName))).second != "" ) {
f_writeFileMode[objName] = mode;
} else {
G4cerr << "!! unknown object type " << objName << " for output."
<< G4endl;
}
}
// Implementation of SetRetrieveMode
void G4PersistencyCenter::SetRetrieveMode(std::string objName, G4bool mode)
{
if ( (*(f_readFileName.find(objName))).second != "" ) {
f_readFileMode[objName] = mode;
} else {
G4cerr << "!! unknown object type " << objName << " for input."
<< G4endl;
}
}
// Implementation of CurrentStoreMode
StoreMode G4PersistencyCenter::CurrentStoreMode(std::string objName)
{
if ( (*(f_writeFileName.find(objName))).second != "" ) {
return f_writeFileMode[objName];
} else {
return kOff;
}
}
// Implementation of CurrentRetrieveMode
G4bool G4PersistencyCenter::CurrentRetrieveMode(std::string objName)
{
if ( (*(f_readFileName.find(objName))).second != "" ) {
return f_readFileMode[objName];
} else {
return false;
}
}
// Implementation of SetWriteFile
G4bool G4PersistencyCenter::SetWriteFile(std::string objName, std::string writeFileName)
{
if ( (*(f_writeFileName.find(objName))).second != "" ) {
f_writeFileName[objName] = writeFileName;
} else {
G4cerr << "!! unknown object type " << objName << " for output."
<< G4endl;
return false;
}
return true;
}
// Implementation of SetReadFile
G4bool G4PersistencyCenter::SetReadFile(std::string objName, std::string readFileName)
{
#ifndef WIN32
if ( f_ut.FileExists(readFileName) )
{
f_readFileName[objName] = readFileName;
}
else
{
G4cerr << "!! File \"" << objName << "\" does not exist."
<< G4endl;
return false;
}
#endif
return true;
}
// Implementation of CurrentWriteFile
std::string G4PersistencyCenter::CurrentWriteFile(std::string objName)
{
if ( (*(f_writeFileName.find(objName))).second != "" ) {
return f_writeFileName[objName];
} else {
return "?????";
}
}
// Implementation of CurrentReadFile
std::string G4PersistencyCenter::CurrentReadFile(std::string objName)
{
if ( (*(f_readFileName.find(objName))).second != "" ) {
return f_readFileName[objName];
} else {
return "?????";
}
}
// Implementation of CurrentObject
std::string G4PersistencyCenter::CurrentObject(std::string file)
{
FileMap::iterator itr;
for ( itr = f_readFileName.begin(); itr != f_readFileName.end(); itr++ ) {
if ( file == (*itr).second ) return (*itr).first;
}
for ( itr = f_writeFileName.begin(); itr != f_writeFileName.end(); itr++ ) {
if ( file == (*itr).second ) return (*itr).first;
}
return "?????";
}
// Implementation of AddHCIOmanager
void G4PersistencyCenter::AddHCIOmanager(std::string detName, std::string colName)
{
G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog();
G4VHCIOentry* ioe = ioc->GetEntry(detName);
if ( ioe != 0 ) {
ioe->CreateHCIOmanager(detName, colName);
} else {
G4cerr << "Error! -- HCIO assignment failed for detector " << detName
<< ", collection " << colName << G4endl;
}
}
// Implementation of CurrentHCIOmanager
std::string G4PersistencyCenter::CurrentHCIOmanager()
{
G4HCIOcatalog* ioc = G4HCIOcatalog::GetHCIOcatalog();
return ioc->CurrentHCIOmanager();
}
// Implementation of AddDCIOmanager
void G4PersistencyCenter::AddDCIOmanager(std::string detName)
{
G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog();
std::string colName = "";
G4VDCIOentry* ioe = ioc->GetEntry(detName);
if ( ioe != 0 ) {
ioe->CreateDCIOmanager(detName, colName);
} else {
G4cerr << "Error! -- DCIO assignment failed for detector " << detName
<< ", collection " << colName << G4endl;
}
}
// Implementation of CurrentDCIOmanager
std::string G4PersistencyCenter::CurrentDCIOmanager()
{
G4DCIOcatalog* ioc = G4DCIOcatalog::GetDCIOcatalog();
return ioc->CurrentDCIOmanager();
}
// Implementation of PrintAll
void G4PersistencyCenter::PrintAll()
{
G4cout << "Persistency Package: " << CurrentSystem() << G4endl;
G4cout << G4endl;
ObjMap::iterator itr;
std::string name;
std::string file;
StoreMode mode;
G4cout << "Output object types and file names:" << G4endl;
for ( itr = f_wrObj.begin(); itr != f_wrObj.end(); itr++ ) {
name = (*itr).second;
// disabled HepMC and MCTruth for now
if ( name != "HepMC" && name != "MCTruth" ) {
G4cout << " Object: " << PadString(name, 9);
mode = CurrentStoreMode(name);
if ( mode == kOn ) {
G4cout << " <on> ";
} else if ( mode == kOff ) {
G4cout << " <off> ";
} else if ( mode == kRecycle ) {
G4cout << "<recycle>";
}
file = CurrentWriteFile(name);
if ( file == "" ) file = " <N/A>";
G4cout << " File: " << file << G4endl;
}
}
G4cout << G4endl;
G4cout << "Input object types and file names:" << G4endl;
for ( itr = f_rdObj.begin(); itr != f_rdObj.end(); itr++ ) {
name = (*itr).second;
// disabled HepMC and MCTruth for now
if ( name != "HepMC" && name != "MCTruth" ) {
G4cout << " Object: " << PadString(name, 9);
if ( CurrentRetrieveMode(name) ) {
G4cout << " <on> ";
} else {
G4cout << " <off> ";
}
file = CurrentReadFile(name);
if ( file == "" ) file = " <N/A>";
G4cout << " File: " << CurrentReadFile(name) << G4endl;
}
}
G4cout << G4endl;
G4HCIOcatalog* hioc = G4HCIOcatalog::GetHCIOcatalog();
if ( hioc != 0 ) {
G4cout << "Hit IO Managers:" << G4endl;
hioc->PrintEntries();
hioc->PrintHCIOmanager();
G4cout << G4endl;
} else {
G4cout << "Hit IO Manager catalog is not registered." << G4endl;
}
G4DCIOcatalog* dioc = G4DCIOcatalog::GetDCIOcatalog();
if ( dioc != 0 ) {
G4cout << "Digit IO Managers:" << G4endl;
dioc->PrintEntries();
dioc->PrintDCIOmanager();
G4cout << G4endl;
} else {
G4cout << "Digit IO Manager catalog is not registered." << G4endl;
}
}
// Implementation of SetPersistencyManager
void G4PersistencyCenter::SetPersistencyManager(G4PersistencyManager* pm,
std::string name)
{
f_currentManager=pm;
f_currentSystemName=name;
}
// Implementation of GetPersistencyManager
G4PersistencyManager* G4PersistencyCenter::GetPersistencyManager(std::string nam)
{
if (f_theCatalog.find(nam)!=f_theCatalog.end())
return f_theCatalog[nam];
return 0;
}
// Implementation of RegisterPersistencyManager
void G4PersistencyCenter::RegisterPersistencyManager(G4PersistencyManager* pm)
{
f_theCatalog[pm->GetName()]=pm;
}
// Implementation of DeletePersistencyManager
void G4PersistencyCenter::DeletePersistencyManager()
{
if (f_currentManager!=0) delete f_currentManager;
f_currentManager=0;
}
// Implementation of SetVerboseLevel
void G4PersistencyCenter::SetVerboseLevel(int v)
{
m_verbose = v;
if ( f_currentManager != 0 ) f_currentManager->SetVerboseLevel(m_verbose);
}
// Implementation of PadString
std::string G4PersistencyCenter::PadString(std::string name, unsigned int width)
{
if ( name.length() > width ) {
return name.substr(0,width-1) + "#";
} else {
std::string wname = name;
for ( unsigned int i=0; i < width-name.length(); i++) wname = wname + " ";
return wname;
}
}
// End of G4PersistencyCenter.cc
@@ -0,0 +1,278 @@
//
// ********************************************************************
// * 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: G4PersistencyCenterMessenger.cc
//
// History:
// 01.07.18 Youhei Morita Initial creation (with "fadsclass")
#include "G4PersistencyCenterMessenger.hh"
// Implementation of Constructor #1
G4PersistencyCenterMessenger::G4PersistencyCenterMessenger(G4PersistencyCenter* p)
: pc(p)
{
std::string name = "/persistency/";
directory=new G4UIdirectory(name.c_str());
directory->SetGuidance("Control commands for Persistency package");
std::string cmd = name + "verbose";
verboseCmd = new G4UIcmdWithAnInteger(cmd.c_str(),this);
verboseCmd->SetGuidance("Set the verbose level of G4PersistencyManager.");
verboseCmd->SetGuidance(" 0 : Silent (default)");
verboseCmd->SetGuidance(" 1 : Display main topics");
verboseCmd->SetGuidance(" 2 : Display event-level topics");
verboseCmd->SetGuidance(" 3 : Display debug information");
verboseCmd->SetParameterName("level",true);
verboseCmd->SetDefaultValue(0);
verboseCmd->SetRange("level >=0 && level <=3");
std::string vname = name + "select";
cmd = vname;
select = new G4UIcmdWithAString(cmd.c_str(),this);
select->SetGuidance("Selection of a persistency package");
select->SetParameterName("Persistency package name", true, true);
select->SetCandidates("ODBMS ROOT None");
vname = name + "store/";
subdir1 = new G4UIdirectory(vname.c_str());
subdir1->SetGuidance("Specifiy object types for store");
wrObj.push_back("HepMC");
wrObj.push_back("MCTruth");
wrObj.push_back("Hits");
std::string guidance;
int i;
for ( i = 0; i < 3; i++ )
{
cmd = vname + wrObj[i];
guidance = "Store " + wrObj[i] + " objects for output";
storeObj.push_back(new G4UIcmdWithAString(cmd.c_str(),this));
storeObj[i]->SetGuidance(guidance.c_str());
if ( wrObj[i] == "HepMC" ) {
storeObj[i]->SetCandidates("on off recycle");
} else {
storeObj[i]->SetCandidates("on off");
}
}
vname += "using/";
subdir2 = new G4UIdirectory(vname.c_str());
subdir2->SetGuidance("Select I/O manager for store");
cmd = vname + "hitIO";
regHitIO = new G4UIcmdWithAString(cmd.c_str(),this);
regHitIO->SetGuidance("Resiter Hits I/O Manager");
regHitIO->SetParameterName("Name of Hits I/O Manager", true, true);
vname = name + "set/";
subdir3 = new G4UIdirectory(vname.c_str());
subdir3->SetGuidance("Set various parameters");
vname += "writeFile/";
subdir4 = new G4UIdirectory(vname.c_str());
subdir4->SetGuidance("Set output file names for object types");
for ( i = 0; i < 3; i++ )
{
cmd = vname + wrObj[i];
guidance = "Set an output file name for " + wrObj[i] + ".";
setWrFile.push_back(new G4UIcmdWithAString(cmd.c_str(),this));
setWrFile[i]->SetGuidance(guidance.c_str());
setWrFile[i]->SetParameterName("file name", true, true);
}
vname = name + "set/ReadFile/";
subdir5 = new G4UIdirectory(vname.c_str());
subdir5->SetGuidance("Set input file names for object types");
rdObj.push_back("Hits");
cmd = vname + rdObj[0];
guidance = "Set an input file name for " + rdObj[0] + ".";
setRdFile.push_back(new G4UIcmdWithAString(cmd.c_str(),this));
setRdFile[0]->SetGuidance(guidance.c_str());
setRdFile[0]->SetParameterName("file name", true, true);
cmd = name + "printall";
printAll = new G4UIcmdWithoutParameter(cmd.c_str(),this);
printAll->SetGuidance("Print all parameters.");
}
// Implementation of Destructor #1
G4PersistencyCenterMessenger::~G4PersistencyCenterMessenger()
{
delete directory;
delete subdir1;
delete subdir2;
delete subdir3;
delete subdir4;
delete subdir5;
delete verboseCmd;
delete select;
delete regHitIO;
for ( int i = 0; i < 3; i++ )
{
delete storeObj[i];
delete setWrFile[i];
}
delete setRdFile[0];
delete printAll;
}
// Implementation of SetNewValue
void G4PersistencyCenterMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if (command==verboseCmd)
{
pc->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
}
else if (command==select)
{
pc->SelectSystem(newValues);
}
else if (command==regHitIO)
{
pc->AddHCIOmanager(PopWord(newValues,1," "),PopWord(newValues,2," "));
}
else if (command==setRdFile[0])
{
pc -> SetReadFile ( rdObj[0],newValues);
}
else if (command==printAll)
{
pc->PrintAll();
}
else
{
for( int i=0; i<3; i++ ) {
if( command==storeObj[i] )
{
StoreMode mode = kOff;
if( newValues == "on" ) {
mode = kOn;
} else if ( newValues == "off" ) {
mode = kOff;
} else if ( newValues == "recycle" ) {
mode = kRecycle;
} else {
G4cerr << "Unrecognized keyword - \"" << newValues << "\"."
<< G4endl;
}
pc->SetStoreMode(wrObj[i],mode);
break;
}
else if( command==setWrFile[i] )
{
pc->SetWriteFile(wrObj[i],newValues);
break;
}
}
}
}
// Implementation of GetCurrentValue
G4String G4PersistencyCenterMessenger::GetCurrentValue(G4UIcommand* command)
{
G4String s="Undefined";
if (command==select)
{
return pc->VerboseLevel();
}
else if (command==select)
{
return pc->CurrentSystem();
}
else if (command==regHitIO)
{
return pc->CurrentHCIOmanager();
}
else if (command==setRdFile[0])
{
return pc->CurrentReadFile(rdObj[0]);
}
else
{
for( int i=0; i<3; i++ ) {
if( command==storeObj[i] )
{
switch (pc->CurrentStoreMode(wrObj[i])) {
case kOn:
return "on";
break;
case kOff:
return "off";
break;
case kRecycle:
return "recycle";
break;
default:
return "?????";
break;
};
}
else if( command==setWrFile[i] )
{
return pc->CurrentWriteFile(wrObj[i]);
}
}
}
return s;
}
// Implementation of PopWord
std::string G4PersistencyCenterMessenger::PopWord(std::string text, int n, std::string delim)
{
if ( text.length() <= 0 ) return "";
int p = 0, p0 = 0;
int p1 = 0;
for ( int i = 0; i < n; i++ ) {
p1 = text.find_first_of(delim,p0+1);
while( p1 == p0+1 ) {
p0 = p1;
p1 = text.find_first_of(delim,p0+1);
}
p = p0;
if ( p1 < 0 ) {
if ( i+1 < n ) return "";
p1 = text.length();
break;
}
p0 = p1;
}
if (p > 0) p++;
return text.substr(p,p1-p);
}
// End of G4PersistencyCenterMessenger.cc
@@ -0,0 +1,433 @@
//
// ********************************************************************
// * 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: G4PersistencyManager.cc
//
// History:
// 01.07.17 Youhei Morita Initial creation (with "fadsclass")
#include "G4PersistencyManager.hh"
// Addtional Include:
#include <iomanip>
#include "G4PersistencyCenter.hh"
// Implementation of Constructor #1
G4PersistencyManager::G4PersistencyManager(G4PersistencyCenter* pc, std::string n)
: f_pc(pc), nameMgr(n), f_is_initialized(false)
{
m_verbose = f_pc->VerboseLevel();
// G4cout << "G4PersistencyManager is constructed with name \"" << nameMgr
// << "\", " << this << ", verbose = " << m_verbose << G4endl;
// f_GenCenter = GeneratorCenter::GetGeneratorCenter();
// f_MCTman = G4MCTManager::GetPointer();
}
// Implementation of Destructor #1
G4PersistencyManager::~G4PersistencyManager()
{}
// Implementation of GetPersistencyManager
G4PersistencyManager* G4PersistencyManager::GetPersistencyManager()
{
return G4PersistencyCenter::GetPersistencyCenter()->CurrentPersistencyManager();
}
// Implementation of SetVerboseLevel
void G4PersistencyManager::SetVerboseLevel(int v)
{
m_verbose = v;
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager[\"" << nameMgr << "\"," << this
<< "]: verbose level is set to " << m_verbose << "."
<< G4endl;
}
if ( EventIO() != 0 ) EventIO()->SetVerboseLevel(m_verbose);
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
if ( HepMCIO() != 0 ) HepMCIO()->SetVerboseLevel(m_verbose);
if ( MCTruthIO() != 0 ) MCTruthIO()->SetVerboseLevel(m_verbose);
#endif
#endif
if ( HitIO() != 0 ) HitIO()->SetVerboseLevel(m_verbose);
if ( DigitIO() != 0 ) DigitIO()->SetVerboseLevel(m_verbose);
if (TransactionManager() != 0) TransactionManager()->SetVerboseLevel(m_verbose);
size_t i;
G4HCIOcatalog* hcio = G4HCIOcatalog::GetHCIOcatalog();
if ( hcio != 0 ) {
hcio->SetVerboseLevel(m_verbose);
for ( i = 0; i < hcio->NumberOfHCIOmanager(); i++ ) {
hcio->GetHCIOmanager(i)->SetVerboseLevel(m_verbose);
}
}
G4DCIOcatalog* dcio = G4DCIOcatalog::GetDCIOcatalog();
if ( dcio != 0 ) {
dcio->SetVerboseLevel(m_verbose);
for ( i = 0; i < dcio->NumberOfDCIOmanager(); i++ ) {
dcio->GetDCIOmanager(i)->SetVerboseLevel(m_verbose);
}
}
}
// Implementation of Store
G4bool G4PersistencyManager::Store(const G4Event* evt)
{
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager::Store() is called for event# "
<< evt->GetEventID() << "." << G4endl;
}
if ( TransactionManager() == 0 ) return true;
G4bool is_store = f_pc->CurrentStoreMode("HepMC") != kOff ||
f_pc->CurrentStoreMode("MCTruth") != kOff ||
f_pc->CurrentStoreMode("Hits") != kOff ||
f_pc->CurrentStoreMode("Digits") != kOff;
if ( ! is_store ) return true;
// Call package dependent Initialize()
//
if ( ! f_is_initialized ) {
f_is_initialized = true;
if ( m_verbose > 1 ) {
G4cout << "G4PersistencyManager:: Initializing Transaction ... "
<< G4endl;
}
Initialize();
}
G4bool st1 = true, st2 = true;
// Start event IO transaction
//
if ( TransactionManager()->StartUpdate() ) {
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager: Update transaction started for event#"
<< evt->GetEventID() << "." << G4endl;
}
} else {
G4cerr << "TransactionManager::Store(G4Event) - StartUpdate() failed."
<< G4endl;
return false;
}
std::string file;
std::string obj;
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
G4bool sthep = true, stmct = true, st3 = true;
// Store HepMC event
//
obj = "HepMC";
HepMC::GenEvent* hepevt = 0;
if ( f_pc->CurrentStoreMode(obj) == kOn ) {
// Note: This part of code will not be activated until a method
// to obtain the current pointer of HepMC::GenEvent* become available.
// if ( (hepevt = f_GenCenter->GetGenEvent()) !=0 ) {
if ( hepevt !=0 ) {
file = f_pc->CurrentWriteFile(obj);
if ( TransactionManager()->SelectWriteFile(obj, file) ) {
sthep = HepMCIO()->Store(hepevt);
if ( sthep && m_verbose > 1 ) {
G4cout << " -- File : " << file << " -- Event# "
<< evt->GetEventID() << " -- HepMC Stored." << G4endl;
}
} else {
sthep = false;
}
} // end of if ( hepevt != 0 )
} else { // recycle or off
// hepevt= f_GenCenter-> GetGenEvent();
}
// Store MCTruth event
//
obj = "MCTruth";
G4MCTEvent* mctevt = 0;
if ( f_pc->CurrentStoreMode(obj) == kOn ) {
// Note: This part of code will not be activated until a method
// to obtain the current pointer of G4MCTEvent* become available.
// if ( (mctevt = f_MCTman->GetCurrentEvent()) != 0 ) {
if ( mctevt != 0 ) {
file = f_pc->CurrentWriteFile(obj);
if ( TransactionManager()->SelectWriteFile(obj, file) ) {
stmct = MCTruthIO()->Store(mctevt);
if ( stmct && m_verbose > 1 ) {
G4cout << " -- File : " << file << " -- Event# "
<< evt->GetEventID() << " -- G4MCTEvent Stored." << G4endl;
}
} else {
stmct = false;
}
} // end of if ( mctevt != 0 )
}
#endif
#endif
// Store hits collection
//
obj = "Hits";
if ( f_pc->CurrentStoreMode(obj) == kOn ) {
if ( G4HCofThisEvent* hc = evt->GetHCofThisEvent() ) {
file = f_pc->CurrentWriteFile(obj);
if ( TransactionManager()->SelectWriteFile(obj, file) ) {
st1 = HitIO()->Store(hc);
if ( st1 && m_verbose > 1 ) {
G4cout << " -- File : " << file << " -- Event# "
<< evt->GetEventID()
<< " -- Hit Collections Stored." << G4endl;
}
} else {
st1 = false;
}
}
}
// Store digits collection
//
obj = "Digits";
if ( f_pc->CurrentStoreMode(obj) == kOn ) {
if ( G4DCofThisEvent* dc = evt->GetDCofThisEvent() ) {
file = f_pc->CurrentWriteFile(obj);
if ( TransactionManager()->SelectWriteFile(obj, file) ) {
st2 = DigitIO()->Store(dc);
if ( st2 && m_verbose > 1 ) {
G4cout << " -- File : " << file << " -- Event# "
<< evt->GetEventID()
<< " -- Digit Collections Stored." << G4endl;
}
} else {
st2 = false;
}
}
}
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
// Store this G4EVENT
//
if ( hepevt!=0 || mctevt!=0 || evt!=0 ) {
obj = "Hits";
file = f_pc->CurrentWriteFile(obj);
if ( TransactionManager()->SelectWriteFile(obj, file) ) {
// st3 = EventIO()->Store(hepevt, mctevt, evt);
st3 = EventIO()->Store(hepevt, evt);
if ( st3 && m_verbose > 1 ) {
G4cout << " -- File name: " << f_pc->CurrentWriteFile("Hits")
<< " -- Event# " << evt->GetEventID()
<< " -- G4Pevent is Stored." << G4endl;
}
} else {
st3 = false;
}
}
G4bool st = sthep && stmct && st1 && st2 && st3;
#else
G4bool st = st1 && st2;
#endif
#else
G4bool st = st1 && st2;
#endif
if ( st ) {
TransactionManager()->Commit();
if ( m_verbose > 0 )
G4cout << "G4PersistencyManager: event# "
<< evt->GetEventID() << " is stored." << G4endl;
} else {
G4cerr << "G4PersistencyManager::Store(G4Event) - Transaction aborted."
<< G4endl;
TransactionManager()->Abort();
}
return st;
}
// Implementation of Retrieve
G4bool G4PersistencyManager::Retrieve(G4Event*& evt)
{
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager::Retrieve(G4Event*&) is called."
<< G4endl;
}
if ( TransactionManager() == 0 ) return true;
if ( f_pc->CurrentRetrieveMode("HepMC") == false &&
f_pc->CurrentRetrieveMode("MCTruth") == false &&
f_pc->CurrentRetrieveMode("Hits") == false &&
f_pc->CurrentRetrieveMode("Digits") == false ) {
return true;
}
// Call package dependent Initialize()
//
if ( ! f_is_initialized ) {
f_is_initialized = true;
if ( m_verbose > 1 ) {
G4cout << "G4PersistencyManager:: Initializing Transaction ... "
<< G4endl;
}
Initialize();
}
// Start event IO transaction
//
if ( TransactionManager()->StartRead() ) {
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager: Read transaction started."
<< G4endl;
}
} else {
G4cerr << "TransactionManager::Retrieve(G4Event) - StartRead() failed."
<< G4endl;
return false;
}
G4bool st = false;
std::string file;
// Retrieve a G4EVENT
//
std::string obj = "Hits";
if ( f_pc->CurrentRetrieveMode(obj) == true ) {
file = f_pc->CurrentReadFile(obj);
if ( TransactionManager()->SelectReadFile(obj, file) ) {
st = EventIO()->Retrieve(evt);
if ( st && m_verbose > 1 ) {
G4cout << " -- File : " << file << " -- Event# "
<< evt->GetEventID()
<< " -- G4Event is Retrieved." << G4endl;
}
} else {
st = false;
}
}
if ( st ) {
TransactionManager()->Commit();
} else {
G4cerr << "G4PersistencyManager::Retrieve() - Transaction aborted."
<< G4endl;
TransactionManager()->Abort();
}
return st;
}
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
// Implementation of Retrieve
G4bool G4PersistencyManager::Retrieve(HepMC::GenEvent*& evt, int id)
{
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager::Retrieve(HepMC::GenEvent*&) is called."
<< G4endl;
}
if ( TransactionManager() == 0 ) return true;
// Call package dependent Initialize()
//
if ( ! f_is_initialized ) {
f_is_initialized = true;
if ( m_verbose > 1 ) {
G4cout << "G4PersistencyManager:: Initializing Transaction ... "
<< G4endl;
}
Initialize();
}
// Start event IO transaction
//
if ( TransactionManager()->StartRead() ) {
if ( m_verbose > 2 ) {
G4cout << "G4PersistencyManager: Read transaction started."
<< G4endl;
}
} else {
G4cerr << "TransactionManager::Retrieve(HepMC) - StartRead() failed."
<< G4endl;
return false;
}
G4bool st = false;
std::string file;
// Retrieve a HepMC GenEvent
//
std::string obj = "HepMC";
if ( f_pc->CurrentRetrieveMode(obj) == true ) {
file = f_pc->CurrentReadFile(obj);
if ( TransactionManager()->SelectReadFile(obj, file) ) {
st = HepMCIO()->Retrieve(evt, id);
if ( st && m_verbose > 1 ) {
G4cout << " -- File: " << file
<< " - Event# " << HepMCIO()->LastEventID()
<< " - HepMC event is Retrieved." << G4endl;
}
} else {
st = false;
}
}
if ( st ) {
TransactionManager()->Commit();
} else {
G4cerr << "G4PersistencyManager::Retrieve(HepMC) - Transaction aborted."
<< G4endl;
TransactionManager()->Abort();
}
return st;
}
#endif
#endif
// End of G4PersistencyManager.cc
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * 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: G4Pevent.cc
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "G4Pevent.hh"
//G4Pevent::G4Pevent( HepMC::GenEvent* hepevt, G4MCTEvent* mctevt, G4Event* g4evt )
// : f_hepevt(hepevt), genEventID(-1), f_mctevt(mctevt), f_g4evt(g4evt)
G4Pevent::G4Pevent( HepMC::GenEvent* hepevt, G4Event* g4evt )
: f_hepevt(hepevt), genEventID(-1), f_g4evt(g4evt)
{
m_id = g4evt->GetEventID();
if (hepevt) genEventID= hepevt->event_number();
}
G4Pevent::~G4Pevent()
{
delete f_g4evt;
}
#endif
#endif
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * 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: G4VDCIOentry.cc
//
// History:
// '01.09.12 Youhei Morita Initial creation
#include "G4VDCIOentry.hh"
// Addtional Include:
#include "G4DCIOcatalog.hh"
// Implementation of Constructor #1
G4VDCIOentry::G4VDCIOentry(std::string n)
: m_name(n)
{
G4DCIOcatalog* c = G4DCIOcatalog::GetDCIOcatalog();
c->RegisterEntry(this);
m_verbose = G4PersistencyCenter::GetPersistencyCenter()->VerboseLevel();
}
// End of G4VDCIOentry.cc
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * 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: G4VHCIOentry.cc
//
// History:
// '01.09.12 Youhei Morita Initial creation
#include "G4VHCIOentry.hh"
// Addtional Include:
#include "G4HCIOcatalog.hh"
// Implementation of Constructor #1
G4VHCIOentry::G4VHCIOentry(std::string n)
: m_name(n)
{
G4HCIOcatalog* c = G4HCIOcatalog::GetHCIOcatalog();
c->RegisterEntry(this);
m_verbose = G4PersistencyCenter::GetPersistencyCenter()->VerboseLevel();
}
// End of G4VHCIOentry.cc
@@ -0,0 +1,44 @@
//
// ********************************************************************
// * 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: G4VHepMCIO.cc
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "G4VHepMCIO.hh"
// Implementation of Constructor #1
G4VHepMCIO::G4VHepMCIO()
: m_verbose(0)
{}
// End of G4VHepMCIO.cc
#endif
#endif
@@ -0,0 +1,42 @@
//
// ********************************************************************
// * 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: G4VMCTruthIO.cc
//
// History:
// '01.11.18 Youhei Morita Initial creation
#ifndef WIN32
#ifdef G4LIB_USE_HEPMC
#include "G4VMCTruthIO.hh"
// Implementation of Constructor #1
G4VMCTruthIO::G4VMCTruthIO()
: m_verbose(0)
{}
#endif
#endif
@@ -0,0 +1,55 @@
//
// ********************************************************************
// * 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: G4VPDigitIO.cc
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#include "G4VPDigitIO.hh"
G4VPDigitIO* G4VPDigitIO::f_G4VPDigitIO = 0;
// Implementation of Constructor #1
G4VPDigitIO::G4VPDigitIO()
: m_verbose(0)
{
f_catalog = G4DCIOcatalog::GetDCIOcatalog();
}
// Implementation of SetVerboseLevel
void G4VPDigitIO::SetVerboseLevel(int v)
{
m_verbose = v;
// Loop through the registered Digit I/O managers
for ( size_t i=0; i < f_catalog->NumberOfDCIOmanager(); i++ ) {
G4VPDigitsCollectionIO* digitIOman = f_catalog->GetDCIOmanager(i);
digitIOman->SetVerboseLevel(v);
}
}
// End of G4VPDigitIO.cc
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * 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: G4VPDigitsCollectionIO.cc
//
// History:
// '01.08.16 Youhei Morita Initial creation
#include "G4VPDigitsCollectionIO.hh"
// Implementation of Constructor #1
G4VPDigitsCollectionIO::G4VPDigitsCollectionIO( std::string detName,
std::string colName )
: m_verbose(0), f_detName(detName), f_colName(colName)
{}
// Implementation of operator==
G4bool G4VPDigitsCollectionIO::operator== (const G4VPDigitsCollectionIO& right) const
{
return ( (f_detName == right.f_detName) &&
(f_colName == right.f_colName) );
}
// End of G4VPDigitsCollectionIO.cc
@@ -0,0 +1,39 @@
//
// ********************************************************************
// * 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: G4VPEventIO.cc
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#include "G4VPEventIO.hh"
// Implementation of Default Constructor
G4VPEventIO::G4VPEventIO()
: m_verbose(0), m_currentEvtID(0)
{
}
// End of G4VPEventIO.cc
@@ -0,0 +1,55 @@
//
// ********************************************************************
// * 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: G4VPHitIO.cc
//
// History:
// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
#include "G4VPHitIO.hh"
G4VPHitIO* G4VPHitIO::f_G4VPHitIO = 0;
// Implementation of Constructor #1
G4VPHitIO::G4VPHitIO()
: m_verbose(0)
{
f_catalog = G4HCIOcatalog::GetHCIOcatalog();
}
// Implementation of SetVerboseLevel
void G4VPHitIO::SetVerboseLevel(int v)
{
m_verbose = v;
// Loop through the registered Hit I/O managers
for ( size_t i=0; i < f_catalog->NumberOfHCIOmanager(); i++ ) {
G4VPHitsCollectionIO* hitIOman = f_catalog->GetHCIOmanager(i);
hitIOman->SetVerboseLevel(v);
}
}
// End of G4VPHitIO.cc
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * 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: G4VPHitsCollectionIO.cc
//
// History:
// '01.08.16 Youhei Morita Initial creation
#include "G4VPHitsCollectionIO.hh"
// Implementation of Constructor #1
G4VPHitsCollectionIO::G4VPHitsCollectionIO( std::string detName,
std::string colName )
: m_verbose(0), f_detName(detName), f_colName(colName)
{}
// Implementation of operator==
G4bool G4VPHitsCollectionIO::operator== (const G4VPHitsCollectionIO& right) const
{
return ( (f_detName == right.f_detName) &&
(f_colName == right.f_colName) );
}
// End of G4VPHitsCollectionIO.cc