testPackedCandidate

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
#include <cppunit/extensions/HelperMacros.h>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>

#include "DataFormats/PatCandidates/interface/PackedCandidate.h"

class testPackedCandidate : public CppUnit::TestFixture {
  CPPUNIT_TEST_SUITE(testPackedCandidate);

  CPPUNIT_TEST(testDefaultConstructor);
  CPPUNIT_TEST(testCopyConstructor);
  CPPUNIT_TEST(testPackUnpack);
  CPPUNIT_TEST(testSimulateReadFromRoot);
  CPPUNIT_TEST(testPackUnpackTime);
  CPPUNIT_TEST(testQualityFlags);

  CPPUNIT_TEST_SUITE_END();

public:
  void setUp() {}
  void tearDown() {}

  void testDefaultConstructor();
  void testCopyConstructor();
  void testPackUnpack();
  void testSimulateReadFromRoot();

  void testPackUnpackTime();
  void testQualityFlags();

private:
};

CPPUNIT_TEST_SUITE_REGISTRATION(testPackedCandidate);

void testPackedCandidate::testDefaultConstructor() {
  pat::PackedCandidate pc;

  CPPUNIT_ASSERT(pc.polarP4() == pat::PackedCandidate::PolarLorentzVector(0, 0, 0, 0));
  CPPUNIT_ASSERT(pc.p4() == pat::PackedCandidate::LorentzVector(0, 0, 0, 0));
  CPPUNIT_ASSERT(pc.vertex() == pat::PackedCandidate::Point(0, 0, 0));
}

static bool tolerance(double iLHS, double iRHS, double fraction) {
  return std::abs(iLHS - iRHS) <= fraction * std::abs(iLHS + iRHS) / 2.;
}

void testPackedCandidate::testCopyConstructor() {
  pat::PackedCandidate::LorentzVector lv(1., 0.5, 0., std::sqrt(1. + 0.25 + 0.120 * 0.120));
  pat::PackedCandidate::PolarLorentzVector plv(lv.Pt(), lv.Eta(), lv.Phi(), lv.M());

  pat::PackedCandidate::Point v(0.01, 0.02, 0.);

  //invalid Refs use a special key
  pat::PackedCandidate pc(lv, v, 1., 1., 1., 11, reco::VertexRefProd(), reco::VertexRef().key());

  //these by design do not work
  //  CPPUNIT_ASSERT(pc.polarP4() == plv);
  //  CPPUNIT_ASSERT(pc.p4() == lv);
  //  CPPUNIT_ASSERT(pc.vertex() == v);

  pat::PackedCandidate copy_pc(pc);

  //CPPUNIT_ASSERT(copy_pc.polarP4() == plv);
  //CPPUNIT_ASSERT(copy_pc.p4() == lv);
  //CPPUNIT_ASSERT(copy_pc.vertex() == v);

  CPPUNIT_ASSERT(&copy_pc.polarP4() != &pc.polarP4());
  CPPUNIT_ASSERT(&copy_pc.p4() != &pc.p4());
  CPPUNIT_ASSERT(&copy_pc.vertex() != &pc.vertex());

  CPPUNIT_ASSERT(tolerance(pc.vertex().X(), copy_pc.vertex().X(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Y(), copy_pc.vertex().Y(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Z(), copy_pc.vertex().Z(), 0.01));
  CPPUNIT_ASSERT(tolerance(pc.dxy(), copy_pc.dxy(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.dzAssociatedPV(), copy_pc.dzAssociatedPV(), 0.01));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), copy_pc.phiAtVtx(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), copy_pc.etaAtVtx(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), copy_pc.ptTrk(), 0.001));

  {
    //Test copy of default constructed candidate
    pat::PackedCandidate def;
    pat::PackedCandidate copy_def(def);

    CPPUNIT_ASSERT(copy_def.polarP4() == pat::PackedCandidate::PolarLorentzVector(0, 0, 0, 0));
    CPPUNIT_ASSERT(copy_def.p4() == pat::PackedCandidate::LorentzVector(0, 0, 0, 0));
    CPPUNIT_ASSERT(copy_def.vertex() == pat::PackedCandidate::Point(0, 0, 0));
  }
}

void testPackedCandidate::testPackUnpack() {
  pat::PackedCandidate::LorentzVector lv(1., 1., 0., std::sqrt(2. + 0.120 * 0.120));
  pat::PackedCandidate::PolarLorentzVector plv(lv.Pt(), lv.Eta(), lv.Phi(), lv.M());

  pat::PackedCandidate::Point v(-0.005, 0.005, 0.1);
  float trkPt = plv.Pt() + 0.5;
  float trkEta = plv.Eta() - 0.1;
  float trkPhi = -3. / 4. * 3.1416;

  //invalid Refs use a special key
  pat::PackedCandidate pc(lv, v, trkPt, trkEta, trkPhi, 11, reco::VertexRefProd(), reco::VertexRef().key());

  pc.pack(true);
  pc.packVtx(true);

  CPPUNIT_ASSERT(tolerance(pc.polarP4().Pt(), plv.Pt(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().Eta(), plv.Eta(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().Phi(), plv.Phi(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().M(), plv.M(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().X(), lv.X(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().Y(), lv.Y(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().Z(), lv.Z(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().E(), lv.E(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().X(), v.X(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Y(), v.Y(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Z(), v.Z(), 0.01));
  //AR : this cannot be called unless track details are set
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().pt(),trkPt,0.001));
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().eta(),trkEta,0.001));
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().phi(),trkPhi,0.001));
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), trkPt, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), trkEta, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), trkPhi, 0.001));
  //Check again after a setP4
  pc.setP4(plv * 2);
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), trkPt, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), trkEta, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), trkPhi, 0.001));
  pc.setP4(lv * 3);
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), trkPt, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), trkEta, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), trkPhi, 0.001));
  pc.setPz(pc.p4().Pz() + 3.3);
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), trkPt, 0.005));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), trkEta, 0.005));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), trkPhi, 0.005));
}

void testPackedCandidate::testSimulateReadFromRoot() {
  pat::PackedCandidate::LorentzVector lv(1., 1., 0., std::sqrt(2. + 0.120 * 0.120));
  pat::PackedCandidate::PolarLorentzVector plv(lv.Pt(), lv.Eta(), lv.Phi(), lv.M());
  pat::PackedCandidate::Point v(-0.005, 0.005, 0.1);

  float trkPt = plv.Pt() + 0.5;
  float trkEta = plv.Eta() - 0.1;
  float trkPhi = -3. / 4. * 3.1416;

  //invalid Refs use a special key
  pat::PackedCandidate pc(lv, v, trkPt, trkEta, trkPhi, 11, reco::VertexRefProd(), reco::VertexRef().key());

  //  CPPUNIT_ASSERT(pc.polarP4() == plv);
  //  CPPUNIT_ASSERT(pc.p4() == lv);
  //  CPPUNIT_ASSERT(pc.vertex() == v);
  //  CPPUNIT_ASSERT(pc.pseudoTrack().p() == lv.P());

  //When reading back from ROOT, these were not stored and are nulled out
  delete pc.p4_.exchange(nullptr);
  delete pc.p4c_.exchange(nullptr);
  delete pc.vertex_.exchange(nullptr);
  delete pc.track_.exchange(nullptr);
  delete pc.m_.exchange(nullptr);

  CPPUNIT_ASSERT(tolerance(pc.polarP4().Pt(), plv.Pt(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().Eta(), plv.Eta(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().Phi(), plv.Phi(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.polarP4().M(), plv.M(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().X(), lv.X(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().Y(), lv.Y(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().Z(), lv.Z(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.p4().E(), lv.E(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().X(), v.X(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Y(), v.Y(), 0.001));
  CPPUNIT_ASSERT(tolerance(pc.vertex().Z(), v.Z(), 0.01));
  //AR : this cannot be called unless track details are set
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().pt(),trkPt,0.001));
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().eta(),trkEta,0.001));
  //  CPPUNIT_ASSERT(tolerance(pc.pseudoTrack().phi(),trkPhi,0.001));
  CPPUNIT_ASSERT(tolerance(pc.ptTrk(), trkPt, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.etaAtVtx(), trkEta, 0.001));
  CPPUNIT_ASSERT(tolerance(pc.phiAtVtx(), trkPhi, 0.001));
}

void testPackedCandidate::testPackUnpackTime() {
  bool debug =
      false;  // turn this on in order to get a printout of the numerical precision you get for the timing in the various encodings

  if (debug)
    std::cout << std::endl;
  if (debug)
    std::cout << "Minimum time error: " << pat::PackedCandidate::unpackTimeError(1) << std::endl;
  if (debug)
    std::cout << "Maximum time error: " << pat::PackedCandidate::unpackTimeError(255) << std::endl;
  float avgres = 0;
  int navg = 0;
  for (int i = 2; i < 255; ++i) {
    float unp = pat::PackedCandidate::unpackTimeError(i);
    float res = 0.5 * (pat::PackedCandidate::unpackTimeError(i + 1) - pat::PackedCandidate::unpackTimeError(i - 1));
    avgres += (res / unp);
    navg++;
    if (debug)
      std::cout << " i = " << i << " unp = " << unp << " quant error = " << res
                << "  packed = " << int(pat::PackedCandidate::packTimeError(unp + 0.3 * res)) << " and "
                << int(pat::PackedCandidate::packTimeError(unp - 0.3 * res)) << std::endl;
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeError(unp + 0.3 * res) == i);
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeError(unp - 0.3 * res) == i);
  }
  if (debug)
    std::cout << "Average rel uncertainty: " << (avgres / navg) << std::endl;
  if (debug)
    std::cout << std::endl;

  if (debug)
    std::cout << "Zero time standalone (pos): " << pat::PackedCandidate::unpackTimeNoError(0) << std::endl;
  if (debug)
    std::cout << "Minimum time standalone (pos): " << pat::PackedCandidate::unpackTimeNoError(+1) << std::endl;
  if (debug)
    std::cout << "Minimum time standalone (neg): " << pat::PackedCandidate::unpackTimeNoError(-1) << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 8 bits (pos): " << pat::PackedCandidate::unpackTimeNoError(+255)
              << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 8 bits (neg): " << pat::PackedCandidate::unpackTimeNoError(-255)
              << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 10 bits (pos): " << pat::PackedCandidate::unpackTimeNoError(+1023)
              << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 10 bits (neg): " << pat::PackedCandidate::unpackTimeNoError(-1023)
              << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 11 bits (pos): " << pat::PackedCandidate::unpackTimeNoError(+2047)
              << std::endl;
  if (debug)
    std::cout << "Maximum time standalone, 11 bits (neg): " << pat::PackedCandidate::unpackTimeNoError(-2047)
              << std::endl;
  avgres = 0;
  navg = 0;
  for (int i = 2; i < 2040; i *= 1.5) {
    float unp = pat::PackedCandidate::unpackTimeNoError(i);
    float res = 0.5 * (pat::PackedCandidate::unpackTimeNoError(i + 1) - pat::PackedCandidate::unpackTimeNoError(i - 1));
    avgres += (res / unp);
    navg++;
    if (debug)
      std::cout << " i = +" << i << " unp = +" << unp << " quant error = " << res
                << "  packed = " << int(pat::PackedCandidate::packTimeNoError(unp + 0.3 * res)) << " and +"
                << int(pat::PackedCandidate::packTimeNoError(unp - 0.3 * res)) << std::endl;
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeNoError(unp + 0.3 * res) == i);
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeNoError(unp - 0.3 * res) == i);
    unp = pat::PackedCandidate::unpackTimeNoError(-i);
    res = 0.5 * (pat::PackedCandidate::unpackTimeNoError(-i + 1) - pat::PackedCandidate::unpackTimeNoError(-i - 1));
    avgres += std::abs(res / unp);
    navg++;
    if (debug)
      std::cout << " i = " << -i << " unp = " << unp << " quant error = " << res
                << "  packed = " << int(pat::PackedCandidate::packTimeNoError(unp + 0.3 * res)) << " and "
                << int(pat::PackedCandidate::packTimeNoError(unp - 0.3 * res)) << std::endl;
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeNoError(unp + 0.3 * res) == -i);
    CPPUNIT_ASSERT(pat::PackedCandidate::packTimeNoError(unp - 0.3 * res) == -i);
  }
  if (debug)
    std::cout << "Average rel uncertainty: " << (avgres / navg) << std::endl;
  if (debug)
    std::cout << std::endl;

  for (float aTimeErr = 2.0e-3; aTimeErr <= 1000e-3; aTimeErr *= std::sqrt(5.f)) {
    uint8_t packedTimeErr = pat::PackedCandidate::packTimeError(aTimeErr);
    float unpackedTimeErr = pat::PackedCandidate::unpackTimeError(packedTimeErr);
    if (debug)
      std::cout << "For a timeError of " << aTimeErr << " ns (uint8: " << unsigned(packedTimeErr) << ", unpack "
                << unpackedTimeErr << ")" << std::endl;
    if (debug)
      std::cout << "Minimum time (pos): " << pat::PackedCandidate::unpackTimeWithError(+1, packedTimeErr) << std::endl;
    if (debug)
      std::cout << "Minimum time (neg): " << pat::PackedCandidate::unpackTimeWithError(-1, packedTimeErr) << std::endl;
    if (debug)
      std::cout << "Maximum time 8 bits (pos): " << pat::PackedCandidate::unpackTimeWithError(+254, packedTimeErr)
                << std::endl;
    if (debug)
      std::cout << "Maximum time 8 bits (neg): " << pat::PackedCandidate::unpackTimeWithError(-254, packedTimeErr)
                << std::endl;
    if (debug)
      std::cout << "Maximum time 10 bits (pos): " << pat::PackedCandidate::unpackTimeWithError(+1022, packedTimeErr)
                << std::endl;
    if (debug)
      std::cout << "Maximum time 10 bits (neg): " << pat::PackedCandidate::unpackTimeWithError(-1022, packedTimeErr)
                << std::endl;
    if (debug)
      std::cout << "Maximum time 12 bits (pos): " << pat::PackedCandidate::unpackTimeWithError(+4094, packedTimeErr)
                << std::endl;
    if (debug)
      std::cout << "Maximum time 12 bits (neg): " << pat::PackedCandidate::unpackTimeWithError(-4094, packedTimeErr)
                << std::endl;
    avgres = 0;
    navg = 0;
    for (int i = 2; i < 4096; i *= 3) {
      float unp = pat::PackedCandidate::unpackTimeWithError(i, packedTimeErr);
      float res = 0.5 * (pat::PackedCandidate::unpackTimeWithError(i + 2, packedTimeErr) -
                         pat::PackedCandidate::unpackTimeWithError(i - 2, packedTimeErr));
      avgres += (res);
      navg++;
      if (debug)
        std::cout << " i = +" << i << " unp = +" << unp << " quant error = " << res << "  packed = +"
                  << int(pat::PackedCandidate::packTimeWithError(unp + 0.2 * res, unpackedTimeErr)) << " and +"
                  << int(pat::PackedCandidate::packTimeWithError(unp - 0.2 * res, unpackedTimeErr)) << std::endl;
      CPPUNIT_ASSERT(pat::PackedCandidate::packTimeWithError(unp + 0.2 * res, unpackedTimeErr) == i);
      CPPUNIT_ASSERT(pat::PackedCandidate::packTimeWithError(unp - 0.2 * res, unpackedTimeErr) == i);
      unp = pat::PackedCandidate::unpackTimeWithError(-i, packedTimeErr);
      res = 0.5 * (pat::PackedCandidate::unpackTimeWithError(-i + 2, packedTimeErr) -
                   pat::PackedCandidate::unpackTimeWithError(-i - 2, packedTimeErr));
      avgres += std::abs(res);
      navg++;
      if (debug)
        std::cout << " i = " << -i << " unp = " << unp << " quant error = " << res
                  << "  packed = " << int(pat::PackedCandidate::packTimeWithError(unp + 0.2 * res, unpackedTimeErr))
                  << " and " << int(pat::PackedCandidate::packTimeWithError(unp - 0.2 * res, unpackedTimeErr))
                  << std::endl;
      CPPUNIT_ASSERT(pat::PackedCandidate::packTimeWithError(unp + 0.2 * res, unpackedTimeErr) == -i);
      CPPUNIT_ASSERT(pat::PackedCandidate::packTimeWithError(unp - 0.2 * res, unpackedTimeErr) == -i);
    }
    if (debug)
      std::cout << "Average abs uncertainty: " << (avgres / navg) << std::endl;
    if (debug)
      std::cout << "Now testing overflows: " << std::endl;
    avgres = 0;
    navg = 0;
    for (float aTime = aTimeErr; aTime <= 200; aTime *= std::sqrt(5.f)) {
      int i = pat::PackedCandidate::packTimeWithError(aTime, unpackedTimeErr);
      float res = 0.5 * std::abs(pat::PackedCandidate::unpackTimeWithError(i + 2, packedTimeErr) -
                                 pat::PackedCandidate::unpackTimeWithError(i - 2, packedTimeErr));
      float unp = pat::PackedCandidate::unpackTimeWithError(i, packedTimeErr);
      if (debug)
        std::cout << " t = +" << aTime << " i = +" << i << "   quant error = " << res << " unpacked = +" << unp
                  << "   diff/res = " << (aTime - unp) / res << std::endl;
      CPPUNIT_ASSERT(std::abs(unp - aTime) < res);
      avgres = std::max(avgres, std::abs(res / unp));
      i = pat::PackedCandidate::packTimeWithError(-aTime, unpackedTimeErr);
      res = 0.5 * std::abs(pat::PackedCandidate::unpackTimeWithError(i + 2, packedTimeErr) -
                           pat::PackedCandidate::unpackTimeWithError(i - 2, packedTimeErr));
      unp = pat::PackedCandidate::unpackTimeWithError(i, packedTimeErr);
      if (debug)
        std::cout << " t = " << -aTime << " i = " << i << "   quant error = " << res << " unpacked = " << unp
                  << "   diff/res = " << (-aTime - unp) / res << std::endl;
      CPPUNIT_ASSERT(std::abs(unp + aTime) < res);
      avgres = std::max(avgres, std::abs(res / unp));
    }
    if (debug)
      std::cout << "Worst rel uncertainty: " << (avgres) << std::endl;
    if (debug)
      std::cout << std::endl;
  }
  if (debug)
    std::cout << std::endl;
}

void testPackedCandidate::testQualityFlags() {
  const std::vector<pat::PackedCandidate::PVAssociationQuality> pvAssocVals = {
      pat::PackedCandidate::NotReconstructedPrimary,
      pat::PackedCandidate::OtherDeltaZ,
      pat::PackedCandidate::CompatibilityBTag,
      pat::PackedCandidate::CompatibilityDz,
      pat::PackedCandidate::UsedInFitLoose,
      pat::PackedCandidate::UsedInFitTight};
  const std::vector<pat::PackedCandidate::LostInnerHits> lostHitsVals = {
      pat::PackedCandidate::validHitInFirstPixelBarrelLayer,
      pat::PackedCandidate::noLostInnerHits,
      pat::PackedCandidate::oneLostInnerHit,
      pat::PackedCandidate::moreLostInnerHits};
  const std::vector<bool> trackQualVals = {false, true};
  const std::vector<bool> glbMuonVals = {false, true};
  const std::vector<bool> staMuonVals = {false, true};
  const std::vector<bool> goodEGVals = {false, true};

  pat::PackedCandidate cand;

  for (auto pvAssoc : pvAssocVals) {
    for (auto lostHits : lostHitsVals) {
      for (auto trackQual : trackQualVals) {
        for (auto glbMuon : glbMuonVals) {
          for (auto staMuon : staMuonVals) {
            for (auto goodEGamma : goodEGVals) {
              cand.setMuonID(staMuon, glbMuon);
              cand.setGoodEgamma(goodEGamma);
              cand.setAssociationQuality(pvAssoc);
              cand.setLostInnerHits(lostHits);
              cand.setTrackHighPurity(trackQual);

              CPPUNIT_ASSERT(lostHits == cand.lostInnerHits());
              CPPUNIT_ASSERT(goodEGamma == cand.isGoodEgamma());
              CPPUNIT_ASSERT(staMuon == cand.isStandAloneMuon());
              CPPUNIT_ASSERT(glbMuon == cand.isGlobalMuon());
              CPPUNIT_ASSERT(trackQual == cand.trackHighPurity());
              CPPUNIT_ASSERT(pvAssoc == cand.pvAssociationQuality());
            }
          }
        }
      }
    }
  }
}