Skip to content
Snippets Groups Projects
Commit cd0c75de authored by JeremyMcCormick's avatar JeremyMcCormick
Browse files

add LCIO compatibility preprocessor macros

parent 8053420f
No related branches found
No related tags found
No related merge requests found
......@@ -102,6 +102,28 @@ ELSE()
# include directories
INCLUDE_DIRECTORIES( ${XERCES_INCLUDE_DIR} ${LCIO_INCLUDE_DIRS} ${Geant4_INCLUDE_DIRS} ${GDML_INCLUDE_DIR} ${LCDD_INCLUDE_DIR} ${HEPPDT_INCLUDE_DIR} )
# check for LCStdHepRdrNew class in LCIO
IF ( EXISTS "${LCIO_INCLUDE_DIRS}/UTIL/LCStdHepRdrNew.h" )
ADD_DEFINITIONS( -DHAVE_STDHEPRDRNEW_H )
ENDIF()
# check if MCParticle implementation has endpoint momentum
SET( CMAKE_REQUIRED_INCLUDES ${LCIO_INCLUDE_DIRS} )
INCLUDE(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES(
"
#include \"EVENT/MCParticle.h\"
int main() {
EVENT::MCParticle* p;
p->getMomentumAtEndpoint();
return 0;
}
" MCPARTICLE_HAS_MOMENTUMATENDPOINT
)
IF ( MCPARTICLE_HAS_MOMENTUMATENDPOINT )
ADD_DEFINITIONS( -DMCPARTICLE_HAS_MOMENTUMATENDPOINT )
ENDIF()
# libraries
TARGET_LINK_LIBRARIES( slic ${XERCES_LIBRARY} ${Geant4_LIBRARIES} ${GDML_LIBRARY} ${LCDD_LIBRARY} ${HEPPDT_LIBRARIES} ${LCIO_LIBRARIES} slicPlugins )
......
......@@ -5,7 +5,11 @@
#include "MCParticleManager.hh"
// LCIO
#if HAVE_LCSTDHEPRDRNEW_H
#include "UTIL/LCStdHepRdrNew.h"
#else
#include "UTIL/LCStdHepRdr.h"
#endif
#include "EVENT/MCParticle.h"
#include "IMPL/LCCollectionVec.h"
......@@ -16,7 +20,12 @@
// STL
#include <set>
#if HAVE_LCSTDHEPRDRNEW_H
using UTIL::LCStdHepRdrNew;
#else
using UTIL::LCStdHepRdr;
#endif
using EVENT::MCParticle;
using EVENT::LCCollection;
using IMPL::LCCollectionVec;
......@@ -60,7 +69,11 @@ public:
LCCollectionVec* getCurrentParticleCollection();
private:
#if HAVE_LCSTDHEPRDRNEW_H
LCStdHepRdrNew* _reader;
#else
LCStdHepRdr* _reader;
#endif
LCCollectionVec* _particles;
};
......
......@@ -9,7 +9,6 @@
// Geant4
#include "G4SystemOfUnits.hh"
using UTIL::LCStdHepRdrNew;
using EVENT::MCParticle;
using EVENT::LCCollection;
using IMPL::MCParticleImpl;
......@@ -18,7 +17,11 @@ namespace slic {
StdHepGenerator::StdHepGenerator(G4String eventFile)
: _particles(0) {
#if HAVE_LCSTDHEPRDRNEW_H
_reader = new LCStdHepRdrNew(eventFile.data());
#else
_reader = new LCStdHepRdr(eventFile.data());
#endif
}
StdHepGenerator::~StdHepGenerator() {
......
......@@ -227,11 +227,13 @@ void TrackSummary::buildMCParticle() {
_mcparticle->setTime(_globalTime);
/* Set momentum at endpoint. */
#ifdef MCPARTICLE_HAS_MOMENTUMATENDPOINT
float momentumAtEndpoint[3];
momentumAtEndpoint[0] = _momentumAtEndpoint(0) / GeV;
momentumAtEndpoint[1] = _momentumAtEndpoint(1) / GeV;
momentumAtEndpoint[2] = _momentumAtEndpoint(2) / GeV;
_mcparticle->setMomentumAtEndpoint(momentumAtEndpoint);
#endif
/* Set up to date. */
_mcParticleIsUpToDate = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment