diff --git a/DQM/include/DQM/SampleValidation.h b/DQM/include/DQM/SampleValidation.h new file mode 100644 index 000000000..4d9846e91 --- /dev/null +++ b/DQM/include/DQM/SampleValidation.h @@ -0,0 +1,38 @@ +#ifndef DQM_SAMPLEVALIDATION_H +#define DQM_SAMPLEVALIDATION_H + +//LDMX Framework +#include "Framework/Configure/Parameters.h" +#include "Framework/EventProcessor.h" + +namespace dqm { + + /** + * @class SampleValidation + * @brief + */ + + class SampleValidation : public framework::Analyzer { + public: + + SampleValidation(const std::string& name, framework::Process& process) : Analyzer(name, process) {} + + virtual void configure(framework::config::Parameters& ps); + + virtual void analyze(const framework::Event& event); + + virtual void onFileOpen(framework::EventFile&); + + virtual void onFileClose(framework::EventFile&); + + virtual void onProcessStart(); + + virtual void onProcessEnd(); + + private: + + }; + +} + +#endif diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 7e5320c98..ac43db27e 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -562,6 +562,25 @@ def __init__(self,name='Trigger',coll='Trigger') : self.trigger_name = coll self.trigger_pass = '' + +class SampleValidation(ldmxcfg.Analyzer) : + def __init__(self, name='SampleValidation') : + super().__init__(name, 'dqm::SampleValidation', 'DQM') + + # primary histograms + self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 2714, -500, 2213) + self.build1DHistogram("energy_primaries", "Energy of primary particles", 50, 0, 5000) # range applicable for 4 GeV beam + self.build2DHistogram("beam_smear", "x", 30, -150, 150, "y", 30, -150, 150) + + # primary daughter of interest (brem / dark brem) histograms + self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughters", 2714, -500, 2213) + self.build1DHistogram("startZ_hardbrem", "Start z position of hard primary daughter", 100, -500, 500) + self.build1DHistogram("endZ_hardbrem", "End z position of hard primary daughter", 100, -500, 500) + self.build1DHistogram("energy_hardbrem", "Energy spectrum of hard primary daughter", 50, 2000, 4500) + + # daughters of hard brem histograms + self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 2714, -500, 2213) + self.build1DHistogram("startZ_hardbremdaughters", "Start z position of hard brem daughters", 200, -1000, 1000) ecal_dqm = [ diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx new file mode 100644 index 000000000..9f1ff75a6 --- /dev/null +++ b/DQM/src/DQM/SampleValidation.cxx @@ -0,0 +1,97 @@ +#include "DQM/SampleValidation.h" +#include "SimCore/Event/SimParticle.h" +#include "Framework/NtupleManager.h" +#include +#include +#include + +namespace dqm { + + void SampleValidation::configure(framework::config::Parameters& ps) { + + return; + } + + void SampleValidation::analyze(const framework::Event& event) { + + //Grab the SimParticle Map + auto particle_map{event.getMap("SimParticles")}; + + std::vector primary_daughters; + + //Loop over all SimParticles + for (auto const& it : particle_map) { + ldmx::SimParticle p = it.second; + int pdgid = p.getPdgID(); + std::vector vertex = p.getVertex(); + double energy = p.getEnergy(); + std::vector parents_track_ids = p.getParents(); + std::vector daughters = p.getDaughters(); + + for (auto const& parent_track_id: parents_track_ids) { + if (parent_track_id == 0) { + histograms_.fill("beam_smear", vertex[0], vertex[1]); + histograms_.fill("pdgid_primaries", pdgid); + histograms_.fill("energy_primaries", energy); + primary_daughters = daughters; + } + } + } + + std::vector> hardbrem_daughters; + + for (auto const& it : particle_map) { + int trackid = it.first; + ldmx::SimParticle p = it.second; + for (auto const& primary_daughter : primary_daughters) { + if (trackid == primary_daughter) { + histograms_.fill("pdgid_primarydaughters", p.getPdgID()); + if (p.getEnergy() >= 2500) { + histograms_.fill("startZ_hardbrem", p.getVertex()[2]); + histograms_.fill("endZ_hardbrem", p.getEndPoint()[2]); + histograms_.fill("energy_hardbrem", p.getEnergy()); + hardbrem_daughters.push_back(p.getDaughters()); + } + } + } + } + + for (auto const& it : particle_map) { + int trackid = it.first; + ldmx::SimParticle p = it.second; + for (const std::vector &daughter_track_id : hardbrem_daughters){ + for (const int &daughter_id : daughter_track_id) { + if (trackid == daughter_id) { + histograms_.fill("pdgid_hardbremdaughters", p.getPdgID()); + histograms_.fill("startZ_hardbremdaughters", p.getVertex()[2]); + } + } + } + } + + + return; + } + + void SampleValidation::onFileOpen(framework::EventFile&) { + + return; + } + + void SampleValidation::onFileClose(framework::EventFile&) { + + return; + } + + void SampleValidation::onProcessStart() { + + return; + } + + void SampleValidation::onProcessEnd() { + + return; + } +} + +DECLARE_ANALYZER_NS(dqm, SampleValidation)