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.6 2012/10/04 13:25:29 venturia 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 
40 
41 
45 
58 
59 /*****************************************************************************************
60 
61 How to use ClusterSummary class:
62 
63 ClusterSummary provides summary inforation for a number of cluster dependent variables.
64 All the variables are stored within variables_
65 The modules selected are stored within modules_
66 The number of variables for each module is stored within iterator_
67 
68 [If putting ClusterSummary into producer]
69 
70 1) In beginJob() of Producer, set the method
71 
72  Cluster.SetUserContent(v_userContent);
73  Cluster.SetUserIterator();
74 
75  where v_userContent is a vector of strings of the varibales you are getting info on
76 
77 
78 2) In produce() of Prodcuer, fill the output vectors
79 
80  // Tell ClusterSummary which Tracker Partitions you want summary information from
81  Cluster.SetUserModules( mod )
82 
83 
84  //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
85  cCluster.SetGenericVariable( "sHits", mod_pair2, 1 );
86  cCluster.SetGenericVariable( "sSize", mod_pair2, Summaryinfo.clusterSize() );
87  cCluster.SetGenericVariable( "sCharge", mod_pair2, Summaryinfo.charge() );
88 
89 
90  // Once the loop over all detIds have finsihed fill the Output vectors
91  Cluster.SetUserVariables( mod );
92 
93 
94  // Dont forget to clear all the vectors and arrays at end of each event
95 
96 
97 
98 
99 [If putting reading back ClusterSummary from anlayzer]
100 
101  You can access all the summary vectors in the following way
102 
103  Handle< ClusterSummary > class_;
104  iEvent.getByLabel( _class, class_);
105 
106  genericVariables_ = class_ -> GetGenericVariable();
107 
108  //You can access the variables by genericVariables_[i][j] where 'i' is the order in which the variable was stored, see enum VariablePlacement
109  cout << genericVariables_[0][1] << endl;
110  cout << genericVariables_[1][1]/genericVariables_[0][1] << endl;
111  cout << genericVariables_[2][2]/genericVariables_[0][2] << endl;
112 
113  --or--
114 
115  //You can access the variables by the variable and partition name.
116  cout << class_ -> GetGenericVariable("cHits", ClusterSummary::TIB) << endl;
117  cout << class_ -> GetGenericVariable("cSize", ClusterSummary::TIB)/class_ -> GetGenericVariable("cHits", ClusterSummary::TIB) << endl;
118  cout << class_ -> GetGenericVariable("cCharge", ClusterSummary::TOB)/class_ -> GetGenericVariable("cHits", ClusterSummary::TOB) << endl;
119 
120 
121 
122 
123 ********************************************************************************************/
124 
125 
127 
128  public:
129 
130  ClusterSummary():genericVariablesTmp_(6, std::vector<double>(100,0) ){}
131 
132  // Enum for each partition within Tracer
133  enum CMSTracker { TRACKER = 0,
134  TIB = 1,
135  TIB_1 = 11, TIB_2 = 12, TIB_3 = 13, TIB_4 = 14, //TIB layer 1-4
136  TOB = 2,
137  TOB_1 = 21, TOB_2 = 22, TOB_3 = 23, TOB_4 = 24, TOB_5 = 25, TOB_6 = 26, //TOB layer 1-6
138  TID = 3,
139  TIDM = 31, TIDP = 32, //TID minus and plus
140  TIDM_1 = 311, TIDM_2 = 312, TIDM_3 = 313, //TID minus layer 1-3
141  TIDP_1 = 321, TIDP_2 = 322, TIDP_3 = 323, //TID plus layer 1-3
142  TIDMR_1 = 3110, TIDMR_2 = 3120, TIDMR_3 = 3130, //TID minus ring 1-3
143  TIDPR_1 = 3210, TIDPR_2 = 3220, TIDPR_3 = 3230, //TID plus ring 1-3
144  TEC = 4,
145  TECM = 41, TECP = 42, //TEC minus and plus
146  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
147  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
148  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
149  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
150  //PIXELS
151  PIXEL = 5,
152  FPIX = 6, // Pixel endcaps
153  FPIX_1 = 61,FPIX_2 = 62,FPIX_3 = 63, // Endcaps disks 1-3
154  FPIXM = 611, FPIXP = 612, // Pixel endcaps minus and plus side
155  FPIXM_1 = 6110, FPIXM_2 = 6120, FPIXM_3 = 6130, // Endcap minus disk 1-3
156  FPIXP_1 = 6210, FPIXP_2 = 6220, FPIXP_3 = 6230, // Endcap plus disk 1-3
157  BPIX = 7, //Pixel barrel
158  BPIX_1 = 71, BPIX_2 = 72, BPIX_3 = 73 //Pixel barrel layer 1-3
159 
160  };
161 
162  // Enum which describes the ordering of the summary variables inside vector variables_
169 
170 
171  //===================+++++++++++++========================
172  //
173  // Main methods to fill
174  // Variables
175  //
176  //===================+++++++++++++========================
177 
178 
179  //Get value of any variable given location of the variable within userContent and the module number based on enum CMSTracker
180  double GetGenericVariable( int variableLocation, int module ) const {
181  return GetModuleLocation(module) < 0 ? 0. : genericVariables_[variableLocation][GetModuleLocation(module)]; }
182 
183  //Get value of any variable given variable name and the module number based on enum CMSTracker
184  double GetGenericVariable( std::string variableName, int module ) const {
185 
186  int position = GetVariableLocation(variableName);
187  int mposition = GetModuleLocation(module);
188 
189  return mposition < 0 ? 0. : genericVariables_[position][mposition];
190  }
191 
192  //Get specific varibale for all modules using the variable name
193  std::vector<double> GetGenericVariable( std::string variableName ) const {
194  return genericVariables_[GetVariableLocation(variableName)];
195  }
196 
197  //Get specific varibale for all modules using the location of the variable within userContent
198  std::vector<double> GetGenericVariable( int variableLocation ) const {
199  return genericVariables_[variableLocation];
200  }
201 
202  //Get the vector genericVariables_
203  std::vector< std::vector<double> > GetGenericVariable() const { return genericVariables_; }
204 
205  //Set the vector genericVariables_ based on the location of the variable within userContent and the module number based on enum CMSTracker
206  void SetGenericVariable( int variableLocation, int module, double value ) {
207  if(GetModuleLocation(module) >=0) genericVariablesTmp_[variableLocation][GetModuleLocation(module)] += value; }
208 
209  //Set the vector genericVariables_ given the variable name and the module number based on enum CMSTracker
210  void SetGenericVariable( std::string variableName, int module, double value ) {
211 
212  /*
213  genericVariablesTmp[ variable ][ module ]
214 
215  This will fill the values in the order as they are filled in the produced.
216 
217  1) Find where the variableName lives in userContent
218  2) Find where module lives in modules_
219 
220  */
221 
222  int position = GetVariableLocation(variableName);
223  int mposition = GetModuleLocation(module);
224 
225  if(mposition >=0) genericVariablesTmp_[position][mposition] += value;
226  }
227 
228  //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.
230 
232 
233  for (unsigned int i = 0; i < userContent.size(); ++i){
235  }
236  }
237 
238  //Clear genericVariablesTmp_. Must be done at the end of each event.
240 
241  //genericVariablesTmp_.clear();
242 
243  for (unsigned int i = 0; i < genericVariablesTmp_.size(); ++i){
244  for (unsigned int j = 0; j < genericVariablesTmp_[i].size(); ++j){
245  genericVariablesTmp_[i][j] = 0;
246  }
247  }
248  }
249 
250 
251 
252  // Setter and Getter for the User Content. You can also return the size and what is stored in the UserContent
253  void SetUserContent(std::vector<std::string> Content) const { userContent = Content;}
254  std::vector<std::string> GetUserContent() { return userContent;}
255  int GetUserContentSize() { return userContent.size(); }
256  void GetUserContentInfo() const {
257  std::cout << "Saving info for " ;
258  for (unsigned int i = 0; i < userContent.size(); ++i){ std::cout << userContent.at(i) << " " ;}
259  std::cout << std::endl;
260  }
261  int GetVariableLocation ( std::string var ) const;
262 
263 
264  //Set and Get modules_
265  void SetUserModules( int value ) { modules_.push_back( value ); }
266  std::vector<int> GetUserModules( ) const { return modules_; }
267  void ClearUserModules( ) { modules_.clear(); }
268  // Return the location of desired module within modules_.
269  int GetModuleLocation ( int mod ) const;
270 
271 
272  //Set and Get iterator_
273  void SetUserIterator() { iterator_.push_back( GetUserContentSize() );}
274  std::vector<int> GetUserIterator() const { return iterator_; }
275  void ClearUserIterator() { iterator_.clear(); }
276 
277  // Return a vector of the modules that summary infomation was requested for. This should come from the provenance information.
278  std::vector<std::string> DecodeProvInfo(std::string ProvInfo) const;
279 
280  // Class which determines if a detId is part of a desired partition
282  public:
283  ModuleSelection(std::string gs);
284  virtual ~ModuleSelection();
285  virtual std::pair<int,int> IsStripSelected (int DetId);
286  virtual std::pair<int,int> IsPixelSelected (int DetId);
287  private:
288  std::string geosearch; // string of selected modules
289  };
290 
291 
292 
293 
294  private:
295 
296 
297  // String which stores the name of the variables the user is getting the summary info for
298  mutable std::vector<std::string> userContent;
299 
300  std::vector<int> iterator_; // <number of varibale for Module1, number of varibale for Module2 ...>
301  std::vector<int> modules_; // <Module1, Module2 ...>
302 
303  std::vector< std::vector<double> > genericVariables_;
304  mutable std::vector< std::vector<double> > genericVariablesTmp_;
305 
306 };
307 
308 
309 #endif
310 
311 
312 
313 
314 
315 
316 
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_
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void ClearUserIterator()
void SetUserContent(std::vector< std::string > Content) const
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
list mod
Load physics model.
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
std::vector< std::string > GetUserContent()
Definition: vlib.h:209
void ClearUserModules()
std::vector< int > iterator_