LDMX Software
EcalSPElectronKinematics.cxx
1#include "DQM/EcalSPElectronKinematics.h"
2
3#include <cmath>
4
5#include "DetDescr/SimSpecialID.h"
7
8namespace dqm {
9
11 ecal_sp_coll_name_ = ps.get<std::string>("ecal_sp_coll_name");
12 ecal_sp_pass_name_ = ps.get<std::string>("ecal_sp_pass_name");
13}
14
17
18 if (!event.exists(ecal_sp_coll_name_, ecal_sp_pass_name_)) return;
19
20 const auto& sp_hits{event.getCollection<ldmx::SimTrackerHit>(
21 ecal_sp_coll_name_, ecal_sp_pass_name_)};
22
23 for (const auto& hit : sp_hits) {
24 ldmx::SimSpecialID hit_id(hit.getID());
25 // Plane 31 is the ECal front face; require forward-going particle
26 if (hit_id.plane() != 31) continue;
27 const auto p = hit.getMomentum();
28 if (p[2] <= 0) continue;
29 // Only the primary beam electron
30 if (hit.getTrackID() != 1 || hit.getPdgID() != 11) continue;
31
32 float energy = hit.getEnergy();
33 float px = static_cast<float>(p[0]);
34 float py = static_cast<float>(p[1]);
35 float pz = static_cast<float>(p[2]);
36 const auto pos = hit.getPosition();
37 float x = pos[0], y = pos[1];
38 float pt = std::sqrt(px * px + py * py);
39
40 event.add("EcalSPEnergy", energy);
41 event.add("EcalSPPx", px);
42 event.add("EcalSPPy", py);
43 event.add("EcalSPPz", pz);
44 event.add("EcalSPX", x);
45 event.add("EcalSPY", y);
46
47 histograms_.fill("energy", energy);
48 histograms_.fill("pt", pt);
49 histograms_.fill("px", px);
50 histograms_.fill("py", py);
51 histograms_.fill("x", x);
52 histograms_.fill("y", y);
53
54 // Use only the first matching hit
55 break;
56 }
57}
58
59} // namespace dqm
60
#define DECLARE_ANALYZER(CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Class which encapsulates information from a hit in a simulated tracking detector.
Extracts and histograms the kinematics of the primary electron at the ECal front-face scoring plane.
void produce(framework::Event &event) override
Process the event and put new data products into it.
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
HistogramPool histograms_
helper object for making and filling histograms
Implements an event buffer system for storing event data.
Definition Event.h:42
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:105
ldmx::EventHeader & getEventHeader()
Get the event header.
Definition Event.h:59
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 encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
double getWeight() const
Get the event weight (default of 1.0).
Definition EventHeader.h:98
Implements detector ids for special simulation-derived hits like scoring planes.
int plane() const
Get the value of the plane field from the ID, if it is a scoring plane.
Represents a simulated tracker hit in the simulation.