CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/FWLite/interface/DataGetterHelper.h

Go to the documentation of this file.
00001 #ifndef DataFormats_FWLite_DataGetterHelper_h
00002 #define DataFormats_FWLite_DataGetterHelper_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     DataFormats/FWLite
00006 // Class  :     DataGetterHelper
00007 //
00016 //
00017 // Original Author: Eric Vaandering
00018 //         Created:  Fri Jan 29 12:45:17 CST 2010
00019 //
00020 
00021 #if !defined(__CINT__) && !defined(__MAKECINT__)
00022 
00023 // system include files
00024 #include <typeinfo>
00025 #include <map>
00026 #include <vector>
00027 #include <memory>
00028 #include <cstring>
00029 #include "boost/shared_ptr.hpp"
00030 
00031 // user include files
00032 #include "FWCore/Utilities/interface/TypeID.h"
00033 #include "DataFormats/FWLite/interface/InternalDataKey.h"
00034 #include "FWCore/FWLite/interface/BranchMapReader.h"
00035 #include "DataFormats/FWLite/interface/HistoryGetterBase.h"
00036 
00037 // forward declarations
00038 class TTreeCache;
00039 class TTree;
00040 
00041 namespace fwlite {
00042     class DataGetterHelper
00043     {
00044 
00045         public:
00046 //            DataGetterHelper() {};
00047             DataGetterHelper(TTree* tree,
00048                              boost::shared_ptr<HistoryGetterBase> historyGetter,
00049                              boost::shared_ptr<BranchMapReader> branchMap = boost::shared_ptr<BranchMapReader>(),
00050                              boost::shared_ptr<edm::EDProductGetter> getter = boost::shared_ptr<edm::EDProductGetter>(),
00051                              bool useCache = false);
00052             virtual ~DataGetterHelper();
00053 
00054             // ---------- const member functions ---------------------
00055             virtual const std::string getBranchNameFor(const std::type_info&,
00056                                                         const char*,
00057                                                         const char*,
00058                                                         const char*) const;
00059 
00060             // This function should only be called by fwlite::Handle<>
00061             virtual bool getByLabel(const std::type_info&, const char*, const char*, const char*, void*, Long_t) const;
00062             edm::EDProduct const* getByProductID(edm::ProductID const&, Long_t) const;
00063 
00064             // ---------- static member functions --------------------
00065             static void throwProductNotFoundException(const std::type_info&, const char*, const char*, const char*);
00066 
00067             // ---------- member functions ---------------------------
00068 
00069             void setGetter( boost::shared_ptr<edm::EDProductGetter> getter ) {
00070                 getter_ = getter;
00071             }
00072        
00073             edm::EDProductGetter* getter() {
00074                return getter_.get();
00075             }
00076 
00077         private:
00078             DataGetterHelper(const DataGetterHelper&); // stop default
00079 
00080             const DataGetterHelper& operator=(const DataGetterHelper&); // stop default
00081             internal::Data& getBranchDataFor(const std::type_info&, const char*, const char*, const char*) const;
00082             void getBranchData(edm::EDProductGetter*, Long64_t, internal::Data&) const;
00083 
00084             // ---------- member data --------------------------------
00085             TTree* tree_;
00086             mutable boost::shared_ptr<BranchMapReader> branchMap_;
00087             typedef std::map<internal::DataKey, boost::shared_ptr<internal::Data> > KeyToDataMap;
00088             mutable KeyToDataMap data_;
00089             mutable std::vector<const char*> labels_;
00090             const edm::ProcessHistory& history() const;
00091 
00092             mutable std::map<edm::ProductID,boost::shared_ptr<internal::Data> > idToData_;
00093             boost::shared_ptr<fwlite::HistoryGetterBase> historyGetter_;
00094             boost::shared_ptr<edm::EDProductGetter> getter_;
00095             mutable std::auto_ptr<TTreeCache> tcache_;
00096             mutable bool tcTrained_;
00097     };
00098 
00099 }
00100 
00101 #endif /*__CINT__ */
00102 
00103 #endif