Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:20:32

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file larceler/PDSimAna.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <map>
0010 #include <TH1D.h>
0011 #include <TH2D.h>
0012 #include <art/Framework/Core/EDAnalyzer.h>
0013 #include <canvas/Utilities/InputTag.h>
0014 #include <fhiclcpp/types/Atom.h>
0015 #include <fhiclcpp/types/Sequence.h>
0016 
0017 namespace sim
0018 {
0019 class SimEnergyDeposit;
0020 class OpDetBacktrackerRecord;
0021 class SimPhotonsLite;
0022 }  // namespace sim
0023 
0024 namespace celeritas
0025 {
0026 //---------------------------------------------------------------------------//
0027 /*!
0028  * Analyzer module that loads \c SimEnergyDeposit and \c OpDetBacktrackerRecord
0029  * data from an \c art::Event and generates output data for comparison.
0030  *
0031  * Related:
0032  * -
0033  * https://github.com/DUNE/duneopdet/blob/develop/duneopdet/OpticalDetector/Ana/OpDetAnalyzer.fcl
0034  */
0035 class PDSimAna : public art::EDAnalyzer
0036 {
0037   public:
0038     struct Config
0039     {
0040         fhicl::Atom<art::InputTag> SimulationLabel{
0041             fhicl::Name("SimulationLabel"),
0042             fhicl::Comment(R"(Module label containing SimEnergyDeposit)")};
0043 
0044         fhicl::Atom<art::InputTag> PDModuleLabel{
0045             fhicl::Name{"PDModuleLabel"},
0046             fhicl::Comment{R"(Module containing SimPhotonsLite/OpDetBTRs)"}};
0047 
0048         fhicl::Atom<unsigned int> NumChannels{
0049             fhicl::Name{"NumChannels"},
0050             fhicl::Comment{R"(Number of detector channels)"},
0051             480};
0052 
0053         fhicl::Atom<double> MinTime{
0054             fhicl::Name{"MinTime"},
0055             fhicl::Comment{R"(Minimum time for histogram binning [ns])"},
0056             10.0};
0057 
0058         fhicl::Atom<double> MaxTime{
0059             fhicl::Name{"MaxTime"},
0060             fhicl::Comment{R"(Maximum time for histogram binning [ns])"},
0061             20e3};
0062     };
0063     using Parameters = art::EDAnalyzer::Table<Config>;
0064 
0065   public:
0066     // Construct with input parameters and export geometry data
0067     explicit PDSimAna(Parameters const& p);
0068 
0069     //!@{
0070     // Prevent copy and assignment operations
0071     PDSimAna(PDSimAna const&) = delete;
0072     PDSimAna(PDSimAna&&) = delete;
0073     PDSimAna& operator=(PDSimAna const&) = delete;
0074     PDSimAna& operator=(PDSimAna&&) = delete;
0075     //!@}
0076 
0077     // Initialize output file(s) and data objects
0078     void beginJob() override;
0079 
0080     // Read art::Event and generate output data
0081     void analyze(art::Event const& event) override;
0082 
0083   private:
0084     struct Dims
0085     {
0086         unsigned int num_channels{0};
0087         double min_time{1e100};
0088         double max_time{0};
0089     };
0090 
0091     struct Histograms
0092     {
0093         using PDG = int;
0094 
0095         TH1D* edep_photons{nullptr};
0096         TH1D* hit_time{nullptr};
0097         std::map<PDG, TH1D*> pdg_edep_step_len;
0098         TH2D* photons_detid_time{nullptr};
0099     };
0100 
0101     // Fcl input data
0102     art::InputTag sim_tag_;
0103     art::InputTag pd_tag_;
0104     Dims inp_;
0105 
0106     // Mutable data
0107     Histograms hist_;
0108     // TODO: `Dims encountered_` for error reporting
0109 
0110     void fill(sim::SimEnergyDeposit const& edep);
0111     void fill(sim::SimPhotonsLite const& spl,
0112               sim::OpDetBacktrackerRecord const& btr);
0113 };
0114 
0115 //---------------------------------------------------------------------------//
0116 }  // namespace celeritas