Skip to content

Commit

Permalink
Create DQM module for dEdx mass estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
danyi211 committed Dec 11, 2024
1 parent 43f563a commit b826d66
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
46 changes: 46 additions & 0 deletions DQM/include/DQM/TrkDeDxMassEstFeatures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef DQM_TRKDEDXMASSESTFEATURES_H
#define DQM_TRKDEDXMASSESTFEATURES_H

// LDMX Framework
#include "Framework/Configure/Parameters.h" // Needed to import parameters from configuration file
#include "Framework/EventProcessor.h" //Needed to declare processor

namespace dqm {

/**
* @class TrkDeDxMassEstFeatures
* @brief Generate histograms to check tracker dE/dx mass estimate features
*/
class TrkDeDxMassEstFeatures : public framework::Analyzer {
public:
/**
* Constructor
*
* Blank Analyzer constructor
*/
TrkDeDxMassEstFeatures(const std::string& name, framework::Process& process)
: framework::Analyzer(name, process) {}

/**
* Input python configuration parameters
*/
virtual void configure(framework::config::Parameters& ps);

/**
* Fills histograms
*/
virtual void analyze(const framework::Event& event);

/// Method executed before processing of events begins.
void onProcessStart() override;

private:
/// Collection Name for mass estimate object
std::string mass_estimate_name_;

/// Pass Name for mass estimate object
std::string mass_estimate_pass_;
};
} // namespace dqm

#endif /* DQM_TRKDEDXMASSESTFEATURES_H */
27 changes: 27 additions & 0 deletions DQM/python/dqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,30 @@ def __init__(self,name='RecoilTracker') :
self.build1DHistogram("tpy%s" % t, "Recoil e^{-} Truth p_{y} (MeV)", 100, -10, 10)
self.build1DHistogram("tpz%s" % t, "Recoil e^{-} Truth p_{z} (MeV)", 260, -100, 2500)

class TrkDeDxMassEstFeatures(ldmxcfg.Analyzer) :
"""Configured TrkDeDxMassEstFeatures python object
Contains an instance of TrkDeDxMassEstFeatures that
has already been configured.
Builds the necessary histograms as well.
Examples
--------
from LDMX.DQM import dqm
p.sequence.append( dqm.TrkDeDxMassEstFeatures() )
"""

def __init__(self,name='TrkDeDxMassEstFeatures') :
super().__init__(name, "dqm::TrkDeDxMassEstFeatures",'DQM')

self.mass_estimate_name = "TrackDeDxMassEstimate"
self.mass_estimate_pass = ""

self.build1DHistogram("mass_estimate", "Mass Estimate [MeV]", 100, 0, 2000)
self.build1DHistogram("track_type", "Track Type", 3, 0, 3)


class TrigScintSimDQM(ldmxcfg.Analyzer) :
"""Configured TrigScintSimDQM python object
Expand Down Expand Up @@ -712,6 +736,9 @@ def __init__(self, name='SampleValidation') :
RecoilTrackerDQM()
]

dEdx_dqm = [
TrkDeDxMassEstFeatures()
]

trigScint_dqm = [
TrigScintSimDQM('TrigScintSimPad1','TriggerPad1SimHits','pad1'),
Expand Down
41 changes: 41 additions & 0 deletions DQM/src/DQM/TrkDeDxMassEstFeatures.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

#include "DQM/TrkDeDxMassEstFeatures.h"

#include "Recon/Event/TrackDeDxMassEstimate.h"

namespace dqm {

void TrkDeDxMassEstFeatures::configure(framework::config::Parameters &ps) {
mass_estimate_name_ = ps.getParameter<std::string>("mass_estimate_name");
mass_estimate_pass_ = ps.getParameter<std::string>("mass_estimate_pass");

return;
}

void TrkDeDxMassEstFeatures::analyze(const framework::Event &event) {
auto massEstimates{
event.getCollection<ldmx::TrackDeDxMassEstimate>(mass_estimate_name_,
mass_estimate_pass_)};

for (const auto &massEst : massEstimates) {
histograms_.fill("mass_estimate", massEst.getMass());
histograms_.fill("track_type", massEst.getTrackType());
}

return;
}

void TrkDeDxMassEstFeatures::onProcessStart() {
std::vector<std::string> labels = {"Other", // 0
"Tagger", // 1
"Recoil", // 2
""};
TH1 *hist = histograms_.get("track_type");
for (int ilabel{1}; ilabel < labels.size(); ++ilabel) {
hist->GetXaxis()->SetBinLabel(ilabel, labels[ilabel - 1].c_str());
}
}

} // namespace dqm

DECLARE_ANALYZER_NS(dqm, TrkDeDxMassEstFeatures);

0 comments on commit b826d66

Please sign in to comment.