CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DEutils.h
Go to the documentation of this file.
1 #ifndef DEUTILS_H
2 #define DEUTILS_H
3 
4 /*\class template DEutils
5  *\description data|emulation auxiliary template
6  collection operations struct
7  *\author Nuno Leonardo (CERN)
8  *\date 07.04
9  */
10 
11 #include <iomanip>
12 
15 
16 template <typename T>
17 struct DEutils {
18  typedef typename T::size_type col_sz;
19  typedef typename T::const_iterator col_cit;
20  typedef typename T::iterator col_it;
22  typedef typename de_trait::cand_type cand_type;
23  typedef typename de_trait::coll_type coll_type;
24 
25 public:
26  DEutils() {
27  if (de_type() > 51)
28  edm::LogError("L1ComparatorDeutilsCollType") //throw cms::Exception("ERROR")
29  << "DEutils::DEutils() :: "
30  << "specialization is still missing for collection of type:" << de_type() << std::endl;
31  }
32  ~DEutils() {}
33 
34  inline int de_type() const { return de_trait::de_type(); }
35  bool de_equal(const cand_type&, const cand_type&);
36  bool de_equal_loc(const cand_type&, const cand_type&);
37  bool de_nequal(const cand_type&, const cand_type&);
38  bool de_nequal_loc(const cand_type&, const cand_type&);
40  //col_it de_find_loc ( col_it, col_it, const cand_type&);
41 
42  std::string print(col_cit) const;
43  bool is_empty(col_cit) const;
44  std::string GetName(int i = 0) const;
45 
46  L1DataEmulDigi DEDigi(col_cit itd, col_cit itm, int ctype);
47 };
48 
50 
51 template <typename T>
54  return L1DataEmulDigi();
55 }
56 
57 template <>
59  int cid = de_type();
60  int errt = aflag;
61  //fill data if flagged, otherwise emulator
62  double x1 = (aflag != 4) ? itd->id().iphi() : itm->id().iphi();
63  double x2 = (aflag != 4) ? itd->id().ieta() : itm->id().ieta();
64  L1DataEmulDigi digi(dedefs::ETP, cid, x1, x2, 0, errt);
65  unsigned int dwS = (aflag == 4) ? 0 : itd->sample(itd->sampleOfInterest()).raw();
66  unsigned int ewS = (aflag == 3) ? 0 : itm->sample(itm->sampleOfInterest()).raw();
67  //dw1 &= 0x01ff; ew1 &= 0x01ff; //9-bit: fg(8),energy(7:0)
68  unsigned int mask = 0x0eff; //fg bit temporary(!) mask
69  dwS &= mask;
70  ewS &= mask;
71  unsigned int dwI = (aflag == 4) ? 0 : itd->id().rawId();
72  unsigned int ewI = (aflag == 3) ? 0 : itm->id().rawId();
73  //dw2 &= 0xfe00ffff; ew2 &= 0xfe00ffff; //32-bit, reset unused (24:16)
74  //merge id and sample words
75  unsigned int dw = (dwI & 0xfe00ffff) | ((dwS & 0x000001ff) << 16);
76  unsigned int ew = (ewI & 0xfe00ffff) | ((ewS & 0x000001ff) << 16);
77  digi.setData(dw, ew);
78  int de = (aflag == 4) ? 0 : itd->compressedEt();
79  int ee = (aflag == 3) ? 0 : itm->compressedEt();
80  digi.setRank((float)de, (float)ee);
81  L1MonitorDigi dedata(dedefs::ETP, cid, itd->id().iphi(), itd->id().ieta(), 0, itd->compressedEt(), itd->id().rawId());
82  L1MonitorDigi deemul(dedefs::ETP, cid, itm->id().iphi(), itm->id().ieta(), 0, itm->compressedEt(), itm->id().rawId());
83  digi.setDEpair(dedata, deemul);
84  return digi;
85 }
86 
87 template <>
89  int cid = de_type();
90  int errt = aflag;
91  double x1 = (aflag != 4) ? itd->id().iphi() : itm->id().iphi();
92  double x2 = (aflag != 4) ? itd->id().ieta() : itm->id().ieta();
93  L1DataEmulDigi digi(dedefs::HTP, cid, x1, x2, 0, errt);
94  unsigned int dw = (aflag == 4) ? 0 : itd->t0().raw();
95  unsigned int ew = (aflag == 3) ? 0 : itm->t0().raw();
96  //16-bit; bits 10:9 not set(?);
97  // bits 15:11 not accessible in emulator (slb/channel ids)
98  unsigned int mask = 0x01ff;
99  dw &= mask;
100  ew &= mask;
101  digi.setData(dw, ew);
102  int de = (aflag == 4) ? 0 : itd->SOI_compressedEt();
103  int ee = (aflag == 3) ? 0 : itm->SOI_compressedEt();
104  digi.setRank((float)de, (float)ee);
105  return digi;
106 }
107 
108 template <>
110  int cid = de_type();
111  int errt = aflag;
112  double x1, x2, x3(0.);
113  // global index ieta (0-21), iphi (0-17), card (0-6)
114  x1 = (aflag != 4) ? itd->regionId().iphi() : itm->regionId().iphi();
115  x2 = (aflag != 4) ? itd->regionId().ieta() : itm->regionId().ieta();
116  x3 = (aflag != 4) ? itd->regionId().rctCard() : itm->regionId().rctCard();
117  //alternative coordinates: rctCrate(), rctCard(), index()
118  L1DataEmulDigi digi(dedefs::RCT, cid, x1, x2, x3, errt);
119  unsigned int dw = itd->raw();
120  unsigned int ew = itm->raw();
121  dw &= 0x3ff;
122  dw += (((itd->rctCrate()) & 0x1f) << 10);
123  dw += (((itd->isolated() ? 1 : 0) & 0x1) << 15);
124  dw += (((itd->index()) & 0x3) << 16);
125  ew &= 0x3ff;
126  ew += (((itm->rctCrate()) & 0x1f) << 10);
127  ew += (((itm->isolated() ? 1 : 0) & 0x1) << 15);
128  ew += (((itm->index()) & 0x3) << 16);
129  dw = (aflag == 4) ? 0 : dw;
130  ew = (aflag == 3) ? 0 : ew;
134  digi.setData(dw, ew);
135  int de = (aflag == 4) ? 0 : itd->rank();
136  int ee = (aflag == 3) ? 0 : itm->rank();
137  digi.setRank((float)de, (float)ee);
138  return digi;
139 }
140 
141 template <>
143  int cid = de_type();
144  int errt = aflag;
145  double x1, x2, x3(0.);
146  x1 = (aflag != 4) ? itd->id().iphi() : itm->id().iphi();
147  x2 = (aflag != 4) ? itd->id().ieta() : itm->id().ieta();
148  x3 = (aflag != 4) ? itd->id().rctCard() : itm->id().rctCard();
149  L1DataEmulDigi digi(dedefs::RCT, cid, x1, x2, x3, errt);
150  unsigned int dw = itd->raw();
151  unsigned int ew = itm->raw();
152  unsigned int mask = 0x3fff;
153  //mask (temporary) mip(12), quiet (13)
154  mask = 0x0fff;
155  dw &= mask;
156  dw += (((itd->id().ieta()) & 0x1f) << 14);
157  dw += (((itd->id().iphi()) & 0x1f) << 19);
158  ew &= mask;
159  ew += (((itm->id().ieta()) & 0x1f) << 14);
160  ew += (((itm->id().iphi()) & 0x1f) << 19);
161  dw = (aflag == 4) ? 0 : dw;
162  ew = (aflag == 3) ? 0 : ew;
164  digi.setData(dw, ew);
165  int de = (aflag == 4) ? 0 : itd->et();
166  int ee = (aflag == 3) ? 0 : itm->et();
167  digi.setRank((float)de, (float)ee);
168  return digi;
169 }
170 
171 template <>
173  int cid = de_type();
174  int errt = aflag;
175  //phi: 0..17; eta: 0..21
176  // bring it to global coordinates
177  double x1 = (aflag != 4) ? itd->regionId().iphi() : itm->regionId().iphi();
178  double x2 = (aflag != 4) ? itd->regionId().ieta() : itm->regionId().ieta();
179  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
180  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
181  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
182  dw &= 0x7fff;
183  ew &= 0x7fff; //15-bit
184  digi.setData(dw, ew);
185  int de = (aflag == 4) ? 0 : itd->rank();
186  int ee = (aflag == 3) ? 0 : itm->rank();
187  digi.setRank((float)de, (float)ee);
188  return digi;
189 }
190 
191 template <>
193  int cid = de_type();
194  int errt = aflag;
195  //phi: 0..17; eta: -6..-0,+0..+6; eta sign:1(z-),0(z+)
196  // bring it to global coordinates 0..21 below
197  double x1 = (aflag != 4) ? itd->phiIndex() : itm->phiIndex();
198  unsigned deta(0), eeta(0);
199  if (!itd->isForward())
200  deta = (itd->etaSign() == 1 ? 10 - (itd->etaIndex() & 0x7) : (itd->etaIndex() & 0x7) + 11);
201  else
202  deta = (itd->etaSign() == 1 ? 3 - (itd->etaIndex() & 0x7) : (itd->etaIndex() & 0x7) + 18);
203  if (!itm->isForward())
204  eeta = (itm->etaSign() == 1 ? 10 - (itm->etaIndex() & 0x7) : (itm->etaIndex() & 0x7) + 11);
205  else
206  eeta = (itm->etaSign() == 1 ? 3 - (itm->etaIndex() & 0x7) : (itm->etaIndex() & 0x7) + 18);
207  double x2 = (aflag != 4) ? deta : eeta;
208  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
209  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
210  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
211  dw &= 0x7fff;
212  ew &= 0x7fff; //15-bit
213  digi.setData(dw, ew);
214  int de = (aflag == 4) ? 0 : itd->rank();
215  int ee = (aflag == 3) ? 0 : itm->rank();
216  digi.setRank((float)de, (float)ee);
217  return digi;
218 }
219 
220 template <>
222  int cid = de_type();
223  int errt = aflag;
224  double x1 = 0;
225  double x2 = 0; //no 'location' associated with candidates...
226  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
227  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
228  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
229  dw &= 0x1fff;
230  ew &= 0x1fff; //13-bit
231  digi.setData(dw, ew);
232  int de = (aflag == 4) ? 0 : itd->et();
233  int ee = (aflag == 3) ? 0 : itm->et();
234  digi.setRank((float)de, (float)ee);
235  return digi;
236 }
237 template <>
239  int cid = de_type();
240  int errt = aflag;
241  double x1 = (aflag != 4) ? itd->phi() : itm->phi();
242  double x2 = 0; //no 'eta' associated with candidates...
243  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
244  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
245  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
246  dw &= 0x8f1fff;
247  ew &= 0x8f1fff; //22-bit (bits 13,14,15 not set)
248  digi.setData(dw, ew);
249  int de = (aflag == 4) ? 0 : itd->et();
250  int ee = (aflag == 3) ? 0 : itm->et();
251  digi.setRank((float)de, (float)ee);
252  return digi;
253 }
254 
255 template <>
257  int cid = de_type();
258  int errt = aflag;
259  double x1 = 0;
260  double x2 = 0; //no 'location' associated with candidates...
261  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
262  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
263  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
264  dw &= 0x1fff;
265  ew &= 0x1fff; //13-bit
266  digi.setData(dw, ew);
267  int de = (aflag == 4) ? 0 : itd->et();
268  int ee = (aflag == 3) ? 0 : itm->et();
269  digi.setRank((float)de, (float)ee);
270  return digi;
271 }
272 template <>
274  int cid = de_type();
275  int errt = aflag;
276  double x1 = 0;
277  double x2 = 0; //no 'location' associated with candidates...
278  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
279  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
280  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
281  digi.setData(dw, ew);
282  int de = 0;
283  int ee = 0; //no 'rank' associated with candidates...
284  digi.setRank((float)de, (float)ee);
285  return digi;
286 }
287 template <>
289  int cid = de_type();
290  int errt = aflag;
291  double x1 = 0;
292  double x2 = 0; //no 'location' associated with candidates...
293  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
294  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
295  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
296  digi.setData(dw, ew);
297  int de = 0;
298  int ee = 0; //no 'rank' associated with candidates...
299  digi.setRank((float)de, (float)ee);
300  return digi;
301 }
302 template <>
304  int cid = de_type();
305  int errt = aflag;
306  double x1 = (aflag != 4) ? itd->phi() : itm->phi();
307  double x2 = 0; //no 'eta' associated with candidates...
308  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
309  unsigned int dw = (aflag == 4) ? 0 : itd->raw();
310  unsigned int ew = (aflag == 3) ? 0 : itm->raw();
311  dw &= 0x8f1fff;
312  ew &= 0x8f1fff; //22-bit (bits 13,14,15 not set)
313  digi.setData(dw, ew);
314  int de = (aflag == 4) ? 0 : itd->et();
315  int ee = (aflag == 3) ? 0 : itm->et();
316  digi.setRank((float)de, (float)ee);
317  return digi;
318 }
319 
320 template <>
322  int cid = de_type();
323  int errt = aflag;
324  double x1 = 0;
325  double x2 = 0; //no 'location' associated with candidates...
326  L1DataEmulDigi digi(dedefs::GCT, cid, x1, x2, 0., errt);
327  unsigned int dw = (aflag == 4) ? 0 : itd->raw0(); //raw0, raw1...
328  unsigned int ew = (aflag == 3) ? 0 : itm->raw0(); //raw0, raw1...
329  digi.setData(dw, ew);
330  int de = 0;
331  int ee = 0; //no 'rank' associated with candidates...
332  digi.setRank((float)de, (float)ee);
333  return digi;
334 }
335 
336 template <>
338  int sid;
339  switch (itd->type_idx()) { // 0 DT, 1 bRPC, 2 CSC, 3 fRPC
340  case 0:
341  sid = dedefs::DTF;
342  break;
343  case 1:
344  sid = dedefs::RPC;
345  break;
346  case 2:
347  sid = dedefs::CTF;
348  break;
349  case 3:
350  sid = dedefs::RPC;
351  break;
352  default:
353  sid = -1;
354  }
355  int cid = de_type();
356  int errt = aflag;
357  //double x1 = (aflag!=4) ? itd->phiValue() : itm->phiValue();
358  //double x2 = (aflag!=4) ? itd->etaValue() : itm->etaValue();
359  double x1 = (aflag != 4) ? itd->phi_packed() : itm->phi_packed();
360  double x2 = (aflag != 4) ? itd->eta_packed() : itm->eta_packed();
361  L1DataEmulDigi digi(sid, cid, x1, x2, 0, errt);
362  unsigned int dw = (aflag == 4) ? 0 : itd->getDataWord();
363  unsigned int ew = (aflag == 3) ? 0 : itm->getDataWord();
364  unsigned int mask = 0xffffffff; //32-bit
365  //RPC: mask bits 25-29 (including synch bits)
366  // emulator doesn't set these bits (permanent masking)
367  if (sid == dedefs::RPC)
368  mask &= 0xc1ffffff;
369  dw &= mask;
370  ew &= mask;
371  digi.setData(dw, ew);
372  int de = (aflag == 4) ? 0 : itd->pt_packed(); //ptValue();
373  int ee = (aflag == 3) ? 0 : itm->pt_packed(); //ptValue();
374  digi.setRank((float)de, (float)ee);
375  //note: phi,eta,pt 'values' not always set for all muon tf systems
376  //(under discussion) need universal mechanism for setting up physical units
377  if (false) //check print
378  std::cout << "L1DataEmulDigi DEutils<L1MuRegionalCandCollection>] dedigi info"
379  //<< " phivalue:" << itd->phiValue() << "," << itm->phiValue()
380  //<< " etavalue:" << itd->etaValue() << "," << itm->etaValue()
381  << " phipackd:" << itd->phi_packed() << "," << itm->phi_packed() << " etapackd:" << itd->eta_packed()
382  << "," << itm->eta_packed() << std::endl;
383  return digi;
384 }
385 
386 template <>
388  int cid = de_type();
389  int errt = aflag;
390  //double x1 = (aflag!=4) ? itd->phiValue() : itm->phiValue();
391  //double x2 = (aflag!=4) ? itd->etaValue() : itm->etaValue();
392  double x1 = (aflag != 4) ? itd->phiIndex() : itm->phiIndex();
393  double x2 = (aflag != 4) ? itd->etaIndex() : itm->etaIndex();
394  L1DataEmulDigi digi(dedefs::GMT, cid, x1, x2, 0, errt);
395  unsigned int dw = (aflag == 4) ? 0 : itd->getDataWord();
396  unsigned int ew = (aflag == 3) ? 0 : itm->getDataWord();
397  unsigned int mask = 0x3ffffff; //26-bit
398  //mask bits 22 (isolation), 23 (mip) [not permanent!]
399  mask &= (~(0x0c00000));
400  dw &= mask;
401  ew &= mask;
402  digi.setData(dw, ew);
403  int de = (aflag == 4) ? 0 : itd->ptIndex(); //ptValue();
404  int ee = (aflag == 3) ? 0 : itm->ptIndex(); //ptValue();
405  digi.setRank((float)de, (float)ee);
406  if (false) //check print
407  std::cout << "l1dataemuldigi l1mugmtcandcoll type:"
408  << cid
409  //<< " eta:" << itd->etaValue() << ", " << itm->etaValue()
410  //<< " phi:" << itd->phiValue() << ", " << itm->phiValue()
411  << std::hex << " word d:" << dw << "e:" << ew << std::dec << std::endl;
412  return digi;
413 }
414 
415 template <>
417  int cid = de_type();
418  int errt = aflag;
419  double x1 = (aflag != 4) ? itd->scNum() : itm->scNum();
420  double x2 = (aflag != 4) ? itd->whNum() : itm->whNum();
421  double x3 = (aflag != 4) ? itd->stNum() : itm->stNum();
422  L1DataEmulDigi digi(dedefs::DTP, cid, x1, x2, x3, errt);
423  //other coordinate methods phi(), phiB()
424  //note: no data word defined for candidate
425  int dr = (aflag == 4) ? 0 : itd->code();
426  int er = (aflag == 3) ? 0 : itm->code();
427  digi.setRank((float)dr, (float)er);
428  return digi;
429 }
430 
431 template <>
433  int cid = de_type();
434  int errt = aflag;
435  double x1 = (aflag != 4) ? itd->scNum() : itm->scNum();
436  double x2 = (aflag != 4) ? itd->whNum() : itm->whNum();
437  double x3 = (aflag != 4) ? itd->stNum() : itm->stNum();
438  L1DataEmulDigi digi(dedefs::DTP, cid, x1, x2, x3, errt);
439  //note: no data word defined for candidate
440  int dr(0), er(0);
441  for (int i = 0; i < 7; i++) {
442  if (itd->code(i) >= dr)
443  dr = itd->quality(i);
444  if (itm->code(i) >= er)
445  er = itm->quality(i);
446  }
447  //alternatives: code() = quality() + positions()
448  dr = (aflag == 4) ? 0 : dr;
449  er = (aflag == 3) ? 0 : er;
450  digi.setRank((float)dr, (float)er);
451  return digi;
452 }
453 
454 template <>
456  int cid = de_type();
457  int errt = aflag;
458  double x1 = (aflag != 4) ? itd->getStrip() : itm->getStrip();
459  double x2 = (aflag != 4) ? itd->getKeyWG() : itm->getKeyWG();
460  double x3 = (aflag != 4) ? itd->getTrknmb() : itm->getTrknmb();
461  //multiple subsystem ctp,ctf
462  L1DataEmulDigi digi(-1, cid, x1, x2, x3, errt);
463  int dq = (aflag == 4) ? 0 : itd->getQuality();
464  int eq = (aflag == 3) ? 0 : itm->getQuality();
465  digi.setRank((float)dq, (float)eq);
466  // Pack LCT digi members into 32-bit data words.
467  static const int kValidBitWidth = 1; // Reverse the order of the 1st
468  static const int kQualityBitWidth = 4; // frame to keep the valid bit
469  static const int kPatternBitWidth = 4; // first and quality second, as
470  static const int kWireGroupBitWidth = 7; // is done in ALCT and CLCT.
471  static const int kHalfstripBitWidth = 8;
472  static const int kBendBitWidth = 1;
473  static const int kBxBitWidth = 1;
474  // Use sync_err and bx0_local bits to store MPC link.
475  static const int kMPCLinkBitWidth = 2;
476  static const int kCSCIdBitWidth = 4;
477  // While packing, check that the right number of bits is retained.
478  unsigned shift = 0, dw = 0, ew = 0;
479  dw = itd->isValid() & ((1 << kValidBitWidth) - 1);
480  dw += (itd->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
481  dw += (itd->getPattern() & ((1 << kPatternBitWidth) - 1)) << (shift += kQualityBitWidth);
482  dw += (itd->getKeyWG() & ((1 << kWireGroupBitWidth) - 1)) << (shift += kPatternBitWidth);
483  dw += (itd->getStrip() & ((1 << kHalfstripBitWidth) - 1)) << (shift += kWireGroupBitWidth);
484  dw += (itd->getBend() & ((1 << kBendBitWidth) - 1)) << (shift += kHalfstripBitWidth);
485  dw += (itd->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kBendBitWidth);
486  dw += (itd->getMPCLink() & ((1 << kMPCLinkBitWidth) - 1)) << (shift += kBxBitWidth);
487  dw += (itd->getCSCID() & ((1 << kCSCIdBitWidth) - 1)) << (shift += kMPCLinkBitWidth);
488  shift = 0;
489  ew = itm->isValid() & ((1 << kValidBitWidth) - 1);
490  ew += (itm->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
491  ew += (itm->getPattern() & ((1 << kPatternBitWidth) - 1)) << (shift += kQualityBitWidth);
492  ew += (itm->getKeyWG() & ((1 << kWireGroupBitWidth) - 1)) << (shift += kPatternBitWidth);
493  ew += (itm->getStrip() & ((1 << kHalfstripBitWidth) - 1)) << (shift += kWireGroupBitWidth);
494  ew += (itm->getBend() & ((1 << kBendBitWidth) - 1)) << (shift += kHalfstripBitWidth);
495  ew += (itm->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kBendBitWidth);
496  ew += (itm->getMPCLink() & ((1 << kMPCLinkBitWidth) - 1)) << (shift += kBxBitWidth);
497  ew += (itm->getCSCID() & ((1 << kCSCIdBitWidth) - 1)) << (shift += kMPCLinkBitWidth);
498  digi.setData(dw, ew);
499  return digi;
500 }
501 
502 template <>
504  int cid = de_type();
505  int errt = aflag;
506  double x2 = (aflag != 4) ? itd->getKeyWG() : itm->getKeyWG();
507  double x3 = (aflag != 4) ? itd->getTrknmb() : itm->getTrknmb();
508  L1DataEmulDigi digi(dedefs::CTP, cid, 0, x2, x3, errt);
509  int dq = (aflag == 4) ? 0 : itd->getQuality();
510  int eq = (aflag == 3) ? 0 : itm->getQuality();
511  digi.setRank((float)dq, (float)eq);
512  // Pack anode digi members into 17-bit data words.
513  static const int kValidBitWidth = 1;
514  static const int kQualityBitWidth = 2;
515  static const int kAccelBitWidth = 1;
516  static const int kPatternBBitWidth = 1;
517  static const int kWireGroupBitWidth = 7;
518  static const int kBxBitWidth = 5;
519  // While packing, check that the right number of bits is retained.
520  unsigned shift = 0, dw = 0, ew = 0;
521  dw = itd->isValid() & ((1 << kValidBitWidth) - 1);
522  dw += (itd->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
523  dw += (itd->getAccelerator() & ((1 << kAccelBitWidth) - 1)) << (shift += kQualityBitWidth);
524  dw += (itd->getCollisionB() & ((1 << kPatternBBitWidth) - 1)) << (shift += kAccelBitWidth);
525  dw += (itd->getKeyWG() & ((1 << kWireGroupBitWidth) - 1)) << (shift += kPatternBBitWidth);
526  dw += (itd->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kWireGroupBitWidth);
527  shift = 0;
528  ew = itm->isValid() & ((1 << kValidBitWidth) - 1);
529  ew += (itm->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
530  ew += (itm->getAccelerator() & ((1 << kAccelBitWidth) - 1)) << (shift += kQualityBitWidth);
531  ew += (itm->getCollisionB() & ((1 << kPatternBBitWidth) - 1)) << (shift += kAccelBitWidth);
532  ew += (itm->getKeyWG() & ((1 << kWireGroupBitWidth) - 1)) << (shift += kPatternBBitWidth);
533  ew += (itm->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kWireGroupBitWidth);
534  digi.setData(dw, ew);
535  return digi;
536 }
537 template <>
539  int cid = de_type();
540  int errt = aflag;
541  double x1 = (aflag != 4) ? itd->getKeyStrip() : itm->getKeyStrip();
542  double x3 = (aflag != 4) ? itd->getTrknmb() : itm->getTrknmb();
543  L1DataEmulDigi digi(dedefs::CTP, cid, x1, 0, x3, errt);
544  int dq = (aflag == 4) ? 0 : itd->getQuality();
545  int eq = (aflag == 3) ? 0 : itm->getQuality();
546  digi.setRank((float)dq, (float)eq);
547  // Pack cathode digi members into 19-bit data words.
548  static const int kValidBitWidth = 1;
549  static const int kQualityBitWidth = 3;
550  static const int kPatternBitWidth = 4;
551  static const int kBendBitWidth = 1;
552  static const int kHalfstripBitWidth = 5;
553  static const int kCFEBBitWidth = 3;
554  static const int kBxBitWidth = 2;
555  // While packing, check that the right number of bits is retained.
556  unsigned shift = 0, dw = 0, ew = 0;
557  dw = itd->isValid() & ((1 << kValidBitWidth) - 1);
558  dw += (itd->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
559  dw += (itd->getPattern() & ((1 << kPatternBitWidth) - 1)) << (shift += kQualityBitWidth);
560  dw += (itd->getBend() & ((1 << kBendBitWidth) - 1)) << (shift += kPatternBitWidth);
561  dw += (itd->getStrip() & ((1 << kHalfstripBitWidth) - 1)) << (shift += kBendBitWidth);
562  dw += (itd->getCFEB() & ((1 << kCFEBBitWidth) - 1)) << (shift += kHalfstripBitWidth);
563  dw += (itd->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kCFEBBitWidth);
564  shift = 0;
565  ew = itm->isValid() & ((1 << kValidBitWidth) - 1);
566  ew += (itm->getQuality() & ((1 << kQualityBitWidth) - 1)) << (shift += kValidBitWidth);
567  ew += (itm->getPattern() & ((1 << kPatternBitWidth) - 1)) << (shift += kQualityBitWidth);
568  ew += (itm->getBend() & ((1 << kBendBitWidth) - 1)) << (shift += kPatternBitWidth);
569  ew += (itm->getStrip() & ((1 << kHalfstripBitWidth) - 1)) << (shift += kBendBitWidth);
570  ew += (itm->getCFEB() & ((1 << kCFEBBitWidth) - 1)) << (shift += kHalfstripBitWidth);
571  ew += (itm->getBX() & ((1 << kBxBitWidth) - 1)) << (shift += kCFEBBitWidth);
572  digi.setData(dw, ew);
573  return digi;
574 }
575 
576 template <>
578  int cid = de_type();
579  int errt = aflag;
580  double x1; //sector/slot
581  x1 = (aflag != 4) ? itd->slot() : itm->slot();
582  //sector-slot map to be in principle to be provided from event setup
583  //int de_cscstatus_slot2sector[22] =
584  // {0,0,0,0,0, 0,1,2,3,4, 5,6,0,0,0, 0,7,8,9,10, 11,12};
585  //x1 = (aflag!=4) ? slot2sector[itd->slot()] : slot2sector[itm->slot()];
586  L1DataEmulDigi digi(dedefs::CTF, cid, x1, 0, 0, errt);
587  //note: no data word and rank defined for candidate
588  return digi;
589 }
590 
592 
593 template <typename T>
595  for (; first != last; first++)
596  if (de_equal(*first, value))
597  break;
598  return first;
599 }
600 
601 /*
602 template <typename T> typename
603 DEutils<T>::col_it DEutils<T>::de_find_loc( col_it first, col_it last, const cand_type& value ) {
604  for ( ;first!=last; first++)
605  if ( de_equal_loc(*first,value) ) break;
606  return first;
607 }
608 */
609 
611 
612 template <typename T>
613 bool DEutils<T>::de_equal(const cand_type& lhs, const cand_type& rhs) {
614  //declare candidate matching by default
615  return true;
616 }
617 template <typename T>
618 bool DEutils<T>::de_nequal(const cand_type& lhs, const cand_type& rhs) {
619  return !de_equal(lhs, rhs);
620 }
621 
622 template <>
624  bool val = true;
625  unsigned int mask = 0x0fff; //keep only ttf[11:9], fg [8], Et [7:0]
626  mask &= 0x0eff; //fg bit temporary(!) mask
627  val &= ((lhs[lhs.sampleOfInterest()].raw() & mask) == (rhs[rhs.sampleOfInterest()].raw() & mask));
628  val &= (lhs.id().rawId() == rhs.id().rawId());
629  return val;
630 }
631 
632 template <>
634  bool val = true;
635  unsigned int mask = 0x01ff;
636  val &= ((lhs.t0().raw() & mask) == (rhs.t0().raw() & mask));
637  val &= (lhs.id().rawId() == rhs.id().rawId());
638  return val;
639 }
640 
641 template <>
642 inline bool DEutils<L1CaloEmCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
643  bool val = true;
644  val &= (lhs.raw() == rhs.raw());
645  val &= (lhs.rctCrate() == rhs.rctCrate());
646  val &= (lhs.isolated() == rhs.isolated());
647  val &= (lhs.index() == rhs.index());
648  //val &= (lhs.bx() == rhs.bx() );
649  return val;
650 }
651 
652 template <>
653 inline bool DEutils<L1CaloRegionCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
654  bool val = true;
655  val &= (lhs.et() == rhs.et());
656  val &= (lhs.rctCrate() == rhs.rctCrate());
657  val &= (lhs.rctRegionIndex() == rhs.rctRegionIndex());
658  val &= (lhs.id().isHf() == rhs.id().isHf());
659  if (!lhs.id().isHf()) {
660  val &= (lhs.overFlow() == rhs.overFlow());
661  val &= (lhs.tauVeto() == rhs.tauVeto());
662  //mask temporarily (!) mip and quiet bits
663  //val &= (lhs.mip() == rhs.mip() );
664  //val &= (lhs.quiet() == rhs.quiet() );
665  val &= (lhs.rctCard() == rhs.rctCard());
666  } else {
667  val &= (lhs.fineGrain() == rhs.fineGrain());
668  }
669  return val;
670 }
671 
672 template <>
673 inline bool DEutils<L1GctEmCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
674  return lhs == rhs;
675 }
676 
677 template <>
678 inline bool DEutils<L1GctJetCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
679  return lhs == rhs;
680 }
681 
682 template <>
683 inline bool DEutils<L1GctEtHadCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
684  return lhs == rhs;
685 }
686 template <>
687 inline bool DEutils<L1GctEtMissCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
688  return lhs == rhs;
689 }
690 template <>
691 inline bool DEutils<L1GctEtTotalCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
692  return lhs == rhs;
693 }
694 template <>
695 inline bool DEutils<L1GctHtMissCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
696  return lhs == rhs;
697 }
698 template <>
700  return lhs == rhs;
701 }
702 template <>
704  return lhs == rhs;
705 }
706 template <>
708  return lhs == rhs;
709 }
710 
711 template <>
713  bool val = true;
714  val &= (lhs.whNum() == rhs.whNum());
715  val &= (lhs.scNum() == rhs.scNum());
716  val &= (lhs.stNum() == rhs.stNum());
717  //val &= (lhs.phi() ==rhs.phi() );
718  //val &= (lhs.phiB() ==rhs.phiB() );
719  val &= (lhs.code() == rhs.code());
720  val &= (lhs.Ts2Tag() == rhs.Ts2Tag());
721  //val &= (lhs.BxCnt() ==rhs.BxCnt() );
722  //val &= (lhs.bxNum() ==rhs.bxNum() );
723  return val;
724 }
725 
726 template <>
728  bool val = true;
729  val &= (lhs.whNum() == rhs.whNum());
730  val &= (lhs.scNum() == rhs.scNum());
731  val &= (lhs.stNum() == rhs.stNum());
732  //for(int i=0; i<7; i++) {
733  // val &= (lhs.code(i) ==rhs.code(i) );
734  // val &= (lhs.position(i)==rhs.position(i));
735  // val &= (lhs.quality(i) ==rhs.quality(i) );
736  //}
737  //val &= (lhs.bxNum() ==rhs.bxNum() );
738  return val;
739 }
740 
741 template <>
743  bool val = true;
744  val &= (lhs.type_idx() == rhs.type_idx());
745  val &= (lhs.bx() == rhs.bx());
746  if (!val)
747  return val;
748  unsigned int dw = lhs.getDataWord();
749  unsigned int ew = rhs.getDataWord();
750  unsigned int mask = 0xffffffff; //32-bit
751  //RPC: mask bits 25-29 (including synch bits)
752  // emulator doesn't set these bits (permanent masking)
753  // 0 DT, 1 bRPC, 2 CSC, 3 fRPC
754  if (rhs.type_idx() == 1 || rhs.type_idx() == 3)
755  mask &= 0xc1ffffff;
756  dw &= mask;
757  ew &= mask;
758  val &= (dw == ew);
759  //val &= (lhs.getDataWord() == rhs.getDataWord() );
760  //check whether collections being compared refer to same system and bx!
761  return val;
762 }
763 
764 template <>
765 inline bool DEutils<L1MuGMTCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
766  //return (lhs.getDataWord() == rhs.getDataWord() );
767  //return lhs==rhs; //(dataword,bx..)
768  bool val = true;
769  unsigned int dw = rhs.getDataWord();
770  unsigned int ew = lhs.getDataWord();
771  unsigned int mask = 0x3ffffff; //26-bit
772  //mask bits 22 (isolation), 23 (mip) [not permanent!]
773  mask &= (~(0x0c00000));
774  dw &= mask;
775  ew &= mask;
776  val &= (dw == ew);
777  return val;
778 }
779 
780 template <>
782  // Exclude track number from comparison since it is only meaningful for
783  // LCTs upstream of the MPC but not downstream (the latter ones are
784  // unpacked by the CSC TF unpacker).
785  bool val = true;
786  val &= (lhs.isValid() == rhs.isValid());
787  val &= (lhs.getQuality() == rhs.getQuality());
788  val &= (lhs.getKeyWG() == rhs.getKeyWG());
789  val &= (lhs.getStrip() == rhs.getStrip());
790  val &= (lhs.getPattern() == rhs.getPattern());
791  val &= (lhs.getBend() == rhs.getBend());
792  val &= (lhs.getBX() == rhs.getBX());
793  val &= (lhs.getMPCLink() == rhs.getMPCLink());
794  val &= (lhs.getCSCID() == rhs.getCSCID());
795  return val;
796  //return lhs==rhs;
797 }
798 template <>
799 inline bool DEutils<CSCALCTDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
800  return lhs == rhs;
801 }
802 template <>
803 inline bool DEutils<CSCCLCTDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
804  return lhs == rhs;
805 }
806 template <>
808  bool val = true;
809  val &= (lhs.slot() == rhs.slot());
810  val &= (lhs.BXN() == rhs.BXN());
811  val &= (lhs.FMM() == rhs.FMM());
812  val &= (lhs.SEs() == rhs.SEs());
813  val &= (lhs.SMs() == rhs.SMs());
814  val &= (lhs.BXs() == rhs.BXs());
815  val &= (lhs.AFs() == rhs.AFs());
816  val &= (lhs.VPs() == rhs.VPs());
817  return val;
818 }
819 
821 
822 template <typename T>
823 bool DEutils<T>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
824  //declare candidate matching by default
825  return true;
826 }
827 template <typename T>
828 bool DEutils<T>::de_nequal_loc(const cand_type& lhs, const cand_type& rhs) {
829  return !de_equal_loc(lhs, rhs);
830 }
831 
832 template <>
834  bool val = true;
835  val &= (lhs.id().zside() == rhs.id().zside());
836  val &= (lhs.id().ietaAbs() == rhs.id().ietaAbs());
837  val &= (lhs.id().iphi() == rhs.id().iphi());
838  return val;
839 }
840 
841 template <>
843  bool val = true;
844  val &= (lhs.id().zside() == rhs.id().zside());
845  val &= (lhs.id().ietaAbs() == rhs.id().ietaAbs());
846  val &= (lhs.id().iphi() == rhs.id().iphi());
847  return val;
848 }
849 
850 template <>
851 inline bool DEutils<L1CaloEmCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
852  bool val = true;
853  val &= (lhs.rctCrate() == rhs.rctCrate());
854  val &= (lhs.rctCard() == rhs.rctCard());
855  val &= (lhs.rctRegion() == rhs.rctRegion());
856  return val;
857 }
858 
859 template <>
861  bool val = true;
862  val &= (lhs.rctCrate() == rhs.rctCrate());
863  val &= (lhs.id().isHf() == rhs.id().isHf());
864  if (!lhs.id().isHf())
865  val &= (lhs.rctCard() == rhs.rctCard());
866  val &= (lhs.rctRegionIndex() == rhs.rctRegionIndex());
867  return val;
868 }
869 
870 template <>
872  bool val = true;
873  val &= (lhs.etaIndex() == rhs.etaIndex());
874  val &= (lhs.phiIndex() == rhs.phiIndex());
875  return val;
876 }
877 template <>
879  bool val = true;
880  val &= (lhs.etaIndex() == rhs.etaIndex());
881  val &= (lhs.phiIndex() == rhs.phiIndex());
882  return val;
883 }
884 
885 template <>
887  return true; // no associated location defined
888 }
889 template <>
891  bool val = true;
892  val &= (lhs.phi() == rhs.phi());
893  return val;
894 }
895 template <>
897  return true; // no associated location defined
898 }
899 template <>
901  bool val = true;
902  val &= (lhs.phi() == rhs.phi());
903  return val;
904 }
905 template <>
907  return true; // no associated location defined
908 }
909 template <>
911  return true; // no associated location defined
912 }
913 template <>
915  return true; // no associated location defined
916 }
917 
918 template <>
920  bool val = true;
921  val &= (lhs.phi_packed() == rhs.phi_packed());
922  val &= (lhs.eta_packed() == rhs.eta_packed());
923  //val &= (lhs.type_idx() == rhs.type_idx());
924  //val &= (lhs.bx() == rhs.bx());
925  return val;
926 }
927 
928 template <>
930  bool val = true;
931  val &= (lhs.phiIndex() == rhs.phiIndex());
932  val &= (lhs.etaIndex() == rhs.etaIndex());
933  return val;
934 }
935 
936 template <>
938  bool val = true;
939  val &= (lhs.whNum() == rhs.whNum());
940  val &= (lhs.scNum() == rhs.scNum());
941  val &= (lhs.stNum() == rhs.stNum());
942  //val &= (lhs.phi() ==rhs.phi() );
943  //val &= (lhs.phiB() ==rhs.phiB() );
944  //val &= (lhs.bxNum() ==rhs.bxNum() );
945  return val;
946 }
947 
948 template <>
950  bool val = true;
951  val &= (lhs.whNum() == rhs.whNum());
952  val &= (lhs.scNum() == rhs.scNum());
953  val &= (lhs.stNum() == rhs.stNum());
954  //val &= (lhs.bxNum() ==rhs.bxNum() );
955  return val;
956 }
957 
958 template <>
960  bool val = true;
961  val &= (lhs.getCSCID() == rhs.getCSCID());
962  val &= (lhs.getStrip() == rhs.getStrip());
963  val &= (lhs.getKeyWG() == rhs.getKeyWG());
964  return val;
965 }
966 
967 template <>
969  bool val = true;
970  val &= (lhs.getTrknmb() == rhs.getTrknmb());
971  val &= (lhs.getKeyWG() == rhs.getKeyWG());
972  return val;
973 }
974 template <>
976  bool val = true;
977  val &= (lhs.getTrknmb() == rhs.getTrknmb());
978  val &= (lhs.getKeyStrip() == rhs.getKeyStrip());
979  return val;
980 }
981 template <>
983  bool val = true;
984  val &= (lhs.slot() == rhs.slot());
985  return val;
986 }
987 
989 
990 template <typename T>
992  //declare candidate non-empty by default
993  return false;
994 }
995 
996 template <>
998  bool val = false;
999  unsigned int raw = it->sample(it->sampleOfInterest()).raw();
1000  unsigned int mask = 0x0fff;
1001  mask = 0x0eff; //fg bit temporary(!) mask
1002  raw &= mask;
1003  val |= (raw == 0);
1004  if (val)
1005  return val;
1006  unsigned int ttf = it->ttFlag();
1007  val |= ((ttf != 0x1) && (ttf != 0x3)); //compare only if ttf is 1 or 3
1008  return val;
1009  // return ( it->size()==0 || it->sample(it->sampleOfInterest()).raw()==0);
1010 }
1011 
1012 template <>
1014  unsigned int mask = 0x01ff;
1015  return (it->size() == 0 || ((it->t0().raw() & mask) == 0) || it->SOI_compressedEt() == 0);
1016 }
1017 
1018 template <>
1020  return ((it->rank()) == 0);
1021  //return it->empty();
1022 }
1023 
1024 template <>
1026  return ((it->et()) == 0);
1027  //return it->empty();
1028 }
1029 
1030 template <>
1032  return (it->empty());
1033 }
1034 
1035 template <>
1037  return (it->empty());
1038 }
1039 
1040 template <>
1042  return (it->empty());
1043 }
1044 template <>
1046  return (it->empty());
1047 }
1048 template <>
1050  return (it->empty());
1051 }
1052 template <>
1054  return (it->empty());
1055 }
1056 template <>
1058  return (it->empty());
1059 }
1060 template <>
1062  return (it->empty());
1063 }
1064 template <>
1066  return (it->empty());
1067 }
1068 
1069 template <>
1071  return (it->bxNum() != 0 || it->code() == 7);
1072  //return (it->qualityCode() == 7);
1073  //return false;
1074 }
1075 template <>
1077  return (it->whNum() == 0 && it->scNum() == 0 && it->stNum() == 0); //tmp!
1078  //return false;
1079 }
1080 
1081 template <>
1083  //note: following call used to give trouble sometimes
1084 
1085  //restrict further processing to bx==0 for RPC
1086  if (it->type_idx() == 1 || it->type_idx() == 3) //rpc
1087  if (it->bx() != 0)
1088  return true;
1089 
1090  return (it->empty());
1091  //virtual bool empty() const { return readDataField( PT_START, PT_LENGTH) == 0; }
1092  //return (it->getDataWord()==0);
1093  //return (it->pt_packed()==0);
1094 }
1095 
1096 template <>
1098  return (it->empty());
1099  //return (it->ptIndex()==0);
1100  //return (it->getDataWord()==0);
1101 }
1102 
1103 template <>
1105  return !(it->isValid());
1106 }
1107 template <>
1109  return !(it->isValid());
1110 }
1111 template <>
1113  return !(it->isValid());
1114 }
1115 
1116 template <>
1118  unsigned data = it->slot() | it->BXN() | it->FMM() | it->SEs() | it->SMs() | it->BXs() | it->AFs() | it->VPs();
1119  return data == 0;
1120 }
1121 
1123 
1124 template <typename T>
1126  std::stringstream ss;
1127  ss << "[DEutils<T>::print()] specialization still missing for collection!";
1128  //ss << *it; // default
1129  ss << std::endl;
1130  return ss.str();
1131 }
1132 
1133 template <>
1135  std::stringstream ss;
1136  ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->sample(it->sampleOfInterest()).raw()
1137  << std::setfill(' ') << std::dec << ", et:" << std::setw(3) << it->compressedEt() << ", fg:" << std::setw(1)
1138  << it->fineGrain() << ", ttf:" << std::setw(2) << it->ttFlag()
1139  << ", sdet:" << ((it->id().subDet() == EcalBarrel) ? ("Barrel") : ("Endcap"))
1140  << ", iz:" << ((it->id().zside() > 0) ? ("+") : ("-")) << ", ieta:" << std::setw(2) << it->id().ietaAbs()
1141  << ", iphi:" << std::setw(2)
1142  << it->id().iphi()
1143  //<< "\n\t: " << *it
1144  << std::endl;
1145  return ss.str();
1146 }
1147 
1148 template <>
1150  std::stringstream ss;
1151  ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->t0().raw() << std::setfill(' ') << std::dec
1152  << ", et:" << std::setw(3) << it->SOI_compressedEt() << ", fg:" << std::setw(1) << it->SOI_fineGrain()
1153  << ", sdet:" << it->id().subdet() << ", iz:" << ((it->id().zside() > 0) ? ("+") : ("-"))
1154  << ", ieta:" << std::setw(2) << it->id().ietaAbs() << ", iphi:" << std::setw(2) << it->id().iphi() << std::endl;
1155  //ss << *it << std::endl;
1156  return ss.str();
1157 }
1158 
1159 template <>
1161  std::stringstream ss;
1162  ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw() << ", rank=0x" << std::setw(2) << std::hex
1163  << it->rank() << std::setfill(' ') << std::dec << ", region:" << std::setw(1) << it->rctRegion()
1164  << ", card:" << std::setw(1) << it->rctCard() << ", crate:" << std::setw(2) << it->rctCrate()
1165  << ", ieta:" << std::setw(2) << it->regionId().ieta() //0..21
1166  << ", iphi:" << std::setw(2)
1167  << it->regionId().iphi() //0..17
1168  //<< ", eta:" << std::setw(2) << it->regionId().rctEta() //0..10
1169  //<< ", phi:" << std::setw(2) << it->regionId().rctPhi() //0..1
1170  << ", iso:" << std::setw(1) << it->isolated() << ", index:" << std::setw(1) << it->index() << ", bx:" << it->bx()
1171  << std::endl;
1172  //ss << *it;
1173  return ss.str();
1174 }
1175 
1176 template <>
1178  std::stringstream ss;
1179  ss << "L1CaloRegion:"
1180  << " et=" << it->et() << " o/f=" << it->overFlow() << " f/g=" << it->fineGrain() << " tau=" << it->tauVeto()
1181  << " rct(crate=" << it->rctCrate() << " card=" << it->rctCard() << " rgn=" << it->rctRegionIndex()
1182  << " eta=" << it->rctEta() << " phi=" << it->rctPhi() << ")\n\t\t"
1183  << "gct(eta=" << it->gctEta() << " phi=" << it->gctPhi() << ")" << std::hex << " cap_block=" << it->capBlock()
1184  << std::dec << " index=" << it->capIndex() << " bx=" << it->bx() << std::endl;
1185  //ss << *it; ///replace due to too long unformatted verbose
1186  //note: raw() data accessor missing in dataformats
1187  return ss.str();
1188 }
1189 
1190 template <>
1192  std::stringstream ss;
1193  //get rct index
1194  //int ieta = (it->etaIndex()&0x7); ieta = it->etaSign() ? 10-ieta:11+ieta;
1195  ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw() << ", rank=0x" << std::setw(2) << std::hex
1196  << it->rank() << std::setfill(' ') << std::dec << ", etaSign:" << it->etaSign()
1197  << ", eta:" << (it->etaIndex() & 0x7) //0..6
1198  << ", phi:" << std::setw(2) << it->phiIndex() //0..17
1199  << " (ieta:" << std::setw(2) << it->regionId().ieta() //0..21
1200  << ",iphi:" << std::setw(2) << it->regionId().iphi() << ")" //0..17
1201  << ", iso:" << it->isolated() << ", cap block:" << std::setw(3) << it->capBlock() << ", index:" << it->capIndex()
1202  << ", bx:" << it->bx() << std::endl;
1203  //<< " " << *it << std::dec << std::endl;
1204  return ss.str();
1205 }
1206 
1207 /*notes on rct/gct indices
1208  ieta: 0 .. 11 .. 21 -> rctEta: 10 .. 0 .. 10 ie: ieta<11?10-ieta:ieta-11
1209  gct from rct eta: rctEta&0x7 (7..0..7) | etaSign(==ieta<11)
1210  rct from gct eta: +-(0..7) -> 3..18 ie: sign?10-eta:eta+11
1211  rct iphi = gct phi
1212 */
1213 
1214 template <>
1216  std::stringstream ss;
1217  ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw() << " " << *it << std::dec << std::endl;
1218  return ss.str();
1219 }
1220 template <>
1222  std::stringstream ss;
1223  ss << *it;
1224  return ss.str();
1225 }
1226 template <>
1228  std::stringstream ss;
1229  ss << *it;
1230  return ss.str();
1231 }
1232 template <>
1234  std::stringstream ss;
1235  ss << *it;
1236  return ss.str();
1237 }
1238 template <>
1240  std::stringstream ss;
1241  ss << *it;
1242  return ss.str();
1243 }
1244 template <>
1246  std::stringstream ss;
1247  ss << *it;
1248  return ss.str();
1249 }
1250 template <>
1252  std::stringstream ss;
1253  ss << *it;
1254  return ss.str();
1255 }
1256 template <>
1258  std::stringstream ss;
1259  ss << *it;
1260  return ss.str();
1261 }
1262 
1263 template <>
1265  std::stringstream ss;
1266  ss << ""
1267  << " bxNum:" << it->bxNum() << " whNum:" << it->whNum() << " scNum:" << it->scNum() << " stNum:" << it->stNum()
1268  << " phi:" << it->phi() << " phiB:" << it->phiB() << " code:" << it->code() << " Ts2Tag:" << it->Ts2Tag()
1269  << " BxCnt:" << it->BxCnt() << std::endl;
1270  //nb: operator << not implemented in base class L1MuDTChambPhDigi
1271  return ss.str();
1272 }
1273 
1274 template <>
1276  std::stringstream ss;
1277  ss << ""
1278  << " bxNum:" << it->bxNum() << " whNum:" << it->whNum() << " scNum:" << it->scNum() << " stNum:" << it->stNum()
1279  << std::endl;
1280  //nb: operator << not implemented in base class L1MuDTChambThDigi
1281  return ss.str();
1282 }
1283 
1284 template <>
1286  std::stringstream ss;
1287  //const float noval = -10; //L1MuRegionalCand::m_invalidValue;
1288  ss << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right | std::ios::adjustfield);
1289  ss << std::hex << std::setfill('0') << " 0x" << std::setw(8) << it->getDataWord();
1290  //if(it->phiValue()==noval || it->etaValue()==noval || it->ptValue()==noval )
1291  ss << std::hex << std::setfill('0') << " pt:0x" << std::setw(2) << it->pt_packed() << " phi:0x" << std::setw(2)
1292  << it->phi_packed() << " eta:0x" << std::setw(2) << it->eta_packed();
1293  //else
1294  // ss << std::dec << std::setfill(' ')
1295  // << " pt:" << std::setw(5) << std::setprecision(1) << it->ptValue() <<"[GeV]"
1296  // << " phi:" << std::setw(5) << std::setprecision(3) << it->phiValue()<<"[rad]"
1297  // << " eta:" << std::setw(6) << std::setprecision(3) << it->etaValue();
1298  ss << std::dec << std::setfill(' ') << " qua:" << std::setw(1) << it->quality() << " cha:" << std::setw(2)
1299  << it->chargeValue() << " chav:" << std::setw(1) << it->chargeValid() << " fh:" << std::setw(1) << it->isFineHalo()
1300  << " bx:" << std::setw(4) << it->bx() << " [id:" << std::setw(1) << it->type_idx()
1301  << "]" // 0 DT, 1 bRPC, 2 CSC, 3 fRPC
1302  << std::endl;
1303  //ss << it->print()
1304  return ss.str();
1305 }
1306 
1307 template <>
1309  std::stringstream ss;
1310  ss << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right | std::ios::adjustfield);
1311  //const float noval = -10; //L1MuGMTCand::m_invalidValue;
1312  ss << std::hex << std::setfill('0') << " 0x" << std::setw(7) << it->getDataWord();
1313  //if(it->phiValue()==noval || it->etaValue()==noval || it->ptValue()==noval)
1314  ss << std::hex << std::setfill('0') << " pt:0x" << std::setw(2) << it->ptIndex() << " eta:0x" << std::setw(2)
1315  << it->etaIndex() << " phi:0x" << std::setw(3) << it->phiIndex();
1316  //else
1317  // ss << std::dec << std::setfill(' ')
1318  // << " pt:" << std::setw(5) << std::setprecision(1) << it->ptValue() <<"[GeV]"
1319  // << " phi:" << std::setw(5) << std::setprecision(3) << it->phiValue()<<"[rad]"
1320  // << " eta:" << std::setw(6) << std::setprecision(2) << it->etaValue();
1321  ss << std::dec << std::setfill(' ') << " cha:" << std::setw(2) << it->charge() << " qua:" << std::setw(3)
1322  << it->quality() << " iso:" << std::setw(1) << it->isol() << " mip:" << std::setw(1) << it->mip()
1323  << " bx:" << it->bx() << std::endl;
1324  //ss << it->print()
1325  return ss.str();
1326 }
1327 
1328 template <>
1330  std::stringstream ss;
1331  ss
1332  //<< " lct#:" << it->getTrknmb()
1333  //<< " val:" << it->isValid()
1334  //<< " qua:" << it->getQuality()
1335  //<< " strip:" << it->getStrip()
1336  //<< " bend:" << ((it->getBend() == 0) ? 'L' : 'R')
1337  //<< " patt:" << it->getPattern()
1338  //<<" key wire:" << it->getKeyWG()
1339  //<< " bx:" << it->getBX()
1340  //<< " mpc-link:" << it->getMPCLink()
1341  //<< " csc id:" << it->getCSCID()
1342  //<< std::endl;
1343  << *it;
1344  return ss.str();
1345 }
1346 
1347 template <>
1349  std::stringstream ss;
1350  ss << *it << std::endl;
1351  return ss.str();
1352 }
1353 
1354 template <>
1356  std::stringstream ss;
1357  ss << *it << std::endl;
1358  return ss.str();
1359 }
1360 
1361 template <>
1363  std::stringstream ss;
1364  ss << " slot:" << it->slot() << " bxn:" << it->BXN() << " fmm:" << it->FMM() << " ses:" << it->SEs()
1365  << " sms:" << it->SMs() << " bxs:" << it->BXs() << " afs:" << it->AFs() << " vps:" << it->VPs() << std::endl;
1366  return ss.str();
1367 }
1368 
1370 
1371 template <typename T>
1373  const int nlabel = 17;
1374  if (!(i < nlabel))
1375  return "un-defined";
1376  std::string str[nlabel] = {"un-registered"};
1377 
1378  switch (de_type()) {
1379  case dedefs::ECALtp:
1380  str[0] = "ECAL tp";
1381  str[1] = "EcalTrigPrimDigiCollection";
1382  str[2] = "EcalTriggerPrimitiveDigi";
1383  break;
1384  case dedefs::HCALtp:
1385  str[0] = "HCAL tp";
1386  str[1] = "HcalTrigPrimDigiCollection";
1387  str[2] = "HcalTriggerPrimitiveDigi";
1388  break;
1389  case dedefs::RCTem:
1390  str[0] = "RCT em";
1391  str[1] = "L1CaloEmCollection";
1392  str[2] = "L1CaloEmCand";
1393  break;
1394  case dedefs::RCTrgn:
1395  str[0] = "RCT region";
1396  str[1] = "L1CaloRegionCollection";
1397  str[2] = "L1CaloRegion";
1398  break;
1399  case dedefs::GCTisolaem:
1400  str[0] = "GCT em isolated";
1401  str[1] = "L1GctEmCandCollection";
1402  str[2] = "L1GctEmCand";
1403  break;
1404  case dedefs::GCTnoisoem:
1405  str[0] = "GCT em non-isolated";
1406  str[1] = "L1GctEmCandCollection";
1407  str[2] = "L1GctEmCand";
1408  break;
1409  case dedefs::GCTcenjets:
1410  str[0] = "GCT central jet";
1411  str[1] = "L1GctJetCandCollection";
1412  str[2] = "L1GctJetCand";
1413  break;
1414  case dedefs::GCTforjets:
1415  str[0] = "GCT forward jet";
1416  str[1] = "L1GctJetCandCollection";
1417  str[2] = "L1GctJetCand";
1418  break;
1419  case dedefs::GCTtaujets:
1420  str[0] = "GCT tau jet";
1421  str[1] = "L1GctJetCandCollection";
1422  str[2] = "L1GctJetCand";
1423  break;
1424  case dedefs::GCTisotaujets:
1425  str[0] = "Stage1Layer2 iso-tau jet";
1426  str[1] = "L1GctJetCandCollection";
1427  str[2] = "L1GctJetCand";
1428  break;
1429  case dedefs::GCTethad:
1430  str[0] = "GCT ht";
1431  str[1] = "L1GctEtHadCollection";
1432  str[2] = "L1GctEtHad";
1433  break;
1434  case dedefs::GCTetmiss:
1435  str[0] = "GCT et miss";
1436  str[1] = "L1GctEtMissCollection";
1437  str[2] = "L1GctEtMiss";
1438  break;
1439  case dedefs::GCTettot:
1440  str[0] = "GCT et total";
1441  str[1] = "L1GctEtTotalCollection";
1442  str[2] = "L1GctEtTotal";
1443  break;
1444  case dedefs::GCThtmiss:
1445  str[0] = "GCT ht miss";
1446  str[1] = "L1GctHtMissCollection";
1447  str[2] = "L1GctHtMiss";
1448  break;
1449  case dedefs::GCThfring:
1450  str[0] = "GCT hf ring";
1451  str[1] = "L1GctHFRingEtSumsCollection";
1452  str[2] = "L1GctHFRingEtSums";
1453  break;
1454  case dedefs::GCThfbit:
1455  str[0] = "GCT hf bit counts";
1456  str[1] = "L1GctHFBitCountsCollection";
1457  str[2] = "L1GctHFBitCounts";
1458  break;
1459 
1460  case dedefs::DTtpPh:
1461  str[0] = "DT tp phi";
1462  str[1] = "L1MuDTChambPhDigiCollection";
1463  str[2] = "L1MuDTChambPhDigi";
1464  break;
1465  case dedefs::DTtpTh:
1466  str[0] = "DT tp theta";
1467  str[1] = "L1MuDTChambThDigiCollection";
1468  str[2] = "L1MuDTChambThDigi";
1469  break;
1470  case dedefs::CSCtpa:
1471  str[0] = "CSC tpa";
1472  str[1] = "CSCALCTDigiCollection";
1473  str[2] = "CSCALCTDigi";
1474  break;
1475  case dedefs::CSCtpc:
1476  str[0] = "CSC tpc";
1477  str[1] = "CSCCLCTDigiCollection";
1478  str[2] = "CSCCLCTDigi";
1479  break;
1480  case dedefs::CSCtpl:
1481  str[0] = "CSC tp";
1482  str[1] = "CSCCorrelatedLCTDigiCollection";
1483  str[2] = "CSCCorrelatedLCTDigi";
1484  break;
1485  case dedefs::CSCsta:
1486  str[0] = "CSC tf status";
1487  str[1] = "L1CSCSPStatusDigiCollection_";
1488  str[2] = "L1CSCSPStatusDigi";
1489  break;
1490  case dedefs::MUrtf:
1491  str[0] = "Mu reg tf";
1492  str[1] = "L1MuRegionalCandCollection";
1493  str[2] = "L1MuRegionalCand";
1494  break;
1495  case dedefs::LTCi:
1496  str[0] = "LTC";
1497  str[1] = "LTCDigiCollection";
1498  str[2] = "LTCDigi";
1499  break;
1500  case dedefs::GMTcnd:
1501  str[0] = "GMT cand";
1502  str[1] = "L1MuGMTCandCollection";
1503  str[2] = "L1MuGMTCand";
1504  break;
1505  case dedefs::GMTrdt:
1506  str[0] = "GMT record";
1507  str[1] = "L1MuGMTReadoutRecordCollection";
1508  str[2] = "L1MuGMTReadoutRecord";
1509  break;
1510  case dedefs::GTdword:
1511  str[0] = "";
1512  str[1] = "";
1513  str[2] = "";
1514  break;
1515  //default:
1516  }
1517  return str[i];
1518 }
1519 
1521 
1522 template <typename T>
1523 struct de_rank : public DEutils<T> {
1525  typedef typename de_trait::cand_type cand_type;
1526  bool operator()(const cand_type& x, const cand_type& y) const {
1527  return false; //default
1528  }
1529 };
1530 
1531 template <>
1533  return x.compressedEt() > y.compressedEt();
1534 }
1535 template <>
1537  return x.SOI_compressedEt() > y.SOI_compressedEt();
1538 }
1539 
1540 template <>
1542  if (x.rank() != y.rank()) {
1543  return (x.rank() < y.rank());
1544  } else if (x.isolated() != y.isolated()) {
1545  return (x.isolated()) ? true : false;
1546  } else if (x.rctRegion() != y.rctRegion()) {
1547  return (x.rctRegion() < y.rctRegion());
1548  } else if (x.rctCrate() != y.rctCrate()) {
1549  return (x.rctCrate() < y.rctCrate());
1550  } else if (x.rctCard() != y.rctCard()) {
1551  return (x.rctCard() < y.rctCard());
1552  } else {
1553  return x.raw() < y.raw();
1554  }
1555 }
1556 
1557 template <>
1559  return x.et() < y.et();
1560 }
1561 
1562 template <>
1564  if (x.rank() != y.rank()) {
1565  return x.rank() < y.rank();
1566  } else {
1567  if (x.etaIndex() != y.etaIndex()) {
1568  return y.etaIndex() < x.etaIndex();
1569  } else {
1570  return x.phiIndex() < y.phiIndex();
1571  }
1572  }
1573 }
1574 template <>
1576  if (x.rank() != y.rank()) {
1577  return x.rank() < y.rank();
1578  } else {
1579  if (x.etaIndex() != y.etaIndex()) {
1580  return y.etaIndex() < x.etaIndex();
1581  } else {
1582  return x.phiIndex() < y.phiIndex();
1583  }
1584  }
1585 }
1586 //template <> inline bool de_rank<L1GctEtHadCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1587 //template <> inline bool de_rank<L1GctEtMissCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1588 //template <> inline bool de_rank<L1GctEtTotalCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1589 //template <> inline bool de_rank<L1GctHtMissCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1590 //template <> inline bool de_rank<L1GctHFRingEtSumsCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1591 //template <> inline bool de_rank<L1GctHFBitCountsCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1592 //template <> inline bool de_rank<L1GctJetCountsCollection>::operator()(const cand_type& x, const cand_type& y)const { }
1593 
1594 template <>
1596  if (x.whNum() != y.whNum()) {
1597  return x.whNum() < y.whNum();
1598  } else {
1599  if (x.scNum() != y.scNum()) {
1600  return y.scNum() < x.scNum();
1601  } else {
1602  return x.stNum() < y.stNum();
1603  }
1604  }
1605 }
1606 template <>
1608  if (x.whNum() != y.whNum()) {
1609  return x.whNum() < y.whNum();
1610  } else {
1611  if (x.scNum() != y.scNum()) {
1612  return y.scNum() < x.scNum();
1613  } else {
1614  return x.stNum() < y.stNum();
1615  }
1616  }
1617 }
1618 
1619 template <>
1621  if (x.phi_packed() != y.phi_packed()) {
1622  return x.phi_packed() < y.phi_packed();
1623  } else {
1624  if (x.eta_packed() != y.eta_packed()) {
1625  return y.eta_packed() < x.eta_packed();
1626  } else {
1627  return x.quality_packed() < y.quality_packed();
1628  }
1629  }
1630 }
1631 
1632 template <>
1634  if (x.bx() != y.bx()) {
1635  return x.bx() < y.bx();
1636  } else if (x.ptIndex() != y.ptIndex()) {
1637  return x.ptIndex() < y.ptIndex();
1638  } else {
1639  return x.quality() < y.quality();
1640  }
1641 }
1642 
1643 template <>
1645  if (x.getTrknmb() != y.getTrknmb()) {
1646  return x.getTrknmb() < y.getTrknmb();
1647  } else {
1648  if (x.getKeyWG() != y.getKeyWG()) {
1649  return y.getKeyWG() < x.getKeyWG();
1650  } else {
1651  return x.getQuality() < y.getQuality();
1652  }
1653  }
1654 }
1655 
1656 #endif
T::const_iterator col_cit
Definition: DEutils.h:19
de_trait::cand_type cand_type
Definition: DEutils.h:22
L1DataEmulDigi DEDigi(col_cit itd, col_cit itm, int ctype)
— form de-digi —
Definition: DEutils.h:52
void setRank(float d, float e)
DEtrait< T > de_trait
Definition: DEutils.h:21
— order candidates —
Definition: DEcompare.h:18
de_trait::coll_type coll_type
Definition: DEutils.h:23
void setData(unsigned int d, unsigned int e)
Log< level::Error, false > LogError
int de_type() const
Definition: DEutils.h:34
uint16_t size_type
bool de_nequal(const cand_type &, const cand_type &)
Definition: DEutils.h:618
bool de_nequal_loc(const cand_type &, const cand_type &)
Definition: DEutils.h:828
DEtrait< T > de_trait
Definition: DEutils.h:1524
bool is_empty(col_cit) const
— candidate emptiness definition —
Definition: DEutils.h:991
void setDEpair(const L1MonitorDigi &d, const L1MonitorDigi &e)
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
std::string print(col_cit) const
— print candidate —
Definition: DEutils.h:1125
~DEutils()
Definition: DEutils.h:32
T::size_type col_sz
Definition: DEutils.h:18
bool de_equal_loc(const cand_type &, const cand_type &)
— candidate location-match definition —
Definition: DEutils.h:823
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
col_it de_find(col_it, col_it, const cand_type &)
— find candidate —
Definition: DEutils.h:594
DEutils()
Definition: DEutils.h:26
static unsigned int const shift
de_trait::cand_type cand_type
Definition: DEutils.h:1525
std::string GetName(int i=0) const
— name candidate —
Definition: DEutils.h:1372
tuple cout
Definition: gather_cfg.py:144
bool operator()(const cand_type &x, const cand_type &y) const
Definition: DEutils.h:1526
tuple last
Definition: dqmdumpme.py:56
#define str(s)
T::iterator col_it
Definition: DEutils.h:20
bool de_equal(const cand_type &, const cand_type &)
— candidate match definition —
Definition: DEutils.h:613