CMS 3D CMS Logo

PrimaryVertexValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Alignment/OfflineValidation
4 // Class: PrimaryVertexValidation
5 //
13 //
14 // Original Author: Marco Musich
15 // Created: Tue Mar 02 10:39:34 CDT 2010
16 //
17 
18 // system include files
19 #include <memory>
20 #include <vector>
21 #include <regex>
22 #include <cassert>
23 #include <chrono>
24 #include <iomanip>
25 #include <boost/range/adaptor/indexed.hpp>
26 
27 // user include files
29 
30 // ROOT includes
31 #include "TH1F.h"
32 #include "TH2F.h"
33 #include "TF1.h"
34 #include "TVector3.h"
35 #include "TFile.h"
36 #include "TMath.h"
37 #include "TROOT.h"
38 #include "TChain.h"
39 #include "TNtuple.h"
40 #include "TMatrixD.h"
41 #include "TVectorD.h"
42 
43 // CMSSW includes
64 
66 
67 // Constructor
71  ttkToken_(esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"))),
73  topoTokenBR_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()),
75  runInfoTokenBR_(esConsumes<RunInfo, RunInfoRcd, edm::Transition::BeginRun>()),
76  compressionSettings_(iConfig.getUntrackedParameter<int>("compressionSettings", -1)),
77  storeNtuple_(iConfig.getParameter<bool>("storeNtuple")),
78  lightNtupleSwitch_(iConfig.getParameter<bool>("isLightNtuple")),
79  useTracksFromRecoVtx_(iConfig.getParameter<bool>("useTracksFromRecoVtx")),
80  vertexZMax_(iConfig.getUntrackedParameter<double>("vertexZMax", 99.)),
81  intLumi_(iConfig.getUntrackedParameter<double>("intLumi", 0.)),
82  askFirstLayerHit_(iConfig.getParameter<bool>("askFirstLayerHit")),
83  doBPix_(iConfig.getUntrackedParameter<bool>("doBPix", true)),
84  doFPix_(iConfig.getUntrackedParameter<bool>("doFPix", true)),
85  ptOfProbe_(iConfig.getUntrackedParameter<double>("probePt", 0.)),
86  pOfProbe_(iConfig.getUntrackedParameter<double>("probeP", 0.)),
87  etaOfProbe_(iConfig.getUntrackedParameter<double>("probeEta", 2.4)),
88  nHitsOfProbe_(iConfig.getUntrackedParameter<double>("probeNHits", 0.)),
89  nBins_(iConfig.getUntrackedParameter<int>("numberOfBins", 24)),
90  minPt_(iConfig.getUntrackedParameter<double>("minPt", 1.)),
91  maxPt_(iConfig.getUntrackedParameter<double>("maxPt", 20.)),
92  debug_(iConfig.getParameter<bool>("Debug")),
93  runControl_(iConfig.getUntrackedParameter<bool>("runControl", false)),
94  forceBeamSpotContraint_(iConfig.getUntrackedParameter<bool>("forceBeamSpot", false)) {
95  // now do what ever initialization is needed
96  // initialize phase space boundaries
97 
98  usesResource(TFileService::kSharedResource);
99 
100  std::vector<unsigned int> defaultRuns;
101  defaultRuns.push_back(0);
102  runControlNumbers_ = iConfig.getUntrackedParameter<std::vector<unsigned int>>("runControlNumber", defaultRuns);
103 
104  edm::InputTag TrackCollectionTag_ = iConfig.getParameter<edm::InputTag>("TrackCollectionTag");
105  theTrackCollectionToken_ = consumes<reco::TrackCollection>(TrackCollectionTag_);
106 
107  edm::InputTag VertexCollectionTag_ = iConfig.getParameter<edm::InputTag>("VertexCollectionTag");
108  theVertexCollectionToken_ = consumes<reco::VertexCollection>(VertexCollectionTag_);
109 
110  edm::InputTag BeamspotTag_ = iConfig.getParameter<edm::InputTag>("BeamSpotTag");
111  theBeamspotToken_ = consumes<reco::BeamSpot>(BeamspotTag_);
112 
113  // select and configure the track filter
115  std::make_unique<TrackFilterForPVFinding>(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters"));
116  // select and configure the track clusterizer
117  std::string clusteringAlgorithm =
118  iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
119  if (clusteringAlgorithm == "gap") {
121  std::make_unique<GapClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
122  .getParameter<edm::ParameterSet>("TkGapClusParameters"));
123  } else if (clusteringAlgorithm == "DA") {
125  std::make_unique<DAClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
126  .getParameter<edm::ParameterSet>("TkDAClusParameters"));
127  // provide the vectorized version of the clusterizer, if supported by the build
128  } else if (clusteringAlgorithm == "DA_vect") {
130  std::make_unique<DAClusterizerInZ_vect>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
131  .getParameter<edm::ParameterSet>("TkDAClusParameters"));
132  } else {
133  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
134  }
135 
136  theDetails_.histobins = 500;
143 
144  for (int i = PVValHelper::phi; i < PVValHelper::END_OF_PLOTS; i++) {
145  for (int j = PVValHelper::dx; j < PVValHelper::END_OF_TYPES; j++) {
146  auto plot_index = static_cast<PVValHelper::plotVariable>(i);
147  auto res_index = static_cast<PVValHelper::residualType>(j);
148 
149  if (debug_) {
150  edm::LogInfo("PrimaryVertexValidation")
151  << "==> " << std::get<0>(PVValHelper::getTypeString(res_index)) << " " << std::setw(10)
152  << std::get<0>(PVValHelper::getVarString(plot_index)) << std::endl;
153  }
154  if (res_index != PVValHelper::d3D && res_index != PVValHelper::norm_d3D)
155  theDetails_.setMap(res_index,
156  plot_index,
157  theDetails_.getLow(PVValHelper::dxy, plot_index),
158  theDetails_.getHigh(PVValHelper::dxy, plot_index));
159  else
160  theDetails_.setMap(res_index, plot_index, 0., theDetails_.getHigh(PVValHelper::dxy, plot_index));
161  }
162  }
163 
164  edm::LogVerbatim("PrimaryVertexValidation") << "######################################";
165  for (const auto& it : theDetails_.range) {
166  edm::LogVerbatim("PrimaryVertexValidation")
167  << "|" << std::setw(10) << std::get<0>(PVValHelper::getTypeString(it.first.first)) << "|" << std::setw(10)
168  << std::get<0>(PVValHelper::getVarString(it.first.second)) << "| (" << std::setw(5) << it.second.first << ";"
169  << std::setw(5) << it.second.second << ") |" << std::endl;
170  }
171 
174 
175  if (debug_) {
176  edm::LogVerbatim("PrimaryVertexValidation") << "etaBins: ";
178  edm::LogVerbatim("PrimaryVertexValidation") << ieta << " ";
179  }
180  edm::LogVerbatim("PrimaryVertexValidation") << "\n";
181 
182  edm::LogVerbatim("PrimaryVertexValidation") << "phiBins: ";
184  edm::LogVerbatim("PrimaryVertexValidation") << iphi << " ";
185  }
186  edm::LogVerbatim("PrimaryVertexValidation") << "\n";
187  }
188 
189  // create the bins of the pT-binned distributions
190 
191  mypT_bins_ = PVValHelper::makeLogBins<float, nPtBins_>(minPt_, maxPt_);
192 
193  std::string toOutput = "";
194  for (auto ptbin : mypT_bins_) {
195  toOutput += " ";
196  toOutput += std::to_string(ptbin);
197  toOutput += ",";
198  }
199 
200  edm::LogVerbatim("PrimaryVertexValidation") << "######################################\n";
201  edm::LogVerbatim("PrimaryVertexValidation") << "The pT binning is: [" << toOutput << "] \n";
202 }
203 
204 // Destructor
206 //
207 // member functions
208 //
209 
210 // ------------ method called to for each event ------------
212  using namespace std;
213  using namespace reco;
214  using namespace IPTools;
215 
216  if (nBins_ != 24 && debug_) {
217  edm::LogInfo("PrimaryVertexValidation") << "Using: " << nBins_ << " bins plots";
218  }
219 
220  bool passesRunControl = false;
221 
222  if (runControl_) {
223  for (const auto& runControlNumber : runControlNumbers_) {
224  if (iEvent.eventAuxiliary().run() == runControlNumber) {
225  if (debug_) {
226  edm::LogInfo("PrimaryVertexValidation")
227  << " run number: " << iEvent.eventAuxiliary().run() << " keeping run:" << runControlNumber;
228  }
229  passesRunControl = true;
230  break;
231  }
232  }
233  if (!passesRunControl)
234  return;
235  }
236 
237  Nevt_++;
238 
239  //=======================================================
240  // Initialize Root-tuple variables
241  //=======================================================
242 
243  SetVarToZero();
244 
245  //=======================================================
246  // Retrieve tracker topology from geometry
247  //=======================================================
248 
249  const TrackerTopology* const tTopo = &iSetup.getData(topoToken_);
250 
251  //=======================================================
252  // Retrieve the Magnetic Field information
253  //=======================================================
254 
256 
257  //=======================================================
258  // Retrieve the Tracking Geometry information
259  //=======================================================
260 
262 
263  //=======================================================
264  // Retrieve the Transient Track Builder information
265  //=======================================================
266 
268  double fBfield_ = ((*theB_).field()->inTesla(GlobalPoint(0., 0., 0.))).z();
269 
270  //=======================================================
271  // Retrieve the Track information
272  //=======================================================
273 
274  edm::Handle<TrackCollection> trackCollectionHandle = iEvent.getHandle(theTrackCollectionToken_);
275  if (!trackCollectionHandle.isValid())
276  return;
277  auto const& tracks = *trackCollectionHandle;
278 
279  //=======================================================
280  // Retrieve offline vartex information (only for reco)
281  //=======================================================
282 
283  //edm::Handle<VertexCollection> vertices;
286  if (!vertices.isValid()) {
287  edm::LogError("PrimaryVertexValidation") << "Vertex collection handle is not valid. Aborting!" << std::endl;
288  return;
289  }
290 
291  std::vector<Vertex> vsorted = *(vertices);
292  // sort the vertices by number of tracks in descending order
293  // use chi2 as tiebreaker
294  std::sort(vsorted.begin(), vsorted.end(), PrimaryVertexValidation::vtxSort);
295 
296  // skip events with no PV, this should not happen
297  if (vsorted.empty())
298  return;
299 
300  // skip events failing vertex cut
301  if (std::abs(vsorted[0].z()) > vertexZMax_)
302  return;
303 
304  if (vsorted[0].isValid()) {
305  xOfflineVertex_ = (vsorted)[0].x();
306  yOfflineVertex_ = (vsorted)[0].y();
307  zOfflineVertex_ = (vsorted)[0].z();
308 
309  xErrOfflineVertex_ = (vsorted)[0].xError();
310  yErrOfflineVertex_ = (vsorted)[0].yError();
311  zErrOfflineVertex_ = (vsorted)[0].zError();
312  }
313 
320 
321  unsigned int vertexCollectionSize = vsorted.size();
322  int nvvertex = 0;
323 
324  for (unsigned int i = 0; i < vertexCollectionSize; i++) {
325  const Vertex& vertex = vsorted.at(i);
326  if (vertex.isValid())
327  nvvertex++;
328  }
329 
330  nOfflineVertices_ = nvvertex;
331  h_nOfflineVertices->Fill(nvvertex);
332 
333  if (!vsorted.empty() && useTracksFromRecoVtx_) {
334  double sumpt = 0;
335  size_t ntracks = 0;
336  double chi2ndf = 0.;
337  double chi2prob = 0.;
338 
339  if (!vsorted.at(0).isFake()) {
340  Vertex pv = vsorted.at(0);
341 
342  ntracks = pv.tracksSize();
343  chi2ndf = pv.normalizedChi2();
344  chi2prob = TMath::Prob(pv.chi2(), (int)pv.ndof());
345 
346  h_recoVtxNtracks_->Fill(ntracks);
347  h_recoVtxChi2ndf_->Fill(chi2ndf);
348  h_recoVtxChi2Prob_->Fill(chi2prob);
349 
350  for (Vertex::trackRef_iterator itrk = pv.tracks_begin(); itrk != pv.tracks_end(); ++itrk) {
351  double pt = (**itrk).pt();
352  sumpt += pt * pt;
353 
354  const math::XYZPoint myVertex(pv.position().x(), pv.position().y(), pv.position().z());
355 
356  double dxyRes = (**itrk).dxy(myVertex);
357  double dzRes = (**itrk).dz(myVertex);
358 
359  double dxy_err = (**itrk).dxyError();
360  double dz_err = (**itrk).dzError();
361 
362  float trackphi = ((**itrk).phi()) * (180 / M_PI);
363  float tracketa = (**itrk).eta();
364 
365  for (int i = 0; i < nBins_; i++) {
366  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
367  float phiL = theDetails_.trendbins[PVValHelper::phi][i + 1];
368 
369  float etaF = theDetails_.trendbins[PVValHelper::eta][i];
370  float etaL = theDetails_.trendbins[PVValHelper::eta][i + 1];
371 
372  if (tracketa >= etaF && tracketa < etaL) {
375  PVValHelper::fillByIndex(n_dxyEtaBiasResiduals, i, (dxyRes) / dxy_err, "3");
376  PVValHelper::fillByIndex(n_dzEtaBiasResiduals, i, (dzRes) / dz_err, "4");
377  }
378 
379  if (trackphi >= phiF && trackphi < phiL) {
382  PVValHelper::fillByIndex(n_dxyPhiBiasResiduals, i, (dxyRes) / dxy_err, "7");
383  PVValHelper::fillByIndex(n_dzPhiBiasResiduals, i, (dzRes) / dz_err, "8");
384 
385  for (int j = 0; j < nBins_; j++) {
386  float etaJ = theDetails_.trendbins[PVValHelper::eta][j];
387  float etaK = theDetails_.trendbins[PVValHelper::eta][j + 1];
388 
389  if (tracketa >= etaJ && tracketa < etaK) {
390  a_dxyBiasResidualsMap[i][j]->Fill(dxyRes * cmToum);
391  a_dzBiasResidualsMap[i][j]->Fill(dzRes * cmToum);
392 
393  n_dxyBiasResidualsMap[i][j]->Fill((dxyRes) / dxy_err);
394  n_dzBiasResidualsMap[i][j]->Fill((dzRes) / dz_err);
395  }
396  }
397  }
398  }
399  }
400 
401  h_recoVtxSumPt_->Fill(sumpt);
402  }
403  }
404 
405  //=======================================================
406  // Retrieve Beamspot information
407  //=======================================================
408 
410  edm::Handle<BeamSpot> beamSpotHandle = iEvent.getHandle(theBeamspotToken_);
411 
412  if (beamSpotHandle.isValid()) {
413  beamSpot = *beamSpotHandle;
414  BSx0_ = beamSpot.x0();
415  BSy0_ = beamSpot.y0();
416  BSz0_ = beamSpot.z0();
417  Beamsigmaz_ = beamSpot.sigmaZ();
418  Beamdxdz_ = beamSpot.dxdz();
419  BeamWidthX_ = beamSpot.BeamWidthX();
420  BeamWidthY_ = beamSpot.BeamWidthY();
421 
422  wxy2_ = TMath::Power(BeamWidthX_, 2) + TMath::Power(BeamWidthY_, 2);
423 
424  } else {
425  edm::LogWarning("PrimaryVertexValidation") << "No BeamSpot found!";
426  }
427 
428  h_BSx0->Fill(BSx0_);
429  h_BSy0->Fill(BSy0_);
430  h_BSz0->Fill(BSz0_);
431  h_Beamsigmaz->Fill(Beamsigmaz_);
432  h_BeamWidthX->Fill(BeamWidthX_);
433  h_BeamWidthY->Fill(BeamWidthY_);
434 
435  if (debug_)
436  edm::LogInfo("PrimaryVertexValidation") << "Beamspot x:" << BSx0_ << " y:" << BSy0_ << " z:" << BSz0_;
437 
438  //=======================================================
439  // Starts here ananlysis
440  //=======================================================
441 
442  RunNumber_ = iEvent.eventAuxiliary().run();
443  LuminosityBlockNumber_ = iEvent.eventAuxiliary().luminosityBlock();
444  EventNumber_ = iEvent.eventAuxiliary().id().event();
445 
446  if (debug_)
447  edm::LogInfo("PrimaryVertexValidation") << " looping over " << trackCollectionHandle->size() << "tracks";
448 
449  h_nTracks->Fill(trackCollectionHandle->size());
450 
451  //======================================================
452  // Interface RECO tracks to vertex reconstruction
453  //======================================================
454 
455  std::vector<TransientTrack> t_tks;
456  for (const auto& track : tracks) {
457  TransientTrack tt = theB_->build(&(track));
458  tt.setBeamSpot(beamSpot);
459  t_tks.push_back(tt);
460  }
461 
462  if (debug_) {
463  edm::LogInfo("PrimaryVertexValidation") << "Found: " << t_tks.size() << " reconstructed tracks";
464  }
465 
466  //======================================================
467  // select the tracks
468  //======================================================
469 
470  std::vector<TransientTrack> seltks = theTrackFilter_->select(t_tks);
471 
472  //======================================================
473  // clusterize tracks in Z
474  //======================================================
475 
476  vector<vector<TransientTrack>> clusters = theTrackClusterizer_->clusterize(seltks);
477 
478  if (debug_) {
479  edm::LogInfo("PrimaryVertexValidation")
480  << " looping over: " << clusters.size() << " clusters from " << t_tks.size() << " selected tracks";
481  }
482 
483  nClus_ = clusters.size();
484  h_nClus->Fill(nClus_);
485 
486  //======================================================
487  // Starts loop on clusters
488  //======================================================
489  for (const auto& iclus : clusters) {
490  nTracksPerClus_ = 0;
491 
492  unsigned int i = 0;
493  for (const auto& theTTrack : iclus) {
494  i++;
495 
496  if (nTracks_ >= nMaxtracks_) {
497  edm::LogError("PrimaryVertexValidation")
498  << " Warning - Number of tracks: " << nTracks_ << " , greater than " << nMaxtracks_;
499  continue;
500  }
501 
502  const Track& theTrack = theTTrack.track();
503 
504  pt_[nTracks_] = theTrack.pt();
505  p_[nTracks_] = theTrack.p();
506  nhits_[nTracks_] = theTrack.numberOfValidHits();
507  eta_[nTracks_] = theTrack.eta();
508  theta_[nTracks_] = theTrack.theta();
509  phi_[nTracks_] = theTrack.phi();
510  chi2_[nTracks_] = theTrack.chi2();
511  chi2ndof_[nTracks_] = theTrack.normalizedChi2();
512  charge_[nTracks_] = theTrack.charge();
513  qoverp_[nTracks_] = theTrack.qoverp();
514  dz_[nTracks_] = theTrack.dz();
515  dxy_[nTracks_] = theTrack.dxy();
516 
517  TrackBase::TrackQuality _trackQuality = TrackBase::qualityByName("highPurity");
518  isHighPurity_[nTracks_] = theTrack.quality(_trackQuality);
519 
521  dxyBs_[nTracks_] = theTrack.dxy(point);
522  dzBs_[nTracks_] = theTrack.dz(point);
523 
524  xPCA_[nTracks_] = theTrack.vertex().x();
525  yPCA_[nTracks_] = theTrack.vertex().y();
526  zPCA_[nTracks_] = theTrack.vertex().z();
527 
528  //=======================================================
529  // Retrieve rechit information
530  //=======================================================
531 
532  const reco::HitPattern& hits = theTrack.hitPattern();
533 
534  int nRecHit1D = 0;
535  int nRecHit2D = 0;
536  int nhitinTIB = hits.numberOfValidStripTIBHits();
537  int nhitinTOB = hits.numberOfValidStripTOBHits();
538  int nhitinTID = hits.numberOfValidStripTIDHits();
539  int nhitinTEC = hits.numberOfValidStripTECHits();
540  int nhitinBPIX = hits.numberOfValidPixelBarrelHits();
541  int nhitinFPIX = hits.numberOfValidPixelEndcapHits();
542  for (trackingRecHit_iterator iHit = theTTrack.recHitsBegin(); iHit != theTTrack.recHitsEnd(); ++iHit) {
543  if ((*iHit)->isValid()) {
544  if (this->isHit2D(**iHit, phase_)) {
545  ++nRecHit2D;
546  } else {
547  ++nRecHit1D;
548  }
549  }
550  }
551 
552  nhits1D_[nTracks_] = nRecHit1D;
553  nhits2D_[nTracks_] = nRecHit2D;
554  nhitsBPIX_[nTracks_] = nhitinBPIX;
555  nhitsFPIX_[nTracks_] = nhitinFPIX;
556  nhitsTIB_[nTracks_] = nhitinTIB;
557  nhitsTID_[nTracks_] = nhitinTID;
558  nhitsTOB_[nTracks_] = nhitinTOB;
559  nhitsTEC_[nTracks_] = nhitinTEC;
560 
561  //=======================================================
562  // Good tracks for vertexing selection
563  //=======================================================
564 
565  bool pass = true;
566  if (askFirstLayerHit_)
567  pass = this->hasFirstLayerPixelHits(theTTrack);
568  if (pass && (theTrack.pt() >= ptOfProbe_) && std::abs(theTrack.eta()) <= etaOfProbe_ &&
569  (theTrack.numberOfValidHits()) >= nHitsOfProbe_ && (theTrack.p()) >= pOfProbe_) {
570  isGoodTrack_[nTracks_] = 1;
571  }
572 
573  //=======================================================
574  // Fit unbiased vertex
575  //=======================================================
576 
577  vector<TransientTrack> theFinalTracks;
578  theFinalTracks.clear();
579 
580  for (const auto& tk : iclus) {
581  pass = this->hasFirstLayerPixelHits(tk);
582  if (pass) {
583  if (tk == theTTrack)
584  continue;
585  else {
586  theFinalTracks.push_back(tk);
587  }
588  }
589  }
590 
591  if (theFinalTracks.size() > 1) {
592  if (debug_)
593  edm::LogInfo("PrimaryVertexValidation") << "Transient Track Collection size: " << theFinalTracks.size();
594  try {
595  //AdaptiveVertexFitter* theFitter = new AdaptiveVertexFitter;
596  auto theFitter = std::unique_ptr<VertexFitter<5>>(new AdaptiveVertexFitter());
597  TransientVertex theFittedVertex;
598 
600  theFittedVertex = theFitter->vertex(theFinalTracks, beamSpot); // if you want the beam constraint
601  } else {
602  theFittedVertex = theFitter->vertex(theFinalTracks);
603  }
604 
605  double totalTrackWeights = 0;
606  if (theFittedVertex.isValid()) {
607  if (theFittedVertex.hasTrackWeight()) {
608  for (const auto& theFinalTrack : theFinalTracks) {
609  sumOfWeightsUnbiasedVertex_[nTracks_] += theFittedVertex.trackWeight(theFinalTrack);
610  totalTrackWeights += theFittedVertex.trackWeight(theFinalTrack);
611  h_fitVtxTrackWeights_->Fill(theFittedVertex.trackWeight(theFinalTrack));
612  }
613  }
614 
615  h_fitVtxTrackAverageWeight_->Fill(totalTrackWeights / theFinalTracks.size());
616 
618  const math::XYZPoint myVertex(
619  theFittedVertex.position().x(), theFittedVertex.position().y(), theFittedVertex.position().z());
620 
621  const Vertex vertex = theFittedVertex;
622  fillTrackHistos(hDA, "all", &theTTrack, vertex, beamSpot, fBfield_);
623 
624  hasRecVertex_[nTracks_] = 1;
625  xUnbiasedVertex_[nTracks_] = theFittedVertex.position().x();
626  yUnbiasedVertex_[nTracks_] = theFittedVertex.position().y();
627  zUnbiasedVertex_[nTracks_] = theFittedVertex.position().z();
628 
629  chi2normUnbiasedVertex_[nTracks_] = theFittedVertex.normalisedChiSquared();
630  chi2UnbiasedVertex_[nTracks_] = theFittedVertex.totalChiSquared();
631  DOFUnbiasedVertex_[nTracks_] = theFittedVertex.degreesOfFreedom();
633  TMath::Prob(theFittedVertex.totalChiSquared(), (int)theFittedVertex.degreesOfFreedom());
634  tracksUsedForVertexing_[nTracks_] = theFinalTracks.size();
635 
636  h_fitVtxNtracks_->Fill(theFinalTracks.size());
637  h_fitVtxChi2_->Fill(theFittedVertex.totalChiSquared());
638  h_fitVtxNdof_->Fill(theFittedVertex.degreesOfFreedom());
639  h_fitVtxChi2ndf_->Fill(theFittedVertex.normalisedChiSquared());
640  h_fitVtxChi2Prob_->Fill(
641  TMath::Prob(theFittedVertex.totalChiSquared(), (int)theFittedVertex.degreesOfFreedom()));
642 
643  // from my Vertex
644  double dxyFromMyVertex = theTrack.dxy(myVertex);
645  double dzFromMyVertex = theTrack.dz(myVertex);
646 
647  GlobalPoint vert(
648  theFittedVertex.position().x(), theFittedVertex.position().y(), theFittedVertex.position().z());
649 
650  //FreeTrajectoryState theTrackNearVertex = theTTrack.trajectoryStateClosestToPoint(vert).theState();
651  //double dz_err = sqrt(theFittedVertex.positionError().czz() + theTrackNearVertex.cartesianError().position().czz());
652  //double dz_err = hypot(theTrack.dzError(),theFittedVertex.positionError().czz());
653 
654  double dz_err = sqrt(std::pow(theTrack.dzError(), 2) + theFittedVertex.positionError().czz());
655 
656  // PV2D
657  std::pair<bool, Measurement1D> s_ip2dpv = signedTransverseImpactParameter(
658  theTTrack, GlobalVector(theTrack.px(), theTrack.py(), theTrack.pz()), theFittedVertex);
659 
660  double s_ip2dpv_corr = s_ip2dpv.second.value();
661  double s_ip2dpv_err = s_ip2dpv.second.error();
662 
663  // PV3D
664  std::pair<bool, Measurement1D> s_ip3dpv = signedImpactParameter3D(
665  theTTrack, GlobalVector(theTrack.px(), theTrack.py(), theTrack.pz()), theFittedVertex);
666 
667  double s_ip3dpv_corr = s_ip3dpv.second.value();
668  double s_ip3dpv_err = s_ip3dpv.second.error();
669 
670  // PV3D absolute
671  std::pair<bool, Measurement1D> ip3dpv = absoluteImpactParameter3D(theTTrack, theFittedVertex);
672  double ip3d_corr = ip3dpv.second.value();
673  double ip3d_err = ip3dpv.second.error();
674 
675  // with respect to any specified vertex, such as primary vertex
677 
678  GlobalPoint refPoint = traj.position();
679  GlobalPoint cPToVtx = traj.theState().position();
680 
681  float my_dx = refPoint.x() - myVertex.x();
682  float my_dy = refPoint.y() - myVertex.y();
683 
684  float my_dx2 = cPToVtx.x() - myVertex.x();
685  float my_dy2 = cPToVtx.y() - myVertex.y();
686 
687  float my_dxy = std::sqrt(my_dx * my_dx + my_dy * my_dy);
688 
690  //double d0_error = traj.perigeeError().transverseImpactParameterError();
692  double z0_error = traj.perigeeError().longitudinalImpactParameterError();
693 
694  if (debug_) {
695  edm::LogInfo("PrimaryVertexValidation")
696  << "my_dx:" << my_dx << " my_dy:" << my_dy << " my_dxy:" << my_dxy << " my_dx2:" << my_dx2
697  << " my_dy2:" << my_dy2 << " d0: " << d0 << " dxyFromVtx:" << dxyFromMyVertex << "\n"
698  << " ============================== "
699  << "\n"
700  << "diff1:" << std::abs(d0) - std::abs(my_dxy) << "\n"
701  << "diff2:" << std::abs(d0) - std::abs(dxyFromMyVertex) << "\n"
702  << "diff3:" << (my_dx - my_dx2) << " " << (my_dy - my_dy2) << "\n"
703  << std::endl;
704  }
705 
706  // define IPs
707 
708  dxyFromMyVertex_[nTracks_] = dxyFromMyVertex;
709  dxyErrorFromMyVertex_[nTracks_] = s_ip2dpv_err;
710  IPTsigFromMyVertex_[nTracks_] = dxyFromMyVertex / s_ip2dpv_err;
711 
712  dzFromMyVertex_[nTracks_] = dzFromMyVertex;
713  dzErrorFromMyVertex_[nTracks_] = dz_err;
714  IPLsigFromMyVertex_[nTracks_] = dzFromMyVertex / dz_err;
715 
716  d3DFromMyVertex_[nTracks_] = ip3d_corr;
717  d3DErrorFromMyVertex_[nTracks_] = ip3d_err;
718  IP3DsigFromMyVertex_[nTracks_] = (ip3d_corr / ip3d_err);
719 
720  // fill directly the histograms of residuals
721 
722  float trackphi = (theTrack.phi()) * (180. / M_PI);
723  float tracketa = theTrack.eta();
724  float trackpt = theTrack.pt();
725  float trackp = theTrack.p();
726  float tracknhits = theTrack.numberOfValidHits();
727 
728  // determine the module number and ladder
729 
730  int ladder_num = -1.;
731  int module_num = -1.;
732  int L1BPixHitCount = 0;
733 
734  for (auto const& hit : theTrack.recHits()) {
735  const DetId& detId = hit->geographicalId();
736  unsigned int subid = detId.subdetId();
737 
738  if (hit->isValid() && (subid == PixelSubdetector::PixelBarrel)) {
739  int layer = tTopo->pxbLayer(detId);
740  if (layer == 1) {
741  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
742  hit); //to be used to get the associated cluster and the cluster probability
743  double clusterProbability = prechit->clusterProbability(0);
744  if (clusterProbability > 0) {
745  h_probeL1ClusterProb_->Fill(log10(clusterProbability));
746  }
747 
748  L1BPixHitCount += 1;
749  ladder_num = tTopo->pxbLadder(detId);
750  module_num = tTopo->pxbModule(detId);
751  }
752  }
753  }
754 
755  h_probeL1Ladder_->Fill(ladder_num);
756  h_probeL1Module_->Fill(module_num);
757  h2_probeLayer1Map_->Fill(module_num, ladder_num);
758  h_probeHasBPixL1Overlap_->Fill(L1BPixHitCount);
759 
760  // residuals vs ladder and module number for map
761  if (module_num > 0 && ladder_num > 0) { // only if we are on BPix Layer 1
762  a_dxyL1ResidualsMap[ladder_num - 1][module_num - 1]->Fill(dxyFromMyVertex * cmToum);
763  a_dzL1ResidualsMap[ladder_num - 1][module_num - 1]->Fill(dzFromMyVertex * cmToum);
764  n_dxyL1ResidualsMap[ladder_num - 1][module_num - 1]->Fill(dxyFromMyVertex / s_ip2dpv_err);
765  n_dzL1ResidualsMap[ladder_num - 1][module_num - 1]->Fill(dzFromMyVertex / dz_err);
766  }
767 
768  // filling the pT-binned distributions
769 
770  for (int ipTBin = 0; ipTBin < nPtBins_; ipTBin++) {
771  float pTF = mypT_bins_[ipTBin];
772  float pTL = mypT_bins_[ipTBin + 1];
773 
774  if (debug_)
775  edm::LogInfo("PrimaryVertexValidation") << "ipTBin:" << ipTBin << " " << mypT_bins_[ipTBin]
776  << " < pT < " << mypT_bins_[ipTBin + 1] << std::endl;
777 
778  if (std::abs(tracketa) < 1.5 && (trackpt >= pTF && trackpt < pTL)) {
779  if (debug_)
780  edm::LogInfo("PrimaryVertexValidation") << "passes this cut: " << mypT_bins_[ipTBin] << std::endl;
781  PVValHelper::fillByIndex(h_dxy_pT_, ipTBin, dxyFromMyVertex * cmToum, "9");
782  PVValHelper::fillByIndex(h_dz_pT_, ipTBin, dzFromMyVertex * cmToum, "10");
783  PVValHelper::fillByIndex(h_norm_dxy_pT_, ipTBin, dxyFromMyVertex / s_ip2dpv_err, "11");
784  PVValHelper::fillByIndex(h_norm_dz_pT_, ipTBin, dzFromMyVertex / dz_err, "12");
785 
786  if (std::abs(tracketa) < 1.) {
787  if (debug_)
788  edm::LogInfo("PrimaryVertexValidation")
789  << "passes tight eta cut: " << mypT_bins_[ipTBin] << std::endl;
790  PVValHelper::fillByIndex(h_dxy_Central_pT_, ipTBin, dxyFromMyVertex * cmToum, "13");
791  PVValHelper::fillByIndex(h_dz_Central_pT_, ipTBin, dzFromMyVertex * cmToum, "14");
792  PVValHelper::fillByIndex(h_norm_dxy_Central_pT_, ipTBin, dxyFromMyVertex / s_ip2dpv_err, "15");
793  PVValHelper::fillByIndex(h_norm_dz_Central_pT_, ipTBin, dzFromMyVertex / dz_err, "16");
794  }
795  }
796  }
797 
798  // checks on the probe track quality
799  if (trackpt >= ptOfProbe_ && std::abs(tracketa) <= etaOfProbe_ && tracknhits >= nHitsOfProbe_ &&
800  trackp >= pOfProbe_) {
801  std::pair<bool, bool> pixelOcc = pixelHitsCheck((theTTrack));
802 
803  if (debug_) {
804  if (pixelOcc.first == true)
805  edm::LogInfo("PrimaryVertexValidation") << "has BPIx hits" << std::endl;
806  if (pixelOcc.second == true)
807  edm::LogInfo("PrimaryVertexValidation") << "has FPix hits" << std::endl;
808  }
809 
810  if (!doBPix_ && (pixelOcc.first == true))
811  continue;
812  if (!doFPix_ && (pixelOcc.second == true))
813  continue;
814 
815  fillTrackHistos(hDA, "sel", &(theTTrack), vertex, beamSpot, fBfield_);
816 
817  // probe checks
818  h_probePt_->Fill(theTrack.pt());
819  h_probePtRebin_->Fill(theTrack.pt());
820  h_probeP_->Fill(theTrack.p());
821  h_probeEta_->Fill(theTrack.eta());
822  h_probePhi_->Fill(theTrack.phi());
823  h2_probeEtaPhi_->Fill(theTrack.eta(), theTrack.phi());
824  h2_probeEtaPt_->Fill(theTrack.eta(), theTrack.pt());
825 
826  h_probeChi2_->Fill(theTrack.chi2());
827  h_probeNormChi2_->Fill(theTrack.normalizedChi2());
828  h_probeCharge_->Fill(theTrack.charge());
829  h_probeQoverP_->Fill(theTrack.qoverp());
830  h_probeHits_->Fill(theTrack.numberOfValidHits());
831  h_probeHits1D_->Fill(nRecHit1D);
832  h_probeHits2D_->Fill(nRecHit2D);
833  h_probeHitsInTIB_->Fill(nhitinTIB);
834  h_probeHitsInTOB_->Fill(nhitinTOB);
835  h_probeHitsInTID_->Fill(nhitinTID);
836  h_probeHitsInTEC_->Fill(nhitinTEC);
837  h_probeHitsInBPIX_->Fill(nhitinBPIX);
838  h_probeHitsInFPIX_->Fill(nhitinFPIX);
839 
840  float dxyRecoV = theTrack.dz(theRecoVertex);
841  float dzRecoV = theTrack.dxy(theRecoVertex);
842  float dxysigmaRecoV =
843  TMath::Sqrt(theTrack.d0Error() * theTrack.d0Error() + xErrOfflineVertex_ * yErrOfflineVertex_);
844  float dzsigmaRecoV =
845  TMath::Sqrt(theTrack.dzError() * theTrack.dzError() + zErrOfflineVertex_ * zErrOfflineVertex_);
846 
847  double zTrack = (theTTrack.stateAtBeamLine().trackStateAtPCA()).position().z();
848  double zVertex = theFittedVertex.position().z();
849  double tantheta = tan((theTTrack.stateAtBeamLine().trackStateAtPCA()).momentum().theta());
850 
851  double dz2 = pow(theTrack.dzError(), 2) + wxy2_ / pow(tantheta, 2);
852  double restrkz = zTrack - zVertex;
853  double pulltrkz = (zTrack - zVertex) / TMath::Sqrt(dz2);
854 
855  h_probedxyRecoV_->Fill(dxyRecoV);
856  h_probedzRecoV_->Fill(dzRecoV);
857 
858  h_probedzRefitV_->Fill(dxyFromMyVertex);
859  h_probedxyRefitV_->Fill(dzFromMyVertex);
860 
861  h_probed0RefitV_->Fill(d0);
862  h_probez0RefitV_->Fill(z0);
863 
864  h_probesignIP2DRefitV_->Fill(s_ip2dpv_corr);
865  h_probed3DRefitV_->Fill(ip3d_corr);
866  h_probereszRefitV_->Fill(restrkz);
867 
868  h_probeRecoVSigZ_->Fill(dzRecoV / dzsigmaRecoV);
869  h_probeRecoVSigXY_->Fill(dxyRecoV / dxysigmaRecoV);
870  h_probeRefitVSigZ_->Fill(dzFromMyVertex / dz_err);
871  h_probeRefitVSigXY_->Fill(dxyFromMyVertex / s_ip2dpv_err);
872  h_probeRefitVSig3D_->Fill(ip3d_corr / ip3d_err);
873  h_probeRefitVLogSig3D_->Fill(log10(ip3d_corr / ip3d_err));
874  h_probeRefitVSigResZ_->Fill(pulltrkz);
875 
876  a_dxyVsPhi->Fill(trackphi, dxyFromMyVertex * cmToum);
877  a_dzVsPhi->Fill(trackphi, z0 * cmToum);
878  n_dxyVsPhi->Fill(trackphi, dxyFromMyVertex / s_ip2dpv_err);
879  n_dzVsPhi->Fill(trackphi, z0 / z0_error);
880 
881  a_dxyVsEta->Fill(tracketa, dxyFromMyVertex * cmToum);
882  a_dzVsEta->Fill(tracketa, z0 * cmToum);
883  n_dxyVsEta->Fill(tracketa, dxyFromMyVertex / s_ip2dpv_err);
884  n_dzVsEta->Fill(tracketa, z0 / z0_error);
885 
886  if (ladder_num > 0 && module_num > 0) {
887  LogDebug("PrimaryVertexValidation")
888  << " ladder_num: " << ladder_num << " module_num: " << module_num << std::endl;
889 
890  PVValHelper::fillByIndex(h_dxy_modZ_, module_num - 1, dxyFromMyVertex * cmToum, "17");
891  PVValHelper::fillByIndex(h_dz_modZ_, module_num - 1, dzFromMyVertex * cmToum, "18");
892  PVValHelper::fillByIndex(h_norm_dxy_modZ_, module_num - 1, dxyFromMyVertex / s_ip2dpv_err, "19");
893  PVValHelper::fillByIndex(h_norm_dz_modZ_, module_num - 1, dzFromMyVertex / dz_err, "20");
894 
895  PVValHelper::fillByIndex(h_dxy_ladder_, ladder_num - 1, dxyFromMyVertex * cmToum, "21");
896 
897  LogDebug("PrimaryVertexValidation") << "h_dxy_ladder size:" << h_dxy_ladder_.size() << std::endl;
898 
899  if (L1BPixHitCount == 1) {
900  PVValHelper::fillByIndex(h_dxy_ladderNoOverlap_, ladder_num - 1, dxyFromMyVertex * cmToum);
901  } else {
902  PVValHelper::fillByIndex(h_dxy_ladderOverlap_, ladder_num - 1, dxyFromMyVertex * cmToum);
903  }
904 
905  h2_probePassingLayer1Map_->Fill(module_num, ladder_num);
906 
907  PVValHelper::fillByIndex(h_dz_ladder_, ladder_num - 1, dzFromMyVertex * cmToum, "22");
908  PVValHelper::fillByIndex(h_norm_dxy_ladder_, ladder_num - 1, dxyFromMyVertex / s_ip2dpv_err, "23");
909  PVValHelper::fillByIndex(h_norm_dz_ladder_, ladder_num - 1, dzFromMyVertex / dz_err, "24");
910  }
911 
912  // filling the binned distributions
913  for (int i = 0; i < nBins_; i++) {
914  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
915  float phiL = theDetails_.trendbins[PVValHelper::phi][i + 1];
916 
917  float etaF = theDetails_.trendbins[PVValHelper::eta][i];
918  float etaL = theDetails_.trendbins[PVValHelper::eta][i + 1];
919 
920  if (tracketa >= etaF && tracketa < etaL) {
921  PVValHelper::fillByIndex(a_dxyEtaResiduals, i, dxyFromMyVertex * cmToum, "25");
924  PVValHelper::fillByIndex(a_dzEtaResiduals, i, dzFromMyVertex * cmToum, "28");
925  PVValHelper::fillByIndex(n_dxyEtaResiduals, i, dxyFromMyVertex / s_ip2dpv_err, "29");
926  PVValHelper::fillByIndex(n_dzEtaResiduals, i, dzFromMyVertex / dz_err, "30");
927  PVValHelper::fillByIndex(a_IP2DEtaResiduals, i, s_ip2dpv_corr * cmToum, "31");
928  PVValHelper::fillByIndex(n_IP2DEtaResiduals, i, s_ip2dpv_corr / s_ip2dpv_err, "32");
931  PVValHelper::fillByIndex(a_d3DEtaResiduals, i, ip3d_corr * cmToum, "35");
932  PVValHelper::fillByIndex(n_d3DEtaResiduals, i, ip3d_corr / ip3d_err, "36");
933  PVValHelper::fillByIndex(a_IP3DEtaResiduals, i, s_ip3dpv_corr * cmToum, "37");
934  PVValHelper::fillByIndex(n_IP3DEtaResiduals, i, s_ip3dpv_corr / s_ip3dpv_err, "38");
935  }
936 
937  if (trackphi >= phiF && trackphi < phiL) {
938  PVValHelper::fillByIndex(a_dxyPhiResiduals, i, dxyFromMyVertex * cmToum, "39");
941  PVValHelper::fillByIndex(a_dzPhiResiduals, i, dzFromMyVertex * cmToum, "42");
942  PVValHelper::fillByIndex(n_dxyPhiResiduals, i, dxyFromMyVertex / s_ip2dpv_err, "43");
943  PVValHelper::fillByIndex(n_dzPhiResiduals, i, dzFromMyVertex / dz_err, "44");
944  PVValHelper::fillByIndex(a_IP2DPhiResiduals, i, s_ip2dpv_corr * cmToum, "45");
945  PVValHelper::fillByIndex(n_IP2DPhiResiduals, i, s_ip2dpv_corr / s_ip2dpv_err, "46");
948  PVValHelper::fillByIndex(a_d3DPhiResiduals, i, ip3d_corr * cmToum, "49");
949  PVValHelper::fillByIndex(n_d3DPhiResiduals, i, ip3d_corr / ip3d_err, "50");
950  PVValHelper::fillByIndex(a_IP3DPhiResiduals, i, s_ip3dpv_corr * cmToum, "51");
951  PVValHelper::fillByIndex(n_IP3DPhiResiduals, i, s_ip3dpv_corr / s_ip3dpv_err, "52");
952 
953  for (int j = 0; j < nBins_; j++) {
954  float etaJ = theDetails_.trendbins[PVValHelper::eta][j];
955  float etaK = theDetails_.trendbins[PVValHelper::eta][j + 1];
956 
957  if (tracketa >= etaJ && tracketa < etaK) {
958  a_dxyResidualsMap[i][j]->Fill(dxyFromMyVertex * cmToum);
959  a_dzResidualsMap[i][j]->Fill(dzFromMyVertex * cmToum);
960  n_dxyResidualsMap[i][j]->Fill(dxyFromMyVertex / s_ip2dpv_err);
961  n_dzResidualsMap[i][j]->Fill(dzFromMyVertex / dz_err);
962  a_d3DResidualsMap[i][j]->Fill(ip3d_corr * cmToum);
963  n_d3DResidualsMap[i][j]->Fill(ip3d_corr / ip3d_err);
964  }
965  }
966  }
967  }
968  }
969 
970  if (debug_) {
971  edm::LogInfo("PrimaryVertexValidation")
972  << " myVertex.x()= " << myVertex.x() << "\n"
973  << " myVertex.y()= " << myVertex.y() << " \n"
974  << " myVertex.z()= " << myVertex.z() << " \n"
975  << " theTrack.dz(myVertex)= " << theTrack.dz(myVertex) << " \n"
976  << " zPCA -myVertex.z() = " << (theTrack.vertex().z() - myVertex.z());
977 
978  } // ends if debug_
979  } // ends if the fitted vertex is Valid
980 
981  //delete theFitter;
982 
983  } catch (cms::Exception& er) {
984  LogTrace("PrimaryVertexValidation") << "caught std::exception " << er.what() << std::endl;
985  }
986 
987  } //ends if theFinalTracks.size() > 2
988 
989  else {
990  if (debug_)
991  edm::LogInfo("PrimaryVertexValidation") << "Not enough tracks to make a vertex. Returns no vertex info";
992  }
993 
994  ++nTracks_;
995  ++nTracksPerClus_;
996 
997  if (debug_)
998  edm::LogInfo("PrimaryVertexValidation") << "Track " << i << " : pT = " << theTrack.pt();
999 
1000  } // for loop on tracks
1001  } // for loop on track clusters
1002 
1003  // Fill the TTree if needed
1004 
1005  if (storeNtuple_) {
1006  rootTree_->Fill();
1007  }
1008 }
1009 
1010 // ------------ method called to discriminate 1D from 2D hits ------------
1012  if (hit.dimension() < 2) {
1013  return false; // some (muon...) stuff really has RecHit1D
1014  } else {
1015  const DetId detId(hit.geographicalId());
1016  if (detId.det() == DetId::Tracker) {
1017  if (detId.subdetId() == PixelSubdetector::PixelBarrel || detId.subdetId() == PixelSubdetector::PixelEndcap) {
1018  return true; // pixel is always 2D
1019  } else if (thePhase != PVValHelper::phase2) { // should be SiStrip now
1020  if (dynamic_cast<const SiStripRecHit2D*>(&hit))
1021  return false; // normal hit
1022  else if (dynamic_cast<const SiStripMatchedRecHit2D*>(&hit))
1023  return true; // matched is 2D
1024  else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(&hit))
1025  return false; // crazy hit...
1026  else {
1027  edm::LogError("UnknownType") << "@SUB=PrimaryVertexValidation::isHit2D"
1028  << "Tracker hit not in pixel and neither SiStripRecHit2D nor "
1029  << "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
1030  return false;
1031  }
1032  } else {
1033  return false;
1034  }
1035  } else { // not tracker??
1036  edm::LogWarning("DetectorMismatch") << "@SUB=PrimaryVertexValidation::isHit2D"
1037  << "Hit not in tracker with 'official' dimension >=2.";
1038  return true; // dimension() >= 2 so accept that...
1039  }
1040  }
1041  // never reached...
1042 }
1043 
1044 // ------------ method to check the presence of pixel hits ------------
1046  bool hasBPixHits = false;
1047  bool hasFPixHits = false;
1048 
1049  const reco::HitPattern& p = track.hitPattern();
1050  if (p.numberOfValidPixelEndcapHits() != 0) {
1051  hasFPixHits = true;
1052  }
1053  if (p.numberOfValidPixelBarrelHits() != 0) {
1054  hasBPixHits = true;
1055  }
1056 
1057  return std::make_pair(hasBPixHits, hasFPixHits);
1058 }
1059 
1060 // ------------ method to check the presence of pixel hits ------------
1062  using namespace reco;
1063  const HitPattern& p = track.hitPattern();
1064  for (int i = 0; i < p.numberOfAllHits(HitPattern::TRACK_HITS); i++) {
1065  uint32_t pattern = p.getHitPattern(HitPattern::TRACK_HITS, i);
1066  if (p.pixelBarrelHitFilter(pattern) || p.pixelEndcapHitFilter(pattern)) {
1067  if (p.getLayer(pattern) == 1) {
1068  if (p.validHitFilter(pattern)) {
1069  return true;
1070  }
1071  }
1072  }
1073  }
1074  return false;
1075 }
1076 
1077 // ------------ method called once each job before begining the event loop ------------
1079  edm::LogInfo("PrimaryVertexValidation") << "######################################\n"
1080  << "Begin Job \n"
1081  << "######################################";
1082 
1083  // Define TTree for output
1084  Nevt_ = 0;
1085  if (compressionSettings_ > 0) {
1086  fs->file().SetCompressionSettings(compressionSettings_);
1087  }
1088 
1089  // rootFile_ = new TFile(filename_.c_str(),"recreate");
1090  rootTree_ = fs->make<TTree>("tree", "PV Validation tree");
1091 
1092  // Track Paramters
1093 
1094  if (lightNtupleSwitch_) {
1095  rootTree_->Branch("EventNumber", &EventNumber_, "EventNumber/i");
1096  rootTree_->Branch("RunNumber", &RunNumber_, "RunNumber/i");
1097  rootTree_->Branch("LuminosityBlockNumber", &LuminosityBlockNumber_, "LuminosityBlockNumber/i");
1098  rootTree_->Branch("nOfflineVertices", &nOfflineVertices_, "nOfflineVertices/I");
1099  rootTree_->Branch("nTracks", &nTracks_, "nTracks/I");
1100  rootTree_->Branch("phi", &phi_, "phi[nTracks]/D");
1101  rootTree_->Branch("eta", &eta_, "eta[nTracks]/D");
1102  rootTree_->Branch("pt", &pt_, "pt[nTracks]/D");
1103  rootTree_->Branch("dxyFromMyVertex", &dxyFromMyVertex_, "dxyFromMyVertex[nTracks]/D");
1104  rootTree_->Branch("dzFromMyVertex", &dzFromMyVertex_, "dzFromMyVertex[nTracks]/D");
1105  rootTree_->Branch("d3DFromMyVertex", &d3DFromMyVertex_, "d3DFromMyVertex[nTracks]/D");
1106  rootTree_->Branch("IPTsigFromMyVertex", &IPTsigFromMyVertex_, "IPTsigFromMyVertex_[nTracks]/D");
1107  rootTree_->Branch("IPLsigFromMyVertex", &IPLsigFromMyVertex_, "IPLsigFromMyVertex_[nTracks]/D");
1108  rootTree_->Branch("IP3DsigFromMyVertex", &IP3DsigFromMyVertex_, "IP3DsigFromMyVertex_[nTracks]/D");
1109  rootTree_->Branch("hasRecVertex", &hasRecVertex_, "hasRecVertex[nTracks]/I");
1110  rootTree_->Branch("isGoodTrack", &isGoodTrack_, "isGoodTrack[nTracks]/I");
1111  rootTree_->Branch("isHighPurity", &isHighPurity_, "isHighPurity_[nTracks]/I");
1112 
1113  } else {
1114  rootTree_->Branch("nTracks", &nTracks_, "nTracks/I");
1115  rootTree_->Branch("nTracksPerClus", &nTracksPerClus_, "nTracksPerClus/I");
1116  rootTree_->Branch("nClus", &nClus_, "nClus/I");
1117  rootTree_->Branch("xOfflineVertex", &xOfflineVertex_, "xOfflineVertex/D");
1118  rootTree_->Branch("yOfflineVertex", &yOfflineVertex_, "yOfflineVertex/D");
1119  rootTree_->Branch("zOfflineVertex", &zOfflineVertex_, "zOfflineVertex/D");
1120  rootTree_->Branch("BSx0", &BSx0_, "BSx0/D");
1121  rootTree_->Branch("BSy0", &BSy0_, "BSy0/D");
1122  rootTree_->Branch("BSz0", &BSz0_, "BSz0/D");
1123  rootTree_->Branch("Beamsigmaz", &Beamsigmaz_, "Beamsigmaz/D");
1124  rootTree_->Branch("Beamdxdz", &Beamdxdz_, "Beamdxdz/D");
1125  rootTree_->Branch("BeamWidthX", &BeamWidthX_, "BeamWidthX/D");
1126  rootTree_->Branch("BeamWidthY", &BeamWidthY_, "BeamWidthY/D");
1127  rootTree_->Branch("pt", &pt_, "pt[nTracks]/D");
1128  rootTree_->Branch("p", &p_, "p[nTracks]/D");
1129  rootTree_->Branch("nhits", &nhits_, "nhits[nTracks]/I");
1130  rootTree_->Branch("nhits1D", &nhits1D_, "nhits1D[nTracks]/I");
1131  rootTree_->Branch("nhits2D", &nhits2D_, "nhits2D[nTracks]/I");
1132  rootTree_->Branch("nhitsBPIX", &nhitsBPIX_, "nhitsBPIX[nTracks]/I");
1133  rootTree_->Branch("nhitsFPIX", &nhitsFPIX_, "nhitsFPIX[nTracks]/I");
1134  rootTree_->Branch("nhitsTIB", &nhitsTIB_, "nhitsTIB[nTracks]/I");
1135  rootTree_->Branch("nhitsTID", &nhitsTID_, "nhitsTID[nTracks]/I");
1136  rootTree_->Branch("nhitsTOB", &nhitsTOB_, "nhitsTOB[nTracks]/I");
1137  rootTree_->Branch("nhitsTEC", &nhitsTEC_, "nhitsTEC[nTracks]/I");
1138  rootTree_->Branch("eta", &eta_, "eta[nTracks]/D");
1139  rootTree_->Branch("theta", &theta_, "theta[nTracks]/D");
1140  rootTree_->Branch("phi", &phi_, "phi[nTracks]/D");
1141  rootTree_->Branch("chi2", &chi2_, "chi2[nTracks]/D");
1142  rootTree_->Branch("chi2ndof", &chi2ndof_, "chi2ndof[nTracks]/D");
1143  rootTree_->Branch("charge", &charge_, "charge[nTracks]/I");
1144  rootTree_->Branch("qoverp", &qoverp_, "qoverp[nTracks]/D");
1145  rootTree_->Branch("dz", &dz_, "dz[nTracks]/D");
1146  rootTree_->Branch("dxy", &dxy_, "dxy[nTracks]/D");
1147  rootTree_->Branch("dzBs", &dzBs_, "dzBs[nTracks]/D");
1148  rootTree_->Branch("dxyBs", &dxyBs_, "dxyBs[nTracks]/D");
1149  rootTree_->Branch("xPCA", &xPCA_, "xPCA[nTracks]/D");
1150  rootTree_->Branch("yPCA", &yPCA_, "yPCA[nTracks]/D");
1151  rootTree_->Branch("zPCA", &zPCA_, "zPCA[nTracks]/D");
1152  rootTree_->Branch("xUnbiasedVertex", &xUnbiasedVertex_, "xUnbiasedVertex[nTracks]/D");
1153  rootTree_->Branch("yUnbiasedVertex", &yUnbiasedVertex_, "yUnbiasedVertex[nTracks]/D");
1154  rootTree_->Branch("zUnbiasedVertex", &zUnbiasedVertex_, "zUnbiasedVertex[nTracks]/D");
1155  rootTree_->Branch("chi2normUnbiasedVertex", &chi2normUnbiasedVertex_, "chi2normUnbiasedVertex[nTracks]/F");
1156  rootTree_->Branch("chi2UnbiasedVertex", &chi2UnbiasedVertex_, "chi2UnbiasedVertex[nTracks]/F");
1157  rootTree_->Branch("DOFUnbiasedVertex", &DOFUnbiasedVertex_, " DOFUnbiasedVertex[nTracks]/F");
1158  rootTree_->Branch("chi2ProbUnbiasedVertex", &chi2ProbUnbiasedVertex_, "chi2ProbUnbiasedVertex[nTracks]/F");
1159  rootTree_->Branch(
1160  "sumOfWeightsUnbiasedVertex", &sumOfWeightsUnbiasedVertex_, "sumOfWeightsUnbiasedVertex[nTracks]/F");
1161  rootTree_->Branch("tracksUsedForVertexing", &tracksUsedForVertexing_, "tracksUsedForVertexing[nTracks]/I");
1162  rootTree_->Branch("dxyFromMyVertex", &dxyFromMyVertex_, "dxyFromMyVertex[nTracks]/D");
1163  rootTree_->Branch("dzFromMyVertex", &dzFromMyVertex_, "dzFromMyVertex[nTracks]/D");
1164  rootTree_->Branch("dxyErrorFromMyVertex", &dxyErrorFromMyVertex_, "dxyErrorFromMyVertex_[nTracks]/D");
1165  rootTree_->Branch("dzErrorFromMyVertex", &dzErrorFromMyVertex_, "dzErrorFromMyVertex_[nTracks]/D");
1166  rootTree_->Branch("IPTsigFromMyVertex", &IPTsigFromMyVertex_, "IPTsigFromMyVertex_[nTracks]/D");
1167  rootTree_->Branch("IPLsigFromMyVertex", &IPLsigFromMyVertex_, "IPLsigFromMyVertex_[nTracks]/D");
1168  rootTree_->Branch("hasRecVertex", &hasRecVertex_, "hasRecVertex[nTracks]/I");
1169  rootTree_->Branch("isGoodTrack", &isGoodTrack_, "isGoodTrack[nTracks]/I");
1170  }
1171 
1172  // event histograms
1173  TFileDirectory EventFeatures = fs->mkdir("EventFeatures");
1174 
1175  TH1F::SetDefaultSumw2(kTRUE);
1176 
1178  EventFeatures.make<TH1F>("h_lumiFromConfig", "luminosity from config;;luminosity of present run", 1, -0.5, 0.5);
1179  h_lumiFromConfig->SetBinContent(1, intLumi_);
1180 
1181  h_runFromConfig = EventFeatures.make<TH1I>("h_runFromConfig",
1182  "run number from config;;run number (from configuration)",
1183  runControlNumbers_.size(),
1184  0.,
1185  runControlNumbers_.size());
1186 
1187  for (const auto& run : runControlNumbers_ | boost::adaptors::indexed(1)) {
1188  h_runFromConfig->SetBinContent(run.index(), run.value());
1189  }
1190 
1191  h_runFromEvent =
1192  EventFeatures.make<TH1I>("h_runFromEvent", "run number from event;;run number (from event)", 1, -0.5, 0.5);
1193  h_nTracks =
1194  EventFeatures.make<TH1F>("h_nTracks", "number of tracks per event;n_{tracks}/event;n_{events}", 300, -0.5, 299.5);
1195  h_nClus =
1196  EventFeatures.make<TH1F>("h_nClus", "number of track clusters;n_{clusters}/event;n_{events}", 50, -0.5, 49.5);
1197  h_nOfflineVertices = EventFeatures.make<TH1F>(
1198  "h_nOfflineVertices", "number of offline reconstructed vertices;n_{vertices}/event;n_{events}", 50, -0.5, 49.5);
1199  h_runNumber = EventFeatures.make<TH1F>("h_runNumber", "run number;run number;n_{events}", 100000, 250000., 350000.);
1200  h_xOfflineVertex = EventFeatures.make<TH1F>(
1201  "h_xOfflineVertex", "x-coordinate of offline vertex;x_{vertex};n_{events}", 100, -0.1, 0.1);
1202  h_yOfflineVertex = EventFeatures.make<TH1F>(
1203  "h_yOfflineVertex", "y-coordinate of offline vertex;y_{vertex};n_{events}", 100, -0.1, 0.1);
1204  h_zOfflineVertex = EventFeatures.make<TH1F>(
1205  "h_zOfflineVertex", "z-coordinate of offline vertex;z_{vertex};n_{events}", 100, -30., 30.);
1206  h_xErrOfflineVertex = EventFeatures.make<TH1F>(
1207  "h_xErrOfflineVertex", "x-coordinate error of offline vertex;err_{x}^{vtx};n_{events}", 100, 0., 0.01);
1208  h_yErrOfflineVertex = EventFeatures.make<TH1F>(
1209  "h_yErrOfflineVertex", "y-coordinate error of offline vertex;err_{y}^{vtx};n_{events}", 100, 0., 0.01);
1210  h_zErrOfflineVertex = EventFeatures.make<TH1F>(
1211  "h_zErrOfflineVertex", "z-coordinate error of offline vertex;err_{z}^{vtx};n_{events}", 100, 0., 10.);
1212  h_BSx0 = EventFeatures.make<TH1F>("h_BSx0", "x-coordinate of reco beamspot;x^{BS}_{0};n_{events}", 100, -0.1, 0.1);
1213  h_BSy0 = EventFeatures.make<TH1F>("h_BSy0", "y-coordinate of reco beamspot;y^{BS}_{0};n_{events}", 100, -0.1, 0.1);
1214  h_BSz0 = EventFeatures.make<TH1F>("h_BSz0", "z-coordinate of reco beamspot;z^{BS}_{0};n_{events}", 100, -1., 1.);
1215  h_Beamsigmaz =
1216  EventFeatures.make<TH1F>("h_Beamsigmaz", "z-coordinate beam width;#sigma_{Z}^{beam};n_{events}", 100, 0., 1.);
1217  h_BeamWidthX =
1218  EventFeatures.make<TH1F>("h_BeamWidthX", "x-coordinate beam width;#sigma_{X}^{beam};n_{events}", 100, 0., 0.01);
1219  h_BeamWidthY =
1220  EventFeatures.make<TH1F>("h_BeamWidthY", "y-coordinate beam width;#sigma_{Y}^{beam};n_{events}", 100, 0., 0.01);
1221 
1222  h_etaMax = EventFeatures.make<TH1F>("etaMax", "etaMax", 1, -0.5, 0.5);
1223  h_pTinfo = EventFeatures.make<TH1F>("pTinfo", "pTinfo", 3, -1.5, 1.5);
1224  h_pTinfo->GetXaxis()->SetBinLabel(1, "n. bins");
1225  h_pTinfo->GetXaxis()->SetBinLabel(2, "pT min");
1226  h_pTinfo->GetXaxis()->SetBinLabel(3, "pT max");
1227 
1228  h_nbins = EventFeatures.make<TH1F>("nbins", "nbins", 1, -0.5, 0.5);
1229  h_nLadders = EventFeatures.make<TH1F>("nladders", "n. ladders", 1, -0.5, 0.5);
1230  h_nModZ = EventFeatures.make<TH1F>("nModZ", "n. modules along z", 1, -0.5, 0.5);
1231 
1232  // probe track histograms
1233  TFileDirectory ProbeFeatures = fs->mkdir("ProbeTrackFeatures");
1234 
1235  h_probePt_ = ProbeFeatures.make<TH1F>("h_probePt", "p_{T} of probe track;track p_{T} (GeV); tracks", 100, 0., 50.);
1236  h_probePtRebin_ = ProbeFeatures.make<TH1F>(
1237  "h_probePtRebin", "p_{T} of probe track;track p_{T} (GeV); tracks", mypT_bins_.size() - 1, mypT_bins_.data());
1238  h_probeP_ = ProbeFeatures.make<TH1F>("h_probeP", "momentum of probe track;track p (GeV); tracks", 100, 0., 100.);
1239  h_probeEta_ = ProbeFeatures.make<TH1F>(
1240  "h_probeEta", "#eta of the probe track;track #eta;tracks", 54, -etaOfProbe_, etaOfProbe_);
1241  h_probePhi_ = ProbeFeatures.make<TH1F>("h_probePhi", "#phi of probe track;track #phi (rad);tracks", 100, -3.15, 3.15);
1242 
1243  h2_probeEtaPhi_ =
1244  ProbeFeatures.make<TH2F>("h2_probeEtaPhi",
1245  "probe track #phi vs #eta;#eta of probe track;track #phi of probe track (rad); tracks",
1246  54,
1247  -etaOfProbe_,
1248  etaOfProbe_,
1249  100,
1250  -M_PI,
1251  M_PI);
1252  h2_probeEtaPt_ = ProbeFeatures.make<TH2F>("h2_probeEtaPt",
1253  "probe track p_{T} vs #eta;#eta of probe track;track p_{T} (GeV); tracks",
1254  54,
1255  -etaOfProbe_,
1256  etaOfProbe_,
1257  100,
1258  0.,
1259  50.);
1260 
1261  h_probeChi2_ =
1262  ProbeFeatures.make<TH1F>("h_probeChi2", "#chi^{2} of probe track;track #chi^{2}; tracks", 100, 0., 100.);
1263  h_probeNormChi2_ = ProbeFeatures.make<TH1F>(
1264  "h_probeNormChi2", " normalized #chi^{2} of probe track;track #chi^{2}/ndof; tracks", 100, 0., 10.);
1265  h_probeCharge_ =
1266  ProbeFeatures.make<TH1F>("h_probeCharge", "charge of probe track;track charge Q;tracks", 3, -1.5, 1.5);
1267  h_probeQoverP_ =
1268  ProbeFeatures.make<TH1F>("h_probeQoverP", "q/p of probe track; track Q/p (GeV^{-1});tracks", 200, -1., 1.);
1269  h_probedzRecoV_ = ProbeFeatures.make<TH1F>(
1270  "h_probedzRecoV", "d_{z}(V_{offline}) of probe track;track d_{z}(V_{off}) (cm);tracks", 200, -1., 1.);
1271  h_probedxyRecoV_ = ProbeFeatures.make<TH1F>(
1272  "h_probedxyRecoV", "d_{xy}(V_{offline}) of probe track;track d_{xy}(V_{off}) (cm);tracks", 200, -1., 1.);
1273  h_probedzRefitV_ = ProbeFeatures.make<TH1F>(
1274  "h_probedzRefitV", "d_{z}(V_{refit}) of probe track;track d_{z}(V_{fit}) (cm);tracks", 200, -0.5, 0.5);
1275  h_probesignIP2DRefitV_ = ProbeFeatures.make<TH1F>(
1276  "h_probesignIPRefitV", "ip_{2D}(V_{refit}) of probe track;track ip_{2D}(V_{fit}) (cm);tracks", 200, -1., 1.);
1277  h_probedxyRefitV_ = ProbeFeatures.make<TH1F>(
1278  "h_probedxyRefitV", "d_{xy}(V_{refit}) of probe track;track d_{xy}(V_{fit}) (cm);tracks", 200, -0.5, 0.5);
1279 
1280  h_probez0RefitV_ = ProbeFeatures.make<TH1F>(
1281  "h_probez0RefitV", "z_{0}(V_{refit}) of probe track;track z_{0}(V_{fit}) (cm);tracks", 200, -1., 1.);
1282  h_probed0RefitV_ = ProbeFeatures.make<TH1F>(
1283  "h_probed0RefitV", "d_{0}(V_{refit}) of probe track;track d_{0}(V_{fit}) (cm);tracks", 200, -1., 1.);
1284 
1285  h_probed3DRefitV_ = ProbeFeatures.make<TH1F>(
1286  "h_probed3DRefitV", "d_{3D}(V_{refit}) of probe track;track d_{3D}(V_{fit}) (cm);tracks", 200, 0., 1.);
1287  h_probereszRefitV_ = ProbeFeatures.make<TH1F>(
1288  "h_probeReszRefitV", "z_{track} -z_{V_{refit}};track res_{z}(V_{refit}) (cm);tracks", 200, -1., 1.);
1289 
1290  h_probeRecoVSigZ_ = ProbeFeatures.make<TH1F>(
1291  "h_probeRecoVSigZ", "Longitudinal DCA Significance (reco);d_{z}(V_{off})/#sigma_{dz};tracks", 100, -8, 8);
1292  h_probeRecoVSigXY_ = ProbeFeatures.make<TH1F>(
1293  "h_probeRecoVSigXY", "Transverse DCA Significance (reco);d_{xy}(V_{off})/#sigma_{dxy};tracks", 100, -8, 8);
1294  h_probeRefitVSigZ_ = ProbeFeatures.make<TH1F>(
1295  "h_probeRefitVSigZ", "Longitudinal DCA Significance (refit);d_{z}(V_{fit})/#sigma_{dz};tracks", 100, -8, 8);
1296  h_probeRefitVSigXY_ = ProbeFeatures.make<TH1F>(
1297  "h_probeRefitVSigXY", "Transverse DCA Significance (refit);d_{xy}(V_{fit})/#sigma_{dxy};tracks", 100, -8, 8);
1298  h_probeRefitVSig3D_ = ProbeFeatures.make<TH1F>(
1299  "h_probeRefitVSig3D", "3D DCA Significance (refit);d_{3D}/#sigma_{3D};tracks", 100, 0., 20.);
1301  ProbeFeatures.make<TH1F>("h_probeRefitVLogSig3D",
1302  "log_{10}(3D DCA-Significance) (refit);log_{10}(d_{3D}/#sigma_{3D});tracks",
1303  100,
1304  -5.,
1305  4.);
1306  h_probeRefitVSigResZ_ = ProbeFeatures.make<TH1F>(
1307  "h_probeRefitVSigResZ",
1308  "Longitudinal residual significance (refit);(z_{track} -z_{V_{fit}})/#sigma_{res_{z}};tracks",
1309  100,
1310  -8,
1311  8);
1312 
1313  h_probeHits_ = ProbeFeatures.make<TH1F>("h_probeNRechits", "N_{hits} ;N_{hits} ;tracks", 40, -0.5, 39.5);
1314  h_probeHits1D_ = ProbeFeatures.make<TH1F>("h_probeNRechits1D", "N_{hits} 1D ;N_{hits} 1D ;tracks", 40, -0.5, 39.5);
1315  h_probeHits2D_ = ProbeFeatures.make<TH1F>("h_probeNRechits2D", "N_{hits} 2D ;N_{hits} 2D ;tracks", 40, -0.5, 39.5);
1317  ProbeFeatures.make<TH1F>("h_probeNRechitsTIB", "N_{hits} TIB ;N_{hits} TIB;tracks", 40, -0.5, 39.5);
1319  ProbeFeatures.make<TH1F>("h_probeNRechitsTOB", "N_{hits} TOB ;N_{hits} TOB;tracks", 40, -0.5, 39.5);
1321  ProbeFeatures.make<TH1F>("h_probeNRechitsTID", "N_{hits} TID ;N_{hits} TID;tracks", 40, -0.5, 39.5);
1323  ProbeFeatures.make<TH1F>("h_probeNRechitsTEC", "N_{hits} TEC ;N_{hits} TEC;tracks", 40, -0.5, 39.5);
1325  ProbeFeatures.make<TH1F>("h_probeNRechitsBPIX", "N_{hits} BPIX;N_{hits} BPIX;tracks", 40, -0.5, 39.5);
1327  ProbeFeatures.make<TH1F>("h_probeNRechitsFPIX", "N_{hits} FPIX;N_{hits} FPIX;tracks", 40, -0.5, 39.5);
1328 
1329  h_probeL1Ladder_ = ProbeFeatures.make<TH1F>(
1330  "h_probeL1Ladder", "Ladder number (L1 hit); ladder number", nLadders_ + 2, -1.5, nLadders_ + 0.5);
1331  h_probeL1Module_ = ProbeFeatures.make<TH1F>(
1332  "h_probeL1Module", "Module number (L1 hit); module number", nModZ_ + 2, -1.5, nModZ_ + 0.5);
1333 
1334  h2_probeLayer1Map_ = ProbeFeatures.make<TH2F>("h2_probeLayer1Map",
1335  "Position in Layer 1 of first hit;module number;ladder number",
1336  nModZ_,
1337  0.5,
1338  nModZ_ + 0.5,
1339  nLadders_,
1340  0.5,
1341  nLadders_ + 0.5);
1342 
1343  h2_probePassingLayer1Map_ = ProbeFeatures.make<TH2F>("h2_probePassingLayer1Map",
1344  "Position in Layer 1 of first hit;module number;ladder number",
1345  nModZ_,
1346  0.5,
1347  nModZ_ + 0.5,
1348  nLadders_,
1349  0.5,
1350  nLadders_ + 0.5);
1352  ProbeFeatures.make<TH1I>("h_probeHasBPixL1Overlap", "n. hits in L1;n. L1-BPix hits;tracks", 5, -0.5, 4.5);
1353  h_probeL1ClusterProb_ = ProbeFeatures.make<TH1F>(
1354  "h_probeL1ClusterProb",
1355  "log_{10}(Cluster Probability) for Layer1 hits;log_{10}(cluster probability); n. Layer1 hits",
1356  100,
1357  -10.,
1358  0.);
1359 
1360  // refit vertex features
1361  TFileDirectory RefitVertexFeatures = fs->mkdir("RefitVertexFeatures");
1362  h_fitVtxNtracks_ = RefitVertexFeatures.make<TH1F>(
1363  "h_fitVtxNtracks", "N_{trks} used in vertex fit;N^{fit}_{tracks};vertices", 100, -0.5, 99.5);
1364  h_fitVtxNdof_ = RefitVertexFeatures.make<TH1F>(
1365  "h_fitVtxNdof", "N_{DOF} of vertex fit;N_{DOF} of refit vertex;vertices", 100, -0.5, 99.5);
1366  h_fitVtxChi2_ = RefitVertexFeatures.make<TH1F>(
1367  "h_fitVtxChi2", "#chi^{2} of vertex fit;vertex #chi^{2};vertices", 100, -0.5, 99.5);
1368  h_fitVtxChi2ndf_ = RefitVertexFeatures.make<TH1F>(
1369  "h_fitVtxChi2ndf", "#chi^{2}/ndf of vertex fit;vertex #chi^{2}/ndf;vertices", 100, -0.5, 9.5);
1370  h_fitVtxChi2Prob_ = RefitVertexFeatures.make<TH1F>(
1371  "h_fitVtxChi2Prob", "Prob(#chi^{2},ndf) of vertex fit;Prob(#chi^{2},ndf);vertices", 40, 0., 1.);
1372  h_fitVtxTrackWeights_ = RefitVertexFeatures.make<TH1F>(
1373  "h_fitVtxTrackWeights", "track weights associated to track;track weights;tracks", 40, 0., 1.);
1374  h_fitVtxTrackAverageWeight_ = RefitVertexFeatures.make<TH1F>(
1375  "h_fitVtxTrackAverageWeight_", "average track weight per vertex;#LT track weight #GT;vertices", 40, 0., 1.);
1376 
1377  if (useTracksFromRecoVtx_) {
1378  TFileDirectory RecoVertexFeatures = fs->mkdir("RecoVertexFeatures");
1380  RecoVertexFeatures.make<TH1F>("h_recoVtxNtracks", "N^{vtx}_{trks};N^{vtx}_{trks};vertices", 100, -0.5, 99.5);
1382  RecoVertexFeatures.make<TH1F>("h_recoVtxChi2ndf", "#chi^{2}/ndf vtx;#chi^{2}/ndf vtx;vertices", 10, -0.5, 9.5);
1383  h_recoVtxChi2Prob_ = RecoVertexFeatures.make<TH1F>(
1384  "h_recoVtxChi2Prob", "Prob(#chi^{2},ndf);Prob(#chi^{2},ndf);vertices", 40, 0., 1.);
1385  h_recoVtxSumPt_ =
1386  RecoVertexFeatures.make<TH1F>("h_recoVtxSumPt", "Sum(p^{trks}_{T});Sum(p^{trks}_{T});vertices", 100, 0., 200.);
1387  }
1388 
1389  TFileDirectory DA = fs->mkdir("DA");
1390  //DA.cd();
1391  hDA = bookVertexHistograms(DA);
1392  //for(std::map<std::string,TH1*>::const_iterator hist=hDA.begin(); hist!=hDA.end(); hist++){
1393  //hist->second->SetDirectory(DA);
1394  // DA.make<TH1F>(hist->second);
1395  // }
1396 
1397  // initialize the residuals histograms
1398 
1399  const float dxymax_phi = theDetails_.getHigh(PVValHelper::dxy, PVValHelper::phi);
1400  const float dzmax_phi = theDetails_.getHigh(PVValHelper::dz, PVValHelper::eta);
1401  const float dxymax_eta = theDetails_.getHigh(PVValHelper::dxy, PVValHelper::phi);
1402  const float dzmax_eta = theDetails_.getHigh(PVValHelper::dz, PVValHelper::eta);
1403  //const float d3Dmax_phi = theDetails_.getHigh(PVValHelper::d3D,PVValHelper::phi);
1404  const float d3Dmax_eta = theDetails_.getHigh(PVValHelper::d3D, PVValHelper::eta);
1405 
1407  //
1408  // Unbiased track-to-vertex residuals
1409  // The vertex is refit without the probe track
1410  //
1412 
1413  // _ _ _ _ ___ _ _ _
1414  // /_\ | |__ ___ ___| |_ _| |_ ___ | _ \___ __(_)__| |_ _ __ _| |___
1415  // / _ \| '_ (_-</ _ \ | || | _/ -_) | / -_|_-< / _` | || / _` | (_-<
1416  // /_/ \_\_.__/__/\___/_|\_,_|\__\___| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1417  //
1418 
1419  TFileDirectory AbsTransPhiRes = fs->mkdir("Abs_Transv_Phi_Residuals");
1424 
1425  TFileDirectory AbsTransEtaRes = fs->mkdir("Abs_Transv_Eta_Residuals");
1430 
1431  TFileDirectory AbsLongPhiRes = fs->mkdir("Abs_Long_Phi_Residuals");
1434 
1435  TFileDirectory AbsLongEtaRes = fs->mkdir("Abs_Long_Eta_Residuals");
1438 
1439  TFileDirectory Abs3DPhiRes = fs->mkdir("Abs_3D_Phi_Residuals");
1442 
1443  TFileDirectory Abs3DEtaRes = fs->mkdir("Abs_3D_Eta_Residuals");
1446 
1447  TFileDirectory NormTransPhiRes = fs->mkdir("Norm_Transv_Phi_Residuals");
1450 
1451  TFileDirectory NormTransEtaRes = fs->mkdir("Norm_Transv_Eta_Residuals");
1454 
1455  TFileDirectory NormLongPhiRes = fs->mkdir("Norm_Long_Phi_Residuals");
1458 
1459  TFileDirectory NormLongEtaRes = fs->mkdir("Norm_Long_Eta_Residuals");
1462 
1463  TFileDirectory Norm3DPhiRes = fs->mkdir("Norm_3D_Phi_Residuals");
1466 
1467  TFileDirectory Norm3DEtaRes = fs->mkdir("Norm_3D_Eta_Residuals");
1470 
1471  TFileDirectory AbsDoubleDiffRes = fs->mkdir("Abs_DoubleDiffResiduals");
1472  TFileDirectory NormDoubleDiffRes = fs->mkdir("Norm_DoubleDiffResiduals");
1473 
1474  TFileDirectory AbsL1Map = fs->mkdir("Abs_L1Residuals");
1475  TFileDirectory NormL1Map = fs->mkdir("Norm_L1Residuals");
1476 
1477  // book residuals vs pT histograms
1478 
1479  TFileDirectory AbsTranspTRes = fs->mkdir("Abs_Transv_pT_Residuals");
1481 
1482  TFileDirectory AbsLongpTRes = fs->mkdir("Abs_Long_pT_Residuals");
1484 
1485  TFileDirectory NormTranspTRes = fs->mkdir("Norm_Transv_pT_Residuals");
1487 
1488  TFileDirectory NormLongpTRes = fs->mkdir("Norm_Long_pT_Residuals");
1490 
1491  // book residuals vs pT histograms in central region (|eta|<1.0)
1492 
1493  TFileDirectory AbsTranspTCentralRes = fs->mkdir("Abs_Transv_pTCentral_Residuals");
1495 
1496  TFileDirectory AbsLongpTCentralRes = fs->mkdir("Abs_Long_pTCentral_Residuals");
1498 
1499  TFileDirectory NormTranspTCentralRes = fs->mkdir("Norm_Transv_pTCentral_Residuals");
1502 
1503  TFileDirectory NormLongpTCentralRes = fs->mkdir("Norm_Long_pTCentral_Residuals");
1506 
1507  // book residuals vs module number
1508 
1509  TFileDirectory AbsTransModZRes = fs->mkdir("Abs_Transv_modZ_Residuals");
1511 
1512  TFileDirectory AbsLongModZRes = fs->mkdir("Abs_Long_modZ_Residuals");
1514 
1515  // _ _ _ _ _ ___ _ _ _
1516  // | \| |___ _ _ _ __ __ _| (_)______ __| | | _ \___ __(_)__| |_ _ __ _| |___
1517  // | .` / _ \ '_| ' \/ _` | | |_ / -_) _` | | / -_|_-< / _` | || / _` | (_-<
1518  // |_|\_\___/_| |_|_|_\__,_|_|_/__\___\__,_| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1519  //
1520 
1521  TFileDirectory NormTransModZRes = fs->mkdir("Norm_Transv_modZ_Residuals");
1523 
1524  TFileDirectory NormLongModZRes = fs->mkdir("Norm_Long_modZ_Residuals");
1526 
1527  TFileDirectory AbsTransLadderRes = fs->mkdir("Abs_Transv_ladder_Residuals");
1529 
1530  TFileDirectory AbsTransLadderResOverlap = fs->mkdir("Abs_Transv_ladderOverlap_Residuals");
1533 
1534  TFileDirectory AbsTransLadderResNoOverlap = fs->mkdir("Abs_Transv_ladderNoOverlap_Residuals");
1537 
1538  TFileDirectory AbsLongLadderRes = fs->mkdir("Abs_Long_ladder_Residuals");
1540 
1541  TFileDirectory NormTransLadderRes = fs->mkdir("Norm_Transv_ladder_Residuals");
1544 
1545  TFileDirectory NormLongLadderRes = fs->mkdir("Norm_Long_ladder_Residuals");
1548 
1549  // book residuals as function of nLadders and nModules
1550 
1551  for (unsigned int iLadder = 0; iLadder < nLadders_; iLadder++) {
1552  for (unsigned int iModule = 0; iModule < nModZ_; iModule++) {
1553  a_dxyL1ResidualsMap[iLadder][iModule] =
1554  AbsL1Map.make<TH1F>(Form("histo_dxy_ladder%i_module%i", iLadder, iModule),
1555  Form("d_{xy} ladder=%i module=%i;d_{xy} [#mum];tracks", iLadder, iModule),
1557  -dzmax_eta,
1558  dzmax_eta);
1559 
1560  a_dzL1ResidualsMap[iLadder][iModule] =
1561  AbsL1Map.make<TH1F>(Form("histo_dz_ladder%i_module%i", iLadder, iModule),
1562  Form("d_{z} ladder=%i module=%i;d_{z} [#mum];tracks", iLadder, iModule),
1564  -dzmax_eta,
1565  dzmax_eta);
1566 
1567  n_dxyL1ResidualsMap[iLadder][iModule] =
1568  NormL1Map.make<TH1F>(Form("histo_norm_dxy_ladder%i_module%i", iLadder, iModule),
1569  Form("d_{xy} ladder=%i module=%i;d_{xy}/#sigma_{d_{xy}};tracks", iLadder, iModule),
1571  -dzmax_eta / 100,
1572  dzmax_eta / 100);
1573 
1574  n_dzL1ResidualsMap[iLadder][iModule] =
1575  NormL1Map.make<TH1F>(Form("histo_norm_dz_ladder%i_module%i", iLadder, iModule),
1576  Form("d_{z} ladder=%i module=%i;d_{z}/#sigma_{d_{z}};tracks", iLadder, iModule),
1578  -dzmax_eta / 100,
1579  dzmax_eta / 100);
1580  }
1581  }
1582 
1583  // book residuals as function of phi and eta
1584 
1585  for (int i = 0; i < nBins_; ++i) {
1586  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
1587  float phiL = theDetails_.trendbins[PVValHelper::phi][i + 1];
1588 
1589  // ___ _ _ ___ _ __ __ ___ _ _ _
1590  // | \ ___ _ _| |__| |___| \(_)/ _|/ _| | _ \___ __(_)__| |_ _ __ _| |___
1591  // | |) / _ \ || | '_ \ / -_) |) | | _| _| | / -_|_-< / _` | || / _` | (_-<
1592  // |___/\___/\_,_|_.__/_\___|___/|_|_| |_| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1593 
1594  for (int j = 0; j < nBins_; ++j) {
1595  float etaF = theDetails_.trendbins[PVValHelper::eta][j];
1596  float etaL = theDetails_.trendbins[PVValHelper::eta][j + 1];
1597 
1598  a_dxyResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(
1599  Form("histo_dxy_eta_plot%i_phi_plot%i", i, j),
1600  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy};tracks", etaF, etaL, phiF, phiL),
1602  -dzmax_eta,
1603  dzmax_eta);
1604 
1605  a_dzResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(
1606  Form("histo_dz_eta_plot%i_phi_plot%i", i, j),
1607  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z};tracks", etaF, etaL, phiF, phiL),
1609  -dzmax_eta,
1610  dzmax_eta);
1611 
1612  a_d3DResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(
1613  Form("histo_d3D_eta_plot%i_phi_plot%i", i, j),
1614  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{3D};tracks", etaF, etaL, phiF, phiL),
1616  0.,
1617  d3Dmax_eta);
1618 
1619  n_dxyResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(
1620  Form("histo_norm_dxy_eta_plot%i_phi_plot%i", i, j),
1621  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy}/#sigma_{d_{xy}};tracks",
1622  etaF,
1623  etaL,
1624  phiF,
1625  phiL),
1627  -dzmax_eta / 100,
1628  dzmax_eta / 100);
1629 
1630  n_dzResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(
1631  Form("histo_norm_dz_eta_plot%i_phi_plot%i", i, j),
1632  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z}/#sigma_{d_{z}};tracks",
1633  etaF,
1634  etaL,
1635  phiF,
1636  phiL),
1638  -dzmax_eta / 100,
1639  dzmax_eta / 100);
1640 
1641  n_d3DResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(
1642  Form("histo_norm_d3D_eta_plot%i_phi_plot%i", i, j),
1643  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{3D}/#sigma_{d_{3D}};tracks",
1644  etaF,
1645  etaL,
1646  phiF,
1647  phiL),
1649  0.,
1650  d3Dmax_eta);
1651  }
1652  }
1653 
1654  // declaration of the directories
1655 
1656  TFileDirectory BiasVsParameter = fs->mkdir("BiasVsParameter");
1657 
1658  a_dxyVsPhi = BiasVsParameter.make<TH2F>("h2_dxy_vs_phi",
1659  "d_{xy} vs track #phi;track #phi [rad];track d_{xy}(PV) [#mum]",
1660  nBins_,
1661  -M_PI,
1662  M_PI,
1664  -dxymax_phi,
1665  dxymax_phi);
1666 
1667  a_dzVsPhi = BiasVsParameter.make<TH2F>("h2_dz_vs_phi",
1668  "d_{z} vs track #phi;track #phi [rad];track d_{z}(PV) [#mum]",
1669  nBins_,
1670  -M_PI,
1671  M_PI,
1673  -dzmax_phi,
1674  dzmax_phi);
1675 
1676  n_dxyVsPhi = BiasVsParameter.make<TH2F>(
1677  "h2_n_dxy_vs_phi",
1678  "d_{xy}/#sigma_{d_{xy}} vs track #phi;track #phi [rad];track d_{xy}(PV)/#sigma_{d_{xy}}",
1679  nBins_,
1680  -M_PI,
1681  M_PI,
1683  -dxymax_phi / 100.,
1684  dxymax_phi / 100.);
1685 
1686  n_dzVsPhi =
1687  BiasVsParameter.make<TH2F>("h2_n_dz_vs_phi",
1688  "d_{z}/#sigma_{d_{z}} vs track #phi;track #phi [rad];track d_{z}(PV)/#sigma_{d_{z}}",
1689  nBins_,
1690  -M_PI,
1691  M_PI,
1693  -dzmax_phi / 100.,
1694  dzmax_phi / 100.);
1695 
1696  a_dxyVsEta = BiasVsParameter.make<TH2F>("h2_dxy_vs_eta",
1697  "d_{xy} vs track #eta;track #eta;track d_{xy}(PV) [#mum]",
1698  nBins_,
1699  -etaOfProbe_,
1700  etaOfProbe_,
1702  -dxymax_eta,
1703  dzmax_eta);
1704 
1705  a_dzVsEta = BiasVsParameter.make<TH2F>("h2_dz_vs_eta",
1706  "d_{z} vs track #eta;track #eta;track d_{z}(PV) [#mum]",
1707  nBins_,
1708  -etaOfProbe_,
1709  etaOfProbe_,
1711  -dzmax_eta,
1712  dzmax_eta);
1713 
1714  n_dxyVsEta =
1715  BiasVsParameter.make<TH2F>("h2_n_dxy_vs_eta",
1716  "d_{xy}/#sigma_{d_{xy}} vs track #eta;track #eta;track d_{xy}(PV)/#sigma_{d_{xy}}",
1717  nBins_,
1718  -etaOfProbe_,
1719  etaOfProbe_,
1721  -dxymax_eta / 100.,
1722  dxymax_eta / 100.);
1723 
1724  n_dzVsEta = BiasVsParameter.make<TH2F>("h2_n_dz_vs_eta",
1725  "d_{z}/#sigma_{d_{z}} vs track #eta;track #eta;track d_{z}(PV)/#sigma_{d_{z}}",
1726  nBins_,
1727  -etaOfProbe_,
1728  etaOfProbe_,
1730  -dzmax_eta / 100.,
1731  dzmax_eta / 100.);
1732 
1733  MeanTrendsDir = fs->mkdir("MeanTrends");
1734  WidthTrendsDir = fs->mkdir("WidthTrends");
1735  MedianTrendsDir = fs->mkdir("MedianTrends");
1736  MADTrendsDir = fs->mkdir("MADTrends");
1737 
1738  Mean2DMapsDir = fs->mkdir("MeanMaps");
1739  Width2DMapsDir = fs->mkdir("WidthMaps");
1740 
1741  double highedge = nBins_ - 0.5;
1742  double lowedge = -0.5;
1743 
1744  // means and widths from the fit
1745 
1747  MeanTrendsDir.make<TH1F>("means_dxy_phi",
1748  "#LT d_{xy} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy} #GT [#mum]",
1749  nBins_,
1750  lowedge,
1751  highedge);
1752 
1754  WidthTrendsDir.make<TH1F>("widths_dxy_phi",
1755  "#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{xy}} [#mum]",
1756  nBins_,
1757  lowedge,
1758  highedge);
1759 
1761  MeanTrendsDir.make<TH1F>("means_dz_phi",
1762  "#LT d_{z} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z} #GT [#mum]",
1763  nBins_,
1764  lowedge,
1765  highedge);
1766 
1768  WidthTrendsDir.make<TH1F>("widths_dz_phi",
1769  "#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{z}} [#mum]",
1770  nBins_,
1771  lowedge,
1772  highedge);
1773 
1775  "means_dxy_eta", "#LT d_{xy} #GT vs #eta sector;#eta (sector);#LT d_{xy} #GT [#mum]", nBins_, lowedge, highedge);
1776 
1777  a_dxyEtaWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_eta",
1778  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{xy}} [#mum]",
1779  nBins_,
1780  lowedge,
1781  highedge);
1782 
1784  "means_dz_eta", "#LT d_{z} #GT vs #eta sector;#eta (sector);#LT d_{z} #GT [#mum]", nBins_, lowedge, highedge);
1785 
1787  "widths_dz_eta", "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{z}} [#mum]", nBins_, lowedge, highedge);
1788 
1790  "norm_means_dxy_phi",
1791  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy}/#sigma_{d_{xy}} #GT",
1792  nBins_,
1793  lowedge,
1794  highedge);
1795 
1797  "norm_widths_dxy_phi",
1798  "width(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;#varphi (sector) [degrees]; width(d_{xy}/#sigma_{d_{xy}})",
1799  nBins_,
1800  lowedge,
1801  highedge);
1802 
1804  "norm_means_dz_phi",
1805  "#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z}/#sigma_{d_{z}} #GT",
1806  nBins_,
1807  lowedge,
1808  highedge);
1809 
1811  "norm_widths_dz_phi",
1812  "width(d_{z}/#sigma_{d_{z}}) vs #phi sector;#varphi (sector) [degrees];width(d_{z}/#sigma_{d_{z}})",
1813  nBins_,
1814  lowedge,
1815  highedge);
1816 
1818  "norm_means_dxy_eta",
1819  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;#eta (sector);#LT d_{xy}/#sigma_{d_{z}} #GT",
1820  nBins_,
1821  lowedge,
1822  highedge);
1823 
1825  "norm_widths_dxy_eta",
1826  "width(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;#eta (sector);width(d_{xy}/#sigma_{d_{z}})",
1827  nBins_,
1828  lowedge,
1829  highedge);
1830 
1832  MeanTrendsDir.make<TH1F>("norm_means_dz_eta",
1833  "#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;#eta (sector);#LT d_{z}/#sigma_{d_{z}} #GT",
1834  nBins_,
1835  lowedge,
1836  highedge);
1837 
1839  WidthTrendsDir.make<TH1F>("norm_widths_dz_eta",
1840  "width(d_{z}/#sigma_{d_{z}}) vs #eta sector;#eta (sector);width(d_{z}/#sigma_{d_{z}})",
1841  nBins_,
1842  lowedge,
1843  highedge);
1844 
1845  // means and widhts vs pT and pTCentral
1846 
1847  a_dxypTMeanTrend = MeanTrendsDir.make<TH1F>("means_dxy_pT",
1848  "#LT d_{xy} #GT vs pT;p_{T} [GeV];#LT d_{xy} #GT [#mum]",
1849  mypT_bins_.size() - 1,
1850  mypT_bins_.data());
1851 
1852  a_dxypTWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_pT",
1853  "#sigma_{d_{xy}} vs pT;p_{T} [GeV];#sigma_{d_{xy}} [#mum]",
1854  mypT_bins_.size() - 1,
1855  mypT_bins_.data());
1856 
1858  "means_dz_pT", "#LT d_{z} #GT vs pT;p_{T} [GeV];#LT d_{z} #GT [#mum]", mypT_bins_.size() - 1, mypT_bins_.data());
1859 
1860  a_dzpTWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_pT",
1861  "#sigma_{d_{z}} vs pT;p_{T} [GeV];#sigma_{d_{z}} [#mum]",
1862  mypT_bins_.size() - 1,
1863  mypT_bins_.data());
1864 
1866  MeanTrendsDir.make<TH1F>("norm_means_dxy_pT",
1867  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs pT;p_{T} [GeV];#LT d_{xy}/#sigma_{d_{xy}} #GT",
1868  mypT_bins_.size() - 1,
1869  mypT_bins_.data());
1870 
1872  WidthTrendsDir.make<TH1F>("norm_widths_dxy_pT",
1873  "width(d_{xy}/#sigma_{d_{xy}}) vs pT;p_{T} [GeV]; width(d_{xy}/#sigma_{d_{xy}})",
1874  mypT_bins_.size() - 1,
1875  mypT_bins_.data());
1876 
1877  n_dzpTMeanTrend =
1878  MeanTrendsDir.make<TH1F>("norm_means_dz_pT",
1879  "#LT d_{z}/#sigma_{d_{z}} #GT vs pT;p_{T} [GeV];#LT d_{z}/#sigma_{d_{z}} #GT",
1880  mypT_bins_.size() - 1,
1881  mypT_bins_.data());
1882 
1884  WidthTrendsDir.make<TH1F>("norm_widths_dz_pT",
1885  "width(d_{z}/#sigma_{d_{z}}) vs pT;p_{T} [GeV];width(d_{z}/#sigma_{d_{z}})",
1886  mypT_bins_.size() - 1,
1887  mypT_bins_.data());
1888 
1890  MeanTrendsDir.make<TH1F>("means_dxy_pTCentral",
1891  "#LT d_{xy} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{xy} #GT [#mum]",
1892  mypT_bins_.size() - 1,
1893  mypT_bins_.data());
1894 
1896  WidthTrendsDir.make<TH1F>("widths_dxy_pTCentral",
1897  "#sigma_{d_{xy}} vs p_{T};p_{T}(|#eta|<1.) [GeV];#sigma_{d_{xy}} [#mum]",
1898  mypT_bins_.size() - 1,
1899  mypT_bins_.data());
1900 
1902  MeanTrendsDir.make<TH1F>("means_dz_pTCentral",
1903  "#LT d_{z} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{z} #GT [#mum]",
1904  mypT_bins_.size() - 1,
1905  mypT_bins_.data());
1906 
1908  WidthTrendsDir.make<TH1F>("widths_dz_pTCentral",
1909  "#sigma_{d_{z}} vs p_{T};p_{T}(|#eta|<1.) [GeV];#sigma_{d_{z}} [#mum]",
1910  mypT_bins_.size() - 1,
1911  mypT_bins_.data());
1912 
1914  "norm_means_dxy_pTCentral",
1915  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{xy}/#sigma_{d_{z}} #GT",
1916  mypT_bins_.size() - 1,
1917  mypT_bins_.data());
1918 
1920  "norm_widths_dxy_pTCentral",
1921  "width(d_{xy}/#sigma_{d_{xy}}) vs p_{T};p_{T}(|#eta|<1.) [GeV];width(d_{xy}/#sigma_{d_{z}})",
1922  mypT_bins_.size() - 1,
1923  mypT_bins_.data());
1924 
1926  "norm_means_dz_pTCentral",
1927  "#LT d_{z}/#sigma_{d_{z}} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{z}/#sigma_{d_{z}} #GT",
1928  mypT_bins_.size() - 1,
1929  mypT_bins_.data());
1930 
1932  "norm_widths_dz_pTCentral",
1933  "width(d_{z}/#sigma_{d_{z}}) vs p_{T};p_{T}(|#eta|<1.) [GeV];width(d_{z}/#sigma_{d_{z}})",
1934  mypT_bins_.size() - 1,
1935  mypT_bins_.data());
1936 
1937  // 2D maps
1938 
1939  a_dxyMeanMap = Mean2DMapsDir.make<TH2F>("means_dxy_map",
1940  "#LT d_{xy} #GT map;#eta (sector);#varphi (sector) [degrees]",
1941  nBins_,
1942  lowedge,
1943  highedge,
1944  nBins_,
1945  lowedge,
1946  highedge);
1947 
1948  a_dzMeanMap = Mean2DMapsDir.make<TH2F>("means_dz_map",
1949  "#LT d_{z} #GT map;#eta (sector);#varphi (sector) [degrees]",
1950  nBins_,
1951  lowedge,
1952  highedge,
1953  nBins_,
1954  lowedge,
1955  highedge);
1956 
1957  n_dxyMeanMap = Mean2DMapsDir.make<TH2F>("norm_means_dxy_map",
1958  "#LT d_{xy}/#sigma_{d_{xy}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1959  nBins_,
1960  lowedge,
1961  highedge,
1962  nBins_,
1963  lowedge,
1964  highedge);
1965 
1966  n_dzMeanMap = Mean2DMapsDir.make<TH2F>("norm_means_dz_map",
1967  "#LT d_{z}/#sigma_{d_{z}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1968  nBins_,
1969  lowedge,
1970  highedge,
1971  nBins_,
1972  lowedge,
1973  highedge);
1974 
1975  a_dxyWidthMap = Width2DMapsDir.make<TH2F>("widths_dxy_map",
1976  "#sigma_{d_{xy}} map;#eta (sector);#varphi (sector) [degrees]",
1977  nBins_,
1978  lowedge,
1979  highedge,
1980  nBins_,
1981  lowedge,
1982  highedge);
1983 
1984  a_dzWidthMap = Width2DMapsDir.make<TH2F>("widths_dz_map",
1985  "#sigma_{d_{z}} map;#eta (sector);#varphi (sector) [degrees]",
1986  nBins_,
1987  lowedge,
1988  highedge,
1989  nBins_,
1990  lowedge,
1991  highedge);
1992 
1993  n_dxyWidthMap =
1994  Width2DMapsDir.make<TH2F>("norm_widths_dxy_map",
1995  "width(d_{xy}/#sigma_{d_{xy}}) map;#eta (sector);#varphi (sector) [degrees]",
1996  nBins_,
1997  lowedge,
1998  highedge,
1999  nBins_,
2000  lowedge,
2001  highedge);
2002 
2003  n_dzWidthMap = Width2DMapsDir.make<TH2F>("norm_widths_dz_map",
2004  "width(d_{z}/#sigma_{d_{z}}) map;#eta (sector);#varphi (sector) [degrees]",
2005  nBins_,
2006  lowedge,
2007  highedge,
2008  nBins_,
2009  lowedge,
2010  highedge);
2011 
2012  // medians and MADs
2013 
2015  MedianTrendsDir.make<TH1F>("medians_dxy_phi",
2016  "Median of d_{xy} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}) [#mum]",
2017  nBins_,
2018  lowedge,
2019  highedge);
2020 
2022  "MADs_dxy_phi",
2023  "Median absolute deviation of d_{xy} vs #phi sector;#varphi (sector) [degrees];MAD(d_{xy}) [#mum]",
2024  nBins_,
2025  lowedge,
2026  highedge);
2027 
2029  MedianTrendsDir.make<TH1F>("medians_dz_phi",
2030  "Median of d_{z} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}) [#mum]",
2031  nBins_,
2032  lowedge,
2033  highedge);
2034 
2036  "MADs_dz_phi",
2037  "Median absolute deviation of d_{z} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}) [#mum]",
2038  nBins_,
2039  lowedge,
2040  highedge);
2041 
2043  MedianTrendsDir.make<TH1F>("medians_dxy_eta",
2044  "Median of d_{xy} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}) [#mum]",
2045  nBins_,
2046  lowedge,
2047  highedge);
2048 
2050  MADTrendsDir.make<TH1F>("MADs_dxy_eta",
2051  "Median absolute deviation of d_{xy} vs #eta sector;#eta (sector);MAD(d_{xy}) [#mum]",
2052  nBins_,
2053  lowedge,
2054  highedge);
2055 
2057  MedianTrendsDir.make<TH1F>("medians_dz_eta",
2058  "Median of d_{z} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}) [#mum]",
2059  nBins_,
2060  lowedge,
2061  highedge);
2062 
2063  a_dzEtaMADTrend =
2064  MADTrendsDir.make<TH1F>("MADs_dz_eta",
2065  "Median absolute deviation of d_{z} vs #eta sector;#eta (sector);MAD(d_{z}) [#mum]",
2066  nBins_,
2067  lowedge,
2068  highedge);
2069 
2071  "norm_medians_dxy_phi",
2072  "Median of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}/#sigma_{d_{xy}})",
2073  nBins_,
2074  lowedge,
2075  highedge);
2076 
2077  n_dxyPhiMADTrend = MADTrendsDir.make<TH1F>("norm_MADs_dxy_phi",
2078  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #phi "
2079  "sector;#varphi (sector) [degrees]; MAD(d_{xy}/#sigma_{d_{xy}})",
2080  nBins_,
2081  lowedge,
2082  highedge);
2083 
2085  "norm_medians_dz_phi",
2086  "Median of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2087  nBins_,
2088  lowedge,
2089  highedge);
2090 
2091  n_dzPhiMADTrend = MADTrendsDir.make<TH1F>("norm_MADs_dz_phi",
2092  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi "
2093  "(sector) [degrees];MAD(d_{z}/#sigma_{d_{z}})",
2094  nBins_,
2095  lowedge,
2096  highedge);
2097 
2099  "norm_medians_dxy_eta",
2100  "Median of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}/#sigma_{d_{z}})",
2101  nBins_,
2102  lowedge,
2103  highedge);
2104 
2106  "norm_MADs_dxy_eta",
2107  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);MAD(d_{xy}/#sigma_{d_{z}})",
2108  nBins_,
2109  lowedge,
2110  highedge);
2111 
2113  "norm_medians_dz_eta",
2114  "Median of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2115  nBins_,
2116  lowedge,
2117  highedge);
2118 
2120  "norm_MADs_dz_eta",
2121  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);MAD(d_{z}/#sigma_{d_{z}})",
2122  nBins_,
2123  lowedge,
2124  highedge);
2125 
2127  //
2128  // plots of biased residuals
2129  // The vertex includes the probe track
2130  //
2132 
2133  if (useTracksFromRecoVtx_) {
2134  TFileDirectory AbsTransPhiBiasRes = fs->mkdir("Abs_Transv_Phi_BiasResiduals");
2136 
2137  TFileDirectory AbsTransEtaBiasRes = fs->mkdir("Abs_Transv_Eta_BiasResiduals");
2139 
2140  TFileDirectory AbsLongPhiBiasRes = fs->mkdir("Abs_Long_Phi_BiasResiduals");
2142 
2143  TFileDirectory AbsLongEtaBiasRes = fs->mkdir("Abs_Long_Eta_BiasResiduals");
2145 
2146  TFileDirectory NormTransPhiBiasRes = fs->mkdir("Norm_Transv_Phi_BiasResiduals");
2148 
2149  TFileDirectory NormTransEtaBiasRes = fs->mkdir("Norm_Transv_Eta_BiasResiduals");
2151 
2152  TFileDirectory NormLongPhiBiasRes = fs->mkdir("Norm_Long_Phi_BiasResiduals");
2154 
2155  TFileDirectory NormLongEtaBiasRes = fs->mkdir("Norm_Long_Eta_BiasResiduals");
2157 
2158  TFileDirectory AbsDoubleDiffBiasRes = fs->mkdir("Abs_DoubleDiffBiasResiduals");
2159  TFileDirectory NormDoubleDiffBiasRes = fs->mkdir("Norm_DoubleDiffBiasResiduals");
2160 
2161  for (int i = 0; i < nBins_; ++i) {
2162  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
2163  float phiL = theDetails_.trendbins[PVValHelper::phi][i + 1];
2164 
2165  for (int j = 0; j < nBins_; ++j) {
2166  float etaF = theDetails_.trendbins[PVValHelper::eta][j];
2167  float etaL = theDetails_.trendbins[PVValHelper::eta][j + 1];
2168 
2169  a_dxyBiasResidualsMap[i][j] = AbsDoubleDiffBiasRes.make<TH1F>(
2170  Form("histo_dxy_eta_plot%i_phi_plot%i", i, j),
2171  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy} [#mum];tracks", etaF, etaL, phiF, phiL),
2173  -dzmax_eta,
2174  dzmax_eta);
2175 
2176  a_dzBiasResidualsMap[i][j] = AbsDoubleDiffBiasRes.make<TH1F>(
2177  Form("histo_dxy_eta_plot%i_phi_plot%i", i, j),
2178  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z} [#mum];tracks", etaF, etaL, phiF, phiL),
2180  -dzmax_eta,
2181  dzmax_eta);
2182 
2183  n_dxyBiasResidualsMap[i][j] = NormDoubleDiffBiasRes.make<TH1F>(
2184  Form("histo_norm_dxy_eta_plot%i_phi_plot%i", i, j),
2185  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy}/#sigma_{d_{xy}};tracks",
2186  etaF,
2187  etaL,
2188  phiF,
2189  phiL),
2191  -dzmax_eta / 100,
2192  dzmax_eta / 100);
2193 
2194  n_dzBiasResidualsMap[i][j] = NormDoubleDiffBiasRes.make<TH1F>(
2195  Form("histo_norm_dxy_eta_plot%i_phi_plot%i", i, j),
2196  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z}/#sigma_{d_{z}};tracks",
2197  etaF,
2198  etaL,
2199  phiF,
2200  phiL),
2202  -dzmax_eta / 100,
2203  dzmax_eta / 100);
2204  }
2205  }
2206 
2207  // declaration of the directories
2208 
2209  TFileDirectory MeanBiasTrendsDir = fs->mkdir("MeanBiasTrends");
2210  TFileDirectory WidthBiasTrendsDir = fs->mkdir("WidthBiasTrends");
2211  TFileDirectory MedianBiasTrendsDir = fs->mkdir("MedianBiasTrends");
2212  TFileDirectory MADBiasTrendsDir = fs->mkdir("MADBiasTrends");
2213 
2214  TFileDirectory Mean2DBiasMapsDir = fs->mkdir("MeanBiasMaps");
2215  TFileDirectory Width2DBiasMapsDir = fs->mkdir("WidthBiasMaps");
2216 
2217  // means and widths from the fit
2218 
2220  MeanBiasTrendsDir.make<TH1F>("means_dxy_phi",
2221  "#LT d_{xy} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy} #GT [#mum]",
2222  nBins_,
2223  lowedge,
2224  highedge);
2225 
2226  a_dxyPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>(
2227  "widths_dxy_phi",
2228  "#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{xy}} [#mum]",
2229  nBins_,
2230  lowedge,
2231  highedge);
2232 
2234  MeanBiasTrendsDir.make<TH1F>("means_dz_phi",
2235  "#LT d_{z} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z} #GT [#mum]",
2236  nBins_,
2237  lowedge,
2238  highedge);
2239 
2241  WidthBiasTrendsDir.make<TH1F>("widths_dz_phi",
2242  "#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{z}} [#mum]",
2243  nBins_,
2244  lowedge,
2245  highedge);
2246 
2247  a_dxyEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2248  "means_dxy_eta", "#LT d_{xy} #GT vs #eta sector;#eta (sector);#LT d_{xy} #GT [#mum]", nBins_, lowedge, highedge);
2249 
2251  WidthBiasTrendsDir.make<TH1F>("widths_dxy_eta",
2252  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{xy}} [#mum]",
2253  nBins_,
2254  lowedge,
2255  highedge);
2256 
2257  a_dzEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2258  "means_dz_eta", "#LT d_{z} #GT vs #eta sector;#eta (sector);#LT d_{z} #GT [#mum]", nBins_, lowedge, highedge);
2259 
2261  WidthBiasTrendsDir.make<TH1F>("widths_dz_eta",
2262  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{z}} [#mum]",
2263  nBins_,
2264  lowedge,
2265  highedge);
2266 
2267  n_dxyPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2268  "norm_means_dxy_phi",
2269  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy}/#sigma_{d_{xy}} #GT",
2270  nBins_,
2271  lowedge,
2272  highedge);
2273 
2274  n_dxyPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>(
2275  "norm_widths_dxy_phi",
2276  "width(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;#varphi (sector) [degrees]; width(d_{xy}/#sigma_{d_{xy}})",
2277  nBins_,
2278  lowedge,
2279  highedge);
2280 
2281  n_dzPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2282  "norm_means_dz_phi",
2283  "#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z}/#sigma_{d_{z}} #GT",
2284  nBins_,
2285  lowedge,
2286  highedge);
2287 
2288  n_dzPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>(
2289  "norm_widths_dz_phi",
2290  "width(d_{z}/#sigma_{d_{z}}) vs #phi sector;#varphi (sector) [degrees];width(d_{z}/#sigma_{d_{z}})",
2291  nBins_,
2292  lowedge,
2293  highedge);
2294 
2295  n_dxyEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2296  "norm_means_dxy_eta",
2297  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;#eta (sector);#LT d_{xy}/#sigma_{d_{z}} #GT",
2298  nBins_,
2299  lowedge,
2300  highedge);
2301 
2302  n_dxyEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>(
2303  "norm_widths_dxy_eta",
2304  "width(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;#eta (sector);width(d_{xy}/#sigma_{d_{z}})",
2305  nBins_,
2306  lowedge,
2307  highedge);
2308 
2309  n_dzEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F>(
2310  "norm_means_dz_eta",
2311  "#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;#eta (sector);#LT d_{z}/#sigma_{d_{z}} #GT",
2312  nBins_,
2313  lowedge,
2314  highedge);
2315 
2316  n_dzEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>(
2317  "norm_widths_dz_eta",
2318  "width(d_{z}/#sigma_{d_{z}}) vs #eta sector;#eta (sector);width(d_{z}/#sigma_{d_{z}})",
2319  nBins_,
2320  lowedge,
2321  highedge);
2322 
2323  // 2D maps
2324 
2325  a_dxyMeanBiasMap = Mean2DBiasMapsDir.make<TH2F>("means_dxy_map",
2326  "#LT d_{xy} #GT map;#eta (sector);#varphi (sector) [degrees]",
2327  nBins_,
2328  lowedge,
2329  highedge,
2330  nBins_,
2331  lowedge,
2332  highedge);
2333 
2334  a_dzMeanBiasMap = Mean2DBiasMapsDir.make<TH2F>("means_dz_map",
2335  "#LT d_{z} #GT map;#eta (sector);#varphi (sector) [degrees]",
2336  nBins_,
2337  lowedge,
2338  highedge,
2339  nBins_,
2340  lowedge,
2341  highedge);
2342 
2344  Mean2DBiasMapsDir.make<TH2F>("norm_means_dxy_map",
2345  "#LT d_{xy}/#sigma_{d_{xy}} #GT map;#eta (sector);#varphi (sector) [degrees]",
2346  nBins_,
2347  lowedge,
2348  highedge,
2349  nBins_,
2350  lowedge,
2351  highedge);
2352 
2353  n_dzMeanBiasMap =
2354  Mean2DBiasMapsDir.make<TH2F>("norm_means_dz_map",
2355  "#LT d_{z}/#sigma_{d_{z}} #GT map;#eta (sector);#varphi (sector) [degrees]",
2356  nBins_,
2357  lowedge,
2358  highedge,
2359  nBins_,
2360  lowedge,
2361  highedge);
2362 
2363  a_dxyWidthBiasMap = Width2DBiasMapsDir.make<TH2F>("widths_dxy_map",
2364  "#sigma_{d_{xy}} map;#eta (sector);#varphi (sector) [degrees]",
2365  nBins_,
2366  lowedge,
2367  highedge,
2368  nBins_,
2369  lowedge,
2370  highedge);
2371 
2372  a_dzWidthBiasMap = Width2DBiasMapsDir.make<TH2F>("widths_dz_map",
2373  "#sigma_{d_{z}} map;#eta (sector);#varphi (sector) [degrees]",
2374  nBins_,
2375  lowedge,
2376  highedge,
2377  nBins_,
2378  lowedge,
2379  highedge);
2380 
2382  Width2DBiasMapsDir.make<TH2F>("norm_widths_dxy_map",
2383  "width(d_{xy}/#sigma_{d_{xy}}) map;#eta (sector);#varphi (sector) [degrees]",
2384  nBins_,
2385  lowedge,
2386  highedge,
2387  nBins_,
2388  lowedge,
2389  highedge);
2390 
2392  Width2DBiasMapsDir.make<TH2F>("norm_widths_dz_map",
2393  "width(d_{z}/#sigma_{d_{z}}) map;#eta (sector);#varphi (sector) [degrees]",
2394  nBins_,
2395  lowedge,
2396  highedge,
2397  nBins_,
2398  lowedge,
2399  highedge);
2400 
2401  // medians and MADs
2402 
2403  a_dxyPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2404  "medians_dxy_phi",
2405  "Median of d_{xy} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}) [#mum]",
2406  nBins_,
2407  lowedge,
2408  highedge);
2409 
2410  a_dxyPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F>(
2411  "MADs_dxy_phi",
2412  "Median absolute deviation of d_{xy} vs #phi sector;#varphi (sector) [degrees];MAD(d_{xy}) [#mum]",
2413  nBins_,
2414  lowedge,
2415  highedge);
2416 
2417  a_dzPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2418  "medians_dz_phi",
2419  "Median of d_{z} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}) [#mum]",
2420  nBins_,
2421  lowedge,
2422  highedge);
2423 
2424  a_dzPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F>(
2425  "MADs_dz_phi",
2426  "Median absolute deviation of d_{z} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}) [#mum]",
2427  nBins_,
2428  lowedge,
2429  highedge);
2430 
2432  MedianBiasTrendsDir.make<TH1F>("medians_dxy_eta",
2433  "Median of d_{xy} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}) [#mum]",
2434  nBins_,
2435  lowedge,
2436  highedge);
2437 
2438  a_dxyEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F>(
2439  "MADs_dxy_eta",
2440  "Median absolute deviation of d_{xy} vs #eta sector;#eta (sector);MAD(d_{xy}) [#mum]",
2441  nBins_,
2442  lowedge,
2443  highedge);
2444 
2446  MedianBiasTrendsDir.make<TH1F>("medians_dz_eta",
2447  "Median of d_{z} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}) [#mum]",
2448  nBins_,
2449  lowedge,
2450  highedge);
2451 
2453  MADBiasTrendsDir.make<TH1F>("MADs_dz_eta",
2454  "Median absolute deviation of d_{z} vs #eta sector;#eta (sector);MAD(d_{z}) [#mum]",
2455  nBins_,
2456  lowedge,
2457  highedge);
2458 
2459  n_dxyPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2460  "norm_medians_dxy_phi",
2461  "Median of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}/#sigma_{d_{xy}})",
2462  nBins_,
2463  lowedge,
2464  highedge);
2465 
2466  n_dxyPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F>("norm_MADs_dxy_phi",
2467  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #phi "
2468  "sector;#varphi (sector) [degrees]; MAD(d_{xy}/#sigma_{d_{xy}})",
2469  nBins_,
2470  lowedge,
2471  highedge);
2472 
2473  n_dzPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2474  "norm_medians_dz_phi",
2475  "Median of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2476  nBins_,
2477  lowedge,
2478  highedge);
2479 
2480  n_dzPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F>("norm_MADs_dz_phi",
2481  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #phi "
2482  "sector;#varphi (sector) [degrees];MAD(d_{z}/#sigma_{d_{z}})",
2483  nBins_,
2484  lowedge,
2485  highedge);
2486 
2487  n_dxyEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2488  "norm_medians_dxy_eta",
2489  "Median of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}/#sigma_{d_{z}})",
2490  nBins_,
2491  lowedge,
2492  highedge);
2493 
2494  n_dxyEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F>(
2495  "norm_MADs_dxy_eta",
2496  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);MAD(d_{xy}/#sigma_{d_{z}})",
2497  nBins_,
2498  lowedge,
2499  highedge);
2500 
2501  n_dzEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>(
2502  "norm_medians_dz_eta",
2503  "Median of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2504  nBins_,
2505  lowedge,
2506  highedge);
2507 
2508  n_dzEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F>(
2509  "norm_MADs_dz_eta",
2510  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);MAD(d_{z}/#sigma_{d_{z}})",
2511  nBins_,
2512  lowedge,
2513  highedge);
2514  }
2515 }
2516 
2517 // ------------ method called once every run before doing the event loop ----------------
2519  //=======================================================
2520  // check on the b-field consistency
2521  //=======================================================
2522 
2523  if (!isBFieldConsistentWithMode(iSetup)) {
2524  edm::LogWarning("PrimaryVertexValidation")
2525  << "*********************************************************************************\n"
2526  << "* The configuration (ptOfProbe > " << ptOfProbe_
2527  << "GeV) is not correctly set for current value of magnetic field \n"
2528  << "* Switching it to 0. !!! \n"
2529  << "*********************************************************************************" << std::endl;
2530  ptOfProbe_ = 0.;
2531  }
2532 
2533  //=======================================================
2534  // Run numbers analysis
2535  //=======================================================
2536 
2537  const auto runNumber_ = iRun.run();
2538  h_runNumber->Fill(runNumber_);
2539 
2540  if (!runNumbersTimesLog_.count(runNumber_)) {
2541  auto times = getRunTime(iSetup);
2542 
2543  if (debug_) {
2544  const time_t start_time = times.first / 1000000;
2545  edm::LogInfo("PrimaryVertexValidation")
2546  << runNumber_ << " has start time: " << times.first << " - " << times.second << std::endl;
2547  edm::LogInfo("PrimaryVertexValidation")
2548  << "human readable time: " << std::asctime(std::gmtime(&start_time)) << std::endl;
2549  }
2550 
2552  }
2553 
2554  if (h_runFromEvent->GetEntries() == 0) {
2555  h_runFromEvent->SetBinContent(1, RunNumber_);
2556  }
2557 
2558  //=======================================================
2559  // Retrieve tracker topology from geometry
2560  //=======================================================
2561 
2562  const TrackerTopology* const tTopo = &iSetup.getData(topoTokenBR_);
2563 
2564  //=======================================================
2565  // Retrieve geometry information
2566  //=======================================================
2567 
2568  edm::LogInfo("read tracker geometry...");
2570  edm::LogInfo("tracker geometry read") << "There are: " << pDD->dets().size() << " detectors";
2571 
2572  PixelTopologyMap PTMap = PixelTopologyMap(pDD.product(), tTopo);
2573  nLadders_ = PTMap.getPXBLadders(1);
2574  nModZ_ = PTMap.getPXBModules(1);
2575 
2576  //=======================================================
2577  // shrink to fit
2578  //=======================================================
2579 
2580  if (h_dxy_ladderOverlap_.size() != nLadders_) {
2587 
2588  if (debug_) {
2589  edm::LogInfo("PrimaryVertexValidation") << "checking size:" << h_dxy_ladder_.size() << std::endl;
2590  }
2591  }
2592 
2593  if (h_dxy_modZ_.size() != nModZ_) {
2598 
2599  if (debug_) {
2600  edm::LogInfo("PrimaryVertexValidation") << "checking size:" << h_dxy_modZ_.size() << std::endl;
2601  }
2602  }
2603 
2605  // switch on the phase-2
2607  if (debug_) {
2608  edm::LogInfo("PrimaryVertexValidation")
2609  << " pixel phase2 setup, nLadders: " << nLadders_ << " nModules:" << nModZ_;
2610  }
2611 
2612  } else if ((pDD->isThere(GeomDetEnumerators::P1PXB)) || (pDD->isThere(GeomDetEnumerators::P1PXEC))) {
2613  // switch on the phase-1
2615  if (debug_) {
2616  edm::LogInfo("PrimaryVertexValidation")
2617  << " pixel phase1 setup, nLadders: " << nLadders_ << " nModules:" << nModZ_;
2618  }
2619  } else {
2620  // switch on the phase-0
2622  if (debug_) {
2623  edm::LogInfo("PrimaryVertexValidation")
2624  << " pixel phase0 setup, nLadders: " << nLadders_ << " nModules:" << nModZ_;
2625  }
2626  }
2627 
2628  switch (phase_) {
2629  case PVValHelper::phase0:
2631  break;
2632  case PVValHelper::phase1:
2634  break;
2635  case PVValHelper::phase2:
2637  break;
2638  default:
2639  throw cms::Exception("LogicError") << "Unknown detector phase: " << phase_;
2640  }
2641 
2642  if (h_etaMax->GetEntries() == 0.) {
2643  h_etaMax->SetBinContent(1., etaOfProbe_);
2644  h_nbins->SetBinContent(1., nBins_);
2645  h_nLadders->SetBinContent(1., nLadders_);
2646  h_nModZ->SetBinContent(1., nModZ_);
2647  h_pTinfo->SetBinContent(1., mypT_bins_.size());
2648  h_pTinfo->SetBinContent(2., minPt_);
2649  h_pTinfo->SetBinContent(3., maxPt_);
2650  }
2651 }
2652 
2653 // ------------ method called once each job just after ending the event loop ------------
2655  // shring the histograms to fit
2656  h_probeL1Ladder_->GetXaxis()->SetRangeUser(-1.5, nLadders_ + 0.5);
2657  h_probeL1Module_->GetXaxis()->SetRangeUser(-1.5, nModZ_ + 0.5);
2658  h2_probeLayer1Map_->GetXaxis()->SetRangeUser(0.5, nModZ_ + 0.5);
2659  h2_probeLayer1Map_->GetYaxis()->SetRangeUser(0.5, nLadders_ + 0.5);
2660  h2_probePassingLayer1Map_->GetXaxis()->SetRangeUser(0.5, nModZ_ + 0.5);
2661  h2_probePassingLayer1Map_->GetYaxis()->SetRangeUser(0.5, nLadders_ + 0.5);
2662 
2663  TFileDirectory RunFeatures = fs->mkdir("RunFeatures");
2664  h_runStartTimes = RunFeatures.make<TH1I>(
2665  "runStartTimes", "run start times", runNumbersTimesLog_.size(), 0, runNumbersTimesLog_.size());
2666  h_runEndTimes =
2667  RunFeatures.make<TH1I>("runEndTimes", "run end times", runNumbersTimesLog_.size(), 0, runNumbersTimesLog_.size());
2668 
2669  unsigned int count = 1;
2670  for (const auto& run : runNumbersTimesLog_) {
2671  // strip down the microseconds
2672  h_runStartTimes->SetBinContent(count, run.second.first / 10e6);
2673  h_runStartTimes->GetXaxis()->SetBinLabel(count, (std::to_string(run.first)).c_str());
2674 
2675  h_runEndTimes->SetBinContent(count, run.second.second / 10e6);
2676  h_runEndTimes->GetXaxis()->SetBinLabel(count, (std::to_string(run.first)).c_str());
2677 
2678  count++;
2679  }
2680 
2681  edm::LogInfo("PrimaryVertexValidation") << "######################################\n"
2682  << "# PrimaryVertexValidation::endJob()\n"
2683  << "# Number of analyzed events: " << Nevt_ << "\n"
2684  << "######################################";
2685 
2686  // means and widhts vs ladder and module number
2687 
2689  "means_dxy_modZ", "#LT d_{xy} #GT vs modZ;module number (Z);#LT d_{xy} #GT [#mum]", nModZ_, 0., nModZ_);
2690 
2692  "widths_dxy_modZ", "#sigma_{d_{xy}} vs modZ;module number (Z);#sigma_{d_{xy}} [#mum]", nModZ_, 0., nModZ_);
2693 
2695  "means_dz_modZ", "#LT d_{z} #GT vs modZ;module number (Z);#LT d_{z} #GT [#mum]", nModZ_, 0., nModZ_);
2696 
2698  "widths_dz_modZ", "#sigma_{d_{z}} vs modZ;module number (Z);#sigma_{d_{z}} [#mum]", nModZ_, 0., nModZ_);
2699 
2700  a_dxyladderMeanTrend = MeanTrendsDir.make<TH1F>("means_dxy_ladder",
2701  "#LT d_{xy} #GT vs ladder;ladder number (#phi);#LT d_{xy} #GT [#mum]",
2702  nLadders_,
2703  0.,
2704  nLadders_);
2705 
2707  WidthTrendsDir.make<TH1F>("widths_dxy_ladder",
2708  "#sigma_{d_{xy}} vs ladder;ladder number (#phi);#sigma_{d_{xy}} [#mum]",
2709  nLadders_,
2710  0.,
2711  nLadders_);
2712 
2714  "means_dz_ladder", "#LT d_{z} #GT vs ladder;ladder number (#phi);#LT d_{z} #GT [#mum]", nLadders_, 0., nLadders_);
2715 
2717  WidthTrendsDir.make<TH1F>("widths_dz_ladder",
2718  "#sigma_{d_{z}} vs ladder;ladder number (#phi);#sigma_{d_{z}} [#mum]",
2719  nLadders_,
2720  0.,
2721  nLadders_);
2722 
2724  "norm_means_dxy_modZ",
2725  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs modZ;module number (Z);#LT d_{xy}/#sigma_{d_{xy}} #GT",
2726  nModZ_,
2727  0.,
2728  nModZ_);
2729 
2731  "norm_widths_dxy_modZ",
2732  "width(d_{xy}/#sigma_{d_{xy}}) vs modZ;module number (Z); width(d_{xy}/#sigma_{d_{xy}})",
2733  nModZ_,
2734  0.,
2735  nModZ_);
2736 
2738  MeanTrendsDir.make<TH1F>("norm_means_dz_modZ",
2739  "#LT d_{z}/#sigma_{d_{z}} #GT vs modZ;module number (Z);#LT d_{z}/#sigma_{d_{z}} #GT",
2740  nModZ_,
2741  0.,
2742  nModZ_);
2743 
2745  WidthTrendsDir.make<TH1F>("norm_widths_dz_modZ",
2746  "width(d_{z}/#sigma_{d_{z}}) vs pT;module number (Z);width(d_{z}/#sigma_{d_{z}})",
2747  nModZ_,
2748  0.,
2749  nModZ_);
2750 
2752  "norm_means_dxy_ladder",
2753  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs ladder;ladder number (#phi);#LT d_{xy}/#sigma_{d_{z}} #GT",
2754  nLadders_,
2755  0.,
2756  nLadders_);
2757 
2759  "norm_widths_dxy_ladder",
2760  "width(d_{xy}/#sigma_{d_{xy}}) vs ladder;ladder number (#phi);width(d_{xy}/#sigma_{d_{z}})",
2761  nLadders_,
2762  0.,
2763  nLadders_);
2764 
2766  "norm_means_dz_ladder",
2767  "#LT d_{z}/#sigma_{d_{z}} #GT vs ladder;ladder number (#phi);#LT d_{z}/#sigma_{d_{z}} #GT",
2768  nLadders_,
2769  0.,
2770  nLadders_);
2771 
2773  "norm_widths_dz_ladder",
2774  "width(d_{z}/#sigma_{d_{z}}) vs ladder;ladder number (#phi);width(d_{z}/#sigma_{d_{z}})",
2775  nLadders_,
2776  0.,
2777  nLadders_);
2778 
2779  // 2D maps of residuals in bins of L1 modules
2780 
2781  a_dxyL1MeanMap = Mean2DMapsDir.make<TH2F>("means_dxy_l1map",
2782  "#LT d_{xy} #GT map;module number [z];ladder number [#varphi]",
2783  nModZ_,
2784  0.,
2785  nModZ_,
2786  nLadders_,
2787  0.,
2788  nLadders_);
2789 
2790  a_dzL1MeanMap = Mean2DMapsDir.make<TH2F>("means_dz_l1map",
2791  "#LT d_{z} #GT map;module number [z];ladder number [#varphi]",
2792  nModZ_,
2793  0.,
2794  nModZ_,
2795  nLadders_,
2796  0.,
2797  nLadders_);
2798 
2799  n_dxyL1MeanMap =
2800  Mean2DMapsDir.make<TH2F>("norm_means_dxy_l1map",
2801  "#LT d_{xy}/#sigma_{d_{xy}} #GT map;module number [z];ladder number [#varphi]",
2802  nModZ_,
2803  0.,
2804  nModZ_,
2805  nLadders_,
2806  0.,
2807  nLadders_);
2808 
2809  n_dzL1MeanMap = Mean2DMapsDir.make<TH2F>("norm_means_dz_l1map",
2810  "#LT d_{z}/#sigma_{d_{z}} #GT map;module number [z];ladder number [#varphi]",
2811  nModZ_,
2812  0.,
2813  nModZ_,
2814  nLadders_,
2815  0.,
2816  nLadders_);
2817 
2818  a_dxyL1WidthMap = Width2DMapsDir.make<TH2F>("widths_dxy_l1map",
2819  "#sigma_{d_{xy}} map;module number [z];ladder number [#varphi]",
2820  nModZ_,
2821  0.,
2822  nModZ_,
2823  nLadders_,
2824  0.,
2825  nLadders_);
2826 
2827  a_dzL1WidthMap = Width2DMapsDir.make<TH2F>("widths_dz_l1map",
2828  "#sigma_{d_{z}} map;module number [z];ladder number [#varphi]",
2829  nModZ_,
2830  0.,
2831  nModZ_,
2832  nLadders_,
2833  0.,
2834  nLadders_);
2835 
2836  n_dxyL1WidthMap =
2837  Width2DMapsDir.make<TH2F>("norm_widths_dxy_l1map",
2838  "width(d_{xy}/#sigma_{d_{xy}}) map;module number [z];ladder number [#varphi]",
2839  nModZ_,
2840  0.,
2841  nModZ_,
2842  nLadders_,
2843  0.,
2844  nLadders_);
2845 
2846  n_dzL1WidthMap =
2847  Width2DMapsDir.make<TH2F>("norm_widths_dz_l1map",
2848  "width(d_{z}/#sigma_{d_{z}}) map;module number [z];ladder number [#varphi]",
2849  nModZ_,
2850  0.,
2851  nModZ_,
2852  nLadders_,
2853  0.,
2854  nLadders_);
2855 
2856  if (useTracksFromRecoVtx_) {
2861 
2866 
2871 
2876 
2877  // medians and MADs
2878 
2883 
2888 
2893 
2898 
2899  // 2d Maps
2900 
2905 
2910  }
2911 
2912  // do profiles
2913 
2918 
2923 
2928 
2933 
2934  // vs transverse momentum
2935 
2940 
2945 
2950 
2955 
2956  // vs ladder and module number
2957 
2962 
2967 
2972 
2977 
2978  // medians and MADs
2979 
2982 
2985 
2990 
2995 
3000 
3001  // 2D Maps
3002 
3007 
3012 
3013  // 2D Maps of residuals in bins of L1 modules
3014 
3019 
3024 }
3025 
3026 //*************************************************************
3027 std::pair<long long, long long> PrimaryVertexValidation::getRunTime(const edm::EventSetup& iSetup) const
3028 //*************************************************************
3029 {
3030  edm::ESHandle<RunInfo> runInfo = iSetup.getHandle(runInfoTokenBR_);
3031  if (debug_) {
3032  edm::LogInfo("PrimaryVertexValidation")
3033  << runInfo.product()->m_start_time_str << " " << runInfo.product()->m_stop_time_str << std::endl;
3034  }
3035  return std::make_pair(runInfo.product()->m_start_time_ll, runInfo.product()->m_stop_time_ll);
3036 }
3037 
3038 //*************************************************************
3040 //*************************************************************
3041 {
3042  edm::ESHandle<RunInfo> runInfo = iSetup.getHandle(runInfoTokenBR_);
3043  double average_current = runInfo.product()->m_avg_current;
3044  bool isOn = (average_current > 2000.);
3045  bool is0T = (ptOfProbe_ == 0.);
3046 
3047  return ((isOn && !is0T) || (!isOn && is0T));
3048 }
3049 
3050 //*************************************************************
3052 //*************************************************************
3053 {
3054  nTracks_ = 0;
3055  nClus_ = 0;
3056  nOfflineVertices_ = 0;
3057  RunNumber_ = 0;
3059  xOfflineVertex_ = -999.;
3060  yOfflineVertex_ = -999.;
3061  zOfflineVertex_ = -999.;
3062  xErrOfflineVertex_ = 0.;
3063  yErrOfflineVertex_ = 0.;
3064  zErrOfflineVertex_ = 0.;
3065  BSx0_ = -999.;
3066  BSy0_ = -999.;
3067  BSz0_ = -999.;
3068  Beamsigmaz_ = -999.;
3069  Beamdxdz_ = -999.;
3070  BeamWidthX_ = -999.;
3071  BeamWidthY_ = -999.;
3072  wxy2_ = -999.;
3073 
3074  for (int i = 0; i < nMaxtracks_; ++i) {
3075  pt_[i] = 0;
3076  p_[i] = 0;
3077  nhits_[i] = 0;
3078  nhits1D_[i] = 0;
3079  nhits2D_[i] = 0;
3080  nhitsBPIX_[i] = 0;
3081  nhitsFPIX_[i] = 0;
3082  nhitsTIB_[i] = 0;
3083  nhitsTID_[i] = 0;
3084  nhitsTOB_[i] = 0;
3085  nhitsTEC_[i] = 0;
3086  isHighPurity_[i] = 0;
3087  eta_[i] = 0;
3088  theta_[i] = 0;
3089  phi_[i] = 0;
3090  chi2_[i] = 0;
3091  chi2ndof_[i] = 0;
3092  charge_[i] = 0;
3093  qoverp_[i] = 0;
3094  dz_[i] = 0;
3095  dxy_[i] = 0;
3096  dzBs_[i] = 0;
3097  dxyBs_[i] = 0;
3098  xPCA_[i] = 0;
3099  yPCA_[i] = 0;
3100  zPCA_[i] = 0;
3101  xUnbiasedVertex_[i] = 0;
3102  yUnbiasedVertex_[i] = 0;
3103  zUnbiasedVertex_[i] = 0;
3105  chi2UnbiasedVertex_[i] = 0;
3107  DOFUnbiasedVertex_[i] = 0;
3110  dxyFromMyVertex_[i] = 0;
3111  dzFromMyVertex_[i] = 0;
3112  d3DFromMyVertex_[i] = 0;
3113  dxyErrorFromMyVertex_[i] = 0;
3114  dzErrorFromMyVertex_[i] = 0;
3115  d3DErrorFromMyVertex_[i] = 0;
3116  IPTsigFromMyVertex_[i] = 0;
3117  IPLsigFromMyVertex_[i] = 0;
3118  IP3DsigFromMyVertex_[i] = 0;
3119  hasRecVertex_[i] = 0;
3120  isGoodTrack_[i] = 0;
3121  }
3122 }
3123 
3124 //*************************************************************
3126  TH1F* residualsPlot[100],
3127  PVValHelper::estimator fitPar_,
3128  const std::string& var_)
3129 //*************************************************************
3130 {
3131  for (int i = 0; i < nBins_; ++i) {
3132  char phibincenter[129];
3134  sprintf(phibincenter, "%.f", (phiBins[i] + phiBins[i + 1]) / 2.);
3135 
3136  char etabincenter[129];
3138  sprintf(etabincenter, "%.1f", (etaBins[i] + etaBins[i + 1]) / 2.);
3139 
3140  switch (fitPar_) {
3141  case PVValHelper::MEAN: {
3142  float mean_ = PVValHelper::fitResiduals(residualsPlot[i]).first.value();
3143  float meanErr_ = PVValHelper::fitResiduals(residualsPlot[i]).first.error();
3144  trendPlot->SetBinContent(i + 1, mean_);
3145  trendPlot->SetBinError(i + 1, meanErr_);
3146  break;
3147  }
3148  case PVValHelper::WIDTH: {
3149  float width_ = PVValHelper::fitResiduals(residualsPlot[i]).second.value();
3150  float widthErr_ = PVValHelper::fitResiduals(residualsPlot[i]).second.error();
3151  trendPlot->SetBinContent(i + 1, width_);
3152  trendPlot->SetBinError(i + 1, widthErr_);
3153  break;
3154  }
3155  case PVValHelper::MEDIAN: {
3156  float median_ = PVValHelper::getMedian(residualsPlot[i]).value();
3157  float medianErr_ = PVValHelper::getMedian(residualsPlot[i]).error();
3158  trendPlot->SetBinContent(i + 1, median_);
3159  trendPlot->SetBinError(i + 1, medianErr_);
3160  break;
3161  }
3162  case PVValHelper::MAD: {
3163  float mad_ = PVValHelper::getMAD(residualsPlot[i]).value();
3164  float madErr_ = PVValHelper::getMAD(residualsPlot[i]).error();
3165  trendPlot->SetBinContent(i + 1, mad_);
3166  trendPlot->SetBinError(i + 1, madErr_);
3167  break;
3168  }
3169  default:
3170  edm::LogWarning("PrimaryVertexValidation")
3171  << "fillTrendPlot() " << fitPar_ << " unknown estimator!" << std::endl;
3172  break;
3173  }
3174 
3175  if (var_.find("eta") != std::string::npos) {
3176  trendPlot->GetXaxis()->SetBinLabel(i + 1, etabincenter);
3177  } else if (var_.find("phi") != std::string::npos) {
3178  trendPlot->GetXaxis()->SetBinLabel(i + 1, phibincenter);
3179  } else {
3180  edm::LogWarning("PrimaryVertexValidation")
3181  << "fillTrendPlot() " << var_ << " unknown track parameter!" << std::endl;
3182  }
3183  }
3184 }
3185 
3186 //*************************************************************
3188  std::vector<TH1F*>& h,
3189  PVValHelper::estimator fitPar_,
3190  PVValHelper::plotVariable plotVar)
3191 //*************************************************************
3192 {
3193  for (auto iterator = h.begin(); iterator != h.end(); iterator++) {
3194  unsigned int bin = std::distance(h.begin(), iterator) + 1;
3195  std::pair<Measurement1D, Measurement1D> myFit = PVValHelper::fitResiduals((*iterator));
3196 
3197  switch (fitPar_) {
3198  case PVValHelper::MEAN: {
3199  float mean_ = myFit.first.value();
3200  float meanErr_ = myFit.first.error();
3201  trendPlot->SetBinContent(bin, mean_);
3202  trendPlot->SetBinError(bin, meanErr_);
3203  break;
3204  }
3205  case PVValHelper::WIDTH: {
3206  float width_ = myFit.second.value();
3207  float widthErr_ = myFit.second.error();
3208  trendPlot->SetBinContent(bin, width_);
3209  trendPlot->SetBinError(bin, widthErr_);
3210  break;
3211  }
3212  case PVValHelper::MEDIAN: {
3213  float median_ = PVValHelper::getMedian(*iterator).value();
3214  float medianErr_ = PVValHelper::getMedian(*iterator).error();
3215  trendPlot->SetBinContent(bin, median_);
3216  trendPlot->SetBinError(bin, medianErr_);
3217  break;
3218  }
3219  case PVValHelper::MAD: {
3220  float mad_ = PVValHelper::getMAD(*iterator).value();
3221  float madErr_ = PVValHelper::getMAD(*iterator).error();
3222  trendPlot->SetBinContent(bin, mad_);
3223  trendPlot->SetBinError(bin, madErr_);
3224  break;
3225  }
3226  default:
3227  edm::LogWarning("PrimaryVertexValidation")
3228  << "fillTrendPlotByIndex() " << fitPar_ << " unknown estimator!" << std::endl;
3229  break;
3230  }
3231 
3232  char bincenter[129];
3233  if (plotVar == PVValHelper::eta) {
3235  sprintf(bincenter, "%.1f", (etaBins[bin - 1] + etaBins[bin]) / 2.);
3236  trendPlot->GetXaxis()->SetBinLabel(bin, bincenter);
3237  } else if (plotVar == PVValHelper::phi) {
3239  sprintf(bincenter, "%.f", (phiBins[bin - 1] + phiBins[bin]) / 2.);
3240  trendPlot->GetXaxis()->SetBinLabel(bin, bincenter);
3241  } else {
3243  //edm::LogWarning("PrimaryVertexValidation")<<"fillTrendPlotByIndex() "<< plotVar <<" unknown track parameter!"<<std::endl;
3244  }
3245  }
3246 }
3247 
3248 //*************************************************************
3250  TH1F* residualsMapPlot[100][100],
3251  PVValHelper::estimator fitPar_,
3252  const int nXBins_,
3253  const int nYBins_)
3254 //*************************************************************
3255 {
3256  for (int i = 0; i < nYBins_; ++i) {
3257  char phibincenter[129];
3259  sprintf(phibincenter, "%.f", (phiBins[i] + phiBins[i + 1]) / 2.);
3260 
3261  if (nXBins_ == nYBins_) {
3262  trendMap->GetYaxis()->SetBinLabel(i + 1, phibincenter);
3263  }
3264 
3265  for (int j = 0; j < nXBins_; ++j) {
3266  char etabincenter[129];
3268  sprintf(etabincenter, "%.1f", (etaBins[j] + etaBins[j + 1]) / 2.);
3269 
3270  if (i == 0) {
3271  if (nXBins_ == nYBins_) {
3272  trendMap->GetXaxis()->SetBinLabel(j + 1, etabincenter);
3273  }
3274  }
3275 
3276  switch (fitPar_) {
3277  case PVValHelper::MEAN: {
3278  float mean_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).first.value();
3279  float meanErr_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).first.error();
3280  trendMap->SetBinContent(j + 1, i + 1, mean_);
3281  trendMap->SetBinError(j + 1, i + 1, meanErr_);
3282  break;
3283  }
3284  case PVValHelper::WIDTH: {
3285  float width_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).second.value();
3286  float widthErr_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).second.error();
3287  trendMap->SetBinContent(j + 1, i + 1, width_);
3288  trendMap->SetBinError(j + 1, i + 1, widthErr_);
3289  break;
3290  }
3291  case PVValHelper::MEDIAN: {
3292  float median_ = PVValHelper::getMedian(residualsMapPlot[i][j]).value();
3293  float medianErr_ = PVValHelper::getMedian(residualsMapPlot[i][j]).error();
3294  trendMap->SetBinContent(j + 1, i + 1, median_);
3295  trendMap->SetBinError(j + 1, i + 1, medianErr_);
3296  break;
3297  }
3298  case PVValHelper::MAD: {
3299  float mad_ = PVValHelper::getMAD(residualsMapPlot[i][j]).value();
3300  float madErr_ = PVValHelper::getMAD(residualsMapPlot[i][j]).error();
3301  trendMap->SetBinContent(j + 1, i + 1, mad_);
3302  trendMap->SetBinError(j + 1, i + 1, madErr_);
3303  break;
3304  }
3305  default:
3306  edm::LogWarning("PrimaryVertexValidation:") << " fillMap() " << fitPar_ << " unknown estimator!" << std::endl;
3307  }
3308  } // closes loop on eta bins
3309  } // cloeses loop on phi bins
3310 }
3311 
3312 //*************************************************************
3314 //*************************************************************
3315 {
3316  if (a.tracksSize() != b.tracksSize())
3317  return a.tracksSize() > b.tracksSize() ? true : false;
3318  else
3319  return a.chi2() < b.chi2() ? true : false;
3320 }
3321 
3322 //*************************************************************
3324  const reco::Vertex& vertex,
3325  const std::string& qualityString_,
3326  double dxyErrMax_,
3327  double dzErrMax_,
3328  double ptErrMax_)
3329 //*************************************************************
3330 {
3331  math::XYZPoint vtxPoint(0.0, 0.0, 0.0);
3332  double vzErr = 0.0, vxErr = 0.0, vyErr = 0.0;
3333  vtxPoint = vertex.position();
3334  vzErr = vertex.zError();
3335  vxErr = vertex.xError();
3336  vyErr = vertex.yError();
3337 
3338  double dxy = 0.0, dz = 0.0, dxysigma = 0.0, dzsigma = 0.0;
3339  dxy = track.dxy(vtxPoint);
3340  dz = track.dz(vtxPoint);
3341  dxysigma = sqrt(track.d0Error() * track.d0Error() + vxErr * vyErr);
3342  dzsigma = sqrt(track.dzError() * track.dzError() + vzErr * vzErr);
3343 
3344  if (track.quality(reco::TrackBase::qualityByName(qualityString_)) != 1)
3345  return false;
3346  if (std::abs(dxy / dxysigma) > dxyErrMax_)
3347  return false;
3348  if (std::abs(dz / dzsigma) > dzErrMax_)
3349  return false;
3350  if (track.ptError() / track.pt() > ptErrMax_)
3351  return false;
3352 
3353  return true;
3354 }
3355 
3356 //*************************************************************
3358 //*************************************************************
3359 {
3360  TH1F::SetDefaultSumw2(kTRUE);
3361 
3362  std::map<std::string, TH1*> h;
3363 
3364  // histograms of track quality (Data and MC)
3365  std::string types[] = {"all", "sel"};
3366  for (const auto& type : types) {
3367  h["pseudorapidity_" + type] =
3368  dir.make<TH1F>(("rapidity_" + type).c_str(), "track pseudorapidity; track #eta; tracks", 100, -3., 3.);
3369  h["z0_" + type] = dir.make<TH1F>(("z0_" + type).c_str(), "track z_{0};track z_{0} (cm);tracks", 80, -40., 40.);
3370  h["phi_" + type] = dir.make<TH1F>(("phi_" + type).c_str(), "track #phi; track #phi;tracks", 80, -M_PI, M_PI);
3371  h["eta_" + type] = dir.make<TH1F>(("eta_" + type).c_str(), "track #eta; track #eta;tracks", 80, -4., 4.);
3372  h["pt_" + type] = dir.make<TH1F>(("pt_" + type).c_str(), "track p_{T}; track p_{T} [GeV];tracks", 100, 0., 20.);
3373  h["p_" + type] = dir.make<TH1F>(("p_" + type).c_str(), "track p; track p [GeV];tracks", 100, 0., 20.);
3374  h["found_" + type] =
3375  dir.make<TH1F>(("found_" + type).c_str(), "n. found hits;n^{found}_{hits};tracks", 30, 0., 30.);
3376  h["lost_" + type] = dir.make<TH1F>(("lost_" + type).c_str(), "n. lost hits;n^{lost}_{hits};tracks", 20, 0., 20.);
3377  h["nchi2_" + type] =
3378  dir.make<TH1F>(("nchi2_" + type).c_str(), "normalized track #chi^{2};track #chi^{2}/ndf;tracks", 100, 0., 20.);
3379  h["rstart_" + type] = dir.make<TH1F>(
3380  ("rstart_" + type).c_str(), "track start radius; track innermost radius r (cm);tracks", 100, 0., 20.);
3381  h["expectedInner_" + type] = dir.make<TH1F>(
3382  ("expectedInner_" + type).c_str(), "n. expected inner hits;n^{expected}_{inner};tracks", 10, 0., 10.);
3383  h["expectedOuter_" + type] = dir.make<TH1F>(
3384  ("expectedOuter_" + type).c_str(), "n. expected outer hits;n^{expected}_{outer};tracks ", 10, 0., 10.);
3385  h["logtresxy_" + type] =
3386  dir.make<TH1F>(("logtresxy_" + type).c_str(),
3387  "log10(track r-#phi resolution/#mum);log10(track r-#phi resolution/#mum);tracks",
3388  100,
3389  0.,
3390  5.);
3391  h["logtresz_" + type] = dir.make<TH1F>(("logtresz_" + type).c_str(),
3392  "log10(track z resolution/#mum);log10(track z resolution/#mum);tracks",
3393  100,
3394  0.,
3395  5.);
3396  h["tpullxy_" + type] =
3397  dir.make<TH1F>(("tpullxy_" + type).c_str(), "track r-#phi pull;pull_{r-#phi};tracks", 100, -10., 10.);
3398  h["tpullz_" + type] =
3399  dir.make<TH1F>(("tpullz_" + type).c_str(), "track r-z pull;pull_{r-z};tracks", 100, -50., 50.);
3400  h["tlogDCAxy_" + type] = dir.make<TH1F>(
3401  ("tlogDCAxy_" + type).c_str(), "track log_{10}(DCA_{r-#phi});track log_{10}(DCA_{r-#phi});tracks", 200, -5., 3.);
3402  h["tlogDCAz_" + type] = dir.make<TH1F>(
3403  ("tlogDCAz_" + type).c_str(), "track log_{10}(DCA_{r-z});track log_{10}(DCA_{r-z});tracks", 200, -5., 5.);
3404  h["lvseta_" + type] = dir.make<TH2F>(
3405  ("lvseta_" + type).c_str(), "cluster length vs #eta;track #eta;cluster length", 60, -3., 3., 20, 0., 20);
3406  h["lvstanlambda_" + type] = dir.make<TH2F>(("lvstanlambda_" + type).c_str(),
3407  "cluster length vs tan #lambda; tan#lambda;cluster length",
3408  60,
3409  -6.,
3410  6.,
3411  20,
3412  0.,
3413  20);
3414  h["restrkz_" + type] =
3415  dir.make<TH1F>(("restrkz_" + type).c_str(), "z-residuals (track vs vertex);res_{z} (cm);tracks", 200, -5., 5.);
3416  h["restrkzvsphi_" + type] = dir.make<TH2F>(("restrkzvsphi_" + type).c_str(),
3417  "z-residuals (track - vertex) vs track #phi;track #phi;res_{z} (cm)",
3418  12,
3419  -M_PI,
3420  M_PI,
3421  100,
3422  -0.5,
3423  0.5);
3424  h["restrkzvseta_" + type] = dir.make<TH2F>(("restrkzvseta_" + type).c_str(),
3425  "z-residuals (track - vertex) vs track #eta;track #eta;res_{z} (cm)",
3426  12,
3427  -3.,
3428  3.,
3429  200,
3430  -0.5,
3431  0.5);
3432  h["pulltrkzvsphi_" + type] =
3433  dir.make<TH2F>(("pulltrkzvsphi_" + type).c_str(),
3434  "normalized z-residuals (track - vertex) vs track #phi;track #phi;res_{z}/#sigma_{res_{z}}",
3435  12,
3436  -M_PI,
3437  M_PI,
3438  100,
3439  -5.,
3440  5.);
3441  h["pulltrkzvseta_" + type] =
3442  dir.make<TH2F>(("pulltrkzvseta_" + type).c_str(),
3443  "normalized z-residuals (track - vertex) vs track #eta;track #eta;res_{z}/#sigma_{res_{z}}",
3444  12,
3445  -3.,
3446  3.,
3447  100,
3448  -5.,
3449  5.);
3450  h["pulltrkz_" + type] = dir.make<TH1F>(("pulltrkz_" + type).c_str(),
3451  "normalized z-residuals (track vs vertex);res_{z}/#sigma_{res_{z}};tracks",
3452  100,
3453  -5.,
3454  5.);
3455  h["sigmatrkz0_" + type] = dir.make<TH1F>(
3456  ("sigmatrkz0_" + type).c_str(), "z-resolution (excluding beam);#sigma^{trk}_{z_{0}} (cm);tracks", 100, 0., 5.);
3457  h["sigmatrkz_" + type] = dir.make<TH1F>(
3458  ("sigmatrkz_" + type).c_str(), "z-resolution (including beam);#sigma^{trk}_{z} (cm);tracks", 100, 0., 5.);
3459  h["nbarrelhits_" + type] = dir.make<TH1F>(
3460  ("nbarrelhits_" + type).c_str(), "number of pixel barrel hits;n. hits Barrel Pixel;tracks", 10, 0., 10.);
3461  h["nbarrelLayers_" + type] = dir.make<TH1F>(
3462  ("nbarrelLayers_" + type).c_str(), "number of pixel barrel layers;n. layers Barrel Pixel;tracks", 10, 0., 10.);
3463  h["nPxLayers_" + type] = dir.make<TH1F>(
3464  ("nPxLayers_" + type).c_str(), "number of pixel layers (barrel+endcap);n. Pixel layers;tracks", 10, 0., 10.);
3465  h["nSiLayers_" + type] =
3466  dir.make<TH1F>(("nSiLayers_" + type).c_str(), "number of Tracker layers;n. Tracker layers;tracks", 20, 0., 20.);
3467  h["trackAlgo_" + type] =
3468  dir.make<TH1F>(("trackAlgo_" + type).c_str(), "track algorithm;track algo;tracks", 30, 0., 30.);
3469  h["trackQuality_" + type] =
3470  dir.make<TH1F>(("trackQuality_" + type).c_str(), "track quality;track quality;tracks", 7, -1., 6.);
3471  }
3472 
3473  return h;
3474 }
3475 
3476 //*************************************************************
3477 // Generic booker function
3478 //*************************************************************
3480  unsigned int theNOfBins,
3481  PVValHelper::residualType resType,
3483  bool isNormalized) {
3484  TH1F::SetDefaultSumw2(kTRUE);
3485 
3486  auto hash = std::make_pair(resType, varType);
3487 
3488  double down = theDetails_.range[hash].first;
3489  double up = theDetails_.range[hash].second;
3490 
3491  if (isNormalized) {
3492  up = up / 100.;
3493  down = down / 100.;
3494  }
3495 
3496  std::vector<TH1F*> h;
3497  h.reserve(theNOfBins);
3498 
3499  if (theNOfBins == 0) {
3500  edm::LogError("PrimaryVertexValidation")
3501  << "bookResidualsHistogram() The number of bins cannot be identically 0" << std::endl;
3502  assert(false);
3503  }
3504 
3505  std::string s_resType = std::get<0>(PVValHelper::getTypeString(resType));
3506  std::string s_varType = std::get<0>(PVValHelper::getVarString(varType));
3507 
3508  std::string t_resType = std::get<1>(PVValHelper::getTypeString(resType));
3509  std::string t_varType = std::get<1>(PVValHelper::getVarString(varType));
3510  std::string units = std::get<2>(PVValHelper::getTypeString(resType));
3511 
3512  for (unsigned int i = 0; i < theNOfBins; i++) {
3514  ? Form("%s vs %s - bin %i (%f < %s < %f);%s %s;tracks",
3515  t_resType.c_str(),
3516  t_varType.c_str(),
3517  i,
3519  t_varType.c_str(),
3521  t_resType.c_str(),
3522  units.c_str())
3523  : Form("%s vs %s - bin %i;%s %s;tracks",
3524  t_resType.c_str(),
3525  t_varType.c_str(),
3526  i,
3527  t_resType.c_str(),
3528  units.c_str());
3529 
3530  TH1F* htemp = dir.make<TH1F>(
3531  Form("histo_%s_%s_plot%i", s_resType.c_str(), s_varType.c_str(), i),
3532  //Form("%s vs %s - bin %i;%s %s;tracks",t_resType.c_str(),t_varType.c_str(),i,t_resType.c_str(),units.c_str()),
3533  title.Data(),
3535  down,
3536  up);
3537  h.push_back(htemp);
3538  }
3539 
3540  return h;
3541 }
3542 
3543 //*************************************************************
3544 void PrimaryVertexValidation::fillTrackHistos(std::map<std::string, TH1*>& h,
3545  const std::string& ttype,
3546  const reco::TransientTrack* tt,
3547  const reco::Vertex& v,
3548  const reco::BeamSpot& beamSpot,
3549  double fBfield_)
3550 //*************************************************************
3551 {
3552  using namespace reco;
3553 
3554  PVValHelper::fill(h, "pseudorapidity_" + ttype, tt->track().eta());
3555  PVValHelper::fill(h, "z0_" + ttype, tt->track().vz());
3556  PVValHelper::fill(h, "phi_" + ttype, tt->track().phi());
3557  PVValHelper::fill(h, "eta_" + ttype, tt->track().eta());
3558  PVValHelper::fill(h, "pt_" + ttype, tt->track().pt());
3559  PVValHelper::fill(h, "p_" + ttype, tt->track().p());
3560  PVValHelper::fill(h, "found_" + ttype, tt->track().found());
3561  PVValHelper::fill(h, "lost_" + ttype, tt->track().lost());
3562  PVValHelper::fill(h, "nchi2_" + ttype, tt->track().normalizedChi2());
3563  PVValHelper::fill(h, "rstart_" + ttype, (tt->track().innerPosition()).Rho());
3564 
3565  double d0Error = tt->track().d0Error();
3566  double d0 = tt->track().dxy(beamSpot.position());
3567  double dz = tt->track().dz(beamSpot.position());
3568  if (d0Error > 0) {
3569  PVValHelper::fill(h, "logtresxy_" + ttype, log(d0Error / 0.0001) / log(10.));
3570  PVValHelper::fill(h, "tpullxy_" + ttype, d0 / d0Error);
3571  PVValHelper::fill(h, "tlogDCAxy_" + ttype, log(std::abs(d0 / d0Error)));
3572  }
3573  //double z0=tt->track().vz();
3574  double dzError = tt->track().dzError();
3575  if (dzError > 0) {
3576  PVValHelper::fill(h, "logtresz_" + ttype, log(dzError / 0.0001) / log(10.));
3577  PVValHelper::fill(h, "tpullz_" + ttype, dz / dzError);
3578  PVValHelper::fill(h, "tlogDCAz_" + ttype, log(std::abs(dz / dzError)));
3579  }
3580 
3581  //
3582  double wxy2_ = pow(beamSpot.BeamWidthX(), 2) + pow(beamSpot.BeamWidthY(), 2);
3583 
3585  h, "sigmatrkz_" + ttype, sqrt(pow(tt->track().dzError(), 2) + wxy2_ / pow(tan(tt->track().theta()), 2)));
3586  PVValHelper::fill(h, "sigmatrkz0_" + ttype, tt->track().dzError());
3587 
3588  // track vs vertex
3589  if (v.isValid()) { // && (v.ndof()<10.)) {
3590  // emulate clusterizer input
3591  //const TransientTrack & tt = theB_->build(&t); wrong !!!!
3592  //reco::TransientTrack tt = theB_->build(&t);
3593  //ttt->track().setBeamSpot(beamSpot); // need the setBeamSpot !
3594  double z = (tt->stateAtBeamLine().trackStateAtPCA()).position().z();
3595  double tantheta = tan((tt->stateAtBeamLine().trackStateAtPCA()).momentum().theta());
3596  double dz2 = pow(tt->track().dzError(), 2) + wxy2_ / pow(tantheta, 2);
3597 
3598  PVValHelper::fill(h, "restrkz_" + ttype, z - v.position().z());
3599  PVValHelper::fill(h, "restrkzvsphi_" + ttype, tt->track().phi(), z - v.position().z());
3600  PVValHelper::fill(h, "restrkzvseta_" + ttype, tt->track().eta(), z - v.position().z());
3601  PVValHelper::fill(h, "pulltrkzvsphi_" + ttype, tt->track().phi(), (z - v.position().z()) / sqrt(dz2));
3602  PVValHelper::fill(h, "pulltrkzvseta_" + ttype, tt->track().eta(), (z - v.position().z()) / sqrt(dz2));
3603 
3604  PVValHelper::fill(h, "pulltrkz_" + ttype, (z - v.position().z()) / sqrt(dz2));
3605 
3606  double x1 = tt->track().vx() - beamSpot.x0();
3607  double y1 = tt->track().vy() - beamSpot.y0();
3608 
3609  double kappa = -0.002998 * fBfield_ * tt->track().qoverp() / cos(tt->track().theta());
3610  double D0 = x1 * sin(tt->track().phi()) - y1 * cos(tt->track().phi()) - 0.5 * kappa * (x1 * x1 + y1 * y1);
3611  double q = sqrt(1. - 2. * kappa * D0);
3612  double s0 = (x1 * cos(tt->track().phi()) + y1 * sin(tt->track().phi())) / q;
3613  // double s1;
3614  if (std::abs(kappa * s0) > 0.001) {
3615  //s1=asin(kappa*s0)/kappa;
3616  } else {
3617  //double ks02=(kappa*s0)*(kappa*s0);
3618  //s1=s0*(1.+ks02/6.+3./40.*ks02*ks02+5./112.*pow(ks02,3));
3619  }
3620  // sp.ddcap=-2.*D0/(1.+q);
3621  //double zdcap=tt->track().vz()-s1/tan(tt->track().theta());
3622  }
3623  //
3624 
3625  // collect some info on hits and clusters
3626  PVValHelper::fill(h, "nbarrelLayers_" + ttype, tt->track().hitPattern().pixelBarrelLayersWithMeasurement());
3627  PVValHelper::fill(h, "nPxLayers_" + ttype, tt->track().hitPattern().pixelLayersWithMeasurement());
3628  PVValHelper::fill(h, "nSiLayers_" + ttype, tt->track().hitPattern().trackerLayersWithMeasurement());
3630  h, "expectedInner_" + ttype, tt->track().hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS));
3632  h, "expectedOuter_" + ttype, tt->track().hitPattern().numberOfLostHits(HitPattern::MISSING_OUTER_HITS));
3633  PVValHelper::fill(h, "trackAlgo_" + ttype, tt->track().algo());
3634  PVValHelper::fill(h, "trackQuality_" + ttype, tt->track().qualityMask());
3635 
3636  //
3637  int longesthit = 0, nbarrel = 0;
3638  for (auto const& hit : tt->track().recHits()) {
3639  if (hit->isValid() && hit->geographicalId().det() == DetId::Tracker) {
3640  bool barrel = DetId(hit->geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
3641  //bool endcap = DetId::DetId(hit->geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
3642  if (barrel) {
3643  const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(&(*hit));
3644  edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> const& clust = (*pixhit).cluster();
3645  if (clust.isNonnull()) {
3646  nbarrel++;
3647  if (clust->sizeY() - longesthit > 0)
3648  longesthit = clust->sizeY();
3649  if (clust->sizeY() > 20.) {
3650  PVValHelper::fill(h, "lvseta_" + ttype, tt->track().eta(), 19.9);
3651  PVValHelper::fill(h, "lvstanlambda_" + ttype, tan(tt->track().lambda()), 19.9);
3652  } else {
3653  PVValHelper::fill(h, "lvseta_" + ttype, tt->track().eta(), float(clust->sizeY()));
3654  PVValHelper::fill(h, "lvstanlambda_" + ttype, tan(tt->track().lambda()), float(clust->sizeY()));
3655  }
3656  }
3657  }
3658  }
3659  }
3660  PVValHelper::fill(h, "nbarrelhits_" + ttype, float(nbarrel));
3661  //-------------------------------------------------------------------
3662 }
3663 
3666  desc.setComment("Validates alignment payloads by evaluating unbiased track paramter resisuals to vertices");
3667 
3668  // PV Validation specific
3669 
3670  desc.addUntracked<int>("compressionSettings", -1);
3671  desc.add<bool>("storeNtuple", false);
3672  desc.add<bool>("isLightNtuple", true);
3673  desc.add<bool>("useTracksFromRecoVtx", false);
3674  desc.addUntracked<double>("vertexZMax", 99);
3675  desc.addUntracked<double>("intLumi", 0.);
3676  desc.add<bool>("askFirstLayerHit", false);
3677  desc.addUntracked<bool>("doBPix", true);
3678  desc.addUntracked<bool>("doFPix", true);
3679  desc.addUntracked<double>("probePt", 0.);
3680  desc.addUntracked<double>("probeP", 0.);
3681  desc.addUntracked<double>("probeEta", 2.4);
3682  desc.addUntracked<double>("probeNHits", 0.);
3683  desc.addUntracked<int>("numberOfBins", 24);
3684  desc.addUntracked<double>("minPt", 1.);
3685  desc.addUntracked<double>("maxPt", 20.);
3686  desc.add<bool>("Debug", false);
3687  desc.addUntracked<bool>("runControl", false);
3688  desc.addUntracked<bool>("forceBeamSpot", false);
3689 
3690  std::vector<unsigned int> defaultRuns;
3691  defaultRuns.push_back(0);
3692  desc.addUntracked<std::vector<unsigned int>>("runControlNumber", defaultRuns);
3693 
3694  // event sources
3695 
3696  desc.add<edm::InputTag>("TrackCollectionTag", edm::InputTag("ALCARECOTkAlMinBias"));
3697  desc.add<edm::InputTag>("VertexCollectionTag", edm::InputTag("offlinePrimaryVertices"));
3698  desc.add<edm::InputTag>("BeamSpotTag", edm::InputTag("offlineBeamSpot"));
3699 
3700  // track filtering
3703  psd0.add<int>("numTracksThreshold", 0); // HI only
3704  desc.add<edm::ParameterSetDescription>("TkFilterParameters", psd0);
3705 
3706  // PV Clusterization
3707  {
3709  {
3712  psd0.add<edm::ParameterSetDescription>("TkDAClusParameters", psd1);
3713 
3716  psd0.add<edm::ParameterSetDescription>("TkGapClusParameters", psd2);
3717  }
3718  psd0.add<std::string>("algorithm", "DA_vect");
3719  desc.add<edm::ParameterSetDescription>("TkClusParameters", psd0);
3720  }
3721 
3722  descriptions.add("primaryVertexValidation", desc);
3723 }
3724 
3725 //define this as a plug-in
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
std::vector< TH1F * > h_norm_dxy_modZ_
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const AlgebraicVector3 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix66 &theCovarianceMatrix, const MagneticField *field)
static const char runNumber_[]
static const std::string kSharedResource
Definition: TFileService.h:76
Definition: BitonicSort.h:7
Log< level::Info, true > LogVerbatim
void fillTrackHistos(std::map< std::string, TH1 *> &h, const std::string &ttype, const reco::TransientTrack *tt, const reco::Vertex &v, const reco::BeamSpot &beamSpot, double fBfield)
double qoverp() const
q / p
Definition: TrackBase.h:599
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken_
std::vector< TH1F * > n_IP3DPhiResiduals
Measurement1D getMedian(TH1F *histo)
std::vector< TH1F * > a_dxyEtaResiduals
TH1F * n_dzResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_d3DEtaResiduals
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
unsigned int pxbLayer(const DetId &id) const
std::vector< TH1F * > n_reszPhiResiduals
std::vector< unsigned int > runControlNumbers_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
static bool vtxSort(const reco::Vertex &a, const reco::Vertex &b)
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:798
std::pair< Measurement1D, Measurement1D > fitResiduals(TH1 *hist)
Quality qualityByName(std::string const &name)
edm::EDGetTokenT< reco::BeamSpot > theBeamspotToken_
void fillTrendPlot(TH1F *trendPlot, TH1F *residualsPlot[100], PVValHelper::estimator fitPar_, const std::string &var_)
std::vector< TH1F * > h_dxy_pT_
TH1F * a_dxyResidualsMap[nMaxBins_][nMaxBins_]
std::map< std::string, TH1 * > hDA
TrackQuality
track quality
Definition: TrackBase.h:150
std::vector< TH1F * > a_IP3DEtaResiduals
Common base class.
std::vector< float > generateBins(int n, float start, float range)
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
std::vector< TH1F * > n_dzPhiResiduals
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
Divides< arg, void > D0
Definition: Factorize.h:135
std::vector< TH1F * > a_d3DPhiResiduals
std::vector< TH1F * > n_d3DPhiResiduals
PrimaryVertexValidation(const edm::ParameterSet &)
std::vector< TH1F * > n_dxyPhiBiasResiduals
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:57
TH1F * n_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > n_d3DEtaResiduals
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > trackingGeomToken_
std::vector< TH1F * > h_norm_dz_Central_pT_
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
const unsigned getPXBModules(unsigned int lay) const
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:81
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double longitudinalImpactParameterError() const
float DOFUnbiasedVertex_[nMaxtracks_]
std::map< std::pair< residualType, plotVariable >, std::pair< float, float > > range
double d3DFromMyVertex_[nMaxtracks_]
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
std::vector< TH1F * > a_reszPhiResiduals
std::vector< TH1F * > a_IP2DPhiResiduals
float chi2ProbUnbiasedVertex_[nMaxtracks_]
unsigned int pxbLadder(const DetId &id) const
const PerigeeTrajectoryError & perigeeError() const
Log< level::Error, false > LogError
std::vector< TH1F * > n_reszEtaResiduals
double dxyFromMyVertex_[nMaxtracks_]
assert(be >=bs)
constexpr double max_eta_phase2
Measurement1D getMAD(TH1F *histo)
std::map< std::string, TH1 * > bookVertexHistograms(const TFileDirectory &dir)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< TH1F * > h_dz_modZ_
std::vector< TH1F * > h_dxy_modZ_
std::vector< TH1F * > a_dxEtaResiduals
std::pair< bool, bool > pixelHitsCheck(const reco::TransientTrack &track)
plotLabels getVarString(plotVariable var)
double dzErrorFromMyVertex_[nMaxtracks_]
static std::string to_string(const XMLCh *ch)
std::vector< TH1F * > n_dxyEtaBiasResiduals
#define LogTrace(id)
std::vector< TH1F * > n_dxyEtaResiduals
double IPTsigFromMyVertex_[nMaxtracks_]
T getUntrackedParameter(std::string const &, T const &) const
reco::TransientTrack build(const reco::Track *p) const
GlobalPoint position() const
std::vector< TH1F * > a_dzPhiBiasResiduals
std::map< plotVariable, std::vector< float > > trendbins
double pt() const
track transverse momentum
Definition: TrackBase.h:637
T * make(const Args &...args) const
make new ROOT object
constexpr double max_eta_phase1
auto recHits() const
Access to reconstructed hits on the track.
Definition: Track.h:85
std::vector< TH1F * > h_norm_dxy_pT_
std::vector< TH1F * > a_dzEtaResiduals
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
edm::EDGetTokenT< reco::VertexCollection > theVertexCollectionToken_
float getHigh(residualType type, plotVariable plot)
int tracksUsedForVertexing_[nMaxtracks_]
float getLow(residualType type, plotVariable plot)
int charge() const
track electric charge
Definition: TrackBase.h:596
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:622
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
Definition: TTTypes.h:54
RunNumber_t run() const
Definition: RunBase.h:40
runControlNumber
Definition: PV_cfg.py:170
std::vector< TH1F * > a_dxyEtaBiasResiduals
const edm::ESGetToken< RunInfo, RunInfoRcd > runInfoTokenBR_
std::vector< TH1F * > h_norm_dxy_ladder_
std::vector< TH1F * > a_dzPhiResiduals
double dzError() const
error on dz
Definition: TrackBase.h:778
double yUnbiasedVertex_[nMaxtracks_]
bool isThere(GeomDetEnumerators::SubDetector subdet) const
std::unique_ptr< TrackClusterizerInZ > theTrackClusterizer_
T sqrt(T t)
Definition: SSEVec.h:19
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::vector< TH1F * > n_dxyPhiResiduals
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TH1F * a_dzL1ResidualsMap[nMaxBins_][nMaxBins_]
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double zUnbiasedVertex_[nMaxtracks_]
Transition
Definition: Transition.h:12
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< TH1F * > h_dxy_ladder_
void fill(std::map< std::string, TH1 *> &h, const std::string &s, double x)
float chi2normUnbiasedVertex_[nMaxtracks_]
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
TH1F * n_d3DResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_dxyPhiResiduals
std::vector< TH1F * > a_dxyPhiBiasResiduals
void analyze(const edm::Event &, const edm::EventSetup &) override
TH1F * a_d3DResidualsMap[nMaxBins_][nMaxBins_]
ParameterDescriptionBase * add(U const &iLabel, T const &value)
float clusterProbability(unsigned int flags=0) const
Definition: SiPixelRecHit.cc:9
std::vector< TH1F * > h_dxy_ladderNoOverlap_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
TH1F * n_dxyL1ResidualsMap[nMaxBins_][nMaxBins_]
double IPLsigFromMyVertex_[nMaxtracks_]
void fillMap(TH2F *trendMap, TH1F *residualsMapPlot[100][100], PVValHelper::estimator fitPar_, const int nXBins_, const int nYBins_)
const PerigeeTrajectoryParameters & perigeeParameters() const
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
bool hasFirstLayerPixelHits(const reco::TransientTrack &track)
std::vector< TH1F * > n_dzEtaResiduals
void setMap(residualType type, plotVariable plot, float low, float high)
std::unique_ptr< TrackFilterForPVFindingBase > theTrackFilter_
#define M_PI
std::vector< TH1F * > n_IP3DEtaResiduals
Log< level::Info, false > LogInfo
std::vector< TH1F * > h_norm_dz_pT_
bool isHit2D(const TrackingRecHit &hit, const PVValHelper::detectorPhase &thePhase) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
Definition: DetId.h:17
bool isBFieldConsistentWithMode(const edm::EventSetup &iSetup) const
static constexpr float d0
TH1F * a_dxyL1ResidualsMap[nMaxBins_][nMaxBins_]
void shrinkHistVectorToFit(std::vector< TH1F *> &h, unsigned int desired_size)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
std::vector< TH1F * > h_dz_pT_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttkToken_
plotLabels getTypeString(residualType type)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
std::vector< TH1F * > n_dzEtaBiasResiduals
edm::Service< TFileService > fs
std::vector< TH1F * > h_dz_Central_pT_
std::vector< TH1F * > h_dz_ladder_
std::vector< TH1F * > a_IP2DEtaResiduals
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:587
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:593
constexpr double max_eta_phase0
double b
Definition: hdecay.h:120
const FreeTrajectoryState & theState() const
std::vector< TH1F * > n_IP2DPhiResiduals
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double xUnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > h_dxy_Central_pT_
PVValHelper::detectorPhase phase_
bool isValid() const
Definition: HandleBase.h:70
double value() const
Definition: Measurement1D.h:25
TH1F * n_dzL1ResidualsMap[nMaxBins_][nMaxBins_]
double theta() const
polar angle
Definition: TrackBase.h:602
std::map< unsigned int, std::pair< long long, long long > > runNumbersTimesLog_
~PrimaryVertexValidation() override
Pixel cluster – collection of neighboring pixels above threshold.
TString units(TString variable, Char_t axis)
double dzFromMyVertex_[nMaxtracks_]
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:289
std::vector< TH1F * > a_reszEtaResiduals
std::vector< TH1F * > bookResidualsHistogram(const TFileDirectory &dir, unsigned int theNOfBins, PVValHelper::residualType resType, PVValHelper::plotVariable varType, bool isNormalized=false)
double error() const
Definition: Measurement1D.h:27
TH1F * a_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::vector< TH1F * > a_dxPhiResiduals
std::vector< TH1F * > h_norm_dz_modZ_
TH1F * n_dxyResidualsMap[nMaxBins_][nMaxBins_]
bool passesTrackCuts(const reco::Track &track, const reco::Vertex &vertex, const std::string &qualityString_, double dxyErrMax_, double dzErrMax_, double ptErrMax_)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoTokenBR_
double dxyErrorFromMyVertex_[nMaxtracks_]
std::vector< TH1F * > a_dyEtaResiduals
unsigned int pxbModule(const DetId &id) const
Log< level::Warning, false > LogWarning
std::vector< TH1F * > n_IP2DEtaResiduals
std::vector< TH1F * > h_norm_dz_ladder_
char const * what() const noexcept override
Definition: Exception.cc:107
float sumOfWeightsUnbiasedVertex_[nMaxtracks_]
void fillByIndex(std::vector< TH1F *> &h, unsigned int index, double x, std::string tag="")
TH1F * n_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
double d3DErrorFromMyVertex_[nMaxtracks_]
std::vector< TH1F * > a_dyPhiResiduals
double d0Error() const
error on d0
Definition: TrackBase.h:772
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< TH1F * > h_dxy_ladderOverlap_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
TH1F * a_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
PVValHelper::histodetails theDetails_
std::array< float, nPtBins_+1 > mypT_bins_
TH1F * a_dzResidualsMap[nMaxBins_][nMaxBins_]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
float chi2UnbiasedVertex_[nMaxtracks_]
std::pair< long long, long long > getRunTime(const edm::EventSetup &iSetup) const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const unsigned getPXBLadders(unsigned int lay) const
std::vector< TH1F * > h_norm_dxy_Central_pT_
Definition: Run.h:45
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void fillTrendPlotByIndex(TH1F *trendPlot, std::vector< TH1F *> &h, PVValHelper::estimator fitPar_, PVValHelper::plotVariable plotVar=PVValHelper::END_OF_PLOTS)
std::vector< TH1F * > a_dzEtaBiasResiduals
Our base class.
Definition: SiPixelRecHit.h:23
std::vector< TH1F * > a_IP3DPhiResiduals
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:608
#define LogDebug(id)
std::vector< TH1F * > n_dzPhiBiasResiduals
double IP3DsigFromMyVertex_[nMaxtracks_]
TFile & file() const
return opened TFile
Definition: TFileService.h:37
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomTokenBR_