Skip to content

Commit 24420e1

Browse files
authored
Generic container (#142)
* bugfix in HelperFunctions sliceCuts name * enable generic (plain) container, w/o default fields * avoid deprecated function * fix Warning: Unused class rule: UserTaskWrite * init GenericContainerFiller * dev GenericContainerFiller * add StringToBool to HelperFunctions * apply clang-format * revert include_directories() due to back compatibility
1 parent b021434 commit 24420e1

15 files changed

Lines changed: 263 additions & 15 deletions

core/AnalysisTreeCoreLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#pragma link C++ typedef AnalysisTree::ModuleDetector;
4141
#pragma link C++ typedef AnalysisTree::HitDetector;
4242
#pragma link C++ typedef AnalysisTree::ModulePositions;
43+
#pragma link C++ typedef AnalysisTree::GenericDetector;
4344

4445
#pragma link C++ defined_in "Constants.h";
4546

core/Constants.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ enum class DetType : ShortInt_t {
4949
kModule,
5050
kTrack,
5151
kEventHeader,
52-
kParticle
52+
kParticle,
53+
kGeneric
5354
};
5455

5556
enum class Types : ShortInt_t {

examples/AnalysisTreeUserLinkDef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#pragma link off all functions;
55
#pragma link C++ nestedclasses;
66

7-
//#pragma link C++ class UserTaskRead++;
8-
#pragma link C++ class UserTaskWrite++;
7+
#pragma link C++ class UserTaskRead+;
8+
#pragma link C++ class UserTaskWrite+;
99

1010
#endif

examples/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ message(STATUS "CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME}")
1414
string(REPLACE ".cpp" ".hpp" HEADERS "${SOURCES}")
1515

1616
include_directories(${CMAKE_SOURCE_DIR}/core ${CMAKE_SOURCE_DIR}/infra ${CMAKE_CURRENT_SOURCE_DIR} $<$<BOOL:${Boost_FOUND}>:${Boost_INCLUDE_DIRS}>)
17-
add_library(AnalysisTreeUser SHARED ${SOURCES} G__AnalysisTreeUser.cxx)
17+
add_library(AnalysisTreeUser SHARED ${SOURCES})
1818
target_compile_definitions(AnalysisTreeUser PUBLIC
1919
$<$<BOOL:${Boost_FOUND}>:ANALYSISTREE_BOOST_FOUND>)
2020

@@ -23,6 +23,7 @@ ROOT_GENERATE_DICTIONARY(G__AnalysisTreeUser ${HEADERS}
2323
OPTIONS
2424
-I${CMAKE_BINARY_DIR}/include
2525
$<$<BOOL:${Boost_FOUND}>:-DANALYSISTREE_BOOST_FOUND>
26+
MODULE AnalysisTreeUser
2627
)
2728
target_link_libraries(AnalysisTreeUser
2829
PUBLIC

examples/UserTaskRead.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef ANALYSISTREE_EXAMPLES_USERTASKREAD_HPP_
22
#define ANALYSISTREE_EXAMPLES_USERTASKREAD_HPP_
33

4-
#include <Task.hpp>
4+
#include <AnalysisTree/Task.hpp>
55

66
class UserTaskRead : public AnalysisTree::Task {
77

examples/UserTaskWrite.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef ANALYSISTREE_EXAMPLES_USERTASKWRITE_HPP_
22
#define ANALYSISTREE_EXAMPLES_USERTASKWRITE_HPP_
33

4-
#include <Branch.hpp>
54
#include <Detector.hpp>
6-
#include <Task.hpp>
5+
#include <AnalysisTree/Branch.hpp>
6+
#include <AnalysisTree/Task.hpp>
77

88
class UserTaskWrite : public AnalysisTree::Task {
99

examples/example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void example(const std::string& filename, const std::string& treename){
3333
data_header->Print();
3434
config->Print();
3535

36-
auto rec_particles = chain->GetBranch("VtxTracks");
36+
auto rec_particles = chain->GetBranchObject("VtxTracks");
3737
auto rec2sim_particles = chain->GetMatching("VtxTracks", "SimParticles");
3838

3939
auto rec_pT = rec_particles.GetField("pT");

infra/Branch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ void Branch::InitDataPtr() {
4141
data_ = temp;
4242
break;
4343
}
44+
case DetType::kGeneric: {
45+
data_ = new GenericDetector(config_.GetId());
46+
break;
47+
}
4448
default: throw std::runtime_error("Branch type is not known!");
4549
}
4650
}

infra/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set(SOURCES
1313
Branch.cpp
1414
BranchChannel.cpp
1515
AnalysisEntry.cpp
16+
GenericContainerFiller.cpp
1617
)
1718

1819

@@ -22,7 +23,7 @@ string(REPLACE ".cpp" ".hpp" HEADERS "${SOURCES}")
2223
list(APPEND HEADERS "VariantMagic.hpp" "ToyMC.hpp" "Utils.hpp" "BranchHashHelper.hpp" "HelperFunctions.hpp")
2324

2425
include_directories(${CMAKE_SOURCE_DIR}/core ${CMAKE_CURRENT_SOURCE_DIR} $<$<BOOL:${Boost_FOUND}>:${Boost_INCLUDE_DIRS}>)
25-
add_library(AnalysisTreeInfra SHARED ${SOURCES} G__AnalysisTreeInfra.cxx)
26+
add_library(AnalysisTreeInfra SHARED ${SOURCES})
2627
target_compile_definitions(AnalysisTreeInfra PUBLIC
2728
$<$<BOOL:${Boost_FOUND}>:ANALYSISTREE_BOOST_FOUND>)
2829

@@ -31,6 +32,7 @@ ROOT_GENERATE_DICTIONARY(G__AnalysisTreeInfra ${HEADERS}
3132
OPTIONS
3233
-I${CMAKE_BINARY_DIR}/include
3334
$<$<BOOL:${Boost_FOUND}>:-DANALYSISTREE_BOOST_FOUND>
35+
MODULE AnalysisTreeInfra
3436
)
3537
target_link_libraries(AnalysisTreeInfra
3638
PUBLIC

infra/Chain.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ void Chain::InitPointersToBranches(std::set<std::string> names) {
8888
branch_ptr = new ModuleDetector;
8989
break;
9090
}
91+
case DetType::kGeneric: {
92+
branch_ptr = new GenericDetector;
93+
break;
94+
}
9195
}
9296
branches_.emplace(branch, branch_ptr);
9397
}

0 commit comments

Comments
 (0)