CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

stor::DQMTopLevelFolder Class Reference

#include <DQMTopLevelFolder.h>

List of all members.

Classes

class  Record

Public Member Functions

void addDQMEvent (const DQMEventMsgView &)
void addDQMEvent (const I2OChain &dqmEvent)
 DQMTopLevelFolder (const DQMKey &, const QueueIDs &, const DQMProcessingParams &, DQMEventMonitorCollection &, const unsigned int expectedUpdates, AlarmHandlerPtr)
bool getRecord (Record &)
bool isReady (const utils::TimePoint_t &now) const
 ~DQMTopLevelFolder ()

Private Types

typedef boost::shared_ptr
< DQMFolder
DQMFolderPtr
typedef std::map< std::string,
DQMFolderPtr
DQMFoldersMap

Private Member Functions

void addEvent (std::auto_ptr< DQMEvent::TObjectTable >)
size_t populateTable (DQMEvent::TObjectTable &) const

Private Attributes

AlarmHandlerPtr alarmHandler_
const QueueIDs dqmConsumers_
DQMEventMonitorCollectiondqmEventMonColl_
DQMFoldersMap dqmFolders_
const DQMKey dqmKey_
const DQMProcessingParams dqmParams_
const unsigned int expectedUpdates_
utils::TimePoint_t lastUpdate_
unsigned int mergeCount_
unsigned int nUpdates_
std::string releaseTag_
edm::Timestamp timeStamp_
uint32_t updateNumber_

Static Private Attributes

static unsigned int sentEvents_

Detailed Description

Class holding information for one DQM event

Author:
mommsen
Revision:
1.5
Date:
2011/04/04 16:05:37

Definition at line 36 of file DQMTopLevelFolder.h.


Member Typedef Documentation

typedef boost::shared_ptr<DQMFolder> stor::DQMTopLevelFolder::DQMFolderPtr [private]

Definition at line 179 of file DQMTopLevelFolder.h.

typedef std::map<std::string, DQMFolderPtr> stor::DQMTopLevelFolder::DQMFoldersMap [private]

Definition at line 180 of file DQMTopLevelFolder.h.


Constructor & Destructor Documentation

stor::DQMTopLevelFolder::DQMTopLevelFolder ( const DQMKey dqmKey,
const QueueIDs dqmConsumers,
const DQMProcessingParams dqmParams,
DQMEventMonitorCollection dqmEventMonColl,
const unsigned int  expectedUpdates,
AlarmHandlerPtr  alarmHandler 
)

Definition at line 26 of file DQMTopLevelFolder.cc.

    :
  dqmKey_(dqmKey),
  dqmConsumers_(dqmConsumers),
  dqmParams_(dqmParams),
  dqmEventMonColl_(dqmEventMonColl),
  expectedUpdates_(expectedUpdates),
  alarmHandler_(alarmHandler),
  nUpdates_(0),
  mergeCount_(0),
  updateNumber_(0)
  {
    gROOT->SetBatch(kTRUE);
    dqmEventMonColl_.getNumberOfTopLevelFoldersMQ().addSample(1);
  }
stor::DQMTopLevelFolder::~DQMTopLevelFolder ( )

Definition at line 49 of file DQMTopLevelFolder.cc.

References dqmFolders_.

  {
    dqmFolders_.clear();
  }

Member Function Documentation

void stor::DQMTopLevelFolder::addDQMEvent ( const DQMEventMsgView view)

Adds the DQMEventMsgView, but does not take ownership of the underlying data buffer. Collates the histograms with the existing DQMEventMsgView if there is one.

Definition at line 55 of file DQMTopLevelFolder.cc.

