CMS 3D CMS Logo

ClusterSummary.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ClusterSummary
4 // Class: ClusterSummary
5 //
13 //
14 // Original Author: Michael Segala
15 // Created: Wed Feb 23 17:36:23 CST 2011
16 //
17 //
18 
19 #ifndef CLUSTERSUMMARY
20 #define CLUSTERSUMMARY
21 
22 // system include files
23 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
24 #include <atomic>
25 #endif
26 #include <memory>
27 #include <string>
28 #include <map>
29 #include <vector>
30 #include <iostream>
31 #include <cstring>
32 #include <sstream>
34 
35 // user include files
36 
41 
44 
48 
49 /*****************************************************************************************
50 
51 How to use ClusterSummary class:
52 
53 ClusterSummary provides summary information for a number of cluster dependent variables.
54 All the variables are stored within variables_
55 The modules selected are stored within modules_
56 The number of variables for each module is stored within iterator_
57 
58 ********************************************************************************************/
59 
61 public:
63  //nSelections is the number of selections that you want to have
64  //It should be highest enum + 1
65  ClusterSummary(const int nSelections);
67  // copy ctor
69  // copy assingment operator
71 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
73 #endif
74 
75  // Enum for each partition within Tracker
76  enum CMSTracker {
77  STRIP = 0,
78  TIB = 1,
79  TOB = 2,
80  TID = 3,
81  TEC = 4,
82  PIXEL = 5,
83  FPIX = 6,
84  BPIX = 7,
87  };
88  static const std::vector<std::string> subDetNames;
89  static const std::vector<std::vector<std::string> > subDetSelections;
90 
91  // Enum which describes the ordering of the summary variables inside vector variables_
93  static const std::vector<std::string> variableNames;
94 
95  //===================+++++++++++++========================
96  //
97  // Main methods to fill
98  // Variables
99  //
100  //===================+++++++++++++========================
101 
102  //These functions are broken into two categories. The standard versions take the enums as input and find the locations in the vector.
103  //The ones labeled "byIndex" take the vector location as input
104 public:
105  int getNClusByIndex(const int mod) const { return nClus.at(mod); }
106  int getClusSizeByIndex(const int mod) const { return clusSize.at(mod); }
107  float getClusChargeByIndex(const int mod) const { return clusCharge.at(mod); }
108 
109  int getNClus(const CMSTracker mod) const {
110  int pos = getModuleLocation(mod);
111  return pos < 0 ? 0. : nClus[pos];
112  }
113  int getClusSize(const CMSTracker mod) const {
114  int pos = getModuleLocation(mod);
115  return pos < 0 ? 0. : clusSize[pos];
116  }
117  float getClusCharge(const CMSTracker mod) const {
118  int pos = getModuleLocation(mod);
119  return pos < 0 ? 0. : clusCharge[pos];
120  }
121 
122  const std::vector<int>& getNClusVector() const { return nClus; }
123  const std::vector<int>& getClusSizeVector() const { return clusSize; }
124  const std::vector<float>& getClusChargeVector() const { return clusCharge; }
125 
126  void addNClusByIndex(const int mod, const int val) { nClus.at(mod) += val; }
127  void addClusSizeByIndex(const int mod, const int val) { clusSize.at(mod) += val; }
128  void addClusChargeByIndex(const int mod, const float val) { clusCharge.at(mod) += val; }
129 
130  void addNClus(const CMSTracker mod, const int val) { nClus.at(getModuleLocation(mod)) += val; }
131  void addClusSize(const CMSTracker mod, const int val) { clusSize.at(getModuleLocation(mod)) += val; }
132  void addClusCharge(const CMSTracker mod, const float val) { clusCharge.at(getModuleLocation(mod)) += val; }
133 
134  const std::vector<int>& getModules() const { return modules; }
135  // Return the location of desired module within modules_. If warn is set to true, a warnign will be outputed in case no module was found
136  int getModuleLocation(int mod, bool warn = true) const;
137  unsigned int getNumberOfModules() const { return modules.size(); }
138  int getModule(const int index) const { return modules[index]; }
139 
140  //copies over only non-zero entries into the current one
141  void copyNonEmpty(const ClusterSummary& src);
142  //Set values to 0
143  void reset();
144 
145 private:
146  std::vector<int> modules; // <Module1, Module2 ...>
147  std::vector<int> nClus;
148  std::vector<int> clusSize;
149  std::vector<float> clusCharge;
150 };
151 
152 #endif
int getClusSize(const CMSTracker mod) const
float getClusChargeByIndex(const int mod) const
const std::vector< int > & getModules() const
float getClusCharge(const CMSTracker mod) const
void addClusChargeByIndex(const int mod, const float val)
void addClusSizeByIndex(const int mod, const int val)
static const std::vector< std::string > subDetNames
void addClusSize(const CMSTracker mod, const int val)
const std::vector< int > & getNClusVector() const
static const std::vector< std::string > variableNames
def warn(args, kwargs)
Definition: __init__.py:21
void copyNonEmpty(const ClusterSummary &src)
const std::vector< int > & getClusSizeVector() const
std::vector< float > clusCharge
const std::vector< float > & getClusChargeVector() const
int getNClusByIndex(const int mod) const
int getNClus(const CMSTracker mod) const
std::vector< int > modules
int getModule(const int index) const
unsigned int getNumberOfModules() const
static const std::vector< std::vector< std::string > > subDetSelections
ClusterSummary & operator=(const ClusterSummary &rhs)
void addClusCharge(const CMSTracker mod, const float val)
int getModuleLocation(int mod, bool warn=true) const
int getClusSizeByIndex(const int mod) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::vector< int > clusSize
void addNClusByIndex(const int mod, const int val)
std::vector< int > nClus
void addNClus(const CMSTracker mod, const int val)