CMS 3D CMS Logo

StraightTrackAlignment.cc
Go to the documentation of this file.
1 /****************************************************************************
2 * Authors:
3 * Jan Kašpar (jan.kaspar@gmail.com)
4 ****************************************************************************/
5 
10 
15 
18 
21 
22 #include <set>
23 #include <unordered_set>
24 #include <vector>
25 #include <string>
26 
27 #include "TDecompLU.h"
28 #include "TH1D.h"
29 #include "TFile.h"
30 #include "TGraph.h"
31 #include "TCanvas.h"
32 
33 //#define DEBUG
34 
35 using namespace edm;
36 using namespace std;
37 
38 //----------------------------------------------------------------------------------------------------
39 
41  return new TH1D(name, ";residual (mm)", 2000, -3., +3.); // in mm
42 }
43 
44 //----------------------------------------------------------------------------------------------------
45 
46 TGraph *newGraph(const string &name, const string &title) {
47  TGraph *g = new TGraph();
48  g->SetName(name.c_str());
49  g->SetTitle(title.c_str());
50  return g;
51 }
52 
53 //----------------------------------------------------------------------------------------------------
54 
55 StraightTrackAlignment::RPSetPlots::RPSetPlots(const string &_name) : name(_name) {
56  chisqn_lin_fitted = new TH1D("chi^2 norm, lin, fitted", ";#chi^{2}/ndf;", 5000, 0., 500.);
57  chisqn_lin_selected = new TH1D("chi^2 norm, lin, selected", ";#chi^{2}/ndf;", 5000, 0., 500.);
58  chisqn_log_fitted = new TH1D("chi^2 norm, log, fitted", ";log_{10}(#chi^{2}/ndf);", 700, -1., 6.);
59  chisqn_log_selected = new TH1D("chi^2 norm, log, selected", ";log_{10}(#chi^{2}/ndf);", 700, -1., 6.);
60 
61  fitAxVsAyGraph_fitted = newGraph("ax vs. ay, fitted", ";a_{x} (rad);a_{y} (rad)");
62  fitAxVsAyGraph_selected = newGraph("ax vs. ay, selected", ";a_{x} (rad);a_{y} (rad)");
63  fitBxVsByGraph_fitted = newGraph("bx vs. by, fitted", ";b_{x} (mm);b_{y} (mm)");
64  fitBxVsByGraph_selected = newGraph("bx vs. by, selected", ";b_{x} (mm);b_{y} (mm)");
65 }
66 //----------------------------------------------------------------------------------------------------
67 
69  delete chisqn_lin_fitted;
70  delete chisqn_lin_selected;
71  delete chisqn_log_fitted;
72  delete chisqn_log_selected;
73 
74  delete fitAxVsAyGraph_fitted;
76  delete fitBxVsByGraph_fitted;
78 }
79 
80 //----------------------------------------------------------------------------------------------------
81 
83  chisqn_lin_fitted->Write();
84  chisqn_lin_selected->Write();
85  chisqn_log_fitted->Write();
86  chisqn_log_selected->Write();
87 
88  fitAxVsAyGraph_fitted->Write();
89  fitAxVsAyGraph_selected->Write();
90  fitBxVsByGraph_fitted->Write();
91  fitBxVsByGraph_selected->Write();
92 }
93 
94 //----------------------------------------------------------------------------------------------------
95 //----------------------------------------------------------------------------------------------------
96 
98  : verbosity(ps.getUntrackedParameter<unsigned int>("verbosity", 0)),
99 
100  rpIds(ps.getParameter<vector<unsigned int> >("rpIds")),
101  excludePlanes(ps.getParameter<vector<unsigned int> >("excludePlanes")),
102  z0(ps.getParameter<double>("z0")),
103 
104  maxEvents(ps.getParameter<signed int>("maxEvents")),
105 
106  removeImpossible(ps.getParameter<bool>("removeImpossible")),
107  requireNumberOfUnits(ps.getParameter<unsigned int>("requireNumberOfUnits")),
108  requireAtLeast3PotsInOverlap(ps.getParameter<bool>("requireAtLeast3PotsInOverlap")),
109  requireOverlap(ps.getParameter<bool>("requireOverlap")),
110  cutOnChiSqPerNdf(ps.getParameter<bool>("cutOnChiSqPerNdf")),
111  chiSqPerNdfCut(ps.getParameter<double>("chiSqPerNdfCut")),
112  maxTrackAx(ps.getParameter<double>("maxTrackAx")),
113  maxTrackAy(ps.getParameter<double>("maxTrackAy")),
114 
115  fileNamePrefix(ps.getParameter<string>("fileNamePrefix")),
116  expandedFileNamePrefix(ps.getParameter<string>("expandedFileNamePrefix")),
117  factoredFileNamePrefix(ps.getParameter<string>("factoredFileNamePrefix")),
118  preciseXMLFormat(ps.getParameter<bool>("preciseXMLFormat")),
119  saveXMLUncertainties(ps.getParameter<bool>("saveXMLUncertainties")),
120 
121  saveIntermediateResults(ps.getParameter<bool>("saveIntermediateResults")),
122  taskDataFileName(ps.getParameter<string>("taskDataFileName")),
123  taskDataFile(nullptr),
124 
125  task(ps),
126  fitter(ps),
127 
128  buildDiagnosticPlots(ps.getParameter<bool>("buildDiagnosticPlots")),
129  diagnosticsFile(ps.getParameter<string>("diagnosticsFile")),
130  fitNdfHist_fitted(new TH1D("ndf_fitted", ";ndf;", 41, -4.5, 36.5)),
131  fitNdfHist_selected(new TH1D("ndf_selected", ";ndf;", 41, -4.5, 36.5)),
132  fitPHist_fitted(new TH1D("p_fitted", ";p value;", 100, 0., 1.)),
133  fitPHist_selected(new TH1D("p_selected", ";p value;", 100, 0., 1.)),
134  fitAxHist_fitted(new TH1D("ax_fitted", ";a_{x} (rad);", 10000, -0.1, 0.1)),
135  fitAxHist_selected(new TH1D("ax_selected", ";a_{x} (rad);", 10000, -0.1, 0.1)),
136  fitAyHist_fitted(new TH1D("ay_fitted", ";a_{y} (rad);", 10000, -0.1, 0.1)),
137  fitAyHist_selected(new TH1D("ay_selected", ";a_{y} (rad);", 10000, -0.1, 0.1)),
138  fitBxHist_fitted(new TH1D("bx_fitted", ";b_{x} (mm);", 500, -30., 30.)),
139  fitBxHist_selected(new TH1D("bx_selected", ";b_{x} (mm);", 500, -30., 30.)),
140  fitByHist_fitted(new TH1D("by_fitted", ";b_{y} (mm);", 500, -30., 30.)),
141  fitByHist_selected(new TH1D("by_selected", ";b_{y} (mm);", 500, -30., 30.)),
142 
143  globalPlots("global") {
144  // open task data file
145  if (!taskDataFileName.empty())
146  taskDataFile = new TFile(taskDataFileName.c_str(), "recreate");
147 
148  // instantiate algorithm objects
149  // (and save them)
150  vector<string> alNames(ps.getParameter<vector<string> >("algorithms"));
151  for (unsigned int i = 0; i < alNames.size(); i++) {
152  AlignmentAlgorithm *a = nullptr;
153 
154  if (alNames[i] == "Ideal") {
155  IdealResult *ir = new IdealResult(ps, &task);
156  a = ir;
157  } else if (alNames[i] == "Jan") {
159  a = jaa;
160  }
161 
162  if (a)
163  algorithms.push_back(a);
164  else
165  throw cms::Exception("PPS") << "Unknown alignment algorithm `" << alNames[i] << "'.";
166  }
167 
168  // get constraints type
169  string ct = ps.getParameter<string>("constraintsType");
170  if (ct.compare("fixedDetectors") == 0)
172  else if (ct.compare("standard") == 0)
174  else
175  throw cms::Exception("PPS") << "Unknown constraints type `" << ct << "'.";
176 
177  // parse additional accepted RP sets
178  string aars_str = ps.getParameter<string>("additionalAcceptedRPSets");
179 
180  size_t idx_b = 0, idx_e = string::npos;
181  while (idx_b != string::npos) {
182  // get one block - portion between successive ";"
183  idx_e = aars_str.find(';', idx_b);
184  size_t len = (idx_e == string::npos) ? string::npos : idx_e - idx_b;
185  string block = aars_str.substr(idx_b, len);
186 
187  // process the block
188  if (!block.empty()) {
189  set<unsigned int> rpSet;
190 
191  // isolate bits (= RP ids)
192  size_t bi_b = 0, bi_e = string::npos;
193  while (bi_b != string::npos) {
194  bi_e = block.find(',', bi_b);
195  size_t bit_len = (bi_e == string::npos) ? string::npos : bi_e - bi_b;
196  const string &bit = block.substr(bi_b, bit_len);
197 
198  unsigned int rp = atoi(bit.c_str());
199  rpSet.insert(rp);
200 
201  bi_b = (bi_e == string::npos) ? string::npos : bi_e + 1;
202  }
203 
204  additionalAcceptedRPSets.push_back(rpSet);
205  }
206 
207  // move to next block
208  idx_b = (idx_e == string::npos) ? string::npos : idx_e + 1;
209  }
210 }
211 
212 //----------------------------------------------------------------------------------------------------
213 
215  if (taskDataFile)
216  delete taskDataFile;
217 
218  for (vector<AlignmentAlgorithm *>::iterator it = algorithms.begin(); it != algorithms.end(); ++it)
219  delete (*it);
220 
221  delete fitNdfHist_fitted;
222  delete fitNdfHist_selected;
223  delete fitPHist_fitted;
224  delete fitPHist_selected;
225  delete fitAxHist_fitted;
226  delete fitAyHist_fitted;
227  delete fitAxHist_selected;
228  delete fitAyHist_selected;
229  delete fitBxHist_fitted;
230  delete fitByHist_fitted;
231  delete fitBxHist_selected;
232  delete fitByHist_selected;
233 
234  globalPlots.free();
235 
236  for (auto &p : rpSetPlots)
237  p.second.free();
238 
239  for (auto it = residuaHistograms.begin(); it != residuaHistograms.end(); ++it) {
240  delete it->second.total_fitted;
241  delete it->second.total_selected;
242  delete it->second.selected_vs_chiSq;
243  for (auto sit = it->second.perRPSet_fitted.begin(); sit != it->second.perRPSet_fitted.end(); ++sit)
244  delete sit->second;
245  for (auto sit = it->second.perRPSet_selected.begin(); sit != it->second.perRPSet_selected.end(); ++sit)
246  delete sit->second;
247  }
248 }
249 
250 //----------------------------------------------------------------------------------------------------
251 
253  edm::ESHandle<CTPPSGeometry> hRealGeometry,
254  edm::ESHandle<CTPPSGeometry> hMisalignedGeometry) {
255  // reset counters
256  eventsTotal = 0;
257  eventsFitted = 0;
258  eventsSelected = 0;
259  fittedTracksPerRPSet.clear();
260  selectedTracksPerRPSet.clear();
261  selectedHitsPerPlane.clear();
262 
263  // prepare geometry
265 
266  // build matrix index mappings
268 
269  // print geometry info
270  if (verbosity > 1)
271  task.geometry.print();
272 
273  // save task (including geometry) and fitter
274  if (taskDataFile) {
275  taskDataFile->WriteObject(&task, "task");
276  taskDataFile->WriteObject(&fitter, "fitter");
277  }
278 
279  // initiate the algorithms
280  for (const auto &a : algorithms)
281  a->begin(hRealGeometry.product(), hMisalignedGeometry.product());
282 
283  // get initial alignments
284  initialAlignments = *hRealAlignment;
285 }
286 
287 //----------------------------------------------------------------------------------------------------
288 
290  const DetSetVector<TotemRPUVPattern> &uvPatternsStrip,
291  const DetSetVector<CTPPSDiamondRecHit> &hitsDiamond,
292  const edm::DetSetVector<CTPPSPixelRecHit> &hitsPixel,
293  const DetSetVector<CTPPSPixelLocalTrack> &tracksPixel) {
294  eventsTotal++;
295 
296  if (verbosity > 9)
297  printf("\n---------- StraightTrackAlignment::ProcessEvent (%u:%llu)\n", eventId.run(), eventId.event());
298 
299  // -------------------- STEP 1: get hits from selected RPs
300 
302 
303  // strips
304  for (const auto &pv : uvPatternsStrip) {
305  const CTPPSDetId detId(pv.detId());
306  const unsigned int rpDecId = detId.arm() * 100 + detId.station() * 10 + detId.rp();
307 
308  // skip if RP not selected
309  if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end())
310  continue;
311 
312  // require exactly 1 U and 1 V pattern, i.e. unique U-V association
313  unsigned int n_U = 0, n_V = 0;
314  unsigned int idx_U = 0, idx_V = 0;
315  for (unsigned int pi = 0; pi < pv.size(); pi++) {
316  const TotemRPUVPattern &pattern = pv[pi];
317 
318  switch (pattern.projection()) {
320  n_U++;
321  idx_U = pi;
322  break;
323 
325  n_V++;
326  idx_V = pi;
327  break;
328 
329  default:
330  break;
331  }
332  }
333 
334  if (n_U != 1 || n_V != 1)
335  continue;
336 
337  // skip if patterns not reasonable
338  if (!pv[idx_U].fittable() || !pv[idx_V].fittable())
339  continue;
340 
341  // add hits from the U and V pattern
342  for (const auto &pattern : {pv[idx_U], pv[idx_V]}) {
343  for (const auto &hitsDetSet : pattern.hits()) {
344  // skip if sensor not in geometry
345  if (!task.geometry.isValidSensorId(hitsDetSet.detId()))
346  continue;
347 
348  const double &z = task.geometry.get(hitsDetSet.detId()).z;
349  for (auto &hit : hitsDetSet)
350  hitSelection.emplace_back(Hit(hitsDetSet.detId(), 2, hit.position(), hit.sigma(), z));
351  }
352  }
353  }
354 
355  // diamonds
356  for (const auto &pv : hitsDiamond) {
357  // skip if RP not selected
358  const CTPPSDetId detId(pv.detId());
359  const unsigned int rpDecId = detId.arm() * 100 + detId.station() * 10 + detId.rp();
360 
361  // skip if RP not selected
362  if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end())
363  continue;
364 
365  // skip if sensor not in geometry
366  if (!task.geometry.isValidSensorId(detId))
367  continue;
368 
369  const double &z = task.geometry.get(pv.detId()).z;
370 
371  for (const auto &h : pv)
372  hitSelection.emplace_back(Hit(pv.detId(), 1, h.x(), h.xWidth() / sqrt(12.), z));
373  }
374 
375  // pixels: data from rec hits
376  map<unsigned int, unsigned int> pixelPlaneMultiplicity;
377  for (const auto &pv : hitsPixel)
378  pixelPlaneMultiplicity[pv.detId()] += pv.size();
379 
380  for (const auto &pv : hitsPixel) {
381  // skip if RP not selected
382  const CTPPSDetId detId(pv.detId());
383  const unsigned int rpDecId = detId.arm() * 100 + detId.station() * 10 + detId.rp();
384 
385  // skip if RP not selected
386  if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end())
387  continue;
388 
389  // skip if sensor not in geometry
390  if (!task.geometry.isValidSensorId(detId))
391  continue;
392 
393  // skip if plane multiplicity greater than 1
394  if (pixelPlaneMultiplicity[pv.detId()] > 1)
395  continue;
396 
397  for (const auto &h : pv) {
398  const auto &dg = task.geometry.get(pv.detId());
399  const double dz1 = dg.getDirectionData(1).dz;
400  const double dz2 = dg.getDirectionData(2).dz;
401  const double z = dg.z + h.point().x() * dz1 + h.point().y() * dz2;
402 
403  double x_unc = sqrt(h.error().xx());
404  double y_unc = sqrt(h.error().yy());
405 
406  // TODO: Check this
407 
408  if (x_unc <= 0.)
409  x_unc = 10E-3; // mm
410  if (y_unc <= 0.)
411  y_unc = 10E-3; // mm
412 
413  hitSelection.emplace_back(Hit(pv.detId(), 1, h.point().x(), x_unc, z));
414  hitSelection.emplace_back(Hit(pv.detId(), 2, h.point().y(), y_unc, z));
415  }
416  }
417 
418  // pixels: data from tracks
419  for (const auto &pv : tracksPixel) {
420  const CTPPSDetId rpId(pv.detId());
421  const unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
422 
423  // skip if RP not selected
424  if (find(rpIds.begin(), rpIds.end(), rpDecId) == rpIds.end())
425  continue;
426 
427  // skip if more than 1 (valid) track in the RP
428  unsigned int n_valid_tracks = 0;
429  for (const auto &tr : pv) {
430  if (tr.isValid())
431  n_valid_tracks++;
432  }
433 
434  if (n_valid_tracks > 1)
435  continue;
436 
437  // go through all valid tracks
438  for (const auto &tr : pv) {
439  if (!tr.isValid())
440  continue;
441 
442  // go through all associated rec hits
443  for (const auto &hv : tr.hits()) {
444  const CTPPSPixelDetId senId(hv.detId());
445 
446  // skip if sensor not in geometry
447  if (!task.geometry.isValidSensorId(senId))
448  continue;
449 
450  for (const auto &h : hv) {
451  // skip hit if not used for fit
452  if (!h.isUsedForFit())
453  continue;
454 
455  const auto &dg = task.geometry.get(senId);
456  const double dz1 = dg.getDirectionData(1).dz;
457  const double dz2 = dg.getDirectionData(2).dz;
458  const double z = dg.z + h.point().x() * dz1 + h.point().y() * dz2;
459 
460  double x_unc = sqrt(h.error().xx());
461  double y_unc = sqrt(h.error().yy());
462 
463  if (x_unc <= 0.)
464  x_unc = 10E-3; // mm
465  if (y_unc <= 0.)
466  y_unc = 10E-3; // mm
467 
468  hitSelection.emplace_back(Hit(senId, 1, h.point().x(), x_unc, z));
469  hitSelection.emplace_back(Hit(senId, 2, h.point().y(), y_unc, z));
470  }
471  }
472  }
473  }
474 
475  if (hitSelection.empty())
476  return;
477 
478  // -------------------- STEP 2: fit + outlier rejection
479 
480  LocalTrackFit trackFit;
481  if (!fitter.fit(hitSelection, task.geometry, trackFit))
482  return;
483 
484  set<unsigned int> selectedRPs;
485  for (const auto &hit : hitSelection) {
486  CTPPSDetId detId(hit.id);
487  const unsigned int decRPId = detId.arm() * 100 + detId.station() * 10 + detId.rp();
488  selectedRPs.insert(decRPId);
489  }
490 
491  eventsFitted++;
492  fittedTracksPerRPSet[selectedRPs]++;
493 
494  // -------------------- STEP 3: quality checks
495 
496  bool top = false, bottom = false, horizontal = false;
497  unordered_set<unsigned int> units;
498  for (const auto &rp : selectedRPs) {
499  unsigned int rpIdx = rp % 10;
500  unsigned int stId = rp / 10;
501  unsigned int unitId = stId * 10;
502  if (rpIdx > 2)
503  unitId++;
504 
505  if (rpIdx == 0 || rpIdx == 4)
506  top = true;
507  if (rpIdx == 1 || rpIdx == 5)
508  bottom = true;
509  if (rpIdx == 2 || rpIdx == 3)
510  horizontal = true;
511 
512  units.insert(unitId);
513  }
514 
515  bool overlap = (top && horizontal) || (bottom && horizontal);
516 
517  bool rp_set_accepted = true;
518 
519  // impossible signature
520  if (removeImpossible && top && bottom)
521  rp_set_accepted = false;
522 
523  // cleanliness cuts
524  if (units.size() < requireNumberOfUnits)
525  rp_set_accepted = false;
526 
527  if (requireOverlap && !overlap)
528  rp_set_accepted = false;
529 
530  if (requireAtLeast3PotsInOverlap && overlap && selectedRPs.size() < 3)
531  rp_set_accepted = false;
532 
533  // is it an additional accepted RP set?
534  if (find(additionalAcceptedRPSets.begin(), additionalAcceptedRPSets.end(), selectedRPs) !=
536  rp_set_accepted = true;
537 
538  if (verbosity > 5)
539  printf("* rp set accepted: %u\n", rp_set_accepted);
540 
541  bool selected = rp_set_accepted;
542 
543  // too bad chisq
544  if (cutOnChiSqPerNdf && trackFit.chiSqPerNdf() > chiSqPerNdfCut)
545  selected = false;
546 
547  // parallelity cut
548  if (fabs(trackFit.ax) > maxTrackAx || fabs(trackFit.ay) > maxTrackAy)
549  selected = false;
550 
551  updateDiagnosticHistograms(hitSelection, selectedRPs, trackFit, selected);
552 
553  if (verbosity > 5)
554  printf("* event selected: %u\n", selected);
555 
556  if (!selected)
557  return;
558 
559  // update counters
560  eventsSelected++;
561  selectedTracksPerRPSet[selectedRPs]++;
562 
563  for (const auto &h : hitSelection)
564  selectedHitsPerPlane[h.id]++;
565 
566  // -------------------- STEP 4: FEED ALGORITHMS
567 
568  for (auto &a : algorithms)
569  a->feed(hitSelection, trackFit);
570 
571  // -------------------- STEP 5: ENOUGH TRACKS?
572 
573  if (eventsSelected == maxEvents)
574  throw "StraightTrackAlignment: Number of tracks processed reached maximum";
575 }
576 
577 //----------------------------------------------------------------------------------------------------
578 
580  const set<unsigned int> &selectedRPs,
581  const LocalTrackFit &trackFit,
582  bool trackSelected) {
584  return;
585 
586  fitNdfHist_fitted->Fill(trackFit.ndf);
587  fitPHist_fitted->Fill(trackFit.pValue());
588  fitAxHist_fitted->Fill(trackFit.ax);
589  fitAyHist_fitted->Fill(trackFit.ay);
590  fitBxHist_fitted->Fill(trackFit.bx);
591  fitByHist_fitted->Fill(trackFit.by);
592 
593  globalPlots.chisqn_lin_fitted->Fill(trackFit.chiSqPerNdf());
594  globalPlots.chisqn_log_fitted->Fill(log10(trackFit.chiSqPerNdf()));
595  globalPlots.fitAxVsAyGraph_fitted->SetPoint(globalPlots.fitAxVsAyGraph_fitted->GetN(), trackFit.ax, trackFit.ay);
596  globalPlots.fitBxVsByGraph_fitted->SetPoint(globalPlots.fitBxVsByGraph_fitted->GetN(), trackFit.bx, trackFit.by);
597 
598  if (trackSelected) {
599  fitNdfHist_selected->Fill(trackFit.ndf);
600  fitPHist_selected->Fill(trackFit.pValue());
601  fitAxHist_selected->Fill(trackFit.ax);
602  fitAyHist_selected->Fill(trackFit.ay);
603  fitBxHist_selected->Fill(trackFit.bx);
604  fitByHist_selected->Fill(trackFit.by);
605 
606  globalPlots.chisqn_lin_selected->Fill(trackFit.chiSqPerNdf());
607  globalPlots.chisqn_log_selected->Fill(log10(trackFit.chiSqPerNdf()));
609  globalPlots.fitAxVsAyGraph_selected->GetN(), trackFit.ax, trackFit.ay);
611  globalPlots.fitBxVsByGraph_selected->GetN(), trackFit.bx, trackFit.by);
612  }
613 
614  auto it = rpSetPlots.find(selectedRPs);
615  if (it == rpSetPlots.end())
616  it = rpSetPlots.insert({selectedRPs, RPSetPlots(setToString(selectedRPs))}).first;
617 
618  it->second.chisqn_lin_fitted->Fill(trackFit.chiSqPerNdf());
619  it->second.chisqn_log_fitted->Fill(log10(trackFit.chiSqPerNdf()));
620  it->second.fitAxVsAyGraph_fitted->SetPoint(it->second.fitAxVsAyGraph_fitted->GetN(), trackFit.ax, trackFit.ay);
621  it->second.fitBxVsByGraph_fitted->SetPoint(it->second.fitBxVsByGraph_fitted->GetN(), trackFit.bx, trackFit.by);
622 
623  if (trackSelected) {
624  it->second.chisqn_lin_selected->Fill(trackFit.chiSqPerNdf());
625  it->second.chisqn_log_selected->Fill(log10(trackFit.chiSqPerNdf()));
626  it->second.fitAxVsAyGraph_selected->SetPoint(it->second.fitAxVsAyGraph_selected->GetN(), trackFit.ax, trackFit.ay);
627  it->second.fitBxVsByGraph_selected->SetPoint(it->second.fitBxVsByGraph_selected->GetN(), trackFit.bx, trackFit.by);
628  }
629 
630  for (const auto &hit : selection) {
631  unsigned int id = hit.id;
632 
633  const DetGeometry &geom = task.geometry.get(id);
634  const auto dirData = geom.getDirectionData(hit.dirIdx);
635 
636  double m = hit.position + dirData.s - (hit.z - geom.z) * dirData.dz;
637  double x = trackFit.ax * hit.z + trackFit.bx;
638  double y = trackFit.ay * hit.z + trackFit.by;
639  double f = x * dirData.dx + y * dirData.dy;
640  double R = m - f;
641 
642  auto it = residuaHistograms.find(id);
643  if (it == residuaHistograms.end()) {
644  it = residuaHistograms.insert(pair<unsigned int, ResiduaHistogramSet>(id, ResiduaHistogramSet())).first;
645  char buf[30];
646  sprintf(buf, "%u: total_fitted", id);
647  it->second.total_fitted = newResiduaHist(buf);
648  sprintf(buf, "%u: total_selected", id);
649  it->second.total_selected = newResiduaHist(buf);
650  it->second.selected_vs_chiSq = new TGraph();
651  sprintf(buf, "%u: selected_vs_chiSq", id);
652  it->second.selected_vs_chiSq->SetName(buf);
653  }
654 
655  it->second.total_fitted->Fill(R);
656 
657  if (trackSelected) {
658  it->second.total_selected->Fill(R);
659  it->second.selected_vs_chiSq->SetPoint(it->second.selected_vs_chiSq->GetN(), trackFit.chiSqPerNdf(), R);
660  }
661 
662  auto sit = it->second.perRPSet_fitted.find(selectedRPs);
663  if (sit == it->second.perRPSet_fitted.end()) {
664  char buf[10];
665  sprintf(buf, "%u: ", id);
666  string label = buf;
667  label += setToString(selectedRPs);
668  sit =
669  it->second.perRPSet_fitted.insert(pair<set<unsigned int>, TH1D *>(selectedRPs, newResiduaHist(label.c_str())))
670  .first;
671  }
672 
673  sit->second->Fill(R);
674 
675  if (trackSelected) {
676  sit = it->second.perRPSet_selected.find(selectedRPs);
677  if (sit == it->second.perRPSet_selected.end()) {
678  char buf[10];
679  sprintf(buf, "%u: ", id);
680  string label = buf;
681  label += setToString(selectedRPs);
682  sit = it->second.perRPSet_selected
683  .insert(pair<set<unsigned int>, TH1D *>(selectedRPs, newResiduaHist(label.c_str())))
684  .first;
685  }
686 
687  sit->second->Fill(R);
688  }
689  }
690 }
691 
692 //----------------------------------------------------------------------------------------------------
693 
694 void StraightTrackAlignment::buildConstraints(vector<AlignmentConstraint> &constraints) {
695  constraints.clear();
696 
697  switch (constraintsType) {
698  case ctFixedDetectors:
700  return;
701 
702  case ctStandard:
704  return;
705  }
706 }
707 
708 //----------------------------------------------------------------------------------------------------
709 
711  // print statistics
712  if (verbosity) {
713  printf("----------------------------------------------------------------------------------------------------\n");
714  printf("\n>> StraightTrackAlignment::Finish\n");
715  printf("\tevents total = %i\n", eventsTotal);
716  printf("\tevents fitted = %i\n", eventsFitted);
717  printf("\tevents selected = %i\n", eventsSelected);
718 
719  printf("\n* events per RP set:\n");
720  printf("%30s %10s%10s\n", "set of RPs", "fitted", "selected");
721 
722  for (auto it = fittedTracksPerRPSet.begin(); it != fittedTracksPerRPSet.end(); ++it) {
723  const string &label = setToString(it->first);
724 
725  auto sit = selectedTracksPerRPSet.find(it->first);
726  unsigned long sv = (sit == selectedTracksPerRPSet.end()) ? 0 : sit->second;
727 
728  printf("%30s :%10lu%10lu\n", label.c_str(), it->second, sv);
729  }
730 
731  if (verbosity >= 2) {
732  printf("\n* hits per plane:\n");
733  for (const auto it : selectedHitsPerPlane) {
734  printf(" ");
735  printId(it.first);
736  printf(" : %u\n", it.second);
737  }
738  }
739  }
740 
741  // write diagnostics plots
742  saveDiagnostics();
743 
744  // run analysis
745  for (auto a : algorithms)
746  a->analyze();
747 
748  // build constraints
749  vector<AlignmentConstraint> constraints;
751 
752  // save constraints
753  if (taskDataFile)
754  taskDataFile->WriteObject(&constraints, "constraints");
755 
756  if (verbosity) {
757  printf("\n>> StraightTrackAlignment::Finish > %lu constraints built\n", constraints.size());
758  for (unsigned int i = 0; i < constraints.size(); i++)
759  printf("\t%s\n", constraints[i].name.c_str());
760  }
761 
762  // solve
763  vector<map<unsigned int, AlignmentResult> > results;
764  for (auto algorithm : algorithms) {
765  TDirectory *dir = nullptr;
767  dir = taskDataFile->mkdir((algorithm->getName() + "_data").c_str());
768 
769  results.resize(results.size() + 1);
770  unsigned int rf = algorithm->solve(constraints, results.back(), dir);
771 
772  if (rf)
773  throw cms::Exception("PPS") << "The Solve method of `" << algorithm->getName()
774  << "' algorithm has failed (return value " << rf << ").";
775  }
776 
777  // print results
778  if (verbosity) {
779  printf("\n>> StraightTrackAlignment::Finish > Print\n");
780 
784 
785  signed int prevRPId = -1;
786 
787  for (const auto &dit : task.geometry.getSensorMap()) {
788  signed int rpId = CTPPSDetId(dit.first).rpId();
789  if (rpId != prevRPId)
791  prevRPId = rpId;
792 
793  printId(dit.first);
794  printf(" ║");
795 
796  for (unsigned int q = 0; q < task.quantityClasses.size(); q++) {
797  for (unsigned int a = 0; a < results.size(); a++) {
798  const auto it = results[a].find(dit.first);
799  if (it == results[a].end()) {
800  if (algorithms[a]->hasErrorEstimate())
801  printf("%19s", "----");
802  else
803  printf("%8s", "----");
804 
805  if (a + 1 == results.size())
806  printf("║");
807  else
808  printf("│");
809 
810  continue;
811  }
812 
813  const auto &ac = it->second;
814  double v = 0., e = 0.;
815  switch (task.quantityClasses[q]) {
817  v = ac.getShR1();
818  e = ac.getShR1Unc();
819  break;
821  v = ac.getShR2();
822  e = ac.getShR2Unc();
823  break;
825  v = ac.getShZ();
826  e = ac.getShZUnc();
827  break;
829  v = ac.getRotZ();
830  e = ac.getRotZUnc();
831  break;
832  }
833 
834  if (algorithms[a]->hasErrorEstimate())
835  printf("%+8.1f ± %7.1f", v * 1E3, e * 1E3);
836  else
837  printf("%+8.1f", v * 1E3);
838 
839  if (a + 1 == results.size())
840  printf("║");
841  else
842  printf("│");
843  }
844  }
845 
846  printf("\n");
847  }
848 
853  }
854 
855  // save results as alignment XML files
856  for (unsigned int a = 0; a < results.size(); a++) {
857  // convert readout-direction corrections to X and Y
858  CTPPSRPAlignmentCorrectionsData convertedAlignments;
859  for (const auto &p : results[a]) {
860  const DetGeometry &d = task.geometry.get(p.first);
861  const auto dir1 = d.getDirectionData(1);
862  const auto dir2 = d.getDirectionData(2);
863 
864  const double det = dir1.dx * dir2.dy - dir1.dy * dir2.dx;
865  const double sh_x = (dir2.dy * p.second.getShR1() - dir1.dy * p.second.getShR2()) / det;
866  const double sh_y = (-dir2.dx * p.second.getShR1() + dir1.dx * p.second.getShR2()) / det;
867 
868  const double sh_x_e =
869  sqrt(pow(dir2.dy / det * p.second.getShR1Unc(), 2) + pow(dir1.dy / det * p.second.getShR2Unc(), 2));
870  const double sh_y_e =
871  sqrt(pow(dir2.dx / det * p.second.getShR1Unc(), 2) + pow(dir1.dx / det * p.second.getShR2Unc(), 2));
872 
874  sh_x_e,
875  sh_y,
876  sh_y_e,
877  p.second.getShZ(),
878  p.second.getShZUnc(),
879  0.,
880  0.,
881  0.,
882  0.,
883  p.second.getRotZ(),
884  p.second.getRotZUnc());
885  convertedAlignments.setSensorCorrection(p.first, corr);
886  }
887 
888  // write non-cumulative alignments
889  if (!fileNamePrefix.empty()) {
891  fileNamePrefix + algorithms[a]->getName() + ".xml",
894  true,
895  true,
896  true,
897  true);
898  }
899 
900  // merge alignments
901  CTPPSRPAlignmentCorrectionsData cumulativeAlignments;
902 
903  cumulativeAlignments.addCorrections(initialAlignments, false, true, true);
904  cumulativeAlignments.addCorrections(convertedAlignments, false, true, true);
905 
906  // write expanded and factored results
907  if (!expandedFileNamePrefix.empty() || !factoredFileNamePrefix.empty()) {
908  CTPPSRPAlignmentCorrectionsData expandedAlignments;
909  CTPPSRPAlignmentCorrectionsData factoredAlignments;
910 
911  if (verbosity)
912  printf(">> Factorizing results of %s algorithm\n", algorithms[a]->getName().c_str());
913 
914  const bool equalWeights = false;
916  cumulativeAlignments, expandedAlignments, factoredAlignments, task.geometry, equalWeights, verbosity);
917 
918  if (!expandedFileNamePrefix.empty()) {
923  true,
924  true,
925  true,
926  true);
927  }
928 
929  if (!factoredFileNamePrefix.empty()) {
934  true,
935  true,
936  true,
937  true);
938  }
939  }
940  }
941 
942  // prepare algorithms for destructions
943  for (const auto &algorithm : algorithms)
944  algorithm->end();
945 }
946 
947 //----------------------------------------------------------------------------------------------------
948 
949 string StraightTrackAlignment::setToString(const set<unsigned int> &s) {
950  unsigned int N = s.size();
951  if (N == 0)
952  return "empty";
953 
954  string str;
955  char buf[10];
956  unsigned int i = 0;
957  for (set<unsigned int>::iterator it = s.begin(); it != s.end(); ++it, ++i) {
958  sprintf(buf, "%u", *it);
959  str += buf;
960  if (i < N - 1)
961  str += ", ";
962  }
963 
964  return str;
965 }
966 
967 //----------------------------------------------------------------------------------------------------
968 
969 void StraightTrackAlignment::printN(const char *str, unsigned int N) {
970  for (unsigned int i = 0; i < N; i++)
971  printf("%s", str);
972 }
973 
974 //----------------------------------------------------------------------------------------------------
975 
976 void StraightTrackAlignment::printLineSeparator(const std::vector<std::map<unsigned int, AlignmentResult> > &results) {
977  printf("═════════════════════════╬");
978  for (unsigned int q = 0; q < task.quantityClasses.size(); q++) {
979  for (unsigned int a = 0; a < results.size(); a++) {
980  printN("═", algorithms[a]->hasErrorEstimate() ? 18 : 8);
981  if (a + 1 != results.size())
982  printf("═");
983  }
984  printf("╬");
985  }
986  printf("\n");
987 }
988 
989 //----------------------------------------------------------------------------------------------------
990 
991 void StraightTrackAlignment::printQuantitiesLine(const std::vector<std::map<unsigned int, AlignmentResult> > &results) {
992  printf(" ║");
993 
994  for (unsigned int q = 0; q < task.quantityClasses.size(); q++) {
995  unsigned int size = 0;
996  for (unsigned int a = 0; a < results.size(); a++)
997  size += (algorithms[a]->hasErrorEstimate()) ? 18 : 8;
998  size += algorithms.size() - 1;
999 
1000  const string &tag = task.quantityClassTag(task.quantityClasses[q]);
1001  unsigned int space = (size - tag.size()) / 2;
1002  printN(" ", space);
1003  printf("%s", tag.c_str());
1004  printN(" ", size - space - tag.size());
1005  printf("║");
1006  }
1007  printf("\n");
1008 }
1009 
1010 //----------------------------------------------------------------------------------------------------
1012 void StraightTrackAlignment::printAlgorithmsLine(const std::vector<std::map<unsigned int, AlignmentResult> > &results) {
1013  printf(" ║");
1014 
1015  for (unsigned int q = 0; q < task.quantityClasses.size(); q++) {
1016  for (unsigned int a = 0; a < results.size(); a++) {
1017  printf((algorithms[a]->hasErrorEstimate()) ? "%18s" : "%8s", algorithms[a]->getName().substr(0, 8).c_str());
1018 
1019  if (a + 1 == results.size())
1020  printf("║");
1021  else
1022  printf("│");
1023  }
1024  }
1025  printf("\n");
1026 }
1027 
1028 //----------------------------------------------------------------------------------------------------
1031  if (diagnosticsFile.empty())
1032  return;
1033 
1034  TFile *df = new TFile(diagnosticsFile.c_str(), "recreate");
1035  if (df->IsZombie())
1036  throw cms::Exception("PPS") << "Cannot open file `" << diagnosticsFile << "' for writing.";
1037 
1038  if (buildDiagnosticPlots) {
1039  TDirectory *commonDir = df->mkdir("common");
1040  gDirectory = commonDir;
1041 
1042  fitNdfHist_fitted->Write();
1043  fitNdfHist_selected->Write();
1044  fitAxHist_fitted->Write();
1045  fitAyHist_fitted->Write();
1046  fitAxHist_selected->Write();
1047  fitAyHist_selected->Write();
1048  fitBxHist_fitted->Write();
1049  fitByHist_fitted->Write();
1050  fitBxHist_selected->Write();
1051  fitByHist_selected->Write();
1052  fitPHist_fitted->Write();
1053  fitPHist_selected->Write();
1054 
1055  gDirectory = commonDir->mkdir("plots global");
1056  globalPlots.write();
1057 
1058  TDirectory *ppsDir = commonDir->mkdir("plots per RP set");
1059  for (map<set<unsigned int>, RPSetPlots>::const_iterator it = rpSetPlots.begin(); it != rpSetPlots.end(); ++it) {
1060  gDirectory = ppsDir->mkdir(setToString(it->first).c_str());
1061 
1062  it->second.write();
1063  }
1064 
1065  TDirectory *resDir = commonDir->mkdir("residuals");
1066  for (map<unsigned int, ResiduaHistogramSet>::const_iterator it = residuaHistograms.begin();
1067  it != residuaHistograms.end();
1068  ++it) {
1069  char buf[10];
1070  sprintf(buf, "%u", it->first);
1071  gDirectory = resDir->mkdir(buf);
1072  it->second.total_fitted->Write();
1073  it->second.total_selected->Write();
1074  it->second.selected_vs_chiSq->Write();
1075 
1076  /*
1077  gDirectory = gDirectory->mkdir("fitted per RP set");
1078  for (map< set<unsigned int>, TH1D* >::iterator sit = it->second.perRPSet_fitted.begin();
1079  sit != it->second.perRPSet_fitted.end(); ++sit)
1080  sit->second->Write();
1081  gDirectory->cd("..");
1082 */
1083 
1084  gDirectory = gDirectory->mkdir("selected per RP set");
1085  TCanvas *c = new TCanvas;
1086  c->SetName("alltogether");
1087  unsigned int idx = 0;
1088  for (map<set<unsigned int>, TH1D *>::const_iterator sit = it->second.perRPSet_selected.begin();
1089  sit != it->second.perRPSet_selected.end();
1090  ++sit, ++idx) {
1091  sit->second->SetLineColor(idx + 1);
1092  sit->second->Draw((idx == 0) ? "" : "same");
1093  sit->second->Write();
1094  }
1095  c->Write();
1096  }
1097  }
1098 
1099  // save diagnostics of algorithms
1100  for (vector<AlignmentAlgorithm *>::const_iterator it = algorithms.begin(); it != algorithms.end(); ++it) {
1101  TDirectory *algDir = df->mkdir((*it)->getName().c_str());
1102  (*it)->saveDiagnostics(algDir);
1103  }
1104 
1105  delete df;
1106 }
TotemRPUVPattern::projV
Definition: TotemRPUVPattern.h:34
StraightTrackAlignment::eventsFitted
signed int eventsFitted
counter of processed tracks
Definition: StraightTrackAlignment.h:170
DetGeometry::DirectionData::dz
double dz
x, y and z components of the direction unit vector in global coordinates
Definition: AlignmentGeometry.h:27
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
StraightTrackAlignment::RPSetPlots::chisqn_log_selected
TH1D * chisqn_log_selected
Definition: StraightTrackAlignment.h:191
edm::DetSetVector
Definition: DetSetVector.h:61
DDAxes::y
StraightTrackAlignment::fitAxHist_fitted
TH1D * fitAxHist_fitted
Definition: StraightTrackAlignment.h:181
CTPPSDetId::rp
uint32_t rp() const
Definition: CTPPSDetId.h:69
L1TDiffHarvesting_cfi.dir2
dir2
Definition: L1TDiffHarvesting_cfi.py:12
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
StraightTrackAlignment::maxEvents
signed int maxEvents
stops after this event number has been reached
Definition: StraightTrackAlignment.h:92
StraightTrackAlignment::requireAtLeast3PotsInOverlap
bool requireAtLeast3PotsInOverlap
if a track goes through overlap, select it only if it leaves signal in at least 3 pots
Definition: StraightTrackAlignment.h:103
AlignmentTask::qcShR1
detector shifts in first readout direction
Definition: AlignmentTask.h:60
DetGeometry::getDirectionData
const DirectionData & getDirectionData(unsigned int idx) const
Definition: AlignmentGeometry.h:43
StraightTrackAlignment::fittedTracksPerRPSet
std::map< std::set< unsigned int >, unsigned long > fittedTracksPerRPSet
counter of fitted tracks in a certain RP set
Definition: StraightTrackAlignment.h:173
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
StraightTrackAlignment::RPSetPlots::write
void write() const
Definition: StraightTrackAlignment.cc:81
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
StraightTrackAlignment::fitBxHist_fitted
TH1D * fitBxHist_fitted
Definition: StraightTrackAlignment.h:183
AlignmentTask::qcShZ
detector shifts in z
Definition: AlignmentTask.h:62
StraightTrackAlignment::RPSetPlots::fitAxVsAyGraph_fitted
TGraph * fitAxVsAyGraph_fitted
plots ax vs. ay
Definition: StraightTrackAlignment.h:194
IdealResult.h
IdealResult
Calculates the ideal result of the StraightTrackAlignment.
Definition: IdealResult.h:24
StraightTrackAlignment::selectedHitsPerPlane
std::map< unsigned int, unsigned int > selectedHitsPerPlane
counter of selected hits per plane
Definition: StraightTrackAlignment.h:177
StraightTrackAlignment::fitPHist_fitted
TH1D * fitPHist_fitted
Definition: StraightTrackAlignment.h:180
edm
HLT enums.
Definition: AlignableModifier.h:19
StraightTrackAlignment::eventsTotal
signed int eventsTotal
counter of events
Definition: StraightTrackAlignment.h:169
StraightTrackAlignment::taskDataFile
TFile * taskDataFile
the file with task data
Definition: StraightTrackAlignment.h:148
LocalTrackFit::ndf
signed int ndf
the number of degrees of freedom
Definition: LocalTrackFit.h:27
LocalTrackFit::chiSqPerNdf
double chiSqPerNdf() const
Definition: LocalTrackFit.h:43
AlignmentTask::quantityClassTag
std::string quantityClassTag(QuantityClass) const
returns a string tag for the given quantity class
Definition: AlignmentTask.cc:213
StraightTrackAlignment::diagnosticsFile
std::string diagnosticsFile
file name for some event selection statistics
Definition: StraightTrackAlignment.h:167
StraightTrackAlignment::saveIntermediateResults
bool saveIntermediateResults
whether itermediate results (S, CS matrices) of alignments shall be saved
Definition: StraightTrackAlignment.h:142
StraightTrackAlignment::residuaHistograms
std::map< unsigned int, ResiduaHistogramSet > residuaHistograms
residua histograms
Definition: StraightTrackAlignment.h:222
StraightTrackAlignment::factoredFileNamePrefix
std::string factoredFileNamePrefix
file name prefix for cumulative factored result files
Definition: StraightTrackAlignment.h:133
bookConverter.results
results
Definition: bookConverter.py:144
AlignmentTask::qcRotZ
detector rotations around z
Definition: AlignmentTask.h:63
StraightTrackAlignment::RPSetPlots::fitBxVsByGraph_selected
TGraph * fitBxVsByGraph_selected
Definition: StraightTrackAlignment.h:197
StraightTrackAlignment::RPSetPlots::chisqn_lin_fitted
TH1D * chisqn_lin_fitted
normalised chi^2 histograms for all/selected tracks, in linear/logarithmic scale
Definition: StraightTrackAlignment.h:190
StraightTrackAlignment::fitBxHist_selected
TH1D * fitBxHist_selected
fit bx histograms for all/selected tracks
Definition: StraightTrackAlignment.h:183
StraightTrackAlignment::printAlgorithmsLine
void printAlgorithmsLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:1011
DDAxes::x
StraightTrackAlignment::ctStandard
Definition: StraightTrackAlignment.h:86
findQualityFiles.v
v
Definition: findQualityFiles.py:179
StraightTrackAlignment::eventsSelected
signed int eventsSelected
counter of processed tracks
Definition: StraightTrackAlignment.h:171
StraightTrackAlignment::fitter
LocalTrackFitter fitter
track fitter
Definition: StraightTrackAlignment.h:156
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
LocalTrackFit::by
double by
Definition: LocalTrackFit.h:24
CTPPSRPAlignmentCorrectionsData::addCorrections
void addCorrections(const CTPPSRPAlignmentCorrectionsData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
adds (merges) corrections on top of the current values
Definition: CTPPSRPAlignmentCorrectionsData.cc:101
AlignmentTask::buildIndexMaps
void buildIndexMaps()
builds "mapMatrixIndeces" from "geometry"
Definition: AlignmentTask.cc:93
StraightTrackAlignment::ctFixedDetectors
Definition: StraightTrackAlignment.h:86
StraightTrackAlignment::taskDataFileName
std::string taskDataFileName
the name task data file
Definition: StraightTrackAlignment.h:145
StraightTrackAlignment::finish
virtual void finish()
performs analyses and fill results variable
Definition: StraightTrackAlignment.cc:709
StraightTrackAlignment::globalPlots
RPSetPlots globalPlots
global (all RP sets) chi^2 histograms
Definition: StraightTrackAlignment.h:209
AlignmentTask::buildFixedDetectorsConstraints
void buildFixedDetectorsConstraints(std::vector< AlignmentConstraint > &) const
builds a set of fixed-detector constraints
Definition: AlignmentTask.cc:250
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
units
TString units(TString variable, Char_t axis)
StraightTrackAlignment::fitNdfHist_selected
TH1D * fitNdfHist_selected
fit num. of degrees of freedom histograms for all/selected tracks
Definition: StraightTrackAlignment.h:179
JanAlignmentAlgorithm.h
DetGeometry
A structure to hold relevant geometrical information about one detector/sensor.
Definition: AlignmentGeometry.h:19
CTPPSGeometry.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CTPPSDetId::station
uint32_t station() const
Definition: CTPPSDetId.h:62
h
StraightTrackAlignment::initialAlignments
CTPPSRPAlignmentCorrectionsData initialAlignments
(real geometry) alignments before this alignment iteration
Definition: StraightTrackAlignment.h:159
StraightTrackAlignment::task
AlignmentTask task
the alignment task to be solved
Definition: StraightTrackAlignment.h:153
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
LocalTrackFitter::fit
bool fit(HitCollection &, const AlignmentGeometry &, LocalTrackFit &) const
Definition: LocalTrackFitter.cc:30
StraightTrackAlignment::verbosity
unsigned int verbosity
verbosity level
Definition: StraightTrackAlignment.h:70
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
AlignmentAlgorithm
Abstract parent for all (track-based) alignment algorithms.
Definition: AlignmentAlgorithm.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
getName
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:235
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
mps_fire.end
end
Definition: mps_fire.py:242
RPRealAlignmentRecord.h
DDAxes::z
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
StraightTrackAlignment::updateDiagnosticHistograms
void updateDiagnosticHistograms(const HitCollection &selection, const std::set< unsigned int > &selectedRPs, const LocalTrackFit &trackFit, bool trackSelected)
fills diagnostic (chi^2, residua, ...) histograms
Definition: StraightTrackAlignment.cc:578
str
#define str(s)
Definition: TestProcessor.cc:53
edm::ESHandle
Definition: DTSurvey.h:22
JanAlignmentAlgorithm
Jan's alignment algorithm.
Definition: JanAlignmentAlgorithm.h:25
StraightTrackAlignment.h
N
#define N
Definition: blowfish.cc:9
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
StraightTrackAlignment::requireOverlap
bool requireOverlap
if true, only track through vertical-horizontal overlap are seleceted
Definition: StraightTrackAlignment.h:106
CTPPSRPAlignmentCorrectionsMethods::writeToXML
static void writeToXML(const CTPPSRPAlignmentCorrectionsDataSequence &seq, const std::string &fileName, bool precise=false, bool wrErrors=true, bool wrSh_xy=true, bool wrSh_z=false, bool wrRot_xy=false, bool wrRot_z=true)
writes sequence of alignment corrections into a single XML file
Definition: CTPPSRPAlignmentCorrectionsMethods.cc:314
L1TDiffHarvesting_cfi.dir1
dir1
Definition: L1TDiffHarvesting_cfi.py:10
StraightTrackAlignment::RPSetPlots::free
void free()
Definition: StraightTrackAlignment.cc:67
StraightTrackAlignment::fitAyHist_fitted
TH1D * fitAyHist_fitted
Definition: StraightTrackAlignment.h:182
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
StraightTrackAlignment::fitPHist_selected
TH1D * fitPHist_selected
fit p-value histograms for all/selected tracks
Definition: StraightTrackAlignment.h:180
hit::z
double z
Definition: SiStripHitEffFromCalibTree.cc:91
StraightTrackAlignment::cutOnChiSqPerNdf
bool cutOnChiSqPerNdf
whether to cut on chi^2/ndf
Definition: StraightTrackAlignment.h:109
StraightTrackAlignment::additionalAcceptedRPSets
std::vector< std::set< unsigned int > > additionalAcceptedRPSets
list of RP sets accepted irrespective of the other "require" settings
Definition: StraightTrackAlignment.h:119
AlignmentGeometry::getSensorMap
const std::map< unsigned int, DetGeometry > & getSensorMap() const
Definition: AlignmentGeometry.h:69
CTPPSDetId::arm
uint32_t arm() const
Definition: CTPPSDetId.h:55
TotemRPUVPattern
A linear pattern in U or V projection. The intercept b is taken at the middle of a RP: (geometry->Get...
Definition: TotemRPUVPattern.h:22
edm::ParameterSet
Definition: ParameterSet.h:47
StraightTrackAlignment::StraightTrackAlignment
StraightTrackAlignment(const edm::ParameterSet &)
Definition: StraightTrackAlignment.cc:96
a
double a
Definition: hdecay.h:119
StraightTrackAlignment::excludePlanes
std::vector< unsigned int > excludePlanes
list of planes to be excluded from processing
Definition: StraightTrackAlignment.h:76
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Event.h
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
StraightTrackAlignment::removeImpossible
bool removeImpossible
remove events with impossible signatures (i.e. simultaneously top and bottom)
Definition: StraightTrackAlignment.h:97
StraightTrackAlignment::ResiduaHistogramSet
map: detector id --> residua histogram
Definition: StraightTrackAlignment.h:215
StraightTrackAlignment::buildDiagnosticPlots
bool buildDiagnosticPlots
whether to build and save diagnostic plots
Definition: StraightTrackAlignment.h:164
StraightTrackAlignment::newResiduaHist
TH1D * newResiduaHist(const char *name)
creates a new residua histogram
Definition: StraightTrackAlignment.cc:39
StraightTrackAlignment::processEvent
virtual void processEvent(const edm::EventID &eventId, const edm::DetSetVector< TotemRPUVPattern > &uvPatternsStrip, const edm::DetSetVector< CTPPSDiamondRecHit > &hitsDiamond, const edm::DetSetVector< CTPPSPixelRecHit > &hitsPixel, const edm::DetSetVector< CTPPSPixelLocalTrack > &tracksPixel)
Definition: StraightTrackAlignment.cc:288
StraightTrackAlignment::RPSetPlots::chisqn_lin_selected
TH1D * chisqn_lin_selected
Definition: StraightTrackAlignment.h:190
qcdUeDQM_cfi.algorithm
algorithm
Definition: qcdUeDQM_cfi.py:32
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
StraightTrackAlignment::fileNamePrefix
std::string fileNamePrefix
file name prefix for result files
Definition: StraightTrackAlignment.h:124
StraightTrackAlignment::preciseXMLFormat
bool preciseXMLFormat
whether to use long format (many decimal digits) when saving XML files
Definition: StraightTrackAlignment.h:136
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
createfilelist.int
int
Definition: createfilelist.py:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
muon::overlap
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
Definition: MuonSelectors.cc:791
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
StraightTrackAlignment::rpSetPlots
std::map< std::set< unsigned int >, RPSetPlots > rpSetPlots
chi^2 histograms per RP set
Definition: StraightTrackAlignment.h:212
LocalTrackFit::pValue
double pValue() const
Definition: LocalTrackFit.h:41
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
StraightTrackAlignment::printLineSeparator
void printLineSeparator(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:975
StraightTrackAlignment::buildConstraints
void buildConstraints(std::vector< AlignmentConstraint > &)
builds a selected set of constraints
Definition: StraightTrackAlignment.cc:693
Utilities.h
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
AlignmentGeometry::get
const DetGeometry & get(unsigned int id) const
retrieves sensor geometry
Definition: AlignmentGeometry.cc:16
hcal_runs.rf
rf
Definition: hcal_runs.py:75
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:15
StraightTrackAlignment::saveDiagnostics
void saveDiagnostics() const
saves a ROOT file with diagnostic plots
Definition: StraightTrackAlignment.cc:1029
LocalTrackFit::ax
double ax
slopes in rad
Definition: LocalTrackFit.h:21
VeryForwardRealGeometryRecord.h
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
createBeamHaloJobs.constraints
string constraints
Definition: createBeamHaloJobs.py:229
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
newGraph
TGraph * newGraph(const string &name, const string &title)
Definition: StraightTrackAlignment.cc:45
StraightTrackAlignment::RPSetPlots::fitBxVsByGraph_fitted
TGraph * fitBxVsByGraph_fitted
plots bx vs. by
Definition: StraightTrackAlignment.h:197
StraightTrackAlignment::constraintsType
ConstraintsType constraintsType
the chosen type of constraints
Definition: StraightTrackAlignment.h:89
profile_2016_postTS2_cff.rpId
rpId
Definition: profile_2016_postTS2_cff.py:21
interestingEgammaIsoDetIdsSequence_cff.hitSelection
hitSelection
Definition: interestingEgammaIsoDetIdsSequence_cff.py:92
StraightTrackAlignment::rpIds
std::vector< unsigned int > rpIds
list of RPs for which the alignment parameters shall be optimized
Definition: StraightTrackAlignment.h:73
StraightTrackAlignment::requireNumberOfUnits
unsigned int requireNumberOfUnits
select only tracks with activity in minimal number of units
Definition: StraightTrackAlignment.h:100
AlignmentTask::buildStandardConstraints
void buildStandardConstraints(std::vector< AlignmentConstraint > &) const
builds the standard constraints
Definition: AlignmentTask.cc:307
factorRPFromSensorCorrections
void factorRPFromSensorCorrections(const CTPPSRPAlignmentCorrectionsData &input, CTPPSRPAlignmentCorrectionsData &expanded, CTPPSRPAlignmentCorrectionsData &factored, const AlignmentGeometry &, bool equalWeights=false, unsigned int verbosity=0)
Definition: Utilities.cc:92
std
Definition: JetResolutionObject.h:76
StraightTrackAlignment::setToString
static std::string setToString(const std::set< unsigned int > &)
converts a set to string
Definition: StraightTrackAlignment.cc:948
StraightTrackAlignment::maxTrackAx
double maxTrackAx
cuts on absolute values of the track angle
Definition: StraightTrackAlignment.h:115
StraightTrackAlignment::selectedTracksPerRPSet
std::map< std::set< unsigned int >, unsigned long > selectedTracksPerRPSet
counter of selected tracks in a certain RP set
Definition: StraightTrackAlignment.h:175
StraightTrackAlignment::fitNdfHist_fitted
TH1D * fitNdfHist_fitted
Definition: StraightTrackAlignment.h:179
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
LocalTrackFit::bx
double bx
intercepts in mm
Definition: LocalTrackFit.h:24
printId
void printId(unsigned int id)
Definition: Utilities.cc:25
StraightTrackAlignment::RPSetPlots::chisqn_log_fitted
TH1D * chisqn_log_fitted
Definition: StraightTrackAlignment.h:190
HitCollection
std::vector< Hit > HitCollection
Definition: HitCollection.h:34
StraightTrackAlignment::printN
void printN(const char *str, unsigned int N)
result pretty printing routines
Definition: StraightTrackAlignment.cc:968
AlignmentTask::buildGeometry
static void buildGeometry(const std::vector< unsigned int > &rpDecIds, const std::vector< unsigned int > &excludedSensors, const CTPPSGeometry *, double z0, AlignmentGeometry &geometry)
builds the alignment geometry
Definition: AlignmentTask.cc:49
StraightTrackAlignment::chiSqPerNdfCut
double chiSqPerNdfCut
the value of chi^2/ndf cut threshold
Definition: StraightTrackAlignment.h:112
Exception
Definition: hltDiff.cc:245
StraightTrackAlignment::fitByHist_fitted
TH1D * fitByHist_fitted
Definition: StraightTrackAlignment.h:184
protons_cff.decRPId
decRPId
Definition: protons_cff.py:56
CTPPSRPAlignmentCorrectionsMethods.h
LocalTrackFit
Local (linear) track description (or a fit result). Uses global reference system.
Definition: LocalTrackFit.h:14
CTPPSRPAlignmentCorrectionsData
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
Definition: CTPPSRPAlignmentCorrectionsData.h:24
StraightTrackAlignment::RPSetPlots::fitAxVsAyGraph_selected
TGraph * fitAxVsAyGraph_selected
Definition: StraightTrackAlignment.h:194
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentTask::quantityClasses
std::vector< QuantityClass > quantityClasses
list of quantity classes to be optimized
Definition: AlignmentTask.h:67
TotemRPUVPattern::projU
Definition: TotemRPUVPattern.h:34
AlignmentTask::geometry
AlignmentGeometry geometry
the geometry for this task
Definition: AlignmentTask.h:47
StraightTrackAlignment::printQuantitiesLine
void printQuantitiesLine(const std::vector< std::map< unsigned int, AlignmentResult > > &)
Definition: StraightTrackAlignment.cc:990
AlignmentGeometry::isValidSensorId
bool isValidSensorId(unsigned int id) const
check whether the sensor Id is valid (present in the map)
Definition: AlignmentGeometry.h:75
AlignmentGeometry::print
void print() const
Prints the geometry.
Definition: AlignmentGeometry.cc:30
StraightTrackAlignment::z0
double z0
Definition: StraightTrackAlignment.h:80
StraightTrackAlignment::saveXMLUncertainties
bool saveXMLUncertainties
whether to save uncertainties in the result XML files
Definition: StraightTrackAlignment.h:139
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
ztail.d
d
Definition: ztail.py:151
CTPPSRPAlignmentCorrectionData
Alignment correction for an element of the CT-PPS detector. Within the geometry description,...
Definition: CTPPSRPAlignmentCorrectionData.h:58
pi
const Double_t pi
Definition: trackSplitPlot.h:36
cms::Exception
Definition: Exception.h:70
StraightTrackAlignment::fitAxHist_selected
TH1D * fitAxHist_selected
fit ax histograms for all/selected tracks
Definition: StraightTrackAlignment.h:181
StraightTrackAlignment::algorithms
std::vector< AlignmentAlgorithm * > algorithms
the collection of the alignment algorithms
Definition: StraightTrackAlignment.h:83
genParticles_cff.map
map
Definition: genParticles_cff.py:11
StraightTrackAlignment::fitAyHist_selected
TH1D * fitAyHist_selected
fit ay histograms for all/selected tracks
Definition: StraightTrackAlignment.h:182
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
CTPPSDetId::rpId
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:82
StraightTrackAlignment::begin
virtual void begin(edm::ESHandle< CTPPSRPAlignmentCorrectionsData > hRealAlignment, edm::ESHandle< CTPPSGeometry > hRealGeometry, edm::ESHandle< CTPPSGeometry > hMisalignedGeometry)
Definition: StraightTrackAlignment.cc:251
edm::EventID
Definition: EventID.h:31
dttmaxenums::R
Definition: DTTMax.h:29
StraightTrackAlignment::~StraightTrackAlignment
virtual ~StraightTrackAlignment()
Definition: StraightTrackAlignment.cc:213
StraightTrackAlignment::maxTrackAy
double maxTrackAy
Definition: StraightTrackAlignment.h:116
label
const char * label
Definition: PFTauDecayModeTools.cc:11
StraightTrackAlignment::RPSetPlots::RPSetPlots
RPSetPlots()
Definition: StraightTrackAlignment.h:199
AlignmentTask::qcShR2
detector shifts in second readout direction
Definition: AlignmentTask.h:61
CTPPSRPAlignmentCorrectionsData::setSensorCorrection
void setSensorCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData &ac)
sets the alignment correction for the given sensor
Definition: CTPPSRPAlignmentCorrectionsData.cc:73
hit
Definition: SiStripHitEffFromCalibTree.cc:88
StraightTrackAlignment::fitByHist_selected
TH1D * fitByHist_selected
fit by histograms for all/selected tracks
Definition: StraightTrackAlignment.h:184
Hit
SeedingHitSet::ConstRecHitPointer Hit
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:34
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
StraightTrackAlignment::RPSetPlots
Definition: StraightTrackAlignment.h:186
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
LocalTrackFit::ay
double ay
Definition: LocalTrackFit.h:21
StraightTrackAlignment::expandedFileNamePrefix
std::string expandedFileNamePrefix
file name prefix for cumulative expanded result files
Definition: StraightTrackAlignment.h:130