Skip to content
Snippets Groups Projects
Commit 576e6f23 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

Revert "Merge branch 'master' into 'master'"

This reverts merge request !2
parent 6726833a
No related branches found
No related tags found
No related merge requests found
gaudi_subdir(Event v0r0)
# Declare PODIO dependency
find_package(podio REQUIRED HINTS $ENV{PODIO})
## Make sure the library is found.
## Not the case if LD_LIBRARY_PATH is wrong
find_library(PODIOLIB podio PATHS ${podio_DIR}/../lib)
if (NOT PODIOLIB)
message(FATAL_ERROR "libpodio.so(dylib) cannot be found dynamically. Make sure you have set up your environment to use PODIO")
endif()
link_directories(${podio_LIBRARY_DIR})
execute_process(COMMAND python ${podio_CMAKE_DIR}/../python/podio_class_generator.py Event/plcio.yaml Event Event
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
include_directories(
${podio_INCLUDE_DIRS}
)
# Declare ROOT dependency
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(ROOT REQUIRED COMPONENTS RIO Tree)
include_directories(${ROOT_INCLUDE_DIR})
include(${ROOT_USE_FILE})
# Settings
file(GLOB sources src/*.cc)
file(GLOB headers Event/*.h)
include_directories(Event)
# Dictionary and Modules
add_library(Event SHARED ${sources} ${headers})
target_link_libraries(Event podio)
install(TARGETS Event DESTINATION lib)
REFLEX_GENERATE_DICTIONARY(Event ${headers} SELECTION src/selection.xml)
add_library(EventDict SHARED Event.cxx)
add_dependencies(EventDict Event-dictgen)
target_link_libraries(EventDict Event ROOT::Core)
install(TARGETS EventDict DESTINATION lib)
# Headers and Libraries
gaudi_install_headers(Event)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EventDict.rootmap DESTINATION lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Event_rdict.pcm DESTINATION lib)
# tests
add_executable( write tests/write.cpp )
target_link_libraries( write EventDict )
install(TARGETS write DESTINATION tests)
add_test(NAME write COMMAND write)
set_property(TEST write PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:$ENV{LD_LIBRARY_PATH})
add_executable( read tests/read.cpp )
target_link_libraries( read EventDict )
install(TARGETS read DESTINATION tests)
add_test(NAME read COMMAND read)
set_property(TEST read PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:$ENV{LD_LIBRARY_PATH})
set_property(TEST read PROPERTY DEPENDS write)
This diff is collapsed.
#include "EventHeaderCollection.h"
#include "MCParticleCollection.h"
#include "podio/EventStore.h"
#include "podio/ROOTReader.h"
int main(int argc, char* argv[])
{
auto reader = podio::ROOTReader();
auto store = podio::EventStore();
reader.openFile("test.root");
store.setReader(&reader);
unsigned int nEvt = reader.getEntries();
for (unsigned int i = 0; i < nEvt; ++i ) {
//if ( i%10 == 0 ) {
// std::cout << "processing event " << i << std::endl;
//}
auto& hds = store.get<plcio::EventHeaderCollection>("EvtHeaders");
if ( hds.isValid() ) {
auto header = hds[0];
std::cout << "processing event " << header.getEventNumber() << std::endl;
}
else {
return -1;
}
auto& mcc = store.get<plcio::MCParticleCollection>("MCParticles");
if ( ! mcc.isValid() ) {
return -1;
}
for ( auto p : mcc ) {
std::cout << " particle " << p.getObjectID().index << " has daughters: ";
for ( auto it = p.daughters_begin(), end = p.daughters_end(); it != end; ++it ) {
std::cout << " " << it->getObjectID().index;
}
std::cout << " and parents: ";
for ( auto it = p.parents_begin(), end = p.parents_end(); it != end ; ++it ){
std::cout << " " << it->getObjectID().index;
}
std::cout << std::endl;
}
store.clear();
reader.endOfEvent();
}
reader.closeFile();
return 0;
}
#include "EventHeaderCollection.h"
#include "MCParticleCollection.h"
#include "podio/EventStore.h"
#include "podio/ROOTWriter.h"
#include <vector>
#include <iostream>
int main(int argc, char* argv[])
{
//std::cout << "start writing test" << std::endl;
auto store = podio::EventStore();
auto writer = podio::ROOTWriter("test.root", &store);
auto& ehc = store.create<plcio::EventHeaderCollection>("EvtHeaders");
auto& mcc = store.create<plcio::MCParticleCollection>("MCParticles");
writer.registerForWrite("EvtHeaders");
writer.registerForWrite("MCParticles");
const unsigned int nEvt = 100;
for ( unsigned int i = 0; i < nEvt; ++i ) {
//if ( i%10 == 0 ) {
std::cout << "processing event " << i << std::endl;
//}
auto header = plcio::EventHeader(i, -99, 9999, "SimDet");
ehc.push_back(header);
for ( unsigned int i = 0; i < 10; ++i ) {
mcc.create();
}
for ( unsigned int i = 0; i < 4; ++i ) {
auto p = mcc[i];
for ( unsigned int j = 0; j < 4; ++j ) {
unsigned int idx = (2+j) + (i/2)*4;
p.addDaughter( mcc[idx] );
mcc[idx].addParent( p );
}
}
for ( auto p : mcc ) {
std::cout << " particle " << p.getObjectID().index << " has daughters: ";
for ( auto it = p.daughters_begin(), end = p.daughters_end(); it != end; ++it ) {
std::cout << " " << it->getObjectID().index;
}
std::cout << " and parents: ";
for ( auto it = p.parents_begin(), end = p.parents_end(); it != end ; ++it ){
std::cout << " " << it->getObjectID().index;
}
std::cout << std::endl;
}
//////////
writer.writeEvent();
store.clearCollections();
}
writer.finish();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment