ATLAS Offline Software
ClassCounts.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 
9 using std::cout;
10 using std::endl;
11 
12 using namespace LArSamples;
13 
14 std::map<TString, int>* ClassCounts::m_counts = nullptr;
15 
17  : m_className(className)
18 {
19  counts()[className] = 0;
20 }
21 
22 
24 {
25  m_counts->erase(className());
26  if (m_counts->empty()) {
27  delete m_counts;
28  m_counts = nullptr;
29  }
30 }
31 
32 
33 std::map<TString, int>& ClassCounts::counts()
34 {
35  if (!m_counts) m_counts = new std::map<TString, int>();
36  return *m_counts;
37 }
38 
39 
41 {
42  cout << "Class instance counts : " << endl;
43  if (!m_counts) return;
44  for (const std::pair<const TString, int>& p : counts())
45  cout << Form("%20s : %-d", p.first.Data(), p.second) << endl;
46 }
LArSamples::ClassCounts::m_counts
static std::map< TString, int > * m_counts
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:46
LArSamples::ClassCounts::counts
static std::map< TString, int > & counts()
Definition: ClassCounts.cxx:33
LArSamples::ClassCounts::className
const TString & className() const
Definition: LArCafJobs/LArCafJobs/ClassCounts.h:29
LArSamples
Definition: AbsShape.h:24
LArSamples::ClassCounts::ClassCounts
ClassCounts(const TString &name)
Constructor
Definition: ClassCounts.cxx:16
LArSamples::ClassCounts::printCountsTable
static void printCountsTable()
Definition: ClassCounts.cxx:40
JetTagCalibConfig.className
string className
Definition: JetTagCalibConfig.py:36
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LArSamples::ClassCounts::~ClassCounts
virtual ~ClassCounts()
Definition: ClassCounts.cxx:23
ClassCounts.h