CMS 3D CMS Logo

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