References addEvent(), stor::MonitoredQuantity::addSample(), alarmHandler_, edm::StreamDQMDeserializer::deserializeDQMEvent(), dqmEventMonColl_, stor::AlarmHandler::ERROR, expectedUpdates_, stor::utils::getCurrentTime(), stor::DQMEventMonitorCollection::getDQMEventSizeMQ(), edm::Timestamp::invalidTimestamp(), lastUpdate_, DQMEventMsgView::lumiSection(), max(), DQMEventMsgView::mergeCount(), mergeCount_, min, MatrixRunner::msg, nUpdates_, DQMEventMsgView::releaseTag(), releaseTag_, DQMEventMsgView::size(), DQMEventMsgView::timeStamp(), timeStamp_, DQMEventMsgView::topFolderName(), DQMEventMsgView::updateNumber(), and updateNumber_.

  {
    if ( releaseTag_.empty() ) releaseTag_ = view.releaseTag();
    // A restarted EP will start counting at 0 again.
    // Thus, take the maximum of all updates we get.
    updateNumber_ = std::max(updateNumber_, view.updateNumber());
    if ( timeStamp_ == edm::Timestamp::invalidTimestamp() )
      timeStamp_ = view.timeStamp();
    else
      timeStamp_ = std::min(timeStamp_, view.timeStamp());
    mergeCount_ += std::max(1U, view.mergeCount());

    edm::StreamDQMDeserializer deserializer;
    std::auto_ptr<DQMEvent::TObjectTable> toTablePtr =
      deserializer.deserializeDQMEvent(view);
    
    addEvent(toTablePtr);
    
    ++nUpdates_;

    if (nUpdates_ > expectedUpdates_)
    {
      std::ostringstream msg;
      msg << "Received " << nUpdates_
        << " updates for top level folder " << view.topFolderName()
        << " and lumi section " << view.lumiSection()
        << " whereas only " << expectedUpdates_
        << " updates are expected.";
      XCEPT_DECLARE(exception::DQMEventProcessing,
        sentinelException, msg.str());
      alarmHandler_->notifySentinel(AlarmHandler::ERROR, sentinelException);
    }

    lastUpdate_ = utils::getCurrentTime();
    
    dqmEventMonColl_.getDQMEventSizeMQ().addSample(
      static_cast<double>(view.size()) / 0x100000
    );
  }
void stor::DQMTopLevelFolder::addDQMEvent ( const I2OChain dqmEvent)

Adds the DQM event message contained in the I2OChain. It copies the data from the I2OChain in its own buffer space. Collates the histograms with the existing DQMEventMsgView if there is one.

void stor::DQMTopLevelFolder::addEvent ( std::auto_ptr< DQMEvent::TObjectTable toTablePtr) [private]

Definition at line 112 of file DQMTopLevelFolder.cc.

References dqmFolders_, and pos.

Referenced by addDQMEvent().

  {
    for (
      DQMEvent::TObjectTable::const_iterator it = toTablePtr->begin(),
        itEnd = toTablePtr->end();
      it != itEnd; 
      ++it
    ) 
    {
      const std::string folderName = it->first;
      
      DQMFoldersMap::iterator pos = dqmFolders_.lower_bound(folderName);
      if ( pos == dqmFolders_.end() || (dqmFolders_.key_comp()(folderName, pos->first)) )
      {
        pos = dqmFolders_.insert(pos, DQMFoldersMap::value_type(
            folderName, DQMFolderPtr( new DQMFolder() )
          ));
      }
      pos->second->addObjects(it->second);
    }
  }
bool stor::DQMTopLevelFolder::getRecord ( DQMTopLevelFolder::Record record)

Populate the record with the currently available data. Return false if no data is available.

Definition at line 135 of file DQMTopLevelFolder.cc.

References stor::MonitoredQuantity::addSample(), edm::StreamDQMSerializer::adler32_chksum(), edm::StreamDQMSerializer::bufferPointer(), stor::DQMTopLevelFolder::Record::clear(), stor::DQMProcessingParams::compressionLevelDQM_, filterCSVwithJSON::copy, edm::StreamDQMSerializer::currentEventSize(), dqmConsumers_, dqmEventMonColl_, dqmKey_, dqmParams_, stor::DQMTopLevelFolder::Record::getBuffer(), stor::DQMEventMonitorCollection::getNumberOfUpdatesMQ(), stor::DQMEventMonitorCollection::getServedDQMEventSizeMQ(), stor::DQMKey::lumiSection, mergeCount_, nUpdates_, populateTable(), releaseTag_, stor::DQMKey::runNumber, sentEvents_, edm::StreamDQMSerializer::serializeDQMEvent(), LaserTracksInput_cfi::source, asciidump::table, stor::DQMTopLevelFolder::Record::tagForEventConsumers(), timeStamp_, stor::DQMKey::topLevelFolderName, stor::DQMTopLevelFolder::Record::totalDataSize(), updateNumber_, and stor::DQMProcessingParams::useCompressionDQM_.

  {
    if ( nUpdates_ == 0 ) return false;
    
    record.clear();
    record.tagForEventConsumers(dqmConsumers_);
    
    // Package list of TObjects into a DQMEvent::TObjectTable
    DQMEvent::TObjectTable table;
    const size_t folderSize = populateTable(table);
    
    edm::StreamDQMSerializer serializer;
    const size_t sourceSize =
      serializer.serializeDQMEvent(table,
        dqmParams_.useCompressionDQM_,
        dqmParams_.compressionLevelDQM_);
    
    // Add space for header
    const size_t totalSize =
      sourceSize
      + sizeof(DQMEventHeader)
      + 12*sizeof(uint32_t)
      + releaseTag_.length()
      + dqmKey_.topLevelFolderName.length()
    + folderSize;
    
    DQMEventMsgBuilder builder(
      record.getBuffer(totalSize),
      totalSize,
      dqmKey_.runNumber,
      ++sentEvents_,
      timeStamp_,
      dqmKey_.lumiSection,
      updateNumber_,
      (uint32_t)serializer.adler32_chksum(),
      toolbox::net::getHostName().c_str(),
      releaseTag_,
      dqmKey_.topLevelFolderName,
      table
    ); 
    unsigned char* source = serializer.bufferPointer();
    std::copy(source,source+sourceSize, builder.eventAddress());
    builder.setEventLength(sourceSize);
    if ( dqmParams_.useCompressionDQM_ ) 
    {
      // the "compression flag" contains the uncompressed size
      builder.setCompressionFlag(serializer.currentEventSize());
    }
    else
    {
      // a size of 0 indicates no compression
      builder.setCompressionFlag(0);
    }
    builder.setMergeCount(mergeCount_);
    dqmEventMonColl_.getNumberOfUpdatesMQ().addSample(nUpdates_);
    dqmEventMonColl_.getServedDQMEventSizeMQ().addSample(
      static_cast<double>(record.totalDataSize()) / 0x100000
    );
    
    return true;
  }
