CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

DTCCBConfig Class Reference

#include <DTCCBConfig.h>

List of all members.

Public Types

typedef
ccb_config_map::const_iterator 
ccb_config_iterator
typedef std::vector< std::pair
< DTCCBId, std::vector< int > > > 
ccb_config_map
typedef std::vector< std::pair
< DTCCBId, int >
>::const_iterator 
const_iterator
 Access methods to data.

Public Member Functions

int appendConfigKey (int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
int appendConfigKey (const DTChamberId &id, const std::vector< int > &confKey)
const_iterator begin () const
void clear ()
 reset content
int configKey (int wheelId, int stationId, int sectorId, std::vector< int > &confKey) const
int configKey (const DTChamberId &id, std::vector< int > &confKey) const
ccb_config_map configKeyMap () const
 DTCCBConfig (const std::string &version)
 DTCCBConfig ()
const_iterator end () const
std::vector< DTConfigKeyfullKey () const
 get content
int setConfigKey (int wheelId, int stationId, int sectorId, const std::vector< int > &confKey)
int setConfigKey (const DTChamberId &id, const std::vector< int > &confKey)
void setFullKey (const std::vector< DTConfigKey > &)
void setStamp (int s)
int stamp () const
const std::string & version () const
 access version
std::string & version ()
virtual ~DTCCBConfig ()

Private Member Functions

void cacheMap () const
 read and store full content
void resetMap () const

Private Attributes

std::vector< std::pair
< DTCCBId, int > > 
dataList
std::string dataVersion
DTBufferTree< int, std::vector
< int > * > * 
dBuf
std::vector< DTConfigKeyfullConfigKey
int timeStamp

Detailed Description

Description: Class to hold configuration identifier for chambers

Date:
2013/05/23 15:59:44
Revision:
1.5
Author:
Paolo Ronchese INFN Padova

Definition at line 63 of file DTCCBConfig.h.


Member Typedef Documentation

typedef ccb_config_map::const_iterator DTCCBConfig::ccb_config_iterator

Definition at line 88 of file DTCCBConfig.h.

typedef std::vector< std::pair< DTCCBId,std::vector<int> > > DTCCBConfig::ccb_config_map

Definition at line 87 of file DTCCBConfig.h.

typedef std::vector< std::pair<DTCCBId,int> >::const_iterator DTCCBConfig::const_iterator

Access methods to data.

Definition at line 118 of file DTCCBConfig.h.


Constructor & Destructor Documentation

DTCCBConfig::DTCCBConfig ( )

Constructor

Definition at line 35 of file DTCCBConfig.cc.

References dataList, and dBuf.

                        :
  dataVersion( " " ) {
  dataList.reserve( 1000 );
  dBuf = 0;
}
DTCCBConfig::DTCCBConfig ( const std::string &  version)

Definition at line 42 of file DTCCBConfig.cc.

References dataList, and dBuf.

                                                  :
  dataVersion( version ) {
  dataList.reserve( 1000 );
  dBuf = 0;
}
DTCCBConfig::~DTCCBConfig ( ) [virtual]

Destructor

Definition at line 65 of file DTCCBConfig.cc.

References dBuf, and resetMap().

                          {
  resetMap();
//  DTDataBuffer< int,std::vector<int>* >::dropBuffer( mapName() );
  delete dBuf;
}

Member Function Documentation

int DTCCBConfig::appendConfigKey ( int  wheelId,
int  stationId,
int  sectorId,
const std::vector< int > &  confKey 
)

Definition at line 278 of file DTCCBConfig.cc.

References cacheMap(), dataList, dBuf, DTBufferTree< Key, Content >::find(), DTBufferTree< Key, Content >::insert(), combine::key, and DTCCBId::stationId.

Referenced by appendConfigKey(), DTKeyedConfigHandler::getNewObjects(), and DTUserKeyedConfigHandler::getNewObjects().

                                                                  {

//  std::string mName = mapName();
//  DTBufferTree< int,std::vector<int>* >* dBuf =
//  DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  if ( dBuf == 0 ) {
//    cacheMap();
//    dBuf =
//    DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  }
  if ( dBuf == 0 ) cacheMap();

  std::vector<int> chanKey;
  chanKey.reserve(3);
  chanKey.push_back(   wheelId );
  chanKey.push_back( stationId );
  chanKey.push_back(  sectorId );

  DTCCBId ccbId;
  ccbId.  wheelId =   wheelId;
  ccbId.stationId = stationId;
  ccbId. sectorId =  sectorId;
  std::vector<int>::const_iterator iter = confKey.begin();
  std::vector<int>::const_iterator iend = confKey.end();
  int key;

  std::vector<int>* confPtr;
  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );

  if ( searchStatus ) {
    dBuf->insert( chanKey.begin(),
                  chanKey.end(), confPtr = new std::vector<int>( confKey ) );
  }

  while ( iter != iend ) {
    key = *iter++;
    dataList.push_back( std::pair<DTCCBId,int>( ccbId, key ) );
    confPtr->push_back( key );
  }

  if ( !searchStatus ) {
    return -1;
  }
  else {
    return 0;
  }

}
int DTCCBConfig::appendConfigKey ( const DTChamberId id,
const std::vector< int > &  confKey 
)

