Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-31 02:19:07

0001 #ifndef DataFormats_FWLite_LuminosityBlock_h
0002 #define DataFormats_FWLite_LuminosityBlock_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWLite/DataFormats
0006 // Class  :     LuminosityBlock
0007 //
0008 /**\class LuminosityBlock LuminosityBlock.h DataFormats/FWLite/interface/LuminosityBlock.h
0009 
0010    Description: <one line class summary>
0011 
0012    Usage:
0013    This class is not safe to use across 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/Run.h"
0031 #include "DataFormats/FWLite/interface/LuminosityBlockBase.h"
0032 #include "DataFormats/FWLite/interface/InternalDataKey.h"
0033 #include "DataFormats/FWLite/interface/EntryFinder.h"
0034 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0035 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
0036 #include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"
0037 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0038 
0039 // forward declarations
0040 namespace edm {
0041   class WrapperBase;
0042   class ProductRegistry;
0043   class EDProductGetter;
0044   class LuminosityBlockAux;
0045   class Timestamp;
0046   class TriggerResults;
0047   class TriggerNames;
0048 }  // namespace edm
0049 
0050 namespace fwlite {
0051   class Event;
0052   class BranchMapReader;
0053   class HistoryGetterBase;
0054   class DataGetterHelper;
0055   class RunFactory;
0056 
0057   class LuminosityBlock : public LuminosityBlockBase {
0058   public:
0059     // NOTE: Does NOT take ownership so iFile must remain around
0060     // at least as long as LuminosityBlock
0061     LuminosityBlock(TFile* iFile);
0062     LuminosityBlock(std::shared_ptr<BranchMapReader> branchMap, std::shared_ptr<RunFactory> runFactory);
0063     LuminosityBlock(const LuminosityBlock&) = delete;                   // stop default
0064     const LuminosityBlock& operator=(const LuminosityBlock&) = delete;  // stop default
0065 
0066     ~LuminosityBlock() override;
0067 
0068     const LuminosityBlock& operator++() override;
0069 
0070     /// Go to event by Run & LuminosityBlock number
0071     bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi);
0072 
0073     // Go to the very first Event.
0074     const LuminosityBlock& toBegin() override;
0075 
0076     // ---------- const member functions ---------------------
0077     virtual std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const;
0078 
0079     // This function should only be called by fwlite::Handle<>
0080     using fwlite::LuminosityBlockBase::getByLabel;
0081     bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
0082     //void getByBranchName(std::type_info const&, char const*, void*&) const;
0083 
0084     bool isValid() const;
0085     operator bool() const;
0086     bool atEnd() const override;
0087 
0088     Long64_t size() const;
0089 
0090     edm::LuminosityBlockAuxiliary const& luminosityBlockAuxiliary() const override;
0091 
0092     std::vector<edm::ProductDescription> const& getProductDescriptions() const {
0093       return branchMap_->getProductDescriptions();
0094     }
0095 
0096     //       void setGetter(//Copy from Event if needed
0097 
0098     edm::WrapperBase const* getByProductID(edm::ProductID const&) const;
0099 
0100     // ---------- static member functions --------------------
0101     static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
0102 
0103     // ---------- member functions ---------------------------
0104     fwlite::Run const& getRun() const;
0105 
0106   private:
0107     friend class internal::ProductGetter;
0108     friend class LumiHistoryGetter;
0109 
0110     const edm::ProcessHistory& history() const;
0111     void updateAux(Long_t lumiIndex) const;
0112 
0113     // ---------- member data --------------------------------
0114     //This class is not inteded to be used across different threads
0115     CMS_SA_ALLOW mutable std::shared_ptr<BranchMapReader> branchMap_;
0116 
0117     CMS_SA_ALLOW mutable std::shared_ptr<fwlite::Run> run_;
0118 
0119     //takes ownership of the strings used by the DataKey keys in data_
0120     CMS_SA_ALLOW mutable std::vector<char const*> labels_;
0121     CMS_SA_ALLOW mutable edm::ProcessHistoryMap historyMap_;
0122     CMS_SA_ALLOW mutable std::vector<std::string> procHistoryNames_;
0123     CMS_SA_ALLOW mutable edm::LuminosityBlockAuxiliary aux_;
0124     CMS_SA_ALLOW mutable EntryFinder entryFinder_;
0125     edm::LuminosityBlockAuxiliary const* pAux_;
0126     edm::LuminosityBlockAux const* pOldAux_;
0127     TBranch* auxBranch_;
0128     int fileVersion_;
0129 
0130     DataGetterHelper dataHelper_;
0131     CMS_SA_ALLOW mutable std::shared_ptr<RunFactory> runFactory_;
0132   };
0133 
0134 }  // namespace fwlite
0135 #endif