CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

SiStripFecKey Class Reference

Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25. More...

#include <SiStripFecKey.h>

Inheritance diagram for SiStripFecKey:
SiStripKey

List of all members.

Public Member Functions

const uint16_t & ccuAddr () const
const uint16_t & ccuChan () const
const uint16_t & fecCrate () const
const uint16_t & fecRing () const
const uint16_t & fecSlot () const
const uint16_t & i2cAddr () const
bool isConsistent (const SiStripKey &) const
bool isEqual (const SiStripKey &) const
bool isInvalid () const
bool isInvalid (const sistrip::Granularity &) const
bool isValid () const
bool isValid (const sistrip::Granularity &) const
const uint16_t & lldChan () const
virtual void print (std::stringstream &ss) const
 SiStripFecKey ()
 SiStripFecKey (const uint16_t &fec_crate, const uint16_t &fec_slot=0, const uint16_t &fec_ring=0, const uint16_t &ccu_addr=0, const uint16_t &ccu_chan=0, const uint16_t &lld_chan=0, const uint16_t &i2c_addr=0)
 SiStripFecKey (const uint32_t &fec_key)
 SiStripFecKey (const SiStripKey &)
 SiStripFecKey (const SiStripKey &, const sistrip::Granularity &)
 SiStripFecKey (const std::string &directory_path)
 SiStripFecKey (const SiStripFecKey &)
virtual void terse (std::stringstream &ss) const

Static Public Member Functions

static bool firstApvOfPair (const uint16_t &i2c_addr)
static uint16_t hybridPos (const uint16_t &i2c_addr)
static uint16_t i2cAddr (const uint16_t &hybrid_pos)
static uint16_t i2cAddr (const uint16_t &lld_chan, const bool &first_apv_of_pair)
static uint16_t lldChan (const uint16_t &i2c_addr)

Private Member Functions

void initFromKey ()
void initFromPath ()
void initFromValue ()
void initGranularity ()

Private Attributes

uint16_t ccuAddr_
uint16_t ccuChan_
uint16_t fecCrate_
uint16_t fecRing_
uint16_t fecSlot_
uint16_t i2cAddr_
uint16_t lldChan_

Static Private Attributes

static const uint16_t ccuAddrMask_ = 0xFF
static const uint16_t ccuAddrOffset_ = 10
static const uint16_t ccuChanMask_ = 0x1F
static const uint16_t ccuChanOffset_ = 5
static const uint16_t fecCrateMask_ = 0x07
static const uint16_t fecCrateOffset_ = 27
static const uint16_t fecRingMask_ = 0x0F
static const uint16_t fecRingOffset_ = 18
static const uint16_t fecSlotMask_ = 0x1F
static const uint16_t fecSlotOffset_ = 22
static const uint16_t i2cAddrMask_ = 0x03
static const uint16_t i2cAddrOffset_ = 0
static const uint16_t lldChanMask_ = 0x07
static const uint16_t lldChanOffset_ = 2

Detailed Description

Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.

Author:
R.Bainbridge

The class allows to encode the position within a 32-bit "key" and, conversely, unpack a 32-bit key to provide the position.

The class provides the following member data:

Member data (integer in type only) with values of 0xFFFF signifies "invalid" (ie, FecSlot = 0xFFFF means "invalid FEC slot"). Data with null values signifies "all" (ie, FecSlot = 0 means "all FEC slots").

The class generates a "directory path" string according to the member data. This can be used to organise histograms / other data types when using DQM / root. Conversely, the member data can also be built using the directory path when provided as a constructor argument.

The class also provides the "granularity" to which the FEC key is unambiguous (ie, not "invalid" or "null") in defining a position within the control system.

Definition at line 46 of file SiStripFecKey.h.


Constructor & Destructor Documentation

SiStripFecKey::SiStripFecKey ( const uint16_t &  fec_crate,
const uint16_t &  fec_slot = 0,
const uint16_t &  fec_ring = 0,
const uint16_t &  ccu_addr = 0,
const uint16_t &  ccu_chan = 0,
const uint16_t &  lld_chan = 0,
const uint16_t &  i2c_addr = 0 
)

Constructor using crate, FEC, ring, CCU, module and channel.

Definition at line 14 of file SiStripFecKey.cc.

References initFromKey(), initFromPath(), initFromValue(), and initGranularity().

                                                         :
  SiStripKey(),
  fecCrate_(fec_crate), 
  fecSlot_(fec_slot),
  fecRing_(fec_ring), 
  ccuAddr_(ccu_addr),
  ccuChan_(ccu_chan),
  lldChan_(lld_chan),
  i2cAddr_(i2c_addr)
{
  // order is important!
  initFromValue();
  initFromKey();
  initFromPath();
  initGranularity();
}
SiStripFecKey::SiStripFecKey ( const uint32_t &  fec_key)
SiStripFecKey::SiStripFecKey ( const std::string &  directory_path)
SiStripFecKey::SiStripFecKey ( const SiStripFecKey input)

Copy constructor.

Definition at line 77 of file SiStripFecKey.cc.

References SiStripKey::granularity(), SiStripKey::key(), and SiStripKey::path().

                                                         :
  SiStripKey(),
  fecCrate_(input.fecCrate()), 
  fecSlot_(input.fecSlot()),
  fecRing_(input.fecRing()), 
  ccuAddr_(input.ccuAddr()),
  ccuChan_(input.ccuChan()), 
  lldChan_(input.lldChan()), 
  i2cAddr_(input.i2cAddr())
{
  key(input.key());
  path(input.path());
  granularity(input.granularity());
}
SiStripFecKey::SiStripFecKey ( const SiStripKey input)
SiStripFecKey::SiStripFecKey ( const SiStripKey input,
const sistrip::Granularity gran 
)

Copy to level specified by granularity.

Definition at line 121 of file SiStripFecKey.cc.

References sistrip::APV, sistrip::CCU_ADDR, sistrip::CCU_CHAN, ccuAddr(), ccuAddr_, ccuChan(), ccuChan_, sistrip::FEC_CRATE, sistrip::FEC_RING, sistrip::FEC_SLOT, fecCrate(), fecCrate_, fecRing(), fecRing_, fecSlot(), fecSlot_, i2cAddr(), i2cAddr_, initFromKey(), initFromPath(), initFromValue(), initGranularity(), LaserDQM_cfg::input, sistrip::LLD_CHAN, lldChan(), and lldChan_.

                                                               :
  SiStripKey(),
  fecCrate_(0), 
  fecSlot_(0),
  fecRing_(0), 
  ccuAddr_(0),
  ccuChan_(0), 
  lldChan_(0),
  i2cAddr_(0)
{
  const SiStripFecKey& fec_key = dynamic_cast<const SiStripFecKey&>(input);
  if ( (&fec_key) ) {
    
    if ( gran == sistrip::FEC_CRATE || gran == sistrip::FEC_SLOT ||
         gran == sistrip::FEC_RING || gran == sistrip::CCU_ADDR ||
         gran == sistrip::CCU_CHAN || gran == sistrip::LLD_CHAN ||
         gran == sistrip::APV ) {
      fecCrate_ = fec_key.fecCrate(); 
    }

    if ( gran == sistrip::FEC_SLOT || gran == sistrip::FEC_RING ||
         gran == sistrip::CCU_ADDR || gran == sistrip::CCU_CHAN ||
         gran == sistrip::LLD_CHAN || gran == sistrip::APV ) {
      fecSlot_ = fec_key.fecSlot();
    }

    if ( gran == sistrip::FEC_RING || gran == sistrip::CCU_ADDR ||
         gran == sistrip::CCU_CHAN || gran == sistrip::LLD_CHAN ||
         gran == sistrip::APV ) {
      fecRing_ = fec_key.fecRing(); 
    }

    if ( gran == sistrip::CCU_ADDR || gran == sistrip::CCU_CHAN ||
         gran == sistrip::LLD_CHAN || gran == sistrip::APV ) {
      ccuAddr_ = fec_key.ccuAddr();
    }

    if ( gran == sistrip::CCU_CHAN || gran == sistrip::LLD_CHAN ||
         gran == sistrip::APV ) {
      ccuChan_ = fec_key.ccuChan(); 
    }

    if ( gran == sistrip::LLD_CHAN || gran == sistrip::APV ) {
      lldChan_ = fec_key.lldChan();
    }

    if ( gran == sistrip::APV ) {
      i2cAddr_ = fec_key.i2cAddr();
    }

    initFromValue();
    initFromKey();
    initFromPath();
    initGranularity();
    
  }

}
SiStripFecKey::SiStripFecKey ( )

Member Function Documentation

const uint16_t & SiStripFecKey::ccuAddr ( ) const [inline]
const uint16_t & SiStripFecKey::ccuChan ( ) const [inline]
const uint16_t & SiStripFecKey::fecCrate ( ) const [inline]
const uint16_t & SiStripFecKey::fecRing ( ) const [inline]
const uint16_t & SiStripFecKey::fecSlot ( ) const [inline]
bool SiStripFecKey::firstApvOfPair ( const uint16_t &  i2c_addr) [static]

Identifies if first APV of pair for given I2C addr (32-37).

Definition at line 240 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, and sistrip::invalid_.

Referenced by initFromKey().

                                                             {
  if ( i2c_addr < sistrip::APV_I2C_MIN ||
       i2c_addr > sistrip::APV_I2C_MAX ) {
    return sistrip::invalid_;
  }
  return ( ( ( i2c_addr - sistrip::APV_I2C_MIN ) % 2 ) == 0 );
}
uint16_t SiStripFecKey::hybridPos ( const uint16_t &  i2c_addr) [static]

Returns hybrid position (1-6) for a given I2C addr (32-37).

Definition at line 196 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, and sistrip::invalid_.

                                                            {
  if ( i2c_addr < sistrip::APV_I2C_MIN ||
       i2c_addr > sistrip::APV_I2C_MAX ) {
    return sistrip::invalid_;
  }
  return ( i2c_addr - sistrip::APV_I2C_MIN + 1 );
}
uint16_t SiStripFecKey::i2cAddr ( const uint16_t &  hybrid_pos) [static]

Returns I2C addr (32-37) for a given hybrid position (1-6).

Definition at line 206 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, and sistrip::invalid_.

                                                            {
  if ( !hybrid_pos ||
       hybrid_pos > 
       ( sistrip::APV_I2C_MAX - 
         sistrip::APV_I2C_MIN + 1 ) ) {
    return sistrip::invalid_;
  }
  return ( hybrid_pos + sistrip::APV_I2C_MIN - 1 );
}
uint16_t SiStripFecKey::i2cAddr ( const uint16_t &  lld_chan,
const bool &  first_apv_of_pair 
) [static]

Returns I2C addr (32-37) for LLD chan (1-3) and APV pos.

Definition at line 218 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MIN, sistrip::APVS_PER_CHAN, sistrip::invalid_, sistrip::LLD_CHAN_MAX, and sistrip::LLD_CHAN_MIN.

                                                         {
  if ( lld_chan < sistrip::LLD_CHAN_MIN ||
       lld_chan > sistrip::LLD_CHAN_MAX ) {
    return sistrip::invalid_; 
  }
  return ( sistrip::APV_I2C_MIN + lld_chan * sistrip::APVS_PER_CHAN - (first_apv?2:1) );
}
const uint16_t & SiStripFecKey::i2cAddr ( ) const [inline]
void SiStripFecKey::initFromKey ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 422 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, sistrip::CCU_ADDR_MAX, sistrip::CCU_ADDR_MIN, sistrip::CCU_CHAN_MAX, sistrip::CCU_CHAN_MIN, ccuAddr_, ccuAddrMask_, ccuAddrOffset_, ccuChan_, ccuChanMask_, ccuChanOffset_, sistrip::CRATE_SLOT_MAX, sistrip::CRATE_SLOT_MIN, sistrip::FEC_CRATE_MAX, sistrip::FEC_CRATE_MIN, sistrip::FEC_RING_MAX, sistrip::FEC_RING_MIN, fecCrate_, fecCrateMask_, fecCrateOffset_, fecRing_, fecRingMask_, fecRingOffset_, fecSlot_, fecSlotMask_, fecSlotOffset_, firstApvOfPair(), i2cAddr(), i2cAddr_, i2cAddrMask_, i2cAddrOffset_, sistrip::invalid32_, sistrip::invalid_, SiStripKey::key(), sistrip::LLD_CHAN_MAX, sistrip::LLD_CHAN_MIN, lldChan(), lldChan_, lldChanMask_, and lldChanOffset_.

Referenced by SiStripFecKey().

                                {
  
  if ( key() == sistrip::invalid32_ ) { 

    // ---------- Set FecKey based on member data ----------
    
    // Initialise to null value
    key(0);
    
    // Extract FEC crate  
    if ( fecCrate_ >= sistrip::FEC_CRATE_MIN &&
         fecCrate_ <= sistrip::FEC_CRATE_MAX ) {
      key( key() | (fecCrate_<<fecCrateOffset_) );
    } else if ( fecCrate_ == 0 ) { 
      key( key() | (fecCrate_<<fecCrateOffset_) );
    } else { 
      key( key() | (fecCrateMask_<<fecCrateOffset_) ); 
    }

    // Extract FEC slot
    if ( fecSlot_ >= sistrip::CRATE_SLOT_MIN &&
         fecSlot_ <= sistrip::CRATE_SLOT_MAX ) {
      key( key() | (fecSlot_<<fecSlotOffset_) );
    } else if ( fecSlot_ == 0 ) { 
      key( key() | (fecSlot_<<fecSlotOffset_) );
    } else { 
      key( key() | (fecSlotMask_<<fecSlotOffset_) ); 
    }

    // Extract FEC ring
    if ( fecRing_ >= sistrip::FEC_RING_MIN &&
         fecRing_ <= sistrip::FEC_RING_MAX ) {
      key( key() | (fecRing_<<fecRingOffset_) );
    } else if ( fecRing_ == 0 ) { 
      key( key() | (fecRing_<<fecRingOffset_) );
    } else { 
      key( key() | (fecRingMask_<<fecRingOffset_) ); 
    }

    // Extract CCU addr
    if ( ccuAddr_ >= sistrip::CCU_ADDR_MIN &&
         ccuAddr_ <= sistrip::CCU_ADDR_MAX ) {
      key( key() | (ccuAddr_<<ccuAddrOffset_) );
    } else if ( ccuAddr_ == 0 ) { 
      key( key() | (ccuAddr_<<ccuAddrOffset_) );
    } else { 
      key( key() | (ccuAddrMask_<<ccuAddrOffset_) ); 
    }

    // Extract CCU chan
    if ( ccuChan_ >= sistrip::CCU_CHAN_MIN &&
         ccuChan_ <= sistrip::CCU_CHAN_MAX ) {
      key( key() | ( (ccuChan_-(sistrip::CCU_CHAN_MIN-1)) << ccuChanOffset_ ) ); 
    } else if ( ccuChan_ == 0 ) { 
      key( key() | (ccuChan_<<ccuChanOffset_) );
    } else { 
      key( key() | (ccuChanMask_<<ccuChanOffset_) ); 
    }
    
    // Extract LLD channel
    if ( lldChan_ >= sistrip::LLD_CHAN_MIN &&
         lldChan_ <= sistrip::LLD_CHAN_MAX ) {
      key( key() | (lldChan_<<lldChanOffset_) ); 
    } else if ( lldChan_ == 0 ) { 
      key( key() | (lldChan_<<lldChanOffset_) );
    } else { 
      key( key() | (lldChanMask_<<lldChanOffset_) ); 
    }
    
    // Extract APV I2C address
    if ( i2cAddr_ >= sistrip::APV_I2C_MIN &&
         i2cAddr_ <= sistrip::APV_I2C_MAX ) {
      key( key() | ( ( firstApvOfPair( i2cAddr_ ) ? 1 : 2 ) << i2cAddrOffset_ ) ); // key encodes APV number (1 or 2)
      if ( lldChan_ && lldChan( i2cAddr_ ) != lldChan_ ) { 
        i2cAddr_ = sistrip::invalid_;
        key( key() | (i2cAddrMask_<<i2cAddrOffset_) ); 
      }
    } else if ( i2cAddr_ == 0 ) { 
      key( key() | (i2cAddr_<<i2cAddrOffset_) );
    } else { 
      key( key() | (i2cAddrMask_<<i2cAddrOffset_) ); 
    }
    
  } else {
    
    // ---------- Set member data based on FEC key ----------

    fecCrate_ = ( key()>>fecCrateOffset_ ) & fecCrateMask_;
    fecSlot_  = ( key()>>fecSlotOffset_ )  & fecSlotMask_;
    fecRing_  = ( key()>>fecRingOffset_ )  & fecRingMask_;
    ccuAddr_  = ( key()>>ccuAddrOffset_ )  & ccuAddrMask_;
    ccuChan_  = ( key()>>ccuChanOffset_ )  & ccuChanMask_;
    lldChan_  = ( key()>>lldChanOffset_ )  & lldChanMask_;
    i2cAddr_  = ( key()>>i2cAddrOffset_ )  & i2cAddrMask_;

    if ( fecCrate_ == fecCrateMask_ ) { fecCrate_ = sistrip::invalid_; } 
    if ( fecSlot_ == fecSlotMask_ ) { fecSlot_ = sistrip::invalid_; } 
    if ( fecRing_ == fecRingMask_ ) { fecRing_ = sistrip::invalid_; } 
    if ( ccuAddr_ == ccuAddrMask_ ) { ccuAddr_ = sistrip::invalid_; } 
    if ( ccuChan_ == ccuChanMask_ ) { ccuChan_ = sistrip::invalid_; }
    else if ( ccuChan_ ) { ccuChan_ += (sistrip::CCU_CHAN_MIN-1); }
    if ( lldChan_ == lldChanMask_ ) { lldChan_ = sistrip::invalid_; }
    if ( i2cAddr_ == i2cAddrMask_ ) { i2cAddr_ = sistrip::invalid_; }
    else if ( i2cAddr_ && lldChan_ != lldChanMask_ ) { i2cAddr_ = i2cAddr( lldChan_, 2-i2cAddr_ ); }
    
  }
  
}
void SiStripFecKey::initFromPath ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 533 of file SiStripFecKey.cc.

References sistrip::apv_, sistrip::ccuAddr_, ccuAddr_, ccuChan_, sistrip::ccuChan_, sistrip::controlView_, dir, sistrip::dir_, fecCrate_, sistrip::fecCrate_, sistrip::fecRing_, fecRing_, fecSlot_, sistrip::fecSlot_, spr::find(), i2cAddr_, sistrip::lldChan_, lldChan_, sistrip::null_, SiStripKey::path(), sistrip::root_, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by SiStripFecKey().

                                 {
  
  if ( path() == sistrip::null_ ) {
    
    // ---------- Set directory path based on member data ----------

    std::stringstream dir;
    
    dir << sistrip::root_ << sistrip::dir_ 
        << sistrip::controlView_ << sistrip::dir_;

    // Add FEC crate
    if ( fecCrate_ ) {
      dir << sistrip::fecCrate_ << fecCrate_ << sistrip::dir_;
      
      // Add FEC slot
      if ( fecSlot_ ) {
        dir << sistrip::fecSlot_ << fecSlot_ << sistrip::dir_;
        
        // Add FEC ring
        if ( fecRing_ ) {
          dir << sistrip::fecRing_ << fecRing_ << sistrip::dir_;
          
          // Add CCU address
          if ( ccuAddr_ ) {
            dir << sistrip::ccuAddr_ << ccuAddr_ << sistrip::dir_;
            
            // Add CCU channel
            if ( ccuChan_ ) {
              dir << sistrip::ccuChan_ << ccuChan_ << sistrip::dir_;

              // Add LLD channel
              if ( lldChan_ ) {
                dir << sistrip::lldChan_ << lldChan_ << sistrip::dir_;

                // Add APV I2C address
                if ( i2cAddr_ ) {
                  dir << sistrip::apv_ << i2cAddr_ << sistrip::dir_;
                }
              }
            }
          }
        }
      }
    }
    
    std::string temp( dir.str() );
    path( temp );

  } else {
    
    // ---------- Set member data based on directory path ----------
    
    fecCrate_ = 0;
    fecSlot_  = 0;
    fecRing_  = 0;
    ccuAddr_  = 0;
    ccuChan_  = 0;
    lldChan_  = 0;
    i2cAddr_  = 0;

    // Check if root is found
    if ( path().find( sistrip::root_ ) == std::string::npos ) {
      std::string temp = path();
      path( std::string(sistrip::root_) + sistrip::dir_ + temp );
    }
    
    size_t curr = 0; // current string position
    size_t next = 0; // next string position
    next = path().find( sistrip::controlView_, curr );

    // Extract view 
    curr = next;
    if ( curr != std::string::npos ) { 
      next = path().find( sistrip::fecCrate_, curr );
      std::string control_view( path(), 
                                curr+(sizeof(sistrip::controlView_) - 1), 
                                next-(sizeof(sistrip::dir_) - 1)-curr );
      
      // Extract FEC crate
      curr = next;
      if ( curr != std::string::npos ) { 
        next = path().find( sistrip::fecSlot_, curr );
        std::string fec_crate( path(), 
                               curr+(sizeof(sistrip::fecCrate_) - 1), 
                               next-(sizeof(sistrip::dir_) - 1)-curr );
        fecCrate_ = std::atoi( fec_crate.c_str() );

        // Extract FEC slot
        curr = next;
        if ( curr != std::string::npos ) { 
          next = path().find( sistrip::fecRing_, curr );
          std::string fec_slot( path(), 
                                curr+(sizeof(sistrip::fecSlot_) - 1), 
                                next-(sizeof(sistrip::dir_) - 1)-curr );
          fecSlot_ = std::atoi( fec_slot.c_str() );

          // Extract FEC ring
          curr = next;
          if ( curr != std::string::npos ) { 
            next = path().find( sistrip::ccuAddr_, curr );
            std::string fec_ring( path(), 
                                  curr+(sizeof(sistrip::fecRing_) - 1),
                                  next-(sizeof(sistrip::dir_) - 1)-curr );
            fecRing_ = std::atoi( fec_ring.c_str() );

            // Extract CCU address
            curr = next;
            if ( curr != std::string::npos ) { 
              next = path().find( sistrip::ccuChan_, curr );
              std::string ccu_addr( path(), 
                                    curr+(sizeof(sistrip::ccuAddr_) - 1), 
                                    next-(sizeof(sistrip::dir_) - 1)-curr );
              ccuAddr_ = std::atoi( ccu_addr.c_str() );

              // Extract CCU channel
              curr = next;
              if ( curr != std::string::npos ) { 
                next = path().find( sistrip::lldChan_, curr );
                std::string ccu_chan( path(), 
                                      curr+(sizeof(sistrip::ccuChan_) - 1), 
                                      next-(sizeof(sistrip::dir_) - 1)-curr );
                ccuChan_ = std::atoi( ccu_chan.c_str() );
                
                // Extract LLD channel
                curr = next;
                if ( curr != std::string::npos ) { 
                  next = path().find( sistrip::apv_, curr );
                  std::string lld_chan( path(), 
                                        curr+(sizeof(sistrip::lldChan_) - 1), 
                                        next-(sizeof(sistrip::dir_) - 1)-curr );
                  lldChan_ = std::atoi( lld_chan.c_str() );
                  
                  // Extract I2C address
                  curr = next;
                  if ( curr != std::string::npos ) { 
                    next = std::string::npos;
                    std::string i2c_addr( path(), 
                                          curr+(sizeof(sistrip::apv_) - 1),
                                          next-curr );
                    i2cAddr_ = std::atoi( i2c_addr.c_str() );
                  }
                }
              }
            }
          }
        }
      }
    } else {
      std::stringstream ss;
      ss << sistrip::root_ << sistrip::dir_;
      //ss << sistrip::root_ << sistrip::dir_
      //<< sistrip::unknownView_ << sistrip::dir_;
      std::string temp( ss.str() );
      path( temp );
    }
    
  }
  
}
void SiStripFecKey::initFromValue ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 356 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, sistrip::CCU_ADDR_MAX, sistrip::CCU_ADDR_MIN, sistrip::CCU_CHAN_MAX, sistrip::CCU_CHAN_MIN, ccuAddr_, ccuChan_, sistrip::CRATE_SLOT_MAX, sistrip::CRATE_SLOT_MIN, sistrip::FEC_CRATE_MAX, sistrip::FEC_CRATE_MIN, sistrip::FEC_RING_MAX, sistrip::FEC_RING_MIN, fecCrate_, fecRing_, fecSlot_, i2cAddr_, i2cAddrMask_, i2cAddrOffset_, sistrip::invalid_, SiStripKey::key(), sistrip::LLD_CHAN_MAX, sistrip::LLD_CHAN_MIN, lldChan(), and lldChan_.

Referenced by SiStripFecKey().

                                  {

  // FEC crate  
  if ( fecCrate_ >= sistrip::FEC_CRATE_MIN &&
       fecCrate_ <= sistrip::FEC_CRATE_MAX ) {
    fecCrate_ = fecCrate_;
  } else if ( fecCrate_ == 0 ) { 
    fecCrate_ = 0;
  } else { fecCrate_ = sistrip::invalid_; }

  // FEC slot
  if ( fecSlot_ >= sistrip::CRATE_SLOT_MIN &&
       fecSlot_ <= sistrip::CRATE_SLOT_MAX ) {
    fecSlot_ = fecSlot_;
  } else if ( fecSlot_ == 0 ) { 
    fecSlot_ = 0;
  } else { fecSlot_ = sistrip::invalid_; }

  // FEC ring
  if ( fecRing_ >= sistrip::FEC_RING_MIN &&
       fecRing_ <= sistrip::FEC_RING_MAX ) {
    fecRing_ = fecRing_;
  } else if ( fecRing_ == 0 ) { 
    fecRing_ = 0;
  } else { fecRing_ = sistrip::invalid_; }

  // CCU addr
  if ( ccuAddr_ >= sistrip::CCU_ADDR_MIN &&
       ccuAddr_ <= sistrip::CCU_ADDR_MAX ) {
    ccuAddr_ = ccuAddr_;
  } else if ( ccuAddr_ == 0 ) { 
    ccuAddr_ = 0;
  } else { ccuAddr_ = sistrip::invalid_; }

  // CCU chan
  if ( ccuChan_ >= sistrip::CCU_CHAN_MIN &&
       ccuChan_ <= sistrip::CCU_CHAN_MAX ) {
    ccuChan_ = ccuChan_;
  } else if ( ccuChan_ == 0 ) { 
    ccuChan_ = 0;
  } else { ccuChan_ = sistrip::invalid_; }
  
  // LLD channel
  if ( lldChan_ >= sistrip::LLD_CHAN_MIN &&
       lldChan_ <= sistrip::LLD_CHAN_MAX ) {
    lldChan_ = lldChan_;
  } else if ( lldChan_ == 0 ) { 
    lldChan_ = 0;
  } else { lldChan_ = sistrip::invalid_; }
  
  // APV I2C address
  if ( i2cAddr_ >= sistrip::APV_I2C_MIN &&
       i2cAddr_ <= sistrip::APV_I2C_MAX ) { 
    i2cAddr_ = i2cAddr_; 
    if ( lldChan_ && lldChan( i2cAddr_ ) != lldChan_ ) { 
      i2cAddr_ = sistrip::invalid_;
      key( key() | (i2cAddrMask_<<i2cAddrOffset_) ); 
    }
  } else if ( i2cAddr_ == 0 ) { 
    i2cAddr_ = 0;
  } else { i2cAddr_ = sistrip::invalid_; }
  
}
void SiStripFecKey::initGranularity ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 696 of file SiStripFecKey.cc.

References sistrip::APV, sistrip::CCU_ADDR, sistrip::CCU_CHAN, ccuAddr_, ccuChan_, SiStripKey::channel(), sistrip::FEC_CRATE, sistrip::FEC_RING, sistrip::FEC_SLOT, sistrip::FEC_SYSTEM, fecCrate_, fecRing_, fecSlot_, SiStripKey::granularity(), i2cAddr_, sistrip::invalid_, sistrip::LLD_CHAN, lldChan_, and sistrip::UNKNOWN_GRAN.

Referenced by SiStripFecKey().

                                    {
  
  granularity( sistrip::FEC_SYSTEM );
  channel(0);
  if ( fecCrate_ && fecCrate_ != sistrip::invalid_ ) {
    granularity( sistrip::FEC_CRATE ); 
    channel(fecCrate_);
    if ( fecSlot_ && fecSlot_ != sistrip::invalid_ ) {
      granularity( sistrip::FEC_SLOT );
      channel(fecSlot_);
      if ( fecRing_ && fecRing_ != sistrip::invalid_ ) {
        granularity( sistrip::FEC_RING );
        channel(fecRing_);
        if ( ccuAddr_ && ccuAddr_ != sistrip::invalid_ ) {
          granularity( sistrip::CCU_ADDR );
          channel(ccuAddr_);
          if ( ccuChan_ && ccuChan_ != sistrip::invalid_ ) {
            granularity( sistrip::CCU_CHAN );
            channel(ccuChan_);
            if ( lldChan_ && lldChan_ != sistrip::invalid_ ) {
              granularity( sistrip::LLD_CHAN );
              channel(lldChan_);
              if ( i2cAddr_ && i2cAddr_ != sistrip::invalid_ ) {
                granularity( sistrip::APV );
                channel(i2cAddr_);
              } else if ( i2cAddr_ == sistrip::invalid_ ) { 
                granularity( sistrip::UNKNOWN_GRAN ); 
                channel(sistrip::invalid_);
              }
            } else if ( lldChan_ == sistrip::invalid_ ) { 
              granularity( sistrip::UNKNOWN_GRAN ); 
              channel(sistrip::invalid_);
            }
          } else if ( ccuChan_ == sistrip::invalid_ ) { 
            granularity( sistrip::UNKNOWN_GRAN ); 
            channel(sistrip::invalid_);
          }
        } else if ( ccuAddr_ == sistrip::invalid_ ) { 
          granularity( sistrip::UNKNOWN_GRAN ); 
          channel(sistrip::invalid_);
        }
      } else if ( fecRing_ == sistrip::invalid_ ) { 
        granularity( sistrip::UNKNOWN_GRAN ); 
        channel(sistrip::invalid_);
      }
    } else if ( fecSlot_ == sistrip::invalid_ ) { 
      granularity( sistrip::UNKNOWN_GRAN ); 
      channel(sistrip::invalid_);
    }
  } else if ( fecCrate_ == sistrip::invalid_ ) { 
    granularity( sistrip::UNKNOWN_GRAN ); 
    channel(sistrip::invalid_);
  }

}
bool SiStripFecKey::isConsistent ( const SiStripKey key) const [virtual]

"Consistent" means identical and/or null (ie, "all") data.

Reimplemented from SiStripKey.

Definition at line 266 of file SiStripFecKey.cc.

References ccuAddr(), ccuAddr_, fecCrate(), fecCrate_, fecRing(), fecRing_, fecSlot(), fecSlot_, i2cAddr(), i2cAddr_, LaserDQM_cfg::input, isEqual(), SiStripKey::key(), lldChan(), and lldChan_.

                                                              {
  const SiStripFecKey& input = dynamic_cast<const SiStripFecKey&>(key);
  if ( !(&input) ) { return false; }
  if ( isEqual(input) ) { return true; }
  else if ( ( fecCrate_ == 0 || input.fecCrate() == 0 ) &&
            ( fecSlot_ == 0 || input.fecSlot() == 0 ) &&
            ( fecRing_ == 0 || input.fecRing() == 0 ) &&
            ( ccuAddr_ == 0 || input.ccuAddr() == 0 ) &&
            ( lldChan_ == 0 || input.lldChan() == 0 ) &&
            ( i2cAddr_ == 0 || input.i2cAddr() == 0 ) ) {
    return true;
  } else { return false; }
}
bool SiStripFecKey::isEqual ( const SiStripKey key) const [virtual]

Identifies key objects with identical member data.

Reimplemented from SiStripKey.

Definition at line 250 of file SiStripFecKey.cc.

References ccuAddr(), ccuAddr_, ccuChan(), ccuChan_, fecCrate(), fecCrate_, fecRing(), fecRing_, fecSlot(), fecSlot_, i2cAddr(), i2cAddr_, LaserDQM_cfg::input, SiStripKey::key(), lldChan(), and lldChan_.

Referenced by isConsistent().

                                                         {
  const SiStripFecKey& input = dynamic_cast<const SiStripFecKey&>(key);
  if ( !(&input) ) { return false; }
  if ( fecCrate_ == input.fecCrate() &&
       fecSlot_ == input.fecSlot() &&
       fecRing_ == input.fecRing() &&
       ccuAddr_ == input.ccuAddr() &&
       ccuChan_ == input.ccuChan() &&
       lldChan_ == input.lldChan() &&
       i2cAddr_ == input.i2cAddr() ) { 
    return true;
  } else { return false; }
}
bool SiStripFecKey::isInvalid ( ) const [virtual]

Identifies all member data as being "invalid".

Reimplemented from SiStripKey.

Definition at line 319 of file SiStripFecKey.cc.

References sistrip::APV.

Referenced by CommissioningHistosUsingDb::detInfo().

                                    { 
  return isInvalid(sistrip::APV); 
}
bool SiStripFecKey::isInvalid ( const sistrip::Granularity gran) const [virtual]

All member data to level of "Granularity" are invalid. If sistrip::Granularity is "undefined", returns true.

Reimplemented from SiStripKey.

Definition at line 325 of file SiStripFecKey.cc.

References sistrip::APV, sistrip::CCU_ADDR, sistrip::CCU_CHAN, ccuAddr_, ccuChan_, sistrip::FEC_CRATE, sistrip::FEC_RING, sistrip::FEC_SYSTEM, fecCrate_, fecRing_, fecSlot_, i2cAddr_, sistrip::invalid_, sistrip::LLD_CHAN, lldChan_, sistrip::UNDEFINED_GRAN, and sistrip::UNKNOWN_GRAN.

                                                                    {
  if ( gran == sistrip::FEC_SYSTEM ) { return false; }
  else if ( gran == sistrip::UNDEFINED_GRAN ||
            gran == sistrip::UNKNOWN_GRAN ) { return false; }
  
  if ( fecCrate_ == sistrip::invalid_ ) {
    if ( gran == sistrip::FEC_CRATE ) { return true; }
    if ( fecSlot_ == sistrip::invalid_ ) {
      if ( gran == sistrip::FEC_RING ) { return true; }
      if ( fecRing_ == sistrip::invalid_ ) {
        if ( gran == sistrip::FEC_RING ) { return true; }
        if ( ccuAddr_ == sistrip::invalid_ ) {
          if ( gran == sistrip::CCU_ADDR ) { return true; }
          if ( ccuChan_ == sistrip::invalid_ ) {
            if ( gran == sistrip::CCU_CHAN ) { return true; }
            if ( lldChan_ == sistrip::invalid_ ) {
              if ( gran == sistrip::LLD_CHAN  ) { return true; }
              if ( i2cAddr_ == sistrip::invalid_ ) {
                if ( gran == sistrip::APV  ) { return true; }
              }
            }
          }
        }
      }
    }
  }
  return false;
}
bool SiStripFecKey::isValid ( void  ) const [virtual]

Identifies all member data as being "valid" or "all" (null).

Reimplemented from SiStripKey.

Definition at line 282 of file SiStripFecKey.cc.

References sistrip::APV.

Referenced by CommissioningHistosUsingDb::buildDetInfo(), SummaryGeneratorControlView::fill(), FastFedCablingAnalysis::header(), and print().

                                  { 
  return isValid(sistrip::APV); 
}
bool SiStripFecKey::isValid ( const sistrip::Granularity gran) const [virtual]

All member data to level of "Granularity" are "valid". If sistrip::Granularity is "undefined", returns false.

Reimplemented from SiStripKey.

Definition at line 288 of file SiStripFecKey.cc.

References sistrip::APV, sistrip::CCU_ADDR, sistrip::CCU_CHAN, ccuAddr_, ccuChan_, sistrip::FEC_CRATE, sistrip::FEC_RING, sistrip::FEC_SYSTEM, fecCrate_, fecRing_, fecSlot_, i2cAddr_, sistrip::invalid_, sistrip::LLD_CHAN, lldChan_, sistrip::UNDEFINED_GRAN, and sistrip::UNKNOWN_GRAN.

                                                                  {
  if ( gran == sistrip::FEC_SYSTEM ) { return true; }
  else if ( gran == sistrip::UNDEFINED_GRAN ||
            gran == sistrip::UNKNOWN_GRAN ) { return false; }
  
  if ( fecCrate_ != sistrip::invalid_ ) {
    if ( gran == sistrip::FEC_CRATE ) { return true; }
    if ( fecSlot_ != sistrip::invalid_ ) {
      if ( gran == sistrip::FEC_RING ) { return true; }
      if ( fecRing_ != sistrip::invalid_ ) {
        if ( gran == sistrip::FEC_RING ) { return true; }
        if ( ccuAddr_ != sistrip::invalid_ ) {
          if ( gran == sistrip::CCU_ADDR ) { return true; }
          if ( ccuChan_ != sistrip::invalid_ ) {
            if ( gran == sistrip::CCU_CHAN ) { return true; }
            if ( lldChan_ != sistrip::invalid_ ) {
              if ( gran == sistrip::LLD_CHAN ) { return true; }
              if ( i2cAddr_ != sistrip::invalid_ ) {
                if ( gran == sistrip::APV ) { return true; }
              }
            }
          }
        }
      }
    }
  }
  return false;
}
uint16_t SiStripFecKey::lldChan ( const uint16_t &  i2c_addr) [static]

Returns LLD channel (1-3) for a given APV I2C addr (32-37).

Definition at line 229 of file SiStripFecKey.cc.

References sistrip::APV_I2C_MAX, sistrip::APV_I2C_MIN, and sistrip::invalid_.

                                                          {
  if ( i2c_addr == 0 ) { return 0; }
  else if ( i2c_addr < sistrip::APV_I2C_MIN ||
            i2c_addr > sistrip::APV_I2C_MAX ) {
    return sistrip::invalid_;
  }
  return ( ( i2c_addr - sistrip::APV_I2C_MIN ) / 2 + 1 );
}
const uint16_t & SiStripFecKey::lldChan ( ) const [inline]
void SiStripFecKey::print ( std::stringstream &  ss) const [virtual]

A terse summary of the key

Reimplemented from SiStripKey.

Definition at line 780 of file SiStripFecKey.cc.

References ccuAddr(), ccuChan(), SiStripKey::channel(), fecCrate(), fecRing(), fecSlot(), SiStripKey::granularity(), i2cAddr(), isValid(), SiStripKey::key(), lldChan(), and SiStripKey::path().

Referenced by operator<<().

                                                     {
  ss << " [SiStripFecKey::print]" << std::endl
     << std::hex
     << " FEC key              : 0x" 
     << std::setfill('0') 
     << std::setw(8) << key() << std::endl
     << std::setfill(' ') 
     << std::dec
     << " FEC VME crate        : " << fecCrate() << std::endl
     << " FEC VME slot         : " << fecSlot() << std::endl 
     << " FEC control ring     : " << fecRing() << std::endl
     << " CCU I2C address      : " << ccuAddr() << std::endl
     << " CCU chan (FE module) : " << ccuChan() << std::endl
     << " LaserDriver channel  : " << lldChan() << std::endl 
     << " APV I2C address      : " << i2cAddr() << std::endl 
     << " Directory            : " << path() << std::endl
     << " Granularity          : "
     << SiStripEnumsAndStrings::granularity( granularity() ) << std::endl
     << " Channel              : " << channel() << std::endl
     << " isValid              : " << isValid();
}
void SiStripFecKey::terse ( std::stringstream &  ss) const [virtual]

A terse summary of the key

Reimplemented from SiStripKey.

Definition at line 754 of file SiStripFecKey.cc.

References ccuAddr(), ccuChan(), fecCrate(), fecRing(), fecSlot(), i2cAddr(), and lldChan().

Referenced by FastFedCablingHistosUsingDb::connections().

                                                     {
  ss << "FEC:crate/slot/ring/CCU/module/LLD/I2C= "
     << fecCrate() << "/"
     << fecSlot() << "/"
     << fecRing() << "/"
     << ccuAddr() << "/"
     << ccuChan() << "/"
     << lldChan() << "/"
     << i2cAddr();
//   ss << " FecKey"
//     //<< "=0x" 
//     //<< std::hex
//     //<< std::setfill('0') << std::setw(8) << key() << std::setfill(' ') 
//     //<< std::dec
//     //<< ", " << ( isValid() ? "Valid" : "Invalid" )
//      << ", Crate=" << fecCrate()
//      << ", Slot=" << fecSlot()
//      << ", Ring=" << fecRing()
//      << ", CCU=" << ccuAddr()
//      << ", module=" << ccuChan()
//      << ", LLD=" << lldChan()
//      << ", I2C=" << i2cAddr();
}

Member Data Documentation

uint16_t SiStripFecKey::ccuAddr_ [private]

CCU module [0,1-126,invalid].

Definition at line 172 of file SiStripFecKey.h.

Referenced by ccuAddr(), initFromKey(), initFromPath(), initFromValue(), initGranularity(), isConsistent(), isEqual(), isInvalid(), isValid(), and SiStripFecKey().

const uint16_t SiStripFecKey::ccuAddrMask_ = 0xFF [static, private]

Definition at line 196 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::ccuAddrOffset_ = 10 [static, private]

Definition at line 187 of file SiStripFecKey.h.

Referenced by initFromKey().

uint16_t SiStripFecKey::ccuChan_ [private]

FE module [0,16-31,invalid].

Definition at line 175 of file SiStripFecKey.h.

Referenced by ccuChan(), initFromKey(), initFromPath(), initFromValue(), initGranularity(), isEqual(), isInvalid(), isValid(), and SiStripFecKey().

const uint16_t SiStripFecKey::ccuChanMask_ = 0x1F [static, private]

Definition at line 197 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::ccuChanOffset_ = 5 [static, private]

Definition at line 188 of file SiStripFecKey.h.

Referenced by initFromKey().

uint16_t SiStripFecKey::fecCrate_ [private]
const uint16_t SiStripFecKey::fecCrateMask_ = 0x07 [static, private]

Definition at line 193 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::fecCrateOffset_ = 27 [static, private]

Definition at line 184 of file SiStripFecKey.h.

Referenced by initFromKey().

uint16_t SiStripFecKey::fecRing_ [private]
const uint16_t SiStripFecKey::fecRingMask_ = 0x0F [static, private]

Definition at line 195 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::fecRingOffset_ = 18 [static, private]

Definition at line 186 of file SiStripFecKey.h.

Referenced by initFromKey().

uint16_t SiStripFecKey::fecSlot_ [private]

FEC slot [0,2-21,invalid].

Definition at line 166 of file SiStripFecKey.h.

Referenced by fecSlot(), initFromKey(), initFromPath(), initFromValue(), initGranularity(), isConsistent(), isEqual(), isInvalid(), isValid(), and SiStripFecKey().

const uint16_t SiStripFecKey::fecSlotMask_ = 0x1F [static, private]

Definition at line 194 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::fecSlotOffset_ = 22 [static, private]

Definition at line 185 of file SiStripFecKey.h.

Referenced by initFromKey().

uint16_t SiStripFecKey::i2cAddr_ [private]

APV I2C address [0,32-37,invalid].

Definition at line 181 of file SiStripFecKey.h.

Referenced by i2cAddr(), initFromKey(), initFromPath(), initFromValue(), initGranularity(), isConsistent(), isEqual(), isInvalid(), isValid(), and SiStripFecKey().

const uint16_t SiStripFecKey::i2cAddrMask_ = 0x03 [static, private]

Definition at line 199 of file SiStripFecKey.h.

Referenced by initFromKey(), and initFromValue().

const uint16_t SiStripFecKey::i2cAddrOffset_ = 0 [static, private]

Definition at line 190 of file SiStripFecKey.h.

Referenced by initFromKey(), and initFromValue().

uint16_t SiStripFecKey::lldChan_ [private]

LLD channel [0,1-3,invalid].

Definition at line 178 of file SiStripFecKey.h.

Referenced by initFromKey(), initFromPath(), initFromValue(), initGranularity(), isConsistent(), isEqual(), isInvalid(), isValid(), lldChan(), and SiStripFecKey().

const uint16_t SiStripFecKey::lldChanMask_ = 0x07 [static, private]

Definition at line 198 of file SiStripFecKey.h.

Referenced by initFromKey().

const uint16_t SiStripFecKey::lldChanOffset_ = 2 [static, private]

Definition at line 189 of file SiStripFecKey.h.

Referenced by initFromKey().