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

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.

21  rctLookupTables_(rctLookupTables), etIn10Bits(2), overFlowBits(2),
22  muonBits(2), 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::~L1RCTReceiverCard ( )

Definition at line 24 of file L1RCTReceiverCard.cc.

24 {}
L1RCTReceiverCard::L1RCTReceiverCard ( )
privatedelete

Member Function Documentation

unsigned short L1RCTReceiverCard::calcMuonBit ( L1RCTRegion  region)
private

Definition at line 234 of file L1RCTReceiverCard.cc.

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

Referenced by fillMuonBits().

234  {
235  unsigned short muonBit = 0;
236  for (int i = 0; i < 4; i++) {
237  for (int j = 0; j < 4; j++) {
238  muonBit = muonBit || region.getMuonBit(i, j);
239  }
240  }
241  return muonBit;
242 }
unsigned short getMuonBit(int i, int j) const
Definition: L1RCTRegion.cc:62
unsigned short L1RCTReceiverCard::calcRegionSum ( L1RCTRegion  region)
private

Definition at line 209 of file L1RCTReceiverCard.cc.

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

Referenced by fillRegionSums().

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

Definition at line 159 of file L1RCTReceiverCard.cc.

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

Referenced by fillTauBits().

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

Definition at line 23 of file L1RCTReceiverCard.h.

References cardNo, fillInput(), fillMuonBits(), fillRegionSums(), fillTauBits(), and input.

23 { return cardNo; }
unsigned short cardNo
int L1RCTReceiverCard::crateNumber ( )
inline

Definition at line 22 of file L1RCTReceiverCard.h.

References crtNo.

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

Definition at line 33 of file L1RCTReceiverCard.cc.

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

Referenced by printEdges().

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

Definition at line 67 of file L1RCTReceiverCard.cc.

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

Referenced by cardNumber(), fileInput(), and randomInput().

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

Definition at line 229 of file L1RCTReceiverCard.cc.

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

Referenced by cardNumber().

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

Definition at line 202 of file L1RCTReceiverCard.cc.

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

Referenced by cardNumber().

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

Definition at line 154 of file L1RCTReceiverCard.cc.

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

Referenced by cardNumber().

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

Definition at line 59 of file L1RCTReceiverCard.h.

References etIn10Bits, print(), and towerToRegionMap().

59 { return etIn10Bits.at(i); }
std::vector< unsigned short > etIn10Bits
unsigned short L1RCTReceiverCard::getMuonBitRegion ( int  i)
inline

Definition at line 57 of file L1RCTReceiverCard.h.

References muonBits.

57 { return muonBits.at(i); }
std::vector< unsigned short > muonBits
unsigned short L1RCTReceiverCard::getOverFlowBitRegion ( int  i)
inline

Definition at line 58 of file L1RCTReceiverCard.h.

References overFlowBits.

58 { return overFlowBits.at(i); }
std::vector< unsigned short > overFlowBits
L1RCTRegion* L1RCTReceiverCard::getRegion ( int  i)
inline

Definition at line 55 of file L1RCTReceiverCard.h.

References regions.

55 { return &regions.at(i); }
std::vector< L1RCTRegion > regions
unsigned short L1RCTReceiverCard::getTauBitRegion ( int  i)
inline

Definition at line 56 of file L1RCTReceiverCard.h.

References tauBits.

56 { return tauBits.at(i); }
std::vector< unsigned short > tauBits
void L1RCTReceiverCard::print ( void  )

Definition at line 244 of file L1RCTReceiverCard.cc.

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

Referenced by getEtIn10BitsRegion().

244  {
245  std::cout << "Receiver Card " << cardNo << " in Crate " << crtNo << std::endl;
246 
247  for (int i = 0; i < 2; i++) {
248  std::cout << "Region " << i << " information" << std::endl;
249  regions.at(i).print();
250  std::cout << "Region Et sum " << etIn10Bits.at(i) << std::endl;
251  std::cout << "Tau Veto Bit " << tauBits.at(i) << std::endl;
252  std::cout << "Muon Bit " << muonBits.at(i) << std::endl;
253  }
254 }
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
void L1RCTReceiverCard::printEdges ( )
inline

Definition at line 65 of file L1RCTReceiverCard.h.

References fileInput(), corrVsCorr::filename, randomInput(), and regions.

65  {
66  regions.at(0).printEdges();
67  regions.at(1).printEdges();
68  }
std::vector< L1RCTRegion > regions
void L1RCTReceiverCard::randomInput ( )

Definition at line 26 of file L1RCTReceiverCard.cc.

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

Referenced by printEdges().

26  {
27  std::vector<unsigned short> input(64);
28  for (int i = 0; i < 64; i++)
29  input.at(i) = rand() & 511;
31 }
void fillInput(const std::vector< unsigned short > &input)
static std::string const input
Definition: EdmProvDump.cc:48
Signal rand(Signal arg)
Definition: vlib.cc:442
vector< unsigned short > L1RCTReceiverCard::towerToRegionMap ( int  towernum)

Definition at line 98 of file L1RCTReceiverCard.cc.

References cardNo, and crtNo.

Referenced by fillInput(), and getEtIn10BitsRegion().

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

Member Data Documentation

unsigned short L1RCTReceiverCard::cardNo
private

Definition at line 80 of file L1RCTReceiverCard.h.

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

unsigned short L1RCTReceiverCard::crtNo
private

Definition at line 79 of file L1RCTReceiverCard.h.

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

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

Definition at line 84 of file L1RCTReceiverCard.h.

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

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

Definition at line 86 of file L1RCTReceiverCard.h.

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

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

Definition at line 85 of file L1RCTReceiverCard.h.

Referenced by fillRegionSums(), and getOverFlowBitRegion().

const L1RCTLookupTables* L1RCTReceiverCard::rctLookupTables_
private

Definition at line 82 of file L1RCTReceiverCard.h.

Referenced by fillInput().

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

Definition at line 87 of file L1RCTReceiverCard.h.

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