Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podio::DataSource #309

Merged
merged 32 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b6d1734
Integrating EDM4hep RDataSource
kjvbrt Aug 3, 2023
264899a
Add legacy reader
kjvbrt Aug 7, 2023
93fd3ac
Split off legacy reader
kjvbrt Aug 7, 2023
a2172d0
Protecting collection retrieval by mutex
kjvbrt Aug 8, 2023
58292c8
Add source test
kjvbrt Aug 14, 2023
96600f5
Updated man pages
kjvbrt Aug 15, 2023
33a357f
Renaming Source na DataSource
kjvbrt Aug 15, 2023
ca7e91e
Adding source test for run stages
kjvbrt Oct 3, 2023
ccd3671
Add tests for the standalone mode
kjvbrt Oct 12, 2023
da73dbb
Adding test files per process for histmaker
kjvbrt Oct 26, 2023
616a827
Adding selector by size and sorter by pT
kjvbrt Nov 15, 2023
2187e48
Few more analyzers
kjvbrt Nov 16, 2023
a61b6cf
Putting back things omitted from run_analysis.py
kjvbrt Jan 25, 2024
1530e5e
Adding e4hsource in LD_LIBRARY_PATH for managed tests
kjvbrt Jan 25, 2024
285a170
Making building of the source optional
kjvbrt Mar 1, 2024
e1aa165
Removed legacy support
kjvbrt Mar 1, 2024
9d74103
Separated analyzers using Collections into independent headers
kjvbrt Mar 4, 2024
258813c
Reimplementing analyzers needed for the stage1 of the example analysis
kjvbrt Mar 8, 2024
311379b
Adjusitng test input files
kjvbrt Mar 8, 2024
27dcbbd
Moving recoParticle definition
kjvbrt May 3, 2024
97db64b
Changes to use podio::ROOTDataSource
kjvbrt May 6, 2024
b1b76c3
using podio::DataSource
kjvbrt Aug 28, 2024
ce2981f
Adjusting stages source example
kjvbrt Sep 18, 2024
005ac4e
Adding C++ analysis tests
kjvbrt Sep 19, 2024
53f3402
Updating examples
kjvbrt Sep 20, 2024
7bd35ce
Formatting
kjvbrt Sep 20, 2024
d1aad33
Removing e4hsource
kjvbrt Sep 20, 2024
c2aa199
Adjust clang-format check
kjvbrt Sep 20, 2024
eb6dffe
Formatting
kjvbrt Sep 20, 2024
026ff54
Using PodioSource namespace
kjvbrt Oct 1, 2024
c0eb383
Adding .cache to .gitignore
kjvbrt Oct 1, 2024
26240f1
Formatting
kjvbrt Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Split off legacy reader
  • Loading branch information
kjvbrt committed Oct 1, 2024
commit 93fd3ac01e04ba82f5eca61e5f02e810e5448586
30 changes: 30 additions & 0 deletions e4hsource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,33 @@ install(FILES "${PROJECT_BINARY_DIR}/e4hsource/libe4hsource.rootmap"
install(FILES "${PROJECT_BINARY_DIR}/e4hsource/libe4hsource_rdict.pcm"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)


# Legacy
add_library(e4hlegacysource SHARED src/EDM4hepLegacySource.cxx)
target_include_directories(e4hlegacysource PUBLIC include)
target_link_libraries(e4hlegacysource PUBLIC ROOT::RIO
ROOT::ROOTDataFrame
podio::podioRootIO
EDM4HEP::edm4hep
EDM4HEP::edm4hepDict
)

ROOT_GENERATE_DICTIONARY(G__FCCAnalyses_EDM4hepLegacySource
include/EDM4hepSource/EDM4hepLegacySource.hxx
MODULE e4hlegacysource
LINKDEF include/EDM4hepSource/Legacy_LinkDef.h
)

install(TARGETS e4hlegacysource
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(FILES "${PROJECT_BINARY_DIR}/e4hsource/libe4hlegacysource.rootmap"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

install(FILES "${PROJECT_BINARY_DIR}/e4hsource/libe4hlegacysource_rdict.pcm"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
107 changes: 107 additions & 0 deletions e4hsource/include/EDM4hepSource/EDM4hepLegacySource.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#ifndef EDM4HEP_LEGACY_SOURCE_H__
#define EDM4HEP_LEGACY_SOURCE_H__

// STL
#include <vector>
#include <string>
#include <functional>
#include <shared_mutex>

// ROOT
#include <ROOT/RDataFrame.hxx>
#include <ROOT/RDataSource.hxx>

// Podio
#include <podio/Frame.h>
#include <podio/ROOTLegacyReader.h>
#include <podio/CollectionBase.h>

bool loadEDM4hepLegacySource();

namespace FCCAnalyses {
using Record_t = std::vector<void*>;

class EDM4hepLegacySource final : public ROOT::RDF::RDataSource {
public:
EDM4hepLegacySource(const std::string& filePath, int nEvents = -1);
EDM4hepLegacySource(const std::vector<std::string>& filePathList,
int nEvents = -1);

void SetNSlots(unsigned int nSlots);

template<typename T>
std::vector<T**> GetColumnReaders(std::string_view columnName);

void Initialize();

std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges();

void InitSlot(unsigned int slot, ULong64_t firstEntry);

bool SetEntry(unsigned int slot, ULong64_t entry);

void FinalizeSlot(unsigned int slot);

void Finalize();

const std::vector<std::string>& GetColumnNames() const;

bool HasColumn(std::string_view columnName) const;

std::string GetTypeName(std::string_view columnName) const;

protected:
Record_t GetColumnReadersImpl (std::string_view name,
const std::type_info& typeInfo);

std::string AsString() { return "Edm4hep data source"; };

private:
/// Number of slots/threads
unsigned int m_nSlots;
/// Input filename
std::vector<std::string> m_filePathList;
/// Total number of events
unsigned int m_nEvents;
/// Ranges of events available to be processed
std::vector<std::pair<ULong64_t, ULong64_t>> m_rangesAvailable;
/// Ranges of events available ever created
std::vector<std::pair<ULong64_t, ULong64_t>> m_rangesAll;
/// Column names
std::vector<std::string> m_columnNames;
/// Column types
std::vector<std::string> m_columnTypes;
/// Collections, m_Collections[columnIndex][slotIndex]
std::vector<std::vector<const podio::CollectionBase*>> m_Collections;
/// Active collections
std::vector<unsigned int> m_activeCollections;
/// Root legacy podio reader
std::map<int, podio::ROOTLegacyReader> m_podioReaders;
/// Podio frames
std::map<int, podio::Frame> m_frames;
/// Mutex to protect frame map
mutable std::shared_mutex m_frames_mutex;
/// Setup input
void SetupInput(int nEvents);
};


/**
* \brief Retrieve from EDM4hepLegacySource per-thread readers for the
* desired columns.
*/
template<typename T>
std::vector<T**>
EDM4hepLegacySource::GetColumnReaders(std::string_view columnName) {
std::cout << "EDM4hepLegacySource: Getting column readers for column: "
<< columnName << std::endl;

std::vector<T**> readers;

return readers;
}

ROOT::RDataFrame FromEDM4hepLegacy(const std::vector<std::string>& filePathList);
}

#endif /* EDM4HEP_LEGACY_SOURCE_H__ */
3 changes: 0 additions & 3 deletions e4hsource/include/EDM4hepSource/EDM4hepSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <vector>
#include <string>
#include <functional>
#include <mutex>

// ROOT
#include <ROOT/RDataFrame.hxx>
Expand Down Expand Up @@ -87,8 +86,6 @@ namespace FCCAnalyses {
bool m_useLegacyReaders;
/// Setup input
void SetupInput(int nEvents);

std::map<int, std::mutex> m_mutex;
};


Expand Down
16 changes: 16 additions & 0 deletions e4hsource/include/EDM4hepSource/Legacy_LinkDef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifdef __CINT__

//Globals
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;

// Load function
#pragma link C++ function loadEDM4hepLegacySource;

// Source
#pragma link C++ class FCCAnalyses::EDM4hepLegacySource;
#pragma link C++ function FCCAnalyses::FromEDM4hepLegacy;

#endif
Loading