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