LDMX Software
dqm::EcalTrackAnalyzer Class Reference

DQM analyzer for ECAL tracks fitted with ACTS zero-B field CKF. More...

#include <EcalTrackAnalyzer.h>

Public Member Functions

 EcalTrackAnalyzer (const std::string &name, framework::Process &process)
 Constructor.
 
 ~EcalTrackAnalyzer () override=default
 Destructor.
 
void configure (framework::config::Parameters &ps) override
 Configure the analyzer.
 
void analyze (const framework::Event &event) override
 Analyze the event.
 
- Public Member Functions inherited from framework::Analyzer
 Analyzer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for an Analyzer is calling analyze.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header) final
 Don't allow Analyzers to add parameters to the run header.
 
- 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 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::string track_collection_ {"EcalTracks"}
 ECAL track collection name.
 
std::string track_pass_name_ {""}
 Pass name for tracks.
 
std::string rec_hit_collection_ {"EcalRecHits"}
 ECAL RecHit collection (for layer occupancy)
 
std::string rec_hit_pass_name_ {""}
 Pass name for RecHits.
 

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

DQM analyzer for ECAL tracks fitted with ACTS zero-B field CKF.

Creates histograms of track properties:

  • Track multiplicity
  • Number of hits per track
  • Chi2 and NDF distributions
  • Track parameters (d0, z0, phi, theta, p)
  • Hit occupancy by layer

Definition at line 30 of file EcalTrackAnalyzer.h.

Constructor & Destructor Documentation

◆ EcalTrackAnalyzer()

dqm::EcalTrackAnalyzer::EcalTrackAnalyzer ( const std::string & name,
framework::Process & process )
inline

Constructor.

Definition at line 35 of file EcalTrackAnalyzer.h.

36 : Analyzer(name, process) {}
virtual void process(Event &event) final
Processing an event for an Analyzer is calling analyze.
Analyzer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ analyze()

void dqm::EcalTrackAnalyzer::analyze ( const framework::Event & event)
overridevirtual

Analyze the event.

Implements framework::Analyzer.

Definition at line 19 of file EcalTrackAnalyzer.cxx.

19 {
20 // Check if track collection exists
22 ldmx_log(debug) << "ECAL track collection does not exist";
23 return;
24 }
25
26 // Get ECAL tracks
27 const auto& ecal_tracks =
28 event.getCollection<ldmx::Track>(track_collection_, track_pass_name_);
29
30 int n_tracks = ecal_tracks.size();
31 histograms_.fill("n_tracks", n_tracks);
32
33 if (n_tracks == 0) {
34 return;
35 }
36
37 // Loop over tracks
38 for (size_t i_track = 0; i_track < ecal_tracks.size(); ++i_track) {
39 const auto& track = ecal_tracks[i_track];
40
41 // Track quality
42 double chi2 = track.getChi2();
43 int ndf = track.getNdf();
44 int nhits = track.getNhits();
45
46 histograms_.fill("track_chi2", chi2);
47 histograms_.fill("track_ndf", ndf);
48 histograms_.fill("track_nhits", nhits);
49
50 if (ndf > 0) {
51 histograms_.fill("track_chi2_ndf", chi2 / ndf);
52 }
53
54 // Track parameters
55 double d0 = track.getD0();
56 double z0 = track.getZ0();
57 double phi = track.getPhi();
58 double theta = track.getTheta();
59 double qop = track.getQoP();
60 int charge = track.getCharge();
61
62 histograms_.fill("track_d0", d0);
63 histograms_.fill("track_z0", z0);
64 histograms_.fill("track_phi", phi);
65 histograms_.fill("track_theta", theta);
66 histograms_.fill("track_qop", qop);
67 histograms_.fill("track_charge", charge);
68
69 // Momentum
70 double p = 0;
71 if (std::abs(qop) > 1e-9) {
72 p = 1.0 / std::abs(qop);
73 }
74 histograms_.fill("track_p", p);
75
76 // Momentum components (approximate from angles and magnitude)
77 double px = p * std::sin(theta) * std::cos(phi);
78 double py = p * std::sin(theta) * std::sin(phi);
79 double pz = p * std::cos(theta);
80
81 double pt = std::sqrt(px * px + py * py);
82 histograms_.fill("track_px", px);
83 histograms_.fill("track_py", py);
84 histograms_.fill("track_pz", pz);
85 histograms_.fill("track_pt", pt);
86
87 // Position at ECAL front (from d0, z0)
88 // d0 and z0 are in the perigee frame
89 double x = -d0 * std::sin(phi); // Approximate x position
90 double y = d0 * std::cos(phi); // Approximate y position
91
92 histograms_.fill("track_x", x);
93 histograms_.fill("track_y", y);
94 histograms_.fill("track_xy", x, y);
95
96 // 2D correlations
97 histograms_.fill("track_nhits_vs_chi2", nhits, chi2);
98 histograms_.fill("track_nhits_vs_chi2_ndf", nhits, (ndf > 0) ? chi2 / ndf : 0.0);
99 histograms_.fill("track_chi2_vs_nhits", chi2, nhits);
100 histograms_.fill("track_p_vs_chi2", p, chi2);
101 histograms_.fill("track_p_vs_nhits", p, nhits);
102 histograms_.fill("track_p_vs_theta", p, theta);
103
104 // If multiple tracks, fill special histograms
105 if (n_tracks > 1) {
106 histograms_.fill("track_p_multitracks", p);
107
108 // Calculate angular separation between tracks
109 for (size_t j_track = i_track + 1; j_track < ecal_tracks.size();
110 ++j_track) {
111 const auto& other_track = ecal_tracks[j_track];
112
113 double phi1 = track.getPhi();
114 double theta1 = track.getTheta();
115 double phi2 = other_track.getPhi();
116 double theta2 = other_track.getTheta();
117
118 // Direction vectors
119 double dx1 = std::sin(theta1) * std::cos(phi1);
120 double dy1 = std::sin(theta1) * std::sin(phi1);
121 double dz1 = std::cos(theta1);
122
123 double dx2 = std::sin(theta2) * std::cos(phi2);
124 double dy2 = std::sin(theta2) * std::sin(phi2);
125 double dz2 = std::cos(theta2);
126
127 // Dot product
128 double dot = dx1 * dx2 + dy1 * dy2 + dz1 * dz2;
129 double angle = std::acos(std::max(-1.0, std::min(1.0, dot)));
130
131 histograms_.fill("track_separation", angle);
132 }
133 }
134 }
135
136 ldmx_log(debug) << "Analyzed " << n_tracks << " ECAL tracks";
137}
std::string track_collection_
ECAL track collection name.
std::string track_pass_name_
Pass name for tracks.
HistogramPool histograms_
helper object for making and filling histograms
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
void fill(const std::string &name, const T &val)
Fill a 1D histogram.
Implementation of a track object.
Definition Track.h:53

References framework::Event::exists(), framework::HistogramPool::fill(), framework::EventProcessor::histograms_, track_collection_, and track_pass_name_.

◆ configure()

void dqm::EcalTrackAnalyzer::configure ( framework::config::Parameters & ps)
overridevirtual

Configure the analyzer.

Reimplemented from framework::EventProcessor.

Definition at line 12 of file EcalTrackAnalyzer.cxx.

12 {
13 track_collection_ = ps.get<std::string>("track_collection");
14 track_pass_name_ = ps.get<std::string>("track_pass_name");
15 rec_hit_collection_ = ps.get<std::string>("rec_hit_collection");
16 rec_hit_pass_name_ = ps.get<std::string>("rec_hit_pass_name");
17}
std::string rec_hit_pass_name_
Pass name for RecHits.
std::string rec_hit_collection_
ECAL RecHit collection (for layer occupancy)
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

References framework::config::Parameters::get(), rec_hit_collection_, rec_hit_pass_name_, track_collection_, and track_pass_name_.

Member Data Documentation

◆ rec_hit_collection_

std::string dqm::EcalTrackAnalyzer::rec_hit_collection_ {"EcalRecHits"}
private

ECAL RecHit collection (for layer occupancy)

Definition at line 61 of file EcalTrackAnalyzer.h.

61{"EcalRecHits"};

Referenced by configure().

◆ rec_hit_pass_name_

std::string dqm::EcalTrackAnalyzer::rec_hit_pass_name_ {""}
private

Pass name for RecHits.

Definition at line 64 of file EcalTrackAnalyzer.h.

64{""};

Referenced by configure().

◆ track_collection_

std::string dqm::EcalTrackAnalyzer::track_collection_ {"EcalTracks"}
private

ECAL track collection name.

Definition at line 55 of file EcalTrackAnalyzer.h.

55{"EcalTracks"};

Referenced by analyze(), and configure().

◆ track_pass_name_

std::string dqm::EcalTrackAnalyzer::track_pass_name_ {""}
private

Pass name for tracks.

Definition at line 58 of file EcalTrackAnalyzer.h.

58{""};

Referenced by analyze(), and configure().


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