CMS 3D CMS Logo

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

CSCALCTHeader Class Reference

#include <CSCALCTHeader.h>

List of all members.

Public Types

enum  FIFO_MODE { NO_DUMP, FULL_DUMP, LOCAL_DUMP }

Public Member Functions

unsigned short int ActiveFEBs () const
void add (const std::vector< CSCALCTDigi > &digis)
std::vector< CSCALCTDigiALCTDigis () const
unsigned short int alctFirmwareVersion () const
CSCALCTHeader2006 alctHeader2006 () const
CSCALCTHeader2007 alctHeader2007 () const
unsigned short int BoardID () const
unsigned short int BXNCount () const
bool check () const
 CSCALCTHeader (const unsigned short *buf)
 for packing
 CSCALCTHeader (const CSCALCTStatusDigi &digi)
 CSCALCTHeader (int chamberType)
unsigned short int CSCID () const
unsigned short int * data ()
unsigned short int ExtTrig () const
unsigned short int FIFOMode () const
unsigned short int L1Acc () const
unsigned short int L1AMatch () const
unsigned short int LCTChipRead () const
unsigned short int nLCTChipRead () const
 for packing
unsigned short int NTBins () const
boost::dynamic_bitset pack ()
unsigned short int Promote1 () const
unsigned short int Promote2 () const
void setDAVForChannel (int wireGroup)
void setEventInformation (const CSCDMBHeader &)
int sizeInWords ()
 in 16-bit words

Static Public Member Functions

static void selfTest (int firmware)
 tests that we unpack what we packed
static void setDebug (bool value)
 to access data by via status digis

Private Attributes

CSCALCTs2006 alcts2006
unsigned short int bxn0
unsigned short int bxn1
std::vector< CSCCollisionMaskcollisionMasks
CSCConfigurationRegister configRegister
CSCALCTHeader2006 header2006
CSCALCTHeader2007 header2007
std::vector< CSCHotChannelMaskhotChannelMasks
unsigned short int sizeInWords2007_
 size of the 2007 header in words
std::vector< CSCALCTtheALCTs
unsigned short int theOriginalBuffer [116]
CSCVirtexID virtexID

Static Private Attributes

static bool debug = false
static unsigned short int firmwareVersion = 2007

Detailed Description

documented in flags http://www.phys.ufl.edu/~madorsky/alctv/alct2000_spec.PDF

Definition at line 18 of file CSCALCTHeader.h.


Member Enumeration Documentation

some accessors here are only applicable to 2006 header some to both 2006 and 2007

Enumerator:
NO_DUMP 
FULL_DUMP 
LOCAL_DUMP 

Definition at line 37 of file CSCALCTHeader.h.


Constructor & Destructor Documentation

CSCALCTHeader::CSCALCTHeader ( int  chamberType) [explicit]

Definition at line 11 of file CSCALCTHeader.cc.

References firmwareVersion, header2006, header2007, CSCALCTHeader2007::lctBins, CSCALCTHeader2006::sizeInWords(), CSCALCTHeader2007::sizeInWords(), sizeInWords(), sizeInWords2007_, theALCTs, and theOriginalBuffer.

Referenced by CSCALCTHeader().

: header2006(chamberType),
  header2007(chamberType)
{ //constructor for digi->raw packing based on header2006 
  if (firmwareVersion==2006)
  {
    memcpy(theOriginalBuffer, &header2006, header2006.sizeInWords()*2);
  }
  else if(firmwareVersion==2007)
  {
    memcpy(theOriginalBuffer, &header2007, header2007.sizeInWords()*2);
    // assume no virtex or masks or registers
    sizeInWords2007_ = header2007.sizeInWords() + header2007.lctBins*CSCALCT::sizeInWords()*2;
    theALCTs.resize(header2007.lctBins*2);
  }
  else
  {
    edm::LogError("CSCALCTHeader|CSCRawToDigi")
      <<"Cannot construct ALCT header: ALCT firmware version is bad/not defined!" << firmwareVersion;
  }

}
CSCALCTHeader::CSCALCTHeader ( const unsigned short *  buf) [explicit]

for packing

collision and hot channel masks are variable sized the sizes vary depending on type of the ALCT board number of words for various alct board types: 1 2 3 5 6

first determine the correct format

Now fill data

the header part

the alct0 and alct1

the fixed sized header part

now come the variable parts

2007 has LCTbins * 2 alct words

also store raw data buffer too; it is later returned by data() method

Definition at line 34 of file CSCALCTHeader.cc.

References ALCTDigis(), alcts2006, CSCALCTHeader2007::boardType, collisionMasks, CSCALCTHeader2007::configPresent, configRegister, constexpr, firmwareVersion, header2006, header2007, hotChannelMasks, i, CSCALCTHeader2007::lctBins, LogTrace, CSCVirtexID::sizeInWords(), CSCALCTHeader2006::sizeInWords(), CSCALCTHeader2007::sizeInWords(), sizeInWords(), CSCALCTs2006::sizeInWords(), CSCConfigurationRegister::sizeInWords(), sizeInWords2007_, theALCTs, theOriginalBuffer, and virtexID.

                                                       {
  constexpr unsigned short int collisionMaskWordcount[7]    = { 8, 8,12,16,16,24,28};
  constexpr unsigned short int hotChannelMaskWordcount[7]   = {18,18,24,36,36,48,60};

  if (buf[0]==0xDB0A) {
    firmwareVersion=2007;
  }
  else if ( (buf[0]&0xF800)==0x6000 ) {
    firmwareVersion=2006;
  }
  else {
    edm::LogError("CSCALCTHeader|CSCRawToDigi") << "failed to determine ALCT firmware version!!";
  }

  LogTrace("CSCALCTHeader|CSCRawToDigi") << "firmware version - " << firmwareVersion;

  switch (firmwareVersion) {
  case 2006:
    memcpy(&header2006, buf, header2006.sizeInWords()*2);
    buf +=header2006.sizeInWords();
    memcpy(&alcts2006, buf, alcts2006.sizeInWords()*2);
    buf +=alcts2006.sizeInWords();
    break;

  case 2007:
    memcpy(&header2007, buf, header2007.sizeInWords()*2); 
    buf +=header2007.sizeInWords();
    sizeInWords2007_ = header2007.sizeInWords();
    if (header2007.configPresent==1) {
      memcpy(&virtexID, buf, virtexID.sizeInWords()*2);
      buf +=virtexID.sizeInWords();
      sizeInWords2007_ = virtexID.sizeInWords();
      memcpy(&configRegister, buf, configRegister.sizeInWords()*2);
      buf +=configRegister.sizeInWords();
      sizeInWords2007_ += configRegister.sizeInWords();

      collisionMasks.resize(collisionMaskWordcount[header2007.boardType]);
      for (unsigned int i=0; i<collisionMaskWordcount[header2007.boardType]; ++i){
        memcpy(&collisionMasks[i], buf, collisionMasks[i].sizeInWords()*2);
        buf += collisionMasks[i].sizeInWords();
        sizeInWords2007_ += collisionMasks[i].sizeInWords();
      }

      hotChannelMasks.resize(hotChannelMaskWordcount[header2007.boardType]);
      for (unsigned int i=0; i<hotChannelMaskWordcount[header2007.boardType]; ++i) {
        memcpy(&hotChannelMasks[i], buf, hotChannelMasks[i].sizeInWords()*2);
        buf += hotChannelMasks[i].sizeInWords();
        sizeInWords2007_ += hotChannelMasks[i].sizeInWords();
      }
    }

    theALCTs.resize(header2007.lctBins*2); 
    for (int i=0; i<header2007.lctBins*2; ++i) {
      memcpy(&theALCTs[i], buf, theALCTs[i].sizeInWords()*2);
      buf += theALCTs[i].sizeInWords(); 
      sizeInWords2007_ += theALCTs[i].sizeInWords();
    }

    ALCTDigis();
    break;

  default:
    edm::LogError("CSCALCTHeader|CSCRawToDigi")
      <<"couldn't construct: ALCT firmware version is bad/not defined!";
    break;
  }

  if ((firmwareVersion==2006)||(firmwareVersion==2007))
    memcpy(theOriginalBuffer, buf-sizeInWords(), sizeInWords()*2);
  
}
CSCALCTHeader::CSCALCTHeader ( const CSCALCTStatusDigi digi)

Definition at line 115 of file CSCALCTHeader.cc.

References CSCALCTHeader(), and CSCALCTStatusDigi::header().

                                                          {
  CSCALCTHeader(digi.header());
}

Member Function Documentation

unsigned short int CSCALCTHeader::ActiveFEBs ( ) const [inline]

Definition at line 82 of file CSCALCTHeader.h.

References CSCALCTHeader2006::activeFEBs, and header2006.

void CSCALCTHeader::add ( const std::vector< CSCALCTDigi > &  digis)

Definition at line 169 of file CSCALCTHeader.cc.

References CSCALCTs2006::add(), alcts2006, firmwareVersion, header2007, i, CSCALCTHeader2007::lctBins, q1, q2, theALCTs, and TrackValidation_HighPurity_cff::valid.

Referenced by CSCEventData::add(), and selfTest().

{
  if(firmwareVersion == 2006) {
      alcts2006.add(digis);
  }
  else if(firmwareVersion == 2007) {
    if(theALCTs.empty())
    {
      theALCTs.resize(header2007.lctBins*2);
    }
    for(std::vector<CSCALCTDigi>::const_iterator digi = digis.begin();
        digi != digis.end(); ++digi)
    {
      int bx = digi->getBX();
      if(bx < (int)header2007.lctBins) 
      {
        // 2 ALCTs per bx
        int i = bx*2;
        int q1 = theALCTs[i].quality;
        int q2 = theALCTs[i+1].quality;
        // see if it's non=blank
        if(!theALCTs[i].valid)
        {
          theALCTs[i] = CSCALCT(*digi);
        }
        // new best LCT
        else if(digi->getQuality() > q1)
        {
          theALCTs[i+1] = theALCTs[i];
          theALCTs[i] = CSCALCT(*digi);
        }
        // new second best
        else if(!theALCTs[i+1].valid || (digi->getQuality() > q2))
        {
          theALCTs[i+1] = CSCALCT(*digi);
        }
      }
    }
  }
}
std::vector< CSCALCTDigi > CSCALCTHeader::ALCTDigis ( ) const

loop over all alct words

Definition at line 138 of file CSCALCTHeader.cc.

References CSCALCTs2006::ALCTDigis(), alcts2006, BXNCount(), firmwareVersion, i, listBenchmarks::pattern, query::result, theALCTs, and TrackValidation_HighPurity_cff::valid.

Referenced by CSCALCTHeader(), and cscdqm::EventProcessor::processCSC().

{ 
  std::vector<CSCALCTDigi> result;

  switch (firmwareVersion) {
  case 2006:
    {
      result = alcts2006.ALCTDigis();
      break;
    }
  case 2007:
    {
      result.reserve(theALCTs.size());
      for (unsigned int i=0; i<theALCTs.size(); ++i) {
        CSCALCTDigi digi(theALCTs[i].valid, theALCTs[i].quality, theALCTs[i].accel, theALCTs[i].pattern,
                         theALCTs[i].keyWire, (int)i/2, i%2+1);
        result.push_back(digi);
      }
      break;
    }
  default:
    edm::LogError("CSCALCTHeader|CSCRawToDigi")
      <<"Empty Digis: ALCT firmware version is bad/not defined!" << firmwareVersion; 
    break;
  }
  for(unsigned i = 0; i < result.size(); ++i) {result[i].setFullBX(BXNCount());}
  return result;

}
unsigned short int CSCALCTHeader::alctFirmwareVersion ( ) const [inline]

Definition at line 86 of file CSCALCTHeader.h.

References firmwareVersion.

Referenced by CSCEventData::checkALCTClasses(), and cscdqm::EventProcessor::processCSC().

{return firmwareVersion;}
CSCALCTHeader2006 CSCALCTHeader::alctHeader2006 ( ) const [inline]

Definition at line 93 of file CSCALCTHeader.h.

References header2006.

{return header2006;}
CSCALCTHeader2007 CSCALCTHeader::alctHeader2007 ( ) const [inline]

Definition at line 92 of file CSCALCTHeader.h.

References header2007.

Referenced by CSCAnodeData2007::init().

{return header2007;}
unsigned short int CSCALCTHeader::BoardID ( ) const [inline]

Definition at line 52 of file CSCALCTHeader.h.

References CSCALCTHeader2006::boardID, and header2006.

{return header2006.boardID;}
unsigned short int CSCALCTHeader::BXNCount ( ) const [inline]

Definition at line 55 of file CSCALCTHeader.h.

References CSCALCTHeader2006::bxnCount, CSCALCTHeader2007::bxnCount, firmwareVersion, header2006, and header2007.

Referenced by ALCTDigis(), CSCAnodeData2006::CSCAnodeData2006(), CSCAnodeData2007::CSCAnodeData2007(), and cscdqm::EventProcessor::processCSC().

                                            {
    switch (firmwareVersion)
      {
      case 2006:
        return header2006.bxnCount;
      case 2007:
        return header2007.bxnCount;
      default:
        edm::LogError("CSCALCTHeader|CSCRawToDigi")
          <<"trying to access BXNcount: ALCT firmware version is bad/not defined!";
        return 0;
      }
  }
bool CSCALCTHeader::check ( ) const [inline]

Definition at line 112 of file CSCALCTHeader.h.

References firmwareVersion, CSCALCTHeader2007::flag1, CSCALCTHeader2006::flag_0, header2006, and header2007.

Referenced by CSCAnodeData2006::CSCAnodeData2006().

                     {
    switch (firmwareVersion)
      {
      case 2006:
        return header2006.flag_0 == 0xC;
      case 2007:
        return header2007.flag1 == 0xDB0A;
      default:
        edm::LogError("CSCALCTHeader|CSCRawToDigi")
          <<"check(): ALCT firmware version is bad/not defined!";
        return 0;
      }
  }
unsigned short int CSCALCTHeader::CSCID ( ) const [inline]

Definition at line 54 of file CSCALCTHeader.h.

References CSCALCTHeader2006::cscID, and header2006.

Referenced by operator<<().

{return header2006.cscID;}
unsigned short int* CSCALCTHeader::data ( ) [inline]

Definition at line 95 of file CSCALCTHeader.h.

References theOriginalBuffer.

unsigned short int CSCALCTHeader::ExtTrig ( ) const [inline]

Definition at line 53 of file CSCALCTHeader.h.

References CSCALCTHeader2006::extTrig, and header2006.

{return header2006.extTrig;}
unsigned short int CSCALCTHeader::FIFOMode ( ) const [inline]

Definition at line 38 of file CSCALCTHeader.h.

References CSCALCTHeader2006::fifoMode, and header2006.

{return header2006.fifoMode;} 
unsigned short int CSCALCTHeader::L1Acc ( ) const [inline]

Definition at line 68 of file CSCALCTHeader.h.

References firmwareVersion, header2006, header2007, CSCALCTHeader2006::l1Acc, and CSCALCTHeader2007::l1aCounter.

Referenced by operator<<(), and cscdqm::EventProcessor::processCSC().

                                            {
    switch (firmwareVersion)
      {
      case 2006:
        return header2006.l1Acc;
      case 2007:
        return header2007.l1aCounter;
      default:
        edm::LogError("CSCALCTHeader|CSCRawToDigi")
          <<"trying to access L1Acc: ALCT firmware version is bad/not defined!";
        return 0;
      }
  }
unsigned short int CSCALCTHeader::L1AMatch ( ) const [inline]

Definition at line 81 of file CSCALCTHeader.h.

References header2006, and CSCALCTHeader2006::l1aMatch.

{return header2006.l1aMatch;}
unsigned short int CSCALCTHeader::LCTChipRead ( ) const [inline]

Definition at line 85 of file CSCALCTHeader.h.

References header2006, and CSCALCTHeader2006::lctChipRead.

unsigned short CSCALCTHeader::nLCTChipRead ( ) const

for packing

header2006 method

Definition at line 124 of file CSCALCTHeader.cc.

References firmwareVersion, header2006, and CSCALCTHeader2006::nLCTChipRead().

                                                 {
  if(firmwareVersion == 2006) {
    return header2006.nLCTChipRead();
  }
  else {
    // nLCTChip obsolete in ALCT2007 format (email Andrey K. & Victor B., 20.10.2008)
    // and we don't think anyone makes uses of this call.
    //    edm::LogError("CSCALCTHeader|CSCRawToDigi")
    //      <<"How is nLCTChipRead() supposed to work for ALCTHeader2007?";
  }
  return 0;
}
unsigned short int CSCALCTHeader::NTBins ( ) const [inline]

Definition at line 39 of file CSCALCTHeader.h.

References firmwareVersion, header2006, header2007, CSCALCTHeader2006::nTBins, and CSCALCTHeader2007::rawBins.

Referenced by operator<<().

                                            {
    switch (firmwareVersion)
      {
      case 2006:
        return header2006.nTBins;
      case 2007:
        return header2007.rawBins;
      default:
        edm::LogError("CSCALCTHeader|CSCRawToDigi")
          <<"trying to access NTBINs: ALCT firmware version is bad/not defined!";
        return 0;
      }
  }
boost::dynamic_bitset CSCALCTHeader::pack ( )

Definition at line 211 of file CSCALCTHeader.cc.

References alcts2006, python::multivaluedict::append(), firmwareVersion, header2006, header2007, i, query::result, CSCALCTHeader2006::sizeInWords(), CSCALCTHeader2007::sizeInWords(), sizeInWords(), CSCALCTs2006::sizeInWords(), theALCTs, and bitset_utilities::ushortToBitset().

Referenced by CSCEventData::pack().

{
  boost::dynamic_bitset<> result;
  if(firmwareVersion == 2006)
  {
     boost::dynamic_bitset<> header
       = bitset_utilities::ushortToBitset(header2006.sizeInWords()*16,
                                          (unsigned short *) &header2006);
     boost::dynamic_bitset<> alcts 
       = bitset_utilities::ushortToBitset(alcts2006.sizeInWords()*16,
                                          (unsigned short *) &alcts2006);
     result = bitset_utilities::append(header, alcts);
  }

  else if(firmwareVersion == 2007)
  {
    result = bitset_utilities::ushortToBitset(header2007.sizeInWords()*16,
                                          (unsigned short *) &header2007);

    for (unsigned i = 0; i < theALCTs.size(); ++i)
    {
       boost::dynamic_bitset<> alct
         = bitset_utilities::ushortToBitset(theALCTs[i].sizeInWords()*16,
                                          (unsigned short *) &theALCTs[i]);
       result = bitset_utilities::append(result, alct);
    }
  }
  return result;
}
unsigned short int CSCALCTHeader::Promote1 ( ) const [inline]

Definition at line 83 of file CSCALCTHeader.h.

References header2006, and CSCALCTHeader2006::promote1.

{return header2006.promote1;}
unsigned short int CSCALCTHeader::Promote2 ( ) const [inline]

Definition at line 84 of file CSCALCTHeader.h.

References header2006, and CSCALCTHeader2006::promote2.

{return header2006.promote2;}
void CSCALCTHeader::selfTest ( int  firmware) [static]

tests that we unpack what we packed

Definition at line 243 of file CSCALCTHeader.cc.

References add(), firmwareVersion, CSCDetId::iChamberType(), and relativeConstraints::station.

{
  firmwareVersion = firmware;
  CSCALCTDigi alct0(true, 1, 1, 1, 10, 6, 1);
  CSCALCTDigi alct1(true, 1, 1, 0, 11, 6, 2);

    // tests packing and unpacking
    for(int station = 1; station <= 4; ++station)
    {
      CSCDetId detId(1, station, 1, 1, 0);

      std::vector<CSCALCTDigi> oldAlcts;
      oldAlcts.push_back(alct0);
      oldAlcts.push_back(alct1);
      CSCALCTHeader alctHeader(detId.iChamberType());

      alctHeader.add(oldAlcts);

      std::vector<CSCALCTDigi> alcts = alctHeader.ALCTDigis();
      // pick out the valid ones
      std::vector<CSCALCTDigi> validALCTs;
      for(std::vector<CSCALCTDigi>::const_iterator alctItr = alcts.begin();
          alctItr != alcts.end(); ++ alctItr)
      {
        if(alctItr->isValid())
        {
          validALCTs.push_back(*alctItr);
        }
      }
      assert(validALCTs[0] == alct0);
      assert(validALCTs[1] == alct1);
      //cscClassPackerCompare(alctHeader);
    }
}
void CSCALCTHeader::setDAVForChannel ( int  wireGroup) [inline]

Definition at line 87 of file CSCALCTHeader.h.

References firmwareVersion, header2006, and CSCALCTHeader2006::setDAV().

Referenced by CSCEventData::add().

                                       {
     if(firmwareVersion == 2006) {
       header2006.setDAV((wireGroup-1)/16);
     }
  }
static void CSCALCTHeader::setDebug ( bool  value) [inline, static]

to access data by via status digis

turns on the debug flag for this class

Definition at line 27 of file CSCALCTHeader.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

{debug = value;};
void CSCALCTHeader::setEventInformation ( const CSCDMBHeader dmb)
int CSCALCTHeader::sizeInWords ( ) [inline]

in 16-bit words

Definition at line 98 of file CSCALCTHeader.h.

References firmwareVersion, and sizeInWords2007_.

Referenced by CSCEventData::checkALCTClasses(), CSCALCTHeader(), and pack().

                    {
    switch (firmwareVersion)
      {
      case 2006:
        return 8;
      case 2007:
        return sizeInWords2007_;
      default:
        edm::LogError("CSCALCTHeader|CSCRawToDigi")
          <<"SizeInWords(): ALCT firmware version is bad/not defined!";
        return 0;
      }
  }

Member Data Documentation

Definition at line 137 of file CSCALCTHeader.h.

Referenced by add(), ALCTDigis(), CSCALCTHeader(), and pack().

unsigned short int CSCALCTHeader::bxn0 [private]

Definition at line 151 of file CSCALCTHeader.h.

unsigned short int CSCALCTHeader::bxn1 [private]

Definition at line 151 of file CSCALCTHeader.h.

Definition at line 140 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader().

Definition at line 139 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader().

bool CSCALCTHeader::debug = false [static, private]

Definition at line 147 of file CSCALCTHeader.h.

Referenced by setDebug().

short unsigned int CSCALCTHeader::firmwareVersion = 2007 [static, private]

Definition at line 135 of file CSCALCTHeader.h.

Referenced by add(), alctHeader2007(), BXNCount(), check(), CSCALCTHeader(), L1Acc(), NTBins(), and pack().

Definition at line 141 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader().

unsigned short int CSCALCTHeader::sizeInWords2007_ [private]

size of the 2007 header in words

Definition at line 151 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader(), and sizeInWords().

std::vector<CSCALCT> CSCALCTHeader::theALCTs [private]

Definition at line 136 of file CSCALCTHeader.h.

Referenced by add(), ALCTDigis(), CSCALCTHeader(), and pack().

unsigned short int CSCALCTHeader::theOriginalBuffer[116] [private]

Definition at line 145 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader(), and data().

Definition at line 138 of file CSCALCTHeader.h.

Referenced by CSCALCTHeader().