//////////////////////////////////////////////////////////////////////// /// \class RAT::DS::Meta /// /// \brief All the meta information about the root file is container /// herein. /// /// \author Phil G Jones /// /// REVISION HISTORY:\n /// 2014-04-18 : P G Jones - New file. \n /// 2017-04-24 : Jack Dunger - Add CompletePass & Getter methods, new fields /// /// \details This class stores all the relevant information about how this /// root file was produced and reprocessed. This information is organised /// by a pass number for the file. This pass number increments each time /// the file is reprocessed. /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_Meta__ #define __RAT_DS_Meta__ #include #include #include #include #include namespace RAT { namespace DS { class Meta : public TObject { public: Meta() : TObject() { } /// Creates a new pass /// /// This should be called whenever a simulation starts or the file is reprocessed /// /// @param[in] name of the computer/host /// @param[in] system of the host /// @param[in] version of rat /// @param[in] revision of rat /// @param[in] geant4Version string identifier of the G4 version /// @param[in] rootVersion string identifier of the root version inline void NewPass( const std::string& name, const std::string& system, const std::string& version, const std::string& revision, const std::string& geant4Version, const std::string& rootVersion ); /// Finishes the pass, writing information that can only be known at the end of the job /// /// @param[in] container holding some end of job meta information, created by an IO class inline void CompletePass(const MetaHelper&); /// Get the latest/current pass number /// /// @return the current/latest pass number size_t GetCurrentPass() const { if( metaDBs.empty() ) throw; return metaDBs.size() - 1; } /// Get the total number of passes /// /// @return the number of passes size_t GetPassCount() const { return metaDBs.size(); } /// Get the Meta Database information /// /// @param[in] pass to return /// @return the MetaDB information by reference for the pass /// @throws out_of_range error if pass does not exist MetaDB& GetMetaDB( const size_t pass ) { return metaDBs.at( pass ); } /// @copydoc GetMetaDB(size_t) const MetaDB& GetMetaDB( const size_t pass ) const { return metaDBs.at( pass ); } /// Get the Meta Database information as a vector indexed by pass /// /// @return Meta Database information as a vector indexed by pass const std::vector& GetMetaDBs() const {return metaDBs;} /// Get the names of the hosts that ran each pass /// /// @return vector of strings indexed by pass const std::vector& GetHostNames() const {return hostNames;} /// Get the systems of the hosts that ran each pass /// /// @return vector of strings indexed by pass const std::vector& GetHostSystems() const {return hostSystems;} /// Get the rat version used to process each pass /// /// @return vector of strings indexed by pass const std::vector& GetVersions() const {return ratVersions;} /// Get the rat revision used to process each pass /// /// @return vector of strings indexed by pass const std::vector& GetRevisions() const {return ratRevisions;} /// Get the Geant4 version used to process each pass /// /// @return vector of strings indexed by pass const std::vector& GetGeant4Versions() const {return geant4Versions;} /// Get the ROOT version used to process each pass /// /// @return vector of strings indexed by pass const std::vector& GetRootVersions() const {return rootVersions;} /// Get the ContainsMCFlag for each pass /// /// @return vector of Int_t indexed by pass, ==1 -> the file contains MC const std::vector& GetContainsMCFlags() const {return containsMCFlags;} /// Get the ContainsDataFlag for each pass /// /// @return vector of Int_t indexed by pass, ==1 -> the file contains Data const std::vector& GetContainsDataFlags() const {return containsDataFlags;} /// Get the total number of events generated (across all passes) recorded at each pass /// generation level cuts mean this is generally not the same as the number stored /// /// @return vector of integers indexed by pass const std::vector& GetEventsGeneratedCounts() const {return eventsGeneratedCounts;} /// Get the total number of events stored (across all passes) recorded at each pass /// generation level cuts mean this is generally not the same as the number generated /// /// @return vector of integers indexed by pass const std::vector& GetEventsStoredCounts() const {return eventsStoredCounts;} // 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( Meta, 3 ); protected: std::vector metaDBs; ///< The database information indexed by pass std::vector hostNames; ///< The name of the host computer indexed by pass std::vector hostSystems; ///< The system type of the host computer indexed by pass std::vector ratVersions; ///< The rat base version indexed by pass std::vector ratRevisions; ///< The rat revision indexed by pass std::vector geant4Versions; ///< The geant4 versions indexed by pass std::vector rootVersions; ///< The root versions indexed by pass // note the booleans are stored as Int_t // std::vector::operator[] returns a `std::vector::reference ` by value unlike all other vectors // and this plays havoc with CINT std::vector containsMCFlags; ///< the file contains MC, indexed by pass std::vector containsDataFlags; ///< file contains Data, indexed by pass std::vector eventsGeneratedCounts; ///< number of mc events generated, indexed by pass std::vector eventsStoredCounts; ///< number of events stored, indexed by pass }; inline void Meta::NewPass( const std::string& name, const std::string& system, const std::string& version, const std::string& revision, const std::string& geant4Version, const std::string& rootVersion ) { metaDBs.push_back( MetaDB() ); hostNames.push_back( name ); hostSystems.push_back( system ); ratVersions.push_back( version ); ratRevisions.push_back( revision ); geant4Versions.push_back( geant4Version ); rootVersions.push_back( rootVersion ); // defaults in case the pass isn't completed // false for both containsMC and containsData indicates a corruption containsMCFlags.push_back( false ); containsDataFlags.push_back( false ); eventsGeneratedCounts.push_back( 0 ); eventsStoredCounts.push_back( 0 ); } inline void Meta::CompletePass(const MetaHelper& helper){ containsMCFlags[GetCurrentPass()] = helper.GetContainsMC(); containsDataFlags[GetCurrentPass()]= helper.GetContainsData(); eventsGeneratedCounts[GetCurrentPass()] = helper.GetEventsGenerated(); eventsStoredCounts[GetCurrentPass()] = helper.GetEventsStored(); } } // namespace DS } // namespace RAT #endif