CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripRecHitsValid.cc
Go to the documentation of this file.
1 // File: SiStripRecHitsValid.cc
2 // Description: see SiStripRecHitsValid.h
3 // Author: P. Azzi
4 // Creation Date: PA May 2006 Initial version.
5 //
6 //--------------------------------------------
8 
15 
18 
25 
38 
40 
42 
43 namespace helper {
44  struct GetDetId {
45  template<typename X>
46  DetId operator()(const X &x) { return DetId(x.detId()); }
47  };
48 
49  template<typename T>
50  std::pair<typename T::DetSet::const_iterator, typename T::DetSet::const_iterator>
51  getRange(const T &detset, const DetId &id) {
52  typedef std::pair<typename T::DetSet::const_iterator, typename T::DetSet::const_iterator> return_type;
53  typename T::const_iterator match = detset.find(id);
54  if (match == detset.end()) return return_type();
55  typename T::DetSet hits = *match;
56  return return_type(hits.begin(), hits.end());
57  }
58 }
59 
60 
61 
62 //Constructor
64  : outputFile_( ps.getUntrackedParameter<std::string>( "outputFile", "sistriprechitshisto.root" ) )
65  , dbe_(0)
66  , conf_(ps)
67  , siStripMatchedRecHit2DCollectionToken_( consumes<SiStripMatchedRecHit2DCollection>( ps.getParameter<edm::InputTag>( "matchedRecHits" ) ) )
68  , siStripRecHit2DCollection_rphi_Token_( consumes<SiStripRecHit2DCollection>( ps.getParameter<edm::InputTag>( "rphiRecHits" ) ) )
69  , siStripRecHit2DCollection_stereo_Token_( consumes<SiStripRecHit2DCollection>( ps.getParameter<edm::InputTag>("stereoRecHits") ) ) {
70 
71 }
72 
73 
75  //if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
76 }
77 
79 
80 }
81 
84  //dbe_->showDirStructure();
85  dbe_->setCurrentFolder("TrackerRecHitsV/TrackerRecHits/Strip/SISTRIP");
86 
87  meNumTotRphi = dbe_->book1D("NumTotRphi","Num of RecHits rphi",100, 0, 10000);
88  meNumTotSas = dbe_->book1D("NumTotSas","Num of RecHits sas",100, 0, 10000);
89  meNumTotMatched = dbe_->book1D("NumTotMatched","Num of RecHits rmatched",100, 0, 10000);
90 
91  dbe_->setCurrentFolder("TrackerRecHitsV/TrackerRecHits/Strip/TIB");
92  meNumRphiTIB = dbe_->book1D("NumRphiTIB","Num of RecHits rphi", 100, 0, 1000.);
93  meNumSasTIB = dbe_->book1D("NumSasTIB","Num of RecHits sas", 100, 0, 1000.);
94  meNumMatchedTIB = dbe_->book1D("NumMatchedTIB","Num of RecHits matched", 100, 0, 1000.);
95 
96  //one histo per Layer rphi hits
97  for(int i = 0 ;i<4 ; i++) {
98  Char_t histo[200];
99  sprintf(histo,"Nstp_rphi_layer%dtib",i+1);
100  meNstpRphiTIB[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
101  sprintf(histo,"Adc_rphi_layer%dtib",i+1);
102  meAdcRphiTIB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
103  sprintf(histo,"Posx_rphi_layer%dtib",i+1);
104  mePosxRphiTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
105  sprintf(histo,"Errx_rphi_layer%dtib",i+1);
106  meErrxRphiTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.01); //<error>~20micron
107  sprintf(histo,"Res_rphi_layer%dtib",i+1);
108  meResRphiTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);
109  sprintf(histo,"Pull_LF_rphi_layer%dtib",i+1);
110  mePullLFRphiTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
111  sprintf(histo,"Pull_MF_rphi_layer%dtib",i+1);
112  mePullMFRphiTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
113  sprintf(histo,"Chi2_rphi_layer%dtib",i+1);
114  meChi2RphiTIB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
115  }
116 
117  //one histo per Layer stereo and matched hits
118  for(int i = 0 ;i<2 ; i++) {
119  Char_t histo[200];
120  sprintf(histo,"Nstp_sas_layer%dtib",i+1);
121  meNstpSasTIB[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
122  sprintf(histo,"Adc_sas_layer%dtib",i+1);
123  meAdcSasTIB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
124  sprintf(histo,"Posx_sas_layer%dtib",i+1);
125  mePosxSasTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
126  sprintf(histo,"Errx_sas_layer%dtib",i+1);
127  meErrxSasTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.01);
128  sprintf(histo,"Res_sas_layer%dtib",i+1);
129  meResSasTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);
130  sprintf(histo,"Pull_LF_sas_layer%dtib",i+1);
131  mePullLFSasTIB[i] = dbe_->book1D(histo,"Pull",100,-4.,4.);
132  sprintf(histo,"Pull_MF_sas_layer%dtib",i+1);
133  mePullMFSasTIB[i] = dbe_->book1D(histo,"Pull",100,-4.,4.);
134  sprintf(histo,"Chi2_sas_layer%dtib",i+1);
135  meChi2SasTIB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
136 
137  sprintf(histo,"Posx_matched_layer%dtib",i+1);
138  mePosxMatchedTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);
139  sprintf(histo,"Posy_matched_layer%dtib",i+1);
140  mePosyMatchedTIB[i] = dbe_->book1D(histo,"RecHit y coord.",100,-6.0, +6.0);
141  sprintf(histo,"Errx_matched_layer%dtib",i+1);
142  meErrxMatchedTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.01);
143  sprintf(histo,"Erry_matched_layer%dtib",i+1);
144  meErryMatchedTIB[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.05);
145  sprintf(histo,"Resx_matched_layer%dtib",i+1);
146  meResxMatchedTIB[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.02, +0.02);
147  sprintf(histo,"Resy_matched_layer%dtib",i+1);
148  meResyMatchedTIB[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);
149  sprintf(histo,"Chi2_matched_layer%dtib",i+1);
150  meChi2MatchedTIB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
151  }
152 
153  dbe_->setCurrentFolder("TrackerRecHitsV/TrackerRecHits/Strip/TOB");
154  meNumRphiTOB = dbe_->book1D("NumRphiTOB","Num of RecHits rphi", 100, 0, 1000.);
155  meNumSasTOB = dbe_->book1D("NumSasTOB","Num of RecHits sas", 100, 0, 1000.);
156  meNumMatchedTOB = dbe_->book1D("NumMatchedTOB","Num of RecHits matched", 100, 0, 1000.);
157  //one histo per Layer rphi hits
158  for(int i = 0 ;i<6 ; i++) {
159  Char_t histo[200];
160  sprintf(histo,"Nstp_rphi_layer%dtob",i+1);
161  meNstpRphiTOB[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
162  sprintf(histo,"Adc_rphi_layer%dtob",i+1);
163  meAdcRphiTOB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
164  sprintf(histo,"Posx_rphi_layer%dtob",i+1);
165  mePosxRphiTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
166  sprintf(histo,"Errx_rphi_layer%dtob",i+1);
167  meErrxRphiTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.01);
168  sprintf(histo,"Res_rphi_layer%dtob",i+1);
169  meResRphiTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);
170  sprintf(histo,"Pull_LF_rphi_layer%dtob",i+1);
171  mePullLFRphiTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
172  sprintf(histo,"Pull_MF_rphi_layer%dtob",i+1);
173  mePullMFRphiTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
174  sprintf(histo,"Chi2_rphi_layer%dtob",i+1);
175  meChi2RphiTOB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
176  }
177 
178  //one histo per Layer stereo and matched hits
179  for(int i = 0 ;i<2 ; i++) {
180  Char_t histo[200];
181  sprintf(histo,"Nstp_sas_layer%dtob",i+1);
182  meNstpSasTOB[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
183  sprintf(histo,"Adc_sas_layer%dtob",i+1);
184  meAdcSasTOB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
185  sprintf(histo,"Posx_sas_layer%dtob",i+1);
186  mePosxSasTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
187  sprintf(histo,"Errx_sas_layer%dtob",i+1);
188  meErrxSasTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.01);
189  sprintf(histo,"Res_sas_layer%dtob",i+1);
190  meResSasTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);
191  sprintf(histo,"Pull_LF_sas_layer%dtob",i+1);
192  mePullLFSasTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
193  sprintf(histo,"Pull_MF_sas_layer%dtob",i+1);
194  mePullMFSasTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
195  sprintf(histo,"Chi2_sas_layer%dtob",i+1);
196  meChi2SasTOB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
197 
198  sprintf(histo,"Posx_matched_layer%dtob",i+1);
199  mePosxMatchedTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);
200  sprintf(histo,"Posy_matched_layer%dtob",i+1);
201  mePosyMatchedTOB[i] = dbe_->book1D(histo,"RecHit y coord.",100,-10.0, +10.0);
202  sprintf(histo,"Errx_matched_layer%dtob",i+1);
203  meErrxMatchedTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.01);
204  sprintf(histo,"Erry_matched_layer%dtob",i+1);
205  meErryMatchedTOB[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.1);
206  sprintf(histo,"Resx_matched_layer%dtob",i+1);
207  meResxMatchedTOB[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.02, +0.02);
208  sprintf(histo,"Resy_matched_layer%dtob",i+1);
209  meResyMatchedTOB[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);
210  sprintf(histo,"Chi2_matched_layer%dtob",i+1);
211  meChi2MatchedTOB[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
212  }
213 
214  dbe_->setCurrentFolder("TrackerRecHitsV/TrackerRecHits/Strip/TID");
215  meNumRphiTID = dbe_->book1D("NumRphiTID","Num of RecHits rphi", 100, 0, 1000.);
216  meNumSasTID = dbe_->book1D("NumSasTID","Num of RecHits sas", 100, 0, 1000.);
217  meNumMatchedTID = dbe_->book1D("NumMatchedTID","Num of RecHits matched", 100, 0, 1000.);
218 
219  //one histo per Ring rphi hits: 3 rings, 6 disks, 2 inner rings are glued
220  for(int i = 0 ;i<3 ; i++) {
221  Char_t histo[200];
222  sprintf(histo,"Nstp_rphi_layer%dtid",i+1);
223  meNstpRphiTID[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
224  sprintf(histo,"Adc_rphi_layer%dtid",i+1);
225  meAdcRphiTID[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
226  sprintf(histo,"Posx_rphi_layer%dtid",i+1);
227  mePosxRphiTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
228  sprintf(histo,"Errx_rphi_layer%dtid",i+1);
229  meErrxRphiTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);
230  sprintf(histo,"Res_rphi_layer%dtid",i+1);
231  meResRphiTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);
232  sprintf(histo,"Pull_LF_rphi_layer%dtid",i+1);
233  mePullLFRphiTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
234  sprintf(histo,"Pull_MF_rphi_layer%dtid",i+1);
235  mePullMFRphiTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
236  sprintf(histo,"Chi2_rphi_layer%dtid",i+1);
237  meChi2RphiTID[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
238  }
239 
240  //one histo per Ring stereo and matched hits
241  for(int i = 0 ;i<2 ; i++) {
242  Char_t histo[200];
243  sprintf(histo,"Nstp_sas_layer%dtid",i+1);
244  meNstpSasTID[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
245  sprintf(histo,"Adc_sas_layer%dtid",i+1);
246  meAdcSasTID[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
247  sprintf(histo,"Posx_sas_layer%dtid",i+1);
248  mePosxSasTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
249  sprintf(histo,"Errx_sas_layer%dtid",i+1);
250  meErrxSasTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);
251  sprintf(histo,"Res_sas_layer%dtid",i+1);
252  meResSasTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);
253  sprintf(histo,"Pull_LF_sas_layer%dtid",i+1);
254  mePullLFSasTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
255  sprintf(histo,"Pull_MF_sas_layer%dtid",i+1);
256  mePullMFSasTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
257  sprintf(histo,"Chi2_sas_layer%dtid",i+1);
258  meChi2SasTID[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
259 
260  sprintf(histo,"Posx_matched_layer%dtid",i+1);
261  mePosxMatchedTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);
262  sprintf(histo,"Posy_matched_layer%dtid",i+1);
263  mePosyMatchedTID[i] = dbe_->book1D(histo,"RecHit y coord.",100,-6.0, +6.0);
264  sprintf(histo,"Errx_matched_layer%dtid",i+1);
265  meErrxMatchedTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.05);
266  sprintf(histo,"Erry_matched_layer%dtid",i+1);
267  meErryMatchedTID[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.1);
268  sprintf(histo,"Resx_matched_layer%dtid",i+1);
269  meResxMatchedTID[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.2, +0.2);
270  sprintf(histo,"Resy_matched_layer%dtid",i+1);
271  meResyMatchedTID[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);
272  sprintf(histo,"Chi2_matched_layer%dtid",i+1);
273  meChi2MatchedTID[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
274  }
275 
276  dbe_->setCurrentFolder("TrackerRecHitsV/TrackerRecHits/Strip/TEC");
277  meNumRphiTEC = dbe_->book1D("NumRphiTEC","Num of RecHits rphi", 100, 0, 1000.);
278  meNumSasTEC = dbe_->book1D("NumSasTEC","Num of RecHits sas", 100, 0, 1000.);
279  meNumMatchedTEC = dbe_->book1D("NumMatchedTEC","Num of RecHits matched", 100, 0, 1000.);
280 
281  //one histo per Ring rphi hits: 7 rings, 18 disks. Innermost 3 rings are same as TID above.
282  for(int i = 0 ;i<7 ; i++) {
283  Char_t histo[200];
284  sprintf(histo,"Nstp_rphi_layer%dtec",i+1);
285  meNstpRphiTEC[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
286  sprintf(histo,"Adc_rphi_layer%dtec",i+1);
287  meAdcRphiTEC[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
288  sprintf(histo,"Posx_rphi_layer%dtec",i+1);
289  mePosxRphiTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
290  sprintf(histo,"Errx_rphi_layer%dtec",i+1);
291  meErrxRphiTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);
292  sprintf(histo,"Res_rphi_layer%dtec",i+1);
293  meResRphiTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);
294  sprintf(histo,"Pull_LF_rphi_layer%dtec",i+1);
295  mePullLFRphiTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
296  sprintf(histo,"Pull_MF_rphi_layer%dtec",i+1);
297  mePullMFRphiTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
298  sprintf(histo,"Chi2_rphi_layer%dtec",i+1);
299  meChi2RphiTEC[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
300  }
301 
302  //one histo per Layer stereo and matched hits: rings 1,2,5 are double sided
303  for(int i = 0 ;i<5 ; i++) {
304  if(i == 0 || i == 1 || i == 4) {
305  Char_t histo[200];
306  sprintf(histo,"Nstp_sas_layer%dtec",i+1);
307  meNstpSasTEC[i] = dbe_->book1D(histo,"RecHit Cluster Size",10,0.5,10.5);
308  sprintf(histo,"Adc_sas_layer%dtec",i+1);
309  meAdcSasTEC[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);
310  sprintf(histo,"Posx_sas_layer%dtec",i+1);
311  mePosxSasTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);
312  sprintf(histo,"Errx_sas_layer%dtec",i+1);
313  meErrxSasTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);
314  sprintf(histo,"Res_sas_layer%dtec",i+1);
315  meResSasTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);
316  sprintf(histo,"Pull_LF_sas_layer%dtec",i+1);
317  mePullLFSasTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
318  sprintf(histo,"Pull_MF_sas_layer%dtec",i+1);
319  mePullMFSasTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
320  sprintf(histo,"Chi2_sas_layer%dtec",i+1);
321  meChi2SasTEC[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
322 
323  sprintf(histo,"Posx_matched_layer%dtec",i+1);
324  mePosxMatchedTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);
325  sprintf(histo,"Posy_matched_layer%dtec",i+1);
326  mePosyMatchedTEC[i] = dbe_->book1D(histo,"RecHit y coord.",100,-8.0, +8.0);
327  sprintf(histo,"Errx_matched_layer%dtec",i+1);
328  meErrxMatchedTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.05);
329  sprintf(histo,"Erry_matched_layer%dtec",i+1);
330  meErryMatchedTEC[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.1);
331  sprintf(histo,"Resx_matched_layer%dtec",i+1);
332  meResxMatchedTEC[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.2, +0.2);
333  sprintf(histo,"Resy_matched_layer%dtec",i+1);
334  meResyMatchedTEC[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);
335  sprintf(histo,"Chi2_matched_layer%dtec",i+1);
336  meChi2MatchedTEC[i] = dbe_->book1D(histo,"RecHit Chi2 test",100,0., 50);
337  }
338  }
339 }
340 
342  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
343 }
344 
345 
347  //Retrieve tracker topology from geometry
349  es.get<IdealGeometryRecord>().get(tTopo);
350 
351 
352 
353  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
354  //std::cout << " Run = " << e.id().run() << " Event = " << e.id().event() << std::endl;
355 
356  //--- get RecHits
357 
358  std::string rechitProducer = "SiStripRecHits2D";
359 
360  // Step A: Get Inputs
367 
368  int numrechitrphi =0;
369  int numrechitsas =0;
370  int numrechitmatched=0;
371 
372  int totTibnumrechitrphi=0;
373  int totTibnumrechitsas=0;
374  int totTibnumrechitmatched=0;
375  int totTobnumrechitrphi=0;
376  int totTobnumrechitsas=0;
377  int totTobnumrechitmatched=0;
378  int totTidnumrechitrphi=0;
379  int totTidnumrechitsas=0;
380  int totTidnumrechitmatched=0;
381  int totTecnumrechitrphi=0;
382  int totTecnumrechitsas=0;
383  int totTecnumrechitmatched=0;
384  int totrechitrphi =0;
385  int totrechitsas =0;
386  int totrechitmatched =0;
387 
388  TrackerHitAssociator associate(e, conf_);
389 
391  es.get<TrackerDigiGeometryRecord> ().get (pDD);
392  const TrackerGeometry &tracker(*pDD);
393  // FIXME: this using of vector<DetId> is suboptimal, but I don't want to re-write the full class now
394  std::vector<DetId> IDs;
395  IDs.reserve(rechitsrphi->size() + rechitsmatched->size() + rechitsstereo->size());
396  std::transform(rechitsrphi->begin(), rechitsrphi->end(), std::back_inserter(IDs), helper::GetDetId() );
397  std::transform(rechitsstereo->begin(), rechitsstereo->end(), std::back_inserter(IDs), helper::GetDetId() );
398  std::transform(rechitsmatched->begin(), rechitsmatched->end(), std::back_inserter(IDs), helper::GetDetId() );
399  // loop over detunits
400  // for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
401  for(std::vector<DetId>::const_iterator it = IDs.begin(); it != IDs.end(); ++it ){//loop on rphi detector with hits
402  uint32_t myid=((*it).rawId());
403  DetId detid = ((*it));
404 
405  // initialize here
406  for(int i=0; i<MAXHIT; i++){
407  rechitrphix[i] =0;
408  rechitrphierrx[i] =0;
409  rechitrphiy[i] =0;
410  rechitrphiz[i] =0;
411  rechitsasx[i] =0;
412  rechitsaserrx[i] =0;
413  rechitsasy[i] =0;
414  rechitsasz[i] =0;
415  clusizrphi[i] =0;
416  clusizsas[i] =0;
417  cluchgrphi[i] =0;
418  cluchgsas[i] =0;
419  rechitrphires[i]=-999.;
420  rechitsasres[i]=-999.;
421  rechitrphipullMF[i]=-999.;
422  rechitsaspullMF[i]=-999.;
423  chi2rphi[i] =0;
424  chi2sas[i]=0;
425  rechitmatchedx[i] =0;
426  rechitmatchedy[i] =0;
427  rechitmatchedz[i] =0;
428  rechitmatchederrxx[i] =0;
429  rechitmatchederrxy[i] =0;
430  rechitmatchederryy[i] =0;
431  rechitmatchedresx[i]=-999;
432  rechitmatchedresy[i]=-999;
433  chi2matched[i]=0;
434  }
435 
436  numrechitrphi =0;
437  //loop over rechits-rphi in the same subdetector
438  std::pair<SiStripRecHit2DCollection::DetSet::const_iterator,SiStripRecHit2DCollection::DetSet::const_iterator> rechitrphiRange = helper::getRange(*rechitsrphi, detid);
439  SiStripRecHit2DCollection::DetSet::const_iterator rechitrphiRangeIteratorBegin = rechitrphiRange.first;
440  SiStripRecHit2DCollection::DetSet::const_iterator rechitrphiRangeIteratorEnd = rechitrphiRange.second;
441  SiStripRecHit2DCollection::DetSet::const_iterator iterrphi=rechitrphiRangeIteratorBegin;
442 
443  numrechitrphi = rechitrphiRangeIteratorEnd - rechitrphiRangeIteratorBegin;
444 
445 
446  int i=0;
447  int i2=0;
448 
449  if(numrechitrphi > 0 ){
450  totrechitrphi+=numrechitrphi;
451  for(iterrphi=rechitrphiRangeIteratorBegin; iterrphi!=rechitrphiRangeIteratorEnd;++iterrphi){
452  const GeomDetUnit * det = tracker.idToDetUnit(detid);
453  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
454  const StripTopology &topol=(StripTopology&)stripdet->topology();
455  SiStripRecHit2D const rechit=*iterrphi;
456  LocalPoint position=rechit.localPosition();
457  LocalError error=rechit.localPositionError();
458  MeasurementPoint Mposition;
459  MeasurementError Merror;
460  Mposition = topol.measurementPosition(position);
461  Merror = topol.measurementError(position,error);
462  SiStripRecHit2D::ClusterRef clust=rechit.cluster();
463  int clusiz=0;
464  int totcharge=0;
465  clusiz = clust->amplitudes().size();
466  const std::vector<uint8_t> amplitudes=clust->amplitudes();
467  for(size_t ia=0; ia<amplitudes.size();ia++){
468  totcharge+=amplitudes[ia];
469  }
470  rechitrphix[i] = position.x();
471  rechitrphiy[i] = position.y();
472  rechitrphiz[i] = position.z();
473  rechitrphierrx[i] = error.xx();
474  clusizrphi[i] = clusiz;
475  cluchgrphi[i] = totcharge;
476 
477  matched.clear();
478  matched = associate.associateHit(rechit);
479  float mindist = 999999;
480  float dist = 999999;
481  PSimHit closest;
482  if(!matched.empty()){
483  for(std::vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
484  dist = fabs(rechitrphix[i] - (*m).localPosition().x());
485  if(dist<mindist){
486  mindist = dist;
487  closest = (*m);
488  }
489  rechitrphires[i] = rechitrphix[i] - closest.localPosition().x();
490  }
491  rechitrphipullMF[i] = (Mposition.x() - (topol.measurementPosition(closest.localPosition())).x())/sqrt(Merror.uu());
492 
493  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
494  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
495  AlgebraicVector rhparameters(2);//= rechit.parameters();
496  rhparameters[0] = position.x();
497  rhparameters[1] = position.y();
498  AlgebraicVector shparameters(2);
499  shparameters[0] = closest.localPosition().x();
500  shparameters[1] = closest.localPosition().y();
501  AlgebraicVector r(rhparameters - shparameters);
502  AlgebraicSymMatrix R(2);// = rechit.parametersError();
503  R[0][0] = error.xx();
504  R[0][1] = error.xy();
505  R[1][1] = error.yy();
506  int ierr;
507  R.invert(ierr); // if (ierr != 0) throw exception;
508  double est = R.similarity(r);
509  // std::cout << " ====== Chi2 test rphi hits ====== " << std::endl;
510  // std::cout << "RecHit param. = " << rhparameters << std::endl;
511  // std::cout << "RecHit errors = " << R << std::endl;
512  // std::cout << "SimHit param. = " << shparameters << std::endl;
513  // std::cout << " chi2 = " << est << std::endl;
514  // std::cout << "DEBUG BORIS,filling chi2rphi[i],i: " << i << std::endl;
515  chi2rphi[i2] = est;
516  i2++;
517  }
518  i++;
519  }
520  }
521 
522  //loop over rechits-sas in the same subdetector
523  int j=0;
524  int j2=0;
525  numrechitsas=0;
526  std::pair<SiStripRecHit2DCollection::DetSet::const_iterator,SiStripRecHit2DCollection::DetSet::const_iterator> rechitsasRange = helper::getRange(*rechitsstereo, detid);
527  SiStripRecHit2DCollection::DetSet::const_iterator rechitsasRangeIteratorBegin = rechitsasRange.first;
528  SiStripRecHit2DCollection::DetSet::const_iterator rechitsasRangeIteratorEnd = rechitsasRange.second;
529  SiStripRecHit2DCollection::DetSet::const_iterator itersas=rechitsasRangeIteratorBegin;
530  numrechitsas = rechitsasRangeIteratorEnd - rechitsasRangeIteratorBegin;
531  if(numrechitsas > 0){
532  totrechitsas+=numrechitsas;
533  for(itersas=rechitsasRangeIteratorBegin; itersas!=rechitsasRangeIteratorEnd;++itersas){
534  const GeomDetUnit * det = tracker.idToDetUnit(detid);
535  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
536  const StripTopology &topol=(StripTopology&)stripdet->topology();
537  SiStripRecHit2D const rechit=*itersas;
538  LocalPoint position=rechit.localPosition();
539  LocalError error=rechit.localPositionError();
540  MeasurementPoint Mposition;
541  MeasurementError Merror;
542  Mposition = topol.measurementPosition(position);
543  Merror = topol.measurementError(position,error);
544  SiStripRecHit2D::ClusterRef clust=rechit.cluster(); int clusiz=0;
545  int totcharge=0;
546  clusiz = clust->amplitudes().size();
547  const std::vector<uint8_t> amplitudes=clust->amplitudes();
548  for(size_t ia=0; ia<amplitudes.size();ia++){
549  totcharge+=amplitudes[ia];
550  }
551 
552  rechitsasx[j] = position.x();
553  rechitsasy[j] = position.y();
554  rechitsasz[j] = position.z();
555  rechitsaserrx[j] = error.xx();
556  clusizsas[j] = clusiz;
557  cluchgsas[j] = totcharge;
558 
559  float mindist = 999999;
560  float dist = 999999;
561  PSimHit closest;
562  matched.clear();
563  matched = associate.associateHit(rechit);
564  if(!matched.empty()){
565  for(std::vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
566  dist = fabs(rechitsasx[j] - (*m).localPosition().x());
567  if(dist<mindist){
568  mindist = dist;
569  closest = (*m);
570  }
571  rechitsasres[j] = rechitsasx[j] - closest.localPosition().x();
572  }
573  rechitsaspullMF[j] = (Mposition.x() - (topol.measurementPosition(closest.localPosition())).x())/sqrt(Merror.uu());
574  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
575  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
576 // AlgebraicVector rhparameters = rechit.parameters();
577  AlgebraicVector rhparameters(2);//= rechit.parameters();
578  rhparameters[0] = position.x();
579  rhparameters[1] = position.y();
580  AlgebraicVector shparameters(2);
581  shparameters[0] = closest.localPosition().x();
582  shparameters[1] = closest.localPosition().y();
583  AlgebraicVector r(rhparameters - shparameters);
584 // AlgebraicSymMatrix R = rechit.parametersError();
585  AlgebraicSymMatrix R(2);// = rechit.parametersError();
586  R[0][0] = error.xx();
587  R[0][1] = error.xy();
588  R[1][1] = error.yy();
589  int ierr;
590  R.invert(ierr); // if (ierr != 0) throw exception;
591  double est = R.similarity(r);
592  // std::cout << " ====== Chi2 test sas hits ====== " << std::endl;
593  // std::cout << "RecHit param. = " << rhparameters << std::endl;
594  // std::cout << "RecHit errors = " << R << std::endl;
595  // std::cout << "SimHit param. = " << shparameters << std::endl;
596  // std::cout << " chi2 = " << est << std::endl;
597  // std::cout << "DEBUG BORIS,filling chi2sas[j],j: " << i << std::endl;
598  chi2sas[j2] = est;
599  j2++;
600  }
601  j++;
602  }
603  }
604 
605  //now matched hits
606 
607  int k=0;
608  int k2=0;
609 
610  //loop over rechits-matched in the same subdetector
611  numrechitmatched=0;
612  std::pair<SiStripMatchedRecHit2DCollection::DetSet::const_iterator,SiStripMatchedRecHit2DCollection::DetSet::const_iterator> rechitmatchedRange = helper::getRange(*rechitsmatched, detid);
613  SiStripMatchedRecHit2DCollection::DetSet::const_iterator rechitmatchedRangeIteratorBegin = rechitmatchedRange.first;
614  SiStripMatchedRecHit2DCollection::DetSet::const_iterator rechitmatchedRangeIteratorEnd = rechitmatchedRange.second;
615  SiStripMatchedRecHit2DCollection::DetSet::const_iterator itermatched=rechitmatchedRangeIteratorBegin;
616  numrechitmatched = rechitmatchedRangeIteratorEnd - rechitmatchedRangeIteratorBegin;
617  if(numrechitmatched > 0){
618  totrechitmatched +=numrechitmatched;
619 
620  for(itermatched=rechitmatchedRangeIteratorBegin; itermatched!=rechitmatchedRangeIteratorEnd;++itermatched){
621  SiStripMatchedRecHit2D const rechit=*itermatched;
622  LocalPoint position=rechit.localPosition();
623  LocalError error=rechit.localPositionError();
624 
625  float mindist = 999999;
626  float distx = 999999;
627  float disty = 999999;
628  float dist = 999999;
629  std::pair<LocalPoint,LocalVector> closestPair;
630  matched.clear();
631  // const SiStripRecHit2D *mono = rechit.monoHit();
632  // const SiStripRecHit2D *st = rechit.stereoHit();
633  // LocalPoint monopos = mono->localPosition();
634  // LocalPoint stpos = st->localPosition();
635 
636  rechitmatchedx[k] = position.x();
637  rechitmatchedy[k] = position.y();
638  rechitmatchedz[k] = position.z();
639  rechitmatchederrxx[k] = error.xx();
640  rechitmatchederrxy[k] = error.xy();
641  rechitmatchederryy[k] = error.yy();
642 
643  // std::cout << " before association " << std::endl;
644  matched = associate.associateHit(rechit);
645  //std::cout << " after association size = " << matched.size() << std::endl;
646 
647  if(!matched.empty()){
648  //project simhit;
649  const GluedGeomDet* gluedDet = (const GluedGeomDet*)tracker.idToDet(rechit.geographicalId());
650  const StripGeomDetUnit* partnerstripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
651  std::pair<LocalPoint,LocalVector> hitPair;
652 
653  //std::cout << " RECHIT position = " << position << std::endl;
654 
655  for(std::vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
656  //project simhit;
657  hitPair= projectHit((*m),partnerstripdet,gluedDet->surface());
658  distx = fabs(rechitmatchedx[k] - hitPair.first.x());
659  disty = fabs(rechitmatchedy[k] - hitPair.first.y());
660  dist = sqrt(distx*distx+disty*disty);
661  // std::cout << " Simhit position x = " << hitPair.first.x()
662  // << " y = " << hitPair.first.y() << " dist = " << dist << std::endl;
663  if(dist<mindist){
664  mindist = dist;
665  closestPair = hitPair;
666  }
667  }
668  //std::cout << " Closest position x = " << closestPair.first.x()
669  // << " y = " << closestPair.first.y() << " dist = " << dist << std::endl;
670  rechitmatchedresx[k] = rechitmatchedx[k] - closestPair.first.x();
671  rechitmatchedresy[k] = rechitmatchedy[k] - closestPair.first.y();
672 
673  //chi2test compare rechit errors with the simhit position ( using null matrix for the simhit).
674  //Can spot problems in the geometry better than a simple residual. (thanks to BorisM)
675 
676  AlgebraicVector rhparameters(2);//= rechit.parameters();
677  rhparameters[0] = position.x();
678  rhparameters[1] = position.y();
679  LocalPoint sh = closestPair.first;
680  AlgebraicVector shparameters(2);
681  shparameters[0] = sh.x();
682  shparameters[1] = sh.y();
683  AlgebraicVector r(rhparameters - shparameters);
684  AlgebraicSymMatrix R(2);// = rechit.parametersError();
685  R[0][0] = error.xx();
686  R[0][1] = error.xy();
687  R[1][1] = error.yy();
688  int ierr;
689  R.invert(ierr); // if (ierr != 0) throw exception;
690  double est = R.similarity(r);
691  // std::cout << " ====== Chi2 test matched ====== " << std::endl;
692  // std::cout << "RecHit param. = " << rhparameters << std::endl;
693  // std::cout << "RecHit errors = " << R << std::endl;
694  // std::cout << "SimHit param. = " << shparameters << std::endl;
695  // std::cout << " chi2 = " << est << std::endl;
696  chi2matched[k2] = est;
697  k2++;
698  }
699 
700  k++;
701  }
702  }
703 
704  //for each detid
705  if(numrechitrphi>0 || numrechitsas>0 || numrechitmatched){
706  if (detid.subdetId() == int(StripSubdetector::TIB)){
707 
708  int Tibnumrechitrphi = numrechitrphi;
709  int Tibnumrechitsas = numrechitsas;
710  int Tibnumrechitmatched = numrechitmatched;
711 
712  int Tibnumrechitrphi2 = i2;
713  int Tibnumrechitsas2 = j2;
714  int Tibnumrechitmatched2 = k2;
715 
716  totTibnumrechitrphi +=numrechitrphi;
717  totTibnumrechitsas +=numrechitsas;
718  totTibnumrechitmatched +=numrechitmatched;
719 
720  int ilay = tTopo->tibLayer(myid) - 1; //for histogram filling
721 
722  if(tTopo->tibStereo(myid)==0){
723  for(int k = 0; k<Tibnumrechitrphi; k++){
724  meNstpRphiTIB[ilay]->Fill(clusizrphi[k]);
725  meAdcRphiTIB[ilay]->Fill(cluchgrphi[k]);
726  mePosxRphiTIB[ilay]->Fill(rechitrphix[k]);
728  meResRphiTIB[ilay]->Fill(rechitrphires[k]);
731 
732  }
733 
734  for(int k = 0; k<Tibnumrechitrphi2; k++){
735  meChi2RphiTIB[ilay]->Fill(chi2rphi[k]);
736  }
737 
738  } else if(tTopo->tibStereo(myid)==1){
739  for(int kk = 0; kk < Tibnumrechitsas; kk++)
740  {
741  meNstpSasTIB[ilay]->Fill(clusizsas[kk]);
742  meAdcSasTIB[ilay]->Fill(cluchgsas[kk]);
743  mePosxSasTIB[ilay]->Fill(rechitsasx[kk]);
744  meErrxSasTIB[ilay]->Fill(sqrt(rechitsaserrx[kk]));
745  meResSasTIB[ilay]->Fill(rechitsasres[kk]);
747  mePullMFSasTIB[ilay]->Fill(rechitsaspullMF[kk]);
748  }
749  for(int l = 0; l<Tibnumrechitsas2; l++){
750  meChi2SasTIB[ilay]->Fill(chi2sas[l]);
751  }
752 
753  }
754  if(Tibnumrechitmatched>0){
755  for(int kkk = 0; kkk<Tibnumrechitmatched; kkk++)
756  {
757  mePosxMatchedTIB[ilay]->Fill(rechitmatchedx[kkk]);
758  mePosyMatchedTIB[ilay]->Fill(rechitmatchedy[kkk]);
763  }
764  for(int l = 0; l<Tibnumrechitmatched2; l++){
766  }
767 
768  }
769  }
770 
771 
772  if (detid.subdetId() == int(StripSubdetector::TOB)){
773 
774  int Tobnumrechitrphi = numrechitrphi;
775  int Tobnumrechitsas = numrechitsas;
776  int Tobnumrechitmatched = numrechitmatched;
777  totTobnumrechitrphi +=numrechitrphi;
778  totTobnumrechitsas +=numrechitsas;
779  totTobnumrechitmatched +=numrechitmatched;
780 
781  int Tobnumrechitrphi2 = i2;
782  int Tobnumrechitsas2 = j2;
783  int Tobnumrechitmatched2 = k2;
784 
785  int ilay = tTopo->tobLayer(myid) - 1; //for histogram filling
786 
787  if(tTopo->tobStereo(myid)==0){
788  for(int k = 0; k<Tobnumrechitrphi; k++){
789  meNstpRphiTOB[ilay]->Fill(clusizrphi[k]);
790  meAdcRphiTOB[ilay]->Fill(cluchgrphi[k]);
791  mePosxRphiTOB[ilay]->Fill(rechitrphix[k]);
793  meResRphiTOB[ilay]->Fill(rechitrphires[k]);
796  }
797  for(int l = 0; l<Tobnumrechitrphi2; l++){
798  meChi2RphiTOB[ilay]->Fill(chi2rphi[l]);
799  }
800  } else if(tTopo->tobStereo(myid)==1){
801  for(int kk = 0; kk < Tobnumrechitsas; kk++)
802  {
803  meNstpSasTOB[ilay]->Fill(clusizsas[kk]);
804  meAdcSasTOB[ilay]->Fill(cluchgsas[kk]);
805  mePosxSasTOB[ilay]->Fill(rechitsasx[kk]);
806  meErrxSasTOB[ilay]->Fill(sqrt(rechitsaserrx[kk]));
807  meResSasTOB[ilay]->Fill(rechitsasres[kk]);
809  mePullMFSasTOB[ilay]->Fill(rechitsaspullMF[kk]);
810  }
811  for(int l = 0; l<Tobnumrechitsas2; l++){
812  meChi2SasTOB[ilay]->Fill(chi2sas[l]);
813  }
814 
815  }
816  if(Tobnumrechitmatched>0){
817  for(int kkk = 0; kkk<Tobnumrechitmatched; kkk++)
818  {
819  mePosxMatchedTOB[ilay]->Fill(rechitmatchedx[kkk]);
820  mePosyMatchedTOB[ilay]->Fill(rechitmatchedy[kkk]);
825  }
826  for(int l = 0; l<Tobnumrechitmatched2; l++){
828  }
829 
830  }
831  }
832  if (detid.subdetId() == int(StripSubdetector::TID)){
833 
834  int Tidnumrechitrphi = numrechitrphi;
835  int Tidnumrechitsas = numrechitsas;
836  int Tidnumrechitmatched = numrechitmatched;
837  totTidnumrechitrphi +=numrechitrphi;
838  totTidnumrechitsas +=numrechitsas;
839  totTidnumrechitmatched +=numrechitmatched;
840 
841  int Tidnumrechitrphi2 = i2;
842  int Tidnumrechitsas2 = j2;
843  int Tidnumrechitmatched2 = k2;
844 
845  int ilay = tTopo->tidRing(myid) - 1; //for histogram filling
846 
847  if(tTopo->tidStereo(myid)==0){
848  for(int k = 0; k<Tidnumrechitrphi; k++){
849  meNstpRphiTID[ilay]->Fill(clusizrphi[k]);
850  meAdcRphiTID[ilay]->Fill(cluchgrphi[k]);
851  mePosxRphiTID[ilay]->Fill(rechitrphix[k]);
853  meResRphiTID[ilay]->Fill(rechitrphires[k]);
856  }
857  for(int l = 0; l<Tidnumrechitrphi2; l++){
858  meChi2RphiTID[ilay]->Fill(chi2rphi[l]);
859  }
860 
861  } else if(tTopo->tidStereo(myid)==1){
862  for(int kk = 0; kk < Tidnumrechitsas; kk++)
863  {
864  meNstpSasTID[ilay]->Fill(clusizsas[kk]);
865  meAdcSasTID[ilay]->Fill(cluchgsas[kk]);
866  mePosxSasTID[ilay]->Fill(rechitsasx[kk]);
867  meErrxSasTID[ilay]->Fill(sqrt(rechitsaserrx[kk]));
868  meResSasTID[ilay]->Fill(rechitsasres[kk]);
870  mePullMFSasTID[ilay]->Fill(rechitsaspullMF[kk]);
871  }
872  for(int l = 0; l<Tidnumrechitsas2; l++){
873  meChi2SasTID[ilay]->Fill(chi2sas[l]);
874  }
875 
876  }
877  if(Tidnumrechitmatched>0){
878  for(int kkk = 0; kkk<Tidnumrechitmatched; kkk++)
879  {
880  mePosxMatchedTID[ilay]->Fill(rechitmatchedx[kkk]);
881  mePosyMatchedTID[ilay]->Fill(rechitmatchedy[kkk]);
886  }
887  for(int l = 0; l<Tidnumrechitmatched2; l++){
889  }
890 
891  }
892  }
893  if (detid.subdetId() == int(StripSubdetector::TEC)){
894 
895  int Tecnumrechitrphi = numrechitrphi;
896  int Tecnumrechitsas = numrechitsas;
897  int Tecnumrechitmatched = numrechitmatched;
898  totTecnumrechitrphi +=numrechitrphi;
899  totTecnumrechitsas +=numrechitsas;
900  totTecnumrechitmatched +=numrechitmatched;
901 
902  int Tecnumrechitrphi2 = i2;
903  int Tecnumrechitsas2 = j2;
904  int Tecnumrechitmatched2 = k2;
905 
906  int ilay = tTopo->tecRing(myid) - 1; //for histogram filling
907 
908  if(tTopo->tecStereo(myid)==0){
909  for(int k = 0; k<Tecnumrechitrphi; k++){
910  meNstpRphiTEC[ilay]->Fill(clusizrphi[k]);
911  meAdcRphiTEC[ilay]->Fill(cluchgrphi[k]);
912  mePosxRphiTEC[ilay]->Fill(rechitrphix[k]);
914  meResRphiTEC[ilay]->Fill(rechitrphires[k]);
917  }
918  for(int l = 0; l<Tecnumrechitrphi2; l++){
919  meChi2RphiTEC[ilay]->Fill(chi2rphi[l]);
920  }
921 
922  } else if(tTopo->tecStereo(myid)==1){
923  for(int kk = 0; kk < Tecnumrechitsas; kk++)
924  {
925  meNstpSasTEC[ilay]->Fill(clusizsas[kk]);
926  meAdcSasTEC[ilay]->Fill(cluchgsas[kk]);
927  mePosxSasTEC[ilay]->Fill(rechitsasx[kk]);
928  meErrxSasTEC[ilay]->Fill(sqrt(rechitsaserrx[kk]));
929  meResSasTEC[ilay]->Fill(rechitsasres[kk]);
931  mePullMFSasTEC[ilay]->Fill(rechitsaspullMF[kk]);
932  }
933  for(int l = 0; l<Tecnumrechitsas2; l++){
934  meChi2SasTEC[ilay]->Fill(chi2sas[l]);
935  }
936 
937  }
938  if(Tecnumrechitmatched>0){
939  for(int kkk = 0; kkk<Tecnumrechitmatched; kkk++)
940  {
941  mePosxMatchedTEC[ilay]->Fill(rechitmatchedx[kkk]);
942  mePosyMatchedTEC[ilay]->Fill(rechitmatchedy[kkk]);
947  }
948  for(int l = 0; l<Tecnumrechitmatched2; l++){
950  }
951 
952  }
953  }
954 
955  }
956  }
957 
958  //now fill the cumulative histograms of the hits
959 
960  meNumRphiTIB->Fill(totTibnumrechitrphi);
961  meNumSasTIB->Fill(totTibnumrechitsas);
962  meNumMatchedTIB->Fill(totTibnumrechitmatched);
963  meNumRphiTOB->Fill(totTobnumrechitrphi);
964  meNumSasTOB->Fill(totTobnumrechitsas);
965  meNumMatchedTOB->Fill(totTobnumrechitmatched);
966  meNumRphiTID->Fill(totTidnumrechitrphi);
967  meNumSasTID->Fill(totTidnumrechitsas);
968  meNumMatchedTID->Fill(totTidnumrechitmatched);
969  meNumRphiTEC->Fill(totTecnumrechitrphi);
970  meNumSasTEC->Fill(totTecnumrechitsas);
971  meNumMatchedTEC->Fill(totTecnumrechitmatched);
972 
973  meNumTotRphi->Fill(totrechitrphi);
974  meNumTotSas->Fill(totrechitsas);
975  meNumTotMatched->Fill(totrechitmatched);
976 
977 
978 }
979 
980 
981 //needed by to do the residual for matched hits
982 std::pair<LocalPoint,LocalVector> SiStripRecHitsValid::projectHit( const PSimHit& hit, const StripGeomDetUnit* stripDet,
983  const BoundPlane& plane)
984 {
985  // const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(hit.det());
986  //if (stripDet == 0) throw MeasurementDetException("HitMatcher hit is not on StripGeomDetUnit");
987 
988  const StripTopology& topol = stripDet->specificTopology();
989  GlobalPoint globalpos= stripDet->surface().toGlobal(hit.localPosition());
990  LocalPoint localHit = plane.toLocal(globalpos);
991  //track direction
992  LocalVector locdir=hit.localDirection();
993  //rotate track in new frame
994 
995  GlobalVector globaldir= stripDet->surface().toGlobal(locdir);
996  LocalVector dir=plane.toLocal(globaldir);
997  float scale = -localHit.z() / dir.z();
998 
999  LocalPoint projectedPos = localHit + scale*dir;
1000 
1001  // std::cout << "projectedPos " << projectedPos << std::endl;
1002 
1003  float selfAngle = topol.stripAngle( topol.strip( hit.localPosition()));
1004 
1005  LocalVector stripDir( sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
1006 
1007  LocalVector localStripDir( plane.toLocal(stripDet->surface().toGlobal( stripDir)));
1008 
1009  return std::pair<LocalPoint,LocalVector>( projectedPos, localStripDir);
1010 }
1011 
1012 
MonitorElement * meNstpRphiTEC[7]
RunNumber_t run() const
Definition: EventID.h:42
MonitorElement * meNumTotRphi
MonitorElement * meNstpSasTEC[5]
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
MonitorElement * meResRphiTEC[7]
EventNumber_t event() const
Definition: EventID.h:44
MonitorElement * meChi2RphiTID[3]
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
MonitorElement * mePullLFSasTIB[4]
MonitorElement * meErrxSasTEC[5]
MonitorElement * meAdcRphiTIB[4]
MonitorElement * meErrxMatchedTIB[2]
void beginRun(const edm::Run &r, const edm::EventSetup &c)
MonitorElement * mePullLFRphiTID[3]
virtual float stripAngle(float strip) const =0
MonitorElement * meChi2RphiTEC[7]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
float rechitmatchedresy[MAXHIT]
MonitorElement * mePosyMatchedTEC[5]
MonitorElement * meNumRphiTIB
MonitorElement * meErrxMatchedTOB[2]
MonitorElement * mePosxRphiTID[3]
MonitorElement * meChi2MatchedTID[2]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * meErryMatchedTID[2]
std::vector< PSimHit > matched
MonitorElement * meNstpRphiTIB[4]
MonitorElement * meResyMatchedTID[2]
MonitorElement * meNumMatchedTOB
float rechitmatchedresx[MAXHIT]
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * meNumSasTOB
MonitorElement * meErrxRphiTIB[4]
float rechitmatchederrxx[MAXHIT]
T y() const
Definition: PV3DBase.h:63
MonitorElement * meResxMatchedTEC[5]
MonitorElement * meNstpSasTOB[2]
MonitorElement * mePullLFSasTEC[5]
MonitorElement * meResSasTID[2]
#define X(str)
Definition: MuonsGrabber.cc:48
MonitorElement * meNumMatchedTID
MonitorElement * mePullMFRphiTOB[6]
MonitorElement * meAdcRphiTEC[7]
MonitorElement * meChi2MatchedTIB[2]
MonitorElement * meNumSasTIB
MonitorElement * meResxMatchedTID[2]
MonitorElement * meNstpRphiTID[3]
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
MonitorElement * mePosxRphiTOB[6]
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
MonitorElement * mePullLFRphiTIB[4]
MonitorElement * meNumRphiTID
virtual float strip(const LocalPoint &) const =0
void Fill(long long x)
float rechitmatchederryy[MAXHIT]
MonitorElement * meErrxRphiTEC[7]
float rechitmatchederrxy[MAXHIT]
MonitorElement * meChi2RphiTOB[6]
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
float xy() const
Definition: LocalError.h:25
MonitorElement * meResSasTOB[2]
MonitorElement * mePullMFRphiTID[3]
MonitorElement * mePosxRphiTEC[7]
MonitorElement * meResRphiTOB[6]
MonitorElement * mePosxSasTID[2]
MonitorElement * meNumMatchedTIB
float rechitsaspullMF[MAXHIT]
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
float yy() const
Definition: LocalError.h:26
Local3DPoint localPosition() const
Definition: PSimHit.h:44
MonitorElement * meNumTotMatched
MonitorElement * meErryMatchedTEC[5]
MonitorElement * mePullMFSasTID[2]
MonitorElement * meResyMatchedTOB[2]
MonitorElement * mePullMFRphiTEC[7]
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MonitorElement * meErrxSasTIB[4]
virtual const Topology & topology() const
Returns a reference to the strip proxy topology.
MonitorElement * meChi2SasTOB[2]
MonitorElement * meAdcRphiTOB[6]
float uu() const
MonitorElement * meChi2SasTEC[5]
edm::EDGetTokenT< SiStripMatchedRecHit2DCollection > siStripMatchedRecHit2DCollectionToken_
int j
Definition: DBlmapReader.cc:9
MonitorElement * meErrxSasTOB[2]
MonitorElement * mePosxMatchedTOB[2]
float rechitmatchedz[MAXHIT]
MonitorElement * mePosyMatchedTIB[2]
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
MonitorElement * meResRphiTIB[4]
float rechitmatchedx[MAXHIT]
MonitorElement * meChi2RphiTIB[4]
MonitorElement * meErrxMatchedTEC[5]
MonitorElement * meChi2SasTIB[4]
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
MonitorElement * mePosyMatchedTID[2]
MonitorElement * mePullLFRphiTEC[7]
std::pair< typename T::DetSet::const_iterator, typename T::DetSet::const_iterator > getRange(const T &detset, const DetId &id)
MonitorElement * meAdcSasTIB[4]
virtual const GeomDet * idToDet(DetId) const
MonitorElement * mePosxSasTIB[4]
DQMStore * dbe_
MonitorElement * meChi2MatchedTOB[2]
int k[5][pyjets_maxn]
MonitorElement * meResSasTEC[5]
MonitorElement * mePosxRphiTIB[4]
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Definition: PSimHit.h:52
MonitorElement * meNstpSasTIB[4]
SiStripRecHitsValid(const edm::ParameterSet &conf)
MonitorElement * mePullLFSasTOB[2]
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
MonitorElement * meErrxRphiTOB[6]
MonitorElement * meResyMatchedTEC[5]
MonitorElement * meErrxRphiTID[3]
MonitorElement * meAdcSasTID[2]
MonitorElement * meResxMatchedTIB[2]
MonitorElement * meErryMatchedTIB[2]
MonitorElement * meNumRphiTEC
MonitorElement * mePosxSasTOB[2]
MonitorElement * meNstpSasTID[2]
edm::EDGetTokenT< SiStripRecHit2DCollection > siStripRecHit2DCollection_stereo_Token_
MonitorElement * mePullLFSasTID[2]
MonitorElement * meAdcSasTEC[5]
const T & get() const
Definition: EventSetup.h:55
MonitorElement * mePullLFRphiTOB[6]
MonitorElement * mePullMFSasTEC[5]
MonitorElement * meNumTotSas
MonitorElement * meNumSasTEC
float rechitrphipullMF[MAXHIT]
std::pair< LocalPoint, LocalVector > projectHit(const PSimHit &hit, const StripGeomDetUnit *stripDet, const BoundPlane &plane)
float rechitrphierrx[MAXHIT]
MonitorElement * meErryMatchedTOB[2]
MonitorElement * meChi2MatchedTEC[5]
MonitorElement * mePosxMatchedTEC[5]
MonitorElement * mePosxSasTEC[5]
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
float rechitmatchedy[MAXHIT]
edm::ParameterSet conf_
edm::EventID id() const
Definition: EventBase.h:56
MonitorElement * mePullMFSasTOB[2]
MonitorElement * mePullMFRphiTIB[4]
MonitorElement * mePosxMatchedTID[2]
edm::EDGetTokenT< SiStripRecHit2DCollection > siStripRecHit2DCollection_rphi_Token_
CLHEP::HepSymMatrix AlgebraicSymMatrix
MonitorElement * meResxMatchedTOB[2]
MonitorElement * meResSasTIB[4]
std::vector< PSimHit > associateHit(const TrackingRecHit &thit)
MonitorElement * mePullMFSasTIB[4]
MonitorElement * meErrxMatchedTID[2]
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
dbl *** dir
Definition: mlp_gen.cc:35
Definition: DDAxes.h:10
MonitorElement * meNumSasTID
MonitorElement * meResyMatchedTIB[2]
MonitorElement * meAdcRphiTID[3]
MonitorElement * meNumRphiTOB
static constexpr int MAXHIT
T x() const
Definition: PV2DBase.h:45
long double T
MonitorElement * meChi2SasTID[2]
T x() const
Definition: PV3DBase.h:62
MonitorElement * meNumMatchedTEC
DetId operator()(const X &x)
MonitorElement * meErrxSasTID[2]
MonitorElement * mePosxMatchedTIB[2]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Definition: Run.h:41
MonitorElement * meResRphiTID[3]
MonitorElement * meNstpRphiTOB[6]
MonitorElement * mePosyMatchedTOB[2]
MonitorElement * meAdcSasTOB[2]