LDMX Software
dqm::DarkBremInteraction Class Reference

Go through the particle map and find the dark brem products, storing their vertex and the dark brem outgoing kinematics for further study. More...

#include <DarkBremInteraction.h>

Public Member Functions

 DarkBremInteraction (const std::string &n, framework::Process &p)
 
virtual void produce (framework::Event &e) override
 extract the kinematics of the dark brem interaction from the SimParticles
 
void configure (framework::config::Parameters &parameters) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::map< std::string, int > known_materials_
 the list of known materials assigning them to material ID numbers
 
std::map< int, int > known_elements_
 The list of known elements assigning them to the bins that we are putting them into.
 
std::string particle_passname_
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Go through the particle map and find the dark brem products, storing their vertex and the dark brem outgoing kinematics for further study.

While histograms are filled to be automatically validated and plotted, we also put these values into the event tree so users can look at the variables related to the dark brem in detail.

Products

APrime{Px,Py,Pz} - 3-vector momentum of A' at dark brem APrimeEnergy - energy of A' at dark brem Recoil{Px,Py,Pz} - 3-vector momentum of electron recoiling from dark brem RecoilEnergy - energy of recoil at dark brem Incident{Px,Py,Pz} - 3-vector momentum of electron incident to dark brem IncidentEnergy - energy of incident electron at dark brem APrimeParentID - TrackID of A' parent DarkBremVertexMaterial - integer corresponding to index of known_materials parameter OR -1 if not found in known_materials DarkBremVertexMaterialZ - elemental Z value for element chosen by random from the elements in the material DarkBrem{X,Y,Z} - physical space location where dark brem occurred

Definition at line 31 of file DarkBremInteraction.h.

Constructor & Destructor Documentation

◆ DarkBremInteraction()

dqm::DarkBremInteraction::DarkBremInteraction ( const std::string & n,
framework::Process & p )
inline

Definition at line 33 of file DarkBremInteraction.h.

34 : framework::Producer(n, p) {}
Base class for a module which produces a data product.

Member Function Documentation

◆ configure()

void dqm::DarkBremInteraction::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 5 of file DarkBremInteraction.cxx.

5 {
6 particle_passname_ = parameters.get<std::string>("particle_passname");
7}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

References framework::config::Parameters::get().

◆ produce()

void dqm::DarkBremInteraction::produce ( framework::Event & e)
overridevirtual

extract the kinematics of the dark brem interaction from the SimParticles

Sometimes the electron that undergoes the dark brem is not in a region where it should be saved (i.e. it is a shower electron inside of the ECal). In this case, we need to reconstruct the incident momentum from the outgoing products (the recoil electron and the dark photon) which should be saved by the biasing filter used during the simulation.

Since the dark brem model does not include a nucleus, it only is able to conserve momentum, so we need to reconstruct the incident particle's 3-momentum and then use the electron mass to calculate its total energy.

Implements framework::Producer.

Definition at line 37 of file DarkBremInteraction.cxx.

