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
//FAMOS headers
#include "FastSimulation/Utilities/interface/Looses.h"

#include <iomanip>
#include <iostream>

Looses* Looses::myself = nullptr;

Looses::Looses() {}

Looses* Looses::instance() {
  if (!myself)
    myself = new Looses();
  return myself;
}

Looses::~Looses() { summary(); }

void Looses::count(const std::string& name, unsigned cut) {
  if (theLosses.find(name) == theLosses.end()) {
    std::vector<unsigned> myCounts;
    for (unsigned i = 0; i < 20; ++i)
      myCounts.push_back(0);
    theLosses[name] = myCounts;
  }

  if (cut < 20)
    ++theLosses[name][cut];
}

void Looses::summary() {
  std::map<std::string, std::vector<unsigned> >::const_iterator lossItr;
  std::cout << "***** From LOOSES ***** : Cuts effects" << std::endl << std::endl;

  for (lossItr = theLosses.begin(); lossItr != theLosses.end(); ++lossItr) {
    std::cout << lossItr->first << ":" << std::endl;
    for (unsigned i = 0; i < 4; ++i) {
      for (unsigned j = 0; j < 5; ++j) {
        std::cout << std::setw(8) << lossItr->second[5 * i + j] << " ";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
}