From 043c3f1753a7553b2d698d2ae795251bc24a5d4d Mon Sep 17 00:00:00 2001 From: Horoho Date: Thu, 5 Oct 2023 08:15:44 -0700 Subject: [PATCH 01/11] Sample scripts for validating future samples --- DQM/include/DQM/SampleValidation.h | 38 ++++++++++++ DQM/python/dqm.py | 19 ++++++ DQM/src/DQM/SampleValidation.cxx | 97 ++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 DQM/include/DQM/SampleValidation.h create mode 100644 DQM/src/DQM/SampleValidation.cxx 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 ecb71a0b7..e2de6537f 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -594,6 +594,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) From 91d70ed3de9262d492706e4590c13978702713a2 Mon Sep 17 00:00:00 2001 From: Tyler Horoho <76532377+tylerhoroho-UVA@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:54:23 -0500 Subject: [PATCH 02/11] Trimming undefined functions Co-authored-by: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com> --- DQM/src/DQM/SampleValidation.cxx | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index 9f1ff75a6..9b68a7d75 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -70,26 +70,6 @@ namespace dqm { } - return; - } - - void SampleValidation::onFileOpen(framework::EventFile&) { - - return; - } - - void SampleValidation::onFileClose(framework::EventFile&) { - - return; - } - - void SampleValidation::onProcessStart() { - - return; - } - - void SampleValidation::onProcessEnd() { - return; } } From bd0ebe5d5a1336eadbc380f53c0651081c937e7f Mon Sep 17 00:00:00 2001 From: Tyler Horoho <76532377+tylerhoroho-UVA@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:54:38 -0500 Subject: [PATCH 03/11] Trimming undefined functions Co-authored-by: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com> --- DQM/include/DQM/SampleValidation.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/DQM/include/DQM/SampleValidation.h b/DQM/include/DQM/SampleValidation.h index 4d9846e91..4433ef902 100644 --- a/DQM/include/DQM/SampleValidation.h +++ b/DQM/include/DQM/SampleValidation.h @@ -20,15 +20,6 @@ namespace dqm { 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: }; From 909d2b2b39e5de65337452f163f05c6c4b5d9b4f Mon Sep 17 00:00:00 2001 From: Horoho Date: Wed, 8 Nov 2023 08:46:08 -0800 Subject: [PATCH 04/11] A few changes that allow SampleValidation to work at 4 or 8 GeV --- DQM/include/DQM/SampleValidation.h | 2 + DQM/python/dqm.py | 10 ++--- DQM/src/DQM/SampleValidation.cxx | 63 ++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/DQM/include/DQM/SampleValidation.h b/DQM/include/DQM/SampleValidation.h index 4433ef902..b8ef8e26f 100644 --- a/DQM/include/DQM/SampleValidation.h +++ b/DQM/include/DQM/SampleValidation.h @@ -20,6 +20,8 @@ namespace dqm { virtual void configure(framework::config::Parameters& ps); virtual void analyze(const framework::Event& event); + + int pdgid_label(const int pdgid); private: }; diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index e2de6537f..59413078a 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -600,18 +600,18 @@ 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.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 18, 0, 18) + self.build1DHistogram("energy_primaries", "Energy of primary particles", 90, 0, 9000) # 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("pdgid_primarydaughters", "PDG ID of primary daughters", 18, 0, 18) 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) + self.build1DHistogram("energy_hardbrem", "Energy spectrum of hard primary daughter", 130, 2000, 8500) # daughters of hard brem histograms - self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 2714, -500, 2213) + self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 18, 0, 18) self.build1DHistogram("startZ_hardbremdaughters", "Start z position of hard brem daughters", 200, -1000, 1000) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index 9b68a7d75..7f0a7bbbd 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -1,5 +1,6 @@ #include "DQM/SampleValidation.h" #include "SimCore/Event/SimParticle.h" +#include "SimCore/Event/SimTrackerHit.h" #include "Framework/NtupleManager.h" #include #include @@ -14,12 +15,15 @@ namespace dqm { void SampleValidation::analyze(const framework::Event& event) { - //Grab the SimParticle Map + //Grab the SimParticle Map and Target Scoring Plane Hits + auto targetSPHits(event.getCollection("TargetScoringPlaneHits")); auto particle_map{event.getMap("SimParticles")}; std::vector primary_daughters; - //Loop over all SimParticles + double hard_thresh = 2500; + + //Loop over all SimParticles for (auto const& it : particle_map) { ldmx::SimParticle p = it.second; int pdgid = p.getPdgID(); @@ -30,10 +34,17 @@ namespace dqm { 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("pdgid_primaries", pdgid_label(pdgid)); histograms_.fill("energy_primaries", energy); + if (energy > 4000) { + hard_thresh = 5000; + } primary_daughters = daughters; + for (const ldmx::SimTrackerHit &sphit : targetSPHits) { + if (sphit.getTrackID() == it.first && sphit.getPosition()[2] < 0) { + histograms_.fill("beam_smear", vertex[0], vertex[1]); + } + } } } } @@ -45,8 +56,8 @@ namespace dqm { 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("pdgid_primarydaughters", pdgid_label(p.getPdgID())); + if (p.getEnergy() >= hard_thresh) { histograms_.fill("startZ_hardbrem", p.getVertex()[2]); histograms_.fill("endZ_hardbrem", p.getEndPoint()[2]); histograms_.fill("energy_hardbrem", p.getEnergy()); @@ -62,7 +73,7 @@ namespace dqm { 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("pdgid_hardbremdaughters", pdgid_label(p.getPdgID())); histograms_.fill("startZ_hardbremdaughters", p.getVertex()[2]); } } @@ -72,6 +83,44 @@ namespace dqm { return; } + + int SampleValidation::pdgid_label(const int pdgid) { + int label = 0; + if (pdgid == -11) label = 1; // e+ + + if (pdgid == 11) label = 2; // e- + + if (pdgid == -13) label = 3; // μ+ + + if (pdgid == 13) label = 4; // μ- + + if (pdgid == 22) label = 5; // γ + + if (pdgid == 2212) label = 6; // proton + + if (pdgid == 2112) label = 7; // neutron + + if (pdgid == 211) label = 8; //π+ + + if (pdgid == -211) label = 9; //π- + + if (pdgid == 111) label = 10; //π0 + + if (pdgid == 321) label = 11; // K+ + + if (pdgid == -321) label = 12; // K- + + if (pdgid == 130) label = 13; // K-Long + + if (pdgid == 310) label = 14; // K-Short + + if (pdgid > 2300) label = 16; //exotic (e.g., baryon with strangeness) + + if (pdgid > 10000) label = 15; //nuclei + + return label; + } + } DECLARE_ANALYZER_NS(dqm, SampleValidation) From b407ba3b8697503474278b5947167c14140cd333 Mon Sep 17 00:00:00 2001 From: Horoho Date: Wed, 8 Nov 2023 13:37:17 -0800 Subject: [PATCH 05/11] Changed threshold for 4 or 8 GeV hard brem selection --- DQM/src/DQM/SampleValidation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index 7f0a7bbbd..04485cefc 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -36,7 +36,7 @@ namespace dqm { if (parent_track_id == 0) { histograms_.fill("pdgid_primaries", pdgid_label(pdgid)); histograms_.fill("energy_primaries", energy); - if (energy > 4000) { + if (energy > 4001) { hard_thresh = 5000; } primary_daughters = daughters; From 73497ed71fe228460e4645174e6d15503127819a Mon Sep 17 00:00:00 2001 From: Horoho Date: Wed, 8 Nov 2023 13:38:52 -0800 Subject: [PATCH 06/11] Adding ability to compare two different files --- Validation/src/Validation/__init__.py | 1 + Validation/src/Validation/simparticles.py | 45 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Validation/src/Validation/simparticles.py diff --git a/Validation/src/Validation/__init__.py b/Validation/src/Validation/__init__.py index e75aa91c1..76d6a9e63 100644 --- a/Validation/src/Validation/__init__.py +++ b/Validation/src/Validation/__init__.py @@ -7,3 +7,4 @@ from . import hcal from . import photonuclear from . import dark_brem +from . import simparticles diff --git a/Validation/src/Validation/simparticles.py b/Validation/src/Validation/simparticles.py new file mode 100644 index 000000000..188b39ebe --- /dev/null +++ b/Validation/src/Validation/simparticles.py @@ -0,0 +1,45 @@ +from ._differ import Differ +from ._plotter import plotter +import logging + +log = logging.getLogger('8GeV') + +@plotter(hist=True, event=False) +def beamenergy_comp(d: Differ, out_dir=None): + + pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', ''] # finish later + + d.plot1d("SampleValidation/SampleValidation_pdgid_primaries", "PDG ID, primaries", + tick_labels=pdgid_labels, + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_energy_primaries", "Energy of primaries (MeV)", + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_pdgid_primarydaughters", "PDG ID, primary daughters", + tick_labels=pdgid_labels, + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_startZ_hardbrem", "Start z position of hard primary daughter", + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_endZ_hardbrem", "End z position of hard primary daughter", + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_energy_hardbrem", "Energy spectrum of hard primary daughter", + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_pdgid_hardbremdaughters", "PDG ID, hard brem daughters", + tick_labels=pdgid_labels, + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_startZ_hardbremdaughters", "Start z position of hard brem daughters", + out_dir=out_dir, + density=True) From c376dfa723d023bf9c34c74bf9d0c4f3a5ef39dd Mon Sep 17 00:00:00 2001 From: Horoho Date: Tue, 14 Nov 2023 12:44:51 -0800 Subject: [PATCH 07/11] Adding A' as tick mark in pdgid plot --- DQM/python/dqm.py | 4 +++- DQM/src/DQM/SampleValidation.cxx | 6 ++++++ Validation/src/Validation/simparticles.py | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 59413078a..85c913438 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -603,9 +603,11 @@ def __init__(self, name='SampleValidation') : self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 18, 0, 18) self.build1DHistogram("energy_primaries", "Energy of primary particles", 90, 0, 9000) # range applicable for 4 GeV beam self.build2DHistogram("beam_smear", "x", 30, -150, 150, "y", 30, -150, 150) + self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughtesr", 18, 0, 18) + self.build1DHistogram("energy_daughterphoton", "Energy spectrum of all photons from primary", 170, 0, 8500) # primary daughter of interest (brem / dark brem) histograms - self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughters", 18, 0, 18) + self.build1DHistogram("pdgid_harddaughters", "PDG ID of primary daughters", 18, 0, 18) 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", 130, 2000, 8500) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index 04485cefc..99a08dde4 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -57,7 +57,11 @@ namespace dqm { for (auto const& primary_daughter : primary_daughters) { if (trackid == primary_daughter) { histograms_.fill("pdgid_primarydaughters", pdgid_label(p.getPdgID())); + if (p.getPdgID() == 22) { + histograms_.fill("energy_daughterphoton", p.getEnergy()); + } if (p.getEnergy() >= hard_thresh) { + histograms_.fill("pdgid_harddaughters", pdgid_label(p.getPdgID())); histograms_.fill("startZ_hardbrem", p.getVertex()[2]); histograms_.fill("endZ_hardbrem", p.getEndPoint()[2]); histograms_.fill("energy_hardbrem", p.getEnergy()); @@ -117,6 +121,8 @@ namespace dqm { if (pdgid > 2300) label = 16; //exotic (e.g., baryon with strangeness) if (pdgid > 10000) label = 15; //nuclei + + if (pdgid == 622) label = 17; // dark photon return label; } diff --git a/Validation/src/Validation/simparticles.py b/Validation/src/Validation/simparticles.py index 188b39ebe..1992593ef 100644 --- a/Validation/src/Validation/simparticles.py +++ b/Validation/src/Validation/simparticles.py @@ -7,7 +7,7 @@ @plotter(hist=True, event=False) def beamenergy_comp(d: Differ, out_dir=None): - pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', ''] # finish later + pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', "A'"] # finish later d.plot1d("SampleValidation/SampleValidation_pdgid_primaries", "PDG ID, primaries", tick_labels=pdgid_labels, @@ -22,6 +22,14 @@ def beamenergy_comp(d: Differ, out_dir=None): tick_labels=pdgid_labels, out_dir=out_dir, density=True) + d.plot1d("SampleValidation/SampleValidation_energy_daughterphoton", "Energy spectrum of all photons from primary", + out_dir=out_dir, + density=True) + + d.plot1d("SampleValidation/SampleValidation_pdgid_harddaughters" "PDG ID of hard primary daughter", + tick_labels=pdgid_labels, + out_dir=out_dir, + density=True) d.plot1d("SampleValidation/SampleValidation_startZ_hardbrem", "Start z position of hard primary daughter", out_dir=out_dir, From b3f00735fe499956b96f4ea36dec75245e4ecf8d Mon Sep 17 00:00:00 2001 From: Horoho Date: Wed, 15 Nov 2023 10:54:17 -0800 Subject: [PATCH 08/11] Added missing comma in one plot --- Validation/src/Validation/simparticles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/src/Validation/simparticles.py b/Validation/src/Validation/simparticles.py index 1992593ef..92006a0b1 100644 --- a/Validation/src/Validation/simparticles.py +++ b/Validation/src/Validation/simparticles.py @@ -7,7 +7,7 @@ @plotter(hist=True, event=False) def beamenergy_comp(d: Differ, out_dir=None): - pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', "A'"] # finish later + pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', "A\'"] # finish later d.plot1d("SampleValidation/SampleValidation_pdgid_primaries", "PDG ID, primaries", tick_labels=pdgid_labels, @@ -26,7 +26,7 @@ def beamenergy_comp(d: Differ, out_dir=None): out_dir=out_dir, density=True) - d.plot1d("SampleValidation/SampleValidation_pdgid_harddaughters" "PDG ID of hard primary daughter", + d.plot1d("SampleValidation/SampleValidation_pdgid_harddaughters", "PDG ID of hard primary daughter", tick_labels=pdgid_labels, out_dir=out_dir, density=True) From 7feeefff137a38bdd1b10c02f021bba02f274cf3 Mon Sep 17 00:00:00 2001 From: Horoho Date: Mon, 20 Nov 2023 11:06:27 -0800 Subject: [PATCH 09/11] Splitting strange baryons from exotics in PDG ID plot --- DQM/python/dqm.py | 8 ++++---- DQM/src/DQM/SampleValidation.cxx | 10 ++++------ Validation/src/Validation/simparticles.py | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 85c913438..8c191af5d 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -600,20 +600,20 @@ def __init__(self, name='SampleValidation') : super().__init__(name, 'dqm::SampleValidation', 'DQM') # primary histograms - self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 18, 0, 18) + self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 19, 0, 19) self.build1DHistogram("energy_primaries", "Energy of primary particles", 90, 0, 9000) # range applicable for 4 GeV beam self.build2DHistogram("beam_smear", "x", 30, -150, 150, "y", 30, -150, 150) - self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughtesr", 18, 0, 18) + self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughtesr", 19, 0, 19) self.build1DHistogram("energy_daughterphoton", "Energy spectrum of all photons from primary", 170, 0, 8500) # primary daughter of interest (brem / dark brem) histograms - self.build1DHistogram("pdgid_harddaughters", "PDG ID of primary daughters", 18, 0, 18) + self.build1DHistogram("pdgid_harddaughters", "PDG ID of primary daughters", 19, 0, 19) 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", 130, 2000, 8500) # daughters of hard brem histograms - self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 18, 0, 18) + self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 19, 0, 19) self.build1DHistogram("startZ_hardbremdaughters", "Start z position of hard brem daughters", 200, -1000, 1000) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index 99a08dde4..e1cd2c860 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -36,9 +36,7 @@ namespace dqm { if (parent_track_id == 0) { histograms_.fill("pdgid_primaries", pdgid_label(pdgid)); histograms_.fill("energy_primaries", energy); - if (energy > 4001) { - hard_thresh = 5000; - } + hard_thresh = (2500/4000)*energy; primary_daughters = daughters; for (const ldmx::SimTrackerHit &sphit : targetSPHits) { if (sphit.getTrackID() == it.first && sphit.getPosition()[2] < 0) { @@ -89,7 +87,7 @@ namespace dqm { } int SampleValidation::pdgid_label(const int pdgid) { - int label = 0; + int label = 18; if (pdgid == -11) label = 1; // e+ if (pdgid == 11) label = 2; // e- @@ -118,11 +116,11 @@ namespace dqm { if (pdgid == 310) label = 14; // K-Short - if (pdgid > 2300) label = 16; //exotic (e.g., baryon with strangeness) + if (pdgid == 3122 || pdgid == 3222 || pdgid == 3212 || pdgid == 3112 || pdgid == 3322 || pdgid == 3312) label = 16; // strange baryon if (pdgid > 10000) label = 15; //nuclei - if (pdgid == 622) label = 17; // dark photon + if (pdgid == 622) label = 17; // dark photon, need pdg id for other models like ALPs and SIMPs return label; } diff --git a/Validation/src/Validation/simparticles.py b/Validation/src/Validation/simparticles.py index 92006a0b1..50bf0e489 100644 --- a/Validation/src/Validation/simparticles.py +++ b/Validation/src/Validation/simparticles.py @@ -7,7 +7,7 @@ @plotter(hist=True, event=False) def beamenergy_comp(d: Differ, out_dir=None): - pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'exotic', "A\'"] # finish later + pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'strange baryon', "A\'", 'something else'] # finish later d.plot1d("SampleValidation/SampleValidation_pdgid_primaries", "PDG ID, primaries", tick_labels=pdgid_labels, From e141757e9c016b50dca19619bbdbf756e6754f6f Mon Sep 17 00:00:00 2001 From: Horoho Date: Tue, 21 Nov 2023 09:24:19 -0800 Subject: [PATCH 10/11] Added comment on pdg id label for code readability --- DQM/src/DQM/SampleValidation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index e1cd2c860..d00f922b9 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -87,7 +87,7 @@ namespace dqm { } int SampleValidation::pdgid_label(const int pdgid) { - int label = 18; + int label = 18; // initially assign label as "anything else"/overflow value, only change if the pdg id is something of interest if (pdgid == -11) label = 1; // e+ if (pdgid == 11) label = 2; // e- From 26bbe9de49d1e08d2213148a24c05ee85ebc0379 Mon Sep 17 00:00:00 2001 From: Horoho Date: Mon, 27 Nov 2023 12:57:29 -0800 Subject: [PATCH 11/11] Added distinction between light and heavy nuclei in PDG ID plots --- DQM/python/dqm.py | 8 ++++---- DQM/src/DQM/SampleValidation.cxx | 23 ++++++++++++++++++----- Validation/src/Validation/simparticles.py | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 8c191af5d..240bfb860 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -600,20 +600,20 @@ def __init__(self, name='SampleValidation') : super().__init__(name, 'dqm::SampleValidation', 'DQM') # primary histograms - self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 19, 0, 19) + self.build1DHistogram("pdgid_primaries", "PDG ID of primary particles", 20, 0, 20) self.build1DHistogram("energy_primaries", "Energy of primary particles", 90, 0, 9000) # range applicable for 4 GeV beam self.build2DHistogram("beam_smear", "x", 30, -150, 150, "y", 30, -150, 150) - self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughtesr", 19, 0, 19) + self.build1DHistogram("pdgid_primarydaughters", "PDG ID of primary daughtesr", 20, 0, 20) self.build1DHistogram("energy_daughterphoton", "Energy spectrum of all photons from primary", 170, 0, 8500) # primary daughter of interest (brem / dark brem) histograms - self.build1DHistogram("pdgid_harddaughters", "PDG ID of primary daughters", 19, 0, 19) + self.build1DHistogram("pdgid_harddaughters", "PDG ID of primary daughters", 20, 0, 20) 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", 130, 2000, 8500) # daughters of hard brem histograms - self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 19, 0, 19) + self.build1DHistogram("pdgid_hardbremdaughters", "PDG ID of hard brem daughters", 20, 0, 20) self.build1DHistogram("startZ_hardbremdaughters", "Start z position of hard brem daughters", 200, -1000, 1000) diff --git a/DQM/src/DQM/SampleValidation.cxx b/DQM/src/DQM/SampleValidation.cxx index d00f922b9..a03652c66 100644 --- a/DQM/src/DQM/SampleValidation.cxx +++ b/DQM/src/DQM/SampleValidation.cxx @@ -21,7 +21,7 @@ namespace dqm { std::vector primary_daughters; - double hard_thresh = 2500; + double hard_thresh; //Loop over all SimParticles for (auto const& it : particle_map) { @@ -87,7 +87,7 @@ namespace dqm { } int SampleValidation::pdgid_label(const int pdgid) { - int label = 18; // initially assign label as "anything else"/overflow value, only change if the pdg id is something of interest + int label = 19; // initially assign label as "anything else"/overflow value, only change if the pdg id is something of interest if (pdgid == -11) label = 1; // e+ if (pdgid == 11) label = 2; // e- @@ -116,11 +116,24 @@ namespace dqm { if (pdgid == 310) label = 14; // K-Short - if (pdgid == 3122 || pdgid == 3222 || pdgid == 3212 || pdgid == 3112 || pdgid == 3322 || pdgid == 3312) label = 16; // strange baryon + if (pdgid == 3122 || pdgid == 3222 || pdgid == 3212 || pdgid == 3112 || pdgid == 3322 || pdgid == 3312) label = 17; // strange baryon + + /* + * Nuclear PDG codes are given by ±10LZZZAAAI so to find the atomic + * number, we divide by 10 (to lose I) and then take the modulo + * with 1000. + */ - if (pdgid > 10000) label = 15; //nuclei + if (pdgid > 1000000000) { //nuclei + if (((pdgid / 10) % 1000) <= 4) { + label = 15; // light nuclei + } + else { + label = 16; // heavy nuclei + } + } - if (pdgid == 622) label = 17; // dark photon, need pdg id for other models like ALPs and SIMPs + if (pdgid == 622) label = 18; // dark photon, need pdg id for other models like ALPs and SIMPs return label; } diff --git a/Validation/src/Validation/simparticles.py b/Validation/src/Validation/simparticles.py index 50bf0e489..af15bb65b 100644 --- a/Validation/src/Validation/simparticles.py +++ b/Validation/src/Validation/simparticles.py @@ -7,7 +7,7 @@ @plotter(hist=True, event=False) def beamenergy_comp(d: Differ, out_dir=None): - pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'nucleus', 'strange baryon', "A\'", 'something else'] # finish later + pdgid_labels = ['', 'e+', 'e-', 'μ+', 'μ-', 'γ', 'p', 'n', 'π+', 'π-', 'π0', 'K+', 'K-', 'K-L', 'K-S', 'light nucleus', 'heavy nucleus', 'strange baryon', "A\'", 'something else'] # finish later d.plot1d("SampleValidation/SampleValidation_pdgid_primaries", "PDG ID, primaries", tick_labels=pdgid_labels,