37 {
38 histograms_.setWeight(event.getEventHeader().getWeight());
39 const auto& particle_map{
40 event.getMap<int, ldmx::SimParticle>("SimParticles", particle_passname_)};
41 const ldmx::SimParticle *recoil{nullptr}, *aprime{nullptr}, *beam{nullptr};
42 for (const auto& [track_id, particle] : particle_map) {
43 if (track_id == 1) beam = &particle;
44 if (particle.getProcessType() ==
45 ldmx::SimParticle::ProcessType::eDarkBrem) {
46 if (particle.getPdgID() == 622) {
47 if (aprime != nullptr) {
48 EXCEPTION_RAISE("BadEvent", "Found multiple A' in event.");
49 }
50 aprime = &particle;
51 } else {
52 recoil = &particle;
53 }
54 }
55 }
56
57 if (recoil == nullptr and aprime == nullptr) {
58 /* dark brem did not occur during the simulation
59 * IF PROPERLY CONFIGURED, this occurs because the simulation
60 * exhausted the maximum number of tries to get a dark brem
61 * to occur. We just leave early so that the entries in the
62 * ntuple are the unphysical numeric minimum.
63 */
64 ldmx_log(error) << " No dark brem occured in this event";
65 return;
66 }
67
68 if (recoil == nullptr or aprime == nullptr or beam == nullptr) {
69 // we are going to end processing so let's take our time to
70 // construct a nice error message
71 ldmx_log(fatal)
72 << "Unable to find all necessary particles for DarkBrem interaction."
73 << " Missing: [ " << (recoil == nullptr ? " recoil " : "")
74 << (aprime == nullptr ? " aprime " : "")
75 << (beam == nullptr ? " beam " : "") << "]";
76 EXCEPTION_RAISE(
77 "BadEvent",
78 "Unable to find all necessary particles for DarkBrem interaction.");
79 return;
80 }
81
82 const auto& recoil_p = recoil->getMomentum();
83 const auto& aprime_p = aprime->getMomentum();
84 ROOT::Math::XYZVector recoil_pvec(recoil_p[0], recoil_p[1], recoil_p[2]);
85 ROOT::Math::XYZVector aprime_pvec(aprime_p[0], aprime_p[1], aprime_p[2]);
86
87 std::vector<double> incident_p = recoil_p;
88 for (std::size_t i{0}; i < recoil_p.size(); ++i)
89 incident_p[i] += aprime_p.at(i);
90
91 double incident_energy = energy(incident_p, recoil->getMass());
92 double recoil_energy = energy(recoil_p, recoil->getMass());
93
94 std::vector<double> ap_vertex{aprime->getVertex()};
95 std::string ap_vertex_volume{aprime->getVertexVolume()};
96 auto ap_vertex_material_it = std::find_if(
98 [&](const auto& mat_pair) {
99 return ap_vertex_volume.find(mat_pair.first) != std::string::npos;
100 });
101 int ap_vertex_material = (ap_vertex_material_it != known_materials_.end())
102 ? ap_vertex_material_it->second
103 : 0;
104
105 if (ap_vertex_material == 0) {
106 ldmx_log(warn) << "Dark brem interaction occurred in an unknown material: "
107 << ap_vertex_volume;
108 }
109
110 int ap_parent_id{-1};
111 if (aprime->getParents().size() > 0) {
112 ap_parent_id = aprime->getParents().at(0);
113 } else {
114 ldmx_log(error) << "Found A' without a parent ID!";
115 }
116
117 float aprime_energy = energy(aprime_p, aprime->getMass());
118 int aprime_genstatus = aprime->getGenStatus();
119 double aprime_px{aprime_p.at(0)}, aprime_py{aprime_p.at(1)},
120 aprime_pz{aprime_p.at(2)};
121 event.add("APrimeEnergy", aprime_energy);
122 event.add("APrimePx", aprime_px);
123 event.add("APrimePy", aprime_py);
124 event.add("APrimePz", aprime_pz);
125 event.add("APrimeParentID", ap_parent_id);
126 event.add("APrimeGenStatus", aprime_genstatus);
127
128 histograms_.fill("aprime_energy", aprime_energy);
129 histograms_.fill("aprime_pt", quadsum({aprime_px, aprime_py}));
130 histograms_.fill("aprime_theta", aprime_pvec.Theta() * (180 / 3.14159));
131
132 int recoil_genstatus = recoil->getGenStatus();
133 double recoil_px{recoil_p.at(0)}, recoil_py{recoil_p.at(1)},
134 recoil_pz{recoil_p.at(2)};
135 event.add("RecoilEnergy", recoil_energy);
136 event.add("RecoilPx", recoil_px);
137 event.add("RecoilPy", recoil_py);
138 event.add("RecoilPz", recoil_pz);
139 event.add("RecoilGenStatus", recoil_genstatus);
140
141 histograms_.fill("recoil_energy", recoil_energy);
142 histograms_.fill("recoil_pt", quadsum({recoil_px, recoil_py}));
143 histograms_.fill("recoil_theta", recoil_pvec.Theta() * (180 / 3.14159));
144
145 event.add("IncidentEnergy", incident_energy);
146 double incident_px{incident_p.at(0)}, incident_py{incident_p.at(1)},
147 incident_pz{incident_p.at(2)};
148 event.add("IncidentPx", incident_px);
149 event.add("IncidentPy", incident_py);
150 event.add("IncidentPz", incident_pz);
151
152 histograms_.fill("incident_energy", incident_energy);
153 histograms_.fill("incident_pt", quadsum({incident_px, incident_py}));
154
155 double vtx_x{aprime->getVertex().at(0)}, vtx_y{aprime->getVertex().at(1)},
156 vtx_z{aprime->getVertex().at(2)};
157 event.add("DarkBremX", vtx_x);
158 event.add("DarkBremY", vtx_y);
159 event.add("DarkBremZ", vtx_z);
160 event.add("DarkBremVertexMaterial", ap_vertex_material);
161 float db_material_z =
162 event.getEventHeader().getFloatParameter("db_material_z");
163 event.add("DarkBremVertexMaterialZ", db_material_z);
164
165 histograms_.fill("dark_brem_z", vtx_z);
166
167 int i_element = 0;
168 if (db_material_z > 0) {
169 if (known_elements_.find(static_cast<int>(db_material_z)) ==
170 known_elements_.end()) {
171 i_element = known_elements_.size();
172 ldmx_log(warn)
173 << "Dark brem interaction occurred in an unknown element with Z = "
174 << db_material_z << ". Using index " << i_element
175 << " for this element.";
176 } else {
177 i_element = known_elements_.at(static_cast<int>(db_material_z));
178 }
179 }
180
181 histograms_.fill("dark_brem_element", i_element);
182 histograms_.fill("dark_brem_material", ap_vertex_material);
183}
std::map< std::string, int > known_materials_
the list of known materials assigning them to material ID numbers
std::map< int, int > known_elements_
The list of known elements assigning them to the bins that we are putting them into.
HistogramPool histograms_
helper object for making and filling histograms
void setWeight(double w)
Set the weight for filling the histograms.
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Class representing a simulated particle.
Definition SimParticle.h:23
std::vector< double > getMomentum() const
Get a vector containing the momentum of this particle [MeV].

