LDMX Software
AnalysisUtils.cxx
Go to the documentation of this file.
1
8
9//-----------------//
10// C++ StdLib //
11//-----------------//
12#include <string>
13#include <tuple>
14
15//----------//
16// ldmx //
17//----------//
18#include "Framework/Exception/Exception.h"
19#include "SimCore/Event/SimParticle.h"
20
21//----------//
22// ROOT //
23//----------//
24#include "TVector3.h"
25
26namespace Analysis {
27
28std::tuple<int, const ldmx::SimParticle *> getRecoil(
29 const std::map<int, ldmx::SimParticle> &particleMap) {
30 // The recoil electron is "produced" in the dark brem geneartion
31 for (const auto &[trackID, particle] : particleMap) {
32 if (particle.getPdgID() == 11 and
33 particle.getProcessType() ==
34 ldmx::SimParticle::ProcessType::eDarkBrem) {
35 return {trackID, &particle};
36 }
37 }
38 // only get here if recoil electron was not "produced" by dark brem
39 // in this case (bkgd), we interpret the primary electron as also the recoil
40 // electron
41 return {1, &(particleMap.at(1))};
42}
43
44// Search the recoil electrons daughters for a photon
45// Check if the photon has daughters and if so, if they were produced by PN
46//
47
49 const ldmx::SimParticle &gamma,
50 const std::map<int, ldmx::SimParticle> &particleMap) {
51 for (auto daughterID : gamma.getDaughters()) {
52 if (particleMap.find(daughterID) != std::end(particleMap)) {
53 const auto daughter{particleMap.at(daughterID)};
54 const auto processType{daughter.getProcessType()};
55 if (processType == ldmx::SimParticle::ProcessType::photonNuclear) {
56 return true;
57 } // Was it PN?
58 } // Was it in the map?
59 }
60
61 return false;
62}
63
65 const std::map<int, ldmx::SimParticle> &particleMap,
66 const ldmx::SimParticle *recoil, const float &energyThreshold) {
67 auto recoilDaughters{recoil->getDaughters()};
68 for (auto recoilDaughterID : recoilDaughters) {
69 // Have we stored the recoil daughter?
70 if (particleMap.find(recoilDaughterID) != std::end(particleMap)) {
71 auto recoilDaughter{particleMap.at(recoilDaughterID)};
72 // Is it a gamma?
73 if (recoilDaughter.getPdgID() == 22) {
74 // Does it have enough energy?
75 if (recoilDaughter.getEnergy() >= energyThreshold) {
76 // Are its daughters PN products?
77 if (doesParticleHavePNDaughters(recoilDaughter, particleMap)) {
78 return &particleMap.at(recoilDaughterID);
79 }
80 }
81 }
82 }
83 }
84 return nullptr;
85}
86
87} // namespace Analysis
Collection of utility functions useful for analysis.
const ldmx::SimParticle * getPNGamma(const std::map< int, ldmx::SimParticle > &particleMap, const ldmx::SimParticle *recoil, const float &energyThreshold)
Get a pointer to the sim particle associated with the photon that underwent a photo-nuclear reaction.
bool doesParticleHavePNDaughters(const ldmx::SimParticle &gamma, const std::map< int, ldmx::SimParticle > &particleMap)
Helper function to getPNGamma.
std::tuple< int, const ldmx::SimParticle * > getRecoil(const std::map< int, ldmx::SimParticle > &particleMap)
Find and return the sim particle associated with the recoil electron.
Class representing a simulated particle.
Definition SimParticle.h:23
std::vector< int > getDaughters() const
Get a vector containing the track IDs of all daughter particles.