-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample scripts for validating future samples
- Loading branch information
Horoho
committed
Oct 5, 2023
1 parent
0476ccc
commit e45118a
Showing
3 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#include "DQM/SampleValidation.h" | ||
#include "SimCore/Event/SimParticle.h" | ||
#include "Framework/NtupleManager.h" | ||
#include <iostream> | ||
#include <fstream> | ||
#include <algorithm> | ||
|
||
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<int, ldmx::SimParticle>("SimParticles")}; | ||
|
||
std::vector<int> primary_daughters; | ||
|
||
//Loop over all SimParticles | ||
for (auto const& it : particle_map) { | ||
ldmx::SimParticle p = it.second; | ||
int pdgid = p.getPdgID(); | ||
std::vector<double> vertex = p.getVertex(); | ||
double energy = p.getEnergy(); | ||
std::vector<int> parents_track_ids = p.getParents(); | ||
std::vector<int> 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<std::vector<int>> 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<int> &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) |