CMS 3D CMS Logo

DTTSCand.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: DTTSCand.cpp
4 //
5 // Description: A Trigger Server Candidate
6 //
7 //
8 // Author List:
9 // C. Grandi
10 // Modifications:
11 // S. Marcellini, D. Bonacorsi
12 // 04/01/2007 : C. Battilana local config update
13 //
14 //--------------------------------------------------
15 
16 //-----------------------
17 // This Class's Header --
18 //-----------------------
20 
21 //-------------------------------
22 // Collaborating Class Headers --
23 //-------------------------------
25 
26 //---------------
27 // C++ Headers --
28 //---------------
29 #include <iostream>
30 
31 //----------------
32 
33 // Constructors --
34 //----------------
35 
36 DTTSCand::DTTSCand(DTTSS *tss, const DTTracoTrigData *tctrig, int ifs, int pos)
37  : _tss(tss), _tctrig(tctrig), _tcPos(pos), _isCarry(0) {
38 
39  _dataword.one(); // reset dataword to 0x1ff
40 
41  // SM sector collector Set bit 14 instead of 8, for 1st/2nd track to allow
42  // extra space
43  // if(ifs==1)_dataword.unset(8); // set bit 8 (0=first, 1=second tracks)
44  if (ifs == 1)
45  _dataword.unset(14); // set bit 14 (0=first, 1=second tracks)
46 }
47 
49  : _tss(tscand._tss), _tctrig(tscand._tctrig), _tcPos(tscand._tcPos),
50  _isCarry(tscand._isCarry) {}
51 
53 
54 //--------------
55 // Destructor --
56 //--------------
58 
59 //--------------
60 // Operations --
61 //--------------
62 
64  if (this != &tscand) {
65  _tss = tscand._tss;
66  _tctrig = tscand._tctrig;
67  _tcPos = tscand._tcPos;
68  _isCarry = tscand._isCarry;
69  }
70  return *this;
71 }
72 
74  _tctrig = nullptr;
75  _dataword.one();
76 
77  _isCarry = 0;
78 }
79 
81  // first/second track already set. Set other 3 bits
82  int itk = _dataword.element(14); // first tracks 0, second tracks 1
83 
84  clearBits();
85  if (_tctrig->pvK() > 32 ||
86  _tctrig->pvK() < 0) { // Check K within 5 bits range
87  std::cout << "DTTSCand::setBitsTss() pvK outside valid range: "
88  << _tctrig->pvK();
89  std::cout << " deltaPsiR set to 31" << std::endl;
90  } else {
91  // assign preview in dataword (common to any other assignment)
92  _dataword.assign(0, 5, _tctrig->pvK());
93  // _dataword.assign(0,5,0);
94 
95  int posH = -1;
96  int posI = -1;
97  int posC = -1;
98  switch (config()->TssMasking(itk)) {
99  case 123: // H/L, In/Out, Corr/NotC
100  posH = 7;
101  posI = 6;
102  posC = 5;
103  break;
104  case 132: // H/L, Corr/NotC, In/Out
105  posH = 7;
106  posI = 5;
107  posC = 6;
108  break;
109  case 213: // In/Out, H/L, Corr/NotC
110  posH = 6;
111  posI = 7;
112  posC = 5;
113  break;
114  case 231: // In/Out, Corr/NotC, H/L
115  posH = 5;
116  posI = 7;
117  posC = 6;
118  break;
119  case 312: // Corr/NotC, H/L, In/Out
120  posH = 6;
121  posI = 5;
122  posC = 7;
123  break;
124  case 321: // Corr/NotC, In/Out, H/L
125  posH = 5;
126  posI = 6;
127  posC = 7;
128  break;
129  default:
130  std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
131  std::cout << config()->TssMasking(itk);
132  std::cout << " All bits set to 1" << std::endl;
133  }
134  // Masking:
135  bool enaH = config()->TssHtrigEna(itk);
136  bool enaI = config()->TssInOutEna(itk);
137  bool enaC = config()->TssCorrEna(itk);
138  if (isCarry()) {
139  // Special setting for carry
140  enaH = config()->TssHtrigEnaCarry();
141  enaI = config()->TssInOutEnaCarry();
142  enaC = config()->TssCorrEnaCarry();
143  }
144  // Bits set to 0 give higher priority:
145  if (isHtrig() && enaH && posH > 0)
146  _dataword.unset(posH);
147  if (isInner() && enaI && posI > 0)
148  _dataword.unset(posI);
149  if (isCorr() && enaC && posC > 0)
150  _dataword.unset(posC);
151  }
152 }
153 
155  // first/second track already set. Set other 4 bits (1 for null, 3 for a2, a1,
156  // a0)
157  clearBitsBkmod();
158  // std::cout << " clearbits in TSM bk mode " << _dataword.print() <<
159  // std::endl;
160 
161  int a2 = 6;
162  int a1 = 5;
163  int a0 = 4;
164  //
165  // std::cout << " _tctrig->qdec(): " << _tctrig->qdec() << std::endl;
166  if (_tctrig->qdec() == 6) {
167  _dataword.unset(a2);
168  _dataword.unset(a1);
169  _dataword.unset(a0);
170  } // 1-000
171  if (_tctrig->qdec() == 5) {
172  _dataword.unset(a2);
173  _dataword.unset(a1);
174  } // 1-001
175  if (_tctrig->qdec() == 4) {
176  _dataword.unset(a2);
177  _dataword.unset(a0);
178  } // 1-010
179  if (_tctrig->qdec() == 3) {
180  _dataword.unset(a1);
181  } // 1-101
182  if (_tctrig->qdec() == 2) {
183  _dataword.unset(a1);
184  _dataword.unset(a0);
185  } // 1-100
186 
187  if (_tctrig->qdec() == 0) {
188  _dataword.unset(a0);
189  } // 1-110
190 
191  // std::cout << " set Bits TSM back up " << _dataword.print() << std::endl;
192 }
193 
195  // first/second track already set. Set other 3 bits
196  int itk = _dataword.element(14); // first tracks 0, second tracks 1
197 
198  clearBits();
199 
200  if (_tctrig->pvK() > 31 ||
201  _tctrig->pvK() < 0) { // Check K within 5 bits range
202  std::cout << "DTTSCand::setBitsTsm pvK outside valid range: "
203  << _tctrig->pvK();
204  std::cout << " deltaPsiR set to 31" << std::endl;
205  } else {
206  // SM double TSM
207  // assign preview in dataword (common to any other assignment)
208  _dataword.assign(0, 5, _tctrig->pvK());
209  // _dataword.assign(0,5,0);
210  //
211 
212  int posH = -1;
213  int posI = -1;
214  int posC = -1;
215  switch (config()->TsmMasking(itk)) {
216  case 123: // H/L, In/Out, Corr/NotC
217  posH = 7;
218  posI = 6;
219  posC = 5;
220  break;
221  case 132: // H/L, Corr/NotC, In/Out
222  posH = 7;
223  posI = 5;
224  posC = 6;
225  break;
226  case 213: // In/Out, H/L, Corr/NotC
227  posH = 6;
228  posI = 7;
229  posC = 5;
230  break;
231  case 231: // In/Out, Corr/NotC, H/L
232  posH = 5;
233  posI = 7;
234  posC = 6;
235  break;
236  case 312: // Corr/NotC, H/L, In/Out
237  posH = 6;
238  posI = 5;
239  posC = 7;
240  break;
241  case 321: // Corr/NotC, In/Out, H/L
242  posH = 5;
243  posI = 6;
244  posC = 7;
245  break;
246  default:
247  std::cout << "DTTSCand::DTTSCand(): masking not correct: ";
248  std::cout << config()->TssMasking(itk);
249  std::cout << " All bits set to 1" << std::endl;
250 
251  // Masking:
252  bool enaH = config()->TsmHtrigEna(itk);
253  bool enaI = config()->TsmInOutEna(itk);
254  bool enaC = config()->TsmCorrEna(itk);
255  if (isCarry()) {
256  // Special setting for carry
257  enaH = config()->TsmHtrigEnaCarry();
258  enaI = config()->TsmInOutEnaCarry();
259  enaC = config()->TsmCorrEnaCarry();
260  }
261  // Bits set to 0 give higher priority:
262  if (isHtrig() && enaH && posH > 0)
263  _dataword.unset(posH);
264  if (isInner() && enaI && posI > 0)
265  _dataword.unset(posI);
266  if (isCorr() && enaC && posC > 0)
267  _dataword.unset(posC);
268  }
269  }
270 }
271 void DTTSCand::print() const {
272  std::cout << " First=" << isFirst();
273  std::cout << " HTRIG=" << isHtrig();
274  std::cout << " Inner=" << isInner();
275  std::cout << " Corr=" << isCorr();
276  std::cout << " Kpv=" << tracoTr()->pvK();
277  std::cout << " dataword=";
278  _dataword.print();
279  std::cout << std::endl;
280 }
int _isCarry
Definition: DTTSCand.h:175
bool TsmInOutEna(int i) const
Enable Inner SL checking in TSM for sort1/2.
Definition: DTConfigTSPhi.h:96
void setBitsTss()
Set the quality bits for DTTSS analysis.
Definition: DTTSCand.cc:80
bool TssInOutEnaCarry() const
Enable Inner SL checking in TSS for carry.
Definition: DTConfigTSPhi.h:78
bool TsmHtrigEna(int i) const
Enable Htrig checking in TSM for sort1/2.
Definition: DTConfigTSPhi.h:90
int isHtrig() const
Return HTRIG/LTRIG bit.
Definition: DTTSCand.h:103
int _tcPos
Definition: DTTSCand.h:173
~DTTSCand()
Destructor.
Definition: DTTSCand.cc:57
void clearBitsBkmod()
Clear (set to 1) all the bits (back-up mode)
Definition: DTTSCand.h:76
int TsmMasking(int i) const
Order of quality bits in TSM for sort1/2.
Definition: DTConfigTSPhi.h:87
int TssMasking(int i) const
Order of quality bits in TSS for sort1/2.
Definition: DTConfigTSPhi.h:66
void clear()
Clear the trigger.
Definition: DTTSCand.cc:73
const DTTracoTrigData * _tctrig
Definition: DTTSCand.h:168
int isFirst() const
Return the first/second track bit.
Definition: DTTSCand.h:100
void one()
Definition: BitArray.h:223
const DTConfigTSPhi * config() const
Configuration set.
Definition: DTTSCand.h:82
bool TssCorrEnaCarry() const
Enable Correlation checking in TSS for carry.
Definition: DTConfigTSPhi.h:84
DTTSS * _tss
Definition: DTTSCand.h:167
int pvK() const
Return the preview K.
DTTSCand & operator=(const DTTSCand &tscand)
Assignment operator.
Definition: DTTSCand.cc:63
bool TsmHtrigEnaCarry() const
Enable Htrig checking in TSM for carry.
Definition: DTConfigTSPhi.h:93
void setBitsTsm()
Set the quality bits for DTTSM analysis.
Definition: DTTSCand.cc:194
int isCarry() const
Return the carry bit.
Definition: DTTSCand.h:113
void print() const
Print the trigger.
Definition: DTTSCand.cc:271
void unset(const int i)
Definition: BitArray.h:231
bool TssHtrigEnaCarry() const
Enable Htrig checking in TSS for carry.
Definition: DTConfigTSPhi.h:72
DTTSCand()
Constructor.
Definition: DTTSCand.cc:52
const DTTracoTrigData * tracoTr() const
Return associated TRACO trigger.
Definition: DTTSCand.h:85
int element(const int pos) const
Definition: BitArray.h:210
Definition: DTTSS.h:36
bool TsmCorrEnaCarry() const
Enable Correlation checking in TSM for carry.
void clearBits()
Clear (set to 1) the quality bits (but first/second track bit)
Definition: DTTSCand.h:73
bool TsmCorrEna(int i) const
Enable Correlation checking in TSM for sort1/2.
int isInner() const
Return Inner/Outer bit.
Definition: DTTSCand.h:107
void assign(const int p, const int n, const int val)
Definition: BitArray.h:239
bool TssInOutEna(int i) const
Enable Inner SL checking in TSS for sort1/2.
Definition: DTConfigTSPhi.h:75
int qdec() const
Return the trigger code in new format.
bool TsmInOutEnaCarry() const
Enable Inner SL checking in TSM for carry.
Definition: DTConfigTSPhi.h:99
BitArray< 15 > _dataword
Definition: DTTSCand.h:169
std::ostream & print(std::ostream &o=std::cout) const
Definition: BitArray.h:345
bool TssCorrEna(int i) const
Enable Correlation checking in TSS for sort1/2.
Definition: DTConfigTSPhi.h:81
void setBitsBkmod()
Set the bits for TSM back-up mode.
Definition: DTTSCand.cc:154
int isCorr() const
Return correlation bit.
Definition: DTTSCand.h:110
bool TssHtrigEna(int i) const
Enable Htrig checking in TSS for sort1/2.
Definition: DTConfigTSPhi.h:69