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/LarDataReader.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <string>
0011 #include <lardataobj/Simulation/SimEnergyDeposit.h>
0012 
0013 #include "corecel/Macros.hh"
0014 #include "corecel/Types.hh"
0015 #include "corecel/cont/Array.hh"  // IWYU pragma: keep
0016 
0017 #include "SimEnergyDepositData.hh"
0018 
0019 class TTree;
0020 class TFile;
0021 class TDirectory;
0022 
0023 namespace celeritas
0024 {
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * Helper class to read ROOT files produced by the \c GeoSimExporterModule .
0028  *
0029  * \sa GeoSimExporterModule
0030  */
0031 class LarDataReader
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using VecSimEdep = std::vector<sim::SimEnergyDeposit>;
0037     using VecOpDetCenter = std::vector<Real3>;
0038     //!@}
0039 
0040   public:
0041     // Construct with ROOT file name
0042     explicit LarDataReader(std::string name);
0043     ~LarDataReader();
0044     CELER_DELETE_COPY_MOVE(LarDataReader);
0045 
0046     // Return number of events
0047     size_type num_events() const;
0048 
0049     // Return vector of SimEnergyDeposit objects for a given event ID
0050     VecSimEdep read_event(size_type event_id) const;
0051 
0052     // Return detector name
0053     std::string detector_name() const;
0054 
0055     // Return all optical detector centers, indexed by optical detector ID
0056     VecOpDetCenter optical_detector_centers() const;
0057 
0058     //!@{
0059     //! \name ROOT directory and tree name accessors
0060     // TDirectory name created by art; all TTrees are stored in this directory
0061     char const* data_dir_name() const { return "data"; }
0062 
0063     // Detector information tree name
0064     char const* detector_info_tree_name() const { return "detector_info"; }
0065 
0066     // Optical detector tree name
0067     char const* optical_detectors_tree_name() const
0068     {
0069         return "optical_detectors";
0070     }
0071 
0072     // SimEnergyDeposit data tree name
0073     char const* sim_data_tree_name() const { return "sim_energy_deposits"; }
0074     //!@}
0075 
0076   private:
0077     std::unique_ptr<TFile> root_file_;  //!< Input ROOT file
0078     std::unique_ptr<TDirectory> data_dir_;  //!< TDirectory with all TTrees
0079     std::unique_ptr<TTree> sim_tree_;  //!< SimEnergyDepositData TTree
0080     SimEnergyDepositData sim_edep_data_;  //!< SimEnergyDepositData refs
0081 };
0082 
0083 //---------------------------------------------------------------------------//
0084 }  // namespace celeritas