CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/EventFilter/StorageManager/interface/DQMTopLevelFolder.h

Go to the documentation of this file.
00001 // $Id: DQMTopLevelFolder.h,v 1.5 2011/04/04 16:05:37 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_DQMTopLevelFolder_h
00005 #define EventFilter_StorageManager_DQMTopLevelFolder_h
00006 
00007 #include <vector>
00008 
00009 #include "boost/shared_ptr.hpp"
00010 
00011 #include "DataFormats/Provenance/interface/Timestamp.h"
00012 
00013 #include "EventFilter/StorageManager/interface/AlarmHandler.h"
00014 #include "EventFilter/StorageManager/interface/Configuration.h"
00015 #include "EventFilter/StorageManager/interface/DQMFolder.h"
00016 #include "EventFilter/StorageManager/interface/DQMKey.h"
00017 #include "EventFilter/StorageManager/interface/I2OChain.h"
00018 #include "EventFilter/StorageManager/interface/QueueID.h"
00019 
00020 #include "IOPool/Streamer/interface/DQMEventMessage.h"
00021 
00022 
00023 namespace stor {
00024 
00025   class DQMEventMonitorCollection;
00026 
00027 
00036   class DQMTopLevelFolder
00037   {
00038 
00039   public:
00040 
00041     class Record
00042     {
00043     private:
00044 
00045       struct Entry
00046       {
00047         std::vector<unsigned char> buffer;
00048         QueueIDs dqmConsumers;
00049       };
00050 
00051     public:
00052       
00053       Record() :
00054       entry_(new Entry) {};
00055 
00059       inline void clear()
00060       { entry_->buffer.clear(); entry_->dqmConsumers.clear(); }
00061 
00066       inline void* getBuffer(size_t size) const
00067       { entry_->buffer.resize(size); return &(entry_->buffer[0]); }
00068 
00073       inline void tagForEventConsumers(const QueueIDs& ids)
00074       { entry_->dqmConsumers = ids; }
00075       
00080       inline QueueIDs getEventConsumerTags() const
00081        { return entry_->dqmConsumers; }
00082 
00086       inline DQMEventMsgView getDQMEventMsgView() const
00087       { return DQMEventMsgView(&entry_->buffer[0]); }
00088 
00092       inline bool empty() const
00093       { return ( entry_->buffer.empty() ); }
00094 
00098       inline size_t memoryUsed() const
00099       { return entry_->buffer.size() + entry_->dqmConsumers.size()*sizeof(QueueID); }
00100 
00104       inline unsigned long totalDataSize() const
00105       { return entry_->buffer.size(); }
00106 
00107 
00108     private:
00109 
00110       // We use here a shared_ptr to avoid copying the whole
00111       // buffer each time the event record is handed on
00112       boost::shared_ptr<Entry> entry_;
00113       
00114     };
00115     
00116     
00117   public:
00118 
00119     DQMTopLevelFolder
00120     (
00121       const DQMKey&,
00122       const QueueIDs&,
00123       const DQMProcessingParams&,
00124       DQMEventMonitorCollection&,
00125       const unsigned int expectedUpdates,
00126       AlarmHandlerPtr
00127     );
00128 
00129     ~DQMTopLevelFolder();
00130 
00136     void addDQMEvent(const DQMEventMsgView&);
00137 
00144     void addDQMEvent(const I2OChain& dqmEvent);
00145 
00151     bool isReady(const utils::TimePoint_t& now) const;
00152 
00157     bool getRecord(Record&);
00158 
00159 
00160   private:
00161 
00162     void addEvent(std::auto_ptr<DQMEvent::TObjectTable>);
00163     size_t populateTable(DQMEvent::TObjectTable&) const;
00164 
00165     const DQMKey dqmKey_;
00166     const QueueIDs dqmConsumers_;
00167     const DQMProcessingParams dqmParams_;
00168     DQMEventMonitorCollection& dqmEventMonColl_;
00169     const unsigned int expectedUpdates_;
00170     AlarmHandlerPtr alarmHandler_;
00171 
00172     unsigned int nUpdates_;
00173     unsigned int mergeCount_;
00174     utils::TimePoint_t lastUpdate_;
00175     std::string releaseTag_;
00176     uint32_t updateNumber_;
00177     edm::Timestamp timeStamp_;
00178 
00179     typedef boost::shared_ptr<DQMFolder> DQMFolderPtr;
00180     typedef std::map<std::string, DQMFolderPtr> DQMFoldersMap;
00181     DQMFoldersMap dqmFolders_;
00182     
00183     static unsigned int sentEvents_;    
00184   };
00185 
00186   typedef boost::shared_ptr<DQMTopLevelFolder> DQMTopLevelFolderPtr;
00187 
00188 } // namespace stor
00189 
00190 #endif // EventFilter_StorageManager_DQMTopLevelFolder_h 
00191 
00192