CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: ClusterSummary.h,v 1.9 2013/04/22 23:30:07 wmtan Exp $
17 //
18 //
19 
20 #ifndef CLUSTERSUMMARY
21 #define CLUSTERSUMMARY
22 
23 // system include files
24 #include <memory>
25 #include <string>
26 #include <map>
27 #include <vector>
28 #include<iostream>
29 #include <string.h>
30 #include <sstream>
32 
33 // user include files
34 
39 
40 
43 
54 
55 /*****************************************************************************************
56 
57 How to use ClusterSummary class:
58 
59 ClusterSummary provides summary inforation for a number of cluster dependent variables.
60 All the variables are stored within variables_
61 The modules selected are stored within modules_
62 The number of variables for each module is stored within iterator_
63 
64 [If putting ClusterSummary into producer]
65 
66 1) In beginJob() of Producer, set the method
67 
68  Cluster.SetUserContent(v_userContent);
69  Cluster.SetUserIterator();
70 
71  where v_userContent is a vector of strings of the varibales you are getting info on
72 
73 
74 2) In produce() of Prodcuer, fill the output vectors
75 
76  // Tell ClusterSummary which Tracker Partitions you want summary information from
77  Cluster.SetUserModules( mod )
78 
79 
80  //Fill generic vector to hold any variables. You can fill the vector based on the name of the variables or the location of the variable within userContent
81  cCluster.SetGenericVariable( "sHits", mod_pair2, 1 );
82  cCluster.SetGenericVariable( "sSize", mod_pair2, Summaryinfo.clusterSize() );
83  cCluster.SetGenericVariable( "sCharge", mod_pair2, Summaryinfo.charge() );
84 
85 
86  // Once the loop over all detIds have finsihed fill the Output vectors
87  Cluster.SetUserVariables( mod );
88 
89 
90  // Dont forget to clear all the vectors and arrays at end of each event
91 
92 
93 
94 
95 [If putting reading back ClusterSummary from anlayzer]
96 
97  You can access all the summary vectors in the following way
98 
99  Handle< ClusterSummary > class_;
100  iEvent.getByLabel( _class, class_);
101 
102  genericVariables_ = class_ -> GetGenericVariable();
103 
104  //You can access the variables by genericVariables_[i][j] where 'i' is the order in which the variable was stored, see enum VariablePlacement
105  cout << genericVariables_[0][1] << endl;
106  cout << genericVariables_[1][1]/genericVariables_[0][1] << endl;
107  cout << genericVariables_[2][2]/genericVariables_[0][2] << endl;
108 
109  --or--
110 
111  //You can access the variables by the variable and partition name.
112  cout << class_ -> GetGenericVariable("cHits", ClusterSummary::TIB) << endl;
113  cout << class_ -> GetGenericVariable("cSize", ClusterSummary::TIB)/class_ -> GetGenericVariable("cHits", ClusterSummary::TIB) << endl;
114  cout << class_ -> GetGenericVariable("cCharge", ClusterSummary::TOB)/class_ -> GetGenericVariable("cHits", ClusterSummary::TOB) << endl;
115 
116 
117 
118 
119 ********************************************************************************************/
120 
121 
123 
124  public:
125 
126  ClusterSummary():genericVariablesTmp_(6, std::vector<double>(100,0) ){}
127 
128  // Enum for each partition within Tracer
129  enum CMSTracker { TRACKER = 0,
130  TIB = 1,
131  TIB_1 = 11, TIB_2 = 12, TIB_3 = 13, TIB_4 = 14, //TIB layer 1-4
132  TOB = 2,
133  TOB_1 = 21, TOB_2 = 22, TOB_3 = 23, TOB_4 = 24, TOB_5 = 25, TOB_6 = 26, //TOB layer 1-6
134  TID = 3,
135  TIDM = 31, TIDP = 32, //TID minus and plus
136  TIDM_1 = 311, TIDM_2 = 312, TIDM_3 = 313, //TID minus layer 1-3
137  TIDP_1 = 321, TIDP_2 = 322, TIDP_3 = 323, //TID plus layer 1-3
138  TIDMR_1 = 3110, TIDMR_2 = 3120, TIDMR_3 = 3130, //TID minus ring 1-3
139  TIDPR_1 = 3210, TIDPR_2 = 3220, TIDPR_3 = 3230, //TID plus ring 1-3
140  TEC = 4,
141  TECM = 41, TECP = 42, //TEC minus and plus
142  TECM_1 = 411, TECM_2 = 412, TECM_3 = 413, TECM_4 = 414, TECM_5 = 415, TECM_6 = 416, TECM_7 = 417, TECM_8 = 418, TECM_9 = 419, //TEC minus layer 1-9
143  TECP_1 = 421, TECP_2 = 422, TECP_3 = 423, TECP_4 = 424, TECP_5 = 425, TECP_6 = 426, TECP_7 = 427, TECP_8 = 428, TECP_9 = 429, //TEC plus layer 1-9
144  TECMR_1 = 4110, TECMR_2 = 4120, TECMR_3 = 4130, TECMR_4 = 4140, TECMR_5 = 4150, TECMR_6 = 4160, TECMR_7 = 4170, //TEC minus ring 1-9
145  TECPR_1 = 4210, TECPR_2 = 4220, TECPR_3 = 4230, TECPR_4 = 4240, TECPR_5 = 4250, TECPR_6 = 4260, TECPR_7 = 4270, //TEC plus ring 1-9
146  //PIXELS
147  PIXEL = 5,
148  FPIX = 6, // Pixel endcaps
149  FPIX_1 = 61,FPIX_2 = 62,FPIX_3 = 63, // Endcaps disks 1-3
150  FPIXM = 611, FPIXP = 612, // Pixel endcaps minus and plus side
151  FPIXM_1 = 6110, FPIXM_2 = 6120, FPIXM_3 = 6130, // Endcap minus disk 1-3
152  FPIXP_1 = 6210, FPIXP_2 = 6220, FPIXP_3 = 6230, // Endcap plus disk 1-3
153  BPIX = 7, //Pixel barrel
154  BPIX_1 = 71, BPIX_2 = 72, BPIX_3 = 73 //Pixel barrel layer 1-3
155 
156  };
157 
158  // Enum which describes the ordering of the summary variables inside vector variables_
165 
166 
167  //===================+++++++++++++========================
168  //
169  // Main methods to fill
170  // Variables
171  //
172  //===================+++++++++++++========================
173 
174 
175  //Get value of any variable given location of the variable within userContent and the module number based on enum CMSTracker
176  double GetGenericVariable( int variableLocation, int module ) const {
177  return GetModuleLocation(module) < 0 ? 0. : genericVariables_[variableLocation][GetModuleLocation(module)]; }
178 
179  //Get value of any variable given variable name and the module number based on enum CMSTracker
180  double GetGenericVariable( std::string variableName, int module ) const {
181 
182  int position = GetVariableLocation(variableName);
183  int mposition = GetModuleLocation(module);
184 
185  return mposition < 0 ? 0. : genericVariables_[position][mposition];
186  }
187 
188  //Get specific varibale for all modules using the variable name
189  std::vector<double> GetGenericVariable( std::string variableName ) const {
190  return genericVariables_[GetVariableLocation(variableName)];
191  }
192 
193  //Get specific varibale for all modules using the location of the variable within userContent
194  std::vector<double> GetGenericVariable( int variableLocation ) const {
195  return genericVariables_[variableLocation];
196  }
197 
198  //Get the vector genericVariables_
199  std::vector< std::vector<double> > GetGenericVariable() const { return genericVariables_; }
200 
201  //Set the vector genericVariables_ based on the location of the variable within userContent and the module number based on enum CMSTracker
202  void SetGenericVariable( int variableLocation, int module, double value ) {
203  if(GetModuleLocation(module) >=0) genericVariablesTmp_[variableLocation][GetModuleLocation(module)] += value; }
204 
205  //Set the vector genericVariables_ given the variable name and the module number based on enum CMSTracker
206  void SetGenericVariable( std::string variableName, int module, double value ) {
207 
208  /*
209  genericVariablesTmp[ variable ][ module ]
210 
211  This will fill the values in the order as they are filled in the produced.
212 
213  1) Find where the variableName lives in userContent
214  2) Find where module lives in modules_
215 
216  */
217 
218  int position = GetVariableLocation(variableName);
219  int mposition = GetModuleLocation(module);
220 
221  if(mposition >=0) genericVariablesTmp_[position][mposition] += value;
222  }
223 
224  //Prepair the final vector to be put into the producer. Remove any remaining 0's and copy the Tmp to the vector over to genericVariables_. Must be done at the end of each event.
226 
228 
229  for (unsigned int i = 0; i < userContent.size(); ++i){
231  }
232  }
233 
234  //Clear genericVariablesTmp_. Must be done at the end of each event.
236 
237  //genericVariablesTmp_.clear();
238 
239  for (unsigned int i = 0; i < genericVariablesTmp_.size(); ++i){
240  for (unsigned int j = 0; j < genericVariablesTmp_[i].size(); ++j){
241  genericVariablesTmp_[i][j] = 0;
242  }
243  }
244  }
245 
246 
247 
248  // Setter and Getter for the User Content. You can also return the size and what is stored in the UserContent
249  void SetUserContent(const std::vector<std::string>& Content) const { userContent = Content;}
250  std::vector<std::string> GetUserContent() { return userContent;}
251  int GetUserContentSize() { return userContent.size(); }
252  void GetUserContentInfo() const {
253  std::cout << "Saving info for " ;
254  for (unsigned int i = 0; i < userContent.size(); ++i){ std::cout << userContent.at(i) << " " ;}
255  std::cout << std::endl;
256  }
257  int GetVariableLocation ( std::string var ) const;
258 
259 
260  //Set and Get modules_
261  void SetUserModules( int value ) { modules_.push_back( value ); }
262  std::vector<int> GetUserModules( ) const { return modules_; }
263  void ClearUserModules( ) { modules_.clear(); }
264  // Return the location of desired module within modules_.
265  int GetModuleLocation ( int mod ) const;
266 
267 
268  //Set and Get iterator_
269  void SetUserIterator() { iterator_.push_back( GetUserContentSize() );}
270  std::vector<int> GetUserIterator() const { return iterator_; }
271  void ClearUserIterator() { iterator_.clear(); }
272 
273  // Return a vector of the modules that summary infomation was requested for. This should come from the provenance information.
274  std::vector<std::string> DecodeProvInfo(std::string ProvInfo) const;
275 
276  // Class which determines if a detId is part of a desired partition
278  public:
280  virtual ~ModuleSelection();
281  virtual std::pair<int,int> IsStripSelected (int DetId);
282  virtual std::pair<int,int> IsPixelSelected (int DetId);
283  private:
284  std::string geosearch; // string of selected modules
285  };
286 
287 
288 
289 
290  private:
291 
292 
293  // String which stores the name of the variables the user is getting the summary info for
294  mutable std::vector<std::string> userContent;
295 
296  std::vector<int> iterator_; // <number of varibale for Module1, number of varibale for Module2 ...>
297  std::vector<int> modules_; // <Module1, Module2 ...>
298 
299  std::vector< std::vector<double> > genericVariables_;
300  mutable std::vector< std::vector<double> > genericVariablesTmp_;
301 
302 };
303 
304 
305 #endif
306 
307 
308 
309 
310 
311 
312 
int GetUserContentSize()
std::vector< std::string > DecodeProvInfo(std::string ProvInfo) const
int i
Definition: DBlmapReader.cc:9
void SetGenericVariable(int variableLocation, int module, double value)
virtual std::pair< int, int > IsPixelSelected(int DetId)
std::vector< double > GetGenericVariable(int variableLocation) const
std::vector< std::string > userContent
std::vector< int > modules_
std::vector< int > GetUserIterator() const
std::vector< std::vector< double > > GetGenericVariable() const
std::vector< std::vector< double > > genericVariablesTmp_
void SetUserContent(const std::vector< std::string > &Content) const
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void ClearUserIterator()
void SetUserIterator()
std::vector< std::vector< double > > genericVariables_
std::vector< int > GetUserModules() const
virtual std::pair< int, int > IsStripSelected(int DetId)
int j
Definition: DBlmapReader.cc:9
double GetGenericVariable(int variableLocation, int module) const
#define end
Definition: vmac.h:38
double GetGenericVariable(std::string variableName, int module) const
int GetVariableLocation(std::string var) const
Definition: DetId.h:20
std::vector< double > GetGenericVariable(std::string variableName) const
void PrepairGenericVariable()
#define begin
Definition: vmac.h:31
void SetUserModules(int value)
tuple cout
Definition: gather_cfg.py:121
void SetGenericVariable(std::string variableName, int module, double value)
void ClearGenericVariable()
void GetUserContentInfo() const
int GetModuleLocation(int mod) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::vector< std::string > GetUserContent()
Definition: vlib.h:209
void ClearUserModules()
std::vector< int > iterator_