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