Definition at line 331 of file DTCCBConfig.cc.

References appendConfigKey(), and relativeConstraints::station.

                                                                  {
  return appendConfigKey( id.wheel(),
                          id.station(),
                          id.sector(),
                          confKey );
}
DTCCBConfig::const_iterator DTCCBConfig::begin ( void  ) const

Definition at line 340 of file DTCCBConfig.cc.

References dataList.

Referenced by configKeyMap(), DTKeyedConfigHandler::getNewObjects(), and DTUserKeyedConfigHandler::getNewObjects().

                                                   {
  return dataList.begin();
}
void DTCCBConfig::cacheMap ( ) const [private]

read and store full content

Definition at line 359 of file DTCCBConfig.cc.

References dataList, dBuf, DTBufferTree< Key, Content >::find(), DTBufferTree< Key, Content >::insert(), DTBufferTree< Key, Content >::setDefault(), and DTCCBId::stationId.

Referenced by appendConfigKey(), configKey(), and setConfigKey().

                                 {

//  std::string mName = mapName();
//  DTBufferTree< int,std::vector<int>* >* dBuf =
//  DTDataBuffer< int,std::vector<int>* >::openBuffer( mName );
  DTBufferTree< int,std::vector<int>* >** pBuf;
  pBuf = const_cast<DTBufferTree< int,std::vector<int>* >**>( &dBuf );
  *pBuf = new DTBufferTree< int,std::vector<int>* >;
  dBuf->setDefault( 0 );

  const_iterator iter = dataList.begin();
  const_iterator iend = dataList.end();
  std::vector<int> chanKey;
  chanKey.reserve(3);
  while ( iter != iend ) {

    const DTCCBId& chan = iter->first;

    chanKey.clear();
    chanKey.push_back( chan.  wheelId );
    chanKey.push_back( chan.stationId );
    chanKey.push_back( chan. sectorId );
    std::vector<int>* ccbConfPtr;
    int searchStatus = dBuf->find( chanKey.begin(),
                                   chanKey.end(), ccbConfPtr );
    if ( searchStatus ) dBuf->insert( chanKey.begin(),
                                      chanKey.end(),
                                      ccbConfPtr = new std::vector<int> );
    ccbConfPtr->push_back( iter->second );

    iter++;

  }

}
void DTCCBConfig::clear ( void  )

reset content

Definition at line 182 of file DTCCBConfig.cc.

References dataList, dBuf, and resetMap().

                        {
  resetMap();
//  DTDataBuffer< int,std::vector<int>* >::dropBuffer( mapName() );
  delete dBuf;
  dBuf = 0;
  dataList.clear();
  return;
}
int DTCCBConfig::configKey ( int  wheelId,
int  stationId,
int  sectorId,
std::vector< int > &  confKey 
) const

Definition at line 93 of file DTCCBConfig.cc.

References cacheMap(), dBuf, and DTBufferTree< Key, Content >::find().

Referenced by configKey().

                                                            {

  confKey.clear();
//  std::string mName = mapName();
//  DTBufferTree< int,std::vector<int>* >* dBuf =
//  DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  if ( dBuf == 0 ) {
//    cacheMap();
//    dBuf =
//    DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  }
  if ( dBuf == 0 ) cacheMap();

  std::vector<int> chanKey;
  chanKey.reserve(3);
  chanKey.push_back(   wheelId );
  chanKey.push_back( stationId );
  chanKey.push_back(  sectorId );
  std::vector<int>* confPtr;
  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );
  if ( !searchStatus ) confKey = *confPtr;

  return searchStatus;

}
int DTCCBConfig::configKey ( const DTChamberId id,
std::vector< int > &  confKey 
) const

Definition at line 123 of file DTCCBConfig.cc.

References configKey(), and relativeConstraints::station.

                                                            {
  return configKey( id.wheel(),
                    id.station(),
                    id.sector(),
                    confKey );
}
DTCCBConfig::ccb_config_map DTCCBConfig::configKeyMap ( ) const

Definition at line 133 of file DTCCBConfig.cc.

References begin(), end(), and DTCCBId::stationId.

                                {

  ccb_config_map keyList;
  std::vector< std::pair<DTCCBId,int>* > tempList;
  const_iterator d_iter = begin();
  const_iterator d_iend = end();
  while ( d_iter != d_iend ) tempList.push_back(
                             new std::pair<DTCCBId,int>( *d_iter++ ) );
  std::vector< std::pair<DTCCBId,int>* >::iterator t_iter = tempList.begin();
  std::vector< std::pair<DTCCBId,int>* >::iterator t_iend = tempList.end();
  while ( t_iter != t_iend ) {
    std::pair<DTCCBId,int>* ptr = *t_iter++;
    if ( ptr == 0 ) continue;
    DTCCBId& ccbId = ptr->first;
    std::vector<int> cfgKeys;
    cfgKeys.push_back( ptr->second );
    std::vector< std::pair<DTCCBId,int>* >::iterator n_iter( t_iter );
    while( n_iter != t_iend ) {
      std::pair<DTCCBId,int>*& pck = *n_iter++;
      if ( pck == 0 ) continue; 
      DTCCBId& chkId = pck->first;
      if ( ( chkId.  wheelId == ccbId.  wheelId ) && 
           ( chkId.stationId == ccbId.stationId ) && 
           ( chkId. sectorId == ccbId. sectorId ) ) {
        cfgKeys.push_back( pck->second );
        delete pck;
        pck = 0;
      }
    }
    keyList.push_back( std::pair< DTCCBId,std::vector<int> >( ccbId,
                                                              cfgKeys ) );
    delete ptr;
  }
  return keyList;

}
DTCCBConfig::const_iterator DTCCBConfig::end ( void  ) const

Definition at line 345 of file DTCCBConfig.cc.

References dataList.

Referenced by configKeyMap(), DTKeyedConfigHandler::getNewObjects(), and DTUserKeyedConfigHandler::getNewObjects().

                                                 {
  return dataList.end();
}
std::vector< DTConfigKey > DTCCBConfig::fullKey ( ) const

get content

Operations

Definition at line 83 of file DTCCBConfig.cc.

References fullConfigKey.

                                                  {
  return fullConfigKey;
}
void DTCCBConfig::resetMap ( ) const [private]

Definition at line 396 of file DTCCBConfig.cc.

References DTBufferTree< Key, Content >::contList(), dBuf, and list().

Referenced by clear(), and ~DTCCBConfig().

                                 {
//  std::string mName = mapName();
//  DTBufferTree< int,std::vector<int>* >* dBuf =
//  DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
  if ( dBuf != 0 ) {
    std::vector< std::vector<int>* > list( dBuf->contList() );
    std::vector< std::vector<int>* >::const_iterator iter = list.begin();
    std::vector< std::vector<int>* >::const_iterator iend = list.end();
    while ( iter != iend ) delete *iter++;
  }
  return;
}
int DTCCBConfig::setConfigKey ( const DTChamberId id,
const std::vector< int > &  confKey 
)

Definition at line 269 of file DTCCBConfig.cc.

References setConfigKey(), and relativeConstraints::station.

                                                               {
  return setConfigKey( id.wheel(),
                       id.station(),
                       id.sector(),
                       confKey );
}
int DTCCBConfig::setConfigKey ( int  wheelId,
int  stationId,
int  sectorId,
const std::vector< int > &  confKey 
)

Definition at line 202 of file DTCCBConfig.cc.

References cacheMap(), dataList, dBuf, DTBufferTree< Key, Content >::find(), DTBufferTree< Key, Content >::insert(), and DTCCBId::stationId.

Referenced by setConfigKey().

                                                               {

//  std::string mName = mapName();
//  DTBufferTree< int,std::vector<int>* >* dBuf =
//  DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  if ( dBuf == 0 ) {
//    cacheMap();
//    dBuf =
//    DTDataBuffer< int,std::vector<int>* >::findBuffer( mName );
//  }
  if ( dBuf == 0 ) cacheMap();

  std::vector<int> chanKey;
  chanKey.reserve(3);
  chanKey.push_back(   wheelId );
  chanKey.push_back( stationId );
  chanKey.push_back(  sectorId );

  std::vector<int>* confPtr;
  int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), confPtr );

  if ( !searchStatus ) {
    std::vector< std::pair<DTCCBId,int> > tempList;
    const_iterator iter = dataList.begin();
    const_iterator iend = dataList.end();
    while ( iter != iend ) {
      const DTCCBId& ccbId( iter->first );
//      if ( ( ccbId.  wheelId ==   wheelId ) &&
//           ( ccbId.stationId == stationId ) &&
//           ( ccbId. sectorId ==  sectorId ) ) tempList.push_back( *iter );
      if ( ( ccbId.  wheelId !=   wheelId ) ||
           ( ccbId.stationId != stationId ) ||
           ( ccbId. sectorId !=  sectorId ) ) tempList.push_back( *iter );
      ++iter;
    }
    dataList = tempList;
    DTCCBId ccbId;
    ccbId.  wheelId =   wheelId;
    ccbId.stationId = stationId;
    ccbId. sectorId =  sectorId;
    std::vector<int>::const_iterator cfgIter = confKey.begin();
    std::vector<int>::const_iterator cfgIend = confKey.end();
    while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
                                                     ccbId, *cfgIter++ ) );
    *confPtr = confKey;
    return -1;
  }
  else {
    dBuf->insert( chanKey.begin(),
                  chanKey.end(), new std::vector<int>( confKey ) );
    DTCCBId ccbId;
    ccbId.  wheelId =   wheelId;
    ccbId.stationId = stationId;
    ccbId. sectorId =  sectorId;
    std::vector<int>::const_iterator cfgIter = confKey.begin();
    std::vector<int>::const_iterator cfgIend = confKey.end();
    while ( cfgIter != cfgIend ) dataList.push_back( std::pair<DTCCBId,int>(
                                                     ccbId, *cfgIter++ ) );
    return 0;
  }

}
void DTCCBConfig::setFullKey ( const std::vector< DTConfigKey > &  key)
void DTCCBConfig::setStamp ( int  s)
int DTCCBConfig::stamp ( ) const

Definition at line 88 of file DTCCBConfig.cc.

References timeStamp.

                             {
  return timeStamp;
}
std::string & DTCCBConfig::version ( )

Definition at line 177 of file DTCCBConfig.cc.

References dataVersion.

                                {
  return dataVersion;
}
const std::string & DTCCBConfig::version ( ) const

access version

Definition at line 172 of file DTCCBConfig.cc.

References dataVersion.

                                      {
  return dataVersion;
}

Member Data Documentation

std::vector< std::pair<DTCCBId,int> > DTCCBConfig::dataList [private]

Definition at line 127 of file DTCCBConfig.h.

Referenced by appendConfigKey(), begin(), cacheMap(), clear(), DTCCBConfig(), end(), and setConfigKey().

std::string DTCCBConfig::dataVersion [private]

Definition at line 125 of file DTCCBConfig.h.

Referenced by version().

DTBufferTree< int,std::vector<int>* >* DTCCBConfig::dBuf [private]
std::vector<DTConfigKey> DTCCBConfig::fullConfigKey [private]

Definition at line 126 of file DTCCBConfig.h.

Referenced by fullKey(), and setFullKey().

int DTCCBConfig::timeStamp [private]

Definition at line 124 of file DTCCBConfig.h.

Referenced by setStamp(), and stamp().