CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1RCTReceiverCard Class Reference

#include <L1RCTReceiverCard.h>

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)
 
 L1RCTReceiverCard ()=delete
 
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)
 

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() [1/2]

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

Definition at line 18 of file L1RCTReceiverCard.cc.

19  : regions(2),
22  rctLookupTables_(rctLookupTables),
23  etIn10Bits(2),
24  overFlowBits(2),
25  muonBits(2),
26  tauBits(2) {}
unsigned short cardNo
unsigned short crtNo
const L1RCTLookupTables * rctLookupTables_
std::vector< unsigned short > overFlowBits
std::vector< unsigned short > etIn10Bits
std::vector< unsigned short > muonBits
std::vector< unsigned short > tauBits
std::vector< L1RCTRegion > regions

◆ L1RCTReceiverCard() [2/2]

L1RCTReceiverCard::L1RCTReceiverCard ( )
delete

◆ ~L1RCTReceiverCard()

L1RCTReceiverCard::~L1RCTReceiverCard ( )

Definition at line 28 of file L1RCTReceiverCard.cc.

28 {}

Member Function Documentation

◆ calcMuonBit()

unsigned short L1RCTReceiverCard::calcMuonBit ( L1RCTRegion  region)
private

Definition at line 232 of file L1RCTReceiverCard.cc.

References mps_fire::i, dqmiolumiharvest::j, L1TScalersSCAL_cfi::muonBit, and nano_mu_digi_cff::region.

Referenced by fillMuonBits().

232  {
233  unsigned short muonBit = 0;
234  for (int i = 0; i < 4; i++) {
235  for (int j = 0; j < 4; j++) {
236  muonBit = muonBit || region.getMuonBit(i, j);
237  }
238  }
239  return muonBit;
240 }

◆ calcRegionSum()

unsigned short L1RCTReceiverCard::calcRegionSum ( L1RCTRegion  region)
private

Definition at line 207 of file L1RCTReceiverCard.cc.

References mps_fire::i, dqmiolumiharvest::j, and nano_mu_digi_cff::region.

Referenced by fillRegionSums().

207  {
208  unsigned short sum = 0;
209  unsigned short overflow = 0;
210  for (int i = 0; i < 4; i++) {
211  for (int j = 0; j < 4; j++) {
212  unsigned short towerEt = region.getEtIn9Bits(i, j);
213  // If tower is saturated, peg the region to max value
214  // if(towerEt == 0x1FF) sum = 0x3FF; // HARDWARE DOESN'T DO THIS!!
215  // else
216  sum = sum + towerEt;
217  }
218  }
219  if (sum > 1023) {
220  sum = 1023;
221  overflow = 1;
222  }
223  unsigned short sumFullInfo = sum * 2 + overflow;
224  return sumFullInfo;
225 }

◆ calcTauBit()

unsigned short L1RCTReceiverCard::calcTauBit ( L1RCTRegion  region)
private

Definition at line 161 of file L1RCTReceiverCard.cc.

References mps_fire::i, and nano_mu_digi_cff::region.

Referenced by fillTauBits().

