LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 onProcessStart () override
 update the labels of some categorial histograms
 
virtual void produce (framework::Event &e) override
 extract the kinematics of the dark brem interaction from the SimParticles
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void configure (framework::config::Parameters &parameters)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
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 Member Functions

void setHistLabels (const std::string &name, const std::vector< std::string > &labels)
 Set the labels of the histogram of the input name with the input labels.
 

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.
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 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 30 of file DarkBremInteraction.h.

Constructor & Destructor Documentation

◆ DarkBremInteraction()

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

Definition at line 32 of file DarkBremInteraction.h.

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

Member Function Documentation

◆ onProcessStart()

void dqm::DarkBremInteraction::onProcessStart ( )
overridevirtual

update the labels of some categorial histograms

This is helpful for downstream viewers of the histograms so that ROOT will display the bins properly.

Reimplemented from framework::EventProcessor.

Definition at line 47 of file DarkBremInteraction.cxx.

47 {
48 setHistLabels("dark_brem_material",
49 {"Unknown", "C", "PCB", "Glue", "Si", "Al", "W / LYSO", "PVT"});
50
51 setHistLabels("dark_brem_element",
52 {"did not happen", "H 1", "C 6", "O 8", "Na 11", "Si 14",
53 "Ca 20", "Cu 29", "W / LYSO 74", "unlisted"});
54}
void setHistLabels(const std::string &name, const std::vector< std::string > &labels)
Set the labels of the histogram of the input name with the input labels.

References setHistLabels().

◆ 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 56 of file DarkBremInteraction.cxx.

56 {
57 histograms_.setWeight(event.getEventHeader().getWeight());
58 const auto& particle_map{
59 event.getMap<int, ldmx::SimParticle>("SimParticles")};
60 const ldmx::SimParticle *recoil{nullptr}, *aprime{nullptr}, *beam{nullptr};
61 for (const auto& [track_id, particle] : particle_map) {
62 if (track_id == 1) beam = &particle;
63 if (particle.getProcessType() ==
64 ldmx::SimParticle::ProcessType::eDarkBrem) {
65 if (particle.getPdgID() == 622) {
66 if (aprime != nullptr) {
67 EXCEPTION_RAISE("BadEvent", "Found multiple A' in event.");
68 }
69 aprime = &particle;
70 } else {
71 recoil = &particle;
72 }
73 }
74 }
75
76 if (recoil == nullptr and aprime == nullptr) {
77 /* dark brem did not occur during the simulation
78 * IF PROPERLY CONFIGURED, this occurs because the simulation
79 * exhausted the maximum number of tries to get a dark brem
80 * to occur. We just leave early so that the entries in the
81 * ntuple are the unphysical numeric minimum.
82 *
83 * This can also happen during development, so I leave a debug
84 * printout here to be uncommented when developing the dark
85 * brem simulation.
86 std::cout << "Event " << e.getEventNumber()
87 << " did not have a dark brem occur within it." << std::endl;
88 */
89 return;
90 }
91
92 if (recoil == nullptr or aprime == nullptr or beam == nullptr) {
93 // we are going to end processing so let's take our time to
94 // construct a nice error message
95 std::stringstream err_msg;
96 err_msg
97 << "Unable to find all necessary particles for DarkBrem interaction."
98 << " Missing: [ " << (recoil == nullptr ? "recoil " : "")
99 << (aprime == nullptr ? "aprime " : "")
100 << (beam == nullptr ? "beam " : "") << "]" << std::endl;
101 EXCEPTION_RAISE("BadEvent", err_msg.str());
102 return;
103 }
104
105 const auto& recoil_p = recoil->getMomentum();
106 const auto& aprime_p = aprime->getMomentum();
107
108 std::vector<double> incident_p = recoil_p;
109 for (std::size_t i{0}; i < recoil_p.size(); ++i)
110 incident_p[i] += aprime_p.at(i);
111
112 double incident_energy = energy(incident_p, recoil->getMass());
113 double recoil_energy = energy(recoil_p, recoil->getMass());
114
115 std::vector<double> ap_vertex{aprime->getVertex()};
116 std::string ap_vertex_volume{aprime->getVertexVolume()};
117 auto ap_vertex_material_it = std::find_if(
118 known_materials_.begin(), known_materials_.end(),
119 [&](const auto& mat_pair) {
120 return ap_vertex_volume.find(mat_pair.first) != std::string::npos;
121 });
122 int ap_vertex_material = (ap_vertex_material_it != known_materials_.end())
123 ? ap_vertex_material_it->second
124 : 0;
125
126 int ap_parent_id{-1};
127 if (aprime->getParents().size() > 0) {
128 ap_parent_id = aprime->getParents().at(0);
129 } else {
130 ldmx_log(error) << "Found A' without a parent ID!";
131 }
132
133 float aprime_energy = energy(aprime_p, aprime->getMass());
134 int aprime_genstatus = aprime->getGenStatus();
135 double aprime_px{aprime_p.at(0)}, aprime_py{aprime_p.at(1)},
136 aprime_pz{aprime_p.at(2)};
137 event.add("APrimeEnergy", aprime_energy);
138 event.add("APrimePx", aprime_px);
139 event.add("APrimePy", aprime_py);
140 event.add("APrimePz", aprime_pz);
141 event.add("APrimeParentID", ap_parent_id);
142 event.add("APrimeGenStatus", aprime_genstatus);
143
144 histograms_.fill("aprime_energy", aprime_energy);
145 histograms_.fill("aprime_pt", quadsum({aprime_px, aprime_py}));
146
147 int recoil_genstatus = recoil->getGenStatus();
148 double recoil_px{recoil_p.at(0)}, recoil_py{recoil_p.at(1)},
149 recoil_pz{recoil_p.at(2)};
150 event.add("RecoilEnergy", recoil_energy);
151 event.add("RecoilPx", recoil_px);
152 event.add("RecoilPy", recoil_py);
153 event.add("RecoilPz", recoil_pz);
154 event.add("RecoilGenStatus", recoil_genstatus);
155
156 histograms_.fill("recoil_energy", recoil_energy);
157 histograms_.fill("recoil_pt", quadsum({recoil_px, recoil_py}));
158
159 event.add("IncidentEnergy", incident_energy);
160 double incident_px{incident_p.at(0)}, incident_py{incident_p.at(1)},
161 incident_pz{incident_p.at(2)};
162 event.add("IncidentPx", incident_px);
163 event.add("IncidentPy", incident_py);
164 event.add("IncidentPz", incident_pz);
165
166 histograms_.fill("incident_energy", incident_energy);
167 histograms_.fill("incident_pt", quadsum({incident_px, incident_py}));
168
169 double vtx_x{aprime->getVertex().at(0)}, vtx_y{aprime->getVertex().at(1)},
170 vtx_z{aprime->getVertex().at(2)};
171 event.add("DarkBremX", vtx_x);
172 event.add("DarkBremY", vtx_y);
173 event.add("DarkBremZ", vtx_z);
174 event.add("DarkBremVertexMaterial", ap_vertex_material);
175 float db_material_z =
176 event.getEventHeader().getFloatParameter("db_material_z");
177 event.add("DarkBremVertexMaterialZ", db_material_z);
178
179 histograms_.fill("dark_brem_z", vtx_z);
180
181 int i_element = 0;
182 if (db_material_z > 0) {
183 if (known_elements_.find(static_cast<int>(db_material_z)) ==
184 known_elements_.end()) {
185 i_element = known_elements_.size();
186 } else {
187 i_element = known_elements_.at(static_cast<int>(db_material_z));
188 }
189 }
190
191 histograms_.fill("dark_brem_element", i_element);
192 histograms_.fill("dark_brem_material", ap_vertex_material);
193}
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.
HistogramHelper histograms_
Interface class for making and filling histograms.
void fill(const std::string &name, const double &val)
Fill a 1D histogram.
Definition Histograms.h:166
void setWeight(double w)
Set the weight for filling the histograms.
Definition Histograms.h:91
Class representing a simulated particle.
Definition SimParticle.h:23

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

◆ setHistLabels()

void dqm::DarkBremInteraction::setHistLabels ( const std::string &  name,
const std::vector< std::string > &  labels 
)
private

Set the labels of the histogram of the input name with the input labels.

We could probably move this into Framework since it is a relatively common task. I could even imagine a way of constructing a StrCategory histogram.

Definition at line 34 of file DarkBremInteraction.cxx.

35 {
41 auto h{histograms_.get(name)};
42 for (std::size_t ibin{1}; ibin <= labels.size(); ibin++) {
43 h->GetXaxis()->SetBinLabel(ibin, labels[ibin - 1].c_str());
44 }
45}
TH1 * get(const std::string &name)
Get a pointer to a histogram by name.
Definition Histograms.h:194

References framework::HistogramHelper::get(), and framework::EventProcessor::histograms_.

Referenced by onProcessStart().

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}, {74, 8}}

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 : 'W 74', 9 : 'unlisted' }

Definition at line 140 of file DarkBremInteraction.h.

140 {{1, 1}, {6, 2}, {8, 3}, {11, 4},
141 {14, 5}, {20, 6}, {29, 7}, {74, 8}};

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 95 of file DarkBremInteraction.h.

95 {
96 {"Carbon", 1},
97 {"PCB", 2}, // in v12, the motherboards were simple
98 // rectangles with 'PCB' in the name
99 {"Glue", 3},
100 {"Si", 4},
101 {"Al", 5},
102 {"W", 6},
103 {"target", 6},
104 {"trigger_pad", 7},
105 {"strongback", 5}, // strongback
106 // is made of
107 // aluminum
108 {"motherboard", 2}, // motherboards are PCB
109 {"support", 5}, // support box is aluminum
110 {"CFMix", 3}, // in v12, we called the Glue layers CFMix
111 {"C_volume", 1} // in v12, we called the carbon cooling planes C but this
112 // is too general for substr matching
113 };

Referenced by produce().


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