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