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_coll_name_
 
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 class_name 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_coll_name_ = parameters.get<std::string>("particle_coll_name");
7 particle_passname_ = parameters.get<std::string>("particle_passname");
8}
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 38 of file DarkBremInteraction.cxx.

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

std::string dqm::DarkBremInteraction::particle_coll_name_
private

Definition at line 134 of file DarkBremInteraction.h.

◆ 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: