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