CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/FWCore/FWLite/interface/BranchMapReader.h

Go to the documentation of this file.
00001 #ifndef FWLite_BranchMapReader_h
00002 #define FWLite_BranchMapReader_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     FWLite
00006 // Class  :     BranchMapReader
00007 //
00016 //
00017 // Original Author:  Dan Riley
00018 //         Created:  Tue May 20 10:31:32 EDT 2008
00019 // $Id: BranchMapReader.h,v 1.13 2011/06/27 21:50:59 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 #include <memory>
00024 #include "TUUID.h"
00025 
00026 // user include files
00027 #include "DataFormats/Provenance/interface/BranchDescription.h"
00028 
00029 // forward declarations
00030 class TFile;
00031 class TTree;
00032 class TBranch;
00033 
00034 namespace fwlite {
00035   namespace internal {
00036     class BMRStrategy {
00037     public:
00038       BMRStrategy(TFile* file, int fileVersion);
00039       virtual ~BMRStrategy();
00040 
00041       virtual bool updateFile(TFile* file) = 0;
00042       virtual bool updateEvent(Long_t eventEntry) = 0;
00043       virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry) = 0;
00044       virtual bool updateRun(Long_t runEntry) = 0;
00045       virtual bool updateMap() = 0;
00046       virtual edm::BranchID productToBranchID(const edm::ProductID& pid) = 0;
00047       virtual const edm::BranchDescription& productToBranch(const edm::ProductID& pid) = 0;
00048       virtual const std::vector<edm::BranchDescription>& getBranchDescriptions() = 0;
00049 
00050       TFile* currentFile_;
00051       TTree* eventTree_;
00052       TTree* luminosityBlockTree_;
00053       TTree* runTree_;
00054       TUUID fileUUID_;
00055       Long_t eventEntry_;
00056       Long_t luminosityBlockEntry_;
00057       Long_t runEntry_;
00058       int fileVersion_;
00059     };
00060   }
00061 
00062   class BranchMapReader {
00063   public:
00064     BranchMapReader(TFile* file);
00065     BranchMapReader() : strategy_(0),fileVersion_(0) {}
00066 
00067       // ---------- const member functions ---------------------
00068 
00069       // ---------- static member functions --------------------
00070 
00071       // ---------- member functions ---------------------------
00072     bool updateFile(TFile* file);
00073     bool updateEvent(Long_t eventEntry);
00074     bool updateLuminosityBlock(Long_t luminosityBlockEntry);
00075     bool updateRun(Long_t runEntry);
00076     const edm::BranchDescription& productToBranch(const edm::ProductID& pid);
00077     int getFileVersion(TFile* file);
00078     int getFileVersion() const { return  fileVersion_;}
00079 
00080     TFile* getFile() const { return strategy_->currentFile_; }
00081     TTree* getEventTree() const { return strategy_->eventTree_; }
00082     TTree* getLuminosityBlockTree() const { return strategy_->luminosityBlockTree_; }
00083     TTree* getRunTree() const { return strategy_->runTree_; }
00084     TUUID getFileUUID() const { return strategy_->fileUUID_; }
00085     Long_t getEventEntry() const { return strategy_->eventEntry_; }
00086     Long_t getLuminosityBlockEntry() const { return strategy_->luminosityBlockEntry_; }
00087     Long_t getRunEntry() const { return strategy_->runEntry_; }
00088     const std::vector<edm::BranchDescription>& getBranchDescriptions();
00089 
00090       // ---------- member data --------------------------------
00091   private:
00092     std::auto_ptr<internal::BMRStrategy> newStrategy(TFile* file, int fileVersion);
00093     std::auto_ptr<internal::BMRStrategy> strategy_;
00094     int fileVersion_;
00095   };
00096 }
00097 
00098 #endif