diff --git a/DQM/include/DQM/TrkDeDxMassEstFeatures.h b/DQM/include/DQM/TrkDeDxMassEstFeatures.h new file mode 100644 index 000000000..ac2c25308 --- /dev/null +++ b/DQM/include/DQM/TrkDeDxMassEstFeatures.h @@ -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 */ diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 3d66bc76d..88bd9882a 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -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 @@ -712,6 +736,9 @@ def __init__(self, name='SampleValidation') : RecoilTrackerDQM() ] +dEdx_dqm = [ + TrkDeDxMassEstFeatures() + ] trigScint_dqm = [ TrigScintSimDQM('TrigScintSimPad1','TriggerPad1SimHits','pad1'), diff --git a/DQM/src/DQM/TrkDeDxMassEstFeatures.cxx b/DQM/src/DQM/TrkDeDxMassEstFeatures.cxx new file mode 100644 index 000000000..4e3d5a15e --- /dev/null +++ b/DQM/src/DQM/TrkDeDxMassEstFeatures.cxx @@ -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("mass_estimate_name"); + mass_estimate_pass_ = ps.getParameter("mass_estimate_pass"); + + return; +} + +void TrkDeDxMassEstFeatures::analyze(const framework::Event &event) { + auto massEstimates{ + event.getCollection(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 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);