CMS 3D CMS Logo

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

SiStripDetKey Class Reference

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

#include <SiStripDetKey.h>

Inheritance diagram for SiStripDetKey:
SiStripKey

List of all members.

Public Member Functions

const uint16_t & apvPairNumber () const
const uint16_t & apvWithinPair () const
bool isConsistent (const SiStripKey &) const
bool isEqual (const SiStripKey &) const
bool isInvalid () const
bool isInvalid (const sistrip::Granularity &) const
bool isValid (const sistrip::Granularity &) const
bool isValid () const
const uint16_t & partition () const
virtual void print (std::stringstream &ss) const
 SiStripDetKey (const DetId &det_id, const uint16_t &apv_pair_number=0, const uint16_t &apv_within_pair=0)
 SiStripDetKey (const std::string &directory_path)
 SiStripDetKey (const uint32_t &det_key)
 SiStripDetKey (const SiStripDetId &det_id)
 SiStripDetKey ()
 SiStripDetKey (const SiStripKey &)
 SiStripDetKey (const uint16_t &partition)
 SiStripDetKey (const SiStripKey &, const sistrip::Granularity &)
 SiStripDetKey (const SiStripDetKey &)
virtual void terse (std::stringstream &ss) const

Private Member Functions

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

Private Attributes

uint16_t apvPairNumber_
uint16_t apvWithinPair_
uint16_t partition_

Static Private Attributes

static const uint16_t partitionMask_ = 0x07
static const uint16_t partitionOffset_ = 29

Detailed Description

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

Author:
R.Bainbridge, S.Lowette

NOTA BENE: *** NOT FINISHED ***

can generate another key that is NOT DetId and packs sistrip-specific data in a more condensed way, so that all levels can be encoded with "all" and "invalid" values, down to level of apv. also, need "conversion tool" that re-generates DetId key from this new key. this is only way...!!! maybe can "safeguard" use of this key as a DetId by reserving bits 22-24 as a flag (eg, set all high), so that if an attempt to build DetId using SiStripDetId class, we can understand if key is real DetId or not... what about going to level of apv?... what about levels about module?...

Definition at line 29 of file SiStripDetKey.h.


Constructor & Destructor Documentation

SiStripDetKey::SiStripDetKey ( const uint16_t &  partition)
SiStripDetKey::SiStripDetKey ( const DetId det_id,
const uint16_t &  apv_pair_number = 0,
const uint16_t &  apv_within_pair = 0 
)

Constructor using DetId, APV pair and APV pos within pair.

Definition at line 25 of file SiStripDetKey.cc.

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

                                                                :
  SiStripKey(),
  partition_(sistrip::invalid_),
  apvPairNumber_(apv_pair_number), 
  apvWithinPair_(apv_within_pair)
{
  // order is important!
  initFromValue();
  initFromKey();
  initFromPath();
  initGranularity();
}
SiStripDetKey::SiStripDetKey ( const SiStripDetId det_id)
SiStripDetKey::SiStripDetKey ( const uint32_t &  det_key)

Constructor using 32-bit "DET key".

Definition at line 57 of file SiStripDetKey.cc.

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

SiStripDetKey::SiStripDetKey ( const std::string &  directory_path)
SiStripDetKey::SiStripDetKey ( const SiStripDetKey input)

Copy constructor.

Definition at line 87 of file SiStripDetKey.cc.

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

                                                         :
  SiStripKey(),
  partition_(input.partition()),
  apvPairNumber_(input.apvPairNumber()), 
  apvWithinPair_(input.apvWithinPair())
{
  key(input.key());
  path(input.path());
  granularity(input.granularity());
}
SiStripDetKey::SiStripDetKey ( const SiStripKey input)
SiStripDetKey::SiStripDetKey ( const SiStripKey input,
const sistrip::Granularity gran 
)

Copy to level specified by granularity.

Definition at line 120 of file SiStripDetKey.cc.

References initFromKey(), initFromPath(), initFromValue(), initGranularity(), LaserDQM_cfg::input, sistrip::PARTITION, partition(), partition_, and groupFilesInBlocks::temp.

                                                               :
  SiStripKey(),
  partition_(0),
  apvPairNumber_(0),
  apvWithinPair_(0)
{
  SiStripKey& temp = const_cast<SiStripKey&>(input);
  SiStripDetKey& det_key = dynamic_cast<SiStripDetKey&>(temp);
  if ( (&det_key) ) {

    if ( gran == sistrip::PARTITION ) {
      partition_ = det_key.partition(); 
    }

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

}
SiStripDetKey::SiStripDetKey ( )

Member Function Documentation

const uint16_t & SiStripDetKey::apvPairNumber ( ) const [inline]

Returns APV pair number.

Definition at line 143 of file SiStripDetKey.h.

References apvPairNumber_.

Referenced by isConsistent(), isEqual(), and SiStripDetKey().

{ return apvPairNumber_; }
const uint16_t & SiStripDetKey::apvWithinPair ( ) const [inline]

Returns APV position within pair.

Definition at line 144 of file SiStripDetKey.h.

References apvWithinPair_.

Referenced by isConsistent(), isEqual(), and SiStripDetKey().

{ return apvWithinPair_; }
void SiStripDetKey::initFromKey ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 234 of file SiStripDetKey.cc.

References sistrip::invalid32_, sistrip::invalid_, SiStripKey::key(), partition_, partitionMask_, and partitionOffset_.

Referenced by SiStripDetKey().

                                {

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

    // ---------- Set DetKey based on member data ----------
    
    // Initialise to null value
    key(0);
    
    // Extract partition
    if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
         partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
      key( key() | (partition_<<partitionOffset_) );
    } else if ( partition_ == 0 ) {
      key( key() | (partition_<<partitionOffset_) );
    } else {
      key( key() | (partitionMask_<<partitionOffset_) );
    }
    
  } else {
    
    // ---------- Set member data based on Det key ----------

    partition_ = ( key()>>partitionOffset_ ) & partitionMask_;

    if ( partition_ == partitionMask_ ) { partition_ = sistrip::invalid_; }

  }

}
void SiStripDetKey::initFromPath ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 267 of file SiStripDetKey.cc.

References sistrip::detectorView_, dir, sistrip::dir_, spr::find(), sistrip::null_, partition(), sistrip::partition_, partition_, SiStripKey::path(), sistrip::root_, and groupFilesInBlocks::temp.

Referenced by SiStripDetKey().

                                 {

  if ( path() == sistrip::null_ ) {

    // ---------- Set directory path based on member data ----------

    std::stringstream dir;

    dir << sistrip::root_ << sistrip::dir_ 
        << sistrip::detectorView_ << sistrip::dir_;

    // Add partition
    if ( partition_ ) {
      dir << sistrip::partition_ << partition_ << sistrip::dir_;
    }

    std::string temp( dir.str() );
    path( temp );

  } else {

    // ---------- Set member data based on directory path ----------

    partition_ = 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::detectorView_, curr );

    // Extract view
    curr = next;
    if ( curr != std::string::npos ) {
      next = path().find( sistrip::partition_, curr );
      std::string detector_view( path(),
                                 curr+(sizeof(sistrip::detectorView_) - 1),
                                 next-(sizeof(sistrip::dir_) - 1)-curr );
      // Extract partition
      curr = next;
      if ( curr != std::string::npos ) { 
        next = std::string::npos;
        std::string partition( path(), 
                               curr+(sizeof(sistrip::partition_) - 1),
                               next-(sizeof(sistrip::dir_) - 1)-curr );
        partition_ = std::atoi( partition.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 SiStripDetKey::initFromValue ( ) [private, virtual]

Reimplemented from SiStripKey.

Definition at line 220 of file SiStripDetKey.cc.

References sistrip::invalid_, and partition_.

Referenced by SiStripDetKey().

                                  {

  // partition
  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
       partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
    partition_ = partition_;
  } else if ( partition_ == 0 ) {
    partition_ = 0;
  } else { partition_ = sistrip::invalid_; }

}
void SiStripDetKey::initGranularity ( ) [private, virtual]
bool SiStripDetKey::isConsistent ( const SiStripKey key) const [virtual]

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

Reimplemented from SiStripKey.

Definition at line 168 of file SiStripDetKey.cc.

References apvPairNumber(), apvPairNumber_, apvWithinPair(), apvWithinPair_, LaserDQM_cfg::input, isEqual(), SiStripKey::key(), partition(), partition_, and groupFilesInBlocks::temp.

                                                              {
  SiStripKey& temp = const_cast<SiStripKey&>(key);
  SiStripDetKey& input = dynamic_cast<SiStripDetKey&>(temp);
  if ( !(&input) ) { return false; }
  if ( isEqual(input) ) { return false; }
  else if ( ( partition_ == 0 || input.partition() == 0 ) &&
            ( apvPairNumber_ == 0 || input.apvPairNumber() == 0 ) &&
            ( apvWithinPair_ == 0 || input.apvWithinPair() == 0 ) ) {
    return true;
  } else { return false; }
}
bool SiStripDetKey::isEqual ( const SiStripKey key) const [virtual]

Identifies key objects with identical member data.

Reimplemented from SiStripKey.

Definition at line 155 of file SiStripDetKey.cc.

References apvPairNumber(), apvPairNumber_, apvWithinPair(), apvWithinPair_, LaserDQM_cfg::input, SiStripKey::key(), partition(), partition_, and groupFilesInBlocks::temp.

Referenced by isConsistent().

                                                         {
  SiStripKey& temp = const_cast<SiStripKey&>(key);
  SiStripDetKey& input = dynamic_cast<SiStripDetKey&>(temp);
  if ( !(&input) ) { return false; }
  if ( partition_ == input.partition() &&
       apvPairNumber_ == input.apvPairNumber() &&
       apvWithinPair_ == input.apvWithinPair() ) {
    return true;
  } else { return false; }
}
bool SiStripDetKey::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 207 of file SiStripDetKey.cc.

References sistrip::invalid_, sistrip::PARTITION, partition_, sistrip::TRACKER, sistrip::UNDEFINED_GRAN, and sistrip::UNKNOWN_GRAN.

                                                                    {
  if ( gran == sistrip::TRACKER ) { return false; }
  else if ( gran == sistrip::UNDEFINED_GRAN ||
            gran == sistrip::UNKNOWN_GRAN ) { return false; }

  if ( partition_ == sistrip::invalid_ ) {
    if ( gran == sistrip::PARTITION ) { return true; }
  }
  return false;
}
bool SiStripDetKey::isInvalid ( ) const [virtual]

Identifies all member data as being invalid.

Reimplemented from SiStripKey.

Definition at line 201 of file SiStripDetKey.cc.

References sistrip::APV.

                                    { 
  return isInvalid(sistrip::APV); 
}
bool SiStripDetKey::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 188 of file SiStripDetKey.cc.

References sistrip::invalid_, sistrip::PARTITION, partition_, sistrip::TRACKER, sistrip::UNDEFINED_GRAN, and sistrip::UNKNOWN_GRAN.

                                                                  {
  if ( gran == sistrip::TRACKER ) { return true; }
  else if ( gran == sistrip::UNDEFINED_GRAN ||
            gran == sistrip::UNKNOWN_GRAN ) { return false; }

  if ( partition_ != sistrip::invalid_ ) {
    if ( gran == sistrip::PARTITION ) { return true; }
  }
  return false;
}
bool SiStripDetKey::isValid ( void  ) const [virtual]

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

Reimplemented from SiStripKey.

Definition at line 182 of file SiStripDetKey.cc.

References sistrip::APV.

Referenced by print().

                                  { 
  return isValid(sistrip::APV); 
}
const uint16_t & SiStripDetKey::partition ( ) const [inline]

Returns partition.

Definition at line 142 of file SiStripDetKey.h.

References partition_.

Referenced by initFromPath(), isConsistent(), isEqual(), print(), SiStripDetKey(), and terse().

{ return partition_; }
void SiStripDetKey::print ( std::stringstream &  ss) const [virtual]

Print member data of the key

Reimplemented from SiStripKey.

Definition at line 356 of file SiStripDetKey.cc.

References SiStripKey::channel(), SiStripKey::granularity(), isValid(), SiStripKey::key(), partition(), and SiStripKey::path().

Referenced by operator<<().

                                                     {
  ss << " [SiStripDetKey::print]" << std::endl
     << std::hex
     << " 32-bit Det key : 0x"
     << std::setfill('0') 
     << std::setw(8) << key() << std::endl
     << std::setfill(' ')
     << std::dec
     << " Partition      : " << partition() << std::endl
     << " Directory      : " << path() << std::endl
     << " Granularity    : "
     << SiStripEnumsAndStrings::granularity( granularity() ) << std::endl
     << " Channel        : " << channel() << std::endl
     << " isValid        : " << isValid();
}
void SiStripDetKey::terse ( std::stringstream &  ss) const [virtual]

A terse summary of the key

Reimplemented from SiStripKey.

Definition at line 349 of file SiStripDetKey.cc.

References partition().

                                                     {
  ss << "DET:partition= "
     << partition();
}

Member Data Documentation

uint16_t SiStripDetKey::apvPairNumber_ [private]

APV pair number [0,1-3,invalid].

Definition at line 127 of file SiStripDetKey.h.

Referenced by apvPairNumber(), isConsistent(), isEqual(), and SiStripDetKey().

uint16_t SiStripDetKey::apvWithinPair_ [private]

APV position within pair [0,1-2,invalid].

Definition at line 130 of file SiStripDetKey.h.

Referenced by apvWithinPair(), isConsistent(), isEqual(), and SiStripDetKey().

uint16_t SiStripDetKey::partition_ [private]
const uint16_t SiStripDetKey::partitionMask_ = 0x07 [static, private]

Definition at line 136 of file SiStripDetKey.h.

Referenced by initFromKey().

const uint16_t SiStripDetKey::partitionOffset_ = 29 [static, private]

Definition at line 133 of file SiStripDetKey.h.

Referenced by initFromKey().