CMS 3D CMS Logo

TestHits.cc
Go to the documentation of this file.
1 #include "TestHits.h"
2 
11 #include <TDirectory.h>
14 
18 
21 using namespace std;
22 using namespace edm;
23 
24 TestHits::TestHits(const edm::ParameterSet& iConfig) : trackerHitAssociatorConfig_(consumesCollector()) {
25  LogTrace("TestHits") << iConfig << std::endl;
26  propagatorName = iConfig.getParameter<std::string>("Propagator");
27  builderName = iConfig.getParameter<std::string>("TTRHBuilder");
28  srcName = iConfig.getParameter<std::string>("src");
29  fname = iConfig.getParameter<std::string>("Fitter");
30  mineta = iConfig.getParameter<double>("mineta");
31  maxeta = iConfig.getParameter<double>("maxeta");
32 }
33 
35 
36 void TestHits::beginRun(edm::Run const& run, const edm::EventSetup& iSetup) {
42 
43  file = new TFile("testhits.root", "recreate");
44  for (int i = 0; i != 6; i++)
45  for (int j = 0; j != 9; j++) {
46  if (i == 0 && j > 2)
47  break;
48  if (i == 1 && j > 1)
49  break;
50  if (i == 2 && j > 3)
51  break;
52  if (i == 3 && j > 2)
53  break;
54  if (i == 4 && j > 5)
55  break;
56  if (i == 5 && j > 8)
57  break;
58  title.str("");
59  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts";
60  hPullGP_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
61  title.str("");
62  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts";
63  hPullGP_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
64  title.str("");
65  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts";
66  hPullGP_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
67  title.str("");
68  title << "Chi2Increment_" << i + 1 << "-" << j + 1;
69  hChi2Increment[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, 0, 100);
70 
71  title.str("");
72  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts";
73  hPullGM_X_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
74  title.str("");
75  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts";
76  hPullGM_Y_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
77  title.str("");
78  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts";
79  hPullGM_Z_ts[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
80 
81  title.str("");
82  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr";
83  hPullGP_X_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
84  title.str("");
85  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr";
86  hPullGP_Y_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
87  title.str("");
88  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr";
89  hPullGP_Z_tr[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
90 
91  title.str("");
92  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs";
93  hPullGP_X_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
94  title.str("");
95  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs";
96  hPullGP_Y_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
97  title.str("");
98  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs";
99  hPullGP_Z_rs[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
100 
101  if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) {
102  //mono
103  title.str("");
104  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
105  hPullGP_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
106  title.str("");
107  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
108  hPullGP_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
109  title.str("");
110  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
111  hPullGP_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
112 
113  title.str("");
114  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
115  hPullGM_X_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
116  title.str("");
117  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
118  hPullGM_Y_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
119  title.str("");
120  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
121  hPullGM_Z_ts_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
122 
123  title.str("");
124  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono";
125  hPullGP_X_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
126  title.str("");
127  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono";
128  hPullGP_Y_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
129  title.str("");
130  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono";
131  hPullGP_Z_tr_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
132 
133  title.str("");
134  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono";
135  hPullGP_X_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
136  title.str("");
137  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono";
138  hPullGP_Y_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
139  title.str("");
140  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono";
141  hPullGP_Z_rs_mono[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
142 
143  //stereo
144  title.str("");
145  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
146  hPullGP_X_ts_stereo[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 << "_ts_stereo";
149  hPullGP_Y_ts_stereo[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 << "_ts_stereo";
152  hPullGP_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
153 
154  title.str("");
155  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
156  hPullGM_X_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
157  title.str("");
158  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
159  hPullGM_Y_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
160  title.str("");
161  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
162  hPullGM_Z_ts_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
163 
164  title.str("");
165  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo";
166  hPullGP_X_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
167  title.str("");
168  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo";
169  hPullGP_Y_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
170  title.str("");
171  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo";
172  hPullGP_Z_tr_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
173 
174  title.str("");
175  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo";
176  hPullGP_X_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
177  title.str("");
178  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo";
179  hPullGP_Y_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
180  title.str("");
181  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo";
182  hPullGP_Z_rs_stereo[title.str()] = new TH1F(title.str().c_str(), title.str().c_str(), 1000, -50, 50);
183  }
184  }
185  hTotChi2Increment = new TH1F("TotChi2Increment", "TotChi2Increment", 1000, 0, 100);
186  hProcess_vs_Chi2 = new TH2F("Process_vs_Chi2", "Process_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5);
187  hClsize_vs_Chi2 = new TH2F("Clsize_vs_Chi2", "Clsize_vs_Chi2", 1000, 0, 100, 17, -0.5, 16.5);
188 }
189 
190 void TestHits::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
191  //Retrieve tracker topology from geometry
193  iSetup.get<TrackerTopologyRcd>().get(tTopo);
194 
195  LogTrace("TestHits") << "\nnew event";
196 
197  iEvent.getByLabel(srcName, theTCCollection);
199 
201 
202  for (TrackCandidateCollection::const_iterator i = theTCCollection->begin(); i != theTCCollection->end(); i++) {
203  LogTrace("TestHits") << "\n*****************new candidate*****************" << std::endl;
204 
205  const TrackCandidate* theTC = &(*i);
207  const TrackCandidate::range& recHitVec = theTC->recHits();
208 
209  //convert PTrajectoryStateOnDet to TrajectoryStateOnSurface
210 
211  DetId detId(state.detId());
212  TrajectoryStateOnSurface theTSOS =
214 
215  if (theTSOS.globalMomentum().eta() > maxeta || theTSOS.globalMomentum().eta() < mineta)
216  continue;
217 
218  //convert the TrackingRecHit vector to a TransientTrackingRecHit vector
220 
221  for (edm::OwnVector<TrackingRecHit>::const_iterator i = recHitVec.first; i != recHitVec.second; i++) {
222  hits.push_back(theBuilder->build(&(*i)));
223  }
224 
225  //call the fitter
226  std::vector<Trajectory> result = fit->fit(theTC->seed(), hits, theTSOS);
227  if (result.empty())
228  continue;
229  std::vector<TrajectoryMeasurement> vtm = result[0].measurements();
230  double tchi2 = 0;
231 
232  TSOS lastState = theTSOS;
233  for (std::vector<TrajectoryMeasurement>::iterator tm = vtm.begin(); tm != vtm.end(); tm++) {
235  if ((rhit)->isValid() == 0 && rhit->det() != nullptr)
236  continue;
237  LogTrace("TestHits") << "*****************new hit*****************";
238 
239  int subdetId = rhit->det()->geographicalId().subdetId();
240  DetId id = rhit->det()->geographicalId();
241  int layerId = tTopo->layer(id);
242  LogTrace("TestHits") << "subdetId=" << subdetId << " layerId=" << layerId;
243 
244  double delta = 99999;
245  LocalPoint rhitLPv = rhit->localPosition();
246 
247  std::vector<PSimHit> assSimHits = hitAssociator.associateHit(*(rhit->hit()));
248  if (assSimHits.empty())
249  continue;
250  PSimHit shit;
251  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
252  if ((m->localPosition() - rhitLPv).mag() < delta) {
253  shit = *m;
254  delta = (m->localPosition() - rhitLPv).mag();
255  }
256  }
257 
258  TSOS currentState = tm->forwardPredictedState();
259  if (tm->backwardPredictedState().isValid())
260  currentState = combiner(tm->backwardPredictedState(), tm->forwardPredictedState());
261  TSOS updatedState = tm->updatedState();
262  tchi2 += tm->estimate();
263 
264  //plot chi2 increment
265  double chi2increment = tm->estimate();
266  LogTrace("TestHits") << "tm->estimate()=" << tm->estimate();
267  title.str("");
268  title << "Chi2Increment_" << subdetId << "-" << layerId;
269  hChi2Increment[title.str()]->Fill(chi2increment);
270  hTotChi2Increment->Fill(chi2increment);
271  hProcess_vs_Chi2->Fill(chi2increment, shit.processType());
272  if (dynamic_cast<const SiPixelRecHit*>(rhit->hit()))
273  hClsize_vs_Chi2->Fill(chi2increment, ((const SiPixelRecHit*)(rhit->hit()))->cluster()->size());
274  if (dynamic_cast<const SiStripRecHit2D*>(rhit->hit()))
275  hClsize_vs_Chi2->Fill(chi2increment, ((const SiStripRecHit2D*)(rhit->hit()))->cluster()->amplitudes().size());
276 
277  //test hits
278  const Surface* surf = &((rhit)->det()->surface());
279  LocalVector shitLMom;
280  LocalPoint shitLPos;
281  if (dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())) {
282  double rechitmatchedx = rhit->localPosition().x();
283  double rechitmatchedy = rhit->localPosition().y();
284  double mindist = 999999;
285  double distx, disty;
286  std::pair<LocalPoint, LocalVector> closestPair;
287  const StripGeomDetUnit* stripDet = (StripGeomDetUnit*)((const GluedGeomDet*)(rhit)->det())->stereoDet();
288  const BoundPlane& plane = (rhit)->det()->surface();
289  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
290  //project simhit;
291  std::pair<LocalPoint, LocalVector> hitPair = projectHit((*m), stripDet, plane);
292  distx = fabs(rechitmatchedx - hitPair.first.x());
293  disty = fabs(rechitmatchedy - hitPair.first.y());
294  double dist = distx * distx + disty * disty;
295  if (sqrt(dist) < mindist) {
296  mindist = dist;
297  closestPair = hitPair;
298  }
299  }
300  shitLPos = closestPair.first;
301  shitLMom = closestPair.second;
302  } else {
303  shitLPos = shit.localPosition();
304  shitLMom = shit.momentumAtEntry();
305  }
306  GlobalVector shitGMom = surf->toGlobal(shitLMom);
307  GlobalPoint shitGPos = surf->toGlobal(shitLPos);
308 
309  GlobalVector tsosGMom = currentState.globalMomentum();
310  GlobalError tsosGMEr(currentState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
311  GlobalPoint tsosGPos = currentState.globalPosition();
312  GlobalError tsosGPEr = currentState.cartesianError().position();
313 
314  GlobalPoint rhitGPos = (rhit)->globalPosition();
315  GlobalError rhitGPEr = (rhit)->globalPositionError();
316 
317  double pullGPX_rs = (rhitGPos.x() - shitGPos.x()) / sqrt(rhitGPEr.cxx());
318  double pullGPY_rs = (rhitGPos.y() - shitGPos.y()) / sqrt(rhitGPEr.cyy());
319  double pullGPZ_rs = (rhitGPos.z() - shitGPos.z()) / sqrt(rhitGPEr.czz());
320  //double pullGPX_rs = (rhitGPos.x()-shitGPos.x());
321  //double pullGPY_rs = (rhitGPos.y()-shitGPos.y());
322  //double pullGPZ_rs = (rhitGPos.z()-shitGPos.z());
323 
324  LogTrace("TestHits") << "rs" << std::endl;
325  LogVerbatim("TestHits") << "assSimHits.size()=" << assSimHits.size();
326  LogVerbatim("TestHits") << "tsos globalPos =" << tsosGPos;
327  LogVerbatim("TestHits") << "sim hit globalPos=" << shitGPos;
328  LogVerbatim("TestHits") << "rec hit globalPos=" << rhitGPos;
329  LogVerbatim("TestHits") << "geographicalId =" << rhit->det()->geographicalId().rawId();
330  LogVerbatim("TestHits") << "surface position =" << surf->position();
331 
332  title.str("");
333  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs";
334  hPullGP_X_rs[title.str()]->Fill(pullGPX_rs);
335  title.str("");
336  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs";
337  hPullGP_Y_rs[title.str()]->Fill(pullGPY_rs);
338  title.str("");
339  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs";
340  hPullGP_Z_rs[title.str()]->Fill(pullGPZ_rs);
341 
342  double pullGPX_tr = (tsosGPos.x() - rhitGPos.x()) / sqrt(tsosGPEr.cxx() + rhitGPEr.cxx());
343  double pullGPY_tr = (tsosGPos.y() - rhitGPos.y()) / sqrt(tsosGPEr.cyy() + rhitGPEr.cyy());
344  double pullGPZ_tr = (tsosGPos.z() - rhitGPos.z()) / sqrt(tsosGPEr.czz() + rhitGPEr.czz());
345  //double pullGPX_tr = (tsosGPos.x()-rhitGPos.x());
346  //double pullGPY_tr = (tsosGPos.y()-rhitGPos.y());
347  //double pullGPZ_tr = (tsosGPos.z()-rhitGPos.z());
348 
349  LogTrace("TestHits") << "tr" << std::endl;
350 
351  title.str("");
352  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr";
353  hPullGP_X_tr[title.str()]->Fill(pullGPX_tr);
354  title.str("");
355  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr";
356  hPullGP_Y_tr[title.str()]->Fill(pullGPY_tr);
357  title.str("");
358  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr";
359  hPullGP_Z_tr[title.str()]->Fill(pullGPZ_tr);
360 
361  double pullGPX_ts = (tsosGPos.x() - shitGPos.x()) / sqrt(tsosGPEr.cxx());
362  double pullGPY_ts = (tsosGPos.y() - shitGPos.y()) / sqrt(tsosGPEr.cyy());
363  double pullGPZ_ts = (tsosGPos.z() - shitGPos.z()) / sqrt(tsosGPEr.czz());
364  //double pullGPX_ts = (tsosGPos.x()-shitGPos.x());
365  //double pullGPY_ts = (tsosGPos.y()-shitGPos.y());
366  //double pullGPZ_ts = (tsosGPos.z()-shitGPos.z());
367 
368  LogTrace("TestHits") << "ts1" << std::endl;
369 
370  title.str("");
371  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts";
372  hPullGP_X_ts[title.str()]->Fill(pullGPX_ts);
373  title.str("");
374  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts";
375  hPullGP_Y_ts[title.str()]->Fill(pullGPY_ts);
376  title.str("");
377  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts";
378  hPullGP_Z_ts[title.str()]->Fill(pullGPZ_ts);
379 
380  double pullGMX_ts = (tsosGMom.x() - shitGMom.x()) / sqrt(tsosGMEr.cxx());
381  double pullGMY_ts = (tsosGMom.y() - shitGMom.y()) / sqrt(tsosGMEr.cyy());
382  double pullGMZ_ts = (tsosGMom.z() - shitGMom.z()) / sqrt(tsosGMEr.czz());
383  //double pullGMX_ts = (tsosGMom.x()-shitGMom.x());
384  //double pullGMY_ts = (tsosGMom.y()-shitGMom.y());
385  //double pullGMZ_ts = (tsosGMom.z()-shitGMom.z());
386 
387  LogTrace("TestHits") << "ts2" << std::endl;
388 
389  title.str("");
390  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts";
391  hPullGM_X_ts[title.str()]->Fill(pullGMX_ts);
392  title.str("");
393  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts";
394  hPullGM_Y_ts[title.str()]->Fill(pullGMY_ts);
395  title.str("");
396  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts";
397  hPullGM_Z_ts[title.str()]->Fill(pullGMZ_ts);
398 
399  if (dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())) {
400  //mono
401  LogTrace("TestHits") << "MONO HIT" << std::endl;
402  auto m = dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())->monoHit();
403  CTTRHp tMonoHit = theBuilder->build(&m);
404  if (tMonoHit == nullptr)
405  continue;
406  vector<PSimHit> assMonoSimHits = hitAssociator.associateHit(*tMonoHit->hit());
407  if (assMonoSimHits.empty())
408  continue;
409  const PSimHit sMonoHit = *(assSimHits.begin());
410  const Surface* monoSurf = &(tMonoHit->det()->surface());
411  if (monoSurf == nullptr)
412  continue;
413  TSOS monoState = thePropagator->propagate(lastState, *monoSurf);
414  if (monoState.isValid() == 0)
415  continue;
416 
417  LocalVector monoShitLMom = sMonoHit.momentumAtEntry();
418  GlobalVector monoShitGMom = monoSurf->toGlobal(monoShitLMom);
419  LocalPoint monoShitLPos = sMonoHit.localPosition();
420  GlobalPoint monoShitGPos = monoSurf->toGlobal(monoShitLPos);
421 
422  GlobalVector monoTsosGMom = monoState.globalMomentum();
423  GlobalError monoTsosGMEr(monoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
424  GlobalPoint monoTsosGPos = monoState.globalPosition();
425  GlobalError monoTsosGPEr = monoState.cartesianError().position();
426 
427  GlobalPoint monoRhitGPos = tMonoHit->globalPosition();
428  GlobalError monoRhitGPEr = tMonoHit->globalPositionError();
429 
430  double pullGPX_rs_mono = (monoRhitGPos.x() - monoShitGPos.x()) / sqrt(monoRhitGPEr.cxx());
431  double pullGPY_rs_mono = (monoRhitGPos.y() - monoShitGPos.y()) / sqrt(monoRhitGPEr.cyy());
432  double pullGPZ_rs_mono = (monoRhitGPos.z() - monoShitGPos.z()) / sqrt(monoRhitGPEr.czz());
433  //double pullGPX_rs_mono = (monoRhitGPos.x()-monoShitGPos.x());
434  //double pullGPY_rs_mono = (monoRhitGPos.y()-monoShitGPos.y());
435  //double pullGPZ_rs_mono = (monoRhitGPos.z()-monoShitGPos.z());
436 
437  title.str("");
438  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_mono";
439  hPullGP_X_rs_mono[title.str()]->Fill(pullGPX_rs_mono);
440  title.str("");
441  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_mono";
442  hPullGP_Y_rs_mono[title.str()]->Fill(pullGPY_rs_mono);
443  title.str("");
444  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_mono";
445  hPullGP_Z_rs_mono[title.str()]->Fill(pullGPZ_rs_mono);
446 
447  double pullGPX_tr_mono = (monoTsosGPos.x() - monoRhitGPos.x()) / sqrt(monoTsosGPEr.cxx() + monoRhitGPEr.cxx());
448  double pullGPY_tr_mono = (monoTsosGPos.y() - monoRhitGPos.y()) / sqrt(monoTsosGPEr.cyy() + monoRhitGPEr.cyy());
449  double pullGPZ_tr_mono = (monoTsosGPos.z() - monoRhitGPos.z()) / sqrt(monoTsosGPEr.czz() + monoRhitGPEr.czz());
450  //double pullGPX_tr_mono = (monoTsosGPos.x()-monoRhitGPos.x());
451  //double pullGPY_tr_mono = (monoTsosGPos.y()-monoRhitGPos.y());
452  //double pullGPZ_tr_mono = (monoTsosGPos.z()-monoRhitGPos.z());
453 
454  title.str("");
455  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_mono";
456  hPullGP_X_tr_mono[title.str()]->Fill(pullGPX_tr_mono);
457  title.str("");
458  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_mono";
459  hPullGP_Y_tr_mono[title.str()]->Fill(pullGPY_tr_mono);
460  title.str("");
461  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_mono";
462  hPullGP_Z_tr_mono[title.str()]->Fill(pullGPZ_tr_mono);
463 
464  double pullGPX_ts_mono = (monoTsosGPos.x() - monoShitGPos.x()) / sqrt(monoTsosGPEr.cxx());
465  double pullGPY_ts_mono = (monoTsosGPos.y() - monoShitGPos.y()) / sqrt(monoTsosGPEr.cyy());
466  double pullGPZ_ts_mono = (monoTsosGPos.z() - monoShitGPos.z()) / sqrt(monoTsosGPEr.czz());
467  //double pullGPX_ts_mono = (monoTsosGPos.x()-monoShitGPos.x());
468  //double pullGPY_ts_mono = (monoTsosGPos.y()-monoShitGPos.y());
469  //double pullGPZ_ts_mono = (monoTsosGPos.z()-monoShitGPos.z());
470 
471  title.str("");
472  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_mono";
473  hPullGP_X_ts_mono[title.str()]->Fill(pullGPX_ts_mono);
474  title.str("");
475  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_mono";
476  hPullGP_Y_ts_mono[title.str()]->Fill(pullGPY_ts_mono);
477  title.str("");
478  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_mono";
479  hPullGP_Z_ts_mono[title.str()]->Fill(pullGPZ_ts_mono);
480 
481  double pullGMX_ts_mono = (monoTsosGMom.x() - monoShitGMom.x()) / sqrt(monoTsosGMEr.cxx());
482  double pullGMY_ts_mono = (monoTsosGMom.y() - monoShitGMom.y()) / sqrt(monoTsosGMEr.cyy());
483  double pullGMZ_ts_mono = (monoTsosGMom.z() - monoShitGMom.z()) / sqrt(monoTsosGMEr.czz());
484  //double pullGMX_ts_mono = (monoTsosGMom.x()-monoShitGMom.x());
485  //double pullGMY_ts_mono = (monoTsosGMom.y()-monoShitGMom.y());
486  //double pullGMZ_ts_mono = (monoTsosGMom.z()-monoShitGMom.z());
487 
488  title.str("");
489  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_mono";
490  hPullGM_X_ts_mono[title.str()]->Fill(pullGMX_ts_mono);
491  title.str("");
492  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_mono";
493  hPullGM_Y_ts_mono[title.str()]->Fill(pullGMY_ts_mono);
494  title.str("");
495  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_mono";
496  hPullGM_Z_ts_mono[title.str()]->Fill(pullGMZ_ts_mono);
497 
498  //stereo
499  LogTrace("TestHits") << "STEREO HIT" << std::endl;
500  auto s = dynamic_cast<const SiStripMatchedRecHit2D*>((rhit)->hit())->stereoHit();
501  CTTRHp tStereoHit = theBuilder->build(&s);
502  if (tStereoHit == nullptr)
503  continue;
504  vector<PSimHit> assStereoSimHits = hitAssociator.associateHit(*tStereoHit->hit());
505  if (assStereoSimHits.empty())
506  continue;
507  const PSimHit sStereoHit = *(assSimHits.begin());
508  const Surface* stereoSurf = &(tStereoHit->det()->surface());
509  if (stereoSurf == nullptr)
510  continue;
511  TSOS stereoState = thePropagator->propagate(lastState, *stereoSurf);
512  if (stereoState.isValid() == 0)
513  continue;
514 
515  LocalVector stereoShitLMom = sStereoHit.momentumAtEntry();
516  GlobalVector stereoShitGMom = stereoSurf->toGlobal(stereoShitLMom);
517  LocalPoint stereoShitLPos = sStereoHit.localPosition();
518  GlobalPoint stereoShitGPos = stereoSurf->toGlobal(stereoShitLPos);
519 
520  GlobalVector stereoTsosGMom = stereoState.globalMomentum();
521  GlobalError stereoTsosGMEr(stereoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3, 3));
522  GlobalPoint stereoTsosGPos = stereoState.globalPosition();
523  GlobalError stereoTsosGPEr = stereoState.cartesianError().position();
524 
525  GlobalPoint stereoRhitGPos = tStereoHit->globalPosition();
526  GlobalError stereoRhitGPEr = tStereoHit->globalPositionError();
527 
528  double pullGPX_rs_stereo = (stereoRhitGPos.x() - stereoShitGPos.x()) / sqrt(stereoRhitGPEr.cxx());
529  double pullGPY_rs_stereo = (stereoRhitGPos.y() - stereoShitGPos.y()) / sqrt(stereoRhitGPEr.cyy());
530  double pullGPZ_rs_stereo = (stereoRhitGPos.z() - stereoShitGPos.z()) / sqrt(stereoRhitGPEr.czz());
531  //double pullGPX_rs_stereo = (stereoRhitGPos.x()-stereoShitGPos.x());
532  //double pullGPY_rs_stereo = (stereoRhitGPos.y()-stereoShitGPos.y());
533  //double pullGPZ_rs_stereo = (stereoRhitGPos.z()-stereoShitGPos.z());
534 
535  title.str("");
536  title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_stereo";
537  hPullGP_X_rs_stereo[title.str()]->Fill(pullGPX_rs_stereo);
538  title.str("");
539  title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_stereo";
540  hPullGP_Y_rs_stereo[title.str()]->Fill(pullGPY_rs_stereo);
541  title.str("");
542  title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_stereo";
543  hPullGP_Z_rs_stereo[title.str()]->Fill(pullGPZ_rs_stereo);
544 
545  double pullGPX_tr_stereo =
546  (stereoTsosGPos.x() - stereoRhitGPos.x()) / sqrt(stereoTsosGPEr.cxx() + stereoRhitGPEr.cxx());
547  double pullGPY_tr_stereo =
548  (stereoTsosGPos.y() - stereoRhitGPos.y()) / sqrt(stereoTsosGPEr.cyy() + stereoRhitGPEr.cyy());
549  double pullGPZ_tr_stereo =
550  (stereoTsosGPos.z() - stereoRhitGPos.z()) / sqrt(stereoTsosGPEr.czz() + stereoRhitGPEr.czz());
551  //double pullGPX_tr_stereo = (stereoTsosGPos.x()-stereoRhitGPos.x());
552  //double pullGPY_tr_stereo = (stereoTsosGPos.y()-stereoRhitGPos.y());
553  //double pullGPZ_tr_stereo = (stereoTsosGPos.z()-stereoRhitGPos.z());
554 
555  title.str("");
556  title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_stereo";
557  hPullGP_X_tr_stereo[title.str()]->Fill(pullGPX_tr_stereo);
558  title.str("");
559  title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_stereo";
560  hPullGP_Y_tr_stereo[title.str()]->Fill(pullGPY_tr_stereo);
561  title.str("");
562  title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_stereo";
563  hPullGP_Z_tr_stereo[title.str()]->Fill(pullGPZ_tr_stereo);
564 
565  double pullGPX_ts_stereo = (stereoTsosGPos.x() - stereoShitGPos.x()) / sqrt(stereoTsosGPEr.cxx());
566  double pullGPY_ts_stereo = (stereoTsosGPos.y() - stereoShitGPos.y()) / sqrt(stereoTsosGPEr.cyy());
567  double pullGPZ_ts_stereo = (stereoTsosGPos.z() - stereoShitGPos.z()) / sqrt(stereoTsosGPEr.czz());
568  //double pullGPX_ts_stereo = (stereoTsosGPos.x()-stereoShitGPos.x());
569  //double pullGPY_ts_stereo = (stereoTsosGPos.y()-stereoShitGPos.y());
570  //double pullGPZ_ts_stereo = (stereoTsosGPos.z()-stereoShitGPos.z());
571 
572  title.str("");
573  title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_stereo";
574  hPullGP_X_ts_stereo[title.str()]->Fill(pullGPX_ts_stereo);
575  title.str("");
576  title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_stereo";
577  hPullGP_Y_ts_stereo[title.str()]->Fill(pullGPY_ts_stereo);
578  title.str("");
579  title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_stereo";
580  hPullGP_Z_ts_stereo[title.str()]->Fill(pullGPZ_ts_stereo);
581 
582  double pullGMX_ts_stereo = (stereoTsosGMom.x() - stereoShitGMom.x()) / sqrt(stereoTsosGMEr.cxx());
583  double pullGMY_ts_stereo = (stereoTsosGMom.y() - stereoShitGMom.y()) / sqrt(stereoTsosGMEr.cyy());
584  double pullGMZ_ts_stereo = (stereoTsosGMom.z() - stereoShitGMom.z()) / sqrt(stereoTsosGMEr.czz());
585  //double pullGMX_ts_stereo = (stereoTsosGMom.x()-stereoShitGMom.x());
586  //double pullGMY_ts_stereo = (stereoTsosGMom.y()-stereoShitGMom.y());
587  //double pullGMZ_ts_stereo = (stereoTsosGMom.z()-stereoShitGMom.z());
588 
589  title.str("");
590  title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_stereo";
591  hPullGM_X_ts_stereo[title.str()]->Fill(pullGMX_ts_stereo);
592  title.str("");
593  title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_stereo";
594  hPullGM_Y_ts_stereo[title.str()]->Fill(pullGMY_ts_stereo);
595  title.str("");
596  title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_stereo";
597  hPullGM_Z_ts_stereo[title.str()]->Fill(pullGMZ_ts_stereo);
598  }
599  lastState = updatedState;
600  }
601  LogTrace("TestHits") << "traj chi2=" << tchi2;
602  LogTrace("TestHits") << "track chi2=" << result[0].chiSquared();
603  }
604  LogTrace("TestHits") << "end of event" << std::endl;
605 }
606 // TSOS lastState = theTSOS;
607 // for (std::vector<TrajectoryMeasurement>::iterator tm=vtm.begin(); tm!=vtm.end();tm++){
608 
609 // TransientTrackingRecHit::ConstRecHitPointer rhit = tm->recHit();
610 // if ((rhit)->isValid()==0&&rhit->det()!=0) continue;
611 
612 // // //test hits
613 // // TSOS lastState, currentState, updatedState;
614 // // updatedState=theTSOS;
615 // // for (TransientTrackingRecHit::RecHitContainer::iterator rhit=hits.begin()+1;rhit!=hits.end();++rhit){
616 
617 // lastState=updatedState;
618 
619 // LogTrace("TestHits") << "new hit" << std::endl;
620 
621 // if ((*rhit)->isValid()==0) continue;
622 
623 // int subdetId = (*rhit)->det()->geographicalId().subdetId();
624 // int layerId = 0;
625 // DetId id = (*rhit)->det()->geographicalId();
626 // if (id.subdetId()==3) layerId = ((tTopo->tibLayer(id);
627 // if (id.subdetId()==5) layerId = ((tTopo->tobLayer(id);
628 // if (id.subdetId()==1) layerId = ((tTopo->pxbLayer(id);
629 // if (id.subdetId()==4) layerId = ((tTopo->tidWheel(id);
630 // if (id.subdetId()==6) layerId = ((tTopo->tecWheel(id);
631 // if (id.subdetId()==2) layerId = ((tTopo->pxfDisk(id);
632 // const Surface * surf = &( (*rhit)->det()->surface() );
633 // currentState=thePropagator->propagate(lastState,*surf);
634 // if (currentState.isValid()==0) continue;
635 // updatedState=theUpdator->update(currentState,**rhit);
636 
637 // double delta = 99999;
638 // LocalPoint rhitLP = rhit->localPosition();
639 
640 // std::vector<PSimHit> assSimHits = hitAssociator.associateHit(*(*rhit)->hit());
641 // if (assSimHits.size()==0) continue;
642 // PSimHit shit;
643 // for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
644 // if ((*m-rhitLP).mag()<delta) {
645 // shit=*m;
646 // delta = (*m-rhitLP).mag();
647 // }
648 // }
649 
650 // LocalVector shitLMom = shit.momentumAtEntry();
651 // GlobalVector shitGMom = surf->toGlobal(shitLMom);
652 // LocalPoint shitLPos = shit.localPosition();
653 // GlobalPoint shitGPos = surf->toGlobal(shitLPos);
654 
655 // GlobalVector tsosGMom = currentState.globalMomentum();
656 // GlobalError tsosGMEr(currentState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3,3));
657 // GlobalPoint tsosGPos = currentState.globalPosition();
658 // GlobalError tsosGPEr = currentState.cartesianError().position();
659 
660 // GlobalPoint rhitGPos = (*rhit)->globalPosition();
661 // GlobalError rhitGPEr = (*rhit)->globalPositionError();
662 
663 // double pullGPX_rs = (rhitGPos.x()-shitGPos.x())/sqrt(rhitGPEr.cxx());
664 // double pullGPY_rs = (rhitGPos.y()-shitGPos.y())/sqrt(rhitGPEr.cyy());
665 // double pullGPZ_rs = (rhitGPos.z()-shitGPos.z())/sqrt(rhitGPEr.czz());
666 // // double pullGPX_rs = (rhitGPos.x()-shitGPos.x())/*/sqrt(rhitGPEr.cxx())*/;
667 // // double pullGPY_rs = (rhitGPos.y()-shitGPos.y())/*/sqrt(rhitGPEr.cyy())*/;
668 // // double pullGPZ_rs = (rhitGPos.z()-shitGPos.z())/*/sqrt(rhitGPEr.czz())*/;
669 
670 // //plot chi2 increment
671 // MeasurementExtractor me(currentState);
672 // double chi2increment = computeChi2Increment(me,*rhit);
673 // LogTrace("TestHits") << "chi2increment=" << chi2increment << std::endl;
674 // title.str("");
675 // title << "Chi2Increment_" << subdetId << "-" << layerId;
676 // hChi2Increment[title.str()]->Fill( chi2increment );
677 // hTotChi2Increment->Fill( chi2increment );
678 // hChi2_vs_Process->Fill( chi2increment, shit.processType() );
679 // if (dynamic_cast<const SiPixelRecHit*>((*rhit)->hit()))
680 // hChi2_vs_clsize->Fill( chi2increment, ((const SiPixelRecHit*)(*rhit)->hit())->cluster()->size() );
681 // if (dynamic_cast<const SiStripRecHit2D*>((*rhit)->hit()))
682 // hChi2_vs_clsize->Fill( chi2increment, ((const SiStripRecHit2D*)(*rhit)->hit())->cluster()->amplitudes().size() );
683 
684 // LogTrace("TestHits") << "rs" << std::endl;
685 
686 // title.str("");
687 // title << "PullGP_X_" << subdetId << "-" << layerId << "_rs";
688 // hPullGP_X_rs[title.str()]->Fill( pullGPX_rs );
689 // title.str("");
690 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs";
691 // hPullGP_Y_rs[title.str()]->Fill( pullGPY_rs );
692 // title.str("");
693 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs";
694 // hPullGP_Z_rs[title.str()]->Fill( pullGPZ_rs );
695 
696 // double pullGPX_tr = (tsosGPos.x()-rhitGPos.x())/sqrt(tsosGPEr.cxx()+rhitGPEr.cxx());
697 // double pullGPY_tr = (tsosGPos.y()-rhitGPos.y())/sqrt(tsosGPEr.cyy()+rhitGPEr.cyy());
698 // double pullGPZ_tr = (tsosGPos.z()-rhitGPos.z())/sqrt(tsosGPEr.czz()+rhitGPEr.czz());
699 // // double pullGPX_tr = (tsosGPos.x()-rhitGPos.x())/*/sqrt(tsosGPEr.cxx()+rhitGPEr.cxx())*/;
700 // // double pullGPY_tr = (tsosGPos.y()-rhitGPos.y())/*/sqrt(tsosGPEr.cyy()+rhitGPEr.cyy())*/;
701 // // double pullGPZ_tr = (tsosGPos.z()-rhitGPos.z())/*/sqrt(tsosGPEr.czz()+rhitGPEr.czz())*/;
702 
703 // LogTrace("TestHits") << "tr" << std::endl;
704 
705 // title.str("");
706 // title << "PullGP_X_" << subdetId << "-" << layerId << "_tr";
707 // hPullGP_X_tr[title.str()]->Fill( pullGPX_tr );
708 // title.str("");
709 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr";
710 // hPullGP_Y_tr[title.str()]->Fill( pullGPY_tr );
711 // title.str("");
712 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr";
713 // hPullGP_Z_tr[title.str()]->Fill( pullGPZ_tr );
714 
715 // double pullGPX_ts = (tsosGPos.x()-shitGPos.x())/sqrt(tsosGPEr.cxx());
716 // double pullGPY_ts = (tsosGPos.y()-shitGPos.y())/sqrt(tsosGPEr.cyy());
717 // double pullGPZ_ts = (tsosGPos.z()-shitGPos.z())/sqrt(tsosGPEr.czz());
718 // // double pullGPX_ts = (tsosGPos.x()-shitGPos.x())/*/sqrt(tsosGPEr.cxx())*/;
719 // // double pullGPY_ts = (tsosGPos.y()-shitGPos.y())/*/sqrt(tsosGPEr.cyy())*/;
720 // // double pullGPZ_ts = (tsosGPos.z()-shitGPos.z())/*/sqrt(tsosGPEr.czz())*/;
721 
722 // LogTrace("TestHits") << "ts1" << std::endl;
723 
724 // title.str("");
725 // title << "PullGP_X_" << subdetId << "-" << layerId << "_ts";
726 // hPullGP_X_ts[title.str()]->Fill( pullGPX_ts );
727 // title.str("");
728 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts";
729 // hPullGP_Y_ts[title.str()]->Fill( pullGPY_ts );
730 // title.str("");
731 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts";
732 // hPullGP_Z_ts[title.str()]->Fill( pullGPZ_ts );
733 
734 // double pullGMX_ts = (tsosGMom.x()-shitGMom.x())/sqrt(tsosGMEr.cxx());
735 // double pullGMY_ts = (tsosGMom.y()-shitGMom.y())/sqrt(tsosGMEr.cyy());
736 // double pullGMZ_ts = (tsosGMom.z()-shitGMom.z())/sqrt(tsosGMEr.czz());
737 // // double pullGMX_ts = (tsosGMom.x()-shitGMom.x())/*/sqrt(tsosGMEr.cxx())*/;
738 // // double pullGMY_ts = (tsosGMom.y()-shitGMom.y())/*/sqrt(tsosGMEr.cyy())*/;
739 // // double pullGMZ_ts = (tsosGMom.z()-shitGMom.z())/*/sqrt(tsosGMEr.czz())*/;
740 
741 // LogTrace("TestHits") << "ts2" << std::endl;
742 
743 // title.str("");
744 // title << "PullGM_X_" << subdetId << "-" << layerId << "_ts";
745 // hPullGM_X_ts[title.str()]->Fill( pullGMX_ts );
746 // title.str("");
747 // title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts";
748 // hPullGM_Y_ts[title.str()]->Fill( pullGMY_ts );
749 // title.str("");
750 // title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts";
751 // hPullGM_Z_ts[title.str()]->Fill( pullGMZ_ts );
752 
753 // if (dynamic_cast<const SiStripMatchedRecHit2D*>((*rhit)->hit())) {
754 // //mono
755 // LogTrace("TestHits") << "MONO HIT" << std::endl;
756 // CTTRHp tMonoHit =
757 // theBuilder->build(dynamic_cast<const SiStripMatchedRecHit2D*>((*rhit)->hit())->monoHit());
758 // if (tMonoHit==0) continue;
759 // vector<PSimHit> assMonoSimHits = hitAssociator.associateHit(*tMonoHit->hit());
760 // if (assMonoSimHits.size()==0) continue;
761 // const PSimHit sMonoHit = *(assSimHits.begin());
762 // const Surface * monoSurf = &( tMonoHit->det()->surface() );
763 // if (monoSurf==0) continue;
764 // TSOS monoState = thePropagator->propagate(lastState,*monoSurf);
765 // if (monoState.isValid()==0) continue;
766 
767 // LocalVector monoShitLMom = sMonoHit.momentumAtEntry();
768 // GlobalVector monoShitGMom = monoSurf->toGlobal(monoShitLMom);
769 // LocalPoint monoShitLPos = sMonoHit.localPosition();
770 // GlobalPoint monoShitGPos = monoSurf->toGlobal(monoShitLPos);
771 
772 // GlobalVector monoTsosGMom = monoState.globalMomentum();
773 // GlobalError monoTsosGMEr(monoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3,3));
774 // GlobalPoint monoTsosGPos = monoState.globalPosition();
775 // GlobalError monoTsosGPEr = monoState.cartesianError().position();
776 
777 // GlobalPoint monoRhitGPos = tMonoHit->globalPosition();
778 // GlobalError monoRhitGPEr = tMonoHit->globalPositionError();
779 
780 // double pullGPX_rs_mono = (monoRhitGPos.x()-monoShitGPos.x())/sqrt(monoRhitGPEr.cxx());
781 // double pullGPY_rs_mono = (monoRhitGPos.y()-monoShitGPos.y())/sqrt(monoRhitGPEr.cyy());
782 // double pullGPZ_rs_mono = (monoRhitGPos.z()-monoShitGPos.z())/sqrt(monoRhitGPEr.czz());
783 // // double pullGPX_rs_mono = (monoRhitGPos.x()-monoShitGPos.x())/*/sqrt(monoRhitGPEr.cxx())*/;
784 // // double pullGPY_rs_mono = (monoRhitGPos.y()-monoShitGPos.y())/*/sqrt(monoRhitGPEr.cyy())*/;
785 // // double pullGPZ_rs_mono = (monoRhitGPos.z()-monoShitGPos.z())/*/sqrt(monoRhitGPEr.czz())*/;
786 
787 // title.str("");
788 // title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_mono";
789 // hPullGP_X_rs_mono[title.str()]->Fill( pullGPX_rs_mono );
790 // title.str("");
791 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_mono";
792 // hPullGP_Y_rs_mono[title.str()]->Fill( pullGPY_rs_mono );
793 // title.str("");
794 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_mono";
795 // hPullGP_Z_rs_mono[title.str()]->Fill( pullGPZ_rs_mono );
796 
797 // double pullGPX_tr_mono = (monoTsosGPos.x()-monoRhitGPos.x())/sqrt(monoTsosGPEr.cxx()+monoRhitGPEr.cxx());
798 // double pullGPY_tr_mono = (monoTsosGPos.y()-monoRhitGPos.y())/sqrt(monoTsosGPEr.cyy()+monoRhitGPEr.cyy());
799 // double pullGPZ_tr_mono = (monoTsosGPos.z()-monoRhitGPos.z())/sqrt(monoTsosGPEr.czz()+monoRhitGPEr.czz());
800 // // double pullGPX_tr_mono = (monoTsosGPos.x()-monoRhitGPos.x())/*/sqrt(monoTsosGPEr.cxx()+monoRhitGPEr.cxx())*/;
801 // // double pullGPY_tr_mono = (monoTsosGPos.y()-monoRhitGPos.y())/*/sqrt(monoTsosGPEr.cyy()+monoRhitGPEr.cyy())*/;
802 // // double pullGPZ_tr_mono = (monoTsosGPos.z()-monoRhitGPos.z())/*/sqrt(monoTsosGPEr.czz()+monoRhitGPEr.czz())*/;
803 
804 // title.str("");
805 // title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_mono";
806 // hPullGP_X_tr_mono[title.str()]->Fill( pullGPX_tr_mono );
807 // title.str("");
808 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_mono";
809 // hPullGP_Y_tr_mono[title.str()]->Fill( pullGPY_tr_mono );
810 // title.str("");
811 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_mono";
812 // hPullGP_Z_tr_mono[title.str()]->Fill( pullGPZ_tr_mono );
813 
814 // double pullGPX_ts_mono = (monoTsosGPos.x()-monoShitGPos.x())/sqrt(monoTsosGPEr.cxx());
815 // double pullGPY_ts_mono = (monoTsosGPos.y()-monoShitGPos.y())/sqrt(monoTsosGPEr.cyy());
816 // double pullGPZ_ts_mono = (monoTsosGPos.z()-monoShitGPos.z())/sqrt(monoTsosGPEr.czz());
817 // // double pullGPX_ts_mono = (monoTsosGPos.x()-monoShitGPos.x())/*/sqrt(monoTsosGPEr.cxx())*/;
818 // // double pullGPY_ts_mono = (monoTsosGPos.y()-monoShitGPos.y())/*/sqrt(monoTsosGPEr.cyy())*/;
819 // // double pullGPZ_ts_mono = (monoTsosGPos.z()-monoShitGPos.z())/*/sqrt(monoTsosGPEr.czz())*/;
820 
821 // title.str("");
822 // title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_mono";
823 // hPullGP_X_ts_mono[title.str()]->Fill( pullGPX_ts_mono );
824 // title.str("");
825 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_mono";
826 // hPullGP_Y_ts_mono[title.str()]->Fill( pullGPY_ts_mono );
827 // title.str("");
828 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_mono";
829 // hPullGP_Z_ts_mono[title.str()]->Fill( pullGPZ_ts_mono );
830 
831 // double pullGMX_ts_mono = (monoTsosGMom.x()-monoShitGMom.x())/sqrt(monoTsosGMEr.cxx());
832 // double pullGMY_ts_mono = (monoTsosGMom.y()-monoShitGMom.y())/sqrt(monoTsosGMEr.cyy());
833 // double pullGMZ_ts_mono = (monoTsosGMom.z()-monoShitGMom.z())/sqrt(monoTsosGMEr.czz());
834 // // double pullGMX_ts_mono = (monoTsosGMom.x()-monoShitGMom.x())/*/sqrt(monoTsosGMEr.cxx())*/;
835 // // double pullGMY_ts_mono = (monoTsosGMom.y()-monoShitGMom.y())/*/sqrt(monoTsosGMEr.cyy())*/;
836 // // double pullGMZ_ts_mono = (monoTsosGMom.z()-monoShitGMom.z())/*/sqrt(monoTsosGMEr.czz())*/;
837 
838 // title.str("");
839 // title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_mono";
840 // hPullGM_X_ts_mono[title.str()]->Fill( pullGMX_ts_mono );
841 // title.str("");
842 // title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_mono";
843 // hPullGM_Y_ts_mono[title.str()]->Fill( pullGMY_ts_mono );
844 // title.str("");
845 // title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_mono";
846 // hPullGM_Z_ts_mono[title.str()]->Fill( pullGMZ_ts_mono );
847 
848 // //stereo
849 // LogTrace("TestHits") << "STEREO HIT" << std::endl;
850 // CTTRHp tStereoHit =
851 // theBuilder->build(dynamic_cast<const SiStripMatchedRecHit2D*>((*rhit)->hit())->stereoHit());
852 // if (tStereoHit==0) continue;
853 // vector<PSimHit> assStereoSimHits = hitAssociator.associateHit(*tStereoHit->hit());
854 // if (assStereoSimHits.size()==0) continue;
855 // const PSimHit sStereoHit = *(assSimHits.begin());
856 // const Surface * stereoSurf = &( tStereoHit->det()->surface() );
857 // if (stereoSurf==0) continue;
858 // TSOS stereoState = thePropagator->propagate(lastState,*stereoSurf);
859 // if (stereoState.isValid()==0) continue;
860 
861 // LocalVector stereoShitLMom = sStereoHit.momentumAtEntry();
862 // GlobalVector stereoShitGMom = stereoSurf->toGlobal(stereoShitLMom);
863 // LocalPoint stereoShitLPos = sStereoHit.localPosition();
864 // GlobalPoint stereoShitGPos = stereoSurf->toGlobal(stereoShitLPos);
865 
866 // GlobalVector stereoTsosGMom = stereoState.globalMomentum();
867 // GlobalError stereoTsosGMEr(stereoState.cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3,3));
868 // GlobalPoint stereoTsosGPos = stereoState.globalPosition();
869 // GlobalError stereoTsosGPEr = stereoState.cartesianError().position();
870 
871 // GlobalPoint stereoRhitGPos = tStereoHit->globalPosition();
872 // GlobalError stereoRhitGPEr = tStereoHit->globalPositionError();
873 
874 // double pullGPX_rs_stereo = (stereoRhitGPos.x()-stereoShitGPos.x())/sqrt(stereoRhitGPEr.cxx());
875 // double pullGPY_rs_stereo = (stereoRhitGPos.y()-stereoShitGPos.y())/sqrt(stereoRhitGPEr.cyy());
876 // double pullGPZ_rs_stereo = (stereoRhitGPos.z()-stereoShitGPos.z())/sqrt(stereoRhitGPEr.czz());
877 // // double pullGPX_rs_stereo = (stereoRhitGPos.x()-stereoShitGPos.x())/*/sqrt(stereoRhitGPEr.cxx())*/;
878 // // double pullGPY_rs_stereo = (stereoRhitGPos.y()-stereoShitGPos.y())/*/sqrt(stereoRhitGPEr.cyy())*/;
879 // // double pullGPZ_rs_stereo = (stereoRhitGPos.z()-stereoShitGPos.z())/*/sqrt(stereoRhitGPEr.czz())*/;
880 
881 // title.str("");
882 // title << "PullGP_X_" << subdetId << "-" << layerId << "_rs_stereo";
883 // hPullGP_X_rs_stereo[title.str()]->Fill( pullGPX_rs_stereo );
884 // title.str("");
885 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_rs_stereo";
886 // hPullGP_Y_rs_stereo[title.str()]->Fill( pullGPY_rs_stereo );
887 // title.str("");
888 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_rs_stereo";
889 // hPullGP_Z_rs_stereo[title.str()]->Fill( pullGPZ_rs_stereo );
890 
891 // double pullGPX_tr_stereo = (stereoTsosGPos.x()-stereoRhitGPos.x())/sqrt(stereoTsosGPEr.cxx()+stereoRhitGPEr.cxx());
892 // double pullGPY_tr_stereo = (stereoTsosGPos.y()-stereoRhitGPos.y())/sqrt(stereoTsosGPEr.cyy()+stereoRhitGPEr.cyy());
893 // double pullGPZ_tr_stereo = (stereoTsosGPos.z()-stereoRhitGPos.z())/sqrt(stereoTsosGPEr.czz()+stereoRhitGPEr.czz());
894 // // double pullGPX_tr_stereo = (stereoTsosGPos.x()-stereoRhitGPos.x())/*/sqrt(stereoTsosGPEr.cxx()+stereoRhitGPEr.cxx())*/;
895 // // double pullGPY_tr_stereo = (stereoTsosGPos.y()-stereoRhitGPos.y())/*/sqrt(stereoTsosGPEr.cyy()+stereoRhitGPEr.cyy())*/;
896 // // double pullGPZ_tr_stereo = (stereoTsosGPos.z()-stereoRhitGPos.z())/*/sqrt(stereoTsosGPEr.czz()+stereoRhitGPEr.czz())*/;
897 
898 // title.str("");
899 // title << "PullGP_X_" << subdetId << "-" << layerId << "_tr_stereo";
900 // hPullGP_X_tr_stereo[title.str()]->Fill( pullGPX_tr_stereo );
901 // title.str("");
902 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_tr_stereo";
903 // hPullGP_Y_tr_stereo[title.str()]->Fill( pullGPY_tr_stereo );
904 // title.str("");
905 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_tr_stereo";
906 // hPullGP_Z_tr_stereo[title.str()]->Fill( pullGPZ_tr_stereo );
907 
908 // double pullGPX_ts_stereo = (stereoTsosGPos.x()-stereoShitGPos.x())/sqrt(stereoTsosGPEr.cxx());
909 // double pullGPY_ts_stereo = (stereoTsosGPos.y()-stereoShitGPos.y())/sqrt(stereoTsosGPEr.cyy());
910 // double pullGPZ_ts_stereo = (stereoTsosGPos.z()-stereoShitGPos.z())/sqrt(stereoTsosGPEr.czz());
911 // // double pullGPX_ts_stereo = (stereoTsosGPos.x()-stereoShitGPos.x())/*/sqrt(stereoTsosGPEr.cxx())*/;
912 // // double pullGPY_ts_stereo = (stereoTsosGPos.y()-stereoShitGPos.y())/*/sqrt(stereoTsosGPEr.cyy())*/;
913 // // double pullGPZ_ts_stereo = (stereoTsosGPos.z()-stereoShitGPos.z())/*/sqrt(stereoTsosGPEr.czz())*/;
914 
915 // title.str("");
916 // title << "PullGP_X_" << subdetId << "-" << layerId << "_ts_stereo";
917 // hPullGP_X_ts_stereo[title.str()]->Fill( pullGPX_ts_stereo );
918 // title.str("");
919 // title << "PullGP_Y_" << subdetId << "-" << layerId << "_ts_stereo";
920 // hPullGP_Y_ts_stereo[title.str()]->Fill( pullGPY_ts_stereo );
921 // title.str("");
922 // title << "PullGP_Z_" << subdetId << "-" << layerId << "_ts_stereo";
923 // hPullGP_Z_ts_stereo[title.str()]->Fill( pullGPZ_ts_stereo );
924 
925 // double pullGMX_ts_stereo = (stereoTsosGMom.x()-stereoShitGMom.x())/sqrt(stereoTsosGMEr.cxx());
926 // double pullGMY_ts_stereo = (stereoTsosGMom.y()-stereoShitGMom.y())/sqrt(stereoTsosGMEr.cyy());
927 // double pullGMZ_ts_stereo = (stereoTsosGMom.z()-stereoShitGMom.z())/sqrt(stereoTsosGMEr.czz());
928 // // double pullGMX_ts_stereo = (stereoTsosGMom.x()-stereoShitGMom.x())/*/sqrt(stereoTsosGMEr.cxx())*/;
929 // // double pullGMY_ts_stereo = (stereoTsosGMom.y()-stereoShitGMom.y())/*/sqrt(stereoTsosGMEr.cyy())*/;
930 // // double pullGMZ_ts_stereo = (stereoTsosGMom.z()-stereoShitGMom.z())/*/sqrt(stereoTsosGMEr.czz())*/;
931 
932 // title.str("");
933 // title << "PullGM_X_" << subdetId << "-" << layerId << "_ts_stereo";
934 // hPullGM_X_ts_stereo[title.str()]->Fill( pullGMX_ts_stereo );
935 // title.str("");
936 // title << "PullGM_Y_" << subdetId << "-" << layerId << "_ts_stereo";
937 // hPullGM_Y_ts_stereo[title.str()]->Fill( pullGMY_ts_stereo );
938 // title.str("");
939 // title << "PullGM_Z_" << subdetId << "-" << layerId << "_ts_stereo";
940 // hPullGM_Z_ts_stereo[title.str()]->Fill( pullGMZ_ts_stereo );
941 // }
942 // }
943 // }
944 // LogTrace("TestHits") << "end of event" << std::endl;
945 // }
946 
948  //file->Write();
949  TDirectory* chi2i = file->mkdir("Chi2_Increment");
950 
951  TDirectory* gp_ts = file->mkdir("GP_TSOS-SimHit");
952  TDirectory* gm_ts = file->mkdir("GM_TSOS-SimHit");
953  TDirectory* gp_tr = file->mkdir("GP_TSOS-RecHit");
954  TDirectory* gp_rs = file->mkdir("GP_RecHit-SimHit");
955 
956  TDirectory* gp_tsx = gp_ts->mkdir("X");
957  TDirectory* gp_tsy = gp_ts->mkdir("Y");
958  TDirectory* gp_tsz = gp_ts->mkdir("Z");
959  TDirectory* gm_tsx = gm_ts->mkdir("X");
960  TDirectory* gm_tsy = gm_ts->mkdir("Y");
961  TDirectory* gm_tsz = gm_ts->mkdir("Z");
962  TDirectory* gp_trx = gp_tr->mkdir("X");
963  TDirectory* gp_try = gp_tr->mkdir("Y");
964  TDirectory* gp_trz = gp_tr->mkdir("Z");
965  TDirectory* gp_rsx = gp_rs->mkdir("X");
966  TDirectory* gp_rsy = gp_rs->mkdir("Y");
967  TDirectory* gp_rsz = gp_rs->mkdir("Z");
968 
969  TDirectory* gp_tsx_mono = gp_ts->mkdir("MONOX");
970  TDirectory* gp_tsy_mono = gp_ts->mkdir("MONOY");
971  TDirectory* gp_tsz_mono = gp_ts->mkdir("MONOZ");
972  TDirectory* gm_tsx_mono = gm_ts->mkdir("MONOX");
973  TDirectory* gm_tsy_mono = gm_ts->mkdir("MONOY");
974  TDirectory* gm_tsz_mono = gm_ts->mkdir("MONOZ");
975  TDirectory* gp_trx_mono = gp_tr->mkdir("MONOX");
976  TDirectory* gp_try_mono = gp_tr->mkdir("MONOY");
977  TDirectory* gp_trz_mono = gp_tr->mkdir("MONOZ");
978  TDirectory* gp_rsx_mono = gp_rs->mkdir("MONOX");
979  TDirectory* gp_rsy_mono = gp_rs->mkdir("MONOY");
980  TDirectory* gp_rsz_mono = gp_rs->mkdir("MONOZ");
981 
982  TDirectory* gp_tsx_stereo = gp_ts->mkdir("STEREOX");
983  TDirectory* gp_tsy_stereo = gp_ts->mkdir("STEREOY");
984  TDirectory* gp_tsz_stereo = gp_ts->mkdir("STEREOZ");
985  TDirectory* gm_tsx_stereo = gm_ts->mkdir("STEREOX");
986  TDirectory* gm_tsy_stereo = gm_ts->mkdir("STEREOY");
987  TDirectory* gm_tsz_stereo = gm_ts->mkdir("STEREOZ");
988  TDirectory* gp_trx_stereo = gp_tr->mkdir("STEREOX");
989  TDirectory* gp_try_stereo = gp_tr->mkdir("STEREOY");
990  TDirectory* gp_trz_stereo = gp_tr->mkdir("STEREOZ");
991  TDirectory* gp_rsx_stereo = gp_rs->mkdir("STEREOX");
992  TDirectory* gp_rsy_stereo = gp_rs->mkdir("STEREOY");
993  TDirectory* gp_rsz_stereo = gp_rs->mkdir("STEREOZ");
994 
995  chi2i->cd();
996  hTotChi2Increment->Write();
997  hProcess_vs_Chi2->Write();
998  hClsize_vs_Chi2->Write();
999  for (int i = 0; i != 6; i++)
1000  for (int j = 0; j != 9; j++) {
1001  if (i == 0 && j > 2)
1002  break;
1003  if (i == 1 && j > 1)
1004  break;
1005  if (i == 2 && j > 3)
1006  break;
1007  if (i == 3 && j > 2)
1008  break;
1009  if (i == 4 && j > 5)
1010  break;
1011  if (i == 5 && j > 8)
1012  break;
1013  chi2i->cd();
1014  title.str("");
1015  title << "Chi2Increment_" << i + 1 << "-" << j + 1;
1016  hChi2Increment[title.str()]->Write();
1017 
1018  gp_ts->cd();
1019  gp_tsx->cd();
1020  title.str("");
1021  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts";
1022  hPullGP_X_ts[title.str()]->Write();
1023  gp_tsy->cd();
1024  title.str("");
1025  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts";
1026  hPullGP_Y_ts[title.str()]->Write();
1027  gp_tsz->cd();
1028  title.str("");
1029  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts";
1030  hPullGP_Z_ts[title.str()]->Write();
1031 
1032  gm_ts->cd();
1033  gm_tsx->cd();
1034  title.str("");
1035  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts";
1036  hPullGM_X_ts[title.str()]->Write();
1037  gm_tsy->cd();
1038  title.str("");
1039  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts";
1040  hPullGM_Y_ts[title.str()]->Write();
1041  gm_tsz->cd();
1042  title.str("");
1043  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts";
1044  hPullGM_Z_ts[title.str()]->Write();
1045 
1046  gp_tr->cd();
1047  gp_trx->cd();
1048  title.str("");
1049  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr";
1050  hPullGP_X_tr[title.str()]->Write();
1051  gp_try->cd();
1052  title.str("");
1053  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr";
1054  hPullGP_Y_tr[title.str()]->Write();
1055  gp_trz->cd();
1056  title.str("");
1057  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr";
1058  hPullGP_Z_tr[title.str()]->Write();
1059 
1060  gp_rs->cd();
1061  gp_rsx->cd();
1062  title.str("");
1063  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs";
1064  hPullGP_X_rs[title.str()]->Write();
1065  gp_rsy->cd();
1066  title.str("");
1067  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs";
1068  hPullGP_Y_rs[title.str()]->Write();
1069  gp_rsz->cd();
1070  title.str("");
1071  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs";
1072  hPullGP_Z_rs[title.str()]->Write();
1073 
1074  if (((i == 2 || i == 4) && (j == 0 || j == 1)) || (i == 3 || i == 5)) {
1075  //mono
1076  gp_ts->cd();
1077  gp_tsx_mono->cd();
1078  title.str("");
1079  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
1080  hPullGP_X_ts_mono[title.str()]->Write();
1081  gp_tsy_mono->cd();
1082  title.str("");
1083  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
1084  hPullGP_Y_ts_mono[title.str()]->Write();
1085  gp_tsz_mono->cd();
1086  title.str("");
1087  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
1088  hPullGP_Z_ts_mono[title.str()]->Write();
1089 
1090  gm_ts->cd();
1091  gm_tsx_mono->cd();
1092  title.str("");
1093  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_mono";
1094  hPullGM_X_ts_mono[title.str()]->Write();
1095  gm_tsy_mono->cd();
1096  title.str("");
1097  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_mono";
1098  hPullGM_Y_ts_mono[title.str()]->Write();
1099  gm_tsz_mono->cd();
1100  title.str("");
1101  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_mono";
1102  hPullGM_Z_ts_mono[title.str()]->Write();
1103 
1104  gp_tr->cd();
1105  gp_trx_mono->cd();
1106  title.str("");
1107  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_mono";
1108  hPullGP_X_tr_mono[title.str()]->Write();
1109  gp_try_mono->cd();
1110  title.str("");
1111  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_mono";
1112  hPullGP_Y_tr_mono[title.str()]->Write();
1113  gp_trz_mono->cd();
1114  title.str("");
1115  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_mono";
1116  hPullGP_Z_tr_mono[title.str()]->Write();
1117 
1118  gp_rs->cd();
1119  gp_rsx_mono->cd();
1120  title.str("");
1121  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_mono";
1122  hPullGP_X_rs_mono[title.str()]->Write();
1123  gp_rsy_mono->cd();
1124  title.str("");
1125  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_mono";
1126  hPullGP_Y_rs_mono[title.str()]->Write();
1127  gp_rsz_mono->cd();
1128  title.str("");
1129  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_mono";
1130  hPullGP_Z_rs_mono[title.str()]->Write();
1131 
1132  //stereo
1133  gp_ts->cd();
1134  gp_tsx_stereo->cd();
1135  title.str("");
1136  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1137  hPullGP_X_ts_stereo[title.str()]->Write();
1138  gp_tsy_stereo->cd();
1139  title.str("");
1140  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1141  hPullGP_Y_ts_stereo[title.str()]->Write();
1142  gp_tsz_stereo->cd();
1143  title.str("");
1144  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1145  hPullGP_Z_ts_stereo[title.str()]->Write();
1146 
1147  gm_ts->cd();
1148  gm_tsx_stereo->cd();
1149  title.str("");
1150  title << "PullGM_X_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1151  hPullGM_X_ts_stereo[title.str()]->Write();
1152  gm_tsy_stereo->cd();
1153  title.str("");
1154  title << "PullGM_Y_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1155  hPullGM_Y_ts_stereo[title.str()]->Write();
1156  gm_tsz_stereo->cd();
1157  title.str("");
1158  title << "PullGM_Z_" << i + 1 << "-" << j + 1 << "_ts_stereo";
1159  hPullGM_Z_ts_stereo[title.str()]->Write();
1160 
1161  gp_tr->cd();
1162  gp_trx_stereo->cd();
1163  title.str("");
1164  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_tr_stereo";
1165  hPullGP_X_tr_stereo[title.str()]->Write();
1166  gp_try_stereo->cd();
1167  title.str("");
1168  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_tr_stereo";
1169  hPullGP_Y_tr_stereo[title.str()]->Write();
1170  gp_trz_stereo->cd();
1171  title.str("");
1172  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_tr_stereo";
1173  hPullGP_Z_tr_stereo[title.str()]->Write();
1174 
1175  gp_rs->cd();
1176  gp_rsx_stereo->cd();
1177  title.str("");
1178  title << "PullGP_X_" << i + 1 << "-" << j + 1 << "_rs_stereo";
1179  hPullGP_X_rs_stereo[title.str()]->Write();
1180  gp_rsy_stereo->cd();
1181  title.str("");
1182  title << "PullGP_Y_" << i + 1 << "-" << j + 1 << "_rs_stereo";
1183  hPullGP_Y_rs_stereo[title.str()]->Write();
1184  gp_rsz_stereo->cd();
1185  title.str("");
1186  title << "PullGP_Z_" << i + 1 << "-" << j + 1 << "_rs_stereo";
1187  hPullGP_Z_rs_stereo[title.str()]->Write();
1188  }
1189  }
1190 
1191  file->Close();
1192 }
1193 
1194 //needed by to do the residual for matched hits
1195 //taken from SiStripTrackingRecHitsValid.cc
1196 std::pair<LocalPoint, LocalVector> TestHits::projectHit(const PSimHit& hit,
1197  const StripGeomDetUnit* stripDet,
1198  const BoundPlane& plane) {
1199  const StripTopology& topol = stripDet->specificTopology();
1200  GlobalPoint globalpos = stripDet->surface().toGlobal(hit.localPosition());
1201  LocalPoint localHit = plane.toLocal(globalpos);
1202  //track direction
1203  LocalVector locdir = hit.localDirection();
1204  //rotate track in new frame
1205 
1206  GlobalVector globaldir = stripDet->surface().toGlobal(locdir);
1207  LocalVector dir = plane.toLocal(globaldir);
1208  float scale = -localHit.z() / dir.z();
1209 
1210  LocalPoint projectedPos = localHit + scale * dir;
1211 
1212  float selfAngle = topol.stripAngle(topol.strip(hit.localPosition()));
1213 
1214  LocalVector stripDir(sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
1215 
1216  LocalVector localStripDir(plane.toLocal(stripDet->surface().toGlobal(stripDir)));
1217 
1218  return std::pair<LocalPoint, LocalVector>(projectedPos, localStripDir);
1219 }
1220 
1223 
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
TestHits::hPullGP_Y_rs
std::map< std::string, TH1F * > hPullGP_Y_rs
Definition: TestHits.h:86
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TestHits.h
TrajectoryStateOnSurface.h
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
TestHits::hPullGP_Y_tr_stereo
std::map< std::string, TH1F * > hPullGP_Y_tr_stereo
Definition: TestHits.h:118
MessageLogger.h
TestHits::theMF
edm::ESHandle< MagneticField > theMF
Definition: TestHits.h:71
TestHits::file
TFile * file
Definition: TestHits.h:77
TestHits::hPullGP_X_tr_mono
std::map< std::string, TH1F * > hPullGP_X_tr_mono
Definition: TestHits.h:104
TestHits::fname
std::string fname
Definition: TestHits.h:68
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
TrajectoryStateOnSurface::cartesianError
const CartesianTrajectoryError cartesianError() const
Definition: TrajectoryStateOnSurface.h:71
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
TestHits::trackerHitAssociatorConfig_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TestHits.h:61
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
TestHits::hPullGP_Y_ts
std::map< std::string, TH1F * > hPullGP_Y_ts
Definition: TestHits.h:80
TestHits::hPullGP_Z_ts
std::map< std::string, TH1F * > hPullGP_Z_ts
Definition: TestHits.h:81
TestHits::hTotChi2Increment
TH1F * hTotChi2Increment
Definition: TestHits.h:92
GluedGeomDet.h
Surface
Definition: Surface.h:36
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
TestHits::title
std::stringstream title
Definition: TestHits.h:78
TransientTrack.h
TestHits::builderName
std::string builderName
Definition: TestHits.h:66
TransientTrackingRecHitBuilder::build
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TestHits::hPullGM_Y_ts
std::map< std::string, TH1F * > hPullGM_Y_ts
Definition: TestHits.h:83
TrackQuality_cff.hitAssociator
hitAssociator
Definition: TrackQuality_cff.py:10
TestHits::hPullGP_Z_tr_mono
std::map< std::string, TH1F * > hPullGP_Z_tr_mono
Definition: TestHits.h:106
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
TestHits::hClsize_vs_Chi2
TH2F * hClsize_vs_Chi2
Definition: TestHits.h:93
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TestHits::hPullGP_Z_tr_stereo
std::map< std::string, TH1F * > hPullGP_Z_tr_stereo
Definition: TestHits.h:119
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
TestHits::theTCCollection
edm::Handle< TrackCandidateCollection > theTCCollection
Definition: TestHits.h:75
TestHits::maxeta
double maxeta
Definition: TestHits.h:63
TestHits::hPullGM_X_ts_mono
std::map< std::string, TH1F * > hPullGM_X_ts_mono
Definition: TestHits.h:98
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
TestHits::hPullGM_Y_ts_stereo
std::map< std::string, TH1F * > hPullGM_Y_ts_stereo
Definition: TestHits.h:112
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
TestHits::hPullGM_Y_ts_mono
std::map< std::string, TH1F * > hPullGM_Y_ts_mono
Definition: TestHits.h:99
TrackingRecHit::RecHitContainer
std::vector< ConstRecHitPointer > RecHitContainer
Definition: TrackingRecHit.h:31
TestHits::mineta
double mineta
Definition: TestHits.h:63
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TestHits::hPullGP_X_tr
std::map< std::string, TH1F * > hPullGP_X_tr
Definition: TestHits.h:88
TestHits::hPullGM_X_ts
std::map< std::string, TH1F * > hPullGM_X_ts
Definition: TestHits.h:82
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
TestHits::beginRun
void beginRun(edm::Run const &run, const edm::EventSetup &) override
Definition: TestHits.cc:36
TrackingRecHitLessFromGlobalPosition.h
TestHits::hPullGP_X_ts_stereo
std::map< std::string, TH1F * > hPullGP_X_ts_stereo
Definition: TestHits.h:108
edm::ESHandle< TrackerTopology >
PSimHit::localPosition
Local3DPoint localPosition() const
Definition: PSimHit.h:52
TrajectoryFitterRecord
Definition: TrajectoryFitterRecord.h:12
TrajectoryFitter.h
TestHits::hPullGP_Z_ts_mono
std::map< std::string, TH1F * > hPullGP_Z_ts_mono
Definition: TestHits.h:97
Point3DBase< float, LocalTag >
TestHits::hPullGP_Z_ts_stereo
std::map< std::string, TH1F * > hPullGP_Z_ts_stereo
Definition: TestHits.h:110
GlobalErrorBase::cxx
T cxx() const
Definition: GlobalErrorBase.h:97
StripTopology::strip
virtual float strip(const LocalPoint &) const =0
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
TrajectoryStateCombiner
Definition: TrajectoryStateCombiner.h:13
edm::ParameterSet
Definition: ParameterSet.h:36
TestHits::hPullGP_Y_tr_mono
std::map< std::string, TH1F * > hPullGP_Y_tr_mono
Definition: TestHits.h:105
TestHits::theG
edm::ESHandle< TrackerGeometry > theG
Definition: TestHits.h:70
TrackCandidate
Definition: TrackCandidate.h:23
TrackCandidate::recHits
range recHits() const
Definition: TrackCandidate.h:58
TestHits::hPullGP_Y_tr
std::map< std::string, TH1F * > hPullGP_Y_tr
Definition: TestHits.h:89
TestHits::hPullGP_X_rs_mono
std::map< std::string, TH1F * > hPullGP_X_rs_mono
Definition: TestHits.h:101
TestHits::hChi2Increment
std::map< std::string, TH1F * > hChi2Increment
Definition: TestHits.h:91
TestHits::hPullGP_Z_rs_stereo
std::map< std::string, TH1F * > hPullGP_Z_rs_stereo
Definition: TestHits.h:116
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
TrackCandidate::seed
TrajectorySeed const & seed() const
Definition: TrackCandidate.h:60
CTTRHp
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: TestHits.cc:20
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
edm::LogVerbatim
Definition: MessageLogger.h:297
TestHits::projectHit
std::pair< LocalPoint, LocalVector > projectHit(const PSimHit &, const StripGeomDetUnit *, const BoundPlane &)
Definition: TestHits.cc:1196
TestHits::hPullGM_Z_ts_stereo
std::map< std::string, TH1F * > hPullGM_Z_ts_stereo
Definition: TestHits.h:113
GlobalErrorBase< double, ErrorMatrixTag >
TestHits::srcName
std::string srcName
Definition: TestHits.h:67
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
TestHits::hPullGP_Y_rs_stereo
std::map< std::string, TH1F * > hPullGP_Y_rs_stereo
Definition: TestHits.h:115
CartesianTrajectoryError::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: CartesianTrajectoryError.h:28
TestHits::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TestHits.cc:190
TestHits::hPullGP_Z_rs
std::map< std::string, TH1F * > hPullGP_Z_rs
Definition: TestHits.h:87
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackerHitAssociator
Definition: TrackerHitAssociator.h:55
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
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
TestHits::hPullGP_X_rs_stereo
std::map< std::string, TH1F * > hPullGP_X_rs_stereo
Definition: TestHits.h:114
ModuleFactory.h
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TestHits
Definition: TestHits.h:49
TestHits::propagatorName
std::string propagatorName
Definition: TestHits.h:65
TrackInfoProducer_cfi.updatedState
updatedState
Definition: TrackInfoProducer_cfi.py:6
PSimHit::momentumAtEntry
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:55
TestHits::thePropagator
edm::ESHandle< Propagator > thePropagator
Definition: TestHits.h:72
BoundPlane
TransverseImpactPointExtrapolator.h
TestHits::hPullGM_Z_ts_mono
std::map< std::string, TH1F * > hPullGM_Z_ts_mono
Definition: TestHits.h:100
TestHits::hPullGP_Y_ts_mono
std::map< std::string, TH1F * > hPullGP_Y_ts_mono
Definition: TestHits.h:96
TrajectoryStateTransform.h
TestHits::theBuilder
edm::ESHandle< TransientTrackingRecHitBuilder > theBuilder
Definition: TestHits.h:73
GlobalErrorBase::czz
T czz() const
Definition: GlobalErrorBase.h:107
TestHits::hPullGP_X_ts_mono
std::map< std::string, TH1F * > hPullGP_X_ts_mono
Definition: TestHits.h:95
KFTrajectoryFitter.h
TestHits::~TestHits
~TestHits() override
Definition: TestHits.cc:34
StripGeomDetUnit::specificTopology
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Definition: StripGeomDetUnit.cc:17
TestHits::hPullGP_X_rs
std::map< std::string, TH1F * > hPullGP_X_rs
Definition: TestHits.h:85
TestHits::hPullGP_Y_rs_mono
std::map< std::string, TH1F * > hPullGP_Y_rs_mono
Definition: TestHits.h:102
TestHits::hPullGP_X_ts
std::map< std::string, TH1F * > hPullGP_X_ts
Definition: TestHits.h:79
mps_fire.result
result
Definition: mps_fire.py:303
TestHits::hPullGM_Z_ts
std::map< std::string, TH1F * > hPullGM_Z_ts
Definition: TestHits.h:84
TestHits::hPullGP_X_tr_stereo
std::map< std::string, TH1F * > hPullGP_X_tr_stereo
Definition: TestHits.h:117
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
heavyFlavorValidationHarvestingSequence_cff.combiner
combiner
Definition: heavyFlavorValidationHarvestingSequence_cff.py:107
TestHits::hProcess_vs_Chi2
TH2F * hProcess_vs_Chi2
Definition: TestHits.h:93
PSimHit
Definition: PSimHit.h:15
TestHits::hPullGP_Z_tr
std::map< std::string, TH1F * > hPullGP_Z_tr
Definition: TestHits.h:90
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TestHits::hPullGM_X_ts_stereo
std::map< std::string, TH1F * > hPullGM_X_ts_stereo
Definition: TestHits.h:111
TestHits::TestHits
TestHits(const edm::ParameterSet &)
Definition: TestHits.cc:24
edm::Event
Definition: Event.h:73
StripTopology
Definition: StripTopology.h:11
TestHits::hPullGP_Y_ts_stereo
std::map< std::string, TH1F * > hPullGP_Y_ts_stereo
Definition: TestHits.h:109
TestHits::hPullGP_Z_rs_mono
std::map< std::string, TH1F * > hPullGP_Z_rs_mono
Definition: TestHits.h:103
CartesianTrajectoryError::position
const GlobalError position() const
Position error submatrix.
Definition: CartesianTrajectoryError.h:41
TSOS
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
fit
Definition: CombinedChiSquaredLikelihood.h:6
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TestHits::endJob
void endJob() override
Definition: TestHits.cc:947
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
StripGeomDetUnit
Definition: StripGeomDetUnit.h:15
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12