-
Markus Frank authored5e714969
Geant4InputAction.cpp 6.00 KiB
// $Id$
//==========================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// @author P.Kostka (main author)
// @author M.Frank (code reshuffeling into new DDG4 scheme)
//
//====================================================================
// Framework include files
#include "DD4hep/Plugins.h"
#include "DDG4/Geant4Primary.h"
#include "DDG4/Geant4Context.h"
#include "DDG4/Geant4InputAction.h"
#include "G4Event.hh"
using namespace std;
using namespace DD4hep::Simulation;
typedef DD4hep::ReferenceBitMask<int> PropertyMask;
/// Initializing constructor
Geant4EventReader::Geant4EventReader(const std::string& nam)
: m_name(nam), m_directAccess(false), m_currEvent(0)
{
}
/// Default destructor
Geant4EventReader::~Geant4EventReader() {
}
/// Skip event. To be implemented for sequential sources
Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() {
if ( hasDirectAccess() ) {
++m_currEvent;
return EVENT_READER_OK;
}
std::vector<Particle*> particles;
++m_currEvent;
EventReaderStatus sc = readParticles(m_currEvent,particles);
for_each(particles.begin(),particles.end(),deleteObject<Particle>);
return sc;
}
/// Move to the indicated event number.
Geant4EventReader::EventReaderStatus
Geant4EventReader::moveToEvent(int event_number) {
if ( event_number >= INT_MIN ) {
return EVENT_READER_OK; // Logic below does not work as expected.
} // This shortcuts it!
if ( m_currEvent == event_number ) {
return EVENT_READER_OK;
}
else if ( hasDirectAccess() ) {
m_currEvent = event_number;
return EVENT_READER_OK;
}
else if ( event_number<m_currEvent ) {
return EVENT_READER_ERROR;
}
else {
for(int i=m_currEvent; i<event_number;++i)
skipEvent();
m_currEvent = event_number;