00001 #ifndef DEUTILS_H
00002 #define DEUTILS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "L1Trigger/HardwareValidation/interface/DEtrait.h"
00012
00013 template <typename T>
00014 struct DEutils {
00015
00016 typedef typename T::size_type col_sz;
00017 typedef typename T::const_iterator col_cit;
00018 typedef typename T::iterator col_it;
00019 typedef DEtrait<T> de_trait;
00020 typedef typename de_trait::cand_type cand_type;
00021 typedef typename de_trait::coll_type coll_type;
00022
00023 public:
00024
00025 DEutils() {
00026 if(de_type()>38)
00027 edm::LogError("L1ComparatorDeutilsCollType")
00028 << "DEutils::DEutils() :: "
00029 << "specialization is still missing for collection of type:"
00030 << de_type() << std::endl;
00031 }
00032 ~DEutils(){}
00033
00034 inline int de_type() const {return de_trait::de_type();}
00035 bool de_equal (const cand_type&, const cand_type&);
00036 bool de_equal_loc (const cand_type&, const cand_type&);
00037 bool de_nequal (const cand_type&, const cand_type&);
00038 bool de_nequal_loc(const cand_type&, const cand_type&);
00039 col_it de_find ( col_it, col_it, const cand_type&);
00040
00041
00042 std::string print(col_cit) const;
00043 bool is_empty(col_cit) const;
00044 std::string GetName(int i = 0) const;
00045
00046 L1DataEmulDigi DEDigi(col_cit itd, col_cit itm, int ctype);
00047
00048 };
00049
00050
00052
00053 template <typename T>
00054 L1DataEmulDigi DEutils<T>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00056 return L1DataEmulDigi();
00057 }
00058
00059 template<> inline L1DataEmulDigi
00060 DEutils<EcalTrigPrimDigiCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00061 int cid = de_type();
00062 int errt = aflag;
00063
00064 double x1 = (aflag!=4) ? itd->id().iphi() : itm->id().iphi();
00065 double x2 = (aflag!=4) ? itd->id().ieta() : itm->id().ieta();
00066 L1DataEmulDigi digi(dedefs::ETP,cid, x1,x2,0, errt);
00067 unsigned int dwS = (aflag==4)?0:itd->sample(itd->sampleOfInterest()).raw();
00068 unsigned int ewS = (aflag==3)?0:itm->sample(itm->sampleOfInterest()).raw();
00069
00070 unsigned int mask = 0x0eff;
00071 dwS &= mask; ewS &= mask;
00072 unsigned int dwI = (aflag==4)?0:itd->id().rawId();
00073 unsigned int ewI = (aflag==3)?0:itm->id().rawId();
00074
00075
00076 unsigned int dw = (dwI & 0xfe00ffff ) | ( (dwS & 0x000001ff)<<16 );
00077 unsigned int ew = (ewI & 0xfe00ffff ) | ( (ewS & 0x000001ff)<<16 );
00078 digi.setData(dw,ew);
00079 int de = (aflag==4)?0:itd->compressedEt() ;
00080 int ee = (aflag==3)?0:itm->compressedEt() ;
00081 digi.setRank((float)de,(float)ee);
00082 L1MonitorDigi dedata(dedefs::ETP,cid, itd->id().iphi(),itd->id().ieta(),0,
00083 itd->compressedEt(),itd->id().rawId());
00084 L1MonitorDigi deemul(dedefs::ETP,cid, itm->id().iphi(),itm->id().ieta(),0,
00085 itm->compressedEt(),itm->id().rawId());
00086 digi.setDEpair(dedata,deemul);
00087 return digi;
00088 }
00089
00090 template<> inline L1DataEmulDigi
00091 DEutils<HcalTrigPrimDigiCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00092 int cid = de_type();
00093 int errt = aflag;
00094 double x1 = (aflag!=4) ? itd->id().iphi() : itm->id().iphi();
00095 double x2 = (aflag!=4) ? itd->id().ieta() : itm->id().ieta();
00096 L1DataEmulDigi digi(dedefs::HTP,cid, x1,x2,0, errt);
00097 unsigned int dw = (aflag==4)?0:itd->t0().raw();
00098 unsigned int ew = (aflag==3)?0:itm->t0().raw();
00099
00100
00101 unsigned int mask = 0x01ff;
00102 dw &= mask; ew &= mask;
00103 digi.setData(dw,ew);
00104 int de = (aflag==4)?0:itd->SOI_compressedEt();
00105 int ee = (aflag==3)?0:itm->SOI_compressedEt();
00106 digi.setRank((float)de,(float)ee);
00107 return digi;
00108 }
00109
00110 template<> inline L1DataEmulDigi
00111 DEutils<L1CaloEmCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00112 int cid = de_type();
00113 int errt = aflag;
00114 double x1, x2, x3(0.);
00115
00116 x1 = (aflag!=4) ? itd->regionId().iphi() : itm->regionId().iphi();
00117 x2 = (aflag!=4) ? itd->regionId().ieta() : itm->regionId().ieta();
00118 x3 = (aflag!=4) ? itd->regionId().rctCard() : itm->regionId().rctCard();
00119
00120 L1DataEmulDigi digi(dedefs::RCT,cid, x1,x2,x3, errt);
00121 unsigned int dw = itd->raw();
00122 unsigned int ew = itm->raw();
00123 dw &= 0x3ff;
00124 dw += (((itd->rctCrate())&0x1f)<<10);
00125 dw += (((itd->isolated()?1:0)&0x1)<<15);
00126 dw += (((itd->index())&0x3)<<16);
00127 ew &= 0x3ff;
00128 ew += (((itm->rctCrate())&0x1f)<<10);
00129 ew += (((itm->isolated()?1:0)&0x1)<<15);
00130 ew += (((itm->index())&0x3)<<16);
00131 dw = (aflag==4)?0:dw;
00132 ew = (aflag==3)?0:ew;
00136 digi.setData(dw,ew);
00137 int de = (aflag==4)?0:itd->rank();
00138 int ee = (aflag==3)?0:itm->rank();
00139 digi.setRank((float)de,(float)ee);
00140 return digi;
00141 }
00142
00143 template<> inline L1DataEmulDigi
00144 DEutils<L1CaloRegionCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00145 int cid = de_type();
00146 int errt = aflag;
00147 double x1, x2, x3(0.);
00148 x1 = (aflag!=4) ? itd->id().iphi() : itm->id().iphi();
00149 x2 = (aflag!=4) ? itd->id().ieta() : itm->id().ieta();
00150 x3 = (aflag!=4) ? itd->id().rctCard() : itm->id().rctCard();
00151 L1DataEmulDigi digi(dedefs::RCT,cid, x1,x2,x3, errt);
00152 unsigned int dw = itd->raw();
00153 unsigned int ew = itm->raw();
00154 unsigned int mask = 0x3fff;
00155
00156 mask = 0x0fff;
00157 dw &= mask;
00158 dw += (((itd->id().ieta())&0x1f)<<14);
00159 dw += (((itd->id().iphi())&0x1f)<<19);
00160 ew &= mask;
00161 ew += (((itm->id().ieta())&0x1f)<<14);
00162 ew += (((itm->id().iphi())&0x1f)<<19);
00163 dw = (aflag==4)?0:dw;
00164 ew = (aflag==3)?0:ew;
00166 digi.setData(dw,ew);
00167 int de = (aflag==4)?0:itd->et();
00168 int ee = (aflag==3)?0:itm->et();
00169 digi.setRank((float)de,(float)ee);
00170 return digi;
00171 }
00172
00173 template<> inline L1DataEmulDigi
00174 DEutils<L1GctEmCandCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00175 int cid = de_type();
00176 int errt = aflag;
00177
00178
00179 double x1 = (aflag!=4) ? itd->regionId().iphi() : itm->regionId().iphi();
00180 double x2 = (aflag!=4) ? itd->regionId().ieta() : itm->regionId().ieta();
00181 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00182 unsigned int dw = (aflag==4)?0:itd->raw();
00183 unsigned int ew = (aflag==3)?0:itm->raw();
00184 dw &= 0x7fff; ew &= 0x7fff;
00185 digi.setData(dw,ew);
00186 int de = (aflag==4)?0:itd->rank();
00187 int ee = (aflag==3)?0:itm->rank();
00188 digi.setRank((float)de,(float)ee);
00189 return digi;
00190 }
00191
00192 template<> inline L1DataEmulDigi
00193 DEutils<L1GctJetCandCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00194 int cid = de_type();
00195 int errt = aflag;
00196
00197
00198 double x1 = (aflag!=4) ? itd->phiIndex() : itm->phiIndex();
00199 unsigned deta(0), eeta(0);
00200 if (!itd->isForward()) deta=(itd->etaSign()==1?10-(itd->etaIndex()&0x7):(itd->etaIndex()&0x7)+11);
00201 else deta=(itd->etaSign()==1? 3-(itd->etaIndex()&0x7):(itd->etaIndex()&0x7)+18 );
00202 if (!itm->isForward()) eeta=(itm->etaSign()==1?10-(itm->etaIndex()&0x7):(itm->etaIndex()&0x7)+11);
00203 else eeta=(itm->etaSign()==1? 3-(itm->etaIndex()&0x7):(itm->etaIndex()&0x7)+18 );
00204 double x2 = (aflag!=4) ? deta : eeta;
00205 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00206 unsigned int dw = (aflag==4)?0:itd->raw();
00207 unsigned int ew = (aflag==3)?0:itm->raw();
00208 dw &= 0x7fff; ew &= 0x7fff;
00209 digi.setData(dw,ew);
00210 int de = (aflag==4)?0:itd->rank();
00211 int ee = (aflag==3)?0:itm->rank();
00212 digi.setRank((float)de,(float)ee);
00213 return digi;
00214 }
00215
00216 template<> inline L1DataEmulDigi
00217 DEutils<L1GctEtHadCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00218 int cid = de_type();
00219 int errt = aflag;
00220 double x1 = 0; double x2 = 0;
00221 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00222 unsigned int dw = (aflag==4)?0:itd->raw();
00223 unsigned int ew = (aflag==3)?0:itm->raw();
00224 dw &= 0x1fff; ew &= 0x1fff;
00225 digi.setData(dw,ew);
00226 int de = (aflag==4)?0:itd->et();
00227 int ee = (aflag==3)?0:itm->et();
00228 digi.setRank((float)de,(float)ee);
00229 return digi;
00230 }
00231 template<> inline L1DataEmulDigi
00232 DEutils<L1GctEtMissCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00233 int cid = de_type();
00234 int errt = aflag;
00235 double x1 = (aflag!=4) ? itd->phi() : itm->phi();
00236 double x2 = 0;
00237 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00238 unsigned int dw = (aflag==4)?0:itd->raw();
00239 unsigned int ew = (aflag==3)?0:itm->raw();
00240 dw &= 0x8f1fff; ew &= 0x8f1fff;
00241 digi.setData(dw,ew);
00242 int de = (aflag==4)?0:itd->et();
00243 int ee = (aflag==3)?0:itm->et();
00244 digi.setRank((float)de,(float)ee);
00245 return digi;
00246 }
00247
00248 template<> inline L1DataEmulDigi
00249 DEutils<L1GctEtTotalCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00250 int cid = de_type();
00251 int errt = aflag;
00252 double x1 = 0; double x2 = 0;
00253 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00254 unsigned int dw = (aflag==4)?0:itd->raw();
00255 unsigned int ew = (aflag==3)?0:itm->raw();
00256 dw &= 0x1fff; ew &= 0x1fff;
00257 digi.setData(dw,ew);
00258 int de = (aflag==4)?0:itd->et();
00259 int ee = (aflag==3)?0:itm->et();
00260 digi.setRank((float)de,(float)ee);
00261 return digi;
00262 }
00263 template<> inline L1DataEmulDigi
00264 DEutils<L1GctHFBitCountsCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00265 int cid = de_type();
00266 int errt = aflag;
00267 double x1 = 0; double x2 = 0;
00268 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00269 unsigned int dw = (aflag==4)?0:itd->raw();
00270 unsigned int ew = (aflag==3)?0:itm->raw();
00271 digi.setData(dw,ew);
00272 int de = 0; int ee = 0;
00273 digi.setRank((float)de,(float)ee);
00274 return digi;
00275 }
00276 template<> inline L1DataEmulDigi
00277 DEutils<L1GctHFRingEtSumsCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00278 int cid = de_type();
00279 int errt = aflag;
00280 double x1 = 0; double x2 = 0;
00281 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00282 unsigned int dw = (aflag==4)?0:itd->raw();
00283 unsigned int ew = (aflag==3)?0:itm->raw();
00284 digi.setData(dw,ew);
00285 int de = 0; int ee = 0;
00286 digi.setRank((float)de,(float)ee);
00287 return digi;
00288 }
00289 template<> inline L1DataEmulDigi
00290 DEutils<L1GctHtMissCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00291 int cid = de_type();
00292 int errt = aflag;
00293 double x1 = (aflag!=4) ? itd->phi() : itm->phi();
00294 double x2 = 0;
00295 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00296 unsigned int dw = (aflag==4)?0:itd->raw();
00297 unsigned int ew = (aflag==3)?0:itm->raw();
00298 dw &= 0x8f1fff; ew &= 0x8f1fff;
00299 digi.setData(dw,ew);
00300 int de = (aflag==4)?0:itd->et();
00301 int ee = (aflag==3)?0:itm->et();
00302 digi.setRank((float)de,(float)ee);
00303 return digi;
00304 }
00305
00306 template<> inline L1DataEmulDigi
00307 DEutils<L1GctJetCountsCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00308 int cid = de_type();
00309 int errt = aflag;
00310 double x1 = 0; double x2 = 0;
00311 L1DataEmulDigi digi(dedefs::GCT,cid, x1,x2,0., errt);
00312 unsigned int dw = (aflag==4)?0:itd->raw0();
00313 unsigned int ew = (aflag==3)?0:itm->raw0();
00314 digi.setData(dw,ew);
00315 int de = 0; int ee = 0;
00316 digi.setRank((float)de,(float)ee);
00317 return digi;
00318 }
00319
00320 template<> inline L1DataEmulDigi
00321 DEutils<L1MuRegionalCandCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00322 int sid;
00323 switch(itd->type_idx()) {
00324 case 0: sid=dedefs::DTF; break;
00325 case 1: sid=dedefs::RPC; break;
00326 case 2: sid=dedefs::CTF; break;
00327 case 3: sid=dedefs::RPC; break;
00328 default: sid=-1;
00329 }
00330 int cid = de_type();
00331 int errt = aflag;
00332
00333
00334 double x1 = (aflag!=4) ? itd->phi_packed() : itm->phi_packed();
00335 double x2 = (aflag!=4) ? itd->eta_packed() : itm->eta_packed();
00336 L1DataEmulDigi digi(sid,cid, x1,x2,0, errt);
00337 unsigned int dw = (aflag==4)?0 : itd->getDataWord();
00338 unsigned int ew = (aflag==3)?0 : itm->getDataWord();
00339 unsigned int mask = 0xffffffff;
00340
00341
00342 if(sid==dedefs::RPC)
00343 mask &= 0xc1ffffff;
00344 dw &= mask; ew &= mask;
00345 digi.setData(dw,ew);
00346 int de = (aflag==4)?0:itd->pt_packed();
00347 int ee = (aflag==3)?0:itm->pt_packed();
00348 digi.setRank((float)de,(float)ee);
00349
00350
00351 if(0)
00352 std::cout << "L1DataEmulDigi DEutils<L1MuRegionalCandCollection>] dedigi info"
00353
00354
00355 << " phipackd:" << itd->phi_packed() << "," << itm->phi_packed()
00356 << " etapackd:" << itd->eta_packed() << "," << itm->eta_packed()
00357 << std::endl;
00358 return digi;
00359 }
00360
00361 template<> inline L1DataEmulDigi
00362 DEutils<L1MuGMTCandCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00363 int cid = de_type();
00364 int errt = aflag;
00365
00366
00367 double x1 = (aflag!=4) ? itd->phiIndex() : itm->phiIndex();
00368 double x2 = (aflag!=4) ? itd->etaIndex() : itm->etaIndex();
00369 L1DataEmulDigi digi(dedefs::GMT,cid, x1,x2,0, errt);
00370 unsigned int dw = (aflag==4)?0 : itd->getDataWord();
00371 unsigned int ew = (aflag==3)?0 : itm->getDataWord();
00372 unsigned int mask = 0x3ffffff;
00373
00374 mask &= (~(0x0c00000));
00375 dw &= mask; ew &= mask;
00376 digi.setData(dw,ew);
00377 int de = (aflag==4)?0:itd->ptIndex();
00378 int ee = (aflag==3)?0:itm->ptIndex();
00379 digi.setRank((float)de,(float)ee);
00380 if(0)
00381 std::cout << "l1dataemuldigi l1mugmtcandcoll type:" << cid
00382
00383
00384 << std::hex << " word d:" << dw << "e:" << ew << std::dec
00385 << std::endl;
00386 return digi;
00387 }
00388
00389 template<>
00390 inline L1DataEmulDigi DEutils<L1MuDTChambPhDigiCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00391 int cid = de_type();
00392 int errt = aflag;
00393 double x1 = (aflag!=4) ? itd->scNum() : itm->scNum();
00394 double x2 = (aflag!=4) ? itd->whNum() : itm->whNum();
00395 double x3 = (aflag!=4) ? itd->stNum() : itm->stNum();
00396 L1DataEmulDigi digi(dedefs::DTP,cid, x1,x2,x3, errt);
00397
00398
00399 int dr = (aflag==4)?0:itd->code();
00400 int er = (aflag==3)?0:itm->code();
00401 digi.setRank((float)dr,(float)er);
00402 return digi;
00403 }
00404
00405 template<> inline L1DataEmulDigi
00406 DEutils<L1MuDTChambThDigiCollection>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00407 int cid = de_type();
00408 int errt = aflag;
00409 double x1 = (aflag!=4) ? itd->scNum() : itm->scNum();
00410 double x2 = (aflag!=4) ? itd->whNum() : itm->whNum();
00411 double x3 = (aflag!=4) ? itd->stNum() : itm->stNum();
00412 L1DataEmulDigi digi(dedefs::DTP,cid, x1,x2,x3, errt);
00413
00414 int dr(0), er(0);
00415 for(int i=0; i<7;i++){
00416 if(itd->code(i)>=dr) dr=itd->quality(i);
00417 if(itm->code(i)>=er) er=itm->quality(i);
00418 }
00419
00420 dr = (aflag==4)?0:dr;
00421 er = (aflag==3)?0:er;
00422 digi.setRank((float)dr,(float)er);
00423 return digi;
00424 }
00425
00426
00427 template<> inline L1DataEmulDigi
00428 DEutils<CSCCorrelatedLCTDigiCollection_>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00429 int cid = de_type();
00430 int errt = aflag;
00431 double x1 = (aflag!=4) ? itd->getStrip() : itm->getStrip();
00432 double x2 = (aflag!=4) ? itd->getKeyWG() : itm->getKeyWG();
00433 double x3 = (aflag!=4) ? itd->getTrknmb(): itm->getTrknmb();
00434
00435 L1DataEmulDigi digi(-1,cid, x1,x2,x3, errt);
00436 int dq = (aflag==4)?0:itd->getQuality();
00437 int eq = (aflag==3)?0:itm->getQuality();
00438 digi.setRank((float)dq,(float)eq);
00439
00440 static const int kValidBitWidth = 1;
00441 static const int kQualityBitWidth = 4;
00442 static const int kPatternBitWidth = 4;
00443 static const int kWireGroupBitWidth = 7;
00444 static const int kHalfstripBitWidth = 8;
00445 static const int kBendBitWidth = 1;
00446 static const int kBxBitWidth = 1;
00447
00448 static const int kMPCLinkBitWidth = 2;
00449 static const int kCSCIdBitWidth = 4;
00450
00451 unsigned shift = 0, dw = 0, ew = 0;
00452 dw = itd->isValid() & ((1<<kValidBitWidth)-1);
00453 dw += (itd->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00454 (shift += kValidBitWidth);
00455 dw += (itd->getPattern() & ((1<<kPatternBitWidth)-1)) <<
00456 (shift += kQualityBitWidth);
00457 dw += (itd->getKeyWG() & ((1<<kWireGroupBitWidth)-1)) <<
00458 (shift += kPatternBitWidth);
00459 dw += (itd->getStrip() & ((1<<kHalfstripBitWidth)-1)) <<
00460 (shift += kWireGroupBitWidth);
00461 dw += (itd->getBend() & ((1<<kBendBitWidth)-1)) <<
00462 (shift += kHalfstripBitWidth);
00463 dw += (itd->getBX() & ((1<<kBxBitWidth)-1)) <<
00464 (shift += kBendBitWidth);
00465 dw += (itd->getMPCLink() & ((1<<kMPCLinkBitWidth)-1)) <<
00466 (shift += kBxBitWidth);
00467 dw += (itd->getCSCID() & ((1<<kCSCIdBitWidth)-1)) <<
00468 (shift += kMPCLinkBitWidth);
00469 shift = 0;
00470 ew = itm->isValid() & ((1<<kValidBitWidth)-1);
00471 ew += (itm->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00472 (shift += kValidBitWidth);
00473 ew += (itm->getPattern() & ((1<<kPatternBitWidth)-1)) <<
00474 (shift += kQualityBitWidth);
00475 ew += (itm->getKeyWG() & ((1<<kWireGroupBitWidth)-1)) <<
00476 (shift += kPatternBitWidth);
00477 ew += (itm->getStrip() & ((1<<kHalfstripBitWidth)-1)) <<
00478 (shift += kWireGroupBitWidth);
00479 ew += (itm->getBend() & ((1<<kBendBitWidth)-1)) <<
00480 (shift += kHalfstripBitWidth);
00481 ew += (itm->getBX() & ((1<<kBxBitWidth)-1)) <<
00482 (shift += kBendBitWidth);
00483 ew += (itm->getMPCLink() & ((1<<kMPCLinkBitWidth)-1)) <<
00484 (shift += kBxBitWidth);
00485 ew += (itm->getCSCID() & ((1<<kCSCIdBitWidth)-1)) <<
00486 (shift += kMPCLinkBitWidth);
00487 digi.setData(dw, ew);
00488 return digi;
00489 }
00490
00491 template<> inline L1DataEmulDigi
00492 DEutils<CSCALCTDigiCollection_>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00493 int cid = de_type();
00494 int errt = aflag;
00495 double x2 = (aflag!=4) ? itd->getKeyWG () : itm->getKeyWG ();
00496 double x3 = (aflag!=4) ? itd->getTrknmb() : itm->getTrknmb();
00497 L1DataEmulDigi digi(dedefs::CTP,cid, 0,x2,x3, errt);
00498 int dq = (aflag==4)?0:itd->getQuality();
00499 int eq = (aflag==3)?0:itm->getQuality();
00500 digi.setRank((float)dq,(float)eq);
00501
00502 static const int kValidBitWidth = 1;
00503 static const int kQualityBitWidth = 2;
00504 static const int kAccelBitWidth = 1;
00505 static const int kPatternBBitWidth = 1;
00506 static const int kWireGroupBitWidth = 7;
00507 static const int kBxBitWidth = 5;
00508
00509 unsigned shift = 0, dw = 0, ew = 0;
00510 dw = itd->isValid() & ((1<<kValidBitWidth)-1);
00511 dw += (itd->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00512 (shift += kValidBitWidth);
00513 dw += (itd->getAccelerator() & ((1<<kAccelBitWidth)-1)) <<
00514 (shift += kQualityBitWidth);
00515 dw += (itd->getCollisionB() & ((1<<kPatternBBitWidth)-1)) <<
00516 (shift += kAccelBitWidth);
00517 dw += (itd->getKeyWG() & ((1<<kWireGroupBitWidth)-1)) <<
00518 (shift += kPatternBBitWidth);
00519 dw += (itd->getBX() & ((1<<kBxBitWidth)-1)) <<
00520 (shift += kWireGroupBitWidth);
00521 shift = 0;
00522 ew = itm->isValid() & ((1<<kValidBitWidth)-1);
00523 ew += (itm->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00524 (shift += kValidBitWidth);
00525 ew += (itm->getAccelerator() & ((1<<kAccelBitWidth)-1)) <<
00526 (shift += kQualityBitWidth);
00527 ew += (itm->getCollisionB() & ((1<<kPatternBBitWidth)-1)) <<
00528 (shift += kAccelBitWidth);
00529 ew += (itm->getKeyWG() & ((1<<kWireGroupBitWidth)-1)) <<
00530 (shift += kPatternBBitWidth);
00531 ew += (itm->getBX() & ((1<<kBxBitWidth)-1)) <<
00532 (shift += kWireGroupBitWidth);
00533 digi.setData(dw, ew);
00534 return digi;
00535 }
00536 template<> inline L1DataEmulDigi
00537 DEutils<CSCCLCTDigiCollection_>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00538 int cid = de_type();
00539 int errt = aflag;
00540 double x1 = (aflag!=4) ? itd->getKeyStrip() : itm->getKeyStrip();
00541 double x3 = (aflag!=4) ? itd->getTrknmb() : itm->getTrknmb();
00542 L1DataEmulDigi digi(dedefs::CTP,cid, x1,0,x3, errt);
00543 int dq = (aflag==4)?0:itd->getQuality();
00544 int eq = (aflag==3)?0:itm->getQuality();
00545 digi.setRank((float)dq,(float)eq);
00546
00547 static const int kValidBitWidth = 1;
00548 static const int kQualityBitWidth = 3;
00549 static const int kPatternBitWidth = 4;
00550 static const int kBendBitWidth = 1;
00551 static const int kHalfstripBitWidth = 5;
00552 static const int kCFEBBitWidth = 3;
00553 static const int kBxBitWidth = 2;
00554
00555 unsigned shift = 0, dw = 0, ew = 0;
00556 dw = itd->isValid() & ((1<<kValidBitWidth)-1);
00557 dw += (itd->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00558 (shift += kValidBitWidth);
00559 dw += (itd->getPattern() & ((1<<kPatternBitWidth)-1)) <<
00560 (shift += kQualityBitWidth);
00561 dw += (itd->getBend() & ((1<<kBendBitWidth)-1)) <<
00562 (shift += kPatternBitWidth);
00563 dw += (itd->getStrip() & ((1<<kHalfstripBitWidth)-1)) <<
00564 (shift += kBendBitWidth);
00565 dw += (itd->getCFEB() & ((1<<kCFEBBitWidth)-1)) <<
00566 (shift += kHalfstripBitWidth);
00567 dw += (itd->getBX() & ((1<<kBxBitWidth)-1)) <<
00568 (shift += kCFEBBitWidth);
00569 shift = 0;
00570 ew = itm->isValid() & ((1<<kValidBitWidth)-1);
00571 ew += (itm->getQuality() & ((1<<kQualityBitWidth)-1)) <<
00572 (shift += kValidBitWidth);
00573 ew += (itm->getPattern() & ((1<<kPatternBitWidth)-1)) <<
00574 (shift += kQualityBitWidth);
00575 ew += (itm->getBend() & ((1<<kBendBitWidth)-1)) <<
00576 (shift += kPatternBitWidth);
00577 ew += (itm->getStrip() & ((1<<kHalfstripBitWidth)-1)) <<
00578 (shift += kBendBitWidth);
00579 ew += (itm->getCFEB() & ((1<<kCFEBBitWidth)-1)) <<
00580 (shift += kHalfstripBitWidth);
00581 ew += (itm->getBX() & ((1<<kBxBitWidth)-1)) <<
00582 (shift += kCFEBBitWidth);
00583 digi.setData(dw, ew);
00584 return digi;
00585 }
00586
00587 template<> inline L1DataEmulDigi
00588 DEutils<L1CSCSPStatusDigiCollection_>::DEDigi(col_cit itd, col_cit itm, int aflag) {
00589 int cid = de_type();
00590 int errt = aflag;
00591 double x1;
00592 x1 = (aflag!=4) ? itd->slot() : itm->slot();
00593
00594
00595
00596
00597 L1DataEmulDigi digi(dedefs::CTF,cid, x1,0,0, errt);
00598
00599 return digi;
00600 }
00601
00603
00604 template <typename T> typename
00605 DEutils<T>::col_it DEutils<T>::de_find( col_it first, col_it last, const cand_type& value ) {
00606 for ( ;first!=last; first++)
00607 if ( de_equal(*first,value) ) break;
00608 return first;
00609 }
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00621
00622 template <typename T>
00623 bool DEutils<T>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00624
00625 return true;
00626 }
00627 template <typename T>
00628 bool DEutils<T>::de_nequal(const cand_type& lhs, const cand_type& rhs) {
00629 return !de_equal(lhs,rhs);
00630 }
00631
00632 template <> inline bool
00633 DEutils<EcalTrigPrimDigiCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00634 bool val = true;
00635 unsigned int mask = 0x0fff;
00636 mask &= 0x0eff;
00637 val &= ((lhs[lhs.sampleOfInterest()].raw()&mask) == (rhs[rhs.sampleOfInterest()].raw()&mask));
00638 val &= (lhs.id().rawId() == rhs.id().rawId());
00639 return val;
00640 }
00641
00642 template <> inline bool
00643 DEutils<HcalTrigPrimDigiCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00644 bool val = true;
00645 unsigned int mask = 0x01ff;
00646 val &= ((lhs.t0().raw()&mask) == (rhs.t0().raw()&mask));
00647 val &= (lhs.id().rawId() == rhs.id().rawId());
00648 return val;
00649 }
00650
00651 template <> inline bool
00652 DEutils<L1CaloEmCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00653 bool val = true;
00654 val &= (lhs.raw() == rhs.raw() );
00655 val &= (lhs.rctCrate() == rhs.rctCrate());
00656 val &= (lhs.isolated() == rhs.isolated());
00657 val &= (lhs.index() == rhs.index() );
00658
00659 return val;
00660 }
00661
00662 template <> inline bool
00663 DEutils<L1CaloRegionCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00664 bool val = true;
00665 val &= (lhs.et() == rhs.et() );
00666 val &= (lhs.rctCrate() == rhs.rctCrate() );
00667 val &= (lhs.rctRegionIndex() == rhs.rctRegionIndex());
00668 val &= (lhs.id().isHf() == rhs.id().isHf());
00669 if (!lhs.id().isHf()){
00670 val &= (lhs.overFlow() == rhs.overFlow() );
00671 val &= (lhs.tauVeto() == rhs.tauVeto() );
00672
00673
00674
00675 val &= (lhs.rctCard() == rhs.rctCard() );
00676 } else {
00677 val &= (lhs.fineGrain() == rhs.fineGrain());
00678 }
00679 return val;
00680 }
00681
00682 template <> inline bool
00683 DEutils<L1GctEmCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00684
00685 template <> inline bool DEutils<L1GctJetCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00686
00687 template <> inline bool DEutils<L1GctEtHadCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00688 template <> inline bool DEutils<L1GctEtMissCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00689 template <> inline bool DEutils<L1GctEtTotalCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00690 template <> inline bool DEutils<L1GctHtMissCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00691 template <> inline bool DEutils<L1GctHFRingEtSumsCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00692 template <> inline bool DEutils<L1GctHFBitCountsCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00693 template <> inline bool DEutils<L1GctJetCountsCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {return lhs==rhs;}
00694
00695
00696 template <> inline bool
00697 DEutils<L1MuDTChambPhDigiCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00698 bool val = true;
00699 val &= (lhs.whNum() ==rhs.whNum() );
00700 val &= (lhs.scNum() ==rhs.scNum() );
00701 val &= (lhs.stNum() ==rhs.stNum() );
00702
00703
00704 val &= (lhs.code() ==rhs.code() );
00705 val &= (lhs.Ts2Tag()==rhs.Ts2Tag());
00706
00707
00708 return val;
00709 }
00710
00711 template <> inline bool
00712 DEutils<L1MuDTChambThDigiCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00713 bool val = true;
00714 val &= (lhs.whNum() ==rhs.whNum() );
00715 val &= (lhs.scNum() ==rhs.scNum() );
00716 val &= (lhs.stNum() ==rhs.stNum() );
00717
00718
00719
00720
00721
00722
00723 return val;
00724 }
00725
00726 template <> inline bool
00727 DEutils<L1MuRegionalCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00728 bool val = true;
00729 val &= (lhs.type_idx() == rhs.type_idx());
00730 val &= (lhs.bx() == rhs.bx());
00731 if(!val) return val;
00732 unsigned int dw = lhs.getDataWord();
00733 unsigned int ew = rhs.getDataWord();
00734 unsigned int mask = 0xffffffff;
00735
00736
00737
00738 if(rhs.type_idx()==1 || rhs.type_idx()==3)
00739 mask &= 0xc1ffffff;
00740 dw &= mask; ew &= mask;
00741 val &= (dw==ew);
00742
00743
00744 return val;
00745 }
00746
00747 template <> inline bool
00748 DEutils<L1MuGMTCandCollection>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00749
00750
00751 bool val = true;
00752 unsigned int dw = rhs.getDataWord();
00753 unsigned int ew = lhs.getDataWord();
00754 unsigned int mask = 0x3ffffff;
00755
00756 mask &= (~(0x0c00000));
00757 dw &= mask; ew &= mask;
00758 val &= (dw==ew);
00759 return val;
00760 }
00761
00762 template <> inline bool
00763 DEutils<CSCCorrelatedLCTDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00764
00765
00766
00767 bool val = true;
00768 val &= (lhs.isValid() == rhs.isValid() );
00769 val &= (lhs.getQuality() == rhs.getQuality());
00770 val &= (lhs.getKeyWG() == rhs.getKeyWG() );
00771 val &= (lhs.getStrip() == rhs.getStrip() );
00772 val &= (lhs.getPattern() == rhs.getPattern());
00773 val &= (lhs.getBend() == rhs.getBend() );
00774 val &= (lhs.getBX() == rhs.getBX() );
00775 val &= (lhs.getMPCLink() == rhs.getMPCLink());
00776 val &= (lhs.getCSCID() == rhs.getCSCID() );
00777 return val;
00778
00779 }
00780 template <> inline bool
00781 DEutils<CSCALCTDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00782 return lhs==rhs;
00783 }
00784 template <> inline bool
00785 DEutils<CSCCLCTDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00786 return lhs==rhs;
00787 }
00788 template <> inline bool
00789 DEutils<L1CSCSPStatusDigiCollection_>::de_equal(const cand_type& lhs, const cand_type& rhs) {
00790 bool val = true;
00791 val &= (lhs.slot() == rhs.slot());
00792 val &= (lhs.BXN () == rhs.BXN ());
00793 val &= (lhs.FMM () == rhs.FMM ());
00794 val &= (lhs.SEs () == rhs.SEs ());
00795 val &= (lhs.SMs () == rhs.SMs ());
00796 val &= (lhs.BXs () == rhs.BXs ());
00797 val &= (lhs.AFs () == rhs.AFs ());
00798 val &= (lhs.VPs () == rhs.VPs ());
00799 return val;
00800 }
00801
00803
00804 template <typename T>
00805 bool DEutils<T>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00806
00807 return true;
00808 }
00809 template <typename T>
00810 bool DEutils<T>::de_nequal_loc(const cand_type& lhs, const cand_type& rhs) {
00811 return !de_equal_loc(lhs,rhs);
00812 }
00813
00814
00815 template <> inline bool
00816 DEutils<EcalTrigPrimDigiCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00817 bool val = true;
00818 val &= (lhs.id().zside() == rhs.id().zside() );
00819 val &= (lhs.id().ietaAbs() == rhs.id().ietaAbs());
00820 val &= (lhs.id().iphi() == rhs.id().iphi() );
00821 return val;
00822 }
00823
00824 template <> inline bool
00825 DEutils<HcalTrigPrimDigiCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00826 bool val = true;
00827 val &= (lhs.id().zside() == rhs.id().zside() );
00828 val &= (lhs.id().ietaAbs() == rhs.id().ietaAbs());
00829 val &= (lhs.id().iphi() == rhs.id().iphi() );
00830 return val;
00831 }
00832
00833 template <> inline bool
00834 DEutils<L1CaloEmCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00835 bool val = true;
00836 val &= (lhs.rctCrate() == rhs.rctCrate());
00837 val &= (lhs.rctCard() == rhs.rctCard());
00838 val &= (lhs.rctRegion() == rhs.rctRegion());
00839 return val;
00840 }
00841
00842 template <> inline bool
00843 DEutils<L1CaloRegionCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00844 bool val = true;
00845 val &= (lhs.rctCrate() == rhs.rctCrate() );
00846 val &= (lhs.id().isHf() == rhs.id().isHf());
00847 if (!lhs.id().isHf())
00848 val &= (lhs.rctCard() == rhs.rctCard() );
00849 val &= (lhs.rctRegionIndex() == rhs.rctRegionIndex());
00850 return val;
00851 }
00852
00853 template <> inline bool
00854 DEutils<L1GctEmCandCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00855 bool val = true;
00856 val &= (lhs.etaIndex() == rhs.etaIndex());
00857 val &= (lhs.phiIndex() == rhs.phiIndex());
00858 return val;
00859 }
00860 template <> inline bool
00861 DEutils<L1GctJetCandCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00862 bool val = true;
00863 val &= (lhs.etaIndex() == rhs.etaIndex());
00864 val &= (lhs.phiIndex() == rhs.phiIndex());
00865 return val;
00866 }
00867
00868 template <> inline bool
00869 DEutils<L1GctEtHadCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00870 return true;
00871 }
00872 template <> inline bool
00873 DEutils<L1GctEtMissCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00874 bool val = true;
00875 val &= (lhs.phi() == rhs.phi());
00876 return val;
00877 }
00878 template <> inline bool
00879 DEutils<L1GctEtTotalCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00880 return true;
00881 }
00882 template <> inline bool
00883 DEutils<L1GctHtMissCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00884 bool val = true;
00885 val &= (lhs.phi() == rhs.phi());
00886 return val;
00887 }
00888 template <> inline bool
00889 DEutils<L1GctHFRingEtSumsCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00890 return true;
00891 }
00892 template <> inline bool
00893 DEutils<L1GctHFBitCountsCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00894 return true;
00895 }
00896 template <> inline bool
00897 DEutils<L1GctJetCountsCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00898 return true;
00899 }
00900
00901
00902 template <> inline bool
00903 DEutils<L1MuRegionalCandCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00904 bool val = true;
00905 val &= (lhs.phi_packed() ==rhs.phi_packed() );
00906 val &= (lhs.eta_packed() ==rhs.eta_packed() );
00907
00908
00909 return val;
00910 }
00911
00912 template <> inline bool
00913 DEutils<L1MuGMTCandCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00914 bool val = true;
00915 val &= (lhs.phiIndex() ==rhs.phiIndex() );
00916 val &= (lhs.etaIndex() ==rhs.etaIndex() );
00917 return val;
00918 }
00919
00920 template <> inline bool
00921 DEutils<L1MuDTChambPhDigiCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00922 bool val = true;
00923 val &= (lhs.whNum() ==rhs.whNum() );
00924 val &= (lhs.scNum() ==rhs.scNum() );
00925 val &= (lhs.stNum() ==rhs.stNum() );
00926
00927
00928
00929 return val;
00930 }
00931
00932 template <> inline bool
00933 DEutils<L1MuDTChambThDigiCollection>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00934 bool val = true;
00935 val &= (lhs.whNum() ==rhs.whNum() );
00936 val &= (lhs.scNum() ==rhs.scNum() );
00937 val &= (lhs.stNum() ==rhs.stNum() );
00938
00939 return val;
00940 }
00941
00942 template <> inline bool
00943 DEutils<CSCCorrelatedLCTDigiCollection_>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00944 bool val = true;
00945 val &= (lhs.getCSCID() == rhs.getCSCID() );
00946 val &= (lhs.getStrip() == rhs.getStrip() );
00947 val &= (lhs.getKeyWG() == rhs.getKeyWG() );
00948 return val;
00949 }
00950
00951 template <> inline bool
00952 DEutils<CSCALCTDigiCollection_>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00953 bool val = true;
00954 val &= (lhs.getTrknmb() == rhs.getTrknmb() );
00955 val &= (lhs.getKeyWG() == rhs.getKeyWG() );
00956 return val;
00957 }
00958 template <> inline bool
00959 DEutils<CSCCLCTDigiCollection_>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00960 bool val = true;
00961 val &= (lhs.getTrknmb() == rhs.getTrknmb() );
00962 val &= (lhs.getKeyStrip() == rhs.getKeyStrip() );
00963 return val;
00964 }
00965 template <> inline bool
00966 DEutils<L1CSCSPStatusDigiCollection_>::de_equal_loc(const cand_type& lhs, const cand_type& rhs) {
00967 bool val = true;
00968 val &= (lhs.slot() == rhs.slot());
00969 return val;
00970 }
00971
00973
00974 template <typename T>
00975 bool DEutils<T>::is_empty(col_cit it) const {
00976
00977 return false;
00978 }
00979
00980 template<>
00981 inline bool DEutils<EcalTrigPrimDigiCollection>::is_empty(col_cit it) const {
00982 bool val = false;
00983 unsigned int raw = it->sample(it->sampleOfInterest()).raw();
00984 unsigned int mask = 0x0fff;
00985 mask = 0x0eff;
00986 raw &= mask;
00987 val |= (raw==0);
00988 if(val) return val;
00989 unsigned int ttf = it->ttFlag();
00990 val |= ((ttf!=0x1) && (ttf!=0x3));
00991 return val;
00992
00993 }
00994
00995 template<>
00996 inline bool DEutils<HcalTrigPrimDigiCollection>::is_empty(col_cit it) const {
00997 unsigned int mask = 0x01ff;
00998 return ( it->size()==0 || ((it->t0().raw()&mask)==0) || it->SOI_compressedEt()==0 );
00999 }
01000
01001 template<>
01002 inline bool DEutils<L1CaloEmCollection>::is_empty(col_cit it) const {
01003 return ((it->rank())==0);
01004
01005 }
01006
01007 template<>
01008 inline bool DEutils<L1CaloRegionCollection>::is_empty(col_cit it) const {
01009 return ((it->et())==0);
01010
01011 }
01012
01013 template<>
01014 inline bool DEutils<L1GctEmCandCollection>::is_empty(col_cit it) const {
01015 return (it->empty());
01016 }
01017
01018 template<>
01019 inline bool DEutils<L1GctJetCandCollection>::is_empty(col_cit it) const {
01020 return (it->empty());
01021 }
01022
01023 template <> inline bool DEutils<L1GctEtHadCollection>::is_empty(col_cit it) const {return(it->empty());}
01024 template <> inline bool DEutils<L1GctEtMissCollection>::is_empty(col_cit it) const {return(it->empty());}
01025 template <> inline bool DEutils<L1GctEtTotalCollection>::is_empty(col_cit it) const {return(it->empty());}
01026 template <> inline bool DEutils<L1GctHtMissCollection>::is_empty(col_cit it) const {return(it->empty());}
01027 template <> inline bool DEutils<L1GctHFRingEtSumsCollection>::is_empty(col_cit it) const {return(it->empty());}
01028 template <> inline bool DEutils<L1GctHFBitCountsCollection>::is_empty(col_cit it) const {return(it->empty());}
01029 template <> inline bool DEutils<L1GctJetCountsCollection>::is_empty(col_cit it) const {return(it->empty());}
01030
01031
01032 template<>
01033 inline bool DEutils<L1MuDTChambPhDigiCollection>::is_empty(col_cit it) const {
01034 return (it->bxNum() != 0 || it->code() == 7);
01035
01036
01037 }
01038 template<>
01039 inline bool DEutils<L1MuDTChambThDigiCollection>::is_empty(col_cit it) const {
01040 return (it->whNum()==0 && it->scNum()==0 && it->stNum()==0);
01041
01042 }
01043
01044 template<>
01045 inline bool DEutils<L1MuRegionalCandCollection>::is_empty(col_cit it) const {
01046
01047
01048
01049 if(it->type_idx()==1 || it->type_idx()==3)
01050 if (it->bx()!=0)
01051 return true;
01052
01053 return (it->empty());
01054
01055
01056
01057 }
01058
01059 template<>
01060 inline bool DEutils<L1MuGMTCandCollection>::is_empty(col_cit it) const {
01061 return (it->empty());
01062
01063
01064 }
01065
01066 template<>
01067 inline bool DEutils<CSCCorrelatedLCTDigiCollection_>::is_empty(col_cit it) const {
01068 return !(it->isValid());
01069 }
01070 template<>
01071 inline bool DEutils<CSCALCTDigiCollection_>::is_empty(col_cit it) const {
01072 return !(it->isValid());
01073 }
01074 template<>
01075 inline bool DEutils<CSCCLCTDigiCollection_>::is_empty(col_cit it) const {
01076 return !(it->isValid());
01077 }
01078
01079 template<>
01080 inline bool DEutils<L1CSCSPStatusDigiCollection_>::is_empty(col_cit it) const {
01081 unsigned data =
01082 it->slot() | it->BXN () | it->FMM () | it->SEs () |
01083 it->SMs () | it->BXs () | it->AFs () | it->VPs ();
01084 return data==0;
01085 }
01086
01088
01089 template <typename T>
01090 std::string DEutils<T>::print(col_cit it) const {
01091 std::stringstream ss;
01092 ss << "[DEutils<T>::print()] specialization still missing for collection!";
01093
01094 ss << std::endl;
01095 return ss.str();
01096 }
01097
01098 template <>
01099 inline std::string DEutils<EcalTrigPrimDigiCollection>::print(col_cit it) const {
01100 std::stringstream ss;
01101 ss << "0x" << std::setw(4) << std::setfill('0') << std::hex
01102 << it->sample(it->sampleOfInterest()).raw()
01103 << std::setfill(' ') << std::dec
01104 << ", et:" << std::setw(3) << it->compressedEt()
01105 << ", fg:" << std::setw(1) << it->fineGrain()
01106 << ", ttf:" << std::setw(2) << it->ttFlag()
01107 << ", sdet:" << ((it->id().subDet()==EcalBarrel)?("Barrel"):("Endcap"))
01108 << ", iz:" << ((it->id().zside()>0)?("+"):("-"))
01109 << ", ieta:" << std::setw(2) << it->id().ietaAbs()
01110 << ", iphi:" << std::setw(2) << it->id().iphi()
01111
01112 << std::endl;
01113 return ss.str();
01114 }
01115
01116 template <>
01117 inline std::string DEutils<HcalTrigPrimDigiCollection>::print(col_cit it) const {
01118 std::stringstream ss;
01119 ss << "0x" << std::setw(4) << std::setfill('0') << std::hex
01120 << it->t0().raw()
01121 << std::setfill(' ') << std::dec
01122 << ", et:" << std::setw(3) << it->SOI_compressedEt()
01123 << ", fg:" << std::setw(1) << it->SOI_fineGrain()
01124 << ", sdet:" << it->id().subdet()
01125 << ", iz:" << ((it->id().zside()>0)?("+"):("-"))
01126 << ", ieta:" << std::setw(2) << it->id().ietaAbs()
01127 << ", iphi:" << std::setw(2) << it->id().iphi()
01128 << std::endl;
01129
01130 return ss.str();
01131 }
01132
01133 template <>
01134 inline std::string DEutils<L1CaloEmCollection>::print(col_cit it) const {
01135 std::stringstream ss;
01136 ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw()
01137 << ", rank=0x"<< std::setw(2) << std::hex << it->rank()
01138 << std::setfill(' ') << std::dec
01139 << ", region:"<< std::setw(1) << it->rctRegion()
01140 << ", card:" << std::setw(1) << it->rctCard()
01141 << ", crate:" << std::setw(2) << it->rctCrate()
01142 << ", ieta:" << std::setw(2) << it->regionId().ieta()
01143 << ", iphi:" << std::setw(2) << it->regionId().iphi()
01144
01145
01146 << ", iso:" << std::setw(1) << it->isolated()
01147 << ", index:" << std::setw(1) << it->index()
01148 << ", bx:" << it->bx()
01149 << std::endl;
01150
01151 return ss.str();
01152 }
01153
01154 template <>
01155 inline std::string DEutils<L1CaloRegionCollection>::print(col_cit it) const {
01156 std::stringstream ss;
01157 ss << "L1CaloRegion:"
01158 << " et=" << it->et()
01159 << " o/f=" << it->overFlow()
01160 << " f/g=" << it->fineGrain()
01161 << " tau=" << it->tauVeto()
01162 << " rct(crate=" << it->rctCrate()
01163 << " card=" << it->rctCard()
01164 << " rgn=" << it->rctRegionIndex()
01165 << " eta=" << it->rctEta()
01166 << " phi=" << it->rctPhi()
01167 << ")\n\t\t"
01168 << "gct(eta=" << it->gctEta()
01169 << " phi=" << it->gctPhi()
01170 << ")"
01171 << std::hex << " cap_block=" << it->capBlock()
01172 << std::dec << " index=" << it->capIndex()
01173 << " bx=" << it->bx()
01174 << std::endl;
01175
01176
01177 return ss.str();
01178 }
01179
01180 template <>
01181 inline std::string DEutils<L1GctEmCandCollection>::print(col_cit it) const {
01182 std::stringstream ss;
01183
01184
01185 ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw()
01186 << ", rank=0x"<< std::setw(2) << std::hex << it->rank()
01187 << std::setfill(' ') << std::dec
01188 << ", etaSign:" << it->etaSign()
01189 << ", eta:" << (it->etaIndex()&0x7)
01190 << ", phi:" << std::setw(2) << it->phiIndex()
01191 << " (ieta:" << std::setw(2) << it->regionId().ieta()
01192 << ",iphi:" << std::setw(2) << it->regionId().iphi() << ")"
01193 << ", iso:" << it->isolated()
01194 << ", cap block:" << std::setw(3) << it->capBlock()
01195 << ", index:" << it->capIndex()
01196 << ", bx:" << it->bx()
01197 << std::endl;
01198
01199 return ss.str();
01200 }
01201
01202
01203
01204
01205
01206
01207
01208
01209 template <>
01210 inline std::string DEutils<L1GctJetCandCollection>::print(col_cit it) const {
01211 std::stringstream ss;
01212 ss << "0x" << std::setw(4) << std::setfill('0') << std::hex << it->raw()
01213 << " " << *it << std::dec << std::endl;
01214 return ss.str();
01215 }
01216 template <> inline std::string DEutils<L1GctEtHadCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01217 template <> inline std::string DEutils<L1GctEtMissCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01218 template <> inline std::string DEutils<L1GctEtTotalCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01219 template <> inline std::string DEutils<L1GctHtMissCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01220 template <> inline std::string DEutils<L1GctHFRingEtSumsCollection>::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01221 template <> inline std::string DEutils<L1GctHFBitCountsCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01222 template <> inline std::string DEutils<L1GctJetCountsCollection >::print(col_cit it) const {std::stringstream ss; ss<<*it; return ss.str();}
01223
01224 template <>
01225 inline std::string DEutils<L1MuDTChambPhDigiCollection>::print(col_cit it) const {
01226 std::stringstream ss;
01227 ss << ""
01228 << " bxNum:" << it->bxNum()
01229 << " whNum:" << it->whNum()
01230 << " scNum:" << it->scNum()
01231 << " stNum:" << it->stNum()
01232 << " phi:" << it->phi()
01233 << " phiB:" << it->phiB()
01234 << " code:" << it->code()
01235 << " Ts2Tag:" << it->Ts2Tag()
01236 << " BxCnt:" << it->BxCnt()
01237 << std::endl;
01238
01239 return ss.str();
01240 }
01241
01242 template <>
01243 inline std::string DEutils<L1MuDTChambThDigiCollection>::print(col_cit it) const {
01244 std::stringstream ss;
01245 ss << ""
01246 << " bxNum:" << it->bxNum()
01247 << " whNum:" << it->whNum()
01248 << " scNum:" << it->scNum()
01249 << " stNum:" << it->stNum()
01250 << std::endl;
01251
01252 return ss.str();
01253 }
01254
01255 template <>
01256 inline std::string DEutils<L1MuRegionalCandCollection>::print(col_cit it) const {
01257 std::stringstream ss;
01258
01259 ss << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right | std::ios::adjustfield);
01260 ss << std::hex << std::setfill('0')
01261 << " 0x" << std::setw(8) << it->getDataWord();
01262
01263 ss << std::hex << std::setfill('0')
01264 << " pt:0x" << std::setw(2) << it->pt_packed()
01265 << " phi:0x"<< std::setw(2) << it->phi_packed()
01266 << " eta:0x"<< std::setw(2) << it->eta_packed();
01267
01268
01269
01270
01271
01272 ss << std::dec << std::setfill(' ')
01273 << " qua:" << std::setw(1) << it->quality()
01274 << " cha:" << std::setw(2) << it->chargeValue()
01275 << " chav:" << std::setw(1) << it->chargeValid()
01276 << " fh:" << std::setw(1) << it->isFineHalo()
01277 << " bx:" << std::setw(4) << it->bx()
01278 << " [id:" << std::setw(1) << it->type_idx() << "]"
01279 << std::endl;
01280
01281 return ss.str();
01282 }
01283
01284 template <>
01285 inline std::string DEutils<L1MuGMTCandCollection>::print(col_cit it) const {
01286 std::stringstream ss;
01287 ss << std::setiosflags(std::ios::showpoint | std::ios::fixed | std::ios::right | std::ios::adjustfield);
01288
01289 ss << std::hex << std::setfill('0')
01290 << " 0x" << std::setw(7) << it->getDataWord();
01291
01292 ss << std::hex << std::setfill('0')
01293 << " pt:0x" << std::setw(2) << it->ptIndex()
01294 << " eta:0x"<< std::setw(2) << it->etaIndex()
01295 << " phi:0x"<< std::setw(3) << it->phiIndex();
01296
01297
01298
01299
01300
01301 ss << std::dec << std::setfill(' ')
01302 << " cha:" << std::setw(2) << it->charge()
01303 << " qua:" << std::setw(3) << it->quality()
01304 << " iso:" << std::setw(1) << it->isol()
01305 << " mip:" << std::setw(1) << it->mip()
01306 << " bx:" << it->bx()
01307 << std::endl;
01308
01309 return ss.str();
01310 }
01311
01312 template <>
01313 inline std::string DEutils<CSCCorrelatedLCTDigiCollection_>::print(col_cit it) const {
01314 std::stringstream ss;
01315 ss
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327 << *it;
01328 return ss.str();
01329 }
01330
01331 template <>
01332 inline std::string DEutils<CSCALCTDigiCollection_>::print(col_cit it) const {
01333 std::stringstream ss;
01334 ss
01335 << *it
01336 << std::endl;
01337 return ss.str();
01338 }
01339
01340 template <>
01341 inline std::string DEutils<CSCCLCTDigiCollection_>::print(col_cit it) const {
01342 std::stringstream ss;
01343 ss
01344 << *it
01345 << std::endl;
01346 return ss.str();
01347 }
01348
01349 template <>
01350 inline std::string DEutils<L1CSCSPStatusDigiCollection_>::print(col_cit it) const {
01351 std::stringstream ss;
01352 ss
01353 << " slot:"<< it->slot()
01354 << " bxn:" << it->BXN ()
01355 << " fmm:" << it->FMM ()
01356 << " ses:" << it->SEs ()
01357 << " sms:" << it->SMs ()
01358 << " bxs:" << it->BXs ()
01359 << " afs:" << it->AFs ()
01360 << " vps:" << it->VPs ()
01361 << std::endl;
01362 return ss.str();
01363 }
01364
01366
01367 template <typename T>
01368 std::string DEutils<T>::GetName(int i) const {
01369
01370 const int nlabel = 16;
01371 if(!(i<nlabel))
01372 return "un-defined" ;
01373 std::string str[nlabel]= {"un-registered"};
01374
01375 switch(de_type()) {
01376 case dedefs::ECALtp:
01377 str[0] = "ECAL tp";
01378 str[1] = "EcalTrigPrimDigiCollection";
01379 str[2] = "EcalTriggerPrimitiveDigi";
01380 break;
01381 case dedefs::HCALtp:
01382 str[0] = "HCAL tp";
01383 str[1] = "HcalTrigPrimDigiCollection";
01384 str[2] = "HcalTriggerPrimitiveDigi";
01385 break;
01386 case dedefs::RCTem:
01387 str[0] = "RCT em";
01388 str[1] = "L1CaloEmCollection";
01389 str[2] = "L1CaloEmCand";
01390 break;
01391 case dedefs::RCTrgn:
01392 str[0] = "RCT region";
01393 str[1] = "L1CaloRegionCollection";
01394 str[2] = "L1CaloRegion";
01395 break;
01396 case dedefs::GCTisolaem:
01397 str[0] = "GCT em isolated";
01398 str[1] = "L1GctEmCandCollection";
01399 str[2] = "L1GctEmCand";
01400 break;
01401 case dedefs::GCTnoisoem:
01402 str[0] = "GCT em non-isolated";
01403 str[1] = "L1GctEmCandCollection";
01404 str[2] = "L1GctEmCand";
01405 break;
01406 case dedefs::GCTcenjets:
01407 str[0] = "GCT central jet";
01408 str[1] = "L1GctJetCandCollection";
01409 str[2] = "L1GctJetCand";
01410 break;
01411 case dedefs::GCTforjets:
01412 str[0] = "GCT forward jet";
01413 str[1] = "L1GctJetCandCollection";
01414 str[2] = "L1GctJetCand";
01415 break;
01416 case dedefs::GCTtaujets:
01417 str[0] = "GCT tau jet";
01418 str[1] = "L1GctJetCandCollection";
01419 str[2] = "L1GctJetCand";
01420 break;
01421 case dedefs::GCTethad:
01422 str[0] = "GCT ht";
01423 str[1] = "L1GctEtHadCollection";
01424 str[2] = "L1GctEtHad";
01425 break;
01426 case dedefs::GCTetmiss:
01427 str[0] = "GCT et miss";
01428 str[1] = "L1GctEtMissCollection";
01429 str[2] = "L1GctEtMiss";
01430 break;
01431 case dedefs::GCTettot:
01432 str[0] = "GCT et total";
01433 str[1] = "L1GctEtTotalCollection";
01434 str[2] = "L1GctEtTotal";
01435 break;
01436 case dedefs::GCThtmiss:
01437 str[0] = "GCT ht miss";
01438 str[1] = "L1GctHtMissCollection";
01439 str[2] = "L1GctHtMiss";
01440 break;
01441 case dedefs::GCThfring:
01442 str[0] = "GCT hf ring";
01443 str[1] = "L1GctHFRingEtSumsCollection";
01444 str[2] = "L1GctHFRingEtSums";
01445 break;
01446 case dedefs::GCThfbit:
01447 str[0] = "GCT hf bit counts";
01448 str[1] = "L1GctHFBitCountsCollection";
01449 str[2] = "L1GctHFBitCounts";
01450 break;
01451
01452 case dedefs::DTtpPh:
01453 str[0] = "DT tp phi";
01454 str[1] = "L1MuDTChambPhDigiCollection";
01455 str[2] = "L1MuDTChambPhDigi";
01456 break;
01457 case dedefs::DTtpTh:
01458 str[0] = "DT tp theta";
01459 str[1] = "L1MuDTChambThDigiCollection";
01460 str[2] = "L1MuDTChambThDigi";
01461 break;
01462 case dedefs::CSCtpa:
01463 str[0] = "CSC tpa";
01464 str[1] = "CSCALCTDigiCollection";
01465 str[2] = "CSCALCTDigi";
01466 break;
01467 case dedefs::CSCtpc:
01468 str[0] = "CSC tpc";
01469 str[1] = "CSCCLCTDigiCollection";
01470 str[2] = "CSCCLCTDigi";
01471 break;
01472 case dedefs::CSCtpl:
01473 str[0] = "CSC tp";
01474 str[1] = "CSCCorrelatedLCTDigiCollection";
01475 str[2] = "CSCCorrelatedLCTDigi";
01476 break;
01477 case dedefs::CSCsta:
01478 str[0] = "CSC tf status";
01479 str[1] = "L1CSCSPStatusDigiCollection_";
01480 str[2] = "L1CSCSPStatusDigi";
01481 break;
01482 case dedefs::MUrtf:
01483 str[0] = "Mu reg tf";
01484 str[1] = "L1MuRegionalCandCollection";
01485 str[2] = "L1MuRegionalCand";
01486 break;
01487 case dedefs::LTCi:
01488 str[0] = "LTC";
01489 str[1] = "LTCDigiCollection";
01490 str[2] = "LTCDigi";
01491 break;
01492 case dedefs::GMTcnd:
01493 str[0] = "GMT cand";
01494 str[1] = "L1MuGMTCandCollection";
01495 str[2] = "L1MuGMTCand";
01496 break;
01497 case dedefs::GMTrdt:
01498 str[0] = "GMT record";
01499 str[1] = "L1MuGMTReadoutRecordCollection";
01500 str[2] = "L1MuGMTReadoutRecord";
01501 break;
01502 case dedefs::GTdword:
01503 str[0] = "";
01504 str[1] = "";
01505 str[2] = "";
01506 break;
01507
01508 }
01509 return str[i];
01510 }
01511
01513
01514 template <typename T>
01515 struct de_rank : public DEutils<T> , public std::binary_function<typename DEutils<T>::cand_type, typename DEutils<T>::cand_type, bool> {
01516 typedef DEtrait<T> de_trait;
01517 typedef typename de_trait::cand_type cand_type;
01518 bool operator()(const cand_type& x, const cand_type& y) const {
01519 return false;
01520 }
01521 };
01522
01523 template <> inline bool de_rank<EcalTrigPrimDigiCollection>::operator()(const cand_type& x, const cand_type& y) const { return x.compressedEt() > y.compressedEt(); }
01524 template <> inline bool de_rank<HcalTrigPrimDigiCollection>::operator()(const cand_type& x, const cand_type& y) const { return x.SOI_compressedEt() > y.SOI_compressedEt(); }
01525
01526 template <>
01527 inline bool de_rank<L1CaloEmCollection>::operator()
01528 (const cand_type& x, const cand_type& y) const {
01529 if (x.rank() != y.rank()) {
01530 return (x.rank() < y.rank()) ;
01531 } else if(x.isolated() != y.isolated()) {
01532 return (x.isolated())?1:0;
01533 } else if(x.rctRegion() != y.rctRegion()){
01534 return (x.rctRegion() < y.rctRegion());
01535 } else if(x.rctCrate() != y.rctCrate()) {
01536 return (x.rctCrate() < y.rctCrate()) ;
01537 } else if(x.rctCard() != y.rctCard()) {
01538 return (x.rctCard() < y.rctCard()) ;
01539 } else {
01540 return x.raw() < y.raw();
01541 }
01542 }
01543
01544 template <> inline bool de_rank<L1CaloRegionCollection>::operator()(const cand_type& x, const cand_type& y) const { return x.et() < y.et(); }
01545
01546 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();}}}
01547 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();}}}
01548
01549
01550
01551
01552
01553
01554
01555
01556 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();}}}
01557 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();}}}
01558
01559 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();}}}
01560
01561 template <> inline bool de_rank<L1MuGMTCandCollection>::operator()(const cand_type& x, const cand_type& y)const {
01562 if(x.bx()!=y.bx()){return x.bx() < y.bx();}
01563 else if(x.ptIndex()!=y.ptIndex()){return x.ptIndex() < y.ptIndex();}
01564 else{ return x.quality() < y.quality();}
01565 }
01566
01567 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();}}}
01568
01569 #endif