File indexing completed on 2025-07-01 07:56:15
0001
0002
0003
0004 #include "SimHitAnalysis.h"
0005
0006 namespace benchmarks {
0007
0008
0009
0010 void SimHitAnalysis::AlgorithmInit(
0011 std::shared_ptr<spdlog::logger>& logger
0012 )
0013 {
0014 m_log = logger;
0015
0016
0017 m_nphot_dist = new TH1D("nphot_dist", "Number of incident photons;N_{photons}",
0018 Tools::nphot_max, 0, Tools::nphot_max
0019 );
0020 m_nphot_vs_p = new TH2D("nphot_vs_p", "Number of incident photons vs. Thrown Momentum;p [GeV];N_{photons}",
0021 Tools::momentum_bins, 0, Tools::momentum_max,
0022 Tools::nphot_max, 0, Tools::nphot_max
0023 );
0024 m_nphot_vs_p__transient = new TH1D("nphot_vs_p__transient", "",
0025 m_nphot_vs_p->GetNbinsX(),
0026 m_nphot_vs_p->GetXaxis()->GetXmin(),
0027 m_nphot_vs_p->GetXaxis()->GetXmax()
0028 );
0029 m_phot_spectrum = new TH1D(
0030 "phot_spectrum_sim",
0031 "Incident photon wavelength;#lambda [nm], at emission point",
0032 Tools::wl_bins, Tools::wl_min, Tools::wl_max
0033 );
0034 m_phot_spectrum->SetLineColor(kViolet+2);
0035 m_phot_spectrum->SetFillColor(kViolet+2);
0036 m_nphot_dist->SetLineColor(kCyan+2);
0037 m_nphot_dist->SetFillColor(kCyan+2);
0038 }
0039
0040
0041
0042
0043 void SimHitAnalysis::AlgorithmProcess(
0044 const edm4hep::MCParticleCollection& mc_parts,
0045 const edm4hep::SimTrackerHitCollection& sim_hits
0046 )
0047 {
0048
0049
0050 auto part = std::make_unique<ChargedParticle>(m_log);
0051 part->SetSingleParticle(mc_parts);
0052 auto thrown_momentum = part->GetMomentum();
0053
0054
0055 m_nphot_dist->Fill(sim_hits.size());
0056
0057
0058 for(const auto& sim_hit : sim_hits) {
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 m_nphot_vs_p__transient->Fill(thrown_momentum);
0069
0070
0071 auto wavelength = Tools::GetPhotonWavelength(sim_hit, m_log);
0072 if(wavelength>=0)
0073 m_phot_spectrum->Fill(wavelength);
0074 }
0075
0076
0077 for(int b=1; b<=m_nphot_vs_p__transient->GetNbinsX(); b++) {
0078 auto nphot = m_nphot_vs_p__transient->GetBinContent(b);
0079 if(nphot>0) {
0080 auto momentum = m_nphot_vs_p__transient->GetBinCenter(b);
0081 m_nphot_vs_p->Fill(momentum,nphot);
0082 }
0083 }
0084
0085
0086 m_nphot_vs_p__transient->Reset();
0087
0088 }
0089
0090
0091
0092
0093 void SimHitAnalysis::AlgorithmFinish() {
0094
0095 delete m_nphot_vs_p__transient;
0096 }
0097
0098 }