Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-31 04:19:24

0001 #ifndef Streamer_StreamedProducts_h
0002 #define Streamer_StreamedProducts_h
0003 
0004 /*
0005   Simple packaging of all the event data that is needed to be serialized
0006   for transfer.
0007 
0008   The "other stuff in the SendEvent still needs to be
0009   populated.
0010 
0011   The product is paired with its provenance, and the entire event
0012   is captured in the SendEvent structure.
0013  */
0014 
0015 #include <vector>
0016 #include "DataFormats/Provenance/interface/BranchDescription.h"
0017 #include "DataFormats/Provenance/interface/BranchID.h"
0018 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0019 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0020 #include "DataFormats/Provenance/interface/ParameterSetBlob.h"
0021 #include "DataFormats/Provenance/interface/EventSelectionID.h"
0022 #include "DataFormats/Provenance/interface/BranchListIndex.h"
0023 #include "DataFormats/Provenance/interface/ProcessHistory.h"
0024 #include "DataFormats/Provenance/interface/BranchIDList.h"
0025 #include "DataFormats/Provenance/interface/ThinnedAssociationsHelper.h"
0026 
0027 namespace edm {
0028 
0029   // ------------------------------------------
0030 
0031   class WrapperBase;
0032   class StreamedProduct {
0033   public:
0034     StreamedProduct() : prod_(nullptr), desc_(nullptr), present_(false), parents_(nullptr) {}
0035     explicit StreamedProduct(BranchDescription const& desc)
0036         : prod_(nullptr), desc_(&desc), present_(false), parents_(nullptr) {}
0037 
0038     StreamedProduct(WrapperBase const* prod,
0039                     BranchDescription const& desc,
0040                     bool present,
0041                     std::vector<BranchID> const* parents);
0042 
0043     BranchDescription const* desc() const { return desc_; }
0044     BranchID branchID() const { return desc_->branchID(); }
0045     bool present() const { return present_; }
0046     std::vector<BranchID> const* parents() const { return parents_; }
0047     WrapperBase const* prod() { return prod_; }
0048 
0049     void clear() {
0050       prod_ = nullptr;
0051       delete desc_;
0052       desc_ = nullptr;
0053       present_ = false;
0054       delete parents_;
0055       parents_ = nullptr;
0056     }
0057 
0058   private:
0059     WrapperBase const* prod_;
0060     BranchDescription const* desc_;
0061     bool present_;
0062     std::vector<BranchID> const* parents_;
0063   };
0064 
0065   // ------------------------------------------
0066 
0067   typedef std::vector<StreamedProduct> SendProds;
0068 
0069   // ------------------------------------------
0070   // Contains either Event data or meta data about an Event. The header of the
0071   // message contains which way an instance of this class is to be interpreted
0072   // via the use of EventMsgView::isEventMetaData()
0073 
0074   class SendEvent {
0075   public:
0076     SendEvent() {}
0077     SendEvent(EventAuxiliary const& aux,
0078               ProcessHistory const& processHistory,
0079               EventSelectionIDVector const& eventSelectionIDs,
0080               BranchListIndexes const& branchListIndexes,
0081               BranchIDLists const& branchIDLists,
0082               ThinnedAssociationsHelper const& thinnedAssociationsHelper,
0083               uint32_t metaDataChecksum)
0084         : aux_(aux),
0085           processHistory_(processHistory),
0086           eventSelectionIDs_(eventSelectionIDs),
0087           branchListIndexes_(branchListIndexes),
0088           branchIDLists_(branchIDLists),
0089           thinnedAssociationsHelper_(thinnedAssociationsHelper),
0090           products_(),
0091           metaDataChecksum_(metaDataChecksum) {}
0092     EventAuxiliary const& aux() const { return aux_; }
0093     SendProds const& products() const { return products_; }
0094     ProcessHistory const& processHistory() const { return processHistory_; }
0095     EventSelectionIDVector const& eventSelectionIDs() const { return eventSelectionIDs_; }
0096     BranchListIndexes const& branchListIndexes() const { return branchListIndexes_; }
0097     //This will only hold values for EventMetaData messages
0098     BranchIDLists const& branchIDLists() const { return branchIDLists_; }
0099     //This will only hold values for EventMetaData messages
0100     ThinnedAssociationsHelper const& thinnedAssociationsHelper() const { return thinnedAssociationsHelper_; }
0101     //This is the adler32 checksum of the EventMetaData associated with this Event
0102     uint32_t metaDataChecksum() const { return metaDataChecksum_; }
0103     SendProds& products() { return products_; }
0104 
0105   private:
0106     EventAuxiliary aux_;
0107     ProcessHistory processHistory_;
0108     EventSelectionIDVector eventSelectionIDs_;
0109     BranchListIndexes branchListIndexes_;
0110     BranchIDLists branchIDLists_;
0111     ThinnedAssociationsHelper thinnedAssociationsHelper_;
0112     SendProds products_;
0113     uint32_t metaDataChecksum_;
0114 
0115     // other tables necessary for provenance lookup
0116   };
0117 
0118   typedef std::vector<BranchDescription> SendDescs;
0119 
0120   class SendJobHeader {
0121   public:
0122     typedef std::map<ParameterSetID, ParameterSetBlob> ParameterSetMap;
0123     SendJobHeader() {}
0124     SendDescs const& descs() const { return descs_; }
0125     ParameterSetMap const& processParameterSet() const { return processParameterSet_; }
0126     void push_back(BranchDescription const& bd) { descs_.push_back(bd); }
0127     void setParameterSetMap(ParameterSetMap const& psetMap) { processParameterSet_ = psetMap; }
0128     void initializeTransients();
0129 
0130   private:
0131     SendDescs descs_;
0132     ParameterSetMap processParameterSet_;
0133   };
0134 
0135 }  // namespace edm
0136 #endif