CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/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/EventAuxiliary.h"
00019 #include "DataFormats/Provenance/interface/EventSelectionID.h"
00020 #include "FWCore/Framework/interface/Principal.h"
00021 
00022 #include "boost/scoped_ptr.hpp"
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 BranchMapper;
00032   class DelayedReader;
00033   class EventID;
00034   class LuminosityBlockPrincipal;
00035   class RunPrincipal;
00036   class UnscheduledHandler;
00037 
00038   class EventPrincipal : public Principal {
00039   public:
00040     typedef EventAuxiliary Auxiliary;
00041     typedef Principal Base;
00042 
00043     typedef Base::ConstGroupPtr ConstGroupPtr;
00044     static int const invalidBunchXing = EventAuxiliary::invalidBunchXing;
00045     static int const invalidStoreNumber = EventAuxiliary::invalidStoreNumber;
00046     EventPrincipal(
00047         boost::shared_ptr<ProductRegistry const> reg,
00048         ProcessConfiguration const& pc);
00049     ~EventPrincipal() {}
00050 
00051     void fillEventPrincipal(EventAuxiliary const& aux,
00052         boost::shared_ptr<LuminosityBlockPrincipal> lbp,
00053         boost::shared_ptr<EventSelectionIDVector> eventSelectionIDs = boost::shared_ptr<EventSelectionIDVector>(),
00054         boost::shared_ptr<BranchListIndexes> branchListIndexes = boost::shared_ptr<BranchListIndexes>(),
00055         boost::shared_ptr<BranchMapper> mapper = boost::shared_ptr<BranchMapper>(),
00056         DelayedReader* reader = 0);
00057 
00058     void clearEventPrincipal();
00059 
00060     LuminosityBlockPrincipal const& luminosityBlockPrincipal() const {
00061       return *luminosityBlockPrincipal_;
00062     }
00063 
00064     LuminosityBlockPrincipal& luminosityBlockPrincipal() {
00065       return *luminosityBlockPrincipal_;
00066     }
00067 
00068     EventID const& id() const {
00069       return aux().id();
00070     }
00071 
00072     Timestamp const& time() const {
00073       return aux().time();
00074     }
00075 
00076     bool const isReal() const {
00077       return aux().isRealData();
00078     }
00079 
00080     EventAuxiliary::ExperimentType ExperimentType() const {
00081       return aux().experimentType();
00082     }
00083 
00084     int const bunchCrossing() const {
00085       return aux().bunchCrossing();
00086     }
00087 
00088     int const storeNumber() const {
00089       return aux().storeNumber();
00090     }
00091 
00092     EventAuxiliary const& aux() const {
00093       return aux_;
00094     }
00095 
00096     LuminosityBlockNumber_t luminosityBlock() const {
00097       return id().luminosityBlock();
00098     }
00099 
00100     RunNumber_t run() const {
00101       return id().run();
00102     }
00103 
00104     RunPrincipal const& runPrincipal() const;
00105 
00106     RunPrincipal & runPrincipal();
00107 
00108     void setUnscheduledHandler(boost::shared_ptr<UnscheduledHandler> iHandler);
00109     boost::shared_ptr<UnscheduledHandler> unscheduledHandler() const;
00110 
00111     EventSelectionIDVector const& eventSelectionIDs() const;
00112 
00113     BranchListIndexes const& branchListIndexes() const;
00114 
00115     Provenance
00116     getProvenance(ProductID const& pid) const;
00117 
00118     BasicHandle
00119     getByProductID(ProductID const& oid) const;
00120 
00121     void put(
00122         ConstBranchDescription const& bd,
00123         WrapperOwningHolder const& edp,
00124         ProductProvenance const& productProvenance);
00125 
00126     void putOnRead(
00127         ConstBranchDescription const& bd,
00128         void const* product,
00129         ProductProvenance const& productProvenance);
00130 
00131     WrapperHolder getIt(ProductID const& pid) const;
00132 
00133     ProductID branchIDToProductID(BranchID const& bid) const;
00134 
00135     using Base::getProvenance;
00136 
00137   private:
00138 
00139     BranchID pidToBid(ProductID const& pid) const;
00140 
00141     virtual ProductID oldToNewProductID_(ProductID const& oldProductID) const;
00142 
00143     virtual bool unscheduledFill(std::string const& moduleLabel) const;
00144 
00145     virtual void resolveProduct_(Group const& g, bool fillOnDemand) const;
00146 
00147   private:
00148 
00149     EventAuxiliary aux_;
00150 
00151     boost::shared_ptr<LuminosityBlockPrincipal> luminosityBlockPrincipal_;
00152 
00153     // Handler for unscheduled modules
00154     boost::shared_ptr<UnscheduledHandler> unscheduledHandler_;
00155 
00156     mutable std::vector<std::string> moduleLabelsRunning_;
00157 
00158     boost::shared_ptr<EventSelectionIDVector> eventSelectionIDs_;
00159 
00160     boost::shared_ptr<BranchListIndexes> branchListIndexes_;
00161 
00162     std::map<BranchListIndex, ProcessIndex> branchListIndexToProcessIndex_;
00163 
00164   };
00165 
00166   inline
00167   bool
00168   isSameEvent(EventPrincipal const& a, EventPrincipal const& b) {
00169     return isSameEvent(a.aux(), b.aux());
00170   }
00171 }
00172 #endif
00173