CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FWCore/Framework/interface/EventPrincipal.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_EventPrincipal_h
00002 #define FWCore_Framework_EventPrincipal_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 EventPrincipal: This is the class responsible for management of
00007 per event EDProducts. It is not seen by reconstruction code;
00008 such code sees the Event class, which is a proxy for EventPrincipal.
00009 
00010 The major internal component of the EventPrincipal
00011 is the DataBlock.
00012 
00013 ----------------------------------------------------------------------*/
00014 
00015 #include "DataFormats/Common/interface/WrapperHolder.h"
00016 #include "DataFormats/Common/interface/WrapperOwningHolder.h"
00017 #include "DataFormats/Provenance/interface/BranchListIndex.h"
00018 #include "DataFormats/Provenance/interface/BranchMapper.h"
00019 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
00020 #include "DataFormats/Provenance/interface/EventSelectionID.h"
00021 #include "FWCore/Framework/interface/Principal.h"
00022 
00023 #include "boost/shared_ptr.hpp"
00024 
00025 #include <map>
00026 #include <memory>
00027 #include <string>
00028 #include <vector>
00029 
00030 namespace edm {
00031   class BranchIDListHelper;
00032   class BranchMapper;
00033   class DelayedReader;
00034   class EventID;
00035   class HistoryAppender;
00036   class LuminosityBlockPrincipal;
00037   class RunPrincipal;
00038   class UnscheduledHandler;
00039 
00040   class EventPrincipal : public Principal {
00041   public:
00042     typedef EventAuxiliary Auxiliary;
00043     typedef Principal Base;
00044 
00045     typedef Base::ConstProductPtr ConstProductPtr;
00046     static int const invalidBunchXing = EventAuxiliary::invalidBunchXing;
00047     static int const invalidStoreNumber = EventAuxiliary::invalidStoreNumber;
00048     EventPrincipal(
00049         boost::shared_ptr<ProductRegistry const> reg,
00050         boost::shared_ptr<BranchIDListHelper const> branchIDListHelper,
00051         ProcessConfiguration const& pc,
00052         HistoryAppender* historyAppender);
00053     ~EventPrincipal() {}
00054 
00055     void fillEventPrincipal(EventAuxiliary const& aux,
00056         boost::shared_ptr<EventSelectionIDVector> eventSelectionIDs = boost::shared_ptr<EventSelectionIDVector>(),
00057         boost::shared_ptr<BranchListIndexes> branchListIndexes = boost::shared_ptr<BranchListIndexes>(),
00058         boost::shared_ptr<BranchMapper> mapper = boost::shared_ptr<BranchMapper>(new BranchMapper),
00059         DelayedReader* reader = 0);
00060 
00061     void clearEventPrincipal();
00062 
00063     LuminosityBlockPrincipal const& luminosityBlockPrincipal() const {
00064       return *luminosityBlockPrincipal_;
00065     }
00066 
00067     LuminosityBlockPrincipal& luminosityBlockPrincipal() {
00068       return *luminosityBlockPrincipal_;
00069     }
00070 
00071     bool luminosityBlockPrincipalPtrValid() {
00072       return (luminosityBlockPrincipal_) ? true : false;
00073     }
00074 
00075     void setLuminosityBlockPrincipal(boost::shared_ptr<LuminosityBlockPrincipal> const& lbp);
00076 
00077     EventID const& id() const {
00078       return aux().id();
00079     }
00080 
00081     Timestamp const& time() const {
00082       return aux().time();
00083     }
00084 
00085     bool isReal() const {
00086       return aux().isRealData();
00087     }
00088 
00089     EventAuxiliary::ExperimentType ExperimentType() const {
00090       return aux().experimentType();
00091     }
00092 
00093     int bunchCrossing() const {
00094       return aux().bunchCrossing();
00095     }
00096 
00097     int storeNumber() const {
00098       return aux().storeNumber();
00099     }
00100 
00101     EventAuxiliary const& aux() const {
00102       return aux_;
00103     }
00104 
00105     LuminosityBlockNumber_t luminosityBlock() const {
00106       return id().luminosityBlock();
00107     }
00108 
00109     RunNumber_t run() const {
00110       return id().run();
00111     }
00112 
00113     RunPrincipal const& runPrincipal() const;
00114 
00115     boost::shared_ptr<BranchMapper> branchMapperPtr() const {return branchMapperPtr_;}
00116 
00117     void setUnscheduledHandler(boost::shared_ptr<UnscheduledHandler> iHandler);
00118     boost::shared_ptr<UnscheduledHandler> unscheduledHandler() const;
00119 
00120     EventSelectionIDVector const& eventSelectionIDs() const;
00121 
00122     BranchListIndexes const& branchListIndexes() const;
00123 
00124     Provenance
00125     getProvenance(ProductID const& pid) const;
00126 
00127     BasicHandle
00128     getByProductID(ProductID const& oid) const;
00129 
00130     void put(
00131         ConstBranchDescription const& bd,
00132         WrapperOwningHolder const& edp,
00133         ProductProvenance const& productProvenance);
00134 
00135     void putOnRead(
00136         ConstBranchDescription const& bd,
00137         void const* product,
00138         ProductProvenance const& productProvenance);
00139 
00140     WrapperHolder getIt(ProductID const& pid) const;
00141 
00142     ProductID branchIDToProductID(BranchID const& bid) const;
00143 
00144     void mergeMappers(EventPrincipal const& other) {
00145       branchMapperPtr_->mergeMappers(other.branchMapperPtr());
00146     }
00147 
00148     using Base::getProvenance;
00149 
00150   private:
00151 
00152     BranchID pidToBid(ProductID const& pid) const;
00153 
00154     virtual bool unscheduledFill(std::string const& moduleLabel) const override;
00155 
00156     virtual void resolveProduct_(ProductHolderBase const& phb, bool fillOnDemand) const override;
00157 
00158   private:
00159 
00160     EventAuxiliary aux_;
00161 
00162     boost::shared_ptr<LuminosityBlockPrincipal> luminosityBlockPrincipal_;
00163 
00164     // Pointer to the 'mapper' that will get provenance information from the persistent store.
00165     boost::shared_ptr<BranchMapper> branchMapperPtr_;
00166 
00167     // Handler for unscheduled modules
00168     boost::shared_ptr<UnscheduledHandler> unscheduledHandler_;
00169 
00170     mutable std::vector<std::string> moduleLabelsRunning_;
00171 
00172     boost::shared_ptr<EventSelectionIDVector> eventSelectionIDs_;
00173 
00174     boost::shared_ptr<BranchIDListHelper const> branchIDListHelper_;
00175 
00176     boost::shared_ptr<BranchListIndexes> branchListIndexes_;
00177 
00178     std::map<BranchListIndex, ProcessIndex> branchListIndexToProcessIndex_;
00179 
00180   };
00181 
00182   inline
00183   bool
00184   isSameEvent(EventPrincipal const& a, EventPrincipal const& b) {
00185     return isSameEvent(a.aux(), b.aux());
00186   }
00187 }
00188 #endif
00189