References framework::HistogramPool::fill(), framework::Event::getEventHeader(), ldmx::SimParticle::getMomentum(), ldmx::EventHeader::getWeight(), framework::EventProcessor::histograms_, known_elements_, known_materials_, and framework::HistogramPool::setWeight().

Member Data Documentation

◆ known_elements_

std::map<int, int> dqm::DarkBremInteraction::known_elements_
private
Initial value:
= {{1, 1}, {6, 2}, {8, 3}, {11, 4},
{14, 5}, {20, 6}, {29, 7}, {39, 8},
{71, 9}, {74, 10}}

The list of known elements assigning them to the bins that we are putting them into.

There are two failure modes for this:

  1. The dark brem didn't happen, in which case, the element reported by the event header will be -1. We give this an ID of 0.
  2. The dark brem occurred within an element not listed here, in which case we give it the last bin.

The inverset LUT that can be used if studying the output tree is

element_lut = { 0 : 'did_not_happen', 1 : 'H 1', 2 : 'C 6', 3 : 'O 8', 4 : 'Na 11', 5 : 'Si 14', 6 : 'Ca 20', 7 : 'Cu 29', 8 : 'Y 39', 9 : 'Lu 71', 10 : 'W 74', 11 : 'unlisted' }

Definition at line 131 of file DarkBremInteraction.h.

131 {{1, 1}, {6, 2}, {8, 3}, {11, 4},
132 {14, 5}, {20, 6}, {29, 7}, {39, 8},
133 {71, 9}, {74, 10}};

Referenced by produce().

◆ known_materials_

std::map<std::string, int> dqm::DarkBremInteraction::known_materials_
private
Initial value:
= {
{"Carbon", 1},
{"PCB", 2},
{"Glue", 3},
{"Si", 4},
{"Al", 5},
{"W", 6},
{"target", 6},
{"trigger_pad", 7},
{"strongback", 5},
{"motherboard", 2},
{"support", 5},
{"CFMix", 3},
{"C_volume", 1}
}

the list of known materials assigning them to material ID numbers

During the simulation, we can store the name of the logical volume that the particle originated in. There can be many copies of logical volumes in different places but they all will be the same material by construction of how we designed our GDML. In the ecal GDML, the beginning the 'volume' tags list the logical volumes and you can see there which materials they all are in.

We go through this list on each event, checking if any of these entries match a substring of the logical volume name stored. If we don't find any, the integer ID is set to -1.

The inverse LUT that can be used on the plotting side is

material_lut = { 0 : 'Unknown', 1 : 'C', 2 : 'PCB', 3 : 'Glue', 4 : 'Si', 5 : 'Al', 6 : 'W', 7 : 'PVT' }

This is kind of lazy, we could instead do a full LUT where we list all known logical volume names and their associated materials but this analysis isn't as important so I haven't invested that much time in it yet.

Definition at line 84 of file DarkBremInteraction.h.

84 {
85 {"Carbon", 1},
86 {"PCB", 2}, // in v12, the motherboards were simple
87 // rectangles with 'PCB' in the name
88 {"Glue", 3},
89 {"Si", 4},
90 {"Al", 5},
91 {"W", 6},
92 {"target", 6},
93 {"trigger_pad", 7},
94 {"strongback", 5}, // strongback
95 // is made of
96 // aluminum
97 {"motherboard", 2}, // motherboards are PCB
98 {"support", 5}, // support box is aluminum
99 {"CFMix", 3}, // in v12, we called the Glue layers CFMix
100 {"C_volume", 1} // in v12, we called the carbon cooling planes C but this
101 // is too general for substr matching
102 };

Referenced by produce().

◆ particle_passname_

std::string dqm::DarkBremInteraction::particle_passname_
private

Definition at line 135 of file DarkBremInteraction.h.


The documentation for this class was generated from the following files: