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 <string.h>
32 #include <sstream>
34 
35 // user include files
36 
41 
42 
45 
56 
57 /*****************************************************************************************
58 
59 How to use ClusterSummary class:
60 
61 ClusterSummary provides summary inforation for a number of cluster dependent variables.
62 All the variables are stored within variables_
63 The modules selected are stored within modules_
64 The number of variables for each module is stored within iterator_
65 
66 ********************************************************************************************/
67 
68 
70 public:
72  //nSelections is the number of selections that you want to have
73  //It should be highest enum + 1
74  ClusterSummary(const int nSelections);
76  // copy ctor
78  // copy assingment operator
80 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
82 #endif
83 
84  // Enum for each partition within Tracker
85  enum CMSTracker {STRIP = 0, TIB = 1, TOB = 2, TID = 3, TEC = 4, PIXEL = 5, FPIX = 6, BPIX = 7, NVALIDENUMS = 8, NTRACKERENUMS = 100};
86  static const std::vector<std::string> subDetNames;
87  static const std::vector<std::vector<std::string> > subDetSelections ;
88 
89  // Enum which describes the ordering of the summary variables inside vector variables_
91  static const std::vector<std::string> variableNames;
92 
93 
94  //===================+++++++++++++========================
95  //
96  // Main methods to fill
97  // Variables
98  //
99  //===================+++++++++++++========================
100 
101  //These functions are broken into two categories. The standard versions take the enums as input and find the locations in the vector.
102  //The ones labeled "byIndex" take the vector location as input
103  public:
104  int getNClusByIndex (const int mod) const {return nClus .at(mod);}
105  int getClusSizeByIndex (const int mod) const {return clusSize .at(mod);}
106  float getClusChargeByIndex(const int mod) const {return clusCharge.at(mod);}
107 
108  int getNClus (const CMSTracker mod) const {int pos = getModuleLocation(mod); return pos < 0 ? 0. : nClus [pos];}
109  int getClusSize (const CMSTracker mod) const {int pos = getModuleLocation(mod); return pos < 0 ? 0. : clusSize [pos];}
110  float getClusCharge(const CMSTracker mod) const {int pos = getModuleLocation(mod); return pos < 0 ? 0. : clusCharge[pos];}
111 
112  const std::vector<int> & getNClusVector() const {return nClus;}
113  const std::vector<int> & getClusSizeVector() const {return clusSize;}
114  const std::vector<float>& getClusChargeVector() const {return clusCharge;}
115 
116  void addNClusByIndex (const int mod, const int val) {nClus .at(mod)+=val;}
117  void addClusSizeByIndex (const int mod, const int val) {clusSize .at(mod)+=val;}
118  void addClusChargeByIndex(const int mod, const float val) {clusCharge.at(mod)+=val;}
119 
120  void addNClus (const CMSTracker mod, const int val) {nClus .at(getModuleLocation(mod))+=val;}
121  void addClusSize (const CMSTracker mod, const int val) {clusSize .at(getModuleLocation(mod))+=val;}
122  void addClusCharge(const CMSTracker mod, const float val) {clusCharge.at(getModuleLocation(mod))+=val;}
123 
124  const std::vector<int>& getModules() const { return modules; }
125  // 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
126  int getModuleLocation ( int mod, bool warn = true ) const;
127  unsigned int getNumberOfModules() const {return modules.size();}
128  int getModule(const int index) const { return modules[index];}
129 
130  //copies over only non-zero entries into the current one
131  void copyNonEmpty(const ClusterSummary& src);
132  //Set values to 0
133  void reset();
134 
135  private:
136  std::vector<int> modules ; // <Module1, Module2 ...>
137  std::vector<int> nClus ;
138  std::vector<int> clusSize ;
139  std::vector<float> clusCharge;
140 };
141 
142 
143 #endif
144 
145 
146 
147 
148 
149 
150 
int getModule(const int index) const
void addClusChargeByIndex(const int mod, const float val)
float getClusCharge(const CMSTracker mod) const
void addClusSizeByIndex(const int mod, const int val)
const std::vector< int > & getClusSizeVector() const
static const std::vector< std::string > subDetNames
void addClusSize(const CMSTracker mod, const int val)
static const std::vector< std::string > variableNames
void copyNonEmpty(const ClusterSummary &src)
const std::vector< float > & getClusChargeVector() const
std::vector< float > clusCharge
int getClusSizeByIndex(const int mod) const
unsigned int getNumberOfModules() const
int getNClusByIndex(const int mod) const
int getModuleLocation(int mod, bool warn=true) const
int getClusSize(const CMSTracker mod) const
std::vector< int > modules
int getNClus(const CMSTracker mod) const
float getClusChargeByIndex(const int mod) const
static const std::vector< std::vector< std::string > > subDetSelections
const std::vector< int > & getNClusVector() const
ClusterSummary & operator=(const ClusterSummary &rhs)
void addClusCharge(const CMSTracker mod, const float val)
const std::vector< int > & getModules() 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)