//////////////////////////////////////////////////////////////////// /// \class RAT::DS::Entry /// /// \brief Data structure root, 1 per event /// /// \author Stan Seibert \n /// P G Jones /// /// REVISION HISTORY:\n /// 24 Mar 2010 : Gabriel Orebi Gann - add flag to identify the type /// of information stored in PMTCal branch (e.g. pure /// MC, ECA-calibrated, ECA+PCA-calibrated etc)\n /// 29 Mar 2010 : Gabriel Orebi Gann - add additional members /// to hold the full detector data\n /// 09 Apr 2010 : Gabriel Orebi Gann - add headerInfo branch to 'ds'\n /// 2014-02-27 : P G Jones - Refactor following the ds review. /// /// \details This data structure represents a physics event. This may /// mean a simulated Monte Carlo event (MC) with multiple triggered /// data events (EV) or a detector data event (EV). /// /// Instances of this class make up the T TTree present in outroot /// files and are present in memory during rat's analysis stage. /// This results in some members that are useful in memory but should /// not be saved to disc, such members are marked with the ROOT `//!` /// transient flag. /// /// This class is not designed to be inherited from /// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// /// \namespace RAT::DS /// /// \brief The Data Structure Namespace /// /// \details This namespace contains all the class that make up the /// data structure. Not that not everything is saved into a root file /// anything with //! for example will not be saved to disc, but is /// usable within RAT. /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_Entry__ #define __RAT_DS_Entry__ #include #include #include #include #include #include #include // MUST Delete when the DB works properly #include #include #include namespace RAT { namespace DS { class Entry : public TObject { public: /// Construct an instance, by default it has no data saved Entry() : TObject(), runID(0), subRunID(0), seed(0) {} /// Set the ID of the run this event belongs to /// /// @param[in] id the run ID void SetRunID( const UInt_t id ) { runID = id; } /// Get the ID of the run this event belongs to /// /// @return the run ID UInt_t GetRunID() const { return runID; } /// Set the ID of the sub run this event belongs to /// /// @param[in] id the sub run ID void SetSubRunID( const UInt_t id ) { subRunID = id; } /// Get the ID of the sub run this event belongs to /// /// @return the sub run ID UInt_t GetSubRunID() const { return subRunID; } /// Set the seed at the start of this event /// /// @param[in] seed_ the seed value void SetSeed( const Long_t seed_ ) { seed = seed_; } /// Get the seed at the start of this event /// /// @return the seed value Long_t GetSeed() const { return seed; } /// Set the MC branch information, this will delete any existing branch information /// /// @param[in] mc_ the mc information void SetMC( const MC& mc_ ) { if( mc.empty() ) mc.resize(1); mc[0] = mc_; } /// Check if the MC branch exists /// /// @return true if it does Bool_t MCExists() const { return !mc.empty(); } /// Get the MC branch information /// /// @return reference to the mc information /// @throws DataNotFound if the mc branch does not exist MC& GetMC() { if( mc.empty() ) throw DataNotFound( "Entry", "mc" ); return mc.at(0); } /// @copydoc GetMC() const MC& GetMC() const { return mc.at(0); } /// Prune the MC branch void PruneMC() { clear_vector( mc ); } /// Get all the MCHits for the simulated event /// /// @return combination of MCHits inline MCHits GetAllMCHits() const; /// Add a MC event /// /// @param[in] ev the MC event to add void AddMCEV( const MCEV& ev ) { mcevs.push_back( ev ); } /// Get the total number of MC events /// /// @return the number of MC events size_t GetMCEVCount() const { return mcevs.size(); } /// Get a MC event using the index in the mcevs vector /// /// @param[in] index into the mcevs array /// @return reference to the MC event /// @throws out_of_range if the index is out of range MCEV& GetMCEV( const size_t index ) { return mcevs.at( index ); } /// @copydoc GetMCEV(size_t) const MCEV& GetMCEV( const size_t index ) const { return mcevs.at( index ); } /// Prune/delete the MC event collection void PruneMCEVs() { clear_vector( mcevs ); } /// Add a data event /// /// @param[in] ev the data event to add void AddEV( const EV& ev ) { evs.push_back( ev ); } /// Get the total number of data evs /// /// @return the number of data evs size_t GetEVCount() const { return evs.size(); } /// Get a data event using the index in the evs vector /// /// @param[in] index into the evs array /// @return reference to the data event /// @throws out_of_range if the index is out of range EV& GetEV( const size_t index ) { return evs.at( index ); } /// @copydoc GetEV(size_t) const EV& GetEV( const size_t index ) const { return evs.at( index ); } /// Prune/delete the data event collection void PruneEVs() { clear_vector( evs ); } /// Add header info /// /// @param[in] header the header info to add void SetHeaderInfo( HeaderInfo& header ) { if( headerInfo.empty() ) headerInfo.resize( 1 ); headerInfo[0] = header; } /// See if there is header info /// /// @return true if there is header info Bool_t HeaderInfoExists() const { return !headerInfo.empty(); } /// Get the headerInfo if it exists /// /// @return reference to the headerInfo /// @throws out_of_range if the index is out of range HeaderInfo& GetHeaderInfo() { return headerInfo.at( 0 ); } /// @copydoc GetHeaderInfo() const HeaderInfo& GetHeaderInfo() const { return headerInfo.at( 0 ); } /// Prune/delete the data headerInfo collection void PruneHeaderInfos() { clear_vector( headerInfo ); } /// MUST Delete when the DB works properly Calib& GetCalib() { return calib; } /// @copydoc GetCalib const Calib& GetCalib() const { return calib; } // This ROOT macro adds dictionary methods to this class. // The number should be incremented whenever this class's members are changed. // It assumes this class has no virtual methods, use ClassDef if change this. ClassDefNV(Entry, 2); private: std::vector mc; ///< The Monte Carlo data branch std::vector mcevs; ///< The mc-data triggered events std::vector evs; ///< The data triggered events std::vector headerInfo; ///< The header info branche for this event Calib calib; ///< MUST Delete when the DB works properly UInt_t runID; ///< The run ID UInt_t subRunID; ///< The sub run ID Long_t seed; ///< The seed at the start of this event }; inline MCHits Entry::GetAllMCHits() const { MCHits result = mc.at( 0 ).GetUnbuiltMCHits(); for( size_t iEvent = 0; iEvent < mcevs.size(); iEvent++ ) result.Combine( mcevs.at( iEvent ).GetMCHits() ); return result; } } // namespace DS } // namespace RAT #endif