CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripHistoTitle Class Reference

Utility class that holds histogram title. More...

#include <SiStripHistoTitle.h>

List of all members.

Public Member Functions

const uint16_t & channel () const
const std::string & extraInfo () const
const sistrip::Granularitygranularity () const
const sistrip::HistoTypehistoType () const
const sistrip::KeyTypekeyType () const
const uint32_t & keyValue () const
const sistrip::RunTyperunType () const
 SiStripHistoTitle (const sistrip::HistoType &histo_type, const sistrip::RunType &run_type, const sistrip::KeyType &key_type, const uint32_t &key_value, const sistrip::Granularity &gran, const uint16_t &channel, const std::string &extra_info="")
 SiStripHistoTitle (const sistrip::HistoType &histo_type, const sistrip::RunType &run_type, const SiStripKey &key, const std::string &extra_info="")
 SiStripHistoTitle (const std::string &histo_title)
const std::string & title () const

Private Member Functions

void extractTitle ()
void setTitle ()
 SiStripHistoTitle ()

Private Attributes

uint16_t channel_
std::string extraInfo_
sistrip::Granularity granularity_
sistrip::HistoType histoType_
sistrip::KeyType keyType_
uint32_t keyValue_
sistrip::RunType runType_
std::string title_

Detailed Description

Utility class that holds histogram title.

Author:
R.Bainbridge

Definition at line 21 of file SiStripHistoTitle.h.


Constructor & Destructor Documentation

SiStripHistoTitle::SiStripHistoTitle ( const sistrip::HistoType histo_type,
const sistrip::RunType run_type,
const SiStripKey key,
const std::string &  extra_info = "" 
)

Constructs histogram title from key object.

Definition at line 14 of file SiStripHistoTitle.cc.

References SiStripKey::channel(), channel_, sistrip::FEC_KEY, sistrip::FED_KEY, SiStripKey::granularity(), granularity_, SiStripKey::key(), keyType_, keyValue_, setTitle(), groupFilesInBlocks::temp, and sistrip::UNKNOWN_KEY.

  : title_(""),
    histoType_(histo_type),
    runType_(run_type),
    keyType_(sistrip::UNKNOWN_KEY),
    keyValue_(sistrip::invalid32_),
    granularity_(sistrip::UNKNOWN_GRAN),
    channel_(sistrip::invalid_),
    extraInfo_(extra_info)
{
  SiStripKey& temp = const_cast<SiStripKey&>(key_object);
  if ( &dynamic_cast<SiStripFedKey&>(temp) ) {
    keyType_ = sistrip::FED_KEY;
  } else if ( &dynamic_cast<SiStripFecKey&>(temp) ) {
    keyType_ = sistrip::FEC_KEY;
  } else {
    keyType_ = sistrip::UNKNOWN_KEY;
  }
  if ( &key_object ) {
    keyValue_ = key_object.key();
    granularity_ = key_object.granularity();
    channel_ = key_object.channel();
  }
  setTitle();
}
SiStripHistoTitle::SiStripHistoTitle ( const sistrip::HistoType histo_type,
const sistrip::RunType run_type,
const sistrip::KeyType key_type,
const uint32_t &  key_value,
const sistrip::Granularity gran,
const uint16_t &  channel,
const std::string &  extra_info = "" 
)

Constructs histogram title from various data.

Definition at line 45 of file SiStripHistoTitle.cc.

References setTitle().

  : title_(""),
    histoType_(histo_type),
    runType_(run_type),
    keyType_(key_type),
    keyValue_(key_value),
    granularity_(gran),
    channel_(channel),
    extraInfo_(extra_info)
{
  setTitle();
}
SiStripHistoTitle::SiStripHistoTitle ( const std::string &  histo_title)
SiStripHistoTitle::SiStripHistoTitle ( ) [inline, private]

Private default constructor.

Definition at line 76 of file SiStripHistoTitle.h.

{;}

Member Function Documentation

const uint16_t & SiStripHistoTitle::channel ( ) const [inline]

Returns channel for histogram granularity.

