CMS 3D CMS Logo

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