CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterSummaryProducer.cc
Go to the documentation of this file.
2 
4  : stripClustersLabel(iConfig.getParameter<edm::InputTag>("stripClusters")),
5  pixelClustersLabel(iConfig.getParameter<edm::InputTag>("pixelClusters")),
6  stripModules(iConfig.getParameter<std::string>("stripModule")),
7  pixelModules(iConfig.getParameter<std::string>("pixelModule")),
8  stripVariables(iConfig.getParameter<std::string>("stripVariables")),
9  pixelVariables(iConfig.getParameter<std::string>("pixelVariables")),
10  doStrips(iConfig.getParameter<bool>("doStrips")),
11  doPixels(iConfig.getParameter<bool>("doPixels")),
12  verbose(iConfig.getParameter<bool>("verbose"))
13 {
14 
15  //register your products
16  produces<ClusterSummary>().setBranchAlias("SummaryCollection");
17 
18  firstpass = true;
19  firstpass_mod = true;
20  firstpassPixel = true;
21  firstpassPixel_mod = true;
22 
23 }
24 
25 
26 void
28 {
29  using namespace edm;
30 
32 
33  //===================++++++++++++========================
34  //
35  // For SiStrips
36  //
37  //===================++++++++++++========================
38  if (doStrips){
40  iEvent.getByLabel(stripClustersLabel, stripClusters);
41 
42  ModuleSelectionVect.clear();
43  for ( std::vector<std::string>::iterator it=v_stripModuleTypes.begin() ; it < v_stripModuleTypes.end(); it++ ){
45  }
46 
47  firstpass_mod = true;
48 
49  int CurrMod = -1;
50  //Loop over all the ModuleSelectors
51  for ( unsigned int i = 0; i < ModuleSelectionVect.size(); i++){
52 
53  // Loop over the strip clusters
54  edmNew::DetSetVector<SiStripCluster>::const_iterator itClusters=stripClusters->begin();
55  for(;itClusters!=stripClusters->end();++itClusters){
56  uint32_t id = itClusters->id();
57  for(edmNew::DetSet<SiStripCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
58 
59  const ClusterVariables Summaryinfo(*cluster);
60 
61  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
62 
63  std::pair<int, int> ModSelect = ModuleSelectionVect.at(i) -> IsStripSelected( id );
64  int mod_pair = ModSelect.first;
65  int mod_pair2 = ModSelect.second;
66 
67  if ( mod_pair ){
68  if ( firstpass_mod ) {
69  CurrMod = mod_pair2;
70  cCluster.SetUserModules( mod_pair2 ) ;
71  }
72 
73  firstpass_mod = false;
74  int CurrModTmp = mod_pair2;
75 
76  if ( CurrMod != CurrModTmp ) {
77  cCluster.SetUserModules( mod_pair2 ) ;
78  CurrMod = CurrModTmp;
79  }
80 
81  cCluster.SetGenericVariable( "cHits", mod_pair2, 1 );
82  cCluster.SetGenericVariable( "cSize", mod_pair2, Summaryinfo.clusterSize() );
83  cCluster.SetGenericVariable( "cCharge", mod_pair2, Summaryinfo.charge() );
84 
85  }
86  }
87  }
88  }
89 
90  }
91 
92  //===================++++++++++++========================
93  //
94  // For SiPixels
95  //
96  //===================++++++++++++========================
97  if (doPixels){
99  iEvent.getByLabel(pixelClustersLabel, pixelClusters);
100 
102  for ( std::vector<std::string>::iterator it=v_pixelModuleTypes.begin() ; it < v_pixelModuleTypes.end(); it++ ){
104  }
105 
106  firstpassPixel_mod = true;
107 
108  int CurrModPixel = -1;
109  //Loop over all the ModuleSelectors
110  for ( unsigned int i = 0; i < ModuleSelectionVectPixels.size(); i++){
111 
112  // Loop over the pixel clusters
113  edmNew::DetSetVector<SiPixelCluster>::const_iterator itClusters=pixelClusters->begin();
114  for(;itClusters!=pixelClusters->end();++itClusters){
115  uint32_t detid = itClusters->detId();
116  for(edmNew::DetSet<SiPixelCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
117 
118  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
119 
120  std::pair<int, int> ModSelectPixel = ModuleSelectionVectPixels.at(i) -> IsPixelSelected( detid );
121  int mod_pair = ModSelectPixel.first;
122  int mod_pair2 = ModSelectPixel.second;
123  if ( mod_pair ){
124  if ( firstpassPixel_mod ) {
125  CurrModPixel = mod_pair2;
126  cCluster.SetUserModules( mod_pair2 ) ;
127  }
128  firstpassPixel_mod = false;
129  int CurrModTmp = mod_pair2;
130  if ( CurrModPixel != CurrModTmp ) {
131  cCluster.SetUserModules( mod_pair2 ) ;
132  CurrModPixel = CurrModTmp;
133  }
134 
135  cCluster.SetGenericVariable( "pHits", mod_pair2, 1 );
136  cCluster.SetGenericVariable( "pSize", mod_pair2, cluster->size() );
137  cCluster.SetGenericVariable( "pCharge", mod_pair2, float(cluster->charge())/1000. );
138 
139  }
140  }
141  }
142  }
143 
144  }
145 
146 
147  //===================+++++++++++++========================
148  //
149  // Fill Producer
150  //
151  //===================+++++++++++++========================
152 
153 
154  unsigned int n = 0;
155  int n_pixel = 0;
156 
158 
159  std::vector<int> _mod = cCluster.GetUserModules( );
160  for(std::vector<int>::iterator it = _mod.begin(); it != _mod.end(); ++it) {
161 
162  if ( n < v_stripModuleTypes.size() && doStrips ){
163  if (verbose) std::cout << "n" << v_stripModuleTypes.at(n) <<", avg size, avg charge = "<< cCluster.GetGenericVariable( "cHits",*it ) << ", " << cCluster.GetGenericVariable( "cSize",*it )/cCluster.GetGenericVariable( "cHits",*it ) << ", "<< cCluster.GetGenericVariable( "cCharge",*it )/cCluster.GetGenericVariable( "cHits",*it ) << std::endl;
164  delete ModuleSelectionVect[n];
165  }
166  else if (doPixels) {
167  if (verbose) {
168  std::cout << "n" << v_pixelModuleTypes.at(n_pixel) << ", avg size, avg charge = "<< cCluster.GetGenericVariable( "pHits",*it ) << ", " << cCluster.GetGenericVariable( "pSize",*it )/cCluster.GetGenericVariable( "pHits",*it ) << ", "<< cCluster.GetGenericVariable( "pCharge",*it )/cCluster.GetGenericVariable( "pHits",*it ) << std::endl;
169  }
170  delete ModuleSelectionVectPixels[n_pixel];
171  ++n_pixel;
172  }
173  ++n;
174  }
175 
176  if (verbose) std::cout << "-------------------------------------------------------" << std::endl;
177 
178  firstpass = false;
179  firstpassPixel = false;
180 
181  //Put the filled class into the producer
182  std::auto_ptr<ClusterSummary> result(new ClusterSummary (cCluster) );
183  iEvent.put( result );
184 
186 
187 }
188 
189 
190 void
192 {
193 
198 
199  if (doStrips){
200  if (verbose){
201  std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
202  std::cout << "FOR STRIPS: " << std::endl;
203  std::cout << "Getting info on " ;
204  for (unsigned int ii = 0; ii < v_stripModuleTypes.size( ); ++ii) {
205  std::cout << v_stripModuleTypes[ii] << " " ;
206  }
207  std::cout << std::endl;
208  }
209 
210  if (verbose) std::cout << "Getting info on strip variables " ;
211  for (unsigned int ii = 0; ii < v_stripVariables.size( ); ++ii) {
212  if (verbose) std::cout << v_stripVariables[ii] << " " ;
213  v_userContent.push_back(v_stripVariables[ii]);
214  }
215  if (verbose) std::cout << std::endl;
216  }
217 
218  if (doPixels){
219  if (verbose){
220  std::cout << "FOR PIXELS: " << std::endl;
221  std::cout << "Getting info on " ;
222  for (unsigned int ii = 0; ii < v_pixelModuleTypes.size( ); ++ii) {
223  std::cout << v_pixelModuleTypes[ii] << " " ;
224  }
225  std::cout << std::endl;
226  }
227 
228  if (verbose) std::cout << "Getting info on pixel variables " ;
229  for (unsigned int ii = 0; ii < v_pixelVariables.size( ); ++ii) {
230  if (verbose) std::cout << v_pixelVariables[ii] << " " ;
231  v_userContent.push_back(v_pixelVariables[ii]);
232  }
233  if (verbose) std::cout << std::endl;
234  if (verbose) std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
235  }
236 
237  //Create the summary info for output
240 }
241 
242 
243 
244 
245 void
246 ClusterSummaryProducer::decodeInput(std::vector<std::string> & vec, std::string mod)
247 {
248 
249  // Define the Modules to get the summary info out of
251  std::string::size_type j = mod.find(',');
252 
253  if ( j == std::string::npos ){
254  vec.push_back(mod);
255  }
256  else{
257  while (j != std::string::npos) {
258  vec.push_back(mod.substr(i, j-i));
259  i = ++j;
260  j = mod.find(',', j);
261  if (j == std::string::npos)
262  vec.push_back(mod.substr(i, mod.length( )));
263  }
264  }
265 
266 
267 }
268 
269 
270 
274 
275 
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin() const
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVect
void SetGenericVariable(int variableLocation, int module, double value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > v_userContent
void decodeInput(std::vector< std::string > &, std::string)
data_type const * const_iterator
Definition: DetSetNew.h:25
id_type id(size_t cell) const
uint16_t size_type
ClusterSummaryProducer(const edm::ParameterSet &)
void SetUserContent(std::vector< std::string > Content) const
std::vector< std::string > v_pixelVariables
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
void SetUserIterator()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< std::string > v_pixelModuleTypes
uint16_t charge() const
tuple result
Definition: query.py:137
std::vector< int > GetUserModules() const
int j
Definition: DBlmapReader.cc:9
double GetGenericVariable(int variableLocation, int module) const
list mod
Load physics model.
const_iterator end() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< std::string > v_stripModuleTypes
void PrepairGenericVariable()
void SetUserModules(int value)
tuple cout
Definition: gather_cfg.py:121
std::vector< std::string > v_stripVariables
const unsigned clusterSize() const
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVectPixels
void ClearGenericVariable()
void ClearUserModules()