CMS 3D CMS Logo

TestSmoothHits.cc
Go to the documentation of this file.
1 #include "TestSmoothHits.h"
2 
11 #include <TDirectory.h>
13 
17 
20 using namespace std;
21 using namespace edm;
22 
23 TestSmoothHits::TestSmoothHits(const edm::ParameterSet& iConfig) : trackerHitAssociatorConfig_(consumesCollector()) {
24  LogTrace("TestSmoothHits") << iConfig << std::endl;
25  propagatorName = iConfig.getParameter<std::string>("Propagator");
26  builderName = iConfig.getParameter<std::string>("TTRHBuilder");
27  srcName = iConfig.getParameter<std::string>("src");
28  fname = iConfig.getParameter<std::string>("Fitter");
29  sname = iConfig.getParameter<std::string>("Smoother");
30  mineta = iConfig.getParameter<double>("mineta");
31  maxeta = iConfig.getParameter<double>("maxeta");
32 }
33 
35 
43 
44  file = new TFile("testSmoothHits.root", "recreate");
45  for (int i = 0; i != 6; i++)
46  for (int j = 0; j != 9; j++) {
47  if (i == 0 && j > 2)
48  break;
49  if (i == 1 && j > 1)
50  break;
51  if (i == 2 && j > 3)
52  break;
53  if (i == 3 && j > 2)
54  break;
55  if (i == 4 && j > 5)
56  break;
57  if (i == 5 && j > 8)
58  break;
59  title.str("");
60  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts";
61  hPullGP_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
62  title.str("");
63  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts";
64  hPullGP_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
65  title.str("");
66  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts";
67  hPullGP_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
68  title.str("");
69  title << "Chi2Increment_" << i + 1 << "-" << j + 1;
70  hChi2Increment[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100);
71 
72  title.str("");
73  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts";
74  hPullGM_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
75  title.str("");
76  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts";
77  hPullGM_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
78  title.str("");
79  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts";
80  hPullGM_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
81 
82  title.str("");
83  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr";
84  hPullGP_X_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
85  title.str("");
86  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr";
87  hPullGP_Y_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
88  title.str("");
89  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr";
90  hPullGP_Z_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
91 
92  title.str("");
93  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs";
94  hPullGP_X_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
95  title.str("");
96  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs";
97  hPullGP_Y_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
98  title.str("");
99  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs";
100  hPullGP_Z_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
101 
102  if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) {
103  //mono
104  title.str("");
105  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
106  hPullGP_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
107  title.str("");
108  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
109  hPullGP_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
110  title.str("");
111  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
112  hPullGP_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
113 
114  title.str("");
115  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
116  hPullGM_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
117  title.str("");
118  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
119  hPullGM_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
120  title.str("");
121  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
122  hPullGM_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
123 
124  title.str("");
125  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono";
126  hPullGP_X_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
127  title.str("");
128  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono";
129  hPullGP_Y_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
130  title.str("");
131  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono";
132  hPullGP_Z_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
133 
134  title.str("");
135  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono";
136  hPullGP_X_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
137  title.str("");
138  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono";
139  hPullGP_Y_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
140  title.str("");
141  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono";
142  hPullGP_Z_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
143 
144  //stereo
145  title.str("");
146  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
147  hPullGP_X_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
148  title.str("");
149  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
150  hPullGP_Y_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
151  title.str("");
152  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
153  hPullGP_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
154 
155  title.str("");
156  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
157  hPullGM_X_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
158  title.str("");
159  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
160  hPullGM_Y_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
161  title.str("");
162  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
163  hPullGM_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
164 
165  title.str("");
166  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo";
167  hPullGP_X_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
168  title.str("");
169  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo";
170  hPullGP_Y_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
171  title.str("");
172  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo";
173  hPullGP_Z_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
174 
175  title.str("");
176  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo";
177  hPullGP_X_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
178  title.str("");
179  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo";
180  hPullGP_Y_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
181  title.str("");
182  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo";
183  hPullGP_Z_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
184  }
185  }
186  hTotChi2Increment = new TH1F("TotChi2Increment", "TotChi2Increment", 1000, 0, 100);
187  hChi2_vs_Process = new TH2F("Chi2_vs_Process", "Chi2_vs_Process", 1000, 0, 100, 17, -0.5, 16.5);
188  hChi2_vs_clsize = new TH2F("Chi2_vs_clsize", "Chi2_vs_clsize", 1000, 0, 100, 17, -0.5, 16.5);
189 }
190 
192  //Retrieve tracker topology from geometry
194  iSetup.get<TrackerTopologyRcd>().get(tTopo);
195 
196  LogTrace("TestSmoothHits") << "new event" << std::endl;
197 
198  iEvent.getByLabel(srcName, theTCCollection);
200 
202 
203  for (TrackCandidateCollection::const_iterator i = theTCCollection->begin(); i != theTCCollection->end(); i++) {
204  LogTrace("TestSmoothHits") << "new candidate" << std::endl;
205 
206  const TrackCandidate* theTC = &(*i);
208  const TrackCandidate::range& recHitVec = theTC->recHits();
209 
210  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
211 
212  DetId detId(state.detId());
213  TrajectoryStateOnSurface theTSOS =
215 
216  if (theTSOS.globalMomentum().eta() > maxeta || theTSOS.globalMomentum().eta() < mineta)
217  continue;
218 
219  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
221 
222  for (edm::OwnVector<TrackingRecHit>::const_iterator i = recHitVec.first; i != recHitVec.second; i++) {
223  hits.push_back(theBuilder->build(&(*i)));
224  }
225 
226  //call the fitter
227  std::vector<Trajectory> fitted = fit->fit(theTC->seed(), hits, theTSOS);
228  //call the smoother
229  std::vector<Trajectory> result;
230  for (std::vector<Trajectory>::iterator it = fitted.begin(); it != fitted.end(); it++) {
231  std::vector<Trajectory> smoothed = smooth->trajectories(*it);
232  result.insert(result.end(), smoothed.begin(), smoothed.end());
233  }
234  if (result.empty())
235  continue;
236  std::vector<TrajectoryMeasurement> vtm = result[0].measurements();
237 
238  TSOS lastState = theTSOS;
239  for (std::vector<TrajectoryMeasurement>::iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
241  if ((rhit)->isValid() == 0 && rhit->det() != nullptr)
242  continue;
243  LogTrace("TestSmoothHits") << "new hit";
244 
245  int subdetId = rhit->det()->geographicalId().subdetId();
246  DetId id = rhit->det()->geographicalId();
247  int layerId = tTopo->layer(id);
248  LogTrace("TestSmoothHits") << "subdetId=" << subdetId << " layerId=" << layerId;
249 
250  double delta = 99999;
251  LocalPoint rhitLPv = rhit->localPosition();
252 
253  std::vector<PSimHit> assSimHits = hitAssociator.associateHit(*(rhit->hit()));
254  if (assSimHits.empty())
255  continue;
256  PSimHit shit;
257  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
258  if ((m->localPosition() - rhitLPv).mag() < delta) {
259  shit = *m;
260  delta = (m->localPosition() - rhitLPv).mag();
261  }
262  }
263 
264  TSOS currentState = combiner(tm->backwardPredictedState(), tm->forwardPredictedState());
265  TSOS updatedState = tm->updatedState();
266 
267  //plot chi2 increment
268  double chi2increment = tm->estimate();
269  LogTrace("TestSmoothHits") << "tm->estimate()=" << tm->estimate();
270  title.str("");
271  title << "Chi2Increment_" << subdetId << "-" << layerId;
272  hChi2Increment[title.str()]->Fill(chi2increment);
273  hTotChi2Increment->Fill(chi2increment);
274  hChi2_vs_Process->Fill(chi2increment, shit.processType());
275  if (dynamic_cast<const SiPixelRecHit*>(rhit->hit()))
276  hChi2_vs_clsize->Fill(chi2increment, ((const SiPixelRecHit*)(rhit->hit()))->cluster()->size());
277  if (dynamic_cast<const SiStripRecHit2D*>(rhit->hit()))
278  hChi2_vs_clsize->Fill(chi2increment, ((const SiStripRecHit2D*)(rhit->hit()))->cluster()->amplitudes().size());
279 
280  //test hits
281  const Surface* surf = &((rhit)->det()->surface());
282  LocalVector shitLMom;
283  LocalPoint shitLPos;
284  if (dynamic_cast<const SiStripMatchedRecHit2D*>(rhit->hit())) {
285  double rechitmatchedx = rhit->localPosition().x();
286  double rechitmatchedy = rhit->localPosition().y();
287  double mindist = 999999;
288  float distx, disty;
289  std::pair<LocalPoint, LocalVector> closestPair;
290  const StripGeomDetUnit* stripDet = (StripGeomDetUnit*)((const GluedGeomDet*)(rhit)->det())->stereoDet();
291  const BoundPlane& plane = (rhit)->det()->surface();
292  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
293  //project simhit;
294  std::pair<LocalPoint, LocalVector> hitPair = projectHit((*m), stripDet, plane);
295  distx = fabs(rechitmatchedx - hitPair.first.x());
296  disty = fabs(rechitmatchedy - hitPair.first.y());
297  double dist = distx * distx + disty * disty;
298  if (sqrt(dist) < mindist) {
299  mindist = dist;
300  closestPair = hitPair;
301  }
302  }
303  shitLPos = closestPair.first;
304  shitLMom = closestPair.second;
305  } else {
306  shitLPos = shit.localPosition();
307  shitLMom = shit.momentumAtEntry();
308  }
309  GlobalVector shitGMom = surf->toGlobal(shitLMom);
310  GlobalPoint shitGPos = surf->toGlobal(shitLPos);
311  // if (dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())) {
312  // double rechitmatchedx = rhit->localPosition().x();
313  // double rechitmatchedy = rhit->localPosition().y();
314  // double mindist = 999999;
315  // double distx, disty;
316  // std::pair<LocalPoint,LocalVector> closestPair;
317  // const StripGeomDetUnit* stripDet =(StripGeomDetUnit*) ((const GluedGeomDet *)(rhit)->det())->stereoDet();
318  // const BoundPlane& plane = (rhit)->det()->surface();
319  // for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
320  // const PSimHit& hit = *m;
321  // const StripTopology& topol = stripDet->specificTopology();
322  // GlobalPoint globalpos = stripDet->surface().toGlobal(hit.localPosition());
323  // LocalPoint localHit = plane.toLocal(globalpos);
324  // //track direction
325  // LocalVector locdir=hit.localDirection();
326  // //rotate track in new frame
327  // GlobalVector globaldir= stripDet->surface().toGlobal(locdir);
328  // LocalVector dir=plane.toLocal(globaldir);
329  // float scale = -localHit.z() / dir.z();
330  // LocalPoint projectedPos = localHit + scale*dir;
331  // float selfAngle = topol.stripAngle( topol.strip( hit.localPosition()));
332  // LocalVector stripDir( sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
333  // LocalVector localStripDir = LocalVector( plane.toLocal(stripDet->surface().toGlobal( stripDir)));
334  // std::pair<LocalPoint,LocalVector> hitPair( projectedPos, localStripDir);
335  // distx = fabs(rechitmatchedx - hitPair.first.x());
336  // disty = fabs(rechitmatchedy - hitPair.first.y());
337  // double dist = distx*distx+disty*disty;
338  // if(sqrt(dist)<mindist){
339  // mindist = dist;
340  // closestPair = hitPair;
341  // }
342  // }
343  // shitLPos = closestPair.first;
344  // shitLMom = closestPair.second;
345  // } else {
346  // shitLPos = shit.localPosition();
347  // shitLMom = shit.momentumAtEntry();
348  // }
349  // GlobalVector shitGMom = surf->toGlobal(shitLMom);
350  // GlobalPoint shitGPos = surf->toGlobal(shitLPos);
351 
352  GlobalVector tsosGMom = currentState.globalMomentum();
353  GlobalError tsosGMEr(currentState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
354  GlobalPoint tsosGPos = currentState.globalPosition();
355  GlobalError tsosGPEr = currentState.cartesianError().position();
356 
357  GlobalPoint rhitGPos = (rhit)->globalPosition();
358  GlobalError rhitGPEr = (rhit)->globalPositionError();
359 
360  double pullGPX_rs = (rhitGPos.x() - shitGPos.x()) / sqrt(rhitGPEr.cxx());
361  double pullGPY_rs = (rhitGPos.y() - shitGPos.y()) / sqrt(rhitGPEr.cyy());
362  double pullGPZ_rs = (rhitGPos.z() - shitGPos.z()) / sqrt(rhitGPEr.czz());
363  //double pullGPX_rs = (rhitGPos.x()-shitGPos.x());
364  //double pullGPY_rs = (rhitGPos.y()-shitGPos.y());
365  //double pullGPZ_rs = (rhitGPos.z()-shitGPos.z());
366 
367  LogTrace("TestSmoothHits") << "rs" << std::endl;
368 
369  title.str("");
370  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs";
371  hPullGP_X_rs[title.str()]->Fill(pullGPX_rs);
372  title.str("");
373  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs";
374  hPullGP_Y_rs[title.str()]->Fill(pullGPY_rs);
375  title.str("");
376  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs";
377  hPullGP_Z_rs[title.str()]->Fill(pullGPZ_rs);
378 
379  double pullGPX_tr = (tsosGPos.x() - rhitGPos.x()) / sqrt(tsosGPEr.cxx() + rhitGPEr.cxx());
380  double pullGPY_tr = (tsosGPos.y() - rhitGPos.y()) / sqrt(tsosGPEr.cyy() + rhitGPEr.cyy());
381  double pullGPZ_tr = (tsosGPos.z() - rhitGPos.z()) / sqrt(tsosGPEr.czz() + rhitGPEr.czz());
382  //double pullGPX_tr = (tsosGPos.x()-rhitGPos.x());
383  //double pullGPY_tr = (tsosGPos.y()-rhitGPos.y());
384  //double pullGPZ_tr = (tsosGPos.z()-rhitGPos.z());
385 
386  LogTrace("TestSmoothHits") << "tr" << std::endl;
387 
388  title.str("");
389  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr";
390  hPullGP_X_tr[title.str()]->Fill(pullGPX_tr);
391  title.str("");
392  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr";
393  hPullGP_Y_tr[title.str()]->Fill(pullGPY_tr);
394  title.str("");
395  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr";
396  hPullGP_Z_tr[title.str()]->Fill(pullGPZ_tr);
397 
398  double pullGPX_ts = (tsosGPos.x() - shitGPos.x()) / sqrt(tsosGPEr.cxx());
399  double pullGPY_ts = (tsosGPos.y() - shitGPos.y()) / sqrt(tsosGPEr.cyy());
400  double pullGPZ_ts = (tsosGPos.z() - shitGPos.z()) / sqrt(tsosGPEr.czz());
401  //double pullGPX_ts = (tsosGPos.x()-shitGPos.x());
402  //double pullGPY_ts = (tsosGPos.y()-shitGPos.y());
403  //double pullGPZ_ts = (tsosGPos.z()-shitGPos.z());
404 
405  LogTrace("TestSmoothHits") << "ts1" << std::endl;
406 
407  title.str("");
408  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts";
409  hPullGP_X_ts[title.str()]->Fill(pullGPX_ts);
410  title.str("");
411  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts";
412  hPullGP_Y_ts[title.str()]->Fill(pullGPY_ts);
413  title.str("");
414  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts";
415  hPullGP_Z_ts[title.str()]->Fill(pullGPZ_ts);
416 
417  double pullGMX_ts = (tsosGMom.x() - shitGMom.x()) / sqrt(tsosGMEr.cxx());
418  double pullGMY_ts = (tsosGMom.y() - shitGMom.y()) / sqrt(tsosGMEr.cyy());
419  double pullGMZ_ts = (tsosGMom.z() - shitGMom.z()) / sqrt(tsosGMEr.czz());
420  //double pullGMX_ts = (tsosGMom.x()-shitGMom.x());
421  //double pullGMY_ts = (tsosGMom.y()-shitGMom.y());
422  //double pullGMZ_ts = (tsosGMom.z()-shitGMom.z());
423 
424  LogTrace("TestSmoothHits") << "ts2" << std::endl;
425 
426  title.str("");
427  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts";
428  hPullGM_X_ts[title.str()]->Fill(pullGMX_ts);
429  title.str("");
430  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts";
431  hPullGM_Y_ts[title.str()]->Fill(pullGMY_ts);
432  title.str("");
433  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts";
434  hPullGM_Z_ts[title.str()]->Fill(pullGMZ_ts);
435 
436  if (dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())) {
437  //mono
438  LogTrace("TestSmoothHits") << "MONO HIT" << std::endl;
439  auto m = dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())->monoHit();
440  CTTRHp tMonoHit = theBuilder->build(&m);
441  if (tMonoHit == nullptr)
442  continue;
443  vector<PSimHit> assMonoSimHits = hitAssociator.associateHit(*tMonoHit->hit());
444  if (assMonoSimHits.empty())
445  continue;
446  const PSimHit sMonoHit = *(assSimHits.begin());
447  const Surface* monoSurf = &(tMonoHit->det()->surface());
448  if (monoSurf == nullptr)
449  continue;
450  TSOS monoState = thePropagator->propagate(lastState, *monoSurf);
451  if (monoState.isValid() == 0)
452  continue;
453 
454  LocalVector monoShitLMom = sMonoHit.momentumAtEntry();
455  GlobalVector monoShitGMom = monoSurf->toGlobal(monoShitLMom);
456  LocalPoint monoShitLPos = sMonoHit.localPosition();
457  GlobalPoint monoShitGPos = monoSurf->toGlobal(monoShitLPos);
458 
459  GlobalVector monoTsosGMom = monoState.globalMomentum();
460  GlobalError monoTsosGMEr(monoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
461  GlobalPoint monoTsosGPos = monoState.globalPosition();
462  GlobalError monoTsosGPEr = monoState.cartesianError().position();
463 
464  GlobalPoint monoRhitGPos = tMonoHit->globalPosition();
465  GlobalError monoRhitGPEr = tMonoHit->globalPositionError();
466 
467  double pullGPX_rs_mono = (monoRhitGPos.x() - monoShitGPos.x()) / sqrt(monoRhitGPEr.cxx());
468  double pullGPY_rs_mono = (monoRhitGPos.y() - monoShitGPos.y()) / sqrt(monoRhitGPEr.cyy());
469  double pullGPZ_rs_mono = (monoRhitGPos.z() - monoShitGPos.z()) / sqrt(monoRhitGPEr.czz());
470  //double pullGPX_rs_mono = (monoRhitGPos.x()-monoShitGPos.x());
471  //double pullGPY_rs_mono = (monoRhitGPos.y()-monoShitGPos.y());
472  //double pullGPZ_rs_mono = (monoRhitGPos.z()-monoShitGPos.z());
473 
474  title.str("");
475  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_mono";
476  hPullGP_X_rs_mono[title.str()]->Fill(pullGPX_rs_mono);
477  title.str("");
478  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_mono";
479  hPullGP_Y_rs_mono[title.str()]->Fill(pullGPY_rs_mono);
480  title.str("");
481  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_mono";
482  hPullGP_Z_rs_mono[title.str()]->Fill(pullGPZ_rs_mono);
483 
484  double pullGPX_tr_mono = (monoTsosGPos.x() - monoRhitGPos.x()) / sqrt(monoTsosGPEr.cxx() + monoRhitGPEr.cxx());
485  double pullGPY_tr_mono = (monoTsosGPos.y() - monoRhitGPos.y()) / sqrt(monoTsosGPEr.cyy() + monoRhitGPEr.cyy());
486  double pullGPZ_tr_mono = (monoTsosGPos.z() - monoRhitGPos.z()) / sqrt(monoTsosGPEr.czz() + monoRhitGPEr.czz());
487  //double pullGPX_tr_mono = (monoTsosGPos.x()-monoRhitGPos.x());
488  //double pullGPY_tr_mono = (monoTsosGPos.y()-monoRhitGPos.y());
489  //double pullGPZ_tr_mono = (monoTsosGPos.z()-monoRhitGPos.z());
490 
491  title.str("");
492  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_mono";
493  hPullGP_X_tr_mono[title.str()]->Fill(pullGPX_tr_mono);
494  title.str("");
495  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_mono";
496  hPullGP_Y_tr_mono[title.str()]->Fill(pullGPY_tr_mono);
497  title.str("");
498  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_mono";
499  hPullGP_Z_tr_mono[title.str()]->Fill(pullGPZ_tr_mono);
500 
501  double pullGPX_ts_mono = (monoTsosGPos.x() - monoShitGPos.x()) / sqrt(monoTsosGPEr.cxx());
502  double pullGPY_ts_mono = (monoTsosGPos.y() - monoShitGPos.y()) / sqrt(monoTsosGPEr.cyy());
503  double pullGPZ_ts_mono = (monoTsosGPos.z() - monoShitGPos.z()) / sqrt(monoTsosGPEr.czz());
504  //double pullGPX_ts_mono = (monoTsosGPos.x()-monoShitGPos.x());
505  //double pullGPY_ts_mono = (monoTsosGPos.y()-monoShitGPos.y());
506  //double pullGPZ_ts_mono = (monoTsosGPos.z()-monoShitGPos.z());
507 
508  title.str("");
509  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_mono";
510  hPullGP_X_ts_mono[title.str()]->Fill(pullGPX_ts_mono);
511  title.str("");
512  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_mono";
513  hPullGP_Y_ts_mono[title.str()]->Fill(pullGPY_ts_mono);
514  title.str("");
515  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_mono";
516  hPullGP_Z_ts_mono[title.str()]->Fill(pullGPZ_ts_mono);
517 
518  double pullGMX_ts_mono = (monoTsosGMom.x() - monoShitGMom.x()) / sqrt(monoTsosGMEr.cxx());
519  double pullGMY_ts_mono = (monoTsosGMom.y() - monoShitGMom.y()) / sqrt(monoTsosGMEr.cyy());
520  double pullGMZ_ts_mono = (monoTsosGMom.z() - monoShitGMom.z()) / sqrt(monoTsosGMEr.czz());
521  //double pullGMX_ts_mono = (monoTsosGMom.x()-monoShitGMom.x());
522  //double pullGMY_ts_mono = (monoTsosGMom.y()-monoShitGMom.y());
523  //double pullGMZ_ts_mono = (monoTsosGMom.z()-monoShitGMom.z());
524 
525  title.str("");
526  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_mono";
527  hPullGM_X_ts_mono[title.str()]->Fill(pullGMX_ts_mono);
528  title.str("");
529  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_mono";
530  hPullGM_Y_ts_mono[title.str()]->Fill(pullGMY_ts_mono);
531  title.str("");
532  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_mono";
533  hPullGM_Z_ts_mono[title.str()]->Fill(pullGMZ_ts_mono);
534 
535  //stereo
536  LogTrace("TestSmoothHits") << "STEREO HIT" << std::endl;
537  auto s = dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())->stereoHit();
538  CTTRHp tStereoHit = theBuilder->build(&s);
539  if (tStereoHit == nullptr)
540  continue;
541  vector<PSimHit> assStereoSimHits = hitAssociator.associateHit(*tStereoHit->hit());
542  if (assStereoSimHits.empty())
543  continue;
544  const PSimHit sStereoHit = *(assSimHits.begin());
545  const Surface* stereoSurf = &(tStereoHit->det()->surface());
546  if (stereoSurf == nullptr)
547  continue;
548  TSOS stereoState = thePropagator->propagate(lastState, *stereoSurf);
549  if (stereoState.isValid() == 0)
550  continue;
551 
552  LocalVector stereoShitLMom = sStereoHit.momentumAtEntry();
553  GlobalVector stereoShitGMom = stereoSurf->toGlobal(stereoShitLMom);
554  LocalPoint stereoShitLPos = sStereoHit.localPosition();
555  GlobalPoint stereoShitGPos = stereoSurf->toGlobal(stereoShitLPos);
556 
557  GlobalVector stereoTsosGMom = stereoState.globalMomentum();
558  GlobalError stereoTsosGMEr(stereoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
559  GlobalPoint stereoTsosGPos = stereoState.globalPosition();
560  GlobalError stereoTsosGPEr = stereoState.cartesianError().position();
561 
562  GlobalPoint stereoRhitGPos = tStereoHit->globalPosition();
563  GlobalError stereoRhitGPEr = tStereoHit->globalPositionError();
564 
565  double pullGPX_rs_stereo = (stereoRhitGPos.x() - stereoShitGPos.x()) / sqrt(stereoRhitGPEr.cxx());
566  double pullGPY_rs_stereo = (stereoRhitGPos.y() - stereoShitGPos.y()) / sqrt(stereoRhitGPEr.cyy());
567  double pullGPZ_rs_stereo = (stereoRhitGPos.z() - stereoShitGPos.z()) / sqrt(stereoRhitGPEr.czz());
568  //double pullGPX_rs_stereo = (stereoRhitGPos.x()-stereoShitGPos.x());
569  //double pullGPY_rs_stereo = (stereoRhitGPos.y()-stereoShitGPos.y());
570  //double pullGPZ_rs_stereo = (stereoRhitGPos.z()-stereoShitGPos.z());
571 
572  title.str("");
573  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_stereo";
574  hPullGP_X_rs_stereo[title.str()]->Fill(pullGPX_rs_stereo);
575  title.str("");
576  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_stereo";
577  hPullGP_Y_rs_stereo[title.str()]->Fill(pullGPY_rs_stereo);
578  title.str("");
579  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_stereo";
580  hPullGP_Z_rs_stereo[title.str()]->Fill(pullGPZ_rs_stereo);
581 
582  double pullGPX_tr_stereo =
583  (stereoTsosGPos.x() - stereoRhitGPos.x()) / sqrt(stereoTsosGPEr.cxx() + stereoRhitGPEr.cxx());
584  double pullGPY_tr_stereo =
585  (stereoTsosGPos.y() - stereoRhitGPos.y()) / sqrt(stereoTsosGPEr.cyy() + stereoRhitGPEr.cyy());
586  double pullGPZ_tr_stereo =
587  (stereoTsosGPos.z() - stereoRhitGPos.z()) / sqrt(stereoTsosGPEr.czz() + stereoRhitGPEr.czz());
588  //double pullGPX_tr_stereo = (stereoTsosGPos.x()-stereoRhitGPos.x());
589  //double pullGPY_tr_stereo = (stereoTsosGPos.y()-stereoRhitGPos.y());
590  //double pullGPZ_tr_stereo = (stereoTsosGPos.z()-stereoRhitGPos.z());
591 
592  title.str("");
593  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_stereo";
594  hPullGP_X_tr_stereo[title.str()]->Fill(pullGPX_tr_stereo);
595  title.str("");
596  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_stereo";
597  hPullGP_Y_tr_stereo[title.str()]->Fill(pullGPY_tr_stereo);
598  title.str("");
599  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_stereo";
600  hPullGP_Z_tr_stereo[title.str()]->Fill(pullGPZ_tr_stereo);
601 
602  double pullGPX_ts_stereo = (stereoTsosGPos.x() - stereoShitGPos.x()) / sqrt(stereoTsosGPEr.cxx());
603  double pullGPY_ts_stereo = (stereoTsosGPos.y() - stereoShitGPos.y()) / sqrt(stereoTsosGPEr.cyy());
604  double pullGPZ_ts_stereo = (stereoTsosGPos.z() - stereoShitGPos.z()) / sqrt(stereoTsosGPEr.czz());
605  //double pullGPX_ts_stereo = (stereoTsosGPos.x()-stereoShitGPos.x());
606  //double pullGPY_ts_stereo = (stereoTsosGPos.y()-stereoShitGPos.y());
607  //double pullGPZ_ts_stereo = (stereoTsosGPos.z()-stereoShitGPos.z());
608 
609  title.str("");
610  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_stereo";
611  hPullGP_X_ts_stereo[title.str()]->Fill(pullGPX_ts_stereo);
612  title.str("");
613  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_stereo";
614  hPullGP_Y_ts_stereo[title.str()]->Fill(pullGPY_ts_stereo);
615  title.str("");
616  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_stereo";
617  hPullGP_Z_ts_stereo[title.str()]->Fill(pullGPZ_ts_stereo);
618 
619  double pullGMX_ts_stereo = (stereoTsosGMom.x() - stereoShitGMom.x()) / sqrt(stereoTsosGMEr.cxx());
620  double pullGMY_ts_stereo = (stereoTsosGMom.y() - stereoShitGMom.y()) / sqrt(stereoTsosGMEr.cyy());
621  double pullGMZ_ts_stereo = (stereoTsosGMom.z() - stereoShitGMom.z()) / sqrt(stereoTsosGMEr.czz());
622  //double pullGMX_ts_stereo = (stereoTsosGMom.x()-stereoShitGMom.x());
623  //double pullGMY_ts_stereo = (stereoTsosGMom.y()-stereoShitGMom.y());
624  //double pullGMZ_ts_stereo = (stereoTsosGMom.z()-stereoShitGMom.z());
625 
626  title.str("");
627  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_stereo";
628  hPullGM_X_ts_stereo[title.str()]->Fill(pullGMX_ts_stereo);
629  title.str("");
630  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_stereo";
631  hPullGM_Y_ts_stereo[title.str()]->Fill(pullGMY_ts_stereo);
632  title.str("");
633  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_stereo";
634  hPullGM_Z_ts_stereo[title.str()]->Fill(pullGMZ_ts_stereo);
635  }
636  lastState = updatedState;
637  //#endif
638  }
639  }
640  LogTrace("TestSmoothHits") << "end of event" << std::endl;
641 }
642 
644  //file->Write();
645  TDirectory* chi2i = file->mkdir("Chi2_Increment");
646 
647  TDirectory* gp_ts = file->mkdir("GP_TSOS-SimHit");
648  TDirectory* gm_ts = file->mkdir("GM_TSOS-SimHit");
649  TDirectory* gp_tr = file->mkdir("GP_TSOS-RecHit");
650  TDirectory* gp_rs = file->mkdir("GP_RecHit-SimHit");
651 
652  TDirectory* gp_tsx = gp_ts->mkdir("X");
653  TDirectory* gp_tsy = gp_ts->mkdir("Y");
654  TDirectory* gp_tsz = gp_ts->mkdir("Z");
655  TDirectory* gm_tsx = gm_ts->mkdir("X");
656  TDirectory* gm_tsy = gm_ts->mkdir("Y");
657  TDirectory* gm_tsz = gm_ts->mkdir("Z");
658  TDirectory* gp_trx = gp_tr->mkdir("X");
659  TDirectory* gp_try = gp_tr->mkdir("Y");
660  TDirectory* gp_trz = gp_tr->mkdir("Z");
661  TDirectory* gp_rsx = gp_rs->mkdir("X");
662  TDirectory* gp_rsy = gp_rs->mkdir("Y");
663  TDirectory* gp_rsz = gp_rs->mkdir("Z");
664 
665  TDirectory* gp_tsx_mono = gp_ts->mkdir("MONOX");
666  TDirectory* gp_tsy_mono = gp_ts->mkdir("MONOY");
667  TDirectory* gp_tsz_mono = gp_ts->mkdir("MONOZ");
668  TDirectory* gm_tsx_mono = gm_ts->mkdir("MONOX");
669  TDirectory* gm_tsy_mono = gm_ts->mkdir("MONOY");
670  TDirectory* gm_tsz_mono = gm_ts->mkdir("MONOZ");
671  TDirectory* gp_trx_mono = gp_tr->mkdir("MONOX");
672  TDirectory* gp_try_mono = gp_tr->mkdir("MONOY");
673  TDirectory* gp_trz_mono = gp_tr->mkdir("MONOZ");
674  TDirectory* gp_rsx_mono = gp_rs->mkdir("MONOX");
675  TDirectory* gp_rsy_mono = gp_rs->mkdir("MONOY");
676  TDirectory* gp_rsz_mono = gp_rs->mkdir("MONOZ");
677 
678  TDirectory* gp_tsx_stereo = gp_ts->mkdir("STEREOX");
679  TDirectory* gp_tsy_stereo = gp_ts->mkdir("STEREOY");
680  TDirectory* gp_tsz_stereo = gp_ts->mkdir("STEREOZ");
681  TDirectory* gm_tsx_stereo = gm_ts->mkdir("STEREOX");
682  TDirectory* gm_tsy_stereo = gm_ts->mkdir("STEREOY");
683  TDirectory* gm_tsz_stereo = gm_ts->mkdir("STEREOZ");
684  TDirectory* gp_trx_stereo = gp_tr->mkdir("STEREOX");
685  TDirectory* gp_try_stereo = gp_tr->mkdir("STEREOY");
686  TDirectory* gp_trz_stereo = gp_tr->mkdir("STEREOZ");
687  TDirectory* gp_rsx_stereo = gp_rs->mkdir("STEREOX");
688  TDirectory* gp_rsy_stereo = gp_rs->mkdir("STEREOY");
689  TDirectory* gp_rsz_stereo = gp_rs->mkdir("STEREOZ");
690 
691  chi2i->cd();
692  hTotChi2Increment->Write();
693  hChi2_vs_Process->Write();
694  hChi2_vs_clsize->Write();
695  for (int i = 0; i != 6; i++)
696  for (int j = 0; j != 9; j++) {
697  if (i == 0 && j > 2)
698  break;
699  if (i == 1 && j > 1)
700  break;
701  if (i == 2 && j > 3)
702  break;
703  if (i == 3 && j > 2)
704  break;
705  if (i == 4 && j > 5)
706  break;
707  if (i == 5 && j > 8)
708  break;
709  chi2i->cd();
710  title.str("");
711  title << "Chi2Increment_" << i + 1 << "-" << j + 1;
712  hChi2Increment[title.str()]->Write();
713 
714  gp_ts->cd();
715  gp_tsx->cd();
716  title.str("");
717  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts";
718  hPullGP_X_ts[title.str()]->Write();
719  gp_tsy->cd();
720  title.str("");
721  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts";
722  hPullGP_Y_ts[title.str()]->Write();
723  gp_tsz->cd();
724  title.str("");
725  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts";
726  hPullGP_Z_ts[title.str()]->Write();
727 
728  gm_ts->cd();
729  gm_tsx->cd();
730  title.str("");
731  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts";
732  hPullGM_X_ts[title.str()]->Write();
733  gm_tsy->cd();
734  title.str("");
735  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts";
736  hPullGM_Y_ts[title.str()]->Write();
737  gm_tsz->cd();
738  title.str("");
739  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts";
740  hPullGM_Z_ts[title.str()]->Write();
741 
742  gp_tr->cd();
743  gp_trx->cd();
744  title.str("");
745  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr";
746  hPullGP_X_tr[title.str()]->Write();
747  gp_try->cd();
748  title.str("");
749  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr";
750  hPullGP_Y_tr[title.str()]->Write();
751  gp_trz->cd();
752  title.str("");
753  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr";
754  hPullGP_Z_tr[title.str()]->Write();
755 
756  gp_rs->cd();
757  gp_rsx->cd();
758  title.str("");
759  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs";
760  hPullGP_X_rs[title.str()]->Write();
761  gp_rsy->cd();
762  title.str("");
763  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs";
764  hPullGP_Y_rs[title.str()]->Write();
765  gp_rsz->cd();
766  title.str("");
767  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs";
768  hPullGP_Z_rs[title.str()]->Write();
769 
770  if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) {
771  //mono
772  gp_ts->cd();
773  gp_tsx_mono->cd();
774  title.str("");
775  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
776  hPullGP_X_ts_mono[title.str()]->Write();
777  gp_tsy_mono->cd();
778  title.str("");
779  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
780  hPullGP_Y_ts_mono[title.str()]->Write();
781  gp_tsz_mono->cd();
782  title.str("");
783  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
784  hPullGP_Z_ts_mono[title.str()]->Write();
785 
786  gm_ts->cd();
787  gm_tsx_mono->cd();
788  title.str("");
789  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
790  hPullGM_X_ts_mono[title.str()]->Write();
791  gm_tsy_mono->cd();
792  title.str("");
793  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
794  hPullGM_Y_ts_mono[title.str()]->Write();
795  gm_tsz_mono->cd();
796  title.str("");
797  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
798  hPullGM_Z_ts_mono[title.str()]->Write();
799 
800  gp_tr->cd();
801  gp_trx_mono->cd();
802  title.str("");
803  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono";
804  hPullGP_X_tr_mono[title.str()]->Write();
805  gp_try_mono->cd();
806  title.str("");
807  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono";
808  hPullGP_Y_tr_mono[title.str()]->Write();
809  gp_trz_mono->cd();
810  title.str("");
811  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono";
812  hPullGP_Z_tr_mono[title.str()]->Write();
813 
814  gp_rs->cd();
815  gp_rsx_mono->cd();
816  title.str("");
817  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono";
818  hPullGP_X_rs_mono[title.str()]->Write();
819  gp_rsy_mono->cd();
820  title.str("");
821  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono";
822  hPullGP_Y_rs_mono[title.str()]->Write();
823  gp_rsz_mono->cd();
824  title.str("");
825  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono";
826  hPullGP_Z_rs_mono[title.str()]->Write();
827 
828  //stereo
829  gp_ts->cd();
830  gp_tsx_stereo->cd();
831  title.str("");
832  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
833  hPullGP_X_ts_stereo[title.str()]->Write();
834  gp_tsy_stereo->cd();
835  title.str("");
836  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
837  hPullGP_Y_ts_stereo[title.str()]->Write();
838  gp_tsz_stereo->cd();
839  title.str("");
840  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
841  hPullGP_Z_ts_stereo[title.str()]->Write();
842 
843  gm_ts->cd();
844  gm_tsx_stereo->cd();
845  title.str("");
846  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
847  hPullGM_X_ts_stereo[title.str()]->Write();
848  gm_tsy_stereo->cd();
849  title.str("");
850  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
851  hPullGM_Y_ts_stereo[title.str()]->Write();
852  gm_tsz_stereo->cd();
853  title.str("");
854  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
855  hPullGM_Z_ts_stereo[title.str()]->Write();
856 
857  gp_tr->cd();
858  gp_trx_stereo->cd();
859  title.str("");
860  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo";
861  hPullGP_X_tr_stereo[title.str()]->Write();
862  gp_try_stereo->cd();
863  title.str("");
864  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo";
865  hPullGP_Y_tr_stereo[title.str()]->Write();
866  gp_trz_stereo->cd();
867  title.str("");
868  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo";
869  hPullGP_Z_tr_stereo[title.str()]->Write();
870 
871  gp_rs->cd();
872  gp_rsx_stereo->cd();
873  title.str("");
874  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo";
875  hPullGP_X_rs_stereo[title.str()]->Write();
876  gp_rsy_stereo->cd();
877  title.str("");
878  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo";
879  hPullGP_Y_rs_stereo[title.str()]->Write();
880  gp_rsz_stereo->cd();
881  title.str("");
882  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo";
883  hPullGP_Z_rs_stereo[title.str()]->Write();
884  }
885  }
886 
887  file->Close();
888 }
889 
890 //needed by to do the residual for matched hits
891 //taken from SiStripTrackingRecHitsValid.cc
892 std::pair<LocalPoint, LocalVector> TestSmoothHits::projectHit(const PSimHit& hit,
893  const StripGeomDetUnit* stripDet,
894  const BoundPlane& plane) {
895  const StripTopology& topol = stripDet->specificTopology();
896  GlobalPoint globalpos = stripDet->surface().toGlobal(hit.localPosition());
897  LocalPoint localHit = plane.toLocal(globalpos);
898  //track direction
899  LocalVector locdir = hit.localDirection();
900  //rotate track in new frame
901 
902  GlobalVector globaldir = stripDet->surface().toGlobal(locdir);
903  LocalVector dir = plane.toLocal(globaldir);
904  float scale = -localHit.z() / dir.z();
905 
906  LocalPoint projectedPos = localHit + scale * dir;
907 
908  float selfAngle = topol.stripAngle(topol.strip(hit.localPosition()));
909 
910  LocalVector stripDir(sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
911 
912  LocalVector localStripDir(plane.toLocal(stripDet->surface().toGlobal(stripDir)));
913 
914  return std::pair<LocalPoint, LocalVector>(projectedPos, localStripDir);
915 }
916 
919 
Vector3DBase< float, LocalTag >
TrackCandidate::trajectoryStateOnDet
PTrajectoryStateOnDet const & trajectoryStateOnDet() const
Definition: TrackCandidate.h:56
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
TrajectoryStateCombiner.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TestSmoothHits::hPullGP_Z_ts_stereo
std::map< std::string, TH1F * > hPullGP_Z_ts_stereo
Definition: TestSmoothHits.h:113
TrajectoryStateOnSurface.h
TestSmoothHits::title
std::stringstream title
Definition: TestSmoothHits.h:81
TestSmoothHits::hPullGP_Y_tr_stereo
std::map< std::string, TH1F * > hPullGP_Y_tr_stereo
Definition: TestSmoothHits.h:121
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
mps_fire.i
i
Definition: mps_fire.py:355
TestSmoothHits::hPullGP_Y_tr
std::map< std::string, TH1F * > hPullGP_Y_tr
Definition: TestSmoothHits.h:92
TestSmoothHits::hPullGP_Y_rs_stereo
std::map< std::string, TH1F * > hPullGP_Y_rs_stereo
Definition: TestSmoothHits.h:118
TestSmoothHits::thePropagator
edm::ESHandle< Propagator > thePropagator
Definition: TestSmoothHits.h:74
MessageLogger.h
TestSmoothHits::maxeta
double maxeta
Definition: TestSmoothHits.h:64
TestSmoothHits::hPullGP_Z_tr_mono
std::map< std::string, TH1F * > hPullGP_Z_tr_mono
Definition: TestSmoothHits.h:109
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
TestSmoothHits::hPullGM_Y_ts_mono
std::map< std::string, TH1F * > hPullGM_Y_ts_mono
Definition: TestSmoothHits.h:102
TestSmoothHits::hPullGP_Z_ts_mono
std::map< std::string, TH1F * > hPullGP_Z_ts_mono
Definition: TestSmoothHits.h:100
TestSmoothHits::propagatorName
std::string propagatorName
Definition: TestSmoothHits.h:66
TrajectoryStateOnSurface::cartesianError
const CartesianTrajectoryError cartesianError() const
Definition: TrajectoryStateOnSurface.h:71
TestSmoothHits::hPullGP_Y_ts_stereo
std::map< std::string, TH1F * > hPullGP_Y_ts_stereo
Definition: TestSmoothHits.h:112
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
TestSmoothHits::hPullGP_Y_rs
std::map< std::string, TH1F * > hPullGP_Y_rs
Definition: TestSmoothHits.h:89
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
TestSmoothHits::~TestSmoothHits
~TestSmoothHits() override
Definition: TestSmoothHits.cc:34
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
TSOS
TrajectoryStateOnSurface TSOS
Definition: TestSmoothHits.cc:18
TestSmoothHits::hPullGP_Y_rs_mono
std::map< std::string, TH1F * > hPullGP_Y_rs_mono
Definition: TestSmoothHits.h:105
GluedGeomDet.h
Surface
Definition: Surface.h:36
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
TestSmoothHits::hPullGP_Y_ts
std::map< std::string, TH1F * > hPullGP_Y_ts
Definition: TestSmoothHits.h:83
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
TestSmoothHits::hPullGP_X_tr
std::map< std::string, TH1F * > hPullGP_X_tr
Definition: TestSmoothHits.h:91
TestSmoothHits::beginRun
void beginRun(edm::Run const &run, const edm::EventSetup &) override
Definition: TestSmoothHits.cc:36
TransientTrack.h
TransientTrackingRecHitBuilder::build
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrackQuality_cff.hitAssociator
hitAssociator
Definition: TrackQuality_cff.py:10
TestSmoothHits::hChi2_vs_Process
TH2F * hChi2_vs_Process
Definition: TestSmoothHits.h:96
TestSmoothHits::hPullGP_Y_ts_mono
std::map< std::string, TH1F * > hPullGP_Y_ts_mono
Definition: TestSmoothHits.h:99
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
TestSmoothHits::mineta
double mineta
Definition: TestSmoothHits.h:64
TrajectorySmoother::trajectories
virtual TrajectoryContainer trajectories(const Trajectory &traj) const
Definition: TrajectorySmoother.h:18
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TestSmoothHits::hPullGP_Z_rs_mono
std::map< std::string, TH1F * > hPullGP_Z_rs_mono
Definition: TestSmoothHits.h:106
TestSmoothHits::hPullGM_X_ts
std::map< std::string, TH1F * > hPullGM_X_ts
Definition: TestSmoothHits.h:85
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
TrackerTopology.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
GlobalErrorBase::cyy
T cyy() const
Definition: GlobalErrorBase.h:101
TestSmoothHits::sname
std::string sname
Definition: TestSmoothHits.h:70
TestSmoothHits::hPullGP_Z_tr
std::map< std::string, TH1F * > hPullGP_Z_tr
Definition: TestSmoothHits.h:93
TestSmoothHits::smooth
edm::ESHandle< TrajectorySmoother > smooth
Definition: TestSmoothHits.h:78
TestSmoothHits::hPullGM_Y_ts
std::map< std::string, TH1F * > hPullGM_Y_ts
Definition: TestSmoothHits.h:86
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerTopologyRcd.h
CTTRHp
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: CkfDebugger.h:39
PSimHit::processType
unsigned short processType() const
Definition: PSimHit.h:120
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CTTRHp
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: TestSmoothHits.cc:19
TrackingRecHit::RecHitContainer
std::vector< ConstRecHitPointer > RecHitContainer
Definition: TrackingRecHit.h:31
TestSmoothHits::hPullGP_Y_tr_mono
std::map< std::string, TH1F * > hPullGP_Y_tr_mono
Definition: TestSmoothHits.h:108
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
TestSmoothHits::hPullGP_X_rs_stereo
std::map< std::string, TH1F * > hPullGP_X_rs_stereo
Definition: TestSmoothHits.h:117
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
TestSmoothHits::hPullGP_X_tr_stereo
std::map< std::string, TH1F * > hPullGP_X_tr_stereo
Definition: TestSmoothHits.h:120
TrackingRecHitLessFromGlobalPosition.h
edm::ESHandle< TrackerTopology >
PSimHit::localPosition
Local3DPoint localPosition() const
Definition: PSimHit.h:52
TestSmoothHits::endJob
void endJob() override
Definition: TestSmoothHits.cc:643
TrajectoryFitterRecord
Definition: TrajectoryFitterRecord.h:12
TrajectoryFitter.h
TestSmoothHits::hPullGP_Z_tr_stereo
std::map< std::string, TH1F * > hPullGP_Z_tr_stereo
Definition: TestSmoothHits.h:122
Point3DBase< float, LocalTag >
GlobalErrorBase::cxx
T cxx() const
Definition: GlobalErrorBase.h:97
StripTopology::strip
virtual float strip(const LocalPoint &) const =0
TestSmoothHits::TestSmoothHits
TestSmoothHits(const edm::ParameterSet &)
Definition: TestSmoothHits.cc:23
TestSmoothHits::hPullGP_X_rs_mono
std::map< std::string, TH1F * > hPullGP_X_rs_mono
Definition: TestSmoothHits.h:104
GluedGeomDet
Definition: GluedGeomDet.h:7
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
TrackCandidate::range
std::pair< const_iterator, const_iterator > range
Definition: TrackCandidate.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
TestSmoothHits::hPullGP_X_ts_mono
std::map< std::string, TH1F * > hPullGP_X_ts_mono
Definition: TestSmoothHits.h:98
TestSmoothHits::hPullGM_Z_ts_stereo
std::map< std::string, TH1F * > hPullGM_Z_ts_stereo
Definition: TestSmoothHits.h:116
TrajectoryStateCombiner
Definition: TrajectoryStateCombiner.h:13
TestSmoothHits::hPullGP_Z_ts
std::map< std::string, TH1F * > hPullGP_Z_ts
Definition: TestSmoothHits.h:84
edm::ParameterSet
Definition: ParameterSet.h:36
TrackCandidate
Definition: TrackCandidate.h:23
TrackCandidate::recHits
range recHits() const
Definition: TrackCandidate.h:58
TestSmoothHits::theBuilder
edm::ESHandle< TransientTrackingRecHitBuilder > theBuilder
Definition: TestSmoothHits.h:75
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
TestSmoothHits::fname
std::string fname
Definition: TestSmoothHits.h:69
TrackCandidate::seed
TrajectorySeed const & seed() const
Definition: TrackCandidate.h:60
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
StripTopology::stripAngle
virtual float stripAngle(float strip) const =0
iEvent
int iEvent
Definition: GenABIO.cc:224
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
TestSmoothHits::hPullGP_X_ts_stereo
std::map< std::string, TH1F * > hPullGP_X_ts_stereo
Definition: TestSmoothHits.h:111
TestSmoothHits::hChi2_vs_clsize
TH2F * hChi2_vs_clsize
Definition: TestSmoothHits.h:96
TestSmoothHits::hPullGP_X_rs
std::map< std::string, TH1F * > hPullGP_X_rs
Definition: TestSmoothHits.h:88
GlobalErrorBase< double, ErrorMatrixTag >
edm::EventSetup
Definition: EventSetup.h:57
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
TSCPBuilderNoMaterial.h
get
#define get
TestSmoothHits::hPullGP_X_tr_mono
std::map< std::string, TH1F * > hPullGP_X_tr_mono
Definition: TestSmoothHits.h:107
CartesianTrajectoryError::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: CartesianTrajectoryError.h:28
TestSmoothHits::hPullGM_X_ts_stereo
std::map< std::string, TH1F * > hPullGM_X_ts_stereo
Definition: TestSmoothHits.h:114
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TestSmoothHits::hPullGP_Z_rs_stereo
std::map< std::string, TH1F * > hPullGP_Z_rs_stereo
Definition: TestSmoothHits.h:119
TestSmoothHits::hPullGM_Z_ts_mono
std::map< std::string, TH1F * > hPullGM_Z_ts_mono
Definition: TestSmoothHits.h:103
TrackerHitAssociator
Definition: TrackerHitAssociator.h:55
TestSmoothHits.h
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
ModuleFactory.h
std
Definition: JetResolutionObject.h:76
TestSmoothHits::theMF
edm::ESHandle< MagneticField > theMF
Definition: TestSmoothHits.h:73
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TestSmoothHits::file
TFile * file
Definition: TestSmoothHits.h:80
TestSmoothHits::hChi2Increment
std::map< std::string, TH1F * > hChi2Increment
Definition: TestSmoothHits.h:94
TestSmoothHits::hPullGP_Z_rs
std::map< std::string, TH1F * > hPullGP_Z_rs
Definition: TestSmoothHits.h:90
TrackInfoProducer_cfi.updatedState
updatedState
Definition: TrackInfoProducer_cfi.py:6
TestSmoothHits::hTotChi2Increment
TH1F * hTotChi2Increment
Definition: TestSmoothHits.h:95
PSimHit::momentumAtEntry
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:55
BoundPlane
TestSmoothHits::srcName
std::string srcName
Definition: TestSmoothHits.h:68
TransverseImpactPointExtrapolator.h
TestSmoothHits::projectHit
std::pair< LocalPoint, LocalVector > projectHit(const PSimHit &, const StripGeomDetUnit *, const BoundPlane &)
Definition: TestSmoothHits.cc:892
TestSmoothHits::theTCCollection
edm::Handle< TrackCandidateCollection > theTCCollection
Definition: TestSmoothHits.h:76
TrajectoryStateTransform.h
TestSmoothHits::hPullGM_X_ts_mono
std::map< std::string, TH1F * > hPullGM_X_ts_mono
Definition: TestSmoothHits.h:101
GlobalErrorBase::czz
T czz() const
Definition: GlobalErrorBase.h:107
StripGeomDetUnit::specificTopology
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Definition: StripGeomDetUnit.cc:17
TestSmoothHits::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TestSmoothHits.cc:191
mps_fire.result
result
Definition: mps_fire.py:303
TestSmoothHits::theG
edm::ESHandle< TrackerGeometry > theG
Definition: TestSmoothHits.h:72
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TestSmoothHits
Definition: TestSmoothHits.h:50
heavyFlavorValidationHarvestingSequence_cff.combiner
combiner
Definition: heavyFlavorValidationHarvestingSequence_cff.py:107
TestSmoothHits::hPullGP_X_ts
std::map< std::string, TH1F * > hPullGP_X_ts
Definition: TestSmoothHits.h:82
PSimHit
Definition: PSimHit.h:15
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TestSmoothHits::trackerHitAssociatorConfig_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TestSmoothHits.h:62
edm::Event
Definition: Event.h:73
StripTopology
Definition: StripTopology.h:11
CartesianTrajectoryError::position
const GlobalError position() const
Position error submatrix.
Definition: CartesianTrajectoryError.h:41
TestSmoothHits::hPullGM_Y_ts_stereo
std::map< std::string, TH1F * > hPullGM_Y_ts_stereo
Definition: TestSmoothHits.h:115
fit
Definition: CombinedChiSquaredLikelihood.h:6
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TestSmoothHits::hPullGM_Z_ts
std::map< std::string, TH1F * > hPullGM_Z_ts
Definition: TestSmoothHits.h:87
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
TestSmoothHits::builderName
std::string builderName
Definition: TestSmoothHits.h:67
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12