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