CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

L1RCTReceiverCard Class Reference

#include <L1RCTReceiverCard.h>

List of all members.

Public Member Functions

int cardNumber ()
int crateNumber ()
void fileInput (char *filename)
void fillInput (const std::vector< unsigned short > &input)
void fillMuonBits ()
void fillRegionSums ()
void fillTauBits ()
unsigned short getEtIn10BitsRegion (int i)
unsigned short getMuonBitRegion (int i)
unsigned short getOverFlowBitRegion (int i)
L1RCTRegiongetRegion (int i)
unsigned short getTauBitRegion (int i)
 L1RCTReceiverCard (int crateNumber, int cardNumber, const L1RCTLookupTables *rctLookupTables)
void print ()
void printEdges ()
void randomInput ()
std::vector< unsigned short > towerToRegionMap (int towernum)
 ~L1RCTReceiverCard ()

Private Member Functions

unsigned short calcMuonBit (L1RCTRegion region)
unsigned short calcRegionSum (L1RCTRegion region)
unsigned short calcTauBit (L1RCTRegion region)
 L1RCTReceiverCard ()

Private Attributes

unsigned short cardNo
unsigned short crtNo
std::vector< unsigned short > etIn10Bits
std::vector< unsigned short > muonBits
std::vector< unsigned short > overFlowBits
const L1RCTLookupTablesrctLookupTables_
std::vector< L1RCTRegionregions
std::vector< unsigned short > tauBits

Detailed Description

Definition at line 14 of file L1RCTReceiverCard.h.


Constructor & Destructor Documentation

L1RCTReceiverCard::L1RCTReceiverCard ( int  crateNumber,
int  cardNumber,
const L1RCTLookupTables rctLookupTables 
)

Definition at line 18 of file L1RCTReceiverCard.cc.

L1RCTReceiverCard::~L1RCTReceiverCard ( )

Definition at line 25 of file L1RCTReceiverCard.cc.

{}
L1RCTReceiverCard::L1RCTReceiverCard ( ) [private]

Member Function Documentation

unsigned short L1RCTReceiverCard::calcMuonBit ( L1RCTRegion  region) [private]

Definition at line 244 of file L1RCTReceiverCard.cc.

References L1RCTRegion::getMuonBit(), i, and j.

Referenced by fillMuonBits().

                                                               {
  unsigned short muonBit = 0;
  for(int i = 0; i<4; i++){
    for(int j = 0; j<4; j++){
      muonBit = muonBit || region.getMuonBit(i,j);
    }
  }
  return muonBit;

}
unsigned short L1RCTReceiverCard::calcRegionSum ( L1RCTRegion  region) [private]

Definition at line 219 of file L1RCTReceiverCard.cc.

References L1RCTRegion::getEtIn9Bits(), i, and j.

Referenced by fillRegionSums().

                                                                 {
  unsigned short sum = 0;
  unsigned short overflow = 0;
  for(int i = 0; i<4; i++){
    for(int j = 0; j<4; j++){
      unsigned short towerEt = region.getEtIn9Bits(i,j);
      // If tower is saturated, peg the region to max value
      //if(towerEt == 0x1FF) sum = 0x3FF;  // HARDWARE DOESN'T DO THIS!!
      //else 
      sum = sum + towerEt;
    }
  }
  if(sum > 1023){
    sum = 1023;
    overflow = 1;
  }
  unsigned short sumFullInfo = sum*2 + overflow;
  return sumFullInfo;
}
unsigned short L1RCTReceiverCard::calcTauBit ( L1RCTRegion  region) [private]

Definition at line 171 of file L1RCTReceiverCard.cc.

References submit::answer, L1RCTRegion::getActivityBit(), and i.

Referenced by fillTauBits().

                                                              {
  bitset<4> etaPattern;
  bitset<4> phiPattern;

  bitset<4> badPattern5(string("0101"));
  bitset<4> badPattern7(string("0111"));
  bitset<4> badPattern9(string("1001"));
  bitset<4> badPattern10(string("1010"));
  bitset<4> badPattern11(string("1011"));
  bitset<4> badPattern13(string("1101"));
  bitset<4> badPattern14(string("1110"));
  bitset<4> badPattern15(string("1111"));

  for(int i = 0; i<4; i++){
    phiPattern[i] = region.getActivityBit(i,0) || region.getActivityBit(i,1) ||
      region.getActivityBit(i,2) || region.getActivityBit(i,3);
    etaPattern[i] = region.getActivityBit(0,i) || region.getActivityBit(1,i) ||
      region.getActivityBit(2,i) || region.getActivityBit(3,i);
  }

  bool answer;
  
  if(etaPattern != badPattern5 && etaPattern != badPattern7 && 
     etaPattern != badPattern10 && etaPattern != badPattern11 &&
     etaPattern != badPattern13 && etaPattern != badPattern14 &&
     etaPattern != badPattern15 && phiPattern != badPattern5 && 
     phiPattern != badPattern7 && phiPattern != badPattern10 && 
     phiPattern != badPattern11 && phiPattern != badPattern13 && 
     phiPattern != badPattern14 && phiPattern != badPattern15 &&
     etaPattern != badPattern9 && phiPattern != badPattern9){       // adding in "9"
    //return false;
    answer = false;
  }
  //else return true;
  else {
    answer = true;
  }
  // std::cout << "Tau veto set to " << answer << std::endl;
  return answer;
}
int L1RCTReceiverCard::cardNumber ( ) [inline]

Definition at line 23 of file L1RCTReceiverCard.h.

References cardNo.

{return cardNo;}
int L1RCTReceiverCard::crateNumber ( ) [inline]

Definition at line 22 of file L1RCTReceiverCard.h.

References crtNo.

{return crtNo;}
void L1RCTReceiverCard::fileInput ( char *  filename)

Definition at line 34 of file L1RCTReceiverCard.cc.

References fillInput(), i, LaserDQM_cfg::input, and x.

                                               {
  std::vector<unsigned short> input(64);
  unsigned short x;
  std::ifstream instream(filename);
  if(instream){
    for(int i = 0; i<64; i++){
      if(!(instream >> x))
        break;
      else
        input.at(i) = x;
    }
  }
  fillInput(input);
}
void L1RCTReceiverCard::fillInput ( const std::vector< unsigned short > &  input)

Definition at line 70 of file L1RCTReceiverCard.cc.

References cardNo, cuy::col, crtNo, i, L1RCTLookupTables::lookup(), alignCSCRings::r, rctLookupTables_, regions, and towerToRegionMap().

Referenced by fileInput(), and randomInput().

                                                                       {
  
  std::vector<unsigned short> ecalInput(32);
  std::vector<unsigned short> ecalFG(32);
  std::vector<unsigned short> hcalInput(32);
  std::vector<unsigned short> hcalMuon(32);

  for(int i = 0; i<32; i++){
    ecalInput.at(i) = input.at(i)/2;
    ecalFG.at(i) = input.at(i) & 1;
    hcalInput.at(i) = input.at(i+32)/2;
    hcalMuon.at(i) = input.at(i+32) & 1;
    unsigned long lookup = rctLookupTables_->lookup(ecalInput.at(i),hcalInput.at(i),ecalFG.at(i),crtNo, cardNo, i); // tower number 0-31 now
    unsigned short etIn7Bits = lookup&127;
    unsigned short etIn9Bits = (lookup >> 8)&511;
    unsigned short HE_FGBit = (lookup>>7)&1;
    unsigned short activityBit = (lookup>>17)&1;
    std::vector<unsigned short> indices = towerToRegionMap(i);
    unsigned short r = indices.at(0);
    unsigned short row = indices.at(1);
    unsigned short col = indices.at(2);
    regions.at(r).setEtIn7Bits(row,col,etIn7Bits);
    regions.at(r).setEtIn9Bits(row,col,etIn9Bits);
    regions.at(r).setHE_FGBit(row,col,HE_FGBit);
    regions.at(r).setMuonBit(row,col,hcalMuon.at(i));
    regions.at(r).setActivityBit(row,col,activityBit);
  }

}
void L1RCTReceiverCard::fillMuonBits ( )

Definition at line 239 of file L1RCTReceiverCard.cc.

References calcMuonBit(), i, muonBits, and regions.

                                    {
  for(int i = 0; i<2; i++)
    muonBits.at(i) = calcMuonBit(regions.at(i));
}
void L1RCTReceiverCard::fillRegionSums ( )

Definition at line 212 of file L1RCTReceiverCard.cc.

References calcRegionSum(), etIn10Bits, i, overFlowBits, and regions.

                                      {
  for(int i = 0; i<2; i++){
    etIn10Bits.at(i) = (calcRegionSum(regions.at(i)))/2;
    overFlowBits.at(i) = (calcRegionSum(regions.at(i)) & 1);
  }
}
void L1RCTReceiverCard::fillTauBits ( )

Definition at line 166 of file L1RCTReceiverCard.cc.

References calcTauBit(), i, regions, and tauBits.

                                   {
  for(int i = 0; i<2; i++)
    tauBits.at(i) = calcTauBit(regions.at(i));
}
unsigned short L1RCTReceiverCard::getEtIn10BitsRegion ( int  i) [inline]

Definition at line 61 of file L1RCTReceiverCard.h.

References etIn10Bits.

{return etIn10Bits.at(i);}
unsigned short L1RCTReceiverCard::getMuonBitRegion ( int  i) [inline]

Definition at line 59 of file L1RCTReceiverCard.h.

References muonBits.

{return muonBits.at(i);}
unsigned short L1RCTReceiverCard::getOverFlowBitRegion ( int  i) [inline]

Definition at line 60 of file L1RCTReceiverCard.h.

References overFlowBits.

{return overFlowBits.at(i);}
L1RCTRegion* L1RCTReceiverCard::getRegion ( int  i) [inline]

Definition at line 55 of file L1RCTReceiverCard.h.

References regions.

                                {
    return &regions.at(i);
  }
unsigned short L1RCTReceiverCard::getTauBitRegion ( int  i) [inline]

Definition at line 58 of file L1RCTReceiverCard.h.

References tauBits.

{return tauBits.at(i);}
void L1RCTReceiverCard::print ( void  )

Definition at line 255 of file L1RCTReceiverCard.cc.

References cardNo, gather_cfg::cout, crtNo, etIn10Bits, i, muonBits, regions, and tauBits.

                             {
  std::cout <<"Receiver Card " << cardNo << " in Crate " << crtNo <<std::endl;

  for(int i=0;i<2;i++){
    std::cout << "Region " << i << " information" << std::endl;
    regions.at(i).print();
    std::cout << "Region Et sum " << etIn10Bits.at(i) << std::endl;
    std::cout << "Tau Veto Bit " << tauBits.at(i) << std::endl;
    std::cout << "Muon Bit " << muonBits.at(i) << std::endl;
  }
}
void L1RCTReceiverCard::printEdges ( ) [inline]

Definition at line 67 of file L1RCTReceiverCard.h.

References regions.

                   {
    regions.at(0).printEdges();
    regions.at(1).printEdges();
  }
void L1RCTReceiverCard::randomInput ( )

Definition at line 27 of file L1RCTReceiverCard.cc.

References fillInput(), i, and LaserDQM_cfg::input.

                                   {
  std::vector<unsigned short> input(64);
  for(int i = 0; i<64;i++)
    input.at(i) = rand()&511;
  fillInput(input);
}
vector< unsigned short > L1RCTReceiverCard::towerToRegionMap ( int  towernum)

Definition at line 101 of file L1RCTReceiverCard.cc.

References cardNo, and crtNo.

Referenced by fillInput().

                                                                      {
  std::vector<unsigned short> returnVec(3);
  unsigned short region;
  unsigned short towerrow;
  unsigned short towercol;
  if(crtNo <9){
    if(cardNo != 6){
      if(towernum < 16){
        region = 0;
        towerrow = towernum%4;
        towercol = 3-(towernum/4);
      }
      else{
        region = 1;
        towerrow = towernum%4;
        towercol = 7-(towernum/4);
      }
    }
    else{
      if(towernum < 16){
        region = 0;
        towerrow = towernum%4;
        towercol = 3-(towernum/4);
      }
      else{
        region = 1;
        towerrow = towernum%4;
        towercol = (towernum/4)-4;
      }
    }
  }
  else{
    if(cardNo != 6){
      if(towernum < 16){
        region = 0;
        towerrow = towernum%4;
        towercol = towernum/4;
      }
      else{
        region = 1;
        towerrow = towernum%4;
        towercol = (towernum/4)-4;
      }
    }
    else{
      if(towernum < 16){
        region = 0;
        towerrow = towernum%4;
        towercol = towernum/4;
      }
      else{
        region = 1;
        towerrow = towernum%4;
        towercol = 7-(towernum/4);
      }
    }
  }
  returnVec.at(0)=region;
  returnVec.at(1)=towerrow;
  returnVec.at(2)=towercol;
  return returnVec;
}    

Member Data Documentation

unsigned short L1RCTReceiverCard::cardNo [private]

Definition at line 83 of file L1RCTReceiverCard.h.

Referenced by cardNumber(), fillInput(), print(), and towerToRegionMap().

unsigned short L1RCTReceiverCard::crtNo [private]

Definition at line 82 of file L1RCTReceiverCard.h.

Referenced by crateNumber(), fillInput(), print(), and towerToRegionMap().

std::vector<unsigned short> L1RCTReceiverCard::etIn10Bits [private]

Definition at line 87 of file L1RCTReceiverCard.h.

Referenced by fillRegionSums(), getEtIn10BitsRegion(), and print().

std::vector<unsigned short> L1RCTReceiverCard::muonBits [private]

Definition at line 89 of file L1RCTReceiverCard.h.

Referenced by fillMuonBits(), getMuonBitRegion(), and print().

std::vector<unsigned short> L1RCTReceiverCard::overFlowBits [private]

Definition at line 88 of file L1RCTReceiverCard.h.

Referenced by fillRegionSums(), and getOverFlowBitRegion().

Definition at line 85 of file L1RCTReceiverCard.h.

Referenced by fillInput().

std::vector<L1RCTRegion> L1RCTReceiverCard::regions [private]
std::vector<unsigned short> L1RCTReceiverCard::tauBits [private]

Definition at line 90 of file L1RCTReceiverCard.h.

Referenced by fillTauBits(), getTauBitRegion(), and print().