00001 #ifndef _FUShmOutputModule_h 00002 #define _FUShmOutputModule_h 00003 00004 /* 00005 Description: 00006 Header file shared memory to be used with FUShmOutputModule. 00007 See CMS EvF Storage Manager wiki page for further notes. 00008 00009 $Id: FUShmOutputModule.h,v 1.12 2012/10/11 17:48:11 smorovic Exp $ 00010 */ 00011 00012 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00013 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" 00014 #include "FWCore/Framework/interface/EventSelector.h" 00015 00016 #include "IOPool/Streamer/interface/EventMessage.h" 00017 #include "IOPool/Streamer/interface/InitMsgBuilder.h" 00018 #include "IOPool/Streamer/interface/EventMsgBuilder.h" 00019 #include "FWCore/Framework/interface/LuminosityBlock.h" 00020 00021 #include "EventFilter/ShmBuffer/interface/FUShmBuffer.h" 00022 #include "EventFilter/Modules/interface/ShmOutputModuleRegistry.h" 00023 00024 #include <iostream> 00025 00026 // Data structure to be shared by all output modules for event serialization 00027 struct SM_SharedMemoryHandle 00028 { 00029 SM_SharedMemoryHandle(): 00030 shmBuffer_(0) 00031 { } 00032 00033 evf::FUShmBuffer* getShmBuffer() { 00034 if(!shmBuffer_) { 00035 shmBuffer_ = evf::FUShmBuffer::getShmBuffer(); 00036 return shmBuffer_; 00037 } else { 00038 return shmBuffer_; 00039 } 00040 } 00041 void detachShmBuffer() { 00042 if(!shmBuffer_) { 00043 // no shared memory was attached to! 00044 } else { 00045 shmdt(shmBuffer_); 00046 shmBuffer_ = 0; 00047 } 00048 } 00049 evf::FUShmBuffer* getBufferRef() { 00050 return shmBuffer_; 00051 } 00052 00053 evf::FUShmBuffer* shmBuffer_; 00054 }; 00055 00056 namespace edm 00057 { 00058 //class ParameterSetDescription; 00059 class FUShmOutputModule : public evf::OutputModule 00060 { 00061 public: 00062 00063 FUShmOutputModule(edm::ParameterSet const& ps); 00064 ~FUShmOutputModule(); 00065 00066 void insertStreamAndDatasetInfo(edm::ParameterSet & streams, edm::ParameterSet datasets/*std:std::string & moduleList*/); 00067 void doOutputHeader(InitMsgBuilder const& initMessage); 00068 void doOutputEvent(EventMsgBuilder const& eventMessage); 00069 unsigned int getCounts(){ 00070 return count_; 00071 } 00072 void start(); 00073 void stop(); 00074 static void fillDescription(ParameterSetDescription&); 00075 00076 void parseDatasets(InitMsgView const& initMessage); 00077 void countEventForDatasets(EventMsgView const& eventMessage); 00078 std::vector<std::string> getDatasetNames() {return selectedDatasetNames_;} 00079 std::vector<unsigned int>& getDatasetCounts() {return datasetCounts_;} 00080 void clearDatasetCounts() { 00081 for (unsigned int i=0;i<datasetCounts_.size();i++) datasetCounts_[i]=0; 00082 } 00083 std::string getStreamId() {return streamId_;} 00084 00085 //void writeLuminosityBlock(LuminosityBlockPrincipal const&); 00086 void setPostponeInitMsg(); 00087 void sendPostponedStart(); 00088 void sendPostponedInitMsg(); 00089 void setNExpectedEPs(unsigned int EPs); 00090 void unregisterFromShm(); 00091 00092 private: 00093 00094 evf::FUShmBuffer* shmBuffer_; 00095 std::string name_; 00096 unsigned int count_; 00097 00098 static bool fuIdsInitialized_; 00099 static uint32 fuGuidValue_; 00100 unsigned int nExpectedEPs_; 00101 00102 //dataset parsing 00103 std::vector<unsigned int> datasetCounts_; 00104 00105 unsigned int numDatasets_; 00106 std::vector<std::string> selectedDatasetNames_; 00107 std::vector<Strings> datasetPaths_; 00108 std::vector<std::pair<std::string,edm::EventSelector*>> dpEventSelectors_; 00109 unsigned int totalPaths_; 00110 00111 std::string streamId_; 00112 }; 00113 } 00114 00115 #endif