Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:49:50

0001 #ifndef DataFormats_FWLite_Run_h
0002 #define DataFormats_FWLite_Run_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWLite/DataFormats
0006 // Class  :     Run
0007 //
0008 /**\class Run Run.h DataFormats/FWLite/interface/Run.h
0009 
0010    Description: <one line class summary>
0011 
0012    Usage:
0013    This class is not safe to use across different threads
0014 
0015 */
0016 //
0017 // Original Author:  Eric Vaandering
0018 //         Created:  Wed Jan 13 15:01:20 EDT 2007
0019 //
0020 // system include files
0021 #include <typeinfo>
0022 #include <map>
0023 #include <vector>
0024 #include <memory>
0025 #include <cstring>
0026 
0027 #include "Rtypes.h"
0028 
0029 // user include files
0030 #include "DataFormats/FWLite/interface/RunBase.h"
0031 #include "DataFormats/FWLite/interface/InternalDataKey.h"
0032 #include "DataFormats/FWLite/interface/EntryFinder.h"
0033 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0034 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
0035 #include "DataFormats/Provenance/interface/RunID.h"
0036 #include "FWCore/FWLite/interface/BranchMapReader.h"
0037 #include "DataFormats/FWLite/interface/DataGetterHelper.h"
0038 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0039 
0040 // forward declarations
0041 namespace edm {
0042   class WrapperBase;
0043   class ProductRegistry;
0044   class BranchDescription;
0045   class EDProductGetter;
0046   class RunAux;
0047   class Timestamp;
0048   class TriggerResults;
0049   class TriggerNames;
0050 }  // namespace edm
0051 
0052 namespace fwlite {
0053   class Event;
0054   class Run : public RunBase {
0055   public:
0056     // NOTE: Does NOT take ownership so iFile must remain around
0057     // at least as long as Run
0058     Run(TFile* iFile);
0059     Run(std::shared_ptr<BranchMapReader> branchMap);
0060     Run(const Run&) = delete;                   // stop default
0061     const Run& operator=(const Run&) = delete;  // stop default
0062 
0063     ~Run() override;
0064 
0065     const Run& operator++() override;
0066 
0067     /// Go to event by Run & Run number
0068     bool to(edm::RunNumber_t run);
0069 
0070     // Go to the very first Event.
0071     const Run& toBegin() override;
0072 
0073     // ---------- const member functions ---------------------
0074     virtual std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const;
0075 
0076     // This function should only be called by fwlite::Handle<>
0077     using fwlite::RunBase::getByLabel;
0078     bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
0079     //void getByBranchName(std::type_info const&, char const*, void*&) const;
0080 
0081     bool isValid() const;
0082     operator bool() const;
0083     bool atEnd() const override;
0084 
0085     Long64_t size() const;
0086 
0087     edm::RunAuxiliary const& runAuxiliary() const override;
0088 
0089     std::vector<edm::BranchDescription> const& getBranchDescriptions() const {
0090       return branchMap_->getBranchDescriptions();
0091     }
0092 
0093     //       void setGetter(//Copy from Event if needed
0094 
0095     edm::WrapperBase const* getByProductID(edm::ProductID const&) const;
0096 
0097     // ---------- static member functions --------------------
0098     static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
0099 
0100     // ---------- member functions ---------------------------
0101 
0102   private:
0103     friend class internal::ProductGetter;
0104     friend class RunHistoryGetter;
0105 
0106     const edm::ProcessHistory& history() const;
0107     void updateAux(Long_t runIndex) const;
0108 
0109     // ---------- member data --------------------------------
0110     //This class is not inteded to be used across different threads
0111     CMS_SA_ALLOW mutable std::shared_ptr<BranchMapReader> branchMap_;
0112 
0113     //takes ownership of the strings used by the DataKey keys in data_
0114     CMS_SA_ALLOW mutable std::vector<char const*> labels_;
0115     CMS_SA_ALLOW mutable edm::ProcessHistoryMap historyMap_;
0116     CMS_SA_ALLOW mutable std::vector<std::string> procHistoryNames_;
0117     CMS_SA_ALLOW mutable edm::RunAuxiliary aux_;
0118     CMS_SA_ALLOW mutable EntryFinder entryFinder_;
0119     edm::RunAuxiliary const* pAux_;
0120     edm::RunAux const* pOldAux_;
0121     TBranch* auxBranch_;
0122     int fileVersion_;
0123 
0124     fwlite::DataGetterHelper dataHelper_;
0125   };
0126 
0127 }  // namespace fwlite
0128 #endif