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