Skip to content

Commit 7623ef0

Browse files
authored
Merge pull request #50 from DUNE/feature/proxy-navigation
Ancestry traversal for proxy objects
2 parents 6f65d20 + 0249d96 commit 7623ef0

File tree

10 files changed

+115
-29
lines changed

10 files changed

+115
-29
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33

44
##### current
55

6+
##### [v03_07_00] -- 2025-04-17
7+
* Add convenience navigation functions for ancestry traversal with SRProxy [#50]
8+
* Bump default qual to e26, srproxy to v00.45; eliminate e20
9+
10+
##### [v03_06_01] -- 2024-08-30
11+
* Modernize the cetmodules stuff [#31, #38]
12+
* Track & shower matching bugfix [#41]
13+
* Add new flash match class & fix initialization of run info [#42]
14+
* Touch up `classes_def.xml` [#44]
15+
16+
##### [v03_05_00] -- 2025-05-13
17+
* Add extra reco Enu fields for FD analysis usage [#34]
18+
* Bump ROOT version [#36]
19+
* Touch up `classes_def.xml` [#37]
20+
21+
##### [v03_04_00] -- 2024-03-18
22+
* Bump ROOT, SRProxy versions [#33]
23+
624
##### [v03_03_00] -- 2024-01-12 (PR #27)
725
* Store GEANT4 process codes & include documentation links rather than translating them to internal enumeration
826

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cmake_minimum_required (VERSION 3.20 FATAL_ERROR)
1818

1919
find_package(cetmodules REQUIRED)
2020
project(duneanaobj LANGUAGES CXX)
21-
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 03.06.01)
21+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 03.07.00)
2222

2323
message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")
2424

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "duneanaobj/StandardRecord/Navigate.ixx"
2+
#include "duneanaobj/StandardRecord/SREnums.h"
3+
#include "duneanaobj/StandardRecord/SRTrueParticle.h"
4+
#include "duneanaobj/StandardRecord/SRTruthBranch.h"
5+
6+
7+
namespace caf
8+
{
9+
// instantiate the template for "regular" StandardRecord types.
10+
// for the SRProxy version, see Proxy/Instantiations.cxx.
11+
template const SRTrueParticle * FindParticle(const SRTruthBranch & truth, const TrueParticleID & id);
12+
13+
template const SRTrueInteraction * FindInteraction(const SRTruthBranch & truth, long int id);
14+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef DUNEANAOBJ_NAVIGATE_H
2+
#define DUNEANAOBJ_NAVIGATE_H
3+
4+
#include <type_traits>
5+
6+
#include "duneanaobj/StandardRecord/SRTruthBranch.h"
7+
8+
namespace caf
9+
{
10+
// a bit horrible to forward-declare Proxy types...
11+
// (we would #include Proxy/FwdDeclare.h, but
12+
// gen_srproxy has not yet created it
13+
// by the time Navigate.h is first seen)
14+
template <class T> class Proxy;
15+
class SRTrueParticle;
16+
using SRTrueParticleProxy = caf::Proxy<caf::SRTrueParticle>;
17+
18+
/// Convenience method to find a particle stored by its ID easily.
19+
/// Intended to be used with 'regular' StandardRecord objects as well as their SRProxy equivalents.
20+
/// (The horrible return type construction is so that the return type can be deduced automatically
21+
/// and thus avoids having to have the user specify a template parameter for it.)
22+
template <typename TruthBranchType, typename TrueParticleIDType>
23+
const typename std::conditional<std::is_same_v<TruthBranchType, SRTruthBranch>,
24+
SRTrueParticle, SRTrueParticleProxy>::type *
25+
FindParticle(const TruthBranchType & truth, const TrueParticleIDType &id);
26+
27+
class SRTrueInteraction;
28+
using SRTrueInteractionProxy = caf::Proxy<caf::SRTrueInteraction>;
29+
template <typename TruthBranchType>
30+
const typename std::conditional<std::is_same_v<TruthBranchType, SRTruthBranch>,
31+
SRTrueInteraction, SRTrueInteractionProxy>::type *
32+
FindInteraction(const TruthBranchType & truth, long int id);
33+
}
34+
#endif //DUNEANAOBJ_NAVIGATE_H
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "duneanaobj/StandardRecord/Navigate.h"
2+
#include "duneanaobj/StandardRecord/SREnums.h"
3+
4+
#include <stdexcept>
5+
6+
namespace caf
7+
{
8+
template <typename TruthBranchType, typename TrueParticleIDType>
9+
const typename std::conditional<std::is_same_v<TruthBranchType, SRTruthBranch>, SRTrueParticle, SRTrueParticleProxy>::type *
10+
FindParticle(const TruthBranchType & truth, const TrueParticleIDType &id)
11+
{
12+
if (id.type == TrueParticleID::kUnknown || id.ixn < 0 || id.part < 0)
13+
return nullptr;
14+
15+
if (id.type == TrueParticleID::PartType::kPrimary)
16+
return &truth.nu[id.ixn].prim[id.part];
17+
else if (id.type == TrueParticleID::PartType::kPrimaryBeforeFSI)
18+
return &truth.nu[id.ixn].prefsi[id.part];
19+
else if (id.type == TrueParticleID::PartType::kSecondary)
20+
return &truth.nu[id.ixn].sec[id.part];
21+
else
22+
throw std::domain_error("Unknown PartType: " + std::to_string(id.type));
23+
}
24+
25+
template <typename TruthBranchType>
26+
const typename std::conditional<std::is_same_v<TruthBranchType, SRTruthBranch>, SRTrueInteraction, SRTrueInteractionProxy>::type *
27+
FindInteraction(const TruthBranchType & truth, long int id){
28+
if (id < 0)
29+
return nullptr;
30+
31+
return &truth.nu[id];
32+
}
33+
34+
}

duneanaobj/StandardRecord/Proxy/Instantiations.cxx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
// srproxy package doesn't include binaries).
33
#include "SRProxy/BasicTypesProxy.cxx"
44

5-
#include "duneanaobj/StandardRecord/SREnums.h"
5+
#include "duneanaobj/StandardRecord/Proxy/SRProxy.h"
6+
#include "duneanaobj/StandardRecord/Navigate.ixx"
7+
#include "duneanaobj/StandardRecord/SRTrueParticle.h"
68

79
// But this also gives us an opportunity to instantiate the template for
8-
// various DUNE-specific enums that would otherwise be missing symbols.
10+
// various DUNE-specific enums that would otherwise be missing symbols,
11+
// as well as other templated functions that depend on SRProxy having
12+
// already been constructed by gen_srproxy.
913
namespace caf
1014
{
1115
template class Proxy<Detector>;
@@ -17,4 +21,7 @@ namespace caf
1721
template class Proxy<FD_RECO_STACK>;
1822

1923
template class Proxy<TrueParticleID::PartType>;
24+
25+
template const SRTrueParticleProxy * FindParticle(const SRTruthBranchProxy & truth, const TrueParticleIDProxy & id);
26+
template const SRTrueInteractionProxy * FindInteraction(const SRTruthBranchProxy & truth, long int id);
2027
}

duneanaobj/StandardRecord/SRTrueInteraction.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ namespace caf
4343
static constexpr float NaN = std::numeric_limits<float>::signaling_NaN();
4444

4545
public:
46-
long int id = -1; ///< Interaction ID == 'vertexID' from edep-sim (ND) or GENIE record id (FD)
46+
/// Interaction ID == 'vertexID' from edep-sim (ND) or GENIE record id (FD).
47+
/// In the ND case, the packing of the VertexID is described in https://github.com/DUNE/2x2_sim/wiki/Production-changes-and-validation-finding
48+
long int id = -1;
4749

4850
/// Index of interaction in GENIE tree.
4951
/// Note: for ND, check `id` to determine whether
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
#include "duneanaobj/StandardRecord/SRTruthBranch.h"
21

3-
namespace caf
4-
{
5-
const SRTrueParticle * SRTruthBranch::Particle(const TrueParticleID & id) const
6-
{
7-
if (id.type == TrueParticleID::kUnknown || id.ixn < 0 || id.part < 0)
8-
return nullptr;
9-
10-
if (id.type == TrueParticleID::PartType::kPrimary)
11-
return &nu[id.ixn].prim[id.part];
12-
else if (id.type == TrueParticleID::PartType::kPrimaryBeforeFSI)
13-
return &nu[id.ixn].prefsi[id.part];
14-
else if (id.type == TrueParticleID::PartType::kSecondary)
15-
return &nu[id.ixn].sec[id.part];
16-
else
17-
throw std::domain_error("Unknown PartType: " + std::to_string(id.type));
18-
}
19-
}

duneanaobj/StandardRecord/SRTruthBranch.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ namespace caf
1919
/// Vector of true nus, cosmics, etc. contributing to this trigger
2020
std::vector<SRTrueInteraction> nu;
2121
std::size_t nnu = 0;
22-
23-
/// Convenience method to find a particle stored by its ID easily
24-
const SRTrueParticle * Particle(const TrueParticleID & id) const;
2522
};
2623

2724
} // caf

ups/product_deps

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ defaultqual e26
9898
#> define_pythonpath
9999
####################################
100100
parent duneanaobj
101-
defaultqual e20
101+
defaultqual e26:prof
102102
####################################
103103

104104
####################################
@@ -261,7 +261,7 @@ libdir fq_dir lib
261261
####################################
262262
product version qual flags <table_format=2>
263263
root v6_28_12 -
264-
srproxy v00.44 -
264+
srproxy v00.45 -
265265
cetmodules v3_22_02 - only_for_build
266266
end_product_list
267267
####################################
@@ -320,8 +320,6 @@ end_product_list
320320
qualifier root srproxy notes
321321
c14:debug c14:p3915:debug py3915
322322
c14:prof c14:p3915:prof py3915
323-
e20:debug e20:p3915:debug py3915
324-
e20:prof e20:p3915:prof py3915
325323
e26:debug e26:p3915:debug py3915
326324
e26:prof e26:p3915:prof py3915
327325
end_qualifier_list

0 commit comments

Comments
 (0)