CMS 3D CMS Logo

ApeEstimator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ApeEstimator
4 // Class: ApeEstimator
5 //
13 //
14 // Original Author: Johannes Hauk
15 // Created: Tue Jan 6 15:02:09 CET 2009
16 // Modified by: Christian Schomakers (RWTH Aachen)
17 // $Id: ApeEstimator.cc,v 1.27 2012/06/26 09:42:33 hauk Exp $
18 //
19 //
20 
21 // system include files
22 #include <memory>
23 #include <sstream>
24 #include <fstream>
25 
26 // user include files
37 
40 
60 
68 
72 //added by Ajay 6Nov 2014
73 //.......................
76 
78 
79 //...............
80 //
81 
84 
86 
88 
93 
94 #include "TH1.h"
95 #include "TH2.h"
96 #include "TProfile.h"
97 #include "TFile.h"
98 #include "TTree.h"
99 #include "TF1.h"
100 #include "TString.h"
101 #include "TMath.h"
102 
105 
108 //ADDED BY LOIC QUERTENMONT
121 
122 //
123 // class decleration
124 //
125 
127 public:
128  explicit ApeEstimator(const edm::ParameterSet&);
129  ~ApeEstimator() override;
130 
131 private:
133  PositionAndError2() : posX(-999.F), posY(-999.F), errX2(-999.F), errY2(-999.F){};
134  PositionAndError2(float x, float y, float eX, float eY) : posX(x), posY(y), errX2(eX), errY2(eY){};
135  float posX;
136  float posY;
137  float errX2;
138  float errY2;
139  };
140  typedef std::pair<TrackStruct::HitState, PositionAndError2> StatePositionAndError2;
141 
142  void beginJob() override;
143  void analyze(const edm::Event&, const edm::EventSetup&) override;
144  void endJob() override;
145 
146  bool isHit2D(const TrackingRecHit&) const;
147 
148  void sectorBuilder();
149  bool checkIntervalsForSectors(const unsigned int sectorCounter, const std::vector<double>&) const;
150  bool checkModuleIds(const unsigned int, const std::vector<unsigned int>&) const;
151  bool checkModuleBools(const bool, const std::vector<unsigned int>&) const;
152  bool checkModuleDirections(const int, const std::vector<int>&) const;
153  bool checkModulePositions(const float, const std::vector<double>&) const;
154  void statistics(const TrackerSectorStruct&, const int) const;
155 
156  void residualErrorBinning();
157 
160  void bookTrackHists();
161 
164 
165  StatePositionAndError2 positionAndError2(const LocalPoint&, const LocalError&, const TransientTrackingRecHit&);
168 
169  void hitSelection();
170  void setHitSelectionMap(const std::string&);
171  void setHitSelectionMapUInt(const std::string&);
173  bool inDoubleInterval(const std::vector<double>&, const float) const;
174  bool inUintInterval(const std::vector<unsigned int>&, const unsigned int, const unsigned int = 999) const;
175 
180 
181  void calculateAPE();
182 
183  // ----------member data ---------------------------
185  std::map<unsigned int, TrackerSectorStruct> m_tkSector_;
187 
190 
191  std::map<unsigned int, std::pair<double, double> > m_resErrBins_;
192  std::map<unsigned int, ReducedTrackerTreeVariables> m_tkTreeVar_;
193 
194  std::map<std::string, std::vector<double> > m_hitSelection_;
195  std::map<std::string, std::vector<unsigned int> > m_hitSelectionUInt_;
196 
197  bool trackCut_;
198 
199  const unsigned int maxTracksPerEvent_;
200  const unsigned int minGoodHitsPerTrack_;
201 
202  const bool analyzerMode_;
203 
204  const bool calculateApe_;
205 
207 };
208 
209 //
210 // constants, enums and typedefs
211 //
212 
213 //
214 // static data member definitions
215 //
216 
217 //
218 // constructors and destructor
219 //
221  : parameterSet_(iConfig),
222  tjTagToken_(
223  consumes<TrajTrackAssociationCollection>(parameterSet_.getParameter<edm::InputTag>("tjTkAssociationMapTag"))),
224  offlinebeamSpot_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
225  trackCut_(false),
226  maxTracksPerEvent_(parameterSet_.getParameter<unsigned int>("maxTracksPerEvent")),
227  minGoodHitsPerTrack_(parameterSet_.getParameter<unsigned int>("minGoodHitsPerTrack")),
228  analyzerMode_(parameterSet_.getParameter<bool>("analyzerMode")),
229  calculateApe_(parameterSet_.getParameter<bool>("calculateApe")) {
231 }
232 
234 
235 //
236 // member functions
237 //
238 
239 // -----------------------------------------------------------------------------------------------------------
240 
242  TFile* tkTreeFile(TFile::Open((parameterSet_.getParameter<std::string>("TrackerTreeFile")).c_str()));
243  if (tkTreeFile) {
244  edm::LogInfo("SectorBuilder") << "TrackerTreeFile OK";
245  } else {
246  edm::LogError("SectorBuilder") << "TrackerTreeFile not found";
247  return;
248  }
249  TTree* tkTree(nullptr);
250  tkTreeFile->GetObject("TrackerTreeGenerator/TrackerTree/TrackerTree", tkTree);
251  if (tkTree) {
252  edm::LogInfo("SectorBuilder") << "TrackerTree OK";
253  } else {
254  edm::LogError("SectorBuilder") << "TrackerTree not found in file";
255  return;
256  }
257  unsigned int rawId(999), subdetId(999), layer(999), side(999), half(999), rod(999), ring(999), petal(999), blade(999),
258  panel(999), outerInner(999), module(999), nStrips(999);
259  bool isDoubleSide(false), isRPhi(false), isStereo(false);
260  int uDirection(999), vDirection(999), wDirection(999);
261  float posR(999.F), posPhi(999.F), posEta(999.F), posX(999.F), posY(999.F), posZ(999.F);
262 
263  tkTree->SetBranchAddress("RawId", &rawId);
264  tkTree->SetBranchAddress("SubdetId", &subdetId);
265  tkTree->SetBranchAddress("Layer", &layer);
266  tkTree->SetBranchAddress("Side", &side);
267  tkTree->SetBranchAddress("Half", &half);
268  tkTree->SetBranchAddress("Rod", &rod);
269  tkTree->SetBranchAddress("Ring", &ring);
270  tkTree->SetBranchAddress("Petal", &petal);
271  tkTree->SetBranchAddress("Blade", &blade);
272  tkTree->SetBranchAddress("Panel", &panel);
273  tkTree->SetBranchAddress("OuterInner", &outerInner);
274  tkTree->SetBranchAddress("Module", &module);
275  tkTree->SetBranchAddress("NStrips", &nStrips);
276  tkTree->SetBranchAddress("IsDoubleSide", &isDoubleSide);
277  tkTree->SetBranchAddress("IsRPhi", &isRPhi);
278  tkTree->SetBranchAddress("IsStereo", &isStereo);
279  tkTree->SetBranchAddress("UDirection", &uDirection);
280  tkTree->SetBranchAddress("VDirection", &vDirection);
281  tkTree->SetBranchAddress("WDirection", &wDirection);
282  tkTree->SetBranchAddress("PosR", &posR);
283  tkTree->SetBranchAddress("PosPhi", &posPhi);
284  tkTree->SetBranchAddress("PosEta", &posEta);
285  tkTree->SetBranchAddress("PosX", &posX);
286  tkTree->SetBranchAddress("PosY", &posY);
287  tkTree->SetBranchAddress("PosZ", &posZ);
288 
289  int nModules(tkTree->GetEntries());
290  TrackerSectorStruct allSectors;
291 
292  //Loop over all Sectors
293  unsigned int sectorCounter(0);
294  std::vector<edm::ParameterSet> v_sectorDef(parameterSet_.getParameter<std::vector<edm::ParameterSet> >("Sectors"));
295  edm::LogInfo("SectorBuilder") << "There are " << v_sectorDef.size() << " Sectors definded";
296  for (auto const& parSet : v_sectorDef) {
297  ++sectorCounter;
298  const std::string& sectorName(parSet.getParameter<std::string>("name"));
299  std::vector<unsigned int> v_rawId(parSet.getParameter<std::vector<unsigned int> >("rawId")),
300  v_subdetId(parSet.getParameter<std::vector<unsigned int> >("subdetId")),
301  v_layer(parSet.getParameter<std::vector<unsigned int> >("layer")),
302  v_side(parSet.getParameter<std::vector<unsigned int> >("side")),
303  v_half(parSet.getParameter<std::vector<unsigned int> >("half")),
304  v_rod(parSet.getParameter<std::vector<unsigned int> >("rod")),
305  v_ring(parSet.getParameter<std::vector<unsigned int> >("ring")),
306  v_petal(parSet.getParameter<std::vector<unsigned int> >("petal")),
307  v_blade(parSet.getParameter<std::vector<unsigned int> >("blade")),
308  v_panel(parSet.getParameter<std::vector<unsigned int> >("panel")),
309  v_outerInner(parSet.getParameter<std::vector<unsigned int> >("outerInner")),
310  v_module(parSet.getParameter<std::vector<unsigned int> >("module")),
311  v_nStrips(parSet.getParameter<std::vector<unsigned int> >("nStrips")),
312  v_isDoubleSide(parSet.getParameter<std::vector<unsigned int> >("isDoubleSide")),
313  v_isRPhi(parSet.getParameter<std::vector<unsigned int> >("isRPhi")),
314  v_isStereo(parSet.getParameter<std::vector<unsigned int> >("isStereo"));
315  std::vector<int> v_uDirection(parSet.getParameter<std::vector<int> >("uDirection")),
316  v_vDirection(parSet.getParameter<std::vector<int> >("vDirection")),
317  v_wDirection(parSet.getParameter<std::vector<int> >("wDirection"));
318  std::vector<double> v_posR(parSet.getParameter<std::vector<double> >("posR")),
319  v_posPhi(parSet.getParameter<std::vector<double> >("posPhi")),
320  v_posEta(parSet.getParameter<std::vector<double> >("posEta")),
321  v_posX(parSet.getParameter<std::vector<double> >("posX")),
322  v_posY(parSet.getParameter<std::vector<double> >("posY")),
323  v_posZ(parSet.getParameter<std::vector<double> >("posZ"));
324 
325  if (!this->checkIntervalsForSectors(sectorCounter, v_posR) ||
326  !this->checkIntervalsForSectors(sectorCounter, v_posPhi) ||
327  !this->checkIntervalsForSectors(sectorCounter, v_posEta) ||
328  !this->checkIntervalsForSectors(sectorCounter, v_posX) ||
329  !this->checkIntervalsForSectors(sectorCounter, v_posY) ||
330  !this->checkIntervalsForSectors(sectorCounter, v_posZ))
331  continue;
332 
333  TrackerSectorStruct tkSector;
334  tkSector.name = sectorName;
335 
336  ReducedTrackerTreeVariables tkTreeVar;
337 
338  //Loop over all Modules
339  for (int module = 0; module < nModules; ++module) {
340  tkTree->GetEntry(module);
341 
342  if (sectorCounter == 1) {
343  tkTreeVar.subdetId = subdetId;
344  tkTreeVar.nStrips = nStrips;
345  tkTreeVar.uDirection = uDirection;
346  tkTreeVar.vDirection = vDirection;
347  tkTreeVar.wDirection = wDirection;
348  m_tkTreeVar_[rawId] = tkTreeVar;
349  }
350 
351  if (!this->checkModuleIds(rawId, v_rawId))
352  continue;
353  if (!this->checkModuleIds(subdetId, v_subdetId))
354  continue;
355  if (!this->checkModuleIds(layer, v_layer))
356  continue;
357  if (!this->checkModuleIds(side, v_side))
358  continue;
359  if (!this->checkModuleIds(half, v_half))
360  continue;
361  if (!this->checkModuleIds(rod, v_rod))
362  continue;
363  if (!this->checkModuleIds(ring, v_ring))
364  continue;
365  if (!this->checkModuleIds(petal, v_petal))
366  continue;
367  if (!this->checkModuleIds(blade, v_blade))
368  continue;
369  if (!this->checkModuleIds(panel, v_panel))
370  continue;
371  if (!this->checkModuleIds(outerInner, v_outerInner))
372  continue;
373  if (!this->checkModuleIds(module, v_module))
374  continue;
375  if (!this->checkModuleIds(nStrips, v_nStrips))
376  continue;
377  if (!this->checkModuleBools(isDoubleSide, v_isDoubleSide))
378  continue;
379  if (!this->checkModuleBools(isRPhi, v_isRPhi))
380  continue;
381  if (!this->checkModuleBools(isStereo, v_isStereo))
382  continue;
383  if (!this->checkModuleDirections(uDirection, v_uDirection))
384  continue;
385  if (!this->checkModuleDirections(vDirection, v_vDirection))
386  continue;
387  if (!this->checkModuleDirections(wDirection, v_wDirection))
388  continue;
389  if (!this->checkModulePositions(posR, v_posR))
390  continue;
391  if (!this->checkModulePositions(posPhi, v_posPhi))
392  continue;
393  if (!this->checkModulePositions(posEta, v_posEta))
394  continue;
395  if (!this->checkModulePositions(posX, v_posX))
396  continue;
397  if (!this->checkModulePositions(posY, v_posY))
398  continue;
399  if (!this->checkModulePositions(posZ, v_posZ))
400  continue;
401 
402  tkSector.v_rawId.push_back(rawId);
403  bool moduleSelected(false);
404  for (auto const& i_rawId : allSectors.v_rawId) {
405  if (rawId == i_rawId)
406  moduleSelected = true;
407  }
408  if (!moduleSelected)
409  allSectors.v_rawId.push_back(rawId);
410  }
411 
412  bool isPixel(false);
413  bool isStrip(false);
414  for (auto const& i_rawId : tkSector.v_rawId) {
415  switch (m_tkTreeVar_[i_rawId].subdetId) {
418  isPixel = true;
419  break;
424  isStrip = true;
425  break;
426  }
427  }
428 
429  if (isPixel && isStrip) {
430  edm::LogError("SectorBuilder")
431  << "Incorrect Sector Definition: there are pixel and strip modules within one sector"
432  << "\n... sector selection is not applied, sector " << sectorCounter << " is not built";
433  continue;
434  }
435  tkSector.isPixel = isPixel;
436 
437  m_tkSector_[sectorCounter] = tkSector;
438  edm::LogInfo("SectorBuilder") << "There are " << tkSector.v_rawId.size() << " Modules in Sector " << sectorCounter;
439  }
440  this->statistics(allSectors, nModules);
441  return;
442 }
443 
444 // -----------------------------------------------------------------------------------------------------------
445 
446 bool ApeEstimator::checkIntervalsForSectors(const unsigned int sectorCounter, const std::vector<double>& v_id) const {
447  if (v_id.empty())
448  return true;
449  if (v_id.size() % 2 == 1) {
450  edm::LogError("SectorBuilder")
451  << "Incorrect Sector Definition: Position Vectors need even number of arguments (Intervals)"
452  << "\n... sector selection is not applied, sector " << sectorCounter << " is not built";
453  return false;
454  }
455  int entry(0);
456  double intervalBegin(999.);
457  for (auto const& i_id : v_id) {
458  ++entry;
459  if (entry % 2 == 1)
460  intervalBegin = i_id;
461  if (entry % 2 == 0 && intervalBegin > i_id) {
462  edm::LogError("SectorBuilder") << "Incorrect Sector Definition (Position Vector Intervals): \t" << intervalBegin
463  << " is bigger than " << i_id << " but is expected to be smaller"
464  << "\n... sector selection is not applied, sector " << sectorCounter
465  << " is not built";
466  return false;
467  }
468  }
469  return true;
470 }
471 
472 bool ApeEstimator::checkModuleIds(const unsigned int id, const std::vector<unsigned int>& v_id) const {
473  if (v_id.empty())
474  return true;
475  for (auto const& i_id : v_id) {
476  if (id == i_id)
477  return true;
478  }
479  return false;
480 }
481 
482 bool ApeEstimator::checkModuleBools(const bool id, const std::vector<unsigned int>& v_id) const {
483  if (v_id.empty())
484  return true;
485  for (auto const& i_id : v_id) {
486  if (1 == i_id && id)
487  return true;
488  if (2 == i_id && !id)
489  return true;
490  }
491  return false;
492 }
493 
494 bool ApeEstimator::checkModuleDirections(const int id, const std::vector<int>& v_id) const {
495  if (v_id.empty())
496  return true;
497  for (auto const& i_id : v_id) {
498  if (id == i_id)
499  return true;
500  }
501  return false;
502 }
503 
504 bool ApeEstimator::checkModulePositions(const float id, const std::vector<double>& v_id) const {
505  if (v_id.empty())
506  return true;
507  int entry(0);
508  double intervalBegin(999.);
509  for (auto const& i_id : v_id) {
510  ++entry;
511  if (entry % 2 == 1)
512  intervalBegin = i_id;
513  if (entry % 2 == 0 && id >= intervalBegin && id < i_id)
514  return true;
515  }
516  return false;
517 }
518 
519 void ApeEstimator::statistics(const TrackerSectorStruct& allSectors, const int nModules) const {
520  bool commonModules(false);
521  for (std::map<unsigned int, TrackerSectorStruct>::const_iterator i_sector = m_tkSector_.begin();
522  i_sector != m_tkSector_.end();
523  ++i_sector) {
524  std::map<unsigned int, TrackerSectorStruct>::const_iterator i_sector2(i_sector);
525  for (++i_sector2; i_sector2 != m_tkSector_.end(); ++i_sector2) {
526  unsigned int nCommonModules(0);
527  for (auto const& i_module : (*i_sector).second.v_rawId) {
528  for (auto const& i_module2 : (*i_sector2).second.v_rawId) {
529  if (i_module2 == i_module)
530  ++nCommonModules;
531  }
532  }
533  if (nCommonModules == 0)
534  ; //edm::LogInfo("SectorBuilder")<<"Sector "<<(*i_sector).first<<" and Sector "<<(*i_sector2).first<< " have ZERO Modules in common";
535  else {
536  edm::LogError("SectorBuilder") << "Sector " << (*i_sector).first << " and Sector " << (*i_sector2).first
537  << " have " << nCommonModules << " Modules in common";
538  commonModules = true;
539  }
540  }
541  }
542  if (static_cast<int>(allSectors.v_rawId.size()) == nModules)
543  edm::LogInfo("SectorBuilder") << "ALL Tracker Modules are contained in the Sectors";
544  else
545  edm::LogWarning("SectorBuilder") << "There are " << allSectors.v_rawId.size() << " Modules in all Sectors"
546  << " out of " << nModules << " Tracker Modules";
547  if (!commonModules)
548  edm::LogInfo("SectorBuilder") << "There are ZERO modules associated to different sectors, no ambiguities exist";
549  else
550  edm::LogError("SectorBuilder")
551  << "There are modules associated to different sectors, APE value cannot be assigned reasonably";
552 }
553 
554 // -----------------------------------------------------------------------------------------------------------
555 
557  std::vector<double> v_residualErrorBinning(parameterSet_.getParameter<std::vector<double> >("residualErrorBinning"));
558  if (v_residualErrorBinning.size() == 1) {
559  edm::LogError("ResidualErrorBinning") << "Incorrect selection of Residual Error Bins (used for APE calculation): \t"
560  << "Only one argument passed, so no interval is specified"
561  << "\n... delete whole bin selection"; //m_resErrBins_ remains empty
562  return;
563  }
564  double xMin(0.), xMax(0.);
565  unsigned int binCounter(-1);
566  for (auto const& i_binning : v_residualErrorBinning) {
567  ++binCounter;
568  if (binCounter == 0) {
569  xMin = i_binning;
570  continue;
571  }
572  xMax = i_binning;
573  if (xMax <= xMin) {
574  edm::LogError("ResidualErrorBinning")
575  << "Incorrect selection of Residual Error Bins (used for APE calculation): \t" << xMin << " is bigger than "
576  << xMax << " but is expected to be smaller"
577  << "\n... delete whole bin selection";
578  m_resErrBins_.clear();
579  return;
580  }
581  m_resErrBins_[binCounter].first = xMin;
582  m_resErrBins_[binCounter].second = xMax;
583  xMin = xMax;
584  }
585  edm::LogInfo("ResidualErrorBinning")
586  << m_resErrBins_.size() << " Intervals of residual errors used for separate APE calculation sucessfully set";
587 }
588 
589 // -----------------------------------------------------------------------------------------------------------
590 
592  std::vector<unsigned int> v_errHists(parameterSet_.getParameter<std::vector<unsigned int> >("vErrHists"));
593  for (std::vector<unsigned int>::iterator i_errHists = v_errHists.begin(); i_errHists != v_errHists.end();
594  ++i_errHists) {
595  for (std::vector<unsigned int>::iterator i_errHists2 = i_errHists; i_errHists2 != v_errHists.end();) {
596  ++i_errHists2;
597  if (*i_errHists == *i_errHists2) {
598  edm::LogError("BookSectorHists") << "Value of vErrHists in config exists twice: " << *i_errHists
599  << "\n... delete one of both";
600  v_errHists.erase(i_errHists2);
601  }
602  }
603  }
604 
605  for (auto& i_sector : m_tkSector_) {
606  bool zoomHists(parameterSet_.getParameter<bool>("zoomHists"));
607 
608  double widthMax = zoomHists ? 20. : 200.;
609  double chargePixelMax = zoomHists ? 200000. : 2000000.;
610  double chargeStripMax = zoomHists ? 1000. : 10000.;
611  double sOverNMax = zoomHists ? 200. : 2000.;
612  double logClusterProbMin = zoomHists ? -5. : -15.;
613 
614  double resXAbsMax = zoomHists ? 0.5 : 5.;
615  double norResXAbsMax = zoomHists ? 10. : 50.;
616  double probXMin = zoomHists ? -0.01 : -0.1;
617  double probXMax = zoomHists ? 0.11 : 1.1;
618  double sigmaXMin = zoomHists ? 0. : -0.05;
619  double sigmaXMax = zoomHists ? 0.02 : 1.;
620  double sigmaX2Max = sigmaXMax * sigmaXMax;
621  double sigmaXHitMax = zoomHists ? 0.02 : 1.;
622  double phiSensXMax = zoomHists ? 31. : 93.;
623 
624  double norChi2Max = zoomHists ? 5. : 1000.;
625  double d0Max = zoomHists ? 0.02 : 40.; // cosmics: 100.|100.
626  double dzMax = zoomHists ? 15. : 100.; // cosmics: 200.|600.
627  double pMax = zoomHists ? 200. : 2000.;
628  double invPMax = zoomHists ? 0.05 : 10.; //begins at 20GeV, 0.1GeV
629 
631  if (!fileService) {
632  throw edm::Exception(edm::errors::Configuration, "TFileService is not registered in cfg file");
633  }
634 
635  std::stringstream sector;
636  sector << "Sector_" << i_sector.first;
637  TFileDirectory secDir = fileService->mkdir(sector.str());
638 
639  // Dummy histo containing the sector name as title
640  i_sector.second.Name = secDir.make<TH1F>("z_name", i_sector.second.name.c_str(), 1, 0, 1);
641 
642  // Do not book histos for empty sectors
643  if (i_sector.second.v_rawId.empty()) {
644  continue;
645  }
646  // Set parameters for correlationHists
647  i_sector.second.setCorrHistParams(&secDir, norResXAbsMax, sigmaXHitMax, sigmaXMax);
648 
649  // Book pixel or strip specific hists
650  const bool pixelSector(i_sector.second.isPixel);
651 
652  // Cluster Parameters
653  i_sector.second.m_correlationHistsX["WidthX"] = i_sector.second.bookCorrHistsX("WidthX",
654  "cluster width",
655  "w_{cl,x}",
656  "[# channels]",
657  static_cast<int>(widthMax),
658  static_cast<int>(widthMax),
659  0.,
660  widthMax,
661  "nph");
662  i_sector.second.m_correlationHistsX["BaryStripX"] = i_sector.second.bookCorrHistsX(
663  "BaryStripX", "barycenter of cluster charge", "b_{cl,x}", "[# channels]", 800, 100, -10., 790., "nph");
664 
665  if (pixelSector) {
666  i_sector.second.m_correlationHistsY["WidthY"] = i_sector.second.bookCorrHistsY("WidthY",
667  "cluster width",
668  "w_{cl,y}",
669  "[# channels]",
670  static_cast<int>(widthMax),
671  static_cast<int>(widthMax),
672  0.,
673  widthMax,
674  "nph");
675  i_sector.second.m_correlationHistsY["BaryStripY"] = i_sector.second.bookCorrHistsY(
676  "BaryStripY", "barycenter of cluster charge", "b_{cl,y}", "[# channels]", 800, 100, -10., 790., "nph");
677 
678  i_sector.second.m_correlationHistsX["ChargePixel"] = i_sector.second.bookCorrHistsX(
679  "ChargePixel", "cluster charge", "c_{cl}", "[e]", 100, 50, 0., chargePixelMax, "nph");
680  i_sector.second.m_correlationHistsX["ClusterProbXY"] = i_sector.second.bookCorrHistsX(
681  "ClusterProbXY", "cluster probability xy", "prob_{cl,xy}", "", 100, 50, 0., 1., "nph");
682  i_sector.second.m_correlationHistsX["ClusterProbQ"] = i_sector.second.bookCorrHistsX(
683  "ClusterProbQ", "cluster probability q", "prob_{cl,q}", "", 100, 50, 0., 1., "nph");
684  i_sector.second.m_correlationHistsX["ClusterProbXYQ"] = i_sector.second.bookCorrHistsX(
685  "ClusterProbXYQ", "cluster probability xyq", "prob_{cl,xyq}", "", 100, 50, 0., 1., "nph");
686  i_sector.second.m_correlationHistsX["LogClusterProb"] = i_sector.second.bookCorrHistsX(
687  "LogClusterProb", "cluster probability xy", "log(prob_{cl,xy})", "", 60, 30, logClusterProbMin, 0., "nph");
688  i_sector.second.m_correlationHistsX["IsOnEdge"] =
689  i_sector.second.bookCorrHistsX("IsOnEdge", "IsOnEdge", "isOnEdge", "", 2, 2, 0, 2, "nph");
690  i_sector.second.m_correlationHistsX["HasBadPixels"] =
691  i_sector.second.bookCorrHistsX("HasBadPixels", "HasBadPixels", "hasBadPixels", "", 2, 2, 0, 2, "nph");
692  i_sector.second.m_correlationHistsX["SpansTwoRoc"] =
693  i_sector.second.bookCorrHistsX("SpansTwoRoc", "SpansTwoRoc", "spansTwoRoc", "", 2, 2, 0, 2, "nph");
694  i_sector.second.m_correlationHistsX["QBin"] =
695  i_sector.second.bookCorrHistsX("QBin", "q bin", "q bin", "", 8, 8, 0, 8, "nph");
696 
697  i_sector.second.m_correlationHistsY["ChargePixel"] = i_sector.second.bookCorrHistsY(
698  "ChargePixel", "cluster charge", "c_{cl}", "[e]", 100, 50, 0., chargePixelMax, "nph");
699  i_sector.second.m_correlationHistsY["ClusterProbXY"] = i_sector.second.bookCorrHistsY(
700  "ClusterProbXY", "cluster probability xy", "prob_{cl,xy}", "", 100, 50, 0., 1., "nph");
701  i_sector.second.m_correlationHistsY["ClusterProbQ"] = i_sector.second.bookCorrHistsY(
702  "ClusterProbQ", "cluster probability q", "prob_{cl,q}", "", 100, 50, 0., 1., "nph");
703  i_sector.second.m_correlationHistsY["ClusterProbXYQ"] = i_sector.second.bookCorrHistsY(
704  "ClusterProbXYQ", "cluster probability xyq", "prob_{cl,xyq}", "", 100, 50, 0., 1., "nph");
705  i_sector.second.m_correlationHistsY["LogClusterProb"] = i_sector.second.bookCorrHistsY(
706  "LogClusterProb", "cluster probability xy", "log(prob_{cl,xy})", "", 60, 30, logClusterProbMin, 0., "nph");
707  i_sector.second.m_correlationHistsY["IsOnEdge"] =
708  i_sector.second.bookCorrHistsY("IsOnEdge", "IsOnEdge", "isOnEdge", "", 2, 2, 0, 2, "nph");
709  i_sector.second.m_correlationHistsY["HasBadPixels"] =
710  i_sector.second.bookCorrHistsY("HasBadPixels", "HasBadPixels", "hasBadPixels", "", 2, 2, 0, 2, "nph");
711  i_sector.second.m_correlationHistsY["SpansTwoRoc"] =
712  i_sector.second.bookCorrHistsY("SpansTwoRoc", "SpansTwoRoc", "spansTwoRoc", "", 2, 2, 0, 2, "nph");
713  i_sector.second.m_correlationHistsY["QBin"] =
714  i_sector.second.bookCorrHistsY("QBin", "q bin", "q bin", "", 8, 8, 0, 8, "nph");
715  }
716 
717  else {
718  i_sector.second.m_correlationHistsX["ChargeStrip"] = i_sector.second.bookCorrHistsX(
719  "ChargeStrip", "cluster charge", "c_{cl}", "[APV counts]", 100, 50, 0., chargeStripMax, "nph");
720  i_sector.second.m_correlationHistsX["MaxStrip"] = i_sector.second.bookCorrHistsX(
721  "MaxStrip", "strip with max. charge", "n_{cl,max}", "[# strips]", 800, 800, -10., 790., "npht");
722  i_sector.second.m_correlationHistsX["MaxCharge"] = i_sector.second.bookCorrHistsX(
723  "MaxCharge", "charge of strip with max. charge", "c_{cl,max}", "[APV counts]", 300, 75, -10., 290., "nph");
724  i_sector.second.m_correlationHistsX["MaxIndex"] = i_sector.second.bookCorrHistsX(
725  "MaxIndex", "cluster-index of strip with max. charge", "i_{cl,max}", "[# strips]", 10, 10, 0., 10., "nph");
726  i_sector.second.m_correlationHistsX["ChargeOnEdges"] =
727  i_sector.second.bookCorrHistsX("ChargeOnEdges",
728  "fraction of charge on edge strips",
729  "(c_{st,L}+c_{st,R})/c_{cl}",
730  "",
731  60,
732  60,
733  -0.1,
734  1.1,
735  "nph");
736  i_sector.second.m_correlationHistsX["ChargeAsymmetry"] =
737  i_sector.second.bookCorrHistsX("ChargeAsymmetry",
738  "asymmetry of charge on edge strips",
739  "(c_{st,L}-c_{st,R})/c_{cl}",
740  "",
741  110,
742  55,
743  -1.1,
744  1.1,
745  "nph");
746  i_sector.second.m_correlationHistsX["ChargeLRplus"] =
747  i_sector.second.bookCorrHistsX("ChargeLRplus",
748  "fraction of charge not on maxStrip",
749  "(c_{cl,L}+c_{cl,R})/c_{cl}",
750  "",
751  60,
752  60,
753  -0.1,
754  1.1,
755  "nph");
756  i_sector.second.m_correlationHistsX["ChargeLRminus"] =
757  i_sector.second.bookCorrHistsX("ChargeLRminus",
758  "asymmetry of charge L and R of maxStrip",
759  "(c_{cl,L}-c_{cl,R})/c_{cl}",
760  "",
761  110,
762  55,
763  -1.1,
764  1.1,
765  "nph");
766  i_sector.second.m_correlationHistsX["SOverN"] =
767  i_sector.second.bookCorrHistsX("SOverN", "signal over noise", "s/N", "", 100, 50, 0, sOverNMax, "nph");
768  i_sector.second.m_correlationHistsX["WidthProj"] = i_sector.second.bookCorrHistsX(
769  "WidthProj", "projected width", "w_{p}", "[# strips]", 200, 20, 0., widthMax, "nph");
770  i_sector.second.m_correlationHistsX["WidthDiff"] = i_sector.second.bookCorrHistsX("WidthDiff",
771  "width difference",
772  "w_{p} - w_{cl}",
773  "[# strips]",
774  200,
775  20,
776  -widthMax / 2.,
777  widthMax / 2.,
778  "nph");
779 
780  i_sector.second.WidthVsWidthProjected = secDir.make<TH2F>("h2_widthVsWidthProj",
781  "w_{cl} vs. w_{p};w_{p} [# strips];w_{cl} [# strips]",
782  static_cast<int>(widthMax),
783  0,
784  widthMax,
785  static_cast<int>(widthMax),
786  0,
787  widthMax);
788  i_sector.second.PWidthVsWidthProjected =
789  secDir.make<TProfile>("p_widthVsWidthProj",
790  "w_{cl} vs. w_{p};w_{p} [# strips];w_{cl} [# strips]",
791  static_cast<int>(widthMax),
792  0,
793  widthMax);
794 
795  i_sector.second.WidthDiffVsMaxStrip =
796  secDir.make<TH2F>("h2_widthDiffVsMaxStrip",
797  "(w_{p} - w_{cl}) vs. n_{cl,max};n_{cl,max};w_{p} - w_{cl} [# strips]",
798  800,
799  -10.,
800  790.,
801  static_cast<int>(widthMax),
802  -widthMax / 2.,
803  widthMax / 2.);
804  i_sector.second.PWidthDiffVsMaxStrip =
805  secDir.make<TProfile>("p_widthDiffVsMaxStrip",
806  "(w_{p} - w_{cl}) vs. n_{cl,max};n_{cl,max};w_{p} - w_{cl} [# strips]",
807  800,
808  -10.,
809  790.);
810 
811  i_sector.second.WidthDiffVsSigmaXHit =
812  secDir.make<TH2F>("h2_widthDiffVsSigmaXHit",
813  "(w_{p} - w_{cl}) vs. #sigma_{hit,x};#sigma_{hit,x} [cm];w_{p} - w_{cl} [# strips]",
814  100,
815  0.,
816  sigmaXMax,
817  100,
818  -10.,
819  10.);
820  i_sector.second.PWidthDiffVsSigmaXHit =
821  secDir.make<TProfile>("p_widthDiffVsSigmaXHit",
822  "(w_{p} - w_{cl}) vs. #sigma_{hit,x};#sigma_{hit,x} [cm];w_{p} - w_{cl} [# strips]",
823  100,
824  0.,
825  sigmaXMax);
826 
827  i_sector.second.WidthVsPhiSensX =
828  secDir.make<TH2F>("h2_widthVsPhiSensX",
829  "w_{cl} vs. #phi_{module,x};#phi_{module,x} [ ^{o}];w_{cl} [# strips]",
830  93,
831  -93,
832  93,
833  static_cast<int>(widthMax),
834  0,
835  widthMax);
836  i_sector.second.PWidthVsPhiSensX = secDir.make<TProfile>(
837  "p_widthVsPhiSensX", "w_{cl} vs. #phi_{module,x};#phi_{module,x} [ ^{o}];w_{cl} [# strips]", 93, -93, 93);
838  }
839 
840  // Hit Parameters (transform errors and residuals from [cm] in [mum])
841  i_sector.second.m_correlationHistsX["SigmaXHit"] = i_sector.second.bookCorrHistsX(
842  "SigmaXHit", "hit error", "#sigma_{hit,x}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
843  i_sector.second.m_correlationHistsX["SigmaXTrk"] = i_sector.second.bookCorrHistsX(
844  "SigmaXTrk", "track error", "#sigma_{trk,x}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
845  i_sector.second.m_correlationHistsX["SigmaX"] = i_sector.second.bookCorrHistsX(
846  "SigmaX", "residual error", "#sigma_{r,x}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
847  i_sector.second.m_correlationHistsX["PhiSens"] = i_sector.second.bookCorrHistsX(
848  "PhiSens", "track angle on sensor", "#phi_{module}", "[ ^{o}]", 96, 48, -3, 93, "nphtr");
849  i_sector.second.m_correlationHistsX["PhiSensX"] = i_sector.second.bookCorrHistsX(
850  "PhiSensX", "track angle on sensor", "#phi_{module,x}", "[ ^{o}]", 186, 93, -phiSensXMax, phiSensXMax, "nphtr");
851  i_sector.second.m_correlationHistsX["PhiSensY"] = i_sector.second.bookCorrHistsX(
852  "PhiSensY", "track angle on sensor", "#phi_{module,y}", "[ ^{o}]", 186, 93, -93, 93, "nphtr");
853 
854  i_sector.second.XHit = secDir.make<TH1F>("h_XHit", " hit measurement x_{hit};x_{hit} [cm];# hits", 100, -20, 20);
855  i_sector.second.XTrk = secDir.make<TH1F>("h_XTrk", "track prediction x_{trk};x_{trk} [cm];# hits", 100, -20, 20);
856  i_sector.second.SigmaX2 =
857  secDir.make<TH1F>("h_SigmaX2",
858  "squared residual error #sigma_{r,x}^{2};#sigma_{r,x}^{2} [#mum^{2}];# hits",
859  105,
860  sigmaXMin * 10000.,
861  sigmaX2Max * 10000. * 10000.); //no mistake !
862  i_sector.second.ResX = secDir.make<TH1F>(
863  "h_ResX", "residual r_{x};x_{trk}-x_{hit} [#mum];# hits", 100, -resXAbsMax * 10000., resXAbsMax * 10000.);
864  i_sector.second.NorResX =
865  secDir.make<TH1F>("h_NorResX",
866  "normalized residual r_{x}/#sigma_{r,x};(x_{trk}-x_{hit})/#sigma_{r,x};# hits",
867  100,
868  -norResXAbsMax,
869  norResXAbsMax);
870  i_sector.second.ProbX = secDir.make<TH1F>(
871  "h_ProbX", "residual probability;prob(r_{x}^{2}/#sigma_{r,x}^{2},1);# hits", 60, probXMin, probXMax);
872 
873  i_sector.second.PhiSensXVsBarycentreX =
874  secDir.make<TH2F>("h2_phiSensXVsBarycentreX",
875  "#phi_{module,x} vs. b_{cl,x};b_{cl,x} [# channels];#phi_{module,x} [ ^{o}]",
876  200,
877  -10.,
878  790.,
879  93,
880  -93,
881  93);
882  i_sector.second.PPhiSensXVsBarycentreX =
883  secDir.make<TProfile>("p_phiSensXVsBarycentreX",
884  "#phi_{module,x} vs. b_{cl,x};b_{cl,x} [# channels];#phi_{module,x} [ ^{o}]",
885  200,
886  -10.,
887  790.);
888 
889  if (pixelSector) {
890  i_sector.second.m_correlationHistsY["SigmaYHit"] = i_sector.second.bookCorrHistsY(
891  "SigmaYHit", "hit error", "#sigma_{hit,y}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
892  i_sector.second.m_correlationHistsY["SigmaYTrk"] = i_sector.second.bookCorrHistsY(
893  "SigmaYTrk", "track error", "#sigma_{trk,y}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
894  i_sector.second.m_correlationHistsY["SigmaY"] = i_sector.second.bookCorrHistsY(
895  "SigmaY", "residual error", "#sigma_{r,y}", "[#mum]", 105, 20, sigmaXMin * 10000., sigmaXMax * 10000., "np");
896  i_sector.second.m_correlationHistsY["PhiSens"] = i_sector.second.bookCorrHistsY(
897  "PhiSens", "track angle on sensor", "#phi_{module}", "[ ^{o}]", 96, 48, -3, 93, "nphtr");
898  i_sector.second.m_correlationHistsY["PhiSensX"] = i_sector.second.bookCorrHistsY("PhiSensX",
899  "track angle on sensor",
900  "#phi_{module,x}",
901  "[ ^{o}]",
902  186,
903  93,
904  -phiSensXMax,
905  phiSensXMax,
906  "nphtr");
907  i_sector.second.m_correlationHistsY["PhiSensY"] = i_sector.second.bookCorrHistsY(
908  "PhiSensY", "track angle on sensor", "#phi_{module,y}", "[ ^{o}]", 186, 93, -93, 93, "nphtr");
909 
910  i_sector.second.YHit = secDir.make<TH1F>("h_YHit", " hit measurement y_{hit};y_{hit} [cm];# hits", 100, -20, 20);
911  i_sector.second.YTrk = secDir.make<TH1F>("h_YTrk", "track prediction y_{trk};y_{trk} [cm];# hits", 100, -20, 20);
912  i_sector.second.SigmaY2 =
913  secDir.make<TH1F>("h_SigmaY2",
914  "squared residual error #sigma_{r,y}^{2};#sigma_{r,y}^{2} [#mum^{2}];# hits",
915  105,
916  sigmaXMin * 10000.,
917  sigmaX2Max * 10000. * 10000.); //no mistake !
918  i_sector.second.ResY = secDir.make<TH1F>(
919  "h_ResY", "residual r_{y};y_{trk}-y_{hit} [#mum];# hits", 100, -resXAbsMax * 10000., resXAbsMax * 10000.);
920  i_sector.second.NorResY =
921  secDir.make<TH1F>("h_NorResY",
922  "normalized residual r_{y}/#sigma_{r,y};(y_{trk}-y_{hit})/#sigma_{r,y};# hits",
923  100,
924  -norResXAbsMax,
925  norResXAbsMax);
926  i_sector.second.ProbY = secDir.make<TH1F>(
927  "h_ProbY", "residual probability;prob(r_{y}^{2}/#sigma_{r,y}^{2},1);# hits", 60, probXMin, probXMax);
928 
929  i_sector.second.PhiSensYVsBarycentreY =
930  secDir.make<TH2F>("h2_phiSensYVsBarycentreY",
931  "#phi_{module,y} vs. b_{cl,y};b_{cl,y} [# channels];#phi_{module,y} [ ^{o}]",
932  200,
933  -10.,
934  790.,
935  93,
936  -93,
937  93);
938  i_sector.second.PPhiSensYVsBarycentreY =
939  secDir.make<TProfile>("p_phiSensYVsBarycentreY",
940  "#phi_{module,y} vs. b_{cl,y};b_{cl,y} [# channels];#phi_{module,y} [ ^{o}]",
941  200,
942  -10.,
943  790.);
944  }
945 
946  // Track Parameters
947  i_sector.second.m_correlationHistsX["HitsValid"] =
948  i_sector.second.bookCorrHistsX("HitsValid", "# hits", "[valid]", 50, 0, 50, "npt");
949  i_sector.second.m_correlationHistsX["HitsInvalid"] =
950  i_sector.second.bookCorrHistsX("HitsInvalid", "# hits", "[invalid]", 20, 0, 20, "npt");
951  i_sector.second.m_correlationHistsX["Hits2D"] =
952  i_sector.second.bookCorrHistsX("Hits2D", "# hits", "[2D]", 20, 0, 20, "npt");
953  i_sector.second.m_correlationHistsX["LayersMissed"] =
954  i_sector.second.bookCorrHistsX("LayersMissed", "# layers", "[missed]", 10, 0, 10, "npt");
955  i_sector.second.m_correlationHistsX["HitsPixel"] =
956  i_sector.second.bookCorrHistsX("HitsPixel", "# hits", "[pixel]", 10, 0, 10, "npt");
957  i_sector.second.m_correlationHistsX["HitsStrip"] =
958  i_sector.second.bookCorrHistsX("HitsStrip", "# hits", "[strip]", 40, 0, 40, "npt");
959  i_sector.second.m_correlationHistsX["HitsGood"] =
960  i_sector.second.bookCorrHistsX("HitsGood", "# hits", "[good]", 50, 0, 50, "npt");
961  i_sector.second.m_correlationHistsX["NorChi2"] =
962  i_sector.second.bookCorrHistsX("NorChi2", "#chi^{2}/f", "", 50, 0, norChi2Max, "npr");
963  i_sector.second.m_correlationHistsX["Theta"] =
964  i_sector.second.bookCorrHistsX("Theta", "#theta", "[ ^{o}]", 40, -10, 190, "npt");
965  i_sector.second.m_correlationHistsX["Phi"] =
966  i_sector.second.bookCorrHistsX("Phi", "#phi", "[ ^{o}]", 76, -190, 190, "npt");
967  i_sector.second.m_correlationHistsX["D0Beamspot"] =
968  i_sector.second.bookCorrHistsX("D0Beamspot", "d_{0, BS}", "[cm]", 40, -d0Max, d0Max, "npt");
969  i_sector.second.m_correlationHistsX["Dz"] =
970  i_sector.second.bookCorrHistsX("Dz", "d_{z}", "[cm]", 40, -dzMax, dzMax, "npt");
971  i_sector.second.m_correlationHistsX["Pt"] =
972  i_sector.second.bookCorrHistsX("Pt", "p_{t}", "[GeV]", 50, 0, pMax, "npt");
973  i_sector.second.m_correlationHistsX["P"] = i_sector.second.bookCorrHistsX("P", "|p|", "[GeV]", 50, 0, pMax, "npt");
974  i_sector.second.m_correlationHistsX["InvP"] =
975  i_sector.second.bookCorrHistsX("InvP", "1/|p|", "[GeV^{-1}]", 25, 0, invPMax, "t");
976  i_sector.second.m_correlationHistsX["MeanAngle"] =
977  i_sector.second.bookCorrHistsX("MeanAngle", "<#phi_{module}>", "[ ^{o}]", 25, -5, 95, "npt");
978  //i_sector.second.m_correlationHistsX[""] = i_sector.second.bookCorrHistsX("","","",,,,"nphtr");
979 
980  if (pixelSector) {
981  i_sector.second.m_correlationHistsY["HitsValid"] =
982  i_sector.second.bookCorrHistsY("HitsValid", "# hits", "[valid]", 50, 0, 50, "npt");
983  i_sector.second.m_correlationHistsY["HitsInvalid"] =
984  i_sector.second.bookCorrHistsY("HitsInvalid", "# hits", "[invalid]", 20, 0, 20, "npt");
985  i_sector.second.m_correlationHistsY["Hits2D"] =
986  i_sector.second.bookCorrHistsY("Hits2D", "# hits", "[2D]", 20, 0, 20, "npt");
987  i_sector.second.m_correlationHistsY["LayersMissed"] =
988  i_sector.second.bookCorrHistsY("LayersMissed", "# layers", "[missed]", 10, 0, 10, "npt");
989  i_sector.second.m_correlationHistsY["HitsPixel"] =
990  i_sector.second.bookCorrHistsY("HitsPixel", "# hits", "[pixel]", 10, 0, 10, "npt");
991  i_sector.second.m_correlationHistsY["HitsStrip"] =
992  i_sector.second.bookCorrHistsY("HitsStrip", "# hits", "[strip]", 40, 0, 40, "npt");
993  i_sector.second.m_correlationHistsY["HitsGood"] =
994  i_sector.second.bookCorrHistsY("HitsGood", "# hits", "[good]", 50, 0, 50, "npt");
995  i_sector.second.m_correlationHistsY["NorChi2"] =
996  i_sector.second.bookCorrHistsY("NorChi2", "#chi^{2}/f", "", 50, 0, norChi2Max, "npr");
997  i_sector.second.m_correlationHistsY["Theta"] =
998  i_sector.second.bookCorrHistsY("Theta", "#theta", "[ ^{o}]", 40, -10, 190, "npt");
999  i_sector.second.m_correlationHistsY["Phi"] =
1000  i_sector.second.bookCorrHistsY("Phi", "#phi", "[ ^{o}]", 76, -190, 190, "npt");
1001  i_sector.second.m_correlationHistsY["D0Beamspot"] =
1002  i_sector.second.bookCorrHistsY("D0Beamspot", "d_{0, BS}", "[cm]", 40, -d0Max, d0Max, "npt");
1003  i_sector.second.m_correlationHistsY["Dz"] =
1004  i_sector.second.bookCorrHistsY("Dz", "d_{z}", "[cm]", 40, -dzMax, dzMax, "npt");
1005  i_sector.second.m_correlationHistsY["Pt"] =
1006  i_sector.second.bookCorrHistsY("Pt", "p_{t}", "[GeV]", 50, 0, pMax, "npt");
1007  i_sector.second.m_correlationHistsY["P"] =
1008  i_sector.second.bookCorrHistsY("P", "|p|", "[GeV]", 50, 0, pMax, "npt");
1009  i_sector.second.m_correlationHistsY["InvP"] =
1010  i_sector.second.bookCorrHistsY("InvP", "1/|p|", "[GeV^{-1}]", 25, 0, invPMax, "t");
1011  i_sector.second.m_correlationHistsY["MeanAngle"] =
1012  i_sector.second.bookCorrHistsY("MeanAngle", "<#phi_{module}>", "[ ^{o}]", 25, -5, 95, "npt");
1013  }
1014 
1015  // (transform errors and residuals from [cm] in [mum])
1016  for (auto const& i_errHists : v_errHists) {
1017  double xMin(0.01 * (i_errHists - 1)), xMax(0.01 * (i_errHists));
1018  std::stringstream sigmaXHit, sigmaXTrk, sigmaX;
1019  sigmaXHit << "h_sigmaXHit_" << i_errHists;
1020  sigmaXTrk << "h_sigmaXTrk_" << i_errHists;
1021  sigmaX << "h_sigmaX_" << i_errHists;
1022  i_sector.second.m_sigmaX["sigmaXHit"].push_back(
1023  secDir.make<TH1F>(sigmaXHit.str().c_str(),
1024  "hit error #sigma_{hit,x};#sigma_{hit,x} [#mum];# hits",
1025  100,
1026  xMin * 10000.,
1027  xMax * 10000.));
1028  i_sector.second.m_sigmaX["sigmaXTrk"].push_back(
1029  secDir.make<TH1F>(sigmaXTrk.str().c_str(),
1030  "track error #sigma_{trk,x};#sigma_{trk,x} [#mum];# hits",
1031  100,
1032  xMin * 10000.,
1033  xMax * 10000.));
1034  i_sector.second.m_sigmaX["sigmaX"].push_back(
1035  secDir.make<TH1F>(sigmaX.str().c_str(),
1036  "residual error #sigma_{r,x};#sigma_{r,x} [#mum];# hits",
1037  100,
1038  xMin * 10000.,
1039  xMax * 10000.));
1040  if (pixelSector) {
1041  std::stringstream sigmaYHit, sigmaYTrk, sigmaY;
1042  sigmaYHit << "h_sigmaYHit_" << i_errHists;
1043  sigmaYTrk << "h_sigmaYTrk_" << i_errHists;
1044  sigmaY << "h_sigmaY_" << i_errHists;
1045  i_sector.second.m_sigmaY["sigmaYHit"].push_back(
1046  secDir.make<TH1F>(sigmaYHit.str().c_str(),
1047  "hit error #sigma_{hit,y};#sigma_{hit,y} [#mum];# hits",
1048  100,
1049  xMin * 10000.,
1050  xMax * 10000.));
1051  i_sector.second.m_sigmaY["sigmaYTrk"].push_back(
1052  secDir.make<TH1F>(sigmaYTrk.str().c_str(),
1053  "track error #sigma_{trk,y};#sigma_{trk,y} [#mum];# hits",
1054  100,
1055  xMin * 10000.,
1056  xMax * 10000.));
1057  i_sector.second.m_sigmaY["sigmaY"].push_back(
1058  secDir.make<TH1F>(sigmaY.str().c_str(),
1059  "residual error #sigma_{r,y};#sigma_{r,y} [#mum];# hits",
1060  100,
1061  xMin * 10000.,
1062  xMax * 10000.));
1063  }
1064  }
1065  }
1066 }
1067 
1069  std::vector<unsigned int> v_errHists(parameterSet_.getParameter<std::vector<unsigned int> >("vErrHists"));
1070  for (std::vector<unsigned int>::iterator i_errHists = v_errHists.begin(); i_errHists != v_errHists.end();
1071  ++i_errHists) {
1072  for (std::vector<unsigned int>::iterator i_errHists2 = i_errHists; i_errHists2 != v_errHists.end();) {
1073  ++i_errHists2;
1074  if (*i_errHists == *i_errHists2) {
1075  edm::LogError("BookSectorHists") << "Value of vErrHists in config exists twice: " << *i_errHists
1076  << "\n... delete one of both";
1077  v_errHists.erase(i_errHists2);
1078  }
1079  }
1080  }
1081 
1082  for (auto& i_sector : m_tkSector_) {
1084  if (!fileService) {
1085  throw edm::Exception(edm::errors::Configuration, "TFileService is not registered in cfg file");
1086  }
1087 
1088  std::stringstream sector;
1089  sector << "Sector_" << i_sector.first;
1090  TFileDirectory secDir = fileService->mkdir(sector.str());
1091 
1092  // Dummy histo containing the sector name as title
1093  i_sector.second.Name = secDir.make<TH1F>("z_name", i_sector.second.name.c_str(), 1, 0, 1);
1094 
1095  // Do not book histos for empty sectors
1096  if (i_sector.second.v_rawId.empty()) {
1097  continue;
1098  }
1099 
1100  // Distributions in each interval (stay in [cm], to have all calculations in [cm])
1101  if (m_resErrBins_
1102  .empty()) { // default if no selection taken into account: calculate APE with one bin with residual error 0-100um
1103  m_resErrBins_[1].first = 0.;
1104  m_resErrBins_[1].second = 0.01;
1105  }
1106  for (auto const& i_errBins : m_resErrBins_) {
1107  std::stringstream interval;
1108  interval << "Interval_" << i_errBins.first;
1109  TFileDirectory intDir = secDir.mkdir(interval.str());
1110  i_sector.second.m_binnedHists[i_errBins.first]["sigmaX"] =
1111  intDir.make<TH1F>("h_sigmaX", "residual resolution #sigma_{x};#sigma_{x} [cm];# hits", 100, 0., 0.01);
1112  i_sector.second.m_binnedHists[i_errBins.first]["norResX"] = intDir.make<TH1F>(
1113  "h_norResX", "normalized residual r_{x}/#sigma_{r,x};(x_{trk}-x_{hit})/#sigma_{r,x};# hits", 100, -10, 10);
1114  if (i_sector.second.isPixel) {
1115  i_sector.second.m_binnedHists[i_errBins.first]["sigmaY"] =
1116  intDir.make<TH1F>("h_sigmaY", "residual resolution #sigma_{y};#sigma_{y} [cm];# hits", 100, 0., 0.01);
1117  i_sector.second.m_binnedHists[i_errBins.first]["norResY"] = intDir.make<TH1F>(
1118  "h_norResY", "normalized residual r_{y}/#sigma_{r,y};(y_{trk}-y_{hit})/#sigma_{r,y};# hits", 100, -10, 10);
1119  }
1120  }
1121 
1122  TFileDirectory resDir = secDir.mkdir("Results");
1123 
1124  // TTree containing rawIds of all modules in sector
1125  unsigned int rawId(0);
1126  i_sector.second.RawId = resDir.make<TTree>("rawIdTree", "Tree containing rawIds of all modules in sector");
1127  i_sector.second.RawId->Branch("RawId", &rawId, "RawId/i");
1128  for (auto const& i_rawId : i_sector.second.v_rawId) {
1129  rawId = i_rawId;
1130  i_sector.second.RawId->Fill();
1131  }
1132 
1133  // Result plots (one hist per sector containing one bin per interval)
1134  // (transform errors and residuals from [cm] in [mum])
1135  std::vector<double> v_binX(parameterSet_.getParameter<std::vector<double> >("residualErrorBinning"));
1136  for (auto& i_binX : v_binX) {
1137  i_binX *= 10000.;
1138  }
1139  i_sector.second.EntriesX =
1140  resDir.make<TH1F>("h_entriesX", "# hits used;#sigma_{x} [#mum];# hits", v_binX.size() - 1, &(v_binX[0]));
1141  if (i_sector.second.isPixel) {
1142  i_sector.second.EntriesY =
1143  resDir.make<TH1F>("h_entriesY", "# hits used;#sigma_{y} [#mum];# hits", v_binX.size() - 1, &(v_binX[0]));
1144  }
1145 
1146  // In fact these are un-needed Analyzer plots, but I want to have them always for every sector visible
1147  // (transform errors and residuals from [cm] in [mum])
1148  i_sector.second.ResX = resDir.make<TH1F>(
1149  "h_ResX", "residual r_{x};x_{trk}-x_{hit} [#mum];# hits", 100, -0.03 * 10000., 0.03 * 10000.);
1150  i_sector.second.NorResX = resDir.make<TH1F>(
1151  "h_NorResX", "normalized residual r_{x}/#sigma_{r,x};(x_{trk}-x_{hit})/#sigma_{r,x};# hits", 100, -5., 5.);
1152  if (i_sector.second.isPixel) {
1153  i_sector.second.ResY = resDir.make<TH1F>(
1154  "h_ResY", "residual r_{y};y_{trk}-y_{hit} [#mum];# hits", 100, -0.03 * 10000., 0.03 * 10000.);
1155  i_sector.second.NorResY = resDir.make<TH1F>(
1156  "h_NorResY", "normalized residual r_{y}/#sigma_{r,y};(y_{trk}-y_{hit})/#sigma_{r,y};# hits", 100, -5., 5.);
1157  }
1158  }
1159 }
1160 
1161 // -----------------------------------------------------------------------------------------------------------
1162 
1164  bool zoomHists(parameterSet_.getParameter<bool>("zoomHists"));
1165 
1166  int trackSizeBins = zoomHists ? 6 : 201;
1167  double trackSizeMax = trackSizeBins - 1;
1168 
1169  double chi2Max = zoomHists ? 100. : 2000.;
1170  double norChi2Max = zoomHists ? 5. : 1000.;
1171  double d0max = zoomHists ? 0.02 : 40.; // cosmics: 100.|100.
1172  double dzmax = zoomHists ? 15. : 100.; // cosmics: 200.|600.
1173  double pMax = zoomHists ? 200. : 2000.;
1174 
1176  TFileDirectory evtDir = fileService->mkdir("EventVariables");
1178  evtDir.make<TH1F>("h_trackSize", "# tracks [all];# tracks;# events", trackSizeBins, -1, trackSizeMax);
1180  evtDir.make<TH1F>("h_trackSizeGood", "# tracks [good];# tracks;# events", trackSizeBins, -1, trackSizeMax);
1181  TFileDirectory trkDir = fileService->mkdir("TrackVariables");
1182  tkDetector_.HitsSize = trkDir.make<TH1F>("h_hitsSize", "# hits;# hits;# tracks", 51, -1, 50);
1183  tkDetector_.HitsValid = trkDir.make<TH1F>("h_hitsValid", "# hits [valid];# hits [valid];# tracks", 51, -1, 50);
1185  trkDir.make<TH1F>("h_hitsInvalid", "# hits [invalid];# hits [invalid];# tracks", 21, -1, 20);
1186  tkDetector_.Hits2D = trkDir.make<TH1F>("h_hits2D", "# hits [2D];# hits [2D];# tracks", 21, -1, 20);
1188  trkDir.make<TH1F>("h_layersMissed", "# layers [missed];# layers [missed];# tracks", 11, -1, 10);
1189  tkDetector_.HitsPixel = trkDir.make<TH1F>("h_hitsPixel", "# hits [pixel];# hits [pixel];# tracks", 11, -1, 10);
1190  tkDetector_.HitsStrip = trkDir.make<TH1F>("h_hitsStrip", "# hits [strip];# hits [strip];# tracks", 41, -1, 40);
1191  tkDetector_.Charge = trkDir.make<TH1F>("h_charge", "charge q;q [e];# tracks", 5, -2, 3);
1192  tkDetector_.Chi2 = trkDir.make<TH1F>("h_chi2", " #chi^{2};#chi^{2};# tracks", 100, 0, chi2Max);
1193  tkDetector_.Ndof = trkDir.make<TH1F>("h_ndof", "# degrees of freedom f;f;# tracks", 101, -1, 100);
1194  tkDetector_.NorChi2 = trkDir.make<TH1F>("h_norChi2", "normalized #chi^{2};#chi^{2}/f;# tracks", 200, 0, norChi2Max);
1195  tkDetector_.Prob = trkDir.make<TH1F>("h_prob", " #chi^{2} probability;prob(#chi^{2},f);# tracks", 50, 0, 1);
1196  tkDetector_.Eta = trkDir.make<TH1F>("h_eta", "pseudorapidity #eta;#eta;# tracks", 100, -5, 5);
1197  tkDetector_.EtaErr = trkDir.make<TH1F>("h_etaErr", "Error of #eta;#sigma(#eta);# tracks", 100, 0, 0.001);
1199  trkDir.make<TH1F>("h_etaSig", "Significance of #eta;#eta/#sigma(#eta);# tracks", 100, -20000, 20000);
1200  tkDetector_.Theta = trkDir.make<TH1F>("h_theta", "polar angle #theta;#theta [ ^{o}];# tracks", 100, -10, 190);
1201  tkDetector_.Phi = trkDir.make<TH1F>("h_phi", "azimuth angle #phi;#phi [ ^{o}];# tracks", 190, -190, 190);
1202  tkDetector_.PhiErr = trkDir.make<TH1F>("h_phiErr", "Error of #phi;#sigma(#phi) [ ^{o}];# tracks", 100, 0, 0.04);
1204  trkDir.make<TH1F>("h_phiSig", "Significance of #phi;#phi/#sigma(#phi) [ ^{o}];# tracks", 100, -50000, 50000);
1205  tkDetector_.D0Beamspot = trkDir.make<TH1F>(
1206  "h_d0Beamspot", "Closest approach d_{0} wrt. beamspot;d_{0, BS} [cm];# tracks", 200, -d0max, d0max);
1208  trkDir.make<TH1F>("h_d0BeamspotErr", "Error of d_{0, BS};#sigma(d_{0, BS}) [cm];# tracks", 200, 0, 0.01);
1209  tkDetector_.D0BeamspotSig = trkDir.make<TH1F>(
1210  "h_d0BeamspotSig", "Significance of d_{0, BS};d_{0, BS}/#sigma(d_{0, BS});# tracks", 100, -5, 5);
1211  tkDetector_.Dz = trkDir.make<TH1F>("h_dz", "Closest approach d_{z};d_{z} [cm];# tracks", 200, -dzmax, dzmax);
1212  tkDetector_.DzErr = trkDir.make<TH1F>("h_dzErr", "Error of d_{z};#sigma(d_{z}) [cm];# tracks", 200, 0, 0.01);
1213  tkDetector_.DzSig =
1214  trkDir.make<TH1F>("h_dzSig", "Significance of d_{z};d_{z}/#sigma(d_{z});# tracks", 100, -10000, 10000);
1215  tkDetector_.Pt = trkDir.make<TH1F>("h_pt", "transverse momentum p_{t};p_{t} [GeV];# tracks", 100, 0, pMax);
1216  tkDetector_.PtErr = trkDir.make<TH1F>("h_ptErr", "Error of p_{t};#sigma(p_{t}) [GeV];# tracks", 100, 0, 1.6);
1217  tkDetector_.PtSig = trkDir.make<TH1F>("h_ptSig", "Significance of p_{t};p_{t}/#sigma(p_{t});# tracks", 100, 0, 200);
1218  tkDetector_.P = trkDir.make<TH1F>("h_p", "momentum magnitude |p|;|p| [GeV];# tracks", 100, 0, pMax);
1219  tkDetector_.MeanAngle = trkDir.make<TH1F>(
1220  "h_meanAngle", "mean angle on module <#phi_{module}>;<#phi_{module}> [ ^{o}];# tracks", 100, -5, 95);
1221  tkDetector_.HitsGood = trkDir.make<TH1F>("h_hitsGood", "# hits [good];# hits [good];# tracks", 51, -1, 50);
1222 
1223  tkDetector_.MeanAngleVsHits = trkDir.make<TH2F>(
1224  "h2_meanAngleVsHits", "<#phi_{module}> vs. # hits;# hits;<#phi_{module}> [ ^{o}]", 51, -1, 50, 50, -5, 95);
1226  trkDir.make<TH2F>("h2_hitsGoodVsHitsValid",
1227  "# hits [good] vs. # hits [valid];# hits [valid];# hits [good]",
1228  51,
1229  -1,
1230  50,
1231  51,
1232  -1,
1233  50);
1235  trkDir.make<TH2F>("h2_hitsPixelVsEta", "# hits [pixel] vs. #eta;#eta;# hits [pixel]", 60, -3, 3, 11, -1, 10);
1236  tkDetector_.HitsPixelVsTheta = trkDir.make<TH2F>(
1237  "h2_hitsPixelVsTheta", "# hits [pixel] vs. #theta;#theta;# hits [pixel]", 100, -10, 190, 11, -1, 10);
1239  trkDir.make<TH2F>("h2_hitsStripVsEta", "# hits [strip] vs. #eta;#eta;# hits [strip]", 60, -3, 3, 31, -1, 40);
1240  tkDetector_.HitsStripVsTheta = trkDir.make<TH2F>(
1241  "h2_hitsStripVsTheta", "# hits [strip] vs. #theta;#theta;# hits [strip]", 100, -10, 190, 31, -1, 40);
1242  tkDetector_.PtVsEta = trkDir.make<TH2F>("h2_ptVsEta", "p_{t} vs. #eta;#eta;p_{t} [GeV]", 60, -3, 3, 100, 0, pMax);
1244  trkDir.make<TH2F>("h2_ptVsTheta", "p_{t} vs. #theta;#theta;p_{t} [GeV]", 100, -10, 190, 100, 0, pMax);
1245 
1246  tkDetector_.PMeanAngleVsHits = trkDir.make<TProfile>(
1247  "p_meanAngleVsHits", "<#phi_{module}> vs. # hits;# hits;<#phi_{module}> [ ^{o}]", 51, -1, 50);
1248  tkDetector_.PHitsGoodVsHitsValid = trkDir.make<TProfile>(
1249  "p_hitsGoodVsHitsValid", "# hits [good] vs. # hits [valid];# hits [valid];# hits [good]", 51, -1, 50);
1251  trkDir.make<TProfile>("p_hitsPixelVsEta", "# hits [pixel] vs. #eta;#eta;# hits [pixel]", 60, -3, 3);
1253  trkDir.make<TProfile>("p_hitsPixelVsTheta", "# hits [pixel] vs. #theta;#theta;# hits [pixel]", 100, -10, 190);
1255  trkDir.make<TProfile>("p_hitsStripVsEta", "# hits [strip] vs. #eta;#eta;# hits [strip]", 60, -3, 3);
1257  trkDir.make<TProfile>("p_hitsStripVsTheta", "# hits [strip] vs. #theta;#theta;# hits [strip]", 100, -10, 190);
1258  tkDetector_.PPtVsEta = trkDir.make<TProfile>("p_ptVsEta", "p_{t} vs. #eta;#eta;p_{t} [GeV]", 60, -3, 3);
1259  tkDetector_.PPtVsTheta = trkDir.make<TProfile>("p_ptVsTheta", "p_{t} vs. #theta;#theta;p_{t} [GeV]", 100, -10, 190);
1260 }
1261 
1262 // -----------------------------------------------------------------------------------------------------------
1263 
1265  const Trajectory& traj,
1266  const reco::BeamSpot& beamSpot) {
1267  const math::XYZPoint beamPoint(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
1268  double d0BeamspotErr =
1269  std::sqrt(track.d0Error() * track.d0Error() + 0.5 * beamSpot.BeamWidthX() * beamSpot.BeamWidthX() +
1270  0.5 * beamSpot.BeamWidthY() * beamSpot.BeamWidthY());
1271 
1272  const static TrajectoryStateCombiner tsoscomb;
1273 
1274  const reco::HitPattern& hitPattern(track.hitPattern());
1275 
1277 
1278  trkParams.hitsSize = track.recHitsSize();
1279  trkParams.hitsValid = track.found(); // invalid is every hit from every single module that expects a hit
1280  trkParams.hitsInvalid = trkParams.hitsSize - trkParams.hitsValid;
1281  trkParams.layersMissed =
1282  track.lost(); // lost hit means, that a crossed layer doesn't contain a hit (can be more than one invalid hit)
1283  trkParams.hitsPixel = hitPattern.numberOfValidPixelHits();
1284  trkParams.hitsStrip = hitPattern.numberOfValidStripHits();
1285  trkParams.charge = track.charge();
1286  trkParams.chi2 = track.chi2();
1287  trkParams.ndof = track.ndof();
1288  trkParams.norChi2 = trkParams.chi2 / trkParams.ndof;
1289  trkParams.prob = TMath::Prob(trkParams.chi2, trkParams.ndof);
1290  trkParams.eta = track.eta();
1291  trkParams.etaErr = track.etaError();
1292  trkParams.theta = track.theta();
1293  trkParams.phi = track.phi();
1294  trkParams.phiErr = track.phiError();
1295  trkParams.d0 = track.d0();
1296  trkParams.d0Beamspot = -1. * track.dxy(beamPoint);
1297  trkParams.d0BeamspotErr = d0BeamspotErr;
1298  trkParams.dz = track.dz();
1299  trkParams.dzErr = track.dzError();
1300  trkParams.dzBeamspot = track.dz(beamPoint);
1301  trkParams.p = track.p();
1302  trkParams.pt = track.pt();
1303  trkParams.ptErr = track.ptError();
1304 
1305  const std::vector<TrajectoryMeasurement>& v_meas = traj.measurements();
1306 
1307  int count2D(0);
1308  float meanPhiSensToNorm(0.F);
1309  for (auto const& i_meas : v_meas) {
1310  const TrajectoryMeasurement& meas = i_meas;
1311  const TransientTrackingRecHit& hit = *meas.recHit();
1312  const TrackingRecHit& recHit = *hit.hit();
1313  if (this->isHit2D(recHit))
1314  ++count2D;
1315 
1317  const align::LocalVector mom(tsos.localDirection());
1318  meanPhiSensToNorm += atan(fabs(sqrt(mom.x() * mom.x() + mom.y() * mom.y()) / mom.z()));
1319  }
1320  meanPhiSensToNorm *= (1. / static_cast<float>(trkParams.hitsSize));
1321 
1322  trkParams.hits2D = count2D;
1323  trkParams.meanPhiSensToNorm = meanPhiSensToNorm;
1324 
1325  if (parameterSet_.getParameter<bool>("applyTrackCuts")) {
1326  trackCut_ = false;
1327  if (trkParams.hitsStrip < 11 || trkParams.hits2D < 2 || trkParams.hitsPixel < 2 || //trkParams.hitsInvalid>2 ||
1328  trkParams.hitsStrip > 35 || trkParams.hitsPixel > 7 || trkParams.norChi2 > 5. || trkParams.pt < 25. ||
1329  trkParams.pt > 150. || std::abs(trkParams.d0Beamspot) > 0.02 || std::abs(trkParams.dz) > 15.)
1330  trackCut_ = true;
1331  } else {
1332  trackCut_ = false;
1333  }
1334 
1335  return trkParams;
1336 }
1337 
1339  const edm::EventSetup& iSetup) {
1341 
1342  const static TrajectoryStateCombiner tsoscomb;
1343 
1344  const TrajectoryMeasurement& meas = i_meas;
1345  const TransientTrackingRecHit& hit = *meas.recHit();
1346  const TrackingRecHit& recHit = *hit.hit();
1347  const TrajectoryStateOnSurface& tsos = tsoscomb(meas.forwardPredictedState(), meas.backwardPredictedState());
1348 
1349  const DetId& detId(hit.geographicalId());
1350  const DetId::Detector& detector = detId.det();
1351  if (detector != DetId::Tracker) {
1352  hitParams.hitState = TrackStruct::notInTracker;
1353  return hitParams;
1354  }
1355  const uint32_t rawId(detId.rawId());
1356 
1357  for (auto& i_sector : m_tkSector_) {
1358  for (auto const& i_rawId : i_sector.second.v_rawId) {
1359  if (rawId == i_rawId) {
1360  hitParams.v_sector.push_back(i_sector.first);
1361  break;
1362  }
1363  }
1364  }
1365 
1366  const align::LocalVector& mom(tsos.localDirection());
1367  int xMomentum(0), yMomentum(0), zMomentum(0);
1368  xMomentum = mom.x() > 0. ? 1 : -1;
1369  yMomentum = mom.y() > 0. ? 1 : -1;
1370  zMomentum = mom.z() > 0. ? 1 : -1;
1371  float phiSensX =
1372  std::atan(std::fabs(mom.x() / mom.z())) *
1373  static_cast<float>(
1374  m_tkTreeVar_[rawId].vDirection); // check for orientation of E- and B- Field (thoughts for barrel)
1375  float phiSensY = std::atan(std::fabs(mom.y() / mom.z())) * static_cast<float>(m_tkTreeVar_[rawId].vDirection);
1376  hitParams.phiSens = std::atan(std::fabs(std::sqrt(mom.x() * mom.x() + mom.y() * mom.y()) / mom.z()));
1377  hitParams.phiSensX = (xMomentum == zMomentum ? phiSensX : -phiSensX);
1378  hitParams.phiSensY = (yMomentum == zMomentum ? phiSensY : -phiSensY);
1379 
1380  if (!hit.isValid()) {
1381  hitParams.hitState = TrackStruct::invalid;
1382  return hitParams;
1383  }
1384 
1385  // Get local positions and errors of hit and track
1386  const LocalPoint& lPHit = hit.localPosition();
1387  const LocalPoint& lPTrk = tsos.localPosition();
1388 
1389  // use APE also for the hit error, while APE is automatically included in tsos error
1390  //
1391  // no need to add APE to hitError anymore by Ajay 27 Oct 2014
1392  const LocalError& errHitApe = hit.localPositionError(); // now sum of CPE+APE as said by MARCO?
1393  LocalError errorWithoutAPE;
1394 
1395  bool Pixel(false);
1396  bool Strip(false);
1397 
1398  if (m_tkTreeVar_[rawId].subdetId == PixelSubdetector::PixelBarrel ||
1399  m_tkTreeVar_[rawId].subdetId == PixelSubdetector::PixelEndcap) {
1400  Pixel = true;
1401  } else if (m_tkTreeVar_[rawId].subdetId == StripSubdetector::TIB ||
1402  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TOB ||
1403  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TID ||
1404  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TEC) {
1405  Strip = true;
1406  } else {
1407  edm::LogWarning("FillHitVariables") << "cant identify wether hit is from pixel or strip";
1408  hitParams.hitState = TrackStruct::invalid;
1409  return hitParams;
1410  }
1411 
1412  if (!hit.detUnit()) {
1413  hitParams.hitState = TrackStruct::invalid;
1414  return hitParams;
1415  } // is it a single physical module?
1416  const GeomDetUnit& detUnit = *hit.detUnit();
1417 
1418  if (Pixel) {
1419  if (!dynamic_cast<const PixelTopology*>(&detUnit.type().topology())) {
1420  hitParams.hitState = TrackStruct::invalid;
1421  return hitParams;
1422  }
1423  const PixelGeomDetUnit* pixelDet = (const PixelGeomDetUnit*)(&detUnit);
1424  const LocalError& lape = pixelDet->localAlignmentError();
1425  if (lape.valid()) {
1426  errorWithoutAPE = LocalError(errHitApe.xx() - lape.xx(), errHitApe.xy() - lape.xy(), errHitApe.yy() - lape.yy());
1427  }
1428  }
1429  if (Strip) {
1430  if (!dynamic_cast<const StripTopology*>(&detUnit.type().topology())) {
1431  hitParams.hitState = TrackStruct::invalid;
1432  return hitParams;
1433  }
1434  const StripGeomDetUnit* stripDet = (const StripGeomDetUnit*)(&detUnit);
1435  const LocalError& lape = stripDet->localAlignmentError();
1436  if (lape.valid()) {
1437  errorWithoutAPE = LocalError(errHitApe.xx() - lape.xx(), errHitApe.xy() - lape.xy(), errHitApe.yy() - lape.yy());
1438  }
1439  }
1440 
1441  const LocalError& errHitWoApe = errorWithoutAPE;
1442  const LocalError& errTrk = tsos.localError().positionError();
1443 
1444  const StatePositionAndError2 positionAndError2Hit = this->positionAndError2(lPHit, errHitApe, hit);
1445  const StatePositionAndError2 positionAndError2HitWoApe = this->positionAndError2(lPHit, errHitWoApe, hit);
1446  edm::LogInfo("CalculateAPE") << "errHitWoApe " << errHitWoApe << "errHitApe " << errHitApe;
1447 
1448  const StatePositionAndError2 positionAndError2Trk = this->positionAndError2(lPTrk, errTrk, hit);
1449 
1450  const TrackStruct::HitState& stateHit(positionAndError2Hit.first);
1451  const TrackStruct::HitState& stateHitWoApe(positionAndError2HitWoApe.first);
1452  const TrackStruct::HitState& stateTrk(positionAndError2Trk.first);
1453 
1454  if (stateHit == TrackStruct::invalid || stateHitWoApe == TrackStruct::invalid || stateTrk == TrackStruct::invalid) {
1455  hitParams.hitState = TrackStruct::invalid;
1456  return hitParams;
1457  } else if (stateHit == TrackStruct::negativeError || stateHitWoApe == TrackStruct::negativeError ||
1458  stateTrk == TrackStruct::negativeError) {
1459  ++counter1;
1460  // Do not print error message by default
1461  //std::stringstream ss_error;
1462  //ss_error<<"Upper values belong to: ";
1463  //if(stateHit==TrackStruct::negativeError)ss_error<<"Hit without APE, ";
1464  //if(stateHitWoApe==TrackStruct::negativeError)ss_error<<"Hit with APE, ";
1465  //if(stateTrk==TrackStruct::negativeError)ss_error<<"Track,";
1466  //edm::LogError("Negative error Value")<<"@SUB=ApeEstimator::fillHitVariables"<<ss_error.str();
1468  return hitParams;
1469  }
1470 
1471  // Calculate residuals
1472 
1473  const float xHit = positionAndError2Hit.second.posX;
1474  const float xTrk = positionAndError2Trk.second.posX;
1475  const float yHit = positionAndError2Hit.second.posY;
1476  const float yTrk = positionAndError2Trk.second.posY;
1477 
1478  const float errXHit2(positionAndError2Hit.second.errX2);
1479  const float errXHitWoApe2(positionAndError2HitWoApe.second.errX2);
1480  const float errXTrk2(positionAndError2Trk.second.errX2);
1481  const float errYHit2(positionAndError2Hit.second.errY2);
1482  const float errYHitWoApe2(positionAndError2HitWoApe.second.errY2);
1483  const float errYTrk2(positionAndError2Trk.second.errY2);
1484 
1485  const float errXHit = std::sqrt(positionAndError2Hit.second.errX2);
1486  const float errXHitWoApe = std::sqrt(positionAndError2HitWoApe.second.errX2);
1487  const float errXTrk = std::sqrt(positionAndError2Trk.second.errX2);
1488  const float errYHit = std::sqrt(positionAndError2Hit.second.errY2);
1489  const float errYHitWoApe = std::sqrt(positionAndError2HitWoApe.second.errY2);
1490  const float errYTrk = std::sqrt(positionAndError2Trk.second.errY2);
1491 
1492  const float resX = xTrk - xHit;
1493  const float resY = yTrk - yHit;
1494 
1495  const float errX = std::sqrt(errXHit2 + errXTrk2);
1496  const float errXWoApe2 = errXHitWoApe2 + errXTrk2;
1497  const float errXWoApe = std::sqrt(errXWoApe2);
1498  const float errY = std::sqrt(errYHit2 + errYTrk2);
1499  const float errYWoApe2 = errYHitWoApe2 + errYTrk2;
1500  const float errYWoApe = std::sqrt(errYWoApe2);
1501 
1502  const float norResX = resX / errX;
1503  const float norResY = resY / errY;
1504 
1505  // Take global orientation into account for residuals (sign is not important for errors)
1506 
1507  float resXprime(999.F), resYprime(999.F), norResXprime(999.F), norResYprime(999.F);
1508  if (m_tkTreeVar_[rawId].uDirection == 1) {
1509  resXprime = resX;
1510  norResXprime = norResX;
1511  } else if (m_tkTreeVar_[rawId].uDirection == -1) {
1512  resXprime = -resX;
1513  norResXprime = -norResX;
1514  } else {
1515  edm::LogError("FillHitVariables") << "Incorrect value of uDirection, which gives global module orientation";
1516  hitParams.hitState = TrackStruct::invalid;
1517  return hitParams;
1518  }
1519  if (m_tkTreeVar_[rawId].vDirection == 1) {
1520  resYprime = resY;
1521  norResYprime = norResY;
1522  } else if (m_tkTreeVar_[rawId].vDirection == -1) {
1523  resYprime = -resY;
1524  norResYprime = -norResY;
1525  } else {
1526  edm::LogError("FillHitVariables") << "Incorrect value of vDirection, which gives global module orientation";
1527  hitParams.hitState = TrackStruct::invalid;
1528  return hitParams;
1529  }
1530 
1531  hitParams.xHit = xHit;
1532  hitParams.xTrk = xTrk;
1533 
1534  hitParams.errXHit = errXHit;
1535  hitParams.errXHitWoApe = errXHitWoApe;
1536  hitParams.errXTrk = errXTrk;
1537 
1538  hitParams.errX2 = errX * errX;
1539  hitParams.errX = errX;
1540  hitParams.errXWoApe = errXWoApe;
1541 
1542  hitParams.resX = resXprime;
1543  hitParams.norResX = norResXprime;
1544 
1545  const float norResX2(norResXprime * norResXprime);
1546  hitParams.probX = TMath::Prob(norResX2, 1);
1547 
1548  hitParams.yHit = yHit;
1549  hitParams.yTrk = yTrk;
1550 
1551  hitParams.errYHit = errYHit;
1552  hitParams.errYHitWoApe = errYHitWoApe;
1553  hitParams.errYTrk = errYTrk;
1554 
1555  hitParams.errY2 = errY * errY;
1556  hitParams.errY = errY;
1557  hitParams.errYWoApe = errYWoApe;
1558 
1559  hitParams.resY = resYprime;
1560  hitParams.norResY = norResYprime;
1561 
1562  const float norResY2(norResYprime * norResYprime);
1563  hitParams.probY = TMath::Prob(norResY2, 1);
1564 
1565  // Cluster parameters
1566 
1567  if (m_tkTreeVar_[rawId].subdetId == PixelSubdetector::PixelBarrel ||
1568  m_tkTreeVar_[rawId].subdetId == PixelSubdetector::PixelEndcap) {
1569  const SiPixelRecHit& pixelHit = dynamic_cast<const SiPixelRecHit&>(recHit);
1570  const SiPixelCluster& pixelCluster = *pixelHit.cluster();
1571 
1572  hitParams.chargePixel = pixelCluster.charge();
1573  hitParams.widthX = pixelCluster.sizeX();
1574  hitParams.baryStripX = pixelCluster.x();
1575  hitParams.widthY = pixelCluster.sizeY();
1576  hitParams.baryStripY = pixelCluster.y();
1577 
1578  hitParams.clusterProbabilityXY = pixelHit.clusterProbability(0);
1579  hitParams.clusterProbabilityQ = pixelHit.clusterProbability(2);
1580  hitParams.clusterProbabilityXYQ = pixelHit.clusterProbability(1);
1581  hitParams.logClusterProbability = std::log10(hitParams.clusterProbabilityXY);
1582 
1583  hitParams.isOnEdge = pixelHit.isOnEdge();
1584  hitParams.hasBadPixels = pixelHit.hasBadPixels();
1585  hitParams.spansTwoRoc = pixelHit.spansTwoROCs();
1586  hitParams.qBin = pixelHit.qBin();
1587 
1588  hitParams.isPixelHit = true;
1589  } else if (m_tkTreeVar_[rawId].subdetId == StripSubdetector::TIB ||
1590  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TOB ||
1591  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TID ||
1592  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TEC) {
1593  if (!(dynamic_cast<const SiStripRecHit2D*>(&recHit) || dynamic_cast<const SiStripRecHit1D*>(&recHit))) {
1594  edm::LogError("FillHitVariables")
1595  << "RecHit in Strip is 'Matched' or 'Projected', but here all should be monohits per module";
1596  hitParams.hitState = TrackStruct::invalid;
1597  return hitParams;
1598  }
1599  const SiStripCluster* clusterPtr(nullptr);
1600  if (m_tkTreeVar_[rawId].subdetId == StripSubdetector::TIB ||
1601  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TOB) {
1602  if (dynamic_cast<const SiStripRecHit1D*>(&recHit)) {
1603  const SiStripRecHit1D& stripHit = dynamic_cast<const SiStripRecHit1D&>(recHit);
1604  clusterPtr = &(*stripHit.cluster());
1605  } else if (dynamic_cast<const SiStripRecHit2D*>(&recHit)) {
1606  edm::LogWarning("FillHitVariables") << "Data has TIB/TOB hits as SiStripRecHit2D and not 1D. Probably data is "
1607  "processed with CMSSW<34X. Nevertheless everything should work fine";
1608  const SiStripRecHit2D& stripHit = dynamic_cast<const SiStripRecHit2D&>(recHit);
1609  clusterPtr = &(*stripHit.cluster());
1610  }
1611  } else if (m_tkTreeVar_[rawId].subdetId == StripSubdetector::TID ||
1612  m_tkTreeVar_[rawId].subdetId == StripSubdetector::TEC) {
1613  const SiStripRecHit2D& stripHit = dynamic_cast<const SiStripRecHit2D&>(recHit);
1614  clusterPtr = &(*stripHit.cluster());
1615  }
1616  if (!clusterPtr) {
1617  edm::LogError("FillHitVariables") << "Pointer to cluster not valid!!! This should never happen...";
1618  hitParams.hitState = TrackStruct::invalid;
1619  return hitParams;
1620  }
1621  const SiStripCluster& stripCluster(*clusterPtr);
1622 
1623  const SiStripClusterInfo clusterInfo = SiStripClusterInfo(stripCluster, iSetup, rawId, std::string(""));
1624 
1625  const std::vector<uint8_t>::const_iterator stripChargeL(clusterInfo.stripCharges().begin());
1626  const std::vector<uint8_t>::const_iterator stripChargeR(--(clusterInfo.stripCharges().end()));
1627  const std::pair<uint16_t, uint16_t> stripChargeLR = std::make_pair(*stripChargeL, *stripChargeR);
1628 
1629  hitParams.chargeStrip = clusterInfo.charge();
1630  hitParams.widthX = clusterInfo.width();
1631  hitParams.baryStripX = clusterInfo.baryStrip() + 1.;
1632  hitParams.isModuleUsable = clusterInfo.IsModuleUsable();
1633  hitParams.maxStrip = clusterInfo.maxStrip() + 1;
1634  hitParams.maxStripInv = m_tkTreeVar_[rawId].nStrips - hitParams.maxStrip + 1;
1635  hitParams.maxCharge = clusterInfo.maxCharge();
1636  hitParams.maxIndex = clusterInfo.maxIndex();
1637  hitParams.chargeOnEdges =
1638  static_cast<float>(stripChargeLR.first + stripChargeLR.second) / static_cast<float>(hitParams.chargeStrip);
1639  hitParams.chargeAsymmetry = static_cast<float>(stripChargeLR.first - stripChargeLR.second) /
1640  static_cast<float>(stripChargeLR.first + stripChargeLR.second);
1641  hitParams.chargeLRplus = static_cast<float>(clusterInfo.chargeLR().first + clusterInfo.chargeLR().second) /
1642  static_cast<float>(hitParams.chargeStrip);
1643  hitParams.chargeLRminus = static_cast<float>(clusterInfo.chargeLR().first - clusterInfo.chargeLR().second) /
1644  static_cast<float>(hitParams.chargeStrip);
1645  hitParams.sOverN = clusterInfo.signalOverNoise();
1646 
1647  // Calculate projection length corrected by drift
1648  if (!hit.detUnit()) {
1649  hitParams.hitState = TrackStruct::invalid;
1650  return hitParams;
1651  } // is it a single physical module?
1652  const GeomDetUnit& detUnit = *hit.detUnit();
1653  if (!dynamic_cast<const StripTopology*>(&detUnit.type().topology())) {
1654  hitParams.hitState = TrackStruct::invalid;
1655  return hitParams;
1656  }
1657 
1658  edm::ESHandle<MagneticField> magFieldHandle;
1659  iSetup.get<IdealMagneticFieldRecord>().get(magFieldHandle);
1660 
1661  edm::ESHandle<SiStripLorentzAngle> lorentzAngleHandle;
1662  iSetup.get<SiStripLorentzAngleDepRcd>().get(lorentzAngleHandle); //MODIFIED BY LOIC QUERTENMONT
1663 
1664  const StripGeomDetUnit* stripDet = (const StripGeomDetUnit*)(&detUnit);
1665  const MagneticField* magField(magFieldHandle.product());
1666  LocalVector bField = (stripDet->surface()).toLocal(magField->inTesla(stripDet->surface().position()));
1667  const SiStripLorentzAngle* lorentzAngle(lorentzAngleHandle.product());
1668  float tanLorentzAnglePerTesla = lorentzAngle->getLorentzAngle(stripDet->geographicalId().rawId());
1669 
1670  float dirX = -tanLorentzAnglePerTesla * bField.y();
1671  float dirY = tanLorentzAnglePerTesla * bField.x();
1672  float dirZ = 1.; // E field always in z direction
1673  LocalVector driftDirection(dirX, dirY, dirZ);
1674 
1675  const Bounds& bounds = stripDet->specificSurface().bounds();
1676  float maxLength = std::sqrt(std::pow(bounds.length(), 2) + std::pow(bounds.width(), 2));
1677  float thickness = bounds.thickness();
1678 
1679  const StripTopology& topol = dynamic_cast<const StripTopology&>(detUnit.type().topology());
1680  LocalVector momentumDir(tsos.localDirection());
1681  LocalPoint momentumPos(tsos.localPosition());
1682  LocalVector scaledMomentumDir(momentumDir);
1683  if (momentumDir.z() > 0.)
1684  scaledMomentumDir *= std::fabs(thickness / momentumDir.z());
1685  else if (momentumDir.z() < 0.)
1686  scaledMomentumDir *= -std::fabs(thickness / momentumDir.z());
1687  else
1688  scaledMomentumDir *= maxLength / momentumDir.mag();
1689 
1690  float projEdge1 = topol.measurementPosition(momentumPos - 0.5 * scaledMomentumDir).x();
1691  if (projEdge1 < 0.)
1692  projEdge1 = 0.;
1693  else if (projEdge1 > m_tkTreeVar_[rawId].nStrips)
1694  projEdge1 = m_tkTreeVar_[rawId].nStrips;
1695  float projEdge2 = topol.measurementPosition(momentumPos + 0.5 * scaledMomentumDir).x();
1696  if (projEdge2 < 0.)
1697  projEdge1 = 0.;
1698  else if (projEdge2 > m_tkTreeVar_[rawId].nStrips)
1699  projEdge1 = m_tkTreeVar_[rawId].nStrips;
1700 
1701  float coveredStrips = std::fabs(projEdge2 - projEdge1);
1702 
1703  hitParams.projWidth = coveredStrips;
1704 
1705  } else {
1706  edm::LogError("FillHitVariables") << "Incorrect subdetector ID, hit not associated to tracker";
1707  hitParams.hitState = TrackStruct::notInTracker;
1708  return hitParams;
1709  }
1710 
1711  if (!hitParams.isModuleUsable) {
1712  hitParams.hitState = TrackStruct::invalid;
1713  return hitParams;
1714  }
1715 
1716  if (hitParams.v_sector.empty()) {
1718  return hitParams;
1719  }
1720 
1721  return hitParams;
1722  //}
1723 }
1724 
1726  const LocalError& localError,
1727  const TransientTrackingRecHit& hit) {
1729 
1730  const DetId& detId(hit.geographicalId());
1731  const uint32_t& rawId(detId.rawId());
1732  const unsigned int& subdetId(m_tkTreeVar_[rawId].subdetId);
1733 
1734  if (localError.xx() < 0. || localError.yy() < 0.) {
1735  // Do not print error message by default
1736  //edm::LogError("Negative error Value")<<"@SUB=ApeEstimator::fillHitVariables"
1737  // <<"One of the squared error methods gives negative result\n"
1738  // <<"\tSubdetector\tlocalError.xx()\tlocalError.yy()\n"
1739  // <<"\t"<<subdetId<<"\t\t"<<localError.xx()<<"\t"<<localError.yy();
1740  vPE2.first = TrackStruct::negativeError;
1741  return vPE2;
1742  }
1743 
1744  if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap ||
1745  subdetId == StripSubdetector::TIB || subdetId == StripSubdetector::TOB) {
1746  // Cartesian coordinates
1747  vPE2 = std::make_pair(TrackStruct::ok, this->rectangularPositionAndError2(localPoint, localError));
1748  } else if (subdetId == StripSubdetector::TID || subdetId == StripSubdetector::TEC) {
1749  // Local x in radial coordinates
1750  if (!hit.detUnit())
1751  return vPE2; // is it a single physical module?
1752  const GeomDetUnit& detUnit = *hit.detUnit();
1753 
1754  if (!dynamic_cast<const RadialStripTopology*>(&detUnit.type().topology()))
1755  return vPE2;
1756  const RadialStripTopology& topol = dynamic_cast<const RadialStripTopology&>(detUnit.type().topology());
1757 
1758  MeasurementError measError = topol.measurementError(localPoint, localError);
1759  if (measError.uu() < 0. || measError.vv() < 0.) {
1760  // Do not print error message by default
1761  //edm::LogError("Negative error Value")<<"@SUB=ApeEstimator::fillHitVariables"
1762  // <<"One of the squared error methods gives negative result\n"
1763  // <<"\tmeasError.uu()\tmeasError.vv()\n"
1764  // <<"\t"<<measError.uu()<<"\t"<<measError.vv()
1765  // <<"\n\nOriginalValues:\n"
1766  // <<localPoint.x()<<" "<<localPoint.y()<<"\n"
1767  // <<localError.xx()<<" "<<localError.yy()<<"\n"
1768  // <<"Subdet: "<<subdetId;
1769  vPE2.first = TrackStruct::negativeError;
1770  return vPE2;
1771  }
1772  vPE2 = std::make_pair(TrackStruct::ok, this->radialPositionAndError2(localPoint, localError, topol));
1773  } else {
1774  edm::LogError("FillHitVariables") << "Incorrect subdetector ID, hit not associated to tracker";
1775  }
1776 
1777  return vPE2;
1778 }
1779 
1781  const float x(lP.x());
1782  const float y(lP.y());
1783  const float errX2(lE.xx());
1784  const float errY2(lE.yy());
1785 
1786  return PositionAndError2(x, y, errX2, errY2);
1787 }
1788 
1790  const LocalError& lE,
1791  const RadialStripTopology& topol) {
1792  MeasurementPoint measPos = topol.measurementPosition(lP);
1793  MeasurementError measErr = topol.measurementError(lP, lE);
1794 
1795  const float r_0 = topol.originToIntersection();
1796  const float stripLength = topol.localStripLength(lP);
1797  const float phi = topol.stripAngle(measPos.x());
1798 
1799  float x(-999.F);
1800  float y(-999.F);
1801  float errX2(-999.F);
1802  float errY2(-999.F);
1803 
1804  x = phi * r_0;
1805  // Radial y (not symmetric around 0; radial distance with minimum at middle strip at lower edge [0, yMax])
1806  const float l_0 = r_0 - topol.detHeight() / 2;
1807  const float cosPhi(std::cos(phi));
1808  y = measPos.y() * stripLength - 0.5 * stripLength + l_0 * (1. / cosPhi - 1.);
1809 
1810  const float angularWidth2(topol.angularWidth() * topol.angularWidth());
1811  const float errPhi2(measErr.uu() * angularWidth2);
1812 
1813  errX2 = errPhi2 * r_0 * r_0;
1814  // Radial y (not symmetric around 0, real radial distance from intersection point)
1815  const float cosPhi4(std::pow(cosPhi, 4)), sinPhi2(std::sin(phi) * std::sin(phi));
1816  const float helpSummand = l_0 * l_0 * (sinPhi2 / cosPhi4 * errPhi2);
1817  errY2 = measErr.vv() * stripLength * stripLength + helpSummand;
1818 
1819  return PositionAndError2(x, y, errX2, errY2);
1820 }
1821 
1822 // -----------------------------------------------------------------------------------------------------------
1823 
1825  this->setHitSelectionMapUInt("width");
1826  this->setHitSelectionMap("widthProj");
1827  this->setHitSelectionMap("widthDiff");
1828  this->setHitSelectionMap("charge");
1829  this->setHitSelectionMapUInt("edgeStrips");
1830  this->setHitSelectionMap("maxCharge");
1831  this->setHitSelectionMapUInt("maxIndex");
1832  this->setHitSelectionMap("chargeOnEdges");
1833  this->setHitSelectionMap("chargeAsymmetry");
1834  this->setHitSelectionMap("chargeLRplus");
1835  this->setHitSelectionMap("chargeLRminus");
1836  this->setHitSelectionMap("sOverN");
1837 
1838  this->setHitSelectionMap("chargePixel");
1839  this->setHitSelectionMapUInt("widthX");
1840  this->setHitSelectionMapUInt("widthY");
1841 
1842  this->setHitSelectionMap("baryStripX");
1843  this->setHitSelectionMap("baryStripY");
1844  this->setHitSelectionMap("clusterProbabilityXY");
1845  this->setHitSelectionMap("clusterProbabilityQ");
1846  this->setHitSelectionMap("clusterProbabilityXYQ");
1847  this->setHitSelectionMap("logClusterProbability");
1848  this->setHitSelectionMapUInt("isOnEdge");
1849  this->setHitSelectionMapUInt("hasBadPixels");
1850  this->setHitSelectionMapUInt("spansTwoRoc");
1851  this->setHitSelectionMapUInt("qBin");
1852 
1853  this->setHitSelectionMap("phiSens");
1854  this->setHitSelectionMap("phiSensX");
1855  this->setHitSelectionMap("phiSensY");
1856  this->setHitSelectionMap("resX");
1857  this->setHitSelectionMap("norResX");
1858  this->setHitSelectionMap("probX");
1859  this->setHitSelectionMap("errXHit");
1860  this->setHitSelectionMap("errXTrk");
1861  this->setHitSelectionMap("errX");
1862  this->setHitSelectionMap("errX2");
1863 
1864  this->setHitSelectionMap("resY");
1865  this->setHitSelectionMap("norResY");
1866  this->setHitSelectionMap("probY");
1867  this->setHitSelectionMap("errYHit");
1868  this->setHitSelectionMap("errYTrk");
1869  this->setHitSelectionMap("errY");
1870  this->setHitSelectionMap("errY2");
1871 
1872  edm::LogInfo("HitSelector") << "applying hit cuts ...";
1873  bool emptyMap(true);
1874  for (auto& i_hitSelection : m_hitSelection_) {
1875  if (!i_hitSelection.second.empty()) {
1876  int entry(1);
1877  double intervalBegin(999.);
1878  for (std::vector<double>::iterator i_hitInterval = i_hitSelection.second.begin();
1879  i_hitInterval != i_hitSelection.second.end();
1880  ++entry) {
1881  if (entry % 2 == 1) {
1882  intervalBegin = *i_hitInterval;
1883  ++i_hitInterval;
1884  } else {
1885  if (intervalBegin > *i_hitInterval) {
1886  edm::LogError("HitSelector") << "INVALID Interval selected for " << i_hitSelection.first << ":\t"
1887  << intervalBegin << " > " << (*i_hitInterval) << "\n ... delete Selection for "
1888  << i_hitSelection.first;
1889  i_hitSelection.second.clear();
1890  i_hitInterval = i_hitSelection.second.begin(); //emptyMap = true; i_hitSelection = m_hitSelection_.begin();
1891  } else {
1892  edm::LogInfo("HitSelector") << "Interval selected for " << i_hitSelection.first << ":\t" << intervalBegin
1893  << ", " << (*i_hitInterval);
1894  ++i_hitInterval;
1895  }
1896  }
1897  }
1898  if (!i_hitSelection.second.empty())
1899  emptyMap = false;
1900  }
1901  }
1902 
1903  bool emptyMapUInt(true);
1904  for (auto& i_hitSelection : m_hitSelectionUInt_) {
1905  if (!i_hitSelection.second.empty()) {
1906  int entry(1);
1907  unsigned int intervalBegin(999);
1908  for (std::vector<unsigned int>::iterator i_hitInterval = i_hitSelection.second.begin();
1909  i_hitInterval != i_hitSelection.second.end();
1910  ++entry) {
1911  if (entry % 2 == 1) {
1912  intervalBegin = *i_hitInterval;
1913  ++i_hitInterval;
1914  } else {
1915  if (intervalBegin > *i_hitInterval) {
1916  edm::LogError("HitSelector") << "INVALID Interval selected for " << i_hitSelection.first << ":\t"
1917  << intervalBegin << " > " << (*i_hitInterval) << "\n ... delete Selection for "
1918  << i_hitSelection.first;
1919  i_hitSelection.second.clear();
1920  i_hitInterval = i_hitSelection.second.begin(); //emptyMap = true; i_hitSelection = m_hitSelection_.begin();
1921  } else {
1922  edm::LogInfo("HitSelector") << "Interval selected for " << i_hitSelection.first << ":\t" << intervalBegin
1923  << ", " << (*i_hitInterval);
1924  ++i_hitInterval;
1925  }
1926  }
1927  }
1928  if (!i_hitSelection.second.empty())
1929  emptyMapUInt = false;
1930  }
1931  }
1932 
1933  if (emptyMap && emptyMapUInt) {
1934  m_hitSelection_.clear();
1935  m_hitSelectionUInt_.clear();
1936  edm::LogInfo("HitSelector") << "NO hit cuts applied";
1937  }
1938  return;
1939 }
1940 
1943  std::vector<double> v_cutVariable(parSet.getParameter<std::vector<double> >(cutVariable));
1944  if (v_cutVariable.size() % 2 == 1) {
1945  edm::LogError("HitSelector") << "Invalid Hit Selection for " << cutVariable
1946  << ": need even number of arguments (intervals)"
1947  << "\n ... delete Selection for " << cutVariable;
1948  v_cutVariable.clear();
1949  m_hitSelection_[cutVariable] = v_cutVariable;
1950  return;
1951  }
1952  m_hitSelection_[cutVariable] = v_cutVariable;
1953  return;
1954 }
1955 
1958  std::vector<unsigned int> v_cutVariable(parSet.getParameter<std::vector<unsigned int> >(cutVariable));
1959  if (v_cutVariable.size() % 2 == 1) {
1960  edm::LogError("HitSelector") << "Invalid Hit Selection for " << cutVariable
1961  << ": need even number of arguments (intervals)"
1962  << "\n ... delete Selection for " << cutVariable;
1963  v_cutVariable.clear();
1964  m_hitSelectionUInt_[cutVariable] = v_cutVariable;
1965  return;
1966  }
1967  m_hitSelectionUInt_[cutVariable] = v_cutVariable;
1968  return;
1969 }
1970 
1971 // -----------------------------------------------------------------------------------------------------------
1972 
1974  if (hitParams.hitState == TrackStruct::notInTracker)
1975  return false;
1976  if (hitParams.hitState == TrackStruct::invalid || hitParams.hitState == TrackStruct::negativeError)
1977  return false;
1978 
1979  bool isGoodHit(true);
1980  bool isGoodHitX(true);
1981  bool isGoodHitY(true);
1982 
1983  for (auto& i_hitSelection : m_hitSelection_) {
1984  const std::string& hitSelection(i_hitSelection.first);
1985  const std::vector<double>& v_hitSelection(i_hitSelection.second);
1986  if (v_hitSelection.empty())
1987  continue;
1988 
1989  // For pixel and strip sectors in common
1990  if (hitSelection == "phiSens") {
1991  if (!this->inDoubleInterval(v_hitSelection, hitParams.phiSens))
1992  isGoodHit = false;
1993  } else if (hitSelection == "phiSensX") {
1994  if (!this->inDoubleInterval(v_hitSelection, hitParams.phiSensX))
1995  isGoodHit = false;
1996  } else if (hitSelection == "phiSensY") {
1997  if (!this->inDoubleInterval(v_hitSelection, hitParams.phiSensY))
1998  isGoodHit = false;
1999  }
2000 
2001  else if (hitSelection == "resX") {
2002  if (!this->inDoubleInterval(v_hitSelection, hitParams.resX))
2003  isGoodHitX = false;
2004  } else if (hitSelection == "norResX") {
2005  if (!this->inDoubleInterval(v_hitSelection, hitParams.norResX))
2006  isGoodHitX = false;
2007  } else if (hitSelection == "probX") {
2008  if (!this->inDoubleInterval(v_hitSelection, hitParams.probX))
2009  isGoodHitX = false;
2010  } else if (hitSelection == "errXHit") {
2011  if (!this->inDoubleInterval(v_hitSelection, hitParams.errXHit))
2012  isGoodHitX = false;
2013  } else if (hitSelection == "errXTrk") {
2014  if (!this->inDoubleInterval(v_hitSelection, hitParams.errXTrk))
2015  isGoodHitX = false;
2016  } else if (hitSelection == "errX") {
2017  if (!this->inDoubleInterval(v_hitSelection, hitParams.errX))
2018  isGoodHitX = false;
2019  } else if (hitSelection == "errX2") {
2020  if (!this->inDoubleInterval(v_hitSelection, hitParams.errX2))
2021  isGoodHitX = false;
2022  }
2023 
2024  // For pixel only
2025  if (hitParams.isPixelHit) {
2026  if (hitSelection == "chargePixel") {
2027  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargePixel))
2028  isGoodHit = false;
2029  } else if (hitSelection == "clusterProbabilityXY") {
2030  if (!this->inDoubleInterval(v_hitSelection, hitParams.clusterProbabilityXY))
2031  isGoodHit = false;
2032  } else if (hitSelection == "clusterProbabilityQ") {
2033  if (!this->inDoubleInterval(v_hitSelection, hitParams.clusterProbabilityQ))
2034  isGoodHit = false;
2035  } else if (hitSelection == "clusterProbabilityXYQ") {
2036  if (!this->inDoubleInterval(v_hitSelection, hitParams.clusterProbabilityXYQ))
2037  isGoodHit = false;
2038  } else if (hitSelection == "logClusterProbability") {
2039  if (!this->inDoubleInterval(v_hitSelection, hitParams.logClusterProbability))
2040  isGoodHit = false;
2041  }
2042 
2043  else if (hitSelection == "baryStripX") {
2044  if (!this->inDoubleInterval(v_hitSelection, hitParams.baryStripX))
2045  isGoodHitX = false;
2046  } else if (hitSelection == "baryStripY") {
2047  if (!this->inDoubleInterval(v_hitSelection, hitParams.baryStripY))
2048  isGoodHitY = false;
2049  }
2050 
2051  else if (hitSelection == "resY") {
2052  if (!this->inDoubleInterval(v_hitSelection, hitParams.resY))
2053  isGoodHitY = false;
2054  } else if (hitSelection == "norResY") {
2055  if (!this->inDoubleInterval(v_hitSelection, hitParams.norResY))
2056  isGoodHitY = false;
2057  } else if (hitSelection == "probY") {
2058  if (!this->inDoubleInterval(v_hitSelection, hitParams.probY))
2059  isGoodHitY = false;
2060  } else if (hitSelection == "errYHit") {
2061  if (!this->inDoubleInterval(v_hitSelection, hitParams.errYHit))
2062  isGoodHitY = false;
2063  } else if (hitSelection == "errYTrk") {
2064  if (!this->inDoubleInterval(v_hitSelection, hitParams.errYTrk))
2065  isGoodHitY = false;
2066  } else if (hitSelection == "errY") {
2067  if (!this->inDoubleInterval(v_hitSelection, hitParams.errY))
2068  isGoodHitY = false;
2069  } else if (hitSelection == "errY2") {
2070  if (!this->inDoubleInterval(v_hitSelection, hitParams.errY2))
2071  isGoodHitY = false;
2072  }
2073  } else { // For strip only
2074  if (hitSelection == "widthProj") {
2075  if (!this->inDoubleInterval(v_hitSelection, hitParams.projWidth))
2076  isGoodHit = false;
2077  } else if (hitSelection == "widthDiff") {
2078  if (!this->inDoubleInterval(v_hitSelection, hitParams.projWidth - static_cast<float>(hitParams.widthX)))
2079  isGoodHit = false;
2080  } else if (hitSelection == "charge") {
2081  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargeStrip))
2082  isGoodHit = false;
2083  } else if (hitSelection == "maxCharge") {
2084  if (!this->inDoubleInterval(v_hitSelection, hitParams.maxCharge))
2085  isGoodHit = false;
2086  } else if (hitSelection == "chargeOnEdges") {
2087  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargeOnEdges))
2088  isGoodHit = false;
2089  } else if (hitSelection == "chargeAsymmetry") {
2090  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargeAsymmetry))
2091  isGoodHit = false;
2092  } else if (hitSelection == "chargeLRplus") {
2093  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargeLRplus))
2094  isGoodHit = false;
2095  } else if (hitSelection == "chargeLRminus") {
2096  if (!this->inDoubleInterval(v_hitSelection, hitParams.chargeLRminus))
2097  isGoodHit = false;
2098  } else if (hitSelection == "sOverN") {
2099  if (!this->inDoubleInterval(v_hitSelection, hitParams.sOverN))
2100  isGoodHit = false;
2101  }
2102  }
2103  }
2104 
2105  for (auto& i_hitSelection : m_hitSelectionUInt_) {
2106  const std::string& hitSelection(i_hitSelection.first);
2107  const std::vector<unsigned int>& v_hitSelection(i_hitSelection.second);
2108  if (v_hitSelection.empty())
2109  continue;
2110 
2111  // For pixel and strip sectors in common
2112 
2113  // For pixel only
2114  if (hitParams.isPixelHit) {
2115  if (hitSelection == "isOnEdge") {
2116  if (!this->inUintInterval(v_hitSelection, hitParams.isOnEdge))
2117  isGoodHit = false;
2118  } else if (hitSelection == "hasBadPixels") {
2119  if (!this->inUintInterval(v_hitSelection, hitParams.hasBadPixels))
2120  isGoodHit = false;
2121  } else if (hitSelection == "spansTwoRoc") {
2122  if (!this->inUintInterval(v_hitSelection, hitParams.spansTwoRoc))
2123  isGoodHit = false;
2124  } else if (hitSelection == "qBin") {
2125  if (!this->inUintInterval(v_hitSelection, hitParams.qBin))
2126  isGoodHit = false;
2127  }
2128 
2129  else if (hitSelection == "widthX") {
2130  if (!this->inUintInterval(v_hitSelection, hitParams.widthX))
2131  isGoodHitX = false;
2132  } else if (hitSelection == "widthY") {
2133  if (!this->inUintInterval(v_hitSelection, hitParams.widthY))
2134  isGoodHitY = false;
2135  }
2136  } else { // For strip only
2137  if (hitSelection == "width") {
2138  if (!this->inUintInterval(v_hitSelection, hitParams.widthX))
2139  isGoodHit = false;
2140  } else if (hitSelection == "edgeStrips") {
2141  if (!this->inUintInterval(v_hitSelection, hitParams.maxStrip, hitParams.maxStripInv))
2142  isGoodHit = false;
2143  } else if (hitSelection == "maxIndex") {
2144  if (!this->inUintInterval(v_hitSelection, hitParams.maxIndex))
2145  isGoodHit = false;
2146  }
2147  }
2148  }
2149 
2150  if (hitParams.isPixelHit) {
2151  hitParams.goodXMeasurement = isGoodHit && isGoodHitX;
2152  hitParams.goodYMeasurement = isGoodHit && isGoodHitY;
2153  } else {
2154  hitParams.goodXMeasurement = isGoodHit && isGoodHitX;
2155  hitParams.goodYMeasurement = false;
2156  }
2157 
2158  if (!hitParams.goodXMeasurement && !hitParams.goodYMeasurement)
2159  return false;
2160  else
2161  return true;
2162 }
2163 
2164 bool ApeEstimator::inDoubleInterval(const std::vector<double>& v_hitSelection, const float variable) const {
2165  int entry(0);
2166  double intervalBegin(999.);
2167  bool isSelected(false);
2168  for (auto const& i_hitInterval : v_hitSelection) {
2169  ++entry;
2170  if (entry % 2 == 1)
2171  intervalBegin = i_hitInterval;
2172  else if (variable >= intervalBegin && variable < i_hitInterval)
2173  isSelected = true;
2174  }
2175  return isSelected;
2176 }
2177 
2178 bool ApeEstimator::inUintInterval(const std::vector<unsigned int>& v_hitSelection,
2179  const unsigned int variable,
2180  const unsigned int variable2) const {
2181  int entry(0);
2182  unsigned int intervalBegin(999);
2183  bool isSelected(false);
2184  for (auto i_hitInterval : v_hitSelection) {
2185  ++entry;
2186  if (entry % 2 == 1)
2187  intervalBegin = i_hitInterval;
2188  else if (variable >= intervalBegin && variable <= i_hitInterval) {
2189  if (variable2 == 999 || (variable2 >= intervalBegin && variable2 <= i_hitInterval))
2190  isSelected = true;
2191  }
2192  }
2193  return isSelected;
2194 }
2195 
2196 // -----------------------------------------------------------------------------------------------------------
2197 
2199  unsigned int goodHitsPerTrack(trackStruct.v_hitParams.size());
2200  tkDetector_.HitsGood->Fill(goodHitsPerTrack);
2201  tkDetector_.HitsGoodVsHitsValid->Fill(trackStruct.trkParams.hitsValid, goodHitsPerTrack);
2202  tkDetector_.PHitsGoodVsHitsValid->Fill(trackStruct.trkParams.hitsValid, goodHitsPerTrack);
2203 
2204  if (parameterSet_.getParameter<bool>("applyTrackCuts")) {
2205  // which tracks to take? need min. nr. of selected hits?
2206  if (goodHitsPerTrack < minGoodHitsPerTrack_)
2207  return;
2208  }
2209 
2210  tkDetector_.HitsSize->Fill(trackStruct.trkParams.hitsSize);
2211  tkDetector_.HitsValid->Fill(trackStruct.trkParams.hitsValid);
2212  tkDetector_.HitsInvalid->Fill(trackStruct.trkParams.hitsInvalid);
2213  tkDetector_.Hits2D->Fill(trackStruct.trkParams.hits2D);
2214  tkDetector_.LayersMissed->Fill(trackStruct.trkParams.layersMissed);
2215  tkDetector_.HitsPixel->Fill(trackStruct.trkParams.hitsPixel);
2216  tkDetector_.HitsStrip->Fill(trackStruct.trkParams.hitsStrip);
2217  tkDetector_.Charge->Fill(trackStruct.trkParams.charge);
2218  tkDetector_.Chi2->Fill(trackStruct.trkParams.chi2);
2219  tkDetector_.Ndof->Fill(trackStruct.trkParams.ndof);
2220  tkDetector_.NorChi2->Fill(trackStruct.trkParams.norChi2);
2221  tkDetector_.Prob->Fill(trackStruct.trkParams.prob);
2222  tkDetector_.Eta->Fill(trackStruct.trkParams.eta);
2223  tkDetector_.EtaErr->Fill(trackStruct.trkParams.etaErr);
2224  tkDetector_.EtaSig->Fill(trackStruct.trkParams.eta / trackStruct.trkParams.etaErr);
2225  tkDetector_.Theta->Fill(trackStruct.trkParams.theta * 180. / M_PI);
2226  tkDetector_.Phi->Fill(trackStruct.trkParams.phi * 180. / M_PI);
2227  tkDetector_.PhiErr->Fill(trackStruct.trkParams.phiErr * 180. / M_PI);
2228  tkDetector_.PhiSig->Fill(trackStruct.trkParams.phi / trackStruct.trkParams.phiErr);
2229  tkDetector_.D0Beamspot->Fill(trackStruct.trkParams.d0Beamspot);
2230  tkDetector_.D0BeamspotErr->Fill(trackStruct.trkParams.d0BeamspotErr);
2231  tkDetector_.D0BeamspotSig->Fill(trackStruct.trkParams.d0Beamspot / trackStruct.trkParams.d0BeamspotErr);
2232  tkDetector_.Dz->Fill(trackStruct.trkParams.dz);
2233  tkDetector_.DzErr->Fill(trackStruct.trkParams.dzErr);
2234  tkDetector_.DzSig->Fill(trackStruct.trkParams.dz / trackStruct.trkParams.dzErr);
2235  tkDetector_.P->Fill(trackStruct.trkParams.p);
2236  tkDetector_.Pt->Fill(trackStruct.trkParams.pt);
2237  tkDetector_.PtErr->Fill(trackStruct.trkParams.ptErr);
2238  tkDetector_.PtSig->Fill(trackStruct.trkParams.pt / trackStruct.trkParams.ptErr);
2239  tkDetector_.MeanAngle->Fill(trackStruct.trkParams.meanPhiSensToNorm * 180. / M_PI);
2240 
2241  tkDetector_.MeanAngleVsHits->Fill(trackStruct.trkParams.hitsSize,
2242  trackStruct.trkParams.meanPhiSensToNorm * 180. / M_PI);
2243  tkDetector_.HitsPixelVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.hitsPixel);
2244  tkDetector_.HitsPixelVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.hitsPixel);
2245  tkDetector_.HitsStripVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.hitsStrip);
2246  tkDetector_.HitsStripVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.hitsStrip);
2247  tkDetector_.PtVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.pt);
2248  tkDetector_.PtVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.pt);
2249 
2250  tkDetector_.PMeanAngleVsHits->Fill(trackStruct.trkParams.hitsSize,
2251  trackStruct.trkParams.meanPhiSensToNorm * 180. / M_PI);
2252  tkDetector_.PHitsPixelVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.hitsPixel);
2253  tkDetector_.PHitsPixelVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.hitsPixel);
2254  tkDetector_.PHitsStripVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.hitsStrip);
2255  tkDetector_.PHitsStripVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.hitsStrip);
2256  tkDetector_.PPtVsEta->Fill(trackStruct.trkParams.eta, trackStruct.trkParams.pt);
2257  tkDetector_.PPtVsTheta->Fill(trackStruct.trkParams.theta * 180. / M_PI, trackStruct.trkParams.pt);
2258 
2259  for (auto& i_hit : trackStruct.v_hitParams) {
2260  const TrackStruct::HitParameterStruct& hit(i_hit);
2261  //Put here from earlier method
2263  continue;
2264 
2265  for (auto& i_sector : m_tkSector_) {
2266  bool moduleInSector(false);
2267  for (auto const& i_hitSector : hit.v_sector) {
2268  if (i_sector.first == i_hitSector) {
2269  moduleInSector = true;
2270  break;
2271  }
2272  }
2273  if (!moduleInSector)
2274  continue;
2275  TrackerSectorStruct& sector(i_sector.second);
2276 
2277  if (hit.goodXMeasurement) {
2278  std::map<std::string, TrackerSectorStruct::CorrelationHists>& m_corrHists(sector.m_correlationHistsX);
2279 
2280  // Cluster and Hit Parameters
2281  this->fillHitHistsXForAnalyzerMode(hit, sector);
2282 
2283  // Track Parameters
2284  m_corrHists["HitsValid"].fillCorrHistsX(hit, trackStruct.trkParams.hitsValid);
2285  m_corrHists["HitsGood"].fillCorrHistsX(hit, goodHitsPerTrack);
2286  m_corrHists["HitsInvalid"].fillCorrHistsX(hit, trackStruct.trkParams.hitsInvalid);
2287  m_corrHists["Hits2D"].fillCorrHistsX(hit, trackStruct.trkParams.hits2D);
2288  m_corrHists["LayersMissed"].fillCorrHistsX(hit, trackStruct.trkParams.layersMissed);
2289  m_corrHists["HitsPixel"].fillCorrHistsX(hit, trackStruct.trkParams.hitsPixel);
2290  m_corrHists["HitsStrip"].fillCorrHistsX(hit, trackStruct.trkParams.hitsStrip);
2291  m_corrHists["NorChi2"].fillCorrHistsX(hit, trackStruct.trkParams.norChi2);
2292  m_corrHists["Theta"].fillCorrHistsX(hit, trackStruct.trkParams.theta * 180. / M_PI);
2293  m_corrHists["Phi"].fillCorrHistsX(hit, trackStruct.trkParams.phi * 180. / M_PI);
2294  m_corrHists["D0Beamspot"].fillCorrHistsX(hit, trackStruct.trkParams.d0Beamspot);
2295  m_corrHists["Dz"].fillCorrHistsX(hit, trackStruct.trkParams.dz);
2296  m_corrHists["Pt"].fillCorrHistsX(hit, trackStruct.trkParams.pt);
2297  m_corrHists["P"].fillCorrHistsX(hit, trackStruct.trkParams.p);
2298  m_corrHists["InvP"].fillCorrHistsX(hit, 1. / trackStruct.trkParams.p);
2299  m_corrHists["MeanAngle"].fillCorrHistsX(hit, trackStruct.trkParams.meanPhiSensToNorm * 180. / M_PI);
2300  }
2301 
2302  if (hit.goodYMeasurement) {
2303  std::map<std::string, TrackerSectorStruct::CorrelationHists>& m_corrHists(sector.m_correlationHistsY);
2304 
2305  // Cluster and Hit Parameters
2306  this->fillHitHistsYForAnalyzerMode(hit, sector);
2307 
2308  // Track Parameters
2309  m_corrHists["HitsValid"].fillCorrHistsY(hit, trackStruct.trkParams.hitsValid);
2310  m_corrHists["HitsGood"].fillCorrHistsY(hit, goodHitsPerTrack);
2311  m_corrHists["HitsInvalid"].fillCorrHistsY(hit, trackStruct.trkParams.hitsInvalid);
2312  m_corrHists["Hits2D"].fillCorrHistsY(hit, trackStruct.trkParams.hits2D);
2313  m_corrHists["LayersMissed"].fillCorrHistsY(hit, trackStruct.trkParams.layersMissed);
2314  m_corrHists["HitsPixel"].fillCorrHistsY(hit, trackStruct.trkParams.hitsPixel);
2315  m_corrHists["HitsStrip"].fillCorrHistsY(hit, trackStruct.trkParams.hitsStrip);
2316  m_corrHists["NorChi2"].fillCorrHistsY(hit, trackStruct.trkParams.norChi2);
2317  m_corrHists["Theta"].fillCorrHistsY(hit, trackStruct.trkParams.theta * 180. / M_PI);
2318  m_corrHists["Phi"].fillCorrHistsY(hit, trackStruct.trkParams.phi * 180. / M_PI);
2319  m_corrHists["D0Beamspot"].fillCorrHistsY(hit, trackStruct.trkParams.d0Beamspot);
2320  m_corrHists["Dz"].fillCorrHistsY(hit, trackStruct.trkParams.dz);
2321  m_corrHists["Pt"].fillCorrHistsY(hit, trackStruct.trkParams.pt);
2322  m_corrHists["P"].fillCorrHistsY(hit, trackStruct.trkParams.p);
2323  m_corrHists["InvP"].fillCorrHistsY(hit, 1. / trackStruct.trkParams.p);
2324  m_corrHists["MeanAngle"].fillCorrHistsY(hit, trackStruct.trkParams.meanPhiSensToNorm * 180. / M_PI);
2325  }
2326 
2327  // Special Histograms
2328  for (auto& i_sigmaX : sector.m_sigmaX) {
2329  for (auto& iHist : i_sigmaX.second) {
2330  if (i_sigmaX.first == "sigmaXHit")
2331  iHist->Fill(hit.errXHit * 10000.);
2332  else if (i_sigmaX.first == "sigmaXTrk")
2333  iHist->Fill(hit.errXTrk * 10000.);
2334  else if (i_sigmaX.first == "sigmaX")
2335  iHist->Fill(hit.errX * 10000.);
2336  }
2337  }
2338  for (auto& i_sigmaY : sector.m_sigmaY) {
2339  for (auto& iHist : i_sigmaY.second) {
2340  if (i_sigmaY.first == "sigmaYHit")
2341  iHist->Fill(hit.errYHit * 10000.);
2342  else if (i_sigmaY.first == "sigmaYTrk")
2343  iHist->Fill(hit.errYTrk * 10000.);
2344  else if (i_sigmaY.first == "sigmaY")
2345  iHist->Fill(hit.errY * 10000.);
2346  }
2347  }
2348  }
2349  }
2350 }
2351 
2353  TrackerSectorStruct& sector) {
2354  std::map<std::string, TrackerSectorStruct::CorrelationHists>& m_corrHists(sector.m_correlationHistsX);
2355 
2356  // Cluster Parameters
2357  m_corrHists["WidthX"].fillCorrHistsX(hit, hit.widthX);
2358  m_corrHists["BaryStripX"].fillCorrHistsX(hit, hit.baryStripX);
2359 
2360  if (hit.isPixelHit) {
2361  m_corrHists["ChargePixel"].fillCorrHistsX(hit, hit.chargePixel);
2362  m_corrHists["ClusterProbXY"].fillCorrHistsX(hit, hit.clusterProbabilityXY);
2363  m_corrHists["ClusterProbQ"].fillCorrHistsX(hit, hit.clusterProbabilityQ);
2364  m_corrHists["ClusterProbXYQ"].fillCorrHistsX(hit, hit.clusterProbabilityXYQ);
2365  m_corrHists["LogClusterProb"].fillCorrHistsX(hit, hit.logClusterProbability);
2366  m_corrHists["IsOnEdge"].fillCorrHistsX(hit, hit.isOnEdge);
2367  m_corrHists["HasBadPixels"].fillCorrHistsX(hit, hit.hasBadPixels);
2368  m_corrHists["SpansTwoRoc"].fillCorrHistsX(hit, hit.spansTwoRoc);
2369  m_corrHists["QBin"].fillCorrHistsX(hit, hit.qBin);
2370 
2371  } else {
2372  m_corrHists["ChargeStrip"].fillCorrHistsX(hit, hit.chargeStrip);
2373  m_corrHists["MaxStrip"].fillCorrHistsX(hit, hit.maxStrip);
2374  m_corrHists["MaxCharge"].fillCorrHistsX(hit, hit.maxCharge);
2375  m_corrHists["MaxIndex"].fillCorrHistsX(hit, hit.maxIndex);
2376  m_corrHists["ChargeOnEdges"].fillCorrHistsX(hit, hit.chargeOnEdges);
2377  m_corrHists["ChargeAsymmetry"].fillCorrHistsX(hit, hit.chargeAsymmetry);
2378  m_corrHists["ChargeLRplus"].fillCorrHistsX(hit, hit.chargeLRplus);
2379  m_corrHists["ChargeLRminus"].fillCorrHistsX(hit, hit.chargeLRminus);
2380  m_corrHists["SOverN"].fillCorrHistsX(hit, hit.sOverN);
2381  m_corrHists["WidthProj"].fillCorrHistsX(hit, hit.projWidth);
2382  m_corrHists["WidthDiff"].fillCorrHistsX(hit, hit.projWidth - static_cast<float>(hit.widthX));
2383 
2384  sector.WidthVsWidthProjected->Fill(hit.projWidth, hit.widthX);
2385  sector.PWidthVsWidthProjected->Fill(hit.projWidth, hit.widthX);
2386 
2387  sector.WidthDiffVsMaxStrip->Fill(hit.maxStrip, hit.projWidth - static_cast<float>(hit.widthX));
2388  sector.PWidthDiffVsMaxStrip->Fill(hit.maxStrip, hit.projWidth - static_cast<float>(hit.widthX));
2389 
2390  sector.WidthDiffVsSigmaXHit->Fill(hit.errXHit, hit.projWidth - static_cast<float>(hit.widthX));
2391  sector.PWidthDiffVsSigmaXHit->Fill(hit.errXHit, hit.projWidth - static_cast<float>(hit.widthX));
2392 
2393  sector.WidthVsPhiSensX->Fill(hit.phiSensX * 180. / M_PI, hit.widthX);
2394  sector.PWidthVsPhiSensX->Fill(hit.phiSensX * 180. / M_PI, hit.widthX);
2395  }
2396 
2397  // Hit Parameters
2398  m_corrHists["SigmaXHit"].fillCorrHistsX(hit, hit.errXHit * 10000.);
2399  m_corrHists["SigmaXTrk"].fillCorrHistsX(hit, hit.errXTrk * 10000.);
2400  m_corrHists["SigmaX"].fillCorrHistsX(hit, hit.errX * 10000.);
2401 
2402  m_corrHists["PhiSens"].fillCorrHistsX(hit, hit.phiSens * 180. / M_PI);
2403  m_corrHists["PhiSensX"].fillCorrHistsX(hit, hit.phiSensX * 180. / M_PI);
2404  m_corrHists["PhiSensY"].fillCorrHistsX(hit, hit.phiSensY * 180. / M_PI);
2405 
2406  sector.XHit->Fill(hit.xHit);
2407  sector.XTrk->Fill(hit.xTrk);
2408  sector.SigmaX2->Fill(hit.errX2 * 10000. * 10000.);
2409 
2410  sector.ResX->Fill(hit.resX * 10000.);
2411  sector.NorResX->Fill(hit.norResX);
2412 
2413  sector.ProbX->Fill(hit.probX);
2414 
2415  sector.PhiSensXVsBarycentreX->Fill(hit.baryStripX, hit.phiSensX * 180. / M_PI);
2416  sector.PPhiSensXVsBarycentreX->Fill(hit.baryStripX, hit.phiSensX * 180. / M_PI);
2417 }
2418 
2420  TrackerSectorStruct& sector) {
2421  std::map<std::string, TrackerSectorStruct::CorrelationHists>& m_corrHists(sector.m_correlationHistsY);
2422  // Do not fill anything for strip
2423  if (!hit.isPixelHit)
2424  return;
2425 
2426  // Cluster Parameters
2427  m_corrHists["WidthY"].fillCorrHistsY(hit, hit.widthY);
2428  m_corrHists["BaryStripY"].fillCorrHistsY(hit, hit.baryStripY);
2429 
2430  m_corrHists["ChargePixel"].fillCorrHistsY(hit, hit.chargePixel);
2431  m_corrHists["ClusterProbXY"].fillCorrHistsY(hit, hit.clusterProbabilityXY);
2432  m_corrHists["ClusterProbQ"].fillCorrHistsY(hit, hit.clusterProbabilityQ);
2433  m_corrHists["ClusterProbXYQ"].fillCorrHistsY(hit, hit.clusterProbabilityXYQ);
2434  m_corrHists["LogClusterProb"].fillCorrHistsY(hit, hit.logClusterProbability);
2435  m_corrHists["IsOnEdge"].fillCorrHistsY(hit, hit.isOnEdge);
2436  m_corrHists["HasBadPixels"].fillCorrHistsY(hit, hit.hasBadPixels);
2437  m_corrHists["SpansTwoRoc"].fillCorrHistsY(hit, hit.spansTwoRoc);
2438  m_corrHists["QBin"].fillCorrHistsY(hit, hit.qBin);
2439 
2440  // Hit Parameters
2441  m_corrHists["SigmaYHit"].fillCorrHistsY(hit, hit.errYHit * 10000.);
2442  m_corrHists["SigmaYTrk"].fillCorrHistsY(hit, hit.errYTrk * 10000.);
2443  m_corrHists["SigmaY"].fillCorrHistsY(hit, hit.errY * 10000.);
2444 
2445  m_corrHists["PhiSens"].fillCorrHistsY(hit, hit.phiSens * 180. / M_PI);
2446  m_corrHists["PhiSensX"].fillCorrHistsY(hit, hit.phiSensX * 180. / M_PI);
2447  m_corrHists["PhiSensY"].fillCorrHistsY(hit, hit.phiSensY * 180. / M_PI);
2448 
2449  sector.YHit->Fill(hit.yHit);
2450  sector.YTrk->Fill(hit.yTrk);
2451  sector.SigmaY2->Fill(hit.errY2 * 10000. * 10000.);
2452 
2453  sector.ResY->Fill(hit.resY * 10000.);
2454  sector.NorResY->Fill(hit.norResY);
2455 
2456  sector.ProbY->Fill(hit.probY);
2457 
2458  sector.PhiSensYVsBarycentreY->Fill(hit.baryStripY, hit.phiSensY * 180. / M_PI);
2459  sector.PPhiSensYVsBarycentreY->Fill(hit.baryStripY, hit.phiSensY * 180. / M_PI);
2460 }
2461 
2463  unsigned int goodHitsPerTrack(trackStruct.v_hitParams.size());
2464 
2465  if (parameterSet_.getParameter<bool>("applyTrackCuts")) {
2466  // which tracks to take? need min. nr. of selected hits?
2467  if (goodHitsPerTrack < minGoodHitsPerTrack_)
2468  return;
2469  }
2470 
2471  for (auto const& i_hit : trackStruct.v_hitParams) {
2472  // Put here from earlier method
2473  if (i_hit.hitState == TrackStruct::notAssignedToSectors)
2474  continue;
2475 
2476  for (auto& i_sector : m_tkSector_) {
2477  bool moduleInSector(false);
2478  for (auto const& i_hitSector : i_hit.v_sector) {
2479  if (i_sector.first == i_hitSector) {
2480  moduleInSector = true;
2481  break;
2482  }
2483  }
2484  if (!moduleInSector)
2485  continue;
2486 
2487  if (!calculateApe_)
2488  continue;
2489 
2490  if (i_hit.goodXMeasurement) {
2491  for (auto const& i_errBins : m_resErrBins_) {
2492  // Separate the bins for residual resolution w/o APE, to be consistent within iterations where APE will change (have same hit always in same bin)
2493  // So also fill this value in the histogram sigmaX
2494  // But of course use the normalized residual regarding the APE to have its influence in its width
2495  if (i_hit.errXWoApe < i_errBins.second.first || i_hit.errXWoApe >= i_errBins.second.second) {
2496  continue;
2497  }
2498  i_sector.second.m_binnedHists[i_errBins.first]["sigmaX"]->Fill(i_hit.errXWoApe);
2499  i_sector.second.m_binnedHists[i_errBins.first]["norResX"]->Fill(i_hit.norResX);
2500  break;
2501  }
2502  i_sector.second.ResX->Fill(i_hit.resX * 10000.);
2503  i_sector.second.NorResX->Fill(i_hit.norResX);
2504  }
2505 
2506  if (i_hit.goodYMeasurement) {
2507  for (auto const& i_errBins : m_resErrBins_) {
2508  // Separate the bins for residual resolution w/o APE, to be consistent within iterations where APE will change (have same hit always in same bin)
2509  // So also fill this value in the histogram sigmaY
2510  // But of course use the normalized residual regarding the APE to have its influence in its width
2511  if (i_hit.errYWoApe < i_errBins.second.first || i_hit.errYWoApe >= i_errBins.second.second) {
2512  continue;
2513  }
2514  i_sector.second.m_binnedHists[i_errBins.first]["sigmaY"]->Fill(i_hit.errYWoApe);
2515  i_sector.second.m_binnedHists[i_errBins.first]["norResY"]->Fill(i_hit.norResY);
2516  break;
2517  }
2518  i_sector.second.ResY->Fill(i_hit.resY * 10000.);
2519  i_sector.second.NorResY->Fill(i_hit.norResY);
2520  }
2521  }
2522  }
2523 }
2524 
2525 // -----------------------------------------------------------------------------------------------------------
2526 
2528  // Loop over sectors for calculating APE
2529  for (auto& i_sector : m_tkSector_) {
2530  // Loop over residual error bins to calculate APE for every bin
2531  for (auto const& i_errBins : i_sector.second.m_binnedHists) {
2532  std::map<std::string, TH1*> m_Hists = i_errBins.second;
2533 
2534  // Fitting Parameters
2535  double integralX = m_Hists["norResX"]->Integral();
2536  i_sector.second.EntriesX->SetBinContent(i_errBins.first, integralX);
2537 
2538  if (i_sector.second.isPixel) {
2539  double integralY = m_Hists["norResY"]->Integral();
2540  i_sector.second.EntriesY->SetBinContent(i_errBins.first, integralY);
2541  }
2542  }
2543  }
2544 }
2545 
2546 // -----------------------------------------------------------------------------------------------------------
2547 
2549  // we count SiStrip stereo modules as 2D if selected via countStereoHitAs2D_
2550  // (since they provide theta information)
2551  // --- NO, here it is always set to true ---
2552  if (!hit.isValid() || (hit.dimension() < 2 && !dynamic_cast<const SiStripRecHit1D*>(&hit))) {
2553  return false; // real RecHit1D - but SiStripRecHit1D depends on countStereoHitAs2D_
2554  } else {
2555  const DetId detId(hit.geographicalId());
2556  if (detId.det() == DetId::Tracker) {
2557  if (detId.subdetId() == PixelSubdetector::PixelBarrel || detId.subdetId() == PixelSubdetector::PixelEndcap) {
2558  return true; // pixel is always 2D
2559  } else { // should be SiStrip now
2560  const SiStripDetId stripId(detId);
2561  if (stripId.stereo())
2562  return true; // stereo modules
2563  else if (dynamic_cast<const SiStripRecHit1D*>(&hit) || dynamic_cast<const SiStripRecHit2D*>(&hit))
2564  return false; // rphi modules hit
2565  //the following two are not used any more since ages...
2566  else if (dynamic_cast<const SiStripMatchedRecHit2D*>(&hit))
2567  return true; // matched is 2D
2568  else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(&hit)) {
2569  const ProjectedSiStripRecHit2D* pH = static_cast<const ProjectedSiStripRecHit2D*>(&hit);
2570  return (this->isHit2D(pH->originalHit())); // depends on original...
2571  } else {
2572  edm::LogError("UnkownType") << "@SUB=AlignmentTrackSelector::isHit2D"
2573  << "Tracker hit not in pixel, neither SiStripRecHit[12]D nor "
2574  << "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
2575  return false;
2576  }
2577  }
2578  } else { // not tracker??
2579  edm::LogWarning("DetectorMismatch") << "@SUB=AlignmentTrackSelector::isHit2D"
2580  << "Hit not in tracker with 'official' dimension >=2.";
2581  return true; // dimension() >= 2 so accept that...
2582  }
2583  }
2584  // never reached...
2585 }
2586 
2587 // -----------------------------------------------------------------------------------------------------------
2588 
2589 // ------------ method called to for each event ------------
2592  edm::Handle<reco::BeamSpot> beamSpotHandle;
2593  iEvent.getByToken(offlinebeamSpot_, beamSpotHandle);
2594 
2595  if (beamSpotHandle.isValid()) {
2596  beamSpot = *beamSpotHandle;
2597  } else {
2598  edm::LogError("ApeEstimator") << "No beam spot available from EventSetup"
2599  << "\n...skip event";
2600  return;
2601  }
2602 
2604  iEvent.getByToken(tjTagToken_, m_TrajTracksMap);
2605 
2606  if (analyzerMode_)
2607  tkDetector_.TrkSize->Fill(m_TrajTracksMap->size());
2608 
2609  if (maxTracksPerEvent_ != 0 && m_TrajTracksMap->size() > maxTracksPerEvent_)
2610  return;
2611 
2612  //Creation of (traj,track)
2613  typedef std::pair<const Trajectory*, const reco::Track*> ConstTrajTrackPair;
2614  typedef std::vector<ConstTrajTrackPair> ConstTrajTrackPairCollection;
2615  ConstTrajTrackPairCollection trajTracks;
2616 
2618  for (i_trajTrack = m_TrajTracksMap->begin(); i_trajTrack != m_TrajTracksMap->end(); ++i_trajTrack) {
2619  trajTracks.push_back(ConstTrajTrackPair(&(*(*i_trajTrack).key), &(*(*i_trajTrack).val)));
2620  }
2621 
2622  //Loop over Tracks & Hits
2623  unsigned int trackSizeGood(0);
2624  ConstTrajTrackPairCollection::const_iterator iTrack;
2625  for (iTrack = trajTracks.begin(); iTrack != trajTracks.end(); ++iTrack) {
2626  const Trajectory* traj = (*iTrack).first;
2627  const reco::Track* track = (*iTrack).second;
2628 
2629  TrackStruct trackStruct;
2630  trackStruct.trkParams = this->fillTrackVariables(*track, *traj, beamSpot);
2631 
2632  if (trackCut_)
2633  continue;
2634 
2635  const std::vector<TrajectoryMeasurement> v_meas = (*traj).measurements();
2636 
2637  //Loop over Hits
2638  for (std::vector<TrajectoryMeasurement>::const_iterator i_meas = v_meas.begin(); i_meas != v_meas.end(); ++i_meas) {
2639  TrackStruct::HitParameterStruct hitParams = this->fillHitVariables(*i_meas, iSetup);
2640  if (this->hitSelected(hitParams))
2641  trackStruct.v_hitParams.push_back(hitParams);
2642  }
2643 
2644  if (analyzerMode_)
2645  this->fillHistsForAnalyzerMode(trackStruct);
2646  if (calculateApe_)
2647  this->fillHistsForApeCalculation(trackStruct);
2648 
2649  if (!trackStruct.v_hitParams.empty())
2650  ++trackSizeGood;
2651  }
2652  if (analyzerMode_ && trackSizeGood > 0)
2653  tkDetector_.TrkSizeGood->Fill(trackSizeGood);
2654 }
2655 
2656 // ------------ method called once each job just before starting event loop ------------
2658  this->hitSelection();
2659 
2660  this->sectorBuilder();
2661 
2662  this->residualErrorBinning();
2663 
2664  if (analyzerMode_)
2666 
2667  if (calculateApe_)
2669 
2670  if (analyzerMode_)
2671  this->bookTrackHists();
2672 }
2673 
2674 // ------------ method called once each job just after ending the event loop ------------
2676  if (calculateApe_)
2677  this->calculateAPE();
2678 
2679  edm::LogInfo("HitSelector") << "\nThere are " << counter1 << " negative Errors calculated\n";
2680 }
2681 
2682 //define this as a plug-in
ClusterRef cluster() const
virtual const Topology & topology() const =0
uint8_t maxCharge() const
double p() const
momentum vector magnitude
Definition: TrackBase.h:648
bool valid() const
Definition: LocalError.h:21
bool inDoubleInterval(const std::vector< double > &, const float) const
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:68
std::vector< unsigned int > v_sector
virtual float angularWidth() const =0
const edm::ParameterSet parameterSet_
float xx() const
Definition: LocalError.h:24
double d0Error() const
error on d0
Definition: TrackBase.h:847
virtual float length() const =0
std::map< std::string, std::vector< TH1 * > > m_sigmaX
void hitSelection()
float vv() const
unsigned short lost() const
Number of lost (=invalid) hits on track.
Definition: Track.h:204
float clusterProbability(unsigned int flags=0) const
T y() const
Definition: PV2DBase.h:46
ConstRecHitPointer const & recHit() const
void bookSectorHistsForAnalyzerMode()
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:630
uint32_t stereo() const
Definition: SiStripDetId.h:163
virtual const GeomDetType & type() const
Definition: GeomDet.cc:85
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::pair< uint16_t, uint16_t > chargeLR() const
virtual float originToIntersection() const =0
double theta() const
polar angle
Definition: TrackBase.h:612
std::map< std::string, std::vector< TH1 * > > m_sigmaY
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:124
LocalVector localDirection() const
ApeEstimator(const edm::ParameterSet &)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const bool calculateApe_
void sectorBuilder()
unsigned int counter1
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
float baryStrip() const
T y() const
Definition: PV3DBase.h:63
double etaError() const
error on eta
Definition: TrackBase.h:829
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:678
const Bounds & bounds() const
Definition: Surface.h:120
~ApeEstimator() override
int charge() const
PositionAndError2 radialPositionAndError2(const LocalPoint &, const LocalError &, const RadialStripTopology &)
unsigned int counter3
void fillHitHistsYForAnalyzerMode(const TrackStruct::HitParameterStruct &, TrackerSectorStruct &)
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
unsigned int counter4
uint16_t maxIndex() const
auto stripCharges() const -> decltype(cluster() ->amplitudes())
void calculateAPE()
bool isOnEdge() const
PositionAndError2 rectangularPositionAndError2(const LocalPoint &, const LocalError &)
TrackerDetectorStruct tkDetector_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
LocalError positionError() const
const unsigned int maxTracksPerEvent_
bool hasBadPixels() const
TrackStruct::HitParameterStruct fillHitVariables(const TrajectoryMeasurement &, const edm::EventSetup &)
TProfile * PPhiSensYVsBarycentreY
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void residualErrorBinning()
const bool analyzerMode_
virtual float width() const =0
float localStripLength(const LocalPoint &) const override=0
DataContainer const & measurements() const
Definition: Trajectory.h:196
float signalOverNoise() const
float xy() const
Definition: LocalError.h:25
int iEvent
Definition: GenABIO.cc:224
float getLorentzAngle(const uint32_t &) const
TProfile * PPhiSensXVsBarycentreX
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:684
std::vector< HitParameterStruct > v_hitParams
uint16_t charge() const
float yy() const
Definition: LocalError.h:26
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:582
float stripAngle(float strip) const override=0
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:588
T sqrt(T t)
Definition: SSEVec.h:18
virtual int dimension() const =0
bool isHit2D(const TrackingRecHit &) const
TrackStruct::TrackParameterStruct fillTrackVariables(const reco::Track &, const Trajectory &, const reco::BeamSpot &)
double pt() const
track transverse momentum
Definition: TrackBase.h:654
TrackParameterStruct trkParams
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:808
edm::EDGetTokenT< reco::BeamSpot > offlinebeamSpot_
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
double phiError() const
error on phi
Definition: TrackBase.h:835
float uu() const
uint16_t width() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
bool hitSelected(TrackStruct::HitParameterStruct &) const
ClusterRef cluster() const
bool checkModulePositions(const float, const std::vector< double > &) const
void analyze(const edm::Event &, const edm::EventSetup &) override
T * make(const Args &...args) const
make new ROOT object
unsigned int counter6
const LocalTrajectoryError & localError() const
bool checkModuleBools(const bool, const std::vector< unsigned int > &) const
bool checkModuleIds(const unsigned int, const std::vector< unsigned int > &) const
virtual LocalPoint localPosition() const =0
std::map< unsigned int, TrackerSectorStruct > m_tkSector_
bool isValid() const
Definition: HandleBase.h:74
MeasurementError measurementError(const LocalPoint &, const LocalError &) const override=0
TProfile * PWidthVsWidthProjected
std::map< unsigned int, std::pair< double, double > > m_resErrBins_
bool checkIntervalsForSectors(const unsigned int sectorCounter, const std::vector< double > &) const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
#define M_PI
void bookTrackHists()
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:642
double dzError() const
error on dz
Definition: TrackBase.h:859
SiStripRecHit2D originalHit() const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
int qBin() const
Definition: DetId.h:18
virtual TrackingRecHit const * hit() const
virtual float detHeight() const =0
MeasurementPoint measurementPosition(const LocalPoint &) const override=0
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
uint16_t maxStrip() const
size_type size() const
map size
virtual float thickness() const =0
edm::Service< TFileService > fileService
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:479
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool checkModuleDirections(const int, const std::vector< int > &) const
Detector
Definition: DetId.h:26
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
bool isValid() const
bool inUintInterval(const std::vector< unsigned int > &, const unsigned int, const unsigned int=999) const
std::map< std::string, CorrelationHists > m_correlationHistsY
int sizeY() const
bool IsModuleUsable() const
std::map< unsigned int, ReducedTrackerTreeVariables > m_tkTreeVar_
Pixel cluster – collection of neighboring pixels above threshold.
void beginJob() override
fixed size matrix
unsigned int counter5
HLT enums.
virtual const GeomDetUnit * detUnit() const
void fillHistsForApeCalculation(const TrackStruct &)
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:199
T get() const
Definition: EventSetup.h:71
unsigned int counter2
bool isPixel(HitType hitType)
bool spansTwoROCs() const
double y0() const
y coordinate
Definition: BeamSpot.h:66
const unsigned int minGoodHitsPerTrack_
float y() const
void setHitSelectionMap(const std::string &)
edm::EDGetTokenT< TrajTrackAssociationCollection > tjTagToken_
int charge() const
track electric charge
Definition: TrackBase.h:600
void fillHitHistsXForAnalyzerMode(const TrackStruct::HitParameterStruct &, TrackerSectorStruct &)
std::pair< const Trajectory *, const reco::Track * > ConstTrajTrackPair
Definition: Bounds.h:22
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
void fillHistsForAnalyzerMode(const TrackStruct &)
void bookSectorHistsForApeCalculation()
virtual LocalError localPositionError() const =0
std::map< std::string, std::vector< double > > m_hitSelection_
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
void endJob() override
std::map< std::string, std::vector< unsigned int > > m_hitSelectionUInt_
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:624
T x() const
Definition: PV2DBase.h:45
TProfile * PWidthDiffVsSigmaXHit
int sizeX() const
std::pair< TrackStruct::HitState, PositionAndError2 > StatePositionAndError2
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
void setHitSelectionMapUInt(const std::string &)
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:208
float x() const
LocalError const & localAlignmentError() const
Return local alligment error.
std::map< std::string, CorrelationHists > m_correlationHistsX
void statistics(const TrackerSectorStruct &, const int) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< unsigned int > v_rawId
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:45
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
Our base class.
Definition: SiPixelRecHit.h:23
double x0() const
x coordinate
Definition: BeamSpot.h:64
StatePositionAndError2 positionAndError2(const LocalPoint &, const LocalError &, const TransientTrackingRecHit &)