bool stor::DQMTopLevelFolder::isReady ( const utils::TimePoint_t now) const

Returns true if this top level folder is ready to be served. This is either the case if all expected updates have been received or when the last update was more than dqmParams.readyTimeDQM ago.

Definition at line 96 of file DQMTopLevelFolder.cc.

References stor::MonitoredQuantity::addSample(), dqmEventMonColl_, dqmParams_, expectedUpdates_, stor::DQMEventMonitorCollection::getNumberOfCompleteUpdatesMQ(), lastUpdate_, nUpdates_, and stor::DQMProcessingParams::readyTimeDQM_.

  {
    if ( nUpdates_ == 0 ) return false;
    
    if ( nUpdates_ == expectedUpdates_ )
    {
      dqmEventMonColl_.getNumberOfCompleteUpdatesMQ().addSample(1);
      return true;
    }
    
    if ( now > lastUpdate_ + dqmParams_.readyTimeDQM_ ) return true;
    
    return false;
  }
size_t stor::DQMTopLevelFolder::populateTable ( DQMEvent::TObjectTable table) const [private]

Definition at line 198 of file DQMTopLevelFolder.cc.

References dqmFolders_, and pos.

Referenced by getRecord().

  {
    size_t folderSize = 0;
    
    for ( DQMFoldersMap::const_iterator it = dqmFolders_.begin(), itEnd = dqmFolders_.end();
          it != itEnd; ++it )
    {
      const std::string folderName = it->first;
      const DQMFolderPtr folder = it->second;
      
      DQMEvent::TObjectTable::iterator pos = table.lower_bound(folderName);
      if ( pos == table.end() || (table.key_comp()(folderName, pos->first)) )
      {
        std::vector<TObject*> newObjectVector;
        pos = table.insert(pos, DQMEvent::TObjectTable::value_type(folderName, newObjectVector));
        folderSize += 2*sizeof(uint32_t) + folderName.length();
      }
      folder->fillObjectVector(pos->second);
    }
    return folderSize;
  }

Member Data Documentation

Definition at line 170 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent().

Definition at line 166 of file DQMTopLevelFolder.h.

Referenced by getRecord().

Definition at line 168 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), getRecord(), and isReady().

Definition at line 181 of file DQMTopLevelFolder.h.

Referenced by addEvent(), populateTable(), and ~DQMTopLevelFolder().

Definition at line 165 of file DQMTopLevelFolder.h.

Referenced by getRecord().

Definition at line 167 of file DQMTopLevelFolder.h.

Referenced by getRecord(), and isReady().

const unsigned int stor::DQMTopLevelFolder::expectedUpdates_ [private]

Definition at line 169 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and isReady().

Definition at line 174 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and isReady().

unsigned int stor::DQMTopLevelFolder::mergeCount_ [private]

Definition at line 173 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and getRecord().

unsigned int stor::DQMTopLevelFolder::nUpdates_ [private]

Definition at line 172 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), getRecord(), and isReady().

std::string stor::DQMTopLevelFolder::releaseTag_ [private]

Definition at line 175 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and getRecord().

unsigned int stor::DQMTopLevelFolder::sentEvents_ [static, private]

Definition at line 183 of file DQMTopLevelFolder.h.

Referenced by getRecord().

Definition at line 177 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and getRecord().

Definition at line 176 of file DQMTopLevelFolder.h.

Referenced by addDQMEvent(), and getRecord().