DUNE StandardRecord
Base object for DUNE analysis files (CAFs)
Loading...
Searching...
No Matches
Navigate.ixx
1#include "duneanaobj/StandardRecord/Navigate.h"
2#include "duneanaobj/StandardRecord/SREnums.h"
3
4#include <stdexcept>
5
6namespace 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}
Common Analysis Files.
Definition Navigate.cxx:8