Definition at line 120 of file SiStripHistoTitle.h.

References channel_.

Referenced by operator<<().

{ return channel_; }
void SiStripHistoTitle::extractTitle ( ) [private]

Extracts member data values from title.

Definition at line 110 of file SiStripHistoTitle.cc.

References channel_, extraInfo_, granularity(), granularity_, sistrip::hex_, histoType(), histoType_, sistrip::invalid_, combine::key, keyType(), keyType_, keyValue_, pos, position, runType(), runType_, sistrip::sep_, title_, sistrip::UNDEFINED_GRAN, sistrip::UNKNOWN_GRAN, and sistrip::UNKNOWN_HISTO_TYPE.

Referenced by SiStripHistoTitle().

                                     {
  
  std::string::size_type length = title_.length();
  std::string::size_type position = 0;
  std::string::size_type pos = 0;
  std::string::size_type siz = 0;
  
  // Extract HistoType
  siz = title_.find(sistrip::sep_,position) - position;
  histoType_ = SiStripEnumsAndStrings::histoType( title_.substr(position,siz) );
  std::string histo_type = SiStripEnumsAndStrings::histoType( histoType_ );
  position += title_.substr(position).find( histo_type ) + histo_type.size() + (sizeof(sistrip::sep_) - 1);
  if ( histoType_ == sistrip::UNKNOWN_HISTO_TYPE ) { position = 0; }
  else if ( position >= length ) { return; }
  
  // Extract RunType
  siz = title_.find(sistrip::sep_,position) - position;
  runType_ = SiStripEnumsAndStrings::runType( title_.substr(position,siz) );
  std::string run_type = SiStripEnumsAndStrings::runType( runType_ );
  position += title_.substr(position).find( run_type ) + run_type.size() + (sizeof(sistrip::sep_) - 1);
  if ( position >= length ) { return; }
  
  // Extract KeyType
  siz = title_.find(sistrip::sep_,position) - position;
  keyType_ = SiStripEnumsAndStrings::keyType( title_.substr(position,siz) );
  std::string key_type = SiStripEnumsAndStrings::keyType( keyType_ );
  position += title_.substr(position).find( key_type ) + key_type.size() + (sizeof(sistrip::hex_) - 1);
  if ( position >= length ) { return; }
  
  // Extract KeyValue
  siz = 8;
  std::stringstream key; 
  key << title_.substr(position,siz);
  key >> std::hex >> keyValue_;
  position += siz + (sizeof(sistrip::sep_) - 1);
  if ( position >= length ) { return; }
  
  // Extract Granularity
  pos = title_.find(sistrip::sep_,position);
  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
  else { siz = pos - position; }
  granularity_ = SiStripEnumsAndStrings::granularity( title_.substr(position,siz) );
  std::string gran = SiStripEnumsAndStrings::granularity( granularity_ );
  position += title_.substr(position).find( gran ) + gran.size();
  if ( position > length ) { return; }

  // Extract Channel 
  pos = title_.find(sistrip::sep_,position);
  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
  else { siz = pos - position; }
  if ( position == length || !siz ) {
    if ( granularity_ != sistrip::UNDEFINED_GRAN ) { channel_ = 0; }
    else if ( granularity_ == sistrip::UNKNOWN_GRAN ) { channel_ = sistrip::invalid_; }
  } else {
    std::stringstream chan; 
    chan << title_.substr(position,siz);
    chan >> std::dec >> channel_;
  }
  position += siz + (sizeof(sistrip::sep_) - 1);
  if ( position >= length ) { return; }
  
  // Extract ExtraInfo
  extraInfo_ = title_.substr( position, std::string::npos - position ); 
  
}
const std::string & SiStripHistoTitle::extraInfo ( ) const [inline]

Extra information attached to histogram title.

Definition at line 121 of file SiStripHistoTitle.h.

References extraInfo_.

Referenced by operator<<().

{ return extraInfo_; }
const sistrip::Granularity & SiStripHistoTitle::granularity ( ) const [inline]

Returns granularity of histogram.

Definition at line 119 of file SiStripHistoTitle.h.

References granularity_.

Referenced by extractTitle(), operator<<(), and setTitle().

{ return granularity_; }
const sistrip::HistoType & SiStripHistoTitle::histoType ( ) const [inline]

Returns the histogram type.

Definition at line 115 of file SiStripHistoTitle.h.

References histoType_.

Referenced by extractTitle(), operator<<(), and setTitle().

{ return histoType_; }
const sistrip::KeyType & SiStripHistoTitle::keyType ( ) const [inline]

Defines key type used to form the histogram title.

Definition at line 117 of file SiStripHistoTitle.h.

References keyType_.

Referenced by extractTitle(), operator<<(), and setTitle().

{ return keyType_; } 
const uint32_t & SiStripHistoTitle::keyValue ( ) const [inline]

Returns values of the 32-bit key.

Definition at line 118 of file SiStripHistoTitle.h.

References keyValue_.

Referenced by operator<<().

{ return keyValue_; }
const sistrip::RunType & SiStripHistoTitle::runType ( ) const [inline]

Returns the run type.

Definition at line 116 of file SiStripHistoTitle.h.

References runType_.

Referenced by extractTitle(), operator<<(), and setTitle().

{ return runType_; }
void SiStripHistoTitle::setTitle ( ) [private]

Constructs histogram title.

Definition at line 81 of file SiStripHistoTitle.cc.

References channel_, extraInfo_, granularity(), granularity_, sistrip::hex_, histoType(), histoType_, keyType(), keyType_, keyValue_, runType(), runType_, sistrip::sep_, title(), and title_.

Referenced by SiStripHistoTitle().

                                 {

  std::stringstream title;

  // Append HistoType, RunType, KeyType and KeyValue
  title << SiStripEnumsAndStrings::histoType( histoType_ )
        << sistrip::sep_
        << SiStripEnumsAndStrings::runType( runType_ )
        << sistrip::sep_
        << SiStripEnumsAndStrings::keyType( keyType_ )
        << sistrip::hex_ 
        << std::setfill('0') << std::setw(8) << std::hex << keyValue_ << std::dec
        << sistrip::sep_;
  
  // Append Granularity and channel number
  title << SiStripEnumsAndStrings::granularity( granularity_ );
  if ( channel_ ) { title << channel_; }
  
  // Append extra info
  if ( extraInfo_ != "" ) { 
    title << sistrip::sep_ << extraInfo_; 
  }
  
  title_ = title.str();

}
const std::string & SiStripHistoTitle::title ( ) const [inline]

Member Data Documentation

uint16_t SiStripHistoTitle::channel_ [private]

Channel number for granularity.

Definition at line 105 of file SiStripHistoTitle.h.

Referenced by channel(), extractTitle(), setTitle(), and SiStripHistoTitle().

std::string SiStripHistoTitle::extraInfo_ [private]

Extra information to be attached to title.

Definition at line 108 of file SiStripHistoTitle.h.

Referenced by extractTitle(), extraInfo(), and setTitle().

Granularity of histogram.

Definition at line 102 of file SiStripHistoTitle.h.

Referenced by extractTitle(), granularity(), setTitle(), and SiStripHistoTitle().

Defines histo type.

Definition at line 90 of file SiStripHistoTitle.h.

Referenced by extractTitle(), histoType(), and setTitle().

Defines key type.

Definition at line 96 of file SiStripHistoTitle.h.

Referenced by extractTitle(), keyType(), setTitle(), and SiStripHistoTitle().

uint32_t SiStripHistoTitle::keyValue_ [private]

Key value.

Definition at line 99 of file SiStripHistoTitle.h.

Referenced by extractTitle(), keyValue(), setTitle(), and SiStripHistoTitle().

Defines run type.

Definition at line 93 of file SiStripHistoTitle.h.

Referenced by extractTitle(), runType(), and setTitle().

std::string SiStripHistoTitle::title_ [private]

Histogram title.

Definition at line 87 of file SiStripHistoTitle.h.

Referenced by extractTitle(), setTitle(), and title().