161  {
162  bitset<4> etaPattern;
163  bitset<4> phiPattern;
164 
165  bitset<4> badPattern5(string("0101"));
166  bitset<4> badPattern7(string("0111"));
167  bitset<4> badPattern9(string("1001"));
168  bitset<4> badPattern10(string("1010"));
169  bitset<4> badPattern11(string("1011"));
170  bitset<4> badPattern13(string("1101"));
171  bitset<4> badPattern14(string("1110"));
172  bitset<4> badPattern15(string("1111"));
173 
174  for (int i = 0; i < 4; i++) {
175  phiPattern[i] = region.getActivityBit(i, 0) || region.getActivityBit(i, 1) || region.getActivityBit(i, 2) ||
176  region.getActivityBit(i, 3);
177  etaPattern[i] = region.getActivityBit(0, i) || region.getActivityBit(1, i) || region.getActivityBit(2, i) ||
178  region.getActivityBit(3, i);
179  }
180 
181  bool answer;
182 
183  if (etaPattern != badPattern5 && etaPattern != badPattern7 && etaPattern != badPattern10 &&
184  etaPattern != badPattern11 && etaPattern != badPattern13 && etaPattern != badPattern14 &&
185  etaPattern != badPattern15 && phiPattern != badPattern5 && phiPattern != badPattern7 &&
186  phiPattern != badPattern10 && phiPattern != badPattern11 && phiPattern != badPattern13 &&
187  phiPattern != badPattern14 && phiPattern != badPattern15 && etaPattern != badPattern9 &&
188  phiPattern != badPattern9) { // adding in "9"
189  // return false;
190  answer = false;
191  }
192  // else return true;
193  else {
194  answer = true;
195  }
196  // std::cout << "Tau veto set to " << answer << std::endl;
197  return answer;
198 }

◆ cardNumber()

int L1RCTReceiverCard::cardNumber ( )
inline

Definition at line 26 of file L1RCTReceiverCard.h.

References cardNo.

26 { return cardNo; }
unsigned short cardNo

◆ crateNumber()

int L1RCTReceiverCard::crateNumber ( )
inline

Definition at line 25 of file L1RCTReceiverCard.h.

References crtNo.

25 { return crtNo; }
unsigned short crtNo

◆ fileInput()

void L1RCTReceiverCard::fileInput ( char *  filename)

Definition at line 37 of file L1RCTReceiverCard.cc.

References corrVsCorr::filename, fillInput(), mps_fire::i, input, and x.

37  {
38  std::vector<unsigned short> input(64);
39  unsigned short x;
40  std::ifstream instream(filename);
41  if (instream) {
42  for (int i = 0; i < 64; i++) {
43  if (!(instream >> x))
44  break;
45  else
46  input.at(i) = x;
47  }
48  }
50 }
void fillInput(const std::vector< unsigned short > &input)
static std::string const input
Definition: EdmProvDump.cc:50

◆ fillInput()

void L1RCTReceiverCard::fillInput ( const std::vector< unsigned short > &  input)

Definition at line 71 of file L1RCTReceiverCard.cc.

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

Referenced by fileInput(), and randomInput().

71  {
72  std::vector<unsigned short> ecalInput(32);
73  std::vector<unsigned short> ecalFG(32);
74  std::vector<unsigned short> hcalInput(32);
75  std::vector<unsigned short> hcalMuon(32);
76 
77  for (int i = 0; i < 32; i++) {
78  ecalInput.at(i) = input.at(i) / 2;
79  ecalFG.at(i) = input.at(i) & 1;
80  hcalInput.at(i) = input.at(i + 32) / 2;
81  hcalMuon.at(i) = input.at(i + 32) & 1;
82  unsigned long lookup = rctLookupTables_->lookup(
83  ecalInput.at(i), hcalInput.at(i), ecalFG.at(i), crtNo, cardNo, i); // tower number 0-31 now
84  unsigned short etIn7Bits = lookup & 127;
85  unsigned short etIn9Bits = (lookup >> 8) & 511;
86  unsigned short HE_FGBit = (lookup >> 7) & 1;
87  unsigned short activityBit = (lookup >> 17) & 1;
88  std::vector<unsigned short> indices = towerToRegionMap(i);
89  unsigned short r = indices.at(0);
90  unsigned short row = indices.at(1);
91  unsigned short col = indices.at(2);
92  regions.at(r).setEtIn7Bits(row, col, etIn7Bits);
93  regions.at(r).setEtIn9Bits(row, col, etIn9Bits);
94  regions.at(r).setHE_FGBit(row, col, HE_FGBit);
95  regions.at(r).setMuonBit(row, col, hcalMuon.at(i));
96  regions.at(r).setActivityBit(row, col, activityBit);
97  }
98 }
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
unsigned short cardNo
unsigned short crtNo
static std::string const input
Definition: EdmProvDump.cc:50
const L1RCTLookupTables * rctLookupTables_
col
Definition: cuy.py:1009
std::vector< unsigned short > towerToRegionMap(int towernum)
std::vector< L1RCTRegion > regions

◆ fillMuonBits()

void L1RCTReceiverCard::fillMuonBits ( )

Definition at line 227 of file L1RCTReceiverCard.cc.

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

227  {
228  for (int i = 0; i < 2; i++)
229  muonBits.at(i) = calcMuonBit(regions.at(i));
230 }
unsigned short calcMuonBit(L1RCTRegion region)
std::vector< unsigned short > muonBits
std::vector< L1RCTRegion > regions

◆ fillRegionSums()

void L1RCTReceiverCard::fillRegionSums ( )

Definition at line 200 of file L1RCTReceiverCard.cc.

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

200  {
201  for (int i = 0; i < 2; i++) {
202  etIn10Bits.at(i) = (calcRegionSum(regions.at(i))) / 2;
203  overFlowBits.at(i) = (calcRegionSum(regions.at(i)) & 1);
204  }
205 }
std::vector< unsigned short > overFlowBits
std::vector< unsigned short > etIn10Bits
unsigned short calcRegionSum(L1RCTRegion region)
std::vector< L1RCTRegion > regions

◆ fillTauBits()

void L1RCTReceiverCard::fillTauBits ( )

Definition at line 156 of file L1RCTReceiverCard.cc.

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

156  {
157  for (int i = 0; i < 2; i++)
158  tauBits.at(i) = calcTauBit(regions.at(i));
159 }
unsigned short calcTauBit(L1RCTRegion region)
std::vector< unsigned short > tauBits
std::vector< L1RCTRegion > regions

◆ getEtIn10BitsRegion()

unsigned short L1RCTReceiverCard::getEtIn10BitsRegion ( int  i)
inline

Definition at line 62 of file L1RCTReceiverCard.h.

References etIn10Bits, and mps_fire::i.

62 { return etIn10Bits.at(i); }
std::vector< unsigned short > etIn10Bits

◆ getMuonBitRegion()

unsigned short L1RCTReceiverCard::getMuonBitRegion ( int  i)
inline

Definition at line 60 of file L1RCTReceiverCard.h.

References mps_fire::i, and muonBits.

60 { return muonBits.at(i); }
std::vector< unsigned short > muonBits

◆ getOverFlowBitRegion()

unsigned short L1RCTReceiverCard::getOverFlowBitRegion ( int  i)
inline

Definition at line 61 of file L1RCTReceiverCard.h.

References mps_fire::i, and overFlowBits.

61 { return overFlowBits.at(i); }
std::vector< unsigned short > overFlowBits

◆ getRegion()

L1RCTRegion* L1RCTReceiverCard::getRegion ( int  i)
inline

Definition at line 58 of file L1RCTReceiverCard.h.

References mps_fire::i, and regions.

58 { return &regions.at(i); }
std::vector< L1RCTRegion > regions

◆ getTauBitRegion()

unsigned short L1RCTReceiverCard::getTauBitRegion ( int  i)
inline

Definition at line 59 of file L1RCTReceiverCard.h.

References mps_fire::i, and tauBits.

59 { return tauBits.at(i); }
std::vector< unsigned short > tauBits

◆ print()

void L1RCTReceiverCard::print ( void  )

Definition at line 242 of file L1RCTReceiverCard.cc.

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

242  {
243  std::cout << "Receiver Card " << cardNo << " in Crate " << crtNo << std::endl;
244 
245  for (int i = 0; i < 2; i++) {
246  std::cout << "Region " << i << " information" << std::endl;
247  regions.at(i).print();
248  std::cout << "Region Et sum " << etIn10Bits.at(i) << std::endl;
249  std::cout << "Tau Veto Bit " << tauBits.at(i) << std::endl;
250  std::cout << "Muon Bit " << muonBits.at(i) << std::endl;
251  }
252 }
unsigned short cardNo
unsigned short crtNo
std::vector< unsigned short > etIn10Bits
std::vector< unsigned short > muonBits
std::vector< unsigned short > tauBits
std::vector< L1RCTRegion > regions

◆ printEdges()

void L1RCTReceiverCard::printEdges ( )
inline

Definition at line 68 of file L1RCTReceiverCard.h.

References regions.

68  {
69  regions.at(0).printEdges();
70  regions.at(1).printEdges();
71  }
std::vector< L1RCTRegion > regions

◆ randomInput()

void L1RCTReceiverCard::randomInput ( )

Definition at line 30 of file L1RCTReceiverCard.cc.

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

30  {
31  std::vector<unsigned short> input(64);
32  for (int i = 0; i < 64; i++)
33  input.at(i) = rand() & 511;
35 }
void fillInput(const std::vector< unsigned short > &input)
static std::string const input
Definition: EdmProvDump.cc:50

◆ towerToRegionMap()

vector< unsigned short > L1RCTReceiverCard::towerToRegionMap ( int  towernum)

Definition at line 100 of file L1RCTReceiverCard.cc.

References cardNo, crtNo, and nano_mu_digi_cff::region.

Referenced by fillInput().

100  {
101  std::vector<unsigned short> returnVec(3);
102  unsigned short region;
103  unsigned short towerrow;
104  unsigned short towercol;
105  if (crtNo < 9) {
106  if (cardNo != 6) {
107  if (towernum < 16) {
108  region = 0;
109  towerrow = towernum % 4;
110  towercol = 3 - (towernum / 4);
111  } else {
112  region = 1;
113  towerrow = towernum % 4;
114  towercol = 7 - (towernum / 4);
115  }
116  } else {
117  if (towernum < 16) {
118  region = 0;
119  towerrow = towernum % 4;
120  towercol = 3 - (towernum / 4);
121  } else {
122  region = 1;
123  towerrow = towernum % 4;
124  towercol = (towernum / 4) - 4;
125  }
126  }
127  } else {
128  if (cardNo != 6) {
129  if (towernum < 16) {
130  region = 0;
131  towerrow = towernum % 4;
132  towercol = towernum / 4;
133  } else {
134  region = 1;
135  towerrow = towernum % 4;
136  towercol = (towernum / 4) - 4;
137  }
138  } else {
139  if (towernum < 16) {
140  region = 0;
141  towerrow = towernum % 4;
142  towercol = towernum / 4;
143  } else {
144  region = 1;
145  towerrow = towernum % 4;
146  towercol = 7 - (towernum / 4);
147  }
148  }
149  }
150  returnVec.at(0) = region;
151  returnVec.at(1) = towerrow;
152  returnVec.at(2) = towercol;
153  return returnVec;
154 }
unsigned short cardNo
unsigned short crtNo

Member Data Documentation

◆ cardNo

unsigned short L1RCTReceiverCard::cardNo
private

Definition at line 83 of file L1RCTReceiverCard.h.

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

◆ crtNo

unsigned short L1RCTReceiverCard::crtNo
private

Definition at line 82 of file L1RCTReceiverCard.h.

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

◆ etIn10Bits

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

Definition at line 87 of file L1RCTReceiverCard.h.

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

◆ muonBits

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

Definition at line 89 of file L1RCTReceiverCard.h.

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

◆ overFlowBits

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

Definition at line 88 of file L1RCTReceiverCard.h.

Referenced by fillRegionSums(), and getOverFlowBitRegion().

◆ rctLookupTables_

const L1RCTLookupTables* L1RCTReceiverCard::rctLookupTables_
private

Definition at line 85 of file L1RCTReceiverCard.h.

Referenced by fillInput().

◆ regions

std::vector<L1RCTRegion> L1RCTReceiverCard::regions
private

◆ tauBits

std::vector<unsigned short> L1RCTReceiverCard::tauBits
private

Definition at line 90 of file L1RCTReceiverCard.h.

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