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