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 
24 // user include files
26 
27 // ROOT includes
28 #include "TH1F.h"
29 #include "TH2F.h"
30 #include "TF1.h"
31 #include "TVector3.h"
32 #include "TFile.h"
33 #include "TMath.h"
34 #include "TROOT.h"
35 #include "TChain.h"
36 #include "TNtuple.h"
37 #include "TMatrixD.h"
38 #include "TVectorD.h"
39 
40 // CMSSW includes
65 
67 
68 // Constructor
70  storeNtuple_(iConfig.getParameter<bool>("storeNtuple")),
71  lightNtupleSwitch_(iConfig.getParameter<bool>("isLightNtuple")),
72  useTracksFromRecoVtx_(iConfig.getParameter<bool>("useTracksFromRecoVtx")),
73  vertexZMax_(iConfig.getUntrackedParameter<double>("vertexZMax",99.)),
74  intLumi_(iConfig.getUntrackedParameter<double>("intLumi",0.)),
75  askFirstLayerHit_(iConfig.getParameter<bool>("askFirstLayerHit")),
76  doBPix_(iConfig.getUntrackedParameter<bool>("doBPix",true)),
77  doFPix_(iConfig.getUntrackedParameter<bool>("doFPix",true)),
78  ptOfProbe_(iConfig.getUntrackedParameter<double>("probePt",0.)),
79  pOfProbe_(iConfig.getUntrackedParameter<double>("probeP",0.)),
80  etaOfProbe_(iConfig.getUntrackedParameter<double>("probeEta",2.4)),
81  nHitsOfProbe_(iConfig.getUntrackedParameter<double>("probeNHits",0.)),
82  nBins_(iConfig.getUntrackedParameter<int>("numberOfBins",24)),
83  debug_(iConfig.getParameter<bool>("Debug")),
84  runControl_(iConfig.getUntrackedParameter<bool>("runControl",false))
85 {
86 
87  // now do what ever initialization is needed
88  // initialize phase space boundaries
89 
90  usesResource(TFileService::kSharedResource);
91 
92  std::vector<unsigned int> defaultRuns;
93  defaultRuns.push_back(0);
94  runControlNumbers_ = iConfig.getUntrackedParameter<std::vector<unsigned int> >("runControlNumber",defaultRuns);
95 
96  edm::InputTag TrackCollectionTag_ = iConfig.getParameter<edm::InputTag>("TrackCollectionTag");
97  theTrackCollectionToken = consumes<reco::TrackCollection>(TrackCollectionTag_);
98 
99  edm::InputTag VertexCollectionTag_ = iConfig.getParameter<edm::InputTag>("VertexCollectionTag");
100  theVertexCollectionToken = consumes<reco::VertexCollection>(VertexCollectionTag_);
101 
102  edm::InputTag BeamspotTag_ = edm::InputTag("offlineBeamSpot");
103  theBeamspotToken = consumes<reco::BeamSpot>(BeamspotTag_);
104 
105  // select and configure the track filter
106  theTrackFilter_= new TrackFilterForPVFinding(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters") );
107  // select and configure the track clusterizer
108  std::string clusteringAlgorithm=iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
109  if (clusteringAlgorithm=="gap"){
110  theTrackClusterizer_ = new GapClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkGapClusParameters"));
111  }else if(clusteringAlgorithm=="DA"){
112  theTrackClusterizer_ = new DAClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
113  // provide the vectorized version of the clusterizer, if supported by the build
114  } else if(clusteringAlgorithm=="DA_vect") {
115  theTrackClusterizer_ = new DAClusterizerInZ_vect(iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<edm::ParameterSet>("TkDAClusParameters"));
116  } else {
117  throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
118  }
119 
120  theDetails_.histobins = 500;
127 
128  for (int i = PVValHelper::phi; i < PVValHelper::END_OF_PLOTS; i++ ){
129  for (int j = PVValHelper::dx; j < PVValHelper::END_OF_TYPES; j++ ){
130 
131  auto plot_index = static_cast<PVValHelper::plotVariable>(i);
132  auto res_index = static_cast<PVValHelper::residualType>(j);
133 
134  if(debug_){
135  edm::LogInfo("PrimaryVertexValidation")<<"==> "<<std::get<0>(PVValHelper::getTypeString(res_index)) << " "<< std::setw(10)<< std::get<0>(PVValHelper::getVarString(plot_index))<<std::endl;
136  }
137  if(res_index!=PVValHelper::d3D && res_index!=PVValHelper::norm_d3D)
138  theDetails_.setMap(res_index,plot_index,theDetails_.getLow(PVValHelper::dxy,plot_index),theDetails_.getHigh(PVValHelper::dxy,plot_index));
139  else
140  theDetails_.setMap(res_index,plot_index,0.,theDetails_.getHigh(PVValHelper::dxy,plot_index));
141  }
142  }
143 
144  for (const auto & it : theDetails_.range){
145  edm::LogVerbatim("PrimaryVertexValidation")<<std::setw(10) << std::get<0>(PVValHelper::getTypeString(it.first.first)) << " "<< std::setw(10)<< std::get<0>(PVValHelper::getVarString(it.first.second)) << " (" << std::setw(5)<< it.second.first << ";" <<std::setw(5)<< it.second.second << ")"<<std::endl;
146  }
147 
150 
151  if(debug_){
152  edm::LogVerbatim("PrimaryVertexValidation") << "etaBins: ";
153  for (auto ieta: theDetails_.trendbins[PVValHelper::eta]) {
154  edm::LogVerbatim("PrimaryVertexValidation") << ieta << " ";
155  }
156  edm::LogVerbatim("PrimaryVertexValidation") << "\n";
157 
158  edm::LogVerbatim("PrimaryVertexValidation") << "phiBins: ";
159  for (auto iphi: theDetails_.trendbins[PVValHelper::phi]) {
160  edm::LogVerbatim("PrimaryVertexValidation") << iphi << " ";
161  }
162  edm::LogVerbatim("PrimaryVertexValidation") << "\n";
163  }
164 
165 }
166 
167 // Destructor
169 {
170  // do anything here that needs to be done at desctruction time
171  // (e.g. close files, deallocate resources etc.)
172 }
173 
174 
175 //
176 // member functions
177 //
178 
179 // ------------ method called to for each event ------------
180 void
182 {
183 
184  using namespace std;
185  using namespace reco;
186  using namespace IPTools;
187 
188  if (!isBFieldConsistentWithMode(iSetup)) {
189  edm::LogWarning("PrimaryVertexValidation") << "*********************************************************************************\n"
190  << "* The configuration (ptOfProbe > " << ptOfProbe_ << "GeV) is not correctly set for current value of magnetic field \n"
191  << "* Switching it to 0. !!! \n"
192  << "*********************************************************************************"<< std::endl;
193  ptOfProbe_=0.;
194  }
195 
196  if(nBins_!=24 && debug_){
197  edm::LogInfo("PrimaryVertexValidation")<<"Using: "<<nBins_<<" bins plots";
198  }
199 
200  bool passesRunControl = false;
201 
202  if(runControl_){
203  for(const auto & runControlNumber : runControlNumbers_){
204  if(iEvent.eventAuxiliary().run() == runControlNumber){
205  if (debug_){
206  edm::LogInfo("PrimaryVertexValidation")<<" run number: "<<iEvent.eventAuxiliary().run()<<" keeping run:"<<runControlNumber;
207  }
208  passesRunControl = true;
209  break;
210  }
211  }
212  if (!passesRunControl) return;
213  }
214 
215  Nevt_++;
216 
217  //=======================================================
218  // Initialize Root-tuple variables
219  //=======================================================
220 
221  SetVarToZero();
222 
223  //=======================================================
224  // Retrieve the Magnetic Field information
225  //=======================================================
226 
227  edm::ESHandle<MagneticField> theMGField;
228  iSetup.get<IdealMagneticFieldRecord>().get( theMGField );
229 
230  //=======================================================
231  // Retrieve the Tracking Geometry information
232  //=======================================================
233 
234  edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
235  iSetup.get<GlobalTrackingGeometryRecord>().get( theTrackingGeometry );
236 
237  //=======================================================
238  // Retrieve geometry information
239  //=======================================================
240 
241  edm::LogInfo("read tracker geometry...");
243  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
244  edm::LogInfo("tracker geometry read")<<"There are: "<< pDD->dets().size() <<" detectors";
245 
246  // switch on the phase1
247  if( (pDD->isThere(GeomDetEnumerators::P1PXB)) ||
249  isPhase1_ = true;
250  nLadders_ = 12;
251 
252  if(h_dxy_ladderOverlap_.size()!=nLadders_){
253 
260 
261  if (debug_){
262  edm::LogInfo("PrimaryVertexValidation")<<"checking size:"<<h_dxy_ladder_.size()<<std::endl;
263  }
264  }
265 
266  if (debug_){
267  edm::LogInfo("PrimaryVertexValidation")<<" pixel phase1 setup, nLadders: "<<nLadders_;
268  }
269 
270  } else {
271  isPhase1_ = false;
272  nLadders_ = 20;
273  if (debug_){
274  edm::LogInfo("PrimaryVertexValidation")<<" pixel phase0 setup, nLadders: "<<nLadders_;
275  }
276  }
277 
278  if(isPhase1_){
280  } else {
282  }
283 
284  if(h_etaMax->GetEntries()==0.){
285  h_etaMax->SetBinContent(1.,etaOfProbe_);
286  h_nbins->SetBinContent(1.,nBins_);
287  h_nLadders->SetBinContent(1.,nLadders_);
288  }
289 
290  //=======================================================
291  // Retrieve the Transient Track Builder information
292  //=======================================================
293 
295  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB_);
296  double fBfield_=((*theB_).field()->inTesla(GlobalPoint(0.,0.,0.))).z();
297 
298  //=======================================================
299  // Retrieve the Track information
300  //=======================================================
301 
302  edm::Handle<TrackCollection> trackCollectionHandle;
303  iEvent.getByToken(theTrackCollectionToken, trackCollectionHandle);
304  if(!trackCollectionHandle.isValid()) return;
305  auto const & tracks = *trackCollectionHandle;
306 
307  //=======================================================
308  // Retrieve tracker topology from geometry
309  //=======================================================
310 
311  edm::ESHandle<TrackerTopology> tTopoHandle;
312  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
313  const TrackerTopology* const tTopo = tTopoHandle.product();
314 
315  //=======================================================
316  // Retrieve offline vartex information (only for reco)
317  //=======================================================
318 
319  //edm::Handle<VertexCollection> vertices;
321 
322  try {
323  iEvent.getByToken(theVertexCollectionToken, vertices);
324  } catch ( cms::Exception& er ) {
325  LogTrace("PrimaryVertexValidation")<<"caught std::exception "<<er.what()<<std::endl;
326  }
327 
328  std::vector<Vertex> vsorted = *(vertices);
329  // sort the vertices by number of tracks in descending order
330  // use chi2 as tiebreaker
331  std::sort( vsorted.begin(), vsorted.end(), PrimaryVertexValidation::vtxSort );
332 
333  // skip events with no PV, this should not happen
334 
335  if( vsorted.empty()) return;
336 
337  // skip events failing vertex cut
338  if( std::abs(vsorted[0].z()) > vertexZMax_ ) return;
339 
340  if ( vsorted[0].isValid() ) {
341  xOfflineVertex_ = (vsorted)[0].x();
342  yOfflineVertex_ = (vsorted)[0].y();
343  zOfflineVertex_ = (vsorted)[0].z();
344 
345  xErrOfflineVertex_ = (vsorted)[0].xError();
346  yErrOfflineVertex_ = (vsorted)[0].yError();
347  zErrOfflineVertex_ = (vsorted)[0].zError();
348  }
349 
356 
357  unsigned int vertexCollectionSize = vsorted.size();
358  int nvvertex = 0;
359 
360  for (unsigned int i=0; i<vertexCollectionSize; i++) {
361  const Vertex& vertex = vsorted.at(i);
362  if (vertex.isValid()) nvvertex++;
363  }
364 
365  nOfflineVertices_ = nvvertex;
366  h_nOfflineVertices->Fill(nvvertex);
367 
368  if ( !vsorted.empty() && useTracksFromRecoVtx_ ) {
369 
370  double sumpt = 0;
371  size_t ntracks = 0;
372  double chi2ndf = 0.;
373  double chi2prob = 0.;
374 
375  if (!vsorted.at(0).isFake()) {
376 
377  Vertex pv = vsorted.at(0);
378 
379  ntracks = pv.tracksSize();
380  chi2ndf = pv.normalizedChi2();
381  chi2prob = TMath::Prob(pv.chi2(),(int)pv.ndof());
382 
383  h_recoVtxNtracks_->Fill(ntracks);
384  h_recoVtxChi2ndf_->Fill(chi2ndf);
385  h_recoVtxChi2Prob_->Fill(chi2prob);
386 
387  for (Vertex::trackRef_iterator itrk = pv.tracks_begin();itrk != pv.tracks_end(); ++itrk) {
388  double pt = (**itrk).pt();
389  sumpt += pt*pt;
390 
391  const math::XYZPoint myVertex(pv.position().x(),pv.position().y(),pv.position().z());
392 
393  double dxyRes = (**itrk).dxy(myVertex);
394  double dzRes = (**itrk).dz(myVertex);
395 
396  double dxy_err = (**itrk).dxyError();
397  double dz_err = (**itrk).dzError();
398 
399  float trackphi = ((**itrk).phi())*(180/M_PI);
400  float tracketa = (**itrk).eta();
401 
402  for(int i=0; i<nBins_; i++){
403 
404  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
405  float phiL = theDetails_.trendbins[PVValHelper::phi][i+1];
406 
407  float etaF = theDetails_.trendbins[PVValHelper::eta][i];
408  float etaL = theDetails_.trendbins[PVValHelper::eta][i+1];
409 
410  if(tracketa >= etaF && tracketa < etaL ){
411 
416 
417  }
418 
419  if(trackphi >= phiF && trackphi < phiL ){
420 
425 
426  for(int j=0; j<nBins_; j++){
427 
428  float etaJ = theDetails_.trendbins[PVValHelper::eta][j];
429  float etaK = theDetails_.trendbins[PVValHelper::eta][j+1];
430 
431  if(tracketa >= etaJ && tracketa < etaK ){
432 
433  a_dxyBiasResidualsMap[i][j]->Fill(dxyRes*cmToum);
434  a_dzBiasResidualsMap[i][j]->Fill(dzRes*cmToum);
435 
436  n_dxyBiasResidualsMap[i][j]->Fill((dxyRes)/dxy_err);
437  n_dzBiasResidualsMap[i][j]->Fill((dzRes)/dz_err);
438 
439  }
440  }
441  }
442  }
443  }
444 
445  h_recoVtxSumPt_->Fill(sumpt);
446 
447  }
448  }
449 
450  //=======================================================
451  // Retrieve Beamspot information
452  //=======================================================
453 
455  edm::Handle<BeamSpot> beamSpotHandle;
456  iEvent.getByToken(theBeamspotToken, beamSpotHandle);
457 
458  if ( beamSpotHandle.isValid() ) {
459  beamSpot = *beamSpotHandle;
460  BSx0_ = beamSpot.x0();
461  BSy0_ = beamSpot.y0();
462  BSz0_ = beamSpot.z0();
463  Beamsigmaz_ = beamSpot.sigmaZ();
464  Beamdxdz_ = beamSpot.dxdz();
465  BeamWidthX_ = beamSpot.BeamWidthX();
466  BeamWidthY_ = beamSpot.BeamWidthY();
467 
468  wxy2_=TMath::Power(BeamWidthX_,2)+TMath::Power(BeamWidthY_,2);
469 
470  } else {
471  edm::LogWarning("PrimaryVertexValidation")<<"No BeamSpot found!";
472  }
473 
474  h_BSx0->Fill(BSx0_);
475  h_BSy0->Fill(BSy0_);
476  h_BSz0->Fill(BSz0_);
477  h_Beamsigmaz->Fill(Beamsigmaz_);
478  h_BeamWidthX->Fill(BeamWidthX_);
479  h_BeamWidthY->Fill(BeamWidthY_);
480 
481  if(debug_)
482  edm::LogInfo("PrimaryVertexValidation")<<"Beamspot x:" <<BSx0_<<" y:"<<BSy0_<<" z:"<<BSz0_;
483 
484  //=======================================================
485  // Starts here ananlysis
486  //=======================================================
487 
488  RunNumber_=iEvent.eventAuxiliary().run();
489  h_runNumber->Fill(RunNumber_);
490 
491  if(h_runFromEvent->GetEntries()==0){
492  h_runFromEvent->SetBinContent(1,RunNumber_);
493  }
494 
496  EventNumber_=iEvent.eventAuxiliary().id().event();
497 
498  if(debug_)
499  edm::LogInfo("PrimaryVertexValidation")<<" looping over "<<trackCollectionHandle->size()<< "tracks";
500 
501  h_nTracks->Fill(trackCollectionHandle->size());
502 
503  //======================================================
504  // Interface RECO tracks to vertex reconstruction
505  //======================================================
506 
507  std::vector<TransientTrack> t_tks;
508  for (const auto & track : tracks){
509  TransientTrack tt = theB_->build(&(track));
510  tt.setBeamSpot(beamSpot);
511  t_tks.push_back(tt);
512 
513  }
514 
515  if(debug_) {
516  edm::LogInfo("PrimaryVertexValidation") << "Found: " << t_tks.size() << " reconstructed tracks";
517  }
518 
519  //======================================================
520  // select the tracks
521  //======================================================
522 
523  std::vector<TransientTrack> seltks = theTrackFilter_->select(t_tks);
524 
525  //======================================================
526  // clusterize tracks in Z
527  //======================================================
528 
529  vector< vector<TransientTrack> > clusters = theTrackClusterizer_->clusterize(seltks);
530 
531  if (debug_){
532  edm::LogInfo("PrimaryVertexValidation")<<" looping over: "<< clusters.size() << " clusters from " << t_tks.size() << " selected tracks";
533  }
534 
535  nClus_=clusters.size();
536  h_nClus->Fill(nClus_);
537 
538  //======================================================
539  // Starts loop on clusters
540  //======================================================
541  for (const auto & iclus : clusters){
542 
543  nTracksPerClus_=0;
544 
545  unsigned int i=0;
546  for(const auto & theTTrack : iclus)
547  {
548  i++;
549 
550  if ( nTracks_ >= nMaxtracks_ ) {
551  edm::LogError("PrimaryVertexValidation")<<" Warning - Number of tracks: " << nTracks_ << " , greater than " << nMaxtracks_;
552  continue;
553  }
554 
555  const Track & theTrack = theTTrack.track();
556 
557  pt_[nTracks_] = theTrack.pt();
558  p_[nTracks_] = theTrack.p();
559  nhits_[nTracks_] = theTrack.numberOfValidHits();
560  eta_[nTracks_] = theTrack.eta();
561  theta_[nTracks_] = theTrack.theta();
562  phi_[nTracks_] = theTrack.phi();
563  chi2_[nTracks_] = theTrack.chi2();
564  chi2ndof_[nTracks_] = theTrack.normalizedChi2();
565  charge_[nTracks_] = theTrack.charge();
566  qoverp_[nTracks_] = theTrack.qoverp();
567  dz_[nTracks_] = theTrack.dz();
568  dxy_[nTracks_] = theTrack.dxy();
569 
570  TrackBase::TrackQuality _trackQuality = TrackBase::qualityByName("highPurity");
571  isHighPurity_[nTracks_] = theTrack.quality(_trackQuality);
572 
574  dxyBs_[nTracks_] = theTrack.dxy(point);
575  dzBs_[nTracks_] = theTrack.dz(point);
576 
577  xPCA_[nTracks_] = theTrack.vertex().x();
578  yPCA_[nTracks_] = theTrack.vertex().y();
579  zPCA_[nTracks_] = theTrack.vertex().z();
580 
581  //=======================================================
582  // Retrieve rechit information
583  //=======================================================
584 
585  const reco::HitPattern& hits = theTrack.hitPattern();
586 
587  int nRecHit1D=0;
588  int nRecHit2D=0;
589  int nhitinTIB = hits.numberOfValidStripTIBHits();
590  int nhitinTOB = hits.numberOfValidStripTOBHits();
591  int nhitinTID = hits.numberOfValidStripTIDHits();
592  int nhitinTEC = hits.numberOfValidStripTECHits();
593  int nhitinBPIX = hits.numberOfValidPixelBarrelHits();
594  int nhitinFPIX = hits.numberOfValidPixelEndcapHits();
595 
596  for (trackingRecHit_iterator iHit = theTTrack.recHitsBegin(); iHit != theTTrack.recHitsEnd(); ++iHit) {
597  if((*iHit)->isValid()) {
598 
599  if (this->isHit2D(**iHit)) {++nRecHit2D;}
600  else {++nRecHit1D; }
601  }
602  }
603 
604  nhits1D_[nTracks_] = nRecHit1D;
605  nhits2D_[nTracks_] = nRecHit2D;
606  nhitsBPIX_[nTracks_] = nhitinBPIX;
607  nhitsFPIX_[nTracks_] = nhitinFPIX;
608  nhitsTIB_[nTracks_] = nhitinTIB;
609  nhitsTID_[nTracks_] = nhitinTID;
610  nhitsTOB_[nTracks_] = nhitinTOB;
611  nhitsTEC_[nTracks_] = nhitinTEC;
612 
613  //=======================================================
614  // Good tracks for vertexing selection
615  //=======================================================
616 
617  bool pass = true;
618  if(askFirstLayerHit_) pass = this->hasFirstLayerPixelHits(theTTrack);
619  if (pass
620  && (theTrack.pt() >=ptOfProbe_)
621  && std::abs(theTrack.eta()) <= etaOfProbe_
622  && (theTrack.numberOfValidHits())>=nHitsOfProbe_
623  && (theTrack.p()) >= pOfProbe_ ){
625  }
626 
627  //=======================================================
628  // Fit unbiased vertex
629  //=======================================================
630 
631  vector<TransientTrack> theFinalTracks;
632  theFinalTracks.clear();
633 
634  for (const auto & tk : iclus) {
635 
636  pass = this->hasFirstLayerPixelHits(tk);
637  if (pass){
638  if( tk == theTTrack ) continue;
639  else {
640  theFinalTracks.push_back(tk);
641  }
642  }
643  }
644 
645  if(theFinalTracks.size() > 1){
646 
647  if(debug_)
648  edm::LogInfo("PrimaryVertexValidation")<<"Transient Track Collection size: "<<theFinalTracks.size();
649  try{
650 
651  auto theFitter = std::unique_ptr<VertexFitter<5> >( new AdaptiveVertexFitter());
652  TransientVertex theFittedVertex = theFitter->vertex(theFinalTracks);
653 
654  //AdaptiveVertexFitter* theFitter = new AdaptiveVertexFitter;
655  //TransientVertex theFittedVertex = theFitter->vertex(theFinalTracks,beamSpot); // if you want the beam constraint
656 
657  double totalTrackWeights=0;
658  if(theFittedVertex.isValid ()){
659 
660 
661  if(theFittedVertex.hasTrackWeight()){
662  for(const auto & theFinalTrack : theFinalTracks){
663  sumOfWeightsUnbiasedVertex_[nTracks_] += theFittedVertex.trackWeight(theFinalTrack);
664  totalTrackWeights+= theFittedVertex.trackWeight(theFinalTrack);
665  h_fitVtxTrackWeights_->Fill(theFittedVertex.trackWeight(theFinalTrack));
666  }
667  }
668 
669  h_fitVtxTrackAverageWeight_->Fill(totalTrackWeights/theFinalTracks.size());
670 
672  const math::XYZPoint myVertex(theFittedVertex.position().x(),theFittedVertex.position().y(),theFittedVertex.position().z());
673 
674  const Vertex vertex = theFittedVertex;
675  fillTrackHistos(hDA,"all",&theTTrack,vertex,beamSpot,fBfield_);
676 
677  hasRecVertex_[nTracks_] = 1;
678  xUnbiasedVertex_[nTracks_] = theFittedVertex.position().x();
679  yUnbiasedVertex_[nTracks_] = theFittedVertex.position().y();
680  zUnbiasedVertex_[nTracks_] = theFittedVertex.position().z();
681 
682  chi2normUnbiasedVertex_[nTracks_] = theFittedVertex.normalisedChiSquared();
683  chi2UnbiasedVertex_[nTracks_] = theFittedVertex.totalChiSquared();
684  DOFUnbiasedVertex_[nTracks_] = theFittedVertex.degreesOfFreedom();
685  chi2ProbUnbiasedVertex_[nTracks_] = TMath::Prob(theFittedVertex.totalChiSquared(),(int)theFittedVertex.degreesOfFreedom());
686  tracksUsedForVertexing_[nTracks_] = theFinalTracks.size();
687 
688  h_fitVtxNtracks_->Fill(theFinalTracks.size());
689  h_fitVtxChi2_->Fill(theFittedVertex.totalChiSquared());
690  h_fitVtxNdof_->Fill(theFittedVertex.degreesOfFreedom());
691  h_fitVtxChi2ndf_->Fill(theFittedVertex.normalisedChiSquared());
692  h_fitVtxChi2Prob_->Fill(TMath::Prob(theFittedVertex.totalChiSquared(),(int)theFittedVertex.degreesOfFreedom()));
693 
694  // from my Vertex
695  double dxyFromMyVertex = theTrack.dxy(myVertex);
696  double dzFromMyVertex = theTrack.dz(myVertex);
697 
698  GlobalPoint vert(theFittedVertex.position().x(),theFittedVertex.position().y(),theFittedVertex.position().z());
699 
700  //FreeTrajectoryState theTrackNearVertex = theTTrack.trajectoryStateClosestToPoint(vert).theState();
701  //double dz_err = sqrt(theFittedVertex.positionError().czz() + theTrackNearVertex.cartesianError().position().czz());
702  //double dz_err = hypot(theTrack.dzError(),theFittedVertex.positionError().czz());
703 
704  double dz_err = sqrt(std::pow(theTrack.dzError(), 2) + theFittedVertex.positionError().czz());
705 
706 
707  // PV2D
708  std::pair<bool,Measurement1D> s_ip2dpv = signedTransverseImpactParameter(theTTrack,
709  GlobalVector(theTrack.px(),
710  theTrack.py(),
711  theTrack.pz()),
712  theFittedVertex);
713 
714  double s_ip2dpv_corr = s_ip2dpv.second.value();
715  double s_ip2dpv_err = s_ip2dpv.second.error();
716 
717  // PV3D
718  std::pair<bool, Measurement1D> s_ip3dpv = signedImpactParameter3D(theTTrack,
719  GlobalVector(theTrack.px(),
720  theTrack.py(),
721  theTrack.pz()),
722  theFittedVertex);
723 
724  double s_ip3dpv_corr = s_ip3dpv.second.value();
725  double s_ip3dpv_err = s_ip3dpv.second.error();
726 
727  // PV3D absolute
728  std::pair<bool,Measurement1D> ip3dpv = absoluteImpactParameter3D(theTTrack,theFittedVertex);
729  double ip3d_corr = ip3dpv.second.value();
730  double ip3d_err = ip3dpv.second.error();
731 
732  // with respect to any specified vertex, such as primary vertex
734 
735  GlobalPoint refPoint = traj.position();
736  GlobalPoint cPToVtx = traj.theState().position();
737 
738  float my_dx = refPoint.x() - myVertex.x();
739  float my_dy = refPoint.y() - myVertex.y();
740 
741  float my_dx2 = cPToVtx.x() - myVertex.x();
742  float my_dy2 = cPToVtx.y() - myVertex.y();
743 
744  float my_dxy = std::sqrt(my_dx*my_dx + my_dy*my_dy);
745 
747  //double d0_error = traj.perigeeError().transverseImpactParameterError();
748  double z0 = traj.perigeeParameters().longitudinalImpactParameter();
749  double z0_error = traj.perigeeError().longitudinalImpactParameterError();
750 
751  if(debug_){
752  edm::LogInfo("PrimaryVertexValidation")<< "my_dx:" << my_dx
753  << " my_dy:" << my_dy
754  << " my_dxy:" << my_dxy
755  << " my_dx2:" << my_dx2
756  << " my_dy2:" << my_dy2
757  << " d0: " << d0
758  << " dxyFromVtx:" << dxyFromMyVertex << "\n"
759  << " ============================== "<< "\n"
760  << "diff1:" << std::abs(d0) - std::abs(my_dxy) << "\n"
761  << "diff2:" << std::abs(d0) - std::abs(dxyFromMyVertex) << "\n"
762  << "diff3:" << (my_dx - my_dx2) << " " << (my_dy - my_dy2) << "\n"
763  << std::endl;
764  }
765 
766  // define IPs
767 
768  dxyFromMyVertex_[nTracks_] = dxyFromMyVertex;
769  dxyErrorFromMyVertex_[nTracks_] = s_ip2dpv_err;
770  IPTsigFromMyVertex_[nTracks_] = dxyFromMyVertex/s_ip2dpv_err;
771 
772  dzFromMyVertex_[nTracks_] = dzFromMyVertex;
773  dzErrorFromMyVertex_[nTracks_] = dz_err;
774  IPLsigFromMyVertex_[nTracks_] = dzFromMyVertex/dz_err;
775 
776  d3DFromMyVertex_[nTracks_] = ip3d_corr;
777  d3DErrorFromMyVertex_[nTracks_] = ip3d_err;
778  IP3DsigFromMyVertex_[nTracks_] = (ip3d_corr/ip3d_err);
779 
780  // fill directly the histograms of residuals
781 
782  float trackphi = (theTrack.phi())*(180./M_PI);
783  float tracketa = theTrack.eta();
784  float trackpt = theTrack.pt();
785  float trackp = theTrack.p();
786  float tracknhits = theTrack.numberOfValidHits();
787 
788  // determine the module number and ladder
789 
790  int ladder_num = -1.;
791  int module_num = -1.;
792  int L1BPixHitCount = 0;
793 
794  for (trackingRecHit_iterator iHit = theTrack.recHitsBegin(); iHit != theTrack.recHitsEnd(); ++iHit) {
795  TrackingRecHit* hit = (*iHit)->clone();
796  const DetId& detId = hit->geographicalId();
797  unsigned int subid = detId.subdetId();
798 
799  if(hit->isValid() && ( subid == PixelSubdetector::PixelBarrel ) ) {
800  int layer = tTopo->pxbLayer(detId);
801  if(layer==1){
802  L1BPixHitCount+=1;
803  ladder_num = tTopo->pxbLadder(detId);
804  module_num = tTopo->pxbModule(detId);
805  }
806  }
807  }
808 
809  h_probeL1Ladder_->Fill(ladder_num);
810  h_probeL1Module_->Fill(module_num);
811  h_probeHasBPixL1Overlap_->Fill(L1BPixHitCount);
812 
813  // filling the pT-binned distributions
814 
815  for(int ipTBin=0; ipTBin<nPtBins_; ipTBin++){
816 
817  float pTF = mypT_bins_[ipTBin];
818  float pTL = mypT_bins_[ipTBin+1];
819 
820  if(debug_)
821  edm::LogInfo("PrimaryVertexValidation")<<"ipTBin:"<<ipTBin<< " "<<mypT_bins_[ipTBin]<< " < pT < "<<mypT_bins_[ipTBin+1]<<std::endl;
822 
823  if( std::abs(tracketa)<1.5 && (trackpt >= pTF && trackpt < pTL) ){
824 
825  if(debug_)
826  edm::LogInfo("PrimaryVertexValidation")<<"passes this cut: "<<mypT_bins_[ipTBin]<<std::endl;
827  PVValHelper::fillByIndex(h_dxy_pT_,ipTBin,dxyFromMyVertex*cmToum);
828  PVValHelper::fillByIndex(h_dz_pT_,ipTBin,dzFromMyVertex*cmToum);
829  PVValHelper::fillByIndex(h_norm_dxy_pT_,ipTBin,dxyFromMyVertex/s_ip2dpv_err);
830  PVValHelper::fillByIndex(h_norm_dz_pT_,ipTBin,dzFromMyVertex/dz_err);
831 
832  if(std::abs(tracketa)<1.){
833 
834  if(debug_)
835  edm::LogInfo("PrimaryVertexValidation")<<"passes tight eta cut: "<<mypT_bins_[ipTBin]<<std::endl;
836  PVValHelper::fillByIndex(h_dxy_Central_pT_,ipTBin,dxyFromMyVertex*cmToum);
837  PVValHelper::fillByIndex(h_dz_Central_pT_,ipTBin,dzFromMyVertex*cmToum);
838  PVValHelper::fillByIndex(h_norm_dxy_Central_pT_,ipTBin,dxyFromMyVertex/s_ip2dpv_err);
839  PVValHelper::fillByIndex(h_norm_dz_Central_pT_,ipTBin,dzFromMyVertex/dz_err);
840  }
841  }
842  }
843 
844  // checks on the probe track quality
845  if(trackpt >= ptOfProbe_
846  && std::abs(tracketa)<= etaOfProbe_
847  && tracknhits>=nHitsOfProbe_
848  && trackp >= pOfProbe_){
849 
850  std::pair<bool,bool> pixelOcc = pixelHitsCheck((theTTrack));
851 
852  if(debug_){
853  if(pixelOcc.first == true)
854  edm::LogInfo("PrimaryVertexValidation")<<"has BPIx hits"<<std::endl;
855  if(pixelOcc.second == true)
856  edm::LogInfo("PrimaryVertexValidation")<<"has FPix hits"<<std::endl;
857  }
858 
859  if(!doBPix_ && (pixelOcc.first == true)) continue;
860  if(!doFPix_ && (pixelOcc.second == true)) continue;
861 
862  fillTrackHistos(hDA,"sel",&(theTTrack),vertex,beamSpot,fBfield_);
863 
864  // probe checks
865  h_probePt_->Fill(theTrack.pt());
866  h_probeP_->Fill(theTrack.p());
867  h_probeEta_->Fill(theTrack.eta());
868  h_probePhi_->Fill(theTrack.phi());
869  h2_probeEtaPhi_->Fill(theTrack.eta(),theTrack.phi());
870  h2_probeEtaPt_->Fill(theTrack.eta(),theTrack.pt());
871 
872  h_probeChi2_->Fill(theTrack.chi2());
873  h_probeNormChi2_->Fill(theTrack.normalizedChi2());
874  h_probeCharge_->Fill(theTrack.charge());
875  h_probeQoverP_->Fill(theTrack.qoverp());
876  h_probeHits_->Fill(theTrack.numberOfValidHits());
877  h_probeHits1D_->Fill(nRecHit1D);
878  h_probeHits2D_->Fill(nRecHit2D);
879  h_probeHitsInTIB_->Fill(nhitinBPIX);
880  h_probeHitsInTOB_->Fill(nhitinFPIX);
881  h_probeHitsInTID_->Fill(nhitinTIB);
882  h_probeHitsInTEC_->Fill(nhitinTID);
883  h_probeHitsInBPIX_->Fill(nhitinTOB);
884  h_probeHitsInFPIX_->Fill(nhitinTEC);
885 
886  float dxyRecoV = theTrack.dz(theRecoVertex);
887  float dzRecoV = theTrack.dxy(theRecoVertex);
888  float dxysigmaRecoV = TMath::Sqrt(theTrack.d0Error()*theTrack.d0Error()+xErrOfflineVertex_*yErrOfflineVertex_);
889  float dzsigmaRecoV = TMath::Sqrt(theTrack.dzError()*theTrack.dzError()+zErrOfflineVertex_*zErrOfflineVertex_);
890 
891  double zTrack=(theTTrack.stateAtBeamLine().trackStateAtPCA()).position().z();
892  double zVertex=theFittedVertex.position().z();
893  double tantheta=tan((theTTrack.stateAtBeamLine().trackStateAtPCA()).momentum().theta());
894 
895  double dz2= pow(theTrack.dzError(),2)+wxy2_/pow(tantheta,2);
896  double restrkz = zTrack-zVertex;
897  double pulltrkz = (zTrack-zVertex)/TMath::Sqrt(dz2);
898 
899  h_probedxyRecoV_->Fill(dxyRecoV);
900  h_probedzRecoV_->Fill(dzRecoV);
901 
902  h_probedzRefitV_->Fill(dxyFromMyVertex);
903  h_probedxyRefitV_->Fill(dzFromMyVertex);
904 
905  h_probed0RefitV_->Fill(d0);
906  h_probez0RefitV_->Fill(z0);
907 
908  h_probesignIP2DRefitV_->Fill(s_ip2dpv_corr);
909  h_probed3DRefitV_->Fill(ip3d_corr);
910  h_probereszRefitV_->Fill(restrkz);
911 
912  h_probeRecoVSigZ_->Fill(dzRecoV/dzsigmaRecoV);
913  h_probeRecoVSigXY_->Fill(dxyRecoV/dxysigmaRecoV);
914  h_probeRefitVSigZ_->Fill(dzFromMyVertex/dz_err);
915  h_probeRefitVSigXY_->Fill(dxyFromMyVertex/s_ip2dpv_err);
916  h_probeRefitVSig3D_->Fill(ip3d_corr/ip3d_err);
917  h_probeRefitVLogSig3D_->Fill(log10(ip3d_corr/ip3d_err));
918  h_probeRefitVSigResZ_->Fill(pulltrkz);
919 
920  a_dxyVsPhi->Fill(trackphi,dxyFromMyVertex*cmToum);
921  a_dzVsPhi->Fill(trackphi,z0*cmToum);
922  n_dxyVsPhi->Fill(trackphi,dxyFromMyVertex/s_ip2dpv_err);
923  n_dzVsPhi->Fill(trackphi,z0/z0_error);
924 
925  a_dxyVsEta->Fill(tracketa,dxyFromMyVertex*cmToum);
926  a_dzVsEta->Fill(tracketa,z0*cmToum);
927  n_dxyVsEta->Fill(tracketa,dxyFromMyVertex/s_ip2dpv_err);
928  n_dzVsEta->Fill(tracketa,z0/z0_error);
929 
930  if( ladder_num > 0 && module_num > 0 ) {
931 
932  LogDebug("PrimaryVertexValidation")<<" ladder_num"<<ladder_num <<" module_num"<<module_num <<std::endl;
933 
934  PVValHelper::fillByIndex(h_dxy_modZ_,module_num-1,dxyFromMyVertex*cmToum);
935  PVValHelper::fillByIndex(h_dz_modZ_,module_num-1,dzFromMyVertex*cmToum);
936  PVValHelper::fillByIndex(h_norm_dxy_modZ_,module_num-1,dxyFromMyVertex/s_ip2dpv_err);
937  PVValHelper::fillByIndex(h_norm_dz_modZ_,module_num-1,dzFromMyVertex/dz_err);
938 
939  PVValHelper::fillByIndex(h_dxy_ladder_,ladder_num-1,dxyFromMyVertex*cmToum);
940 
941  LogDebug("PrimaryVertexValidation")<<"h_dxy_ladder size:" <<h_dxy_ladder_.size() << std::endl;
942 
943  if(L1BPixHitCount==1){
944  PVValHelper::fillByIndex(h_dxy_ladderNoOverlap_,ladder_num-1,dxyFromMyVertex*cmToum);
945  } else {
946  PVValHelper::fillByIndex(h_dxy_ladderOverlap_,ladder_num-1,dxyFromMyVertex*cmToum);
947  }
948 
949  PVValHelper::fillByIndex(h_dz_ladder_,ladder_num-1,dzFromMyVertex*cmToum);
950  PVValHelper::fillByIndex(h_norm_dxy_ladder_,ladder_num-1,dxyFromMyVertex/s_ip2dpv_err);
951  PVValHelper::fillByIndex(h_norm_dz_ladder_,ladder_num-1,dzFromMyVertex/dz_err);
952 
953  }
954 
955  // filling the binned distributions
956  for(int i=0; i<nBins_; i++){
957 
958  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
959  float phiL = theDetails_.trendbins[PVValHelper::phi][i+1];
960 
961  float etaF = theDetails_.trendbins[PVValHelper::eta][i];
962  float etaL = theDetails_.trendbins[PVValHelper::eta][i+1];
963 
964  if(tracketa >= etaF && tracketa < etaL ){
965 
966  PVValHelper::fillByIndex(a_dxyEtaResiduals,i,dxyFromMyVertex*cmToum,"1");
967  PVValHelper::fillByIndex(a_dxEtaResiduals,i,my_dx*cmToum,"2");
968  PVValHelper::fillByIndex(a_dyEtaResiduals,i,my_dy*cmToum,"3");
969  PVValHelper::fillByIndex(a_dzEtaResiduals,i,dzFromMyVertex*cmToum,"4");
970  PVValHelper::fillByIndex(n_dxyEtaResiduals,i,dxyFromMyVertex/s_ip2dpv_err,"5");
971  PVValHelper::fillByIndex(n_dzEtaResiduals,i,dzFromMyVertex/dz_err,"6");
972  PVValHelper::fillByIndex(a_IP2DEtaResiduals,i,s_ip2dpv_corr*cmToum,"7");
973  PVValHelper::fillByIndex(n_IP2DEtaResiduals,i,s_ip2dpv_corr/s_ip2dpv_err,"8");
974  PVValHelper::fillByIndex(a_reszEtaResiduals,i,restrkz*cmToum,"9");
976  PVValHelper::fillByIndex(a_d3DEtaResiduals,i,ip3d_corr*cmToum,"11");
977  PVValHelper::fillByIndex(n_d3DEtaResiduals,i,ip3d_corr/ip3d_err,"12");
978  PVValHelper::fillByIndex(a_IP3DEtaResiduals,i,s_ip3dpv_corr*cmToum,"13");
979  PVValHelper::fillByIndex(n_IP3DEtaResiduals,i,s_ip3dpv_corr/s_ip3dpv_err,"14");
980 
981  }
982 
983  if(trackphi >= phiF && trackphi < phiL ){
984 
985  PVValHelper::fillByIndex(a_dxyPhiResiduals,i,dxyFromMyVertex*cmToum,"15");
986  PVValHelper::fillByIndex(a_dxPhiResiduals,i,my_dx*cmToum,"16");
987  PVValHelper::fillByIndex(a_dyPhiResiduals,i,my_dy*cmToum,"17");
988  PVValHelper::fillByIndex(a_dzPhiResiduals,i,dzFromMyVertex*cmToum,"18");
989  PVValHelper::fillByIndex(n_dxyPhiResiduals,i,dxyFromMyVertex/s_ip2dpv_err,"19");
990  PVValHelper::fillByIndex(n_dzPhiResiduals,i,dzFromMyVertex/dz_err,"20");
991  PVValHelper::fillByIndex(a_IP2DPhiResiduals,i,s_ip2dpv_corr*cmToum,"21");
992  PVValHelper::fillByIndex(n_IP2DPhiResiduals,i,s_ip2dpv_corr/s_ip2dpv_err,"22");
993  PVValHelper::fillByIndex(a_reszPhiResiduals,i,restrkz*cmToum,"23");
995  PVValHelper::fillByIndex(a_d3DPhiResiduals,i,ip3d_corr*cmToum,"25");
996  PVValHelper::fillByIndex(n_d3DPhiResiduals,i,ip3d_corr/ip3d_err,"26");
997  PVValHelper::fillByIndex(a_IP3DPhiResiduals,i,s_ip3dpv_corr*cmToum,"27");
998  PVValHelper::fillByIndex(n_IP3DPhiResiduals,i,s_ip3dpv_corr/s_ip3dpv_err,"28");
999 
1000  for(int j=0; j<nBins_; j++){
1001 
1002  float etaJ = theDetails_.trendbins[PVValHelper::eta][j];
1003  float etaK = theDetails_.trendbins[PVValHelper::eta][j+1];
1004 
1005  if(tracketa >= etaJ && tracketa < etaK ){
1006  a_dxyResidualsMap[i][j]->Fill(dxyFromMyVertex*cmToum);
1007  a_dzResidualsMap[i][j]->Fill(dzFromMyVertex*cmToum);
1008  n_dxyResidualsMap[i][j]->Fill(dxyFromMyVertex/s_ip2dpv_err);
1009  n_dzResidualsMap[i][j]->Fill(dzFromMyVertex/dz_err);
1010  a_d3DResidualsMap[i][j]->Fill(ip3d_corr*cmToum);
1011  n_d3DResidualsMap[i][j]->Fill(ip3d_corr/ip3d_err);
1012 
1013  }
1014  }
1015  }
1016  }
1017  }
1018 
1019  if(debug_){
1020  edm::LogInfo("PrimaryVertexValidation")<<" myVertex.x()= "<<myVertex.x()<<"\n"
1021  <<" myVertex.y()= "<<myVertex.y()<<" \n"
1022  <<" myVertex.z()= "<<myVertex.z()<<" \n"
1023  <<" theTrack.dz(myVertex)= "<<theTrack.dz(myVertex)<<" \n"
1024  <<" zPCA -myVertex.z() = "<<(theTrack.vertex().z() -myVertex.z());
1025 
1026  }// ends if debug_
1027  } // ends if the fitted vertex is Valid
1028 
1029  //delete theFitter;
1030 
1031  } catch ( cms::Exception& er ) {
1032  LogTrace("PrimaryVertexValidation")<<"caught std::exception "<<er.what()<<std::endl;
1033  }
1034 
1035  } //ends if theFinalTracks.size() > 2
1036 
1037  else {
1038  if(debug_)
1039  edm::LogInfo("PrimaryVertexValidation")<<"Not enough tracks to make a vertex. Returns no vertex info";
1040  }
1041 
1042  ++nTracks_;
1043  ++nTracksPerClus_;
1044 
1045  if(debug_)
1046  edm::LogInfo("PrimaryVertexValidation")<<"Track "<<i<<" : pT = "<<theTrack.pt();
1047 
1048  }// for loop on tracks
1049  } // for loop on track clusters
1050 
1051  // Fill the TTree if needed
1052 
1053  if(storeNtuple_){
1054  rootTree_->Fill();
1055  }
1056 
1057 
1058 }
1059 
1060 // ------------ method called to discriminate 1D from 2D hits ------------
1062 {
1063  if (hit.dimension() < 2) {
1064  return false; // some (muon...) stuff really has RecHit1D
1065  } else {
1066  const DetId detId(hit.geographicalId());
1067  if (detId.det() == DetId::Tracker) {
1068  if (detId.subdetId() == PixelSubdetector::PixelBarrel || detId.subdetId() == PixelSubdetector::PixelEndcap) {
1069  return true; // pixel is always 2D
1070  } else { // should be SiStrip now
1071  if (dynamic_cast<const SiStripRecHit2D*>(&hit)) return false; // normal hit
1072  else if (dynamic_cast<const SiStripMatchedRecHit2D*>(&hit)) return true; // matched is 2D
1073  else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(&hit)) return false; // crazy hit...
1074  else {
1075  edm::LogError("UnkownType") << "@SUB=AlignmentTrackSelector::isHit2D"
1076  << "Tracker hit not in pixel and neither SiStripRecHit2D nor "
1077  << "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
1078  return false;
1079  }
1080  }
1081  } else { // not tracker??
1082  edm::LogWarning("DetectorMismatch") << "@SUB=AlignmentTrackSelector::isHit2D"
1083  << "Hit not in tracker with 'official' dimension >=2.";
1084  return true; // dimension() >= 2 so accept that...
1085  }
1086  }
1087  // never reached...
1088 }
1089 
1090 
1091 // ------------ method to check the presence of pixel hits ------------
1093 
1094  bool hasBPixHits = false;
1095  bool hasFPixHits = false;
1096 
1097  const reco::HitPattern& p = track.hitPattern();
1098  if(p.numberOfValidPixelEndcapHits()!=0){
1099  hasFPixHits = true;
1100  }
1101  if(p.numberOfValidPixelBarrelHits()!=0){
1102  hasBPixHits = true;
1103  }
1104 
1105  return std::make_pair(hasBPixHits,hasFPixHits);
1106 }
1107 
1108 
1109 // ------------ method to check the presence of pixel hits ------------
1111 {
1112  using namespace reco;
1113  const HitPattern& p = track.hitPattern();
1114  for (int i=0; i<p.numberOfHits(HitPattern::TRACK_HITS); i++) {
1115  uint32_t pattern = p.getHitPattern(HitPattern::TRACK_HITS, i);
1116  if (p.pixelBarrelHitFilter(pattern) || p.pixelEndcapHitFilter(pattern) ) {
1117  if (p.getLayer(pattern) == 1) {
1118  if (p.validHitFilter(pattern)) {
1119  return true;
1120  }
1121  }
1122  }
1123  }
1124  return false;
1125 }
1126 
1127 // ------------ method called once each job before begining the event loop ------------
1129 {
1130  edm::LogInfo("PrimaryVertexValidation")
1131  <<"######################################\n"
1132  <<"Begin Job \n"
1133  <<"######################################";
1134 
1135  // Define TTree for output
1136  Nevt_ = 0;
1137 
1138  // rootFile_ = new TFile(filename_.c_str(),"recreate");
1139  rootTree_ = fs->make<TTree>("tree","PV Validation tree");
1140 
1141  // Track Paramters
1142 
1143  if(lightNtupleSwitch_){
1144 
1145  rootTree_->Branch("EventNumber",&EventNumber_,"EventNumber/i");
1146  rootTree_->Branch("RunNumber",&RunNumber_,"RunNumber/i");
1147  rootTree_->Branch("LuminosityBlockNumber",&LuminosityBlockNumber_,"LuminosityBlockNumber/i");
1148  rootTree_->Branch("nOfflineVertices",&nOfflineVertices_,"nOfflineVertices/I");
1149  rootTree_->Branch("nTracks",&nTracks_,"nTracks/I");
1150  rootTree_->Branch("phi",&phi_,"phi[nTracks]/D");
1151  rootTree_->Branch("eta",&eta_,"eta[nTracks]/D");
1152  rootTree_->Branch("pt",&pt_,"pt[nTracks]/D");
1153  rootTree_->Branch("dxyFromMyVertex",&dxyFromMyVertex_,"dxyFromMyVertex[nTracks]/D");
1154  rootTree_->Branch("dzFromMyVertex",&dzFromMyVertex_,"dzFromMyVertex[nTracks]/D");
1155  rootTree_->Branch("d3DFromMyVertex",&d3DFromMyVertex_,"d3DFromMyVertex[nTracks]/D");
1156  rootTree_->Branch("IPTsigFromMyVertex",&IPTsigFromMyVertex_,"IPTsigFromMyVertex_[nTracks]/D");
1157  rootTree_->Branch("IPLsigFromMyVertex",&IPLsigFromMyVertex_,"IPLsigFromMyVertex_[nTracks]/D");
1158  rootTree_->Branch("IP3DsigFromMyVertex",&IP3DsigFromMyVertex_,"IP3DsigFromMyVertex_[nTracks]/D");
1159  rootTree_->Branch("hasRecVertex",&hasRecVertex_,"hasRecVertex[nTracks]/I");
1160  rootTree_->Branch("isGoodTrack",&isGoodTrack_,"isGoodTrack[nTracks]/I");
1161  rootTree_->Branch("isHighPurity",&isHighPurity_,"isHighPurity_[nTracks]/I");
1162 
1163  } else {
1164 
1165  rootTree_->Branch("nTracks",&nTracks_,"nTracks/I");
1166  rootTree_->Branch("nTracksPerClus",&nTracksPerClus_,"nTracksPerClus/I");
1167  rootTree_->Branch("nClus",&nClus_,"nClus/I");
1168  rootTree_->Branch("xOfflineVertex",&xOfflineVertex_,"xOfflineVertex/D");
1169  rootTree_->Branch("yOfflineVertex",&yOfflineVertex_,"yOfflineVertex/D");
1170  rootTree_->Branch("zOfflineVertex",&zOfflineVertex_,"zOfflineVertex/D");
1171  rootTree_->Branch("BSx0",&BSx0_,"BSx0/D");
1172  rootTree_->Branch("BSy0",&BSy0_,"BSy0/D");
1173  rootTree_->Branch("BSz0",&BSz0_,"BSz0/D");
1174  rootTree_->Branch("Beamsigmaz",&Beamsigmaz_,"Beamsigmaz/D");
1175  rootTree_->Branch("Beamdxdz",&Beamdxdz_,"Beamdxdz/D");
1176  rootTree_->Branch("BeamWidthX",&BeamWidthX_,"BeamWidthX/D");
1177  rootTree_->Branch("BeamWidthY",&BeamWidthY_,"BeamWidthY/D");
1178  rootTree_->Branch("pt",&pt_,"pt[nTracks]/D");
1179  rootTree_->Branch("p",&p_,"p[nTracks]/D");
1180  rootTree_->Branch("nhits",&nhits_,"nhits[nTracks]/I");
1181  rootTree_->Branch("nhits1D",&nhits1D_,"nhits1D[nTracks]/I");
1182  rootTree_->Branch("nhits2D",&nhits2D_,"nhits2D[nTracks]/I");
1183  rootTree_->Branch("nhitsBPIX",&nhitsBPIX_,"nhitsBPIX[nTracks]/I");
1184  rootTree_->Branch("nhitsFPIX",&nhitsFPIX_,"nhitsFPIX[nTracks]/I");
1185  rootTree_->Branch("nhitsTIB",&nhitsTIB_,"nhitsTIB[nTracks]/I");
1186  rootTree_->Branch("nhitsTID",&nhitsTID_,"nhitsTID[nTracks]/I");
1187  rootTree_->Branch("nhitsTOB",&nhitsTOB_,"nhitsTOB[nTracks]/I");
1188  rootTree_->Branch("nhitsTEC",&nhitsTEC_,"nhitsTEC[nTracks]/I");
1189  rootTree_->Branch("eta",&eta_,"eta[nTracks]/D");
1190  rootTree_->Branch("theta",&theta_,"theta[nTracks]/D");
1191  rootTree_->Branch("phi",&phi_,"phi[nTracks]/D");
1192  rootTree_->Branch("chi2",&chi2_,"chi2[nTracks]/D");
1193  rootTree_->Branch("chi2ndof",&chi2ndof_,"chi2ndof[nTracks]/D");
1194  rootTree_->Branch("charge",&charge_,"charge[nTracks]/I");
1195  rootTree_->Branch("qoverp",&qoverp_,"qoverp[nTracks]/D");
1196  rootTree_->Branch("dz",&dz_,"dz[nTracks]/D");
1197  rootTree_->Branch("dxy",&dxy_,"dxy[nTracks]/D");
1198  rootTree_->Branch("dzBs",&dzBs_,"dzBs[nTracks]/D");
1199  rootTree_->Branch("dxyBs",&dxyBs_,"dxyBs[nTracks]/D");
1200  rootTree_->Branch("xPCA",&xPCA_,"xPCA[nTracks]/D");
1201  rootTree_->Branch("yPCA",&yPCA_,"yPCA[nTracks]/D");
1202  rootTree_->Branch("zPCA",&zPCA_,"zPCA[nTracks]/D");
1203  rootTree_->Branch("xUnbiasedVertex",&xUnbiasedVertex_,"xUnbiasedVertex[nTracks]/D");
1204  rootTree_->Branch("yUnbiasedVertex",&yUnbiasedVertex_,"yUnbiasedVertex[nTracks]/D");
1205  rootTree_->Branch("zUnbiasedVertex",&zUnbiasedVertex_,"zUnbiasedVertex[nTracks]/D");
1206  rootTree_->Branch("chi2normUnbiasedVertex",&chi2normUnbiasedVertex_,"chi2normUnbiasedVertex[nTracks]/F");
1207  rootTree_->Branch("chi2UnbiasedVertex",&chi2UnbiasedVertex_,"chi2UnbiasedVertex[nTracks]/F");
1208  rootTree_->Branch("DOFUnbiasedVertex",&DOFUnbiasedVertex_," DOFUnbiasedVertex[nTracks]/F");
1209  rootTree_->Branch("chi2ProbUnbiasedVertex",&chi2ProbUnbiasedVertex_,"chi2ProbUnbiasedVertex[nTracks]/F");
1210  rootTree_->Branch("sumOfWeightsUnbiasedVertex",&sumOfWeightsUnbiasedVertex_,"sumOfWeightsUnbiasedVertex[nTracks]/F");
1211  rootTree_->Branch("tracksUsedForVertexing",&tracksUsedForVertexing_,"tracksUsedForVertexing[nTracks]/I");
1212  rootTree_->Branch("dxyFromMyVertex",&dxyFromMyVertex_,"dxyFromMyVertex[nTracks]/D");
1213  rootTree_->Branch("dzFromMyVertex",&dzFromMyVertex_,"dzFromMyVertex[nTracks]/D");
1214  rootTree_->Branch("dxyErrorFromMyVertex",&dxyErrorFromMyVertex_,"dxyErrorFromMyVertex_[nTracks]/D");
1215  rootTree_->Branch("dzErrorFromMyVertex",&dzErrorFromMyVertex_,"dzErrorFromMyVertex_[nTracks]/D");
1216  rootTree_->Branch("IPTsigFromMyVertex",&IPTsigFromMyVertex_,"IPTsigFromMyVertex_[nTracks]/D");
1217  rootTree_->Branch("IPLsigFromMyVertex",&IPLsigFromMyVertex_,"IPLsigFromMyVertex_[nTracks]/D");
1218  rootTree_->Branch("hasRecVertex",&hasRecVertex_,"hasRecVertex[nTracks]/I");
1219  rootTree_->Branch("isGoodTrack",&isGoodTrack_,"isGoodTrack[nTracks]/I");
1220  }
1221 
1222  // event histograms
1223  TFileDirectory EventFeatures = fs->mkdir("EventFeatures");
1224 
1225  TH1F::SetDefaultSumw2(kTRUE);
1226 
1227  h_lumiFromConfig = EventFeatures.make<TH1F>("h_lumiFromConfig","luminosity from config;;luminosity of present run",1,-0.5,0.5);
1228  h_lumiFromConfig->SetBinContent(1,intLumi_);
1229 
1230  h_runFromConfig = EventFeatures.make<TH1I>("h_runFromConfig","run number from config;;run number (from configuration)",
1231  runControlNumbers_.size(),0.,runControlNumbers_.size());
1232  for(const auto & r : runControlNumbers_){
1233  h_runFromConfig->SetBinContent(r+1,runControlNumbers_[r]);
1234  }
1235 
1236  h_runFromEvent = EventFeatures.make<TH1I>("h_runFromEvent","run number from config;;run number (from event)",1,-0.5,0.5);
1237 
1238  h_nTracks = EventFeatures.make<TH1F>("h_nTracks","number of tracks per event;n_{tracks}/event;n_{events}",300,-0.5,299.5);
1239  h_nClus = EventFeatures.make<TH1F>("h_nClus","number of track clusters;n_{clusters}/event;n_{events}",50,-0.5,49.5);
1240  h_nOfflineVertices = EventFeatures.make<TH1F>("h_nOfflineVertices","number of offline reconstructed vertices;n_{vertices}/event;n_{events}",50,-0.5,49.5);
1241  h_runNumber = EventFeatures.make<TH1F>("h_runNumber","run number;run number;n_{events}",100000,250000.,350000.);
1242  h_xOfflineVertex = EventFeatures.make<TH1F>("h_xOfflineVertex","x-coordinate of offline vertex;x_{vertex};n_{events}",100,-0.1,0.1);
1243  h_yOfflineVertex = EventFeatures.make<TH1F>("h_yOfflineVertex","y-coordinate of offline vertex;y_{vertex};n_{events}",100,-0.1,0.1);
1244  h_zOfflineVertex = EventFeatures.make<TH1F>("h_zOfflineVertex","z-coordinate of offline vertex;z_{vertex};n_{events}",100,-30.,30.);
1245  h_xErrOfflineVertex = EventFeatures.make<TH1F>("h_xErrOfflineVertex","x-coordinate error of offline vertex;err_{x}^{vtx};n_{events}",100,0.,0.01);
1246  h_yErrOfflineVertex = EventFeatures.make<TH1F>("h_yErrOfflineVertex","y-coordinate error of offline vertex;err_{y}^{vtx};n_{events}",100,0.,0.01);
1247  h_zErrOfflineVertex = EventFeatures.make<TH1F>("h_zErrOfflineVertex","z-coordinate error of offline vertex;err_{z}^{vtx};n_{events}",100,0.,10.);
1248  h_BSx0 = EventFeatures.make<TH1F>("h_BSx0","x-coordinate of reco beamspot;x^{BS}_{0};n_{events}",100,-0.1,0.1);
1249  h_BSy0 = EventFeatures.make<TH1F>("h_BSy0","y-coordinate of reco beamspot;y^{BS}_{0};n_{events}",100,-0.1,0.1);
1250  h_BSz0 = EventFeatures.make<TH1F>("h_BSz0","z-coordinate of reco beamspot;z^{BS}_{0};n_{events}",100,-1.,1.);
1251  h_Beamsigmaz = EventFeatures.make<TH1F>("h_Beamsigmaz","z-coordinate beam width;#sigma_{Z}^{beam};n_{events}",100,0.,1.);
1252  h_BeamWidthX = EventFeatures.make<TH1F>("h_BeamWidthX","x-coordinate beam width;#sigma_{X}^{beam};n_{events}",100,0.,0.01);
1253  h_BeamWidthY = EventFeatures.make<TH1F>("h_BeamWidthY","y-coordinate beam width;#sigma_{Y}^{beam};n_{events}",100,0.,0.01);
1254 
1255  h_etaMax = EventFeatures.make<TH1F>("etaMax","etaMax",1,-0.5,0.5);
1256  h_nbins = EventFeatures.make<TH1F>("nbins","nbins",1,-0.5,0.5);
1257  h_nLadders = EventFeatures.make<TH1F>("nladders","n. ladders",1,-0.5,0.5);
1258 
1259  // probe track histograms
1260  TFileDirectory ProbeFeatures = fs->mkdir("ProbeTrackFeatures");
1261 
1262  h_probePt_ = ProbeFeatures.make<TH1F>("h_probePt","p_{T} of probe track;track p_{T} (GeV); tracks",100,0.,50.);
1263  h_probeP_ = ProbeFeatures.make<TH1F>("h_probeP","momentum of probe track;track p (GeV); tracks",100,0.,100.);
1264  h_probeEta_ = ProbeFeatures.make<TH1F>("h_probeEta","#eta of the probe track;track #eta;tracks",54,-2.8,2.8);
1265  h_probePhi_ = ProbeFeatures.make<TH1F>("h_probePhi","#phi of probe track;track #phi (rad);tracks",100,-3.15,3.15);
1266 
1267  h2_probeEtaPhi_ = ProbeFeatures.make<TH2F>("h2_probeEtaPhi","probe track #phi vs #eta;#eta of probe track;track #phi of probe track (rad); tracks",54,-2.8,2.8,100,-3.15,3.15);
1268  h2_probeEtaPt_ = ProbeFeatures.make<TH2F>("h2_probeEtaPt","probe track p_{T} vs #eta;#eta of probe track;track p_{T} (GeV); tracks",54,-2.8,2.8,100,0.,50.);
1269 
1270  h_probeChi2_ = ProbeFeatures.make<TH1F>("h_probeChi2","#chi^{2} of probe track;track #chi^{2}; tracks",100,0.,100.);
1271  h_probeNormChi2_ = ProbeFeatures.make<TH1F>("h_probeNormChi2"," normalized #chi^{2} of probe track;track #chi^{2}/ndof; tracks",100,0.,10.);
1272  h_probeCharge_ = ProbeFeatures.make<TH1F>("h_probeCharge","charge of profe track;track charge Q;tracks",3,-1.5,1.5);
1273  h_probeQoverP_ = ProbeFeatures.make<TH1F>("h_probeQoverP","q/p of probe track; track Q/p (GeV^{-1});tracks",200,-1.,1.);
1274  h_probedzRecoV_ = ProbeFeatures.make<TH1F>("h_probedzRecoV","d_{z}(V_{offline}) of probe track;track d_{z}(V_{off}) (cm);tracks",200,-1.,1.);
1275  h_probedxyRecoV_ = ProbeFeatures.make<TH1F>("h_probedxyRecoV","d_{xy}(V_{offline}) of probe track;track d_{xy}(V_{off}) (cm);tracks",200,-1.,1.);
1276  h_probedzRefitV_ = ProbeFeatures.make<TH1F>("h_probedzRefitV","d_{z}(V_{refit}) of probe track;track d_{z}(V_{fit}) (cm);tracks",200,-0.5,0.5);
1277  h_probesignIP2DRefitV_ = ProbeFeatures.make<TH1F>("h_probesignIPRefitV","ip_{2D}(V_{refit}) of probe track;track ip_{2D}(V_{fit}) (cm);tracks",200,-1.,1.);
1278  h_probedxyRefitV_ = ProbeFeatures.make<TH1F>("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>("h_probez0RefitV","z_{0}(V_{refit}) of probe track;track z_{0}(V_{fit}) (cm);tracks",200,-1.,1.);
1281  h_probed0RefitV_ = ProbeFeatures.make<TH1F>("h_probed0RefitV","d_{0}(V_{refit}) of probe track;track d_{0}(V_{fit}) (cm);tracks",200,-1.,1.);
1282 
1283  h_probed3DRefitV_ = ProbeFeatures.make<TH1F>("h_probed3DRefitV","d_{3D}(V_{refit}) of probe track;track d_{3D}(V_{fit}) (cm);tracks",200,0.,1.);
1284  h_probereszRefitV_ = ProbeFeatures.make<TH1F>("h_probeReszRefitV","z_{track} -z_{V_{refit}};track res_{z}(V_{refit}) (cm);tracks",200,-1.,1.);
1285 
1286  h_probeRecoVSigZ_ = ProbeFeatures.make<TH1F>("h_probeRecoVSigZ" ,"Longitudinal DCA Significance (reco);d_{z}(V_{off})/#sigma_{dz};tracks",100,-8,8);
1287  h_probeRecoVSigXY_ = ProbeFeatures.make<TH1F>("h_probeRecoVSigXY" ,"Transverse DCA Significance (reco);d_{xy}(V_{off})/#sigma_{dxy};tracks",100,-8,8);
1288  h_probeRefitVSigZ_ = ProbeFeatures.make<TH1F>("h_probeRefitVSigZ" ,"Longitudinal DCA Significance (refit);d_{z}(V_{fit})/#sigma_{dz};tracks",100,-8,8);
1289  h_probeRefitVSigXY_= ProbeFeatures.make<TH1F>("h_probeRefitVSigXY","Transverse DCA Significance (refit);d_{xy}(V_{fit})/#sigma_{dxy};tracks",100,-8,8);
1290  h_probeRefitVSig3D_= ProbeFeatures.make<TH1F>("h_probeRefitVSig3D","3D DCA Significance (refit);d_{3D}/#sigma_{3D};tracks",100,0.,20.);
1291  h_probeRefitVLogSig3D_ = ProbeFeatures.make<TH1F>("h_probeRefitVLogSig3D","log_{10}(3D DCA-Significance) (refit);log_{10}(d_{3D}/#sigma_{3D});tracks",100,-5.,4.);
1292  h_probeRefitVSigResZ_ = ProbeFeatures.make<TH1F>("h_probeRefitVSigResZ" ,"Longitudinal residual significance (refit);(z_{track} -z_{V_{fit}})/#sigma_{res_{z}};tracks",100,-8,8);
1293 
1294  h_probeHits_ = ProbeFeatures.make<TH1F>("h_probeNRechits" ,"N_{hits} ;N_{hits} ;tracks",40,-0.5,39.5);
1295  h_probeHits1D_ = ProbeFeatures.make<TH1F>("h_probeNRechits1D" ,"N_{hits} 1D ;N_{hits} 1D ;tracks",40,-0.5,39.5);
1296  h_probeHits2D_ = ProbeFeatures.make<TH1F>("h_probeNRechits2D" ,"N_{hits} 2D ;N_{hits} 2D ;tracks",40,-0.5,39.5);
1297  h_probeHitsInTIB_ = ProbeFeatures.make<TH1F>("h_probeNRechitsTIB" ,"N_{hits} TIB ;N_{hits} TIB;tracks",40,-0.5,39.5);
1298  h_probeHitsInTOB_ = ProbeFeatures.make<TH1F>("h_probeNRechitsTOB" ,"N_{hits} TOB ;N_{hits} TOB;tracks",40,-0.5,39.5);
1299  h_probeHitsInTID_ = ProbeFeatures.make<TH1F>("h_probeNRechitsTID" ,"N_{hits} TID ;N_{hits} TID;tracks",40,-0.5,39.5);
1300  h_probeHitsInTEC_ = ProbeFeatures.make<TH1F>("h_probeNRechitsTEC" ,"N_{hits} TEC ;N_{hits} TEC;tracks",40,-0.5,39.5);
1301  h_probeHitsInBPIX_ = ProbeFeatures.make<TH1F>("h_probeNRechitsBPIX","N_{hits} BPIX;N_{hits} BPIX;tracks",40,-0.5,39.5);
1302  h_probeHitsInFPIX_ = ProbeFeatures.make<TH1F>("h_probeNRechitsFPIX","N_{hits} FPIX;N_{hits} FPIX;tracks",40,-0.5,39.5);
1303 
1304  h_probeL1Ladder_ = ProbeFeatures.make<TH1F>("h_probeL1Ladder","Ladder number (L1 hit); ladder number",22,-1.5,20.5);
1305  h_probeL1Module_ = ProbeFeatures.make<TH1F>("h_probeL1Module","Module number (L1 hit); module number",10,-1.5,8.5);
1306  h_probeHasBPixL1Overlap_ = ProbeFeatures.make<TH1I>("h_probeHasBPixL1Overlap","n. hits in L1;n. L1-BPix hits;tracks",5,0,5);
1307 
1308  // refit vertex features
1309  TFileDirectory RefitVertexFeatures = fs->mkdir("RefitVertexFeatures");
1310  h_fitVtxNtracks_ = RefitVertexFeatures.make<TH1F>("h_fitVtxNtracks" ,"N_{trks} used in vertex fit;N^{fit}_{tracks};vertices" ,100,-0.5,99.5);
1311  h_fitVtxNdof_ = RefitVertexFeatures.make<TH1F>("h_fitVtxNdof" ,"N_{DOF} of vertex fit;N_{DOF} of refit vertex;vertices" ,100,-0.5,99.5);
1312  h_fitVtxChi2_ = RefitVertexFeatures.make<TH1F>("h_fitVtxChi2" ,"#chi^{2} of vertex fit;vertex #chi^{2};vertices" ,100,-0.5,99.5);
1313  h_fitVtxChi2ndf_ = RefitVertexFeatures.make<TH1F>("h_fitVtxChi2ndf" ,"#chi^{2}/ndf of vertex fit;vertex #chi^{2}/ndf;vertices" ,100,-0.5,9.5);
1314  h_fitVtxChi2Prob_ = RefitVertexFeatures.make<TH1F>("h_fitVtxChi2Prob" ,"Prob(#chi^{2},ndf) of vertex fit;Prob(#chi^{2},ndf);vertices",40,0.,1.);
1315  h_fitVtxTrackWeights_ = RefitVertexFeatures.make<TH1F>("h_fitVtxTrackWeights","track weights associated to track;track weights;tracks",40,0.,1.);
1316  h_fitVtxTrackAverageWeight_ = RefitVertexFeatures.make<TH1F>("h_fitVtxTrackAverageWeight_","average track weight per vertex;#LT track weight #GT;vertices",40,0.,1.);
1317 
1318  if(useTracksFromRecoVtx_) {
1319 
1320  TFileDirectory RecoVertexFeatures = fs->mkdir("RecoVertexFeatures");
1321  h_recoVtxNtracks_ = RecoVertexFeatures.make<TH1F>("h_recoVtxNtracks" ,"N^{vtx}_{trks};N^{vtx}_{trks};vertices" ,100,-0.5,99.5);
1322  h_recoVtxChi2ndf_ = RecoVertexFeatures.make<TH1F>("h_recoVtxChi2ndf" ,"#chi^{2}/ndf vtx;#chi^{2}/ndf vtx;vertices" ,10,-0.5,9.5);
1323  h_recoVtxChi2Prob_ = RecoVertexFeatures.make<TH1F>("h_recoVtxChi2Prob" ,"Prob(#chi^{2},ndf);Prob(#chi^{2},ndf);vertices",40,0.,1.);
1324  h_recoVtxSumPt_ = RecoVertexFeatures.make<TH1F>("h_recoVtxSumPt" ,"Sum(p^{trks}_{T});Sum(p^{trks}_{T});vertices" ,100,0.,200.);
1325 
1326  }
1327 
1328 
1329  TFileDirectory DA = fs->mkdir("DA");
1330  //DA.cd();
1332  //for(std::map<std::string,TH1*>::const_iterator hist=hDA.begin(); hist!=hDA.end(); hist++){
1333  //hist->second->SetDirectory(DA);
1334  // DA.make<TH1F>(hist->second);
1335  // }
1336 
1337  // initialize the residuals histograms
1338 
1339  const float dxymax_phi = theDetails_.getHigh(PVValHelper::dxy,PVValHelper::phi);
1340  const float dzmax_phi = theDetails_.getHigh(PVValHelper::dz ,PVValHelper::eta);
1341  const float dxymax_eta = theDetails_.getHigh(PVValHelper::dxy,PVValHelper::phi);
1342  const float dzmax_eta = theDetails_.getHigh(PVValHelper::dz, PVValHelper::eta);
1343  //const float d3Dmax_phi = theDetails_.getHigh(PVValHelper::d3D,PVValHelper::phi);
1344  const float d3Dmax_eta = theDetails_.getHigh(PVValHelper::d3D,PVValHelper::eta);
1345 
1347  //
1348  // Unbiased track-to-vertex residuals
1349  // The vertex is refit without the probe track
1350  //
1352 
1353  // _ _ _ _ ___ _ _ _
1354  // /_\ | |__ ___ ___| |_ _| |_ ___ | _ \___ __(_)__| |_ _ __ _| |___
1355  // / _ \| '_ (_-</ _ \ | || | _/ -_) | / -_|_-< / _` | || / _` | (_-<
1356  // /_/ \_\_.__/__/\___/_|\_,_|\__\___| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1357  //
1358 
1359  TFileDirectory AbsTransPhiRes = fs->mkdir("Abs_Transv_Phi_Residuals");
1364 
1365  TFileDirectory AbsTransEtaRes = fs->mkdir("Abs_Transv_Eta_Residuals");
1370 
1371  TFileDirectory AbsLongPhiRes = fs->mkdir("Abs_Long_Phi_Residuals");
1374 
1375  TFileDirectory AbsLongEtaRes = fs->mkdir("Abs_Long_Eta_Residuals");
1378 
1379  TFileDirectory Abs3DPhiRes = fs->mkdir("Abs_3D_Phi_Residuals");
1382 
1383  TFileDirectory Abs3DEtaRes = fs->mkdir("Abs_3D_Eta_Residuals");
1386 
1387  TFileDirectory NormTransPhiRes = fs->mkdir("Norm_Transv_Phi_Residuals");
1390 
1391  TFileDirectory NormTransEtaRes = fs->mkdir("Norm_Transv_Eta_Residuals");
1394 
1395  TFileDirectory NormLongPhiRes = fs->mkdir("Norm_Long_Phi_Residuals");
1398 
1399  TFileDirectory NormLongEtaRes = fs->mkdir("Norm_Long_Eta_Residuals");
1402 
1403  TFileDirectory Norm3DPhiRes = fs->mkdir("Norm_3D_Phi_Residuals");
1406 
1407  TFileDirectory Norm3DEtaRes = fs->mkdir("Norm_3D_Eta_Residuals");
1410 
1411  TFileDirectory AbsDoubleDiffRes = fs->mkdir("Abs_DoubleDiffResiduals");
1412  TFileDirectory NormDoubleDiffRes = fs->mkdir("Norm_DoubleDiffResiduals");
1413 
1414  // book residuals vs pT histograms
1415 
1416  TFileDirectory AbsTranspTRes = fs->mkdir("Abs_Transv_pT_Residuals");
1418 
1419  TFileDirectory AbsLongpTRes = fs->mkdir("Abs_Long_pT_Residuals");
1421 
1422  TFileDirectory NormTranspTRes = fs->mkdir("Norm_Transv_pT_Residuals");
1424 
1425  TFileDirectory NormLongpTRes = fs->mkdir("Norm_Long_pT_Residuals");
1427 
1428  // book residuals vs pT histograms in central region (|eta|<1.0)
1429 
1430  TFileDirectory AbsTranspTCentralRes = fs->mkdir("Abs_Transv_pTCentral_Residuals");
1432 
1433  TFileDirectory AbsLongpTCentralRes = fs->mkdir("Abs_Long_pTCentral_Residuals");
1435 
1436  TFileDirectory NormTranspTCentralRes = fs->mkdir("Norm_Transv_pTCentral_Residuals");
1438 
1439  TFileDirectory NormLongpTCentralRes = fs->mkdir("Norm_Long_pTCentral_Residuals");
1441 
1442  // book residuals vs module number
1443 
1444  TFileDirectory AbsTransModZRes = fs->mkdir("Abs_Transv_modZ_Residuals");
1446 
1447  TFileDirectory AbsLongModZRes = fs->mkdir("Abs_Long_modZ_Residuals");
1449 
1450 
1451  // _ _ _ _ _ ___ _ _ _
1452  // | \| |___ _ _ _ __ __ _| (_)______ __| | | _ \___ __(_)__| |_ _ __ _| |___
1453  // | .` / _ \ '_| ' \/ _` | | |_ / -_) _` | | / -_|_-< / _` | || / _` | (_-<
1454  // |_|\_\___/_| |_|_|_\__,_|_|_/__\___\__,_| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1455  //
1456 
1457  TFileDirectory NormTransModZRes = fs->mkdir("Norm_Transv_modZ_Residuals");
1459 
1460  TFileDirectory NormLongModZRes = fs->mkdir("Norm_Long_modZ_Residuals");
1462 
1463  TFileDirectory AbsTransLadderRes = fs->mkdir("Abs_Transv_ladder_Residuals");
1465 
1466  TFileDirectory AbsTransLadderResOverlap = fs->mkdir("Abs_Transv_ladderOverlap_Residuals");
1468 
1469  TFileDirectory AbsTransLadderResNoOverlap = fs->mkdir("Abs_Transv_ladderNoOverlap_Residuals");
1471 
1472  TFileDirectory AbsLongLadderRes = fs->mkdir("Abs_Long_ladder_Residuals");
1474 
1475  TFileDirectory NormTransLadderRes = fs->mkdir("Norm_Transv_ladder_Residuals");
1477 
1478  TFileDirectory NormLongLadderRes = fs->mkdir("Norm_Long_ladder_Residuals");
1480 
1481 
1482  // book residuals as function of phi and eta
1483 
1484  for (int i=0; i<nBins_; ++i ) {
1485 
1486  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
1487  float phiL = theDetails_.trendbins[PVValHelper::phi][i+1];
1488 
1489  // ___ _ _ ___ _ __ __ ___ _ _ _
1490  // | \ ___ _ _| |__| |___| \(_)/ _|/ _| | _ \___ __(_)__| |_ _ __ _| |___
1491  // | |) / _ \ || | '_ \ / -_) |) | | _| _| | / -_|_-< / _` | || / _` | (_-<
1492  // |___/\___/\_,_|_.__/_\___|___/|_|_| |_| |_|_\___/__/_\__,_|\_,_\__,_|_/__/
1493 
1494  for ( int j=0; j<nBins_; ++j ) {
1495 
1496  float etaF = theDetails_.trendbins[PVValHelper::eta][j];
1497  float etaL = theDetails_.trendbins[PVValHelper::eta][j+1];
1498 
1499  a_dxyResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(Form("histo_dxy_eta_plot%i_phi_plot%i",i,j),
1500  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy};tracks",etaF,etaL,phiF,phiL),
1501  theDetails_.histobins,-dzmax_eta,dzmax_eta);
1502 
1503  a_dzResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(Form("histo_dz_eta_plot%i_phi_plot%i",i,j),
1504  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z};tracks",etaF,etaL,phiF,phiL),
1505  theDetails_.histobins,-dzmax_eta,dzmax_eta);
1506 
1507  a_d3DResidualsMap[i][j] = AbsDoubleDiffRes.make<TH1F>(Form("histo_d3D_eta_plot%i_phi_plot%i",i,j),
1508  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{3D};tracks",etaF,etaL,phiF,phiL),
1509  theDetails_.histobins,0.,d3Dmax_eta);
1510 
1511  n_dxyResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(Form("histo_norm_dxy_eta_plot%i_phi_plot%i",i,j),
1512  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy}/#sigma_{d_{xy}};tracks",etaF,etaL,phiF,phiL),
1513  theDetails_.histobins,-dzmax_eta/100,dzmax_eta/100);
1514 
1515  n_dzResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(Form("histo_norm_dz_eta_plot%i_phi_plot%i",i,j),
1516  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z}/#sigma_{d_{z}};tracks",etaF,etaL,phiF,phiL),
1517  theDetails_.histobins,-dzmax_eta/100,dzmax_eta/100);
1518 
1519  n_d3DResidualsMap[i][j] = NormDoubleDiffRes.make<TH1F>(Form("histo_norm_d3D_eta_plot%i_phi_plot%i",i,j),
1520  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{3D}/#sigma_{d_{3D}};tracks",etaF,etaL,phiF,phiL),
1521  theDetails_.histobins,0.,d3Dmax_eta);
1522 
1523  }
1524  }
1525 
1526  // declaration of the directories
1527 
1528  TFileDirectory BiasVsParameter = fs->mkdir("BiasVsParameter");
1529 
1530  a_dxyVsPhi = BiasVsParameter.make<TH2F>("h2_dxy_vs_phi","d_{xy} vs track #phi;track #phi [rad];track d_{xy}(PV) [#mum]",
1531  nBins_,-M_PI,M_PI,theDetails_.histobins,-dxymax_phi,dxymax_phi);
1532 
1533  a_dzVsPhi = BiasVsParameter.make<TH2F>("h2_dz_vs_phi","d_{z} vs track #phi;track #phi [rad];track d_{z}(PV) [#mum]",
1534  nBins_,-M_PI,M_PI,theDetails_.histobins,-dzmax_phi,dzmax_phi);
1535 
1536  n_dxyVsPhi = BiasVsParameter.make<TH2F>("h2_n_dxy_vs_phi","d_{xy}/#sigma_{d_{xy}} vs track #phi;track #phi [rad];track d_{xy}(PV)/#sigma_{d_{xy}}",
1537  nBins_,-M_PI,M_PI,theDetails_.histobins,-dxymax_phi/100.,dxymax_phi/100.);
1538 
1539  n_dzVsPhi = BiasVsParameter.make<TH2F>("h2_n_dz_vs_phi","d_{z}/#sigma_{d_{z}} vs track #phi;track #phi [rad];track d_{z}(PV)/#sigma_{d_{z}}",
1540  nBins_,-M_PI,M_PI,theDetails_.histobins,-dzmax_phi/100.,dzmax_phi/100.);
1541 
1542  a_dxyVsEta = BiasVsParameter.make<TH2F>("h2_dxy_vs_eta","d_{xy} vs track #eta;track #eta;track d_{xy}(PV) [#mum]",
1543  nBins_,-etaOfProbe_,etaOfProbe_,theDetails_.histobins,-dxymax_eta,dzmax_eta);
1544 
1545  a_dzVsEta = BiasVsParameter.make<TH2F>("h2_dz_vs_eta","d_{z} vs track #eta;track #eta;track d_{z}(PV) [#mum]",
1546  nBins_,-etaOfProbe_,etaOfProbe_,theDetails_.histobins,-dzmax_eta,dzmax_eta);
1547 
1548  n_dxyVsEta = BiasVsParameter.make<TH2F>("h2_n_dxy_vs_eta","d_{xy}/#sigma_{d_{xy}} vs track #eta;track #eta;track d_{xy}(PV)/#sigma_{d_{xy}}",
1549  nBins_,-etaOfProbe_,etaOfProbe_,theDetails_.histobins,-dxymax_eta/100.,dxymax_eta/100.);
1550 
1551  n_dzVsEta = BiasVsParameter.make<TH2F>("h2_n_dz_vs_eta","d_{z}/#sigma_{d_{z}} vs track #eta;track #eta;track d_{z}(PV)/#sigma_{d_{z}}",
1552  nBins_,-etaOfProbe_,etaOfProbe_,theDetails_.histobins,-dzmax_eta/100.,dzmax_eta/100.);
1553 
1554  MeanTrendsDir = fs->mkdir("MeanTrends");
1555  WidthTrendsDir = fs->mkdir("WidthTrends");
1556  MedianTrendsDir = fs->mkdir("MedianTrends");
1557  MADTrendsDir = fs->mkdir("MADTrends");
1558 
1559  Mean2DMapsDir = fs->mkdir("MeanMaps");
1560  Width2DMapsDir = fs->mkdir("WidthMaps");
1561 
1562  double highedge=nBins_-0.5;
1563  double lowedge=-0.5;
1564 
1565  // means and widths from the fit
1566 
1567  a_dxyPhiMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_phi",
1568  "#LT d_{xy} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy} #GT [#mum]",
1569  nBins_,lowedge,highedge);
1570 
1571  a_dxyPhiWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_phi",
1572  "#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{xy}} [#mum]",
1573  nBins_,lowedge,highedge);
1574 
1575  a_dzPhiMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_phi",
1576  "#LT d_{z} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z} #GT [#mum]",
1577  nBins_,lowedge,highedge);
1578 
1579  a_dzPhiWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_phi","#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{z}} [#mum]",
1580  nBins_,lowedge,highedge);
1581 
1582  a_dxyEtaMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_eta",
1583  "#LT d_{xy} #GT vs #eta sector;#eta (sector);#LT d_{xy} #GT [#mum]",
1584  nBins_,lowedge,highedge);
1585 
1586  a_dxyEtaWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_eta",
1587  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{xy}} [#mum]",
1588  nBins_,lowedge,highedge);
1589 
1590  a_dzEtaMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_eta",
1591  "#LT d_{z} #GT vs #eta sector;#eta (sector);#LT d_{z} #GT [#mum]"
1592  ,nBins_,lowedge,highedge);
1593 
1594  a_dzEtaWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_eta",
1595  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{z}} [#mum]",
1596  nBins_,lowedge,highedge);
1597 
1598  n_dxyPhiMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_phi",
1599  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy}/#sigma_{d_{xy}} #GT",
1600  nBins_,lowedge,highedge);
1601 
1602  n_dxyPhiWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_phi",
1603  "width(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;#varphi (sector) [degrees]; width(d_{xy}/#sigma_{d_{xy}})",
1604  nBins_,lowedge,highedge);
1605 
1606  n_dzPhiMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_phi",
1607  "#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z}/#sigma_{d_{z}} #GT",
1608  nBins_,lowedge,highedge);
1609 
1610  n_dzPhiWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_phi",
1611  "width(d_{z}/#sigma_{d_{z}}) vs #phi sector;#varphi (sector) [degrees];width(d_{z}/#sigma_{d_{z}})",
1612  nBins_,lowedge,highedge);
1613 
1614  n_dxyEtaMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_eta",
1615  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;#eta (sector);#LT d_{xy}/#sigma_{d_{z}} #GT",
1616  nBins_,lowedge,highedge);
1617 
1618  n_dxyEtaWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_eta",
1619  "width(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;#eta (sector);width(d_{xy}/#sigma_{d_{z}})",
1620  nBins_,lowedge,highedge);
1621 
1622  n_dzEtaMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_eta",
1623  "#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;#eta (sector);#LT d_{z}/#sigma_{d_{z}} #GT",
1624  nBins_,lowedge,highedge);
1625 
1626  n_dzEtaWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_eta",
1627  "width(d_{z}/#sigma_{d_{z}}) vs #eta sector;#eta (sector);width(d_{z}/#sigma_{d_{z}})",
1628  nBins_,lowedge,highedge);
1629 
1630  // means and widhts vs pT and pTCentral
1631 
1632  a_dxypTMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_pT",
1633  "#LT d_{xy} #GT vs pT;p_{T} [GeV];#LT d_{xy} #GT [#mum]",
1634  48,mypT_bins_);
1635 
1636  a_dxypTWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_pT",
1637  "#sigma_{d_{xy}} vs pT;p_{T} [GeV];#sigma_{d_{xy}} [#mum]",
1638  48,mypT_bins_);
1639 
1640  a_dzpTMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_pT",
1641  "#LT d_{z} #GT vs pT;p_{T} [GeV];#LT d_{z} #GT [#mum]",
1642  48,mypT_bins_);
1643 
1644  a_dzpTWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_pT","#sigma_{d_{z}} vs pT;p_{T} [GeV];#sigma_{d_{z}} [#mum]",
1645  48,mypT_bins_);
1646 
1647 
1648  n_dxypTMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_pT",
1649  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs pT;p_{T} [GeV];#LT d_{xy}/#sigma_{d_{xy}} #GT",
1650  48,mypT_bins_);
1651 
1652  n_dxypTWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_pT",
1653  "width(d_{xy}/#sigma_{d_{xy}}) vs pT;p_{T} [GeV]; width(d_{xy}/#sigma_{d_{xy}})",
1654  48,mypT_bins_);
1655 
1656  n_dzpTMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_pT",
1657  "#LT d_{z}/#sigma_{d_{z}} #GT vs pT;p_{T} [GeV];#LT d_{z}/#sigma_{d_{z}} #GT",
1658  48,mypT_bins_);
1659 
1660  n_dzpTWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_pT",
1661  "width(d_{z}/#sigma_{d_{z}}) vs pT;p_{T} [GeV];width(d_{z}/#sigma_{d_{z}})",
1662  48,mypT_bins_);
1663 
1664 
1665  a_dxypTCentralMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_pTCentral",
1666  "#LT d_{xy} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{xy} #GT [#mum]",
1667  48,mypT_bins_);
1668 
1669  a_dxypTCentralWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_pTCentral",
1670  "#sigma_{d_{xy}} vs p_{T};p_{T}(|#eta|<1.) [GeV];#sigma_{d_{xy}} [#mum]",
1671  48,mypT_bins_);
1672 
1673  a_dzpTCentralMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_pTCentral",
1674  "#LT d_{z} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{z} #GT [#mum]"
1675  ,48,mypT_bins_);
1676 
1677  a_dzpTCentralWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_pTCentral",
1678  "#sigma_{d_{z}} vs p_{T};p_{T}(|#eta|<1.) [GeV];#sigma_{d_{z}} [#mum]",
1679  48,mypT_bins_);
1680 
1681  n_dxypTCentralMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_pTCentral",
1682  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{xy}/#sigma_{d_{z}} #GT",
1683  48,mypT_bins_);
1684 
1685  n_dxypTCentralWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_pTCentral",
1686  "width(d_{xy}/#sigma_{d_{xy}}) vs p_{T};p_{T}(|#eta|<1.) [GeV];width(d_{xy}/#sigma_{d_{z}})",
1687  48,mypT_bins_);
1688 
1689  n_dzpTCentralMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_pTCentral",
1690  "#LT d_{z}/#sigma_{d_{z}} #GT vs p_{T};p_{T}(|#eta|<1.) [GeV];#LT d_{z}/#sigma_{d_{z}} #GT",
1691  48,mypT_bins_);
1692 
1693  n_dzpTCentralWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_pTCentral",
1694  "width(d_{z}/#sigma_{d_{z}}) vs p_{T};p_{T}(|#eta|<1.) [GeV];width(d_{z}/#sigma_{d_{z}})",
1695  48,mypT_bins_);
1696 
1697  // 2D maps
1698 
1699  a_dxyMeanMap = Mean2DMapsDir.make<TH2F> ("means_dxy_map",
1700  "#LT d_{xy} #GT map;#eta (sector);#varphi (sector) [degrees]",
1701  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1702 
1703  a_dzMeanMap = Mean2DMapsDir.make<TH2F> ("means_dz_map",
1704  "#LT d_{z} #GT map;#eta (sector);#varphi (sector) [degrees]",
1705  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1706 
1707  n_dxyMeanMap = Mean2DMapsDir.make<TH2F> ("norm_means_dxy_map",
1708  "#LT d_{xy}/#sigma_{d_{xy}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1709  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1710 
1711  n_dzMeanMap = Mean2DMapsDir.make<TH2F> ("norm_means_dz_map",
1712  "#LT d_{z}/#sigma_{d_{z}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1713  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1714 
1715  a_dxyWidthMap = Width2DMapsDir.make<TH2F> ("widths_dxy_map",
1716  "#sigma_{d_{xy}} map;#eta (sector);#varphi (sector) [degrees]",
1717  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1718 
1719  a_dzWidthMap = Width2DMapsDir.make<TH2F> ("widths_dz_map",
1720  "#sigma_{d_{z}} map;#eta (sector);#varphi (sector) [degrees]",
1721  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1722 
1723  n_dxyWidthMap = Width2DMapsDir.make<TH2F> ("norm_widths_dxy_map",
1724  "width(d_{xy}/#sigma_{d_{xy}}) map;#eta (sector);#varphi (sector) [degrees]",
1725  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1726 
1727  n_dzWidthMap = Width2DMapsDir.make<TH2F> ("norm_widths_dz_map",
1728  "width(d_{z}/#sigma_{d_{z}}) map;#eta (sector);#varphi (sector) [degrees]",
1729  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1730 
1731  // medians and MADs
1732 
1733  a_dxyPhiMedianTrend = MedianTrendsDir.make<TH1F>("medians_dxy_phi",
1734  "Median of d_{xy} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}) [#mum]",
1735  nBins_,lowedge,highedge);
1736 
1737  a_dxyPhiMADTrend = MADTrendsDir.make<TH1F> ("MADs_dxy_phi",
1738  "Median absolute deviation of d_{xy} vs #phi sector;#varphi (sector) [degrees];MAD(d_{xy}) [#mum]",
1739  nBins_,lowedge,highedge);
1740 
1741  a_dzPhiMedianTrend = MedianTrendsDir.make<TH1F>("medians_dz_phi",
1742  "Median of d_{z} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}) [#mum]",
1743  nBins_,lowedge,highedge);
1744 
1745  a_dzPhiMADTrend = MADTrendsDir.make<TH1F> ("MADs_dz_phi",
1746  "Median absolute deviation of d_{z} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}) [#mum]",
1747  nBins_,lowedge,highedge);
1748 
1749  a_dxyEtaMedianTrend = MedianTrendsDir.make<TH1F>("medians_dxy_eta",
1750  "Median of d_{xy} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}) [#mum]",
1751  nBins_,lowedge,highedge);
1752 
1753  a_dxyEtaMADTrend = MADTrendsDir.make<TH1F> ("MADs_dxy_eta",
1754  "Median absolute deviation of d_{xy} vs #eta sector;#eta (sector);MAD(d_{xy}) [#mum]",
1755  nBins_,lowedge,highedge);
1756 
1757  a_dzEtaMedianTrend = MedianTrendsDir.make<TH1F>("medians_dz_eta",
1758  "Median of d_{z} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}) [#mum]",
1759  nBins_,lowedge,highedge);
1760 
1761  a_dzEtaMADTrend = MADTrendsDir.make<TH1F> ("MADs_dz_eta",
1762  "Median absolute deviation of d_{z} vs #eta sector;#eta (sector);MAD(d_{z}) [#mum]",
1763  nBins_,lowedge,highedge);
1764 
1765  n_dxyPhiMedianTrend = MedianTrendsDir.make<TH1F>("norm_medians_dxy_phi",
1766  "Median of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}/#sigma_{d_{xy}})",
1767  nBins_,lowedge,highedge);
1768 
1769  n_dxyPhiMADTrend = MADTrendsDir.make<TH1F> ("norm_MADs_dxy_phi",
1770  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees]; MAD(d_{xy}/#sigma_{d_{xy}})",
1771  nBins_,lowedge,highedge);
1772 
1773  n_dzPhiMedianTrend = MedianTrendsDir.make<TH1F>("norm_medians_dz_phi",
1774  "Median of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
1775  nBins_,lowedge,highedge);
1776 
1777  n_dzPhiMADTrend = MADTrendsDir.make<TH1F> ("norm_MADs_dz_phi",
1778  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}/#sigma_{d_{z}})",
1779  nBins_,lowedge,highedge);
1780 
1781  n_dxyEtaMedianTrend = MedianTrendsDir.make<TH1F>("norm_medians_dxy_eta",
1782  "Median of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}/#sigma_{d_{z}})",
1783  nBins_,lowedge,highedge);
1784 
1785  n_dxyEtaMADTrend = MADTrendsDir.make<TH1F> ("norm_MADs_dxy_eta",
1786  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);MAD(d_{xy}/#sigma_{d_{z}})",
1787  nBins_,lowedge,highedge);
1788 
1789  n_dzEtaMedianTrend = MedianTrendsDir.make<TH1F>("norm_medians_dz_eta",
1790  "Median of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
1791  nBins_,lowedge,highedge);
1792 
1793  n_dzEtaMADTrend = MADTrendsDir.make<TH1F> ("norm_MADs_dz_eta",
1794  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);MAD(d_{z}/#sigma_{d_{z}})",
1795  nBins_,lowedge,highedge);
1796 
1797 
1799  //
1800  // plots of biased residuals
1801  // The vertex includes the probe track
1802  //
1804 
1805  if (useTracksFromRecoVtx_){
1806 
1807  TFileDirectory AbsTransPhiBiasRes = fs->mkdir("Abs_Transv_Phi_BiasResiduals");
1809 
1810  TFileDirectory AbsTransEtaBiasRes = fs->mkdir("Abs_Transv_Eta_BiasResiduals");
1812 
1813  TFileDirectory AbsLongPhiBiasRes = fs->mkdir("Abs_Long_Phi_BiasResiduals");
1815 
1816  TFileDirectory AbsLongEtaBiasRes = fs->mkdir("Abs_Long_Eta_BiasResiduals");
1818 
1819  TFileDirectory NormTransPhiBiasRes = fs->mkdir("Norm_Transv_Phi_BiasResiduals");
1821 
1822  TFileDirectory NormTransEtaBiasRes = fs->mkdir("Norm_Transv_Eta_BiasResiduals");
1824 
1825  TFileDirectory NormLongPhiBiasRes = fs->mkdir("Norm_Long_Phi_BiasResiduals");
1827 
1828  TFileDirectory NormLongEtaBiasRes = fs->mkdir("Norm_Long_Eta_BiasResiduals");
1830 
1831  TFileDirectory AbsDoubleDiffBiasRes = fs->mkdir("Abs_DoubleDiffBiasResiduals");
1832  TFileDirectory NormDoubleDiffBiasRes = fs->mkdir("Norm_DoubleDiffBiasResiduals");
1833 
1834  for ( int i=0; i<nBins_; ++i ) {
1835 
1836  float phiF = theDetails_.trendbins[PVValHelper::phi][i];
1837  float phiL = theDetails_.trendbins[PVValHelper::phi][i+1];
1838 
1839  for ( int j=0; j<nBins_; ++j ) {
1840 
1841  float etaF = theDetails_.trendbins[PVValHelper::eta][j];
1842  float etaL = theDetails_.trendbins[PVValHelper::eta][j+1];
1843 
1844  a_dxyBiasResidualsMap[i][j] = AbsDoubleDiffBiasRes.make<TH1F>(Form("histo_dxy_eta_plot%i_phi_plot%i",i,j),
1845  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy} [#mum];tracks",etaF,etaL,phiF,phiL),
1846  theDetails_.histobins,-dzmax_eta,dzmax_eta);
1847 
1848  a_dzBiasResidualsMap[i][j] = AbsDoubleDiffBiasRes.make<TH1F>(Form("histo_dxy_eta_plot%i_phi_plot%i",i,j),
1849  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z} [#mum];tracks",etaF,etaL,phiF,phiL),
1850  theDetails_.histobins,-dzmax_eta,dzmax_eta);
1851 
1852  n_dxyBiasResidualsMap[i][j] = NormDoubleDiffBiasRes.make<TH1F>(Form("histo_norm_dxy_eta_plot%i_phi_plot%i",i,j),
1853  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{xy}/#sigma_{d_{xy}};tracks",etaF,etaL,phiF,phiL),
1854  theDetails_.histobins,-dzmax_eta/100,dzmax_eta/100);
1855 
1856  n_dzBiasResidualsMap[i][j] = NormDoubleDiffBiasRes.make<TH1F>(Form("histo_norm_dxy_eta_plot%i_phi_plot%i",i,j),
1857  Form("%.2f<#eta_{tk}<%.2f %.2f#circ<#varphi_{tk}<%.2f#circ;d_{z}/#sigma_{d_{z}};tracks",etaF,etaL,phiF,phiL),
1858  theDetails_.histobins,-dzmax_eta/100,dzmax_eta/100);
1859  }
1860  }
1861 
1862  // declaration of the directories
1863 
1864  TFileDirectory MeanBiasTrendsDir = fs->mkdir("MeanBiasTrends");
1865  TFileDirectory WidthBiasTrendsDir = fs->mkdir("WidthBiasTrends");
1866  TFileDirectory MedianBiasTrendsDir = fs->mkdir("MedianBiasTrends");
1867  TFileDirectory MADBiasTrendsDir = fs->mkdir("MADBiasTrends");
1868 
1869  TFileDirectory Mean2DBiasMapsDir = fs->mkdir("MeanBiasMaps");
1870  TFileDirectory Width2DBiasMapsDir = fs->mkdir("WidthBiasMaps");
1871 
1872  // means and widths from the fit
1873 
1874  a_dxyPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("means_dxy_phi",
1875  "#LT d_{xy} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy} #GT [#mum]",
1876  nBins_,lowedge,highedge);
1877 
1878  a_dxyPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("widths_dxy_phi",
1879  "#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{xy}} [#mum]",
1880  nBins_,lowedge,highedge);
1881 
1882  a_dzPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("means_dz_phi",
1883  "#LT d_{z} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z} #GT [#mum]",
1884  nBins_,lowedge,highedge);
1885 
1886  a_dzPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("widths_dz_phi",
1887  "#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#sigma_{d_{z}} [#mum]",
1888  nBins_,lowedge,highedge);
1889 
1890  a_dxyEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("means_dxy_eta",
1891  "#LT d_{xy} #GT vs #eta sector;#eta (sector);#LT d_{xy} #GT [#mum]",
1892  nBins_,lowedge,highedge);
1893 
1894  a_dxyEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("widths_dxy_eta",
1895  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{xy}} [#mum]",
1896  nBins_,lowedge,highedge);
1897 
1898  a_dzEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("means_dz_eta",
1899  "#LT d_{z} #GT vs #eta sector;#eta (sector);#LT d_{z} #GT [#mum]",
1900  nBins_,lowedge,highedge);
1901 
1902  a_dzEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("widths_dz_eta",
1903  "#sigma_{d_{xy}} vs #eta sector;#eta (sector);#sigma_{d_{z}} [#mum]",
1904  nBins_,lowedge,highedge);
1905 
1906  n_dxyPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("norm_means_dxy_phi",
1907  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{xy}/#sigma_{d_{xy}} #GT",
1908  nBins_,lowedge,highedge);
1909 
1910  n_dxyPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("norm_widths_dxy_phi",
1911  "width(d_{xy}/#sigma_{d_{xy}}) vs #phi sector;#varphi (sector) [degrees]; width(d_{xy}/#sigma_{d_{xy}})",
1912  nBins_,lowedge,highedge);
1913 
1914  n_dzPhiMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("norm_means_dz_phi",
1915  "#LT d_{z}/#sigma_{d_{z}} #GT vs #phi sector;#varphi (sector) [degrees];#LT d_{z}/#sigma_{d_{z}} #GT",
1916  nBins_,lowedge,highedge);
1917 
1918  n_dzPhiWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("norm_widths_dz_phi",
1919  "width(d_{z}/#sigma_{d_{z}}) vs #phi sector;#varphi (sector) [degrees];width(d_{z}/#sigma_{d_{z}})",
1920  nBins_,lowedge,highedge);
1921 
1922  n_dxyEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("norm_means_dxy_eta",
1923  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs #eta sector;#eta (sector);#LT d_{xy}/#sigma_{d_{z}} #GT",
1924  nBins_,lowedge,highedge);
1925 
1926  n_dxyEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("norm_widths_dxy_eta",
1927  "width(d_{xy}/#sigma_{d_{xy}}) vs #eta sector;#eta (sector);width(d_{xy}/#sigma_{d_{z}})",
1928  nBins_,lowedge,highedge);
1929 
1930  n_dzEtaMeanBiasTrend = MeanBiasTrendsDir.make<TH1F> ("norm_means_dz_eta",
1931  "#LT d_{z}/#sigma_{d_{z}} #GT vs #eta sector;#eta (sector);#LT d_{z}/#sigma_{d_{z}} #GT",
1932  nBins_,lowedge,highedge);
1933 
1934  n_dzEtaWidthBiasTrend = WidthBiasTrendsDir.make<TH1F>("norm_widths_dz_eta",
1935  "width(d_{z}/#sigma_{d_{z}}) vs #eta sector;#eta (sector);width(d_{z}/#sigma_{d_{z}})",
1936  nBins_,lowedge,highedge);
1937 
1938  // 2D maps
1939 
1940  a_dxyMeanBiasMap = Mean2DBiasMapsDir.make<TH2F> ("means_dxy_map",
1941  "#LT d_{xy} #GT map;#eta (sector);#varphi (sector) [degrees]",
1942  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1943 
1944  a_dzMeanBiasMap = Mean2DBiasMapsDir.make<TH2F> ("means_dz_map",
1945  "#LT d_{z} #GT map;#eta (sector);#varphi (sector) [degrees]",
1946  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1947 
1948  n_dxyMeanBiasMap = Mean2DBiasMapsDir.make<TH2F> ("norm_means_dxy_map",
1949  "#LT d_{xy}/#sigma_{d_{xy}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1950  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1951 
1952  n_dzMeanBiasMap = Mean2DBiasMapsDir.make<TH2F> ("norm_means_dz_map",
1953  "#LT d_{z}/#sigma_{d_{z}} #GT map;#eta (sector);#varphi (sector) [degrees]",
1954  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1955 
1956  a_dxyWidthBiasMap = Width2DBiasMapsDir.make<TH2F> ("widths_dxy_map",
1957  "#sigma_{d_{xy}} map;#eta (sector);#varphi (sector) [degrees]",
1958  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1959 
1960  a_dzWidthBiasMap = Width2DBiasMapsDir.make<TH2F> ("widths_dz_map",
1961  "#sigma_{d_{z}} map;#eta (sector);#varphi (sector) [degrees]",
1962  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1963 
1964  n_dxyWidthBiasMap = Width2DBiasMapsDir.make<TH2F> ("norm_widths_dxy_map",
1965  "width(d_{xy}/#sigma_{d_{xy}}) map;#eta (sector);#varphi (sector) [degrees]",
1966  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1967 
1968  n_dzWidthBiasMap = Width2DBiasMapsDir.make<TH2F> ("norm_widths_dz_map",
1969  "width(d_{z}/#sigma_{d_{z}}) map;#eta (sector);#varphi (sector) [degrees]",
1970  nBins_,lowedge,highedge,nBins_,lowedge,highedge);
1971 
1972  // medians and MADs
1973 
1974  a_dxyPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("medians_dxy_phi",
1975  "Median of d_{xy} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}) [#mum]",
1976  nBins_,lowedge,highedge);
1977 
1978  a_dxyPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("MADs_dxy_phi",
1979  "Median absolute deviation of d_{xy} vs #phi sector;#varphi (sector) [degrees];MAD(d_{xy}) [#mum]",
1980  nBins_,lowedge,highedge);
1981 
1982  a_dzPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("medians_dz_phi",
1983  "Median of d_{z} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}) [#mum]",
1984  nBins_,lowedge,highedge);
1985 
1986  a_dzPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("MADs_dz_phi",
1987  "Median absolute deviation of d_{z} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}) [#mum]",
1988  nBins_,lowedge,highedge);
1989 
1990  a_dxyEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("medians_dxy_eta",
1991  "Median of d_{xy} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}) [#mum]",
1992  nBins_,lowedge,highedge);
1993 
1994  a_dxyEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("MADs_dxy_eta",
1995  "Median absolute deviation of d_{xy} vs #eta sector;#eta (sector);MAD(d_{xy}) [#mum]",
1996  nBins_,lowedge,highedge);
1997 
1998  a_dzEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("medians_dz_eta",
1999  "Median of d_{z} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}) [#mum]",
2000  nBins_,lowedge,highedge);
2001 
2002  a_dzEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("MADs_dz_eta",
2003  "Median absolute deviation of d_{z} vs #eta sector;#eta (sector);MAD(d_{z}) [#mum]",
2004  nBins_,lowedge,highedge);
2005 
2006  n_dxyPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("norm_medians_dxy_phi",
2007  "Median of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{xy}/#sigma_{d_{xy}})",
2008  nBins_,lowedge,highedge);
2009 
2010  n_dxyPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("norm_MADs_dxy_phi",
2011  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #phi sector;#varphi (sector) [degrees]; MAD(d_{xy}/#sigma_{d_{xy}})",
2012  nBins_,lowedge,highedge);
2013 
2014  n_dzPhiMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("norm_medians_dz_phi",
2015  "Median of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2016  nBins_,lowedge,highedge);
2017 
2018  n_dzPhiMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("norm_MADs_dz_phi",
2019  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #phi sector;#varphi (sector) [degrees];MAD(d_{z}/#sigma_{d_{z}})",
2020  nBins_,lowedge,highedge);
2021 
2022  n_dxyEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("norm_medians_dxy_eta",
2023  "Median of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{xy}/#sigma_{d_{z}})",
2024  nBins_,lowedge,highedge);
2025 
2026  n_dxyEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("norm_MADs_dxy_eta",
2027  "Median absolute deviation of d_{xy}/#sigma_{d_{xy}} vs #eta sector;#eta (sector);MAD(d_{xy}/#sigma_{d_{z}})",
2028  nBins_,lowedge,highedge);
2029 
2030  n_dzEtaMedianBiasTrend = MedianBiasTrendsDir.make<TH1F>("norm_medians_dz_eta",
2031  "Median of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);#mu_{1/2}(d_{z}/#sigma_{d_{z}})",
2032  nBins_,lowedge,highedge);
2033 
2034  n_dzEtaMADBiasTrend = MADBiasTrendsDir.make<TH1F> ("norm_MADs_dz_eta",
2035  "Median absolute deviation of d_{z}/#sigma_{d_{z}} vs #eta sector;#eta (sector);MAD(d_{z}/#sigma_{d_{z}})",
2036  nBins_,lowedge,highedge);
2037 
2038  }
2039 }
2040 // ------------ method called once each job just after ending the event loop ------------
2042 {
2043 
2044  edm::LogInfo("PrimaryVertexValidation")
2045  <<"######################################\n"
2046  <<"# PrimaryVertexValidation::endJob()\n"
2047  <<"# Number of analyzed events: "<<Nevt_<<"\n"
2048  <<"######################################";
2049 
2050  // means and widhts vs ladder and module number
2051 
2052  a_dxymodZMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_modZ",
2053  "#LT d_{xy} #GT vs modZ;module number (Z);#LT d_{xy} #GT [#mum]",
2054  nModZ_,0.,nModZ_);
2055 
2056  a_dxymodZWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_modZ",
2057  "#sigma_{d_{xy}} vs modZ;module number (Z);#sigma_{d_{xy}} [#mum]",
2058  nModZ_,0.,nModZ_);
2059 
2060  a_dzmodZMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_modZ",
2061  "#LT d_{z} #GT vs modZ;module number (Z);#LT d_{z} #GT [#mum]",
2062  nModZ_,0.,nModZ_);
2063 
2064  a_dzmodZWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_modZ",
2065  "#sigma_{d_{z}} vs modZ;module number (Z);#sigma_{d_{z}} [#mum]",
2066  nModZ_,0.,nModZ_);
2067 
2068  a_dxyladderMeanTrend = MeanTrendsDir.make<TH1F> ("means_dxy_ladder",
2069  "#LT d_{xy} #GT vs ladder;ladder number (#phi);#LT d_{xy} #GT [#mum]",
2070  nLadders_,0.,nLadders_);
2071 
2072  a_dxyladderWidthTrend = WidthTrendsDir.make<TH1F>("widths_dxy_ladder",
2073  "#sigma_{d_{xy}} vs ladder;ladder number (#phi);#sigma_{d_{xy}} [#mum]",
2074  nLadders_,0.,nLadders_);
2075 
2076  a_dzladderMeanTrend = MeanTrendsDir.make<TH1F> ("means_dz_ladder",
2077  "#LT d_{z} #GT vs ladder;ladder number (#phi);#LT d_{z} #GT [#mum]"
2078  ,nLadders_,0.,nLadders_);
2079 
2080  a_dzladderWidthTrend = WidthTrendsDir.make<TH1F>("widths_dz_ladder",
2081  "#sigma_{d_{z}} vs ladder;ladder number (#phi);#sigma_{d_{z}} [#mum]",
2082  nLadders_,0.,nLadders_);
2083 
2084  n_dxymodZMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_modZ",
2085  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs modZ;module number (Z);#LT d_{xy}/#sigma_{d_{xy}} #GT",
2086  nModZ_,0.,nModZ_);
2087 
2088  n_dxymodZWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_modZ",
2089  "width(d_{xy}/#sigma_{d_{xy}}) vs modZ;module number (Z); width(d_{xy}/#sigma_{d_{xy}})",
2090  nModZ_,0.,nModZ_);
2091 
2092  n_dzmodZMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_modZ",
2093  "#LT d_{z}/#sigma_{d_{z}} #GT vs modZ;module number (Z);#LT d_{z}/#sigma_{d_{z}} #GT",
2094  nModZ_,0.,nModZ_);
2095 
2096  n_dzmodZWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_modZ",
2097  "width(d_{z}/#sigma_{d_{z}}) vs pT;module number (Z);width(d_{z}/#sigma_{d_{z}})",
2098  nModZ_,0.,nModZ_);
2099 
2100  n_dxyladderMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dxy_ladder",
2101  "#LT d_{xy}/#sigma_{d_{xy}} #GT vs ladder;ladder number (#phi);#LT d_{xy}/#sigma_{d_{z}} #GT",
2102  nLadders_,0.,nLadders_);
2103 
2104  n_dxyladderWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dxy_ladder",
2105  "width(d_{xy}/#sigma_{d_{xy}}) vs ladder;ladder number (#phi);width(d_{xy}/#sigma_{d_{z}})",
2106  nLadders_,0.,nLadders_);
2107 
2108  n_dzladderMeanTrend = MeanTrendsDir.make<TH1F> ("norm_means_dz_ladder",
2109  "#LT d_{z}/#sigma_{d_{z}} #GT vs ladder;ladder number (#phi);#LT d_{z}/#sigma_{d_{z}} #GT",
2110  nLadders_,0.,nLadders_);
2111 
2112  n_dzladderWidthTrend = WidthTrendsDir.make<TH1F>("norm_widths_dz_ladder",
2113  "width(d_{z}/#sigma_{d_{z}}) vs ladder;ladder number (#phi);width(d_{z}/#sigma_{d_{z}})",
2114  nLadders_,0.,nLadders_);
2115 
2117 
2122 
2127 
2132 
2137 
2138  // medians and MADs
2139 
2144 
2149 
2154 
2159 
2160  // 2d Maps
2161 
2166 
2171 
2172  }
2173 
2174  // do profiles
2175 
2180 
2185 
2190 
2195 
2196  // vs transverse momentum
2197 
2202 
2207 
2212 
2217 
2218  // vs ladder and module number
2219 
2221  fillTrendPlotByIndex(a_dxymodZWidthTrend ,h_dxy_modZ_,PVValHelper::WIDTH);
2222  fillTrendPlotByIndex(a_dzmodZMeanTrend ,h_dz_modZ_,PVValHelper::MEAN);
2223  fillTrendPlotByIndex(a_dzmodZWidthTrend ,h_dz_modZ_,PVValHelper::WIDTH);
2224 
2225  fillTrendPlotByIndex(a_dxyladderMeanTrend ,h_dxy_ladder_,PVValHelper::MEAN);
2226  fillTrendPlotByIndex(a_dxyladderWidthTrend,h_dxy_ladder_,PVValHelper::WIDTH);
2227  fillTrendPlotByIndex(a_dzladderMeanTrend ,h_dz_ladder_,PVValHelper::MEAN);
2228  fillTrendPlotByIndex(a_dzladderWidthTrend ,h_dz_ladder_,PVValHelper::WIDTH);
2229 
2234 
2239 
2240  // medians and MADs
2241 
2244 
2247 
2252 
2257 
2262 
2263  // 2D Maps
2264 
2269 
2274 
2275 }
2276 
2277 //*************************************************************
2279 //*************************************************************
2280 {
2281  edm::ESHandle<RunInfo> runInfo;
2282  iSetup.get<RunInfoRcd>().get(runInfo);
2283 
2284  double average_current = runInfo.product()->m_avg_current;
2285  bool isOn = (average_current > 2000.);
2286  bool is0T = (ptOfProbe_==0.);
2287 
2288  return ( (isOn && !is0T) || (!isOn && is0T) );
2289 }
2290 
2291 //*************************************************************
2293 //*************************************************************
2294 {
2295  nTracks_ = 0;
2296  nClus_ = 0;
2298  RunNumber_ =0;
2300  xOfflineVertex_ =-999.;
2301  yOfflineVertex_ =-999.;
2302  zOfflineVertex_ =-999.;
2303  xErrOfflineVertex_=0.;
2304  yErrOfflineVertex_=0.;
2305  zErrOfflineVertex_=0.;
2306  BSx0_ = -999.;
2307  BSy0_ = -999.;
2308  BSz0_ = -999.;
2309  Beamsigmaz_=-999.;
2310  Beamdxdz_=-999.;
2311  BeamWidthX_=-999.;
2312  BeamWidthY_=-999.;
2313  wxy2_=-999.;
2314 
2315  for ( int i=0; i<nMaxtracks_; ++i ) {
2316 
2317  pt_[i] = 0;
2318  p_[i] = 0;
2319  nhits_[i] = 0;
2320  nhits1D_[i] = 0;
2321  nhits2D_[i] = 0;
2322  nhitsBPIX_[i] = 0;
2323  nhitsFPIX_[i] = 0;
2324  nhitsTIB_[i] = 0;
2325  nhitsTID_[i] = 0;
2326  nhitsTOB_[i] = 0;
2327  nhitsTEC_[i] = 0;
2328  isHighPurity_[i] = 0;
2329  eta_[i] = 0;
2330  theta_[i] = 0;
2331  phi_[i] = 0;
2332  chi2_[i] = 0;
2333  chi2ndof_[i] = 0;
2334  charge_[i] = 0;
2335  qoverp_[i] = 0;
2336  dz_[i] = 0;
2337  dxy_[i] = 0;
2338  dzBs_[i] = 0;
2339  dxyBs_[i] = 0;
2340  xPCA_[i] = 0;
2341  yPCA_[i] = 0;
2342  zPCA_[i] = 0;
2343  xUnbiasedVertex_[i] =0;
2344  yUnbiasedVertex_[i] =0;
2345  zUnbiasedVertex_[i] =0;
2349  DOFUnbiasedVertex_[i]=0;
2352  dxyFromMyVertex_[i]=0;
2353  dzFromMyVertex_[i]=0;
2354  d3DFromMyVertex_[i]=0;
2358  IPTsigFromMyVertex_[i]=0;
2359  IPLsigFromMyVertex_[i]=0;
2361  hasRecVertex_[i] = 0;
2362  isGoodTrack_[i] = 0;
2363  }
2364 }
2365 
2366 //*************************************************************
2367 void PrimaryVertexValidation::fillTrendPlot(TH1F* trendPlot, TH1F* residualsPlot[100], PVValHelper::estimator fitPar_, const std::string& var_)
2368 //*************************************************************
2369 {
2370 
2371  for ( int i=0; i<nBins_; ++i ) {
2372 
2373  char phibincenter[129];
2374  auto phiBins = theDetails_.trendbins[PVValHelper::phi];
2375  sprintf(phibincenter,"%.f",(phiBins[i]+phiBins[i+1])/2.);
2376 
2377  char etabincenter[129];
2378  auto etaBins = theDetails_.trendbins[PVValHelper::eta];
2379  sprintf(etabincenter,"%.1f",(etaBins[i]+etaBins[i+1])/2.);
2380 
2381  switch(fitPar_)
2382  {
2383  case PVValHelper::MEAN:
2384  {
2385  float mean_ = PVValHelper::fitResiduals(residualsPlot[i]).first.value();
2386  float meanErr_ = PVValHelper::fitResiduals(residualsPlot[i]).first.error();
2387  trendPlot->SetBinContent(i+1,mean_);
2388  trendPlot->SetBinError(i+1,meanErr_);
2389  break;
2390  }
2391  case PVValHelper::WIDTH:
2392  {
2393  float width_ = PVValHelper::fitResiduals(residualsPlot[i]).second.value();
2394  float widthErr_ = PVValHelper::fitResiduals(residualsPlot[i]).second.error();
2395  trendPlot->SetBinContent(i+1,width_);
2396  trendPlot->SetBinError(i+1,widthErr_);
2397  break;
2398  }
2399  case PVValHelper::MEDIAN:
2400  {
2401  float median_ = PVValHelper::getMedian(residualsPlot[i]).value();
2402  float medianErr_ = PVValHelper::getMedian(residualsPlot[i]).error();
2403  trendPlot->SetBinContent(i+1,median_);
2404  trendPlot->SetBinError(i+1,medianErr_);
2405  break;
2406  }
2407  case PVValHelper::MAD:
2408  {
2409  float mad_ = PVValHelper::getMAD(residualsPlot[i]).value();
2410  float madErr_ = PVValHelper::getMAD(residualsPlot[i]).error();
2411  trendPlot->SetBinContent(i+1,mad_);
2412  trendPlot->SetBinError(i+1,madErr_);
2413  break;
2414  }
2415  default:
2416  edm::LogWarning("PrimaryVertexValidation")<<"fillTrendPlot() "<<fitPar_<<" unknown estimator!"<<std::endl;
2417  break;
2418  }
2419 
2420  if(var_.find("eta") != std::string::npos){
2421  trendPlot->GetXaxis()->SetBinLabel(i+1,etabincenter);
2422  } else if(var_.find("phi") != std::string::npos){
2423  trendPlot->GetXaxis()->SetBinLabel(i+1,phibincenter);
2424  } else {
2425  edm::LogWarning("PrimaryVertexValidation")<<"fillTrendPlot() "<<var_<<" unknown track parameter!"<<std::endl;
2426  }
2427  }
2428 }
2429 
2430 //*************************************************************
2432 //*************************************************************
2433 {
2434 
2435  for(auto iterator = h.begin(); iterator != h.end(); iterator++) {
2436 
2437  unsigned int bin = std::distance(h.begin(),iterator)+1;
2438  std::pair<Measurement1D, Measurement1D> myFit = PVValHelper::fitResiduals((*iterator));
2439 
2440  switch(fitPar_)
2441  {
2442  case PVValHelper::MEAN:
2443  {
2444  float mean_ = myFit.first.value();
2445  float meanErr_ = myFit.first.error();
2446  trendPlot->SetBinContent(bin,mean_);
2447  trendPlot->SetBinError(bin,meanErr_);
2448  break;
2449  }
2450  case PVValHelper::WIDTH:
2451  {
2452  float width_ = myFit.second.value();
2453  float widthErr_ = myFit.second.error();
2454  trendPlot->SetBinContent(bin,width_);
2455  trendPlot->SetBinError(bin,widthErr_);
2456  break;
2457  }
2458  case PVValHelper::MEDIAN:
2459  {
2460  float median_ = PVValHelper::getMedian(*iterator).value();
2461  float medianErr_ = PVValHelper::getMedian(*iterator).error();
2462  trendPlot->SetBinContent(bin,median_);
2463  trendPlot->SetBinError(bin,medianErr_);
2464  break;
2465  }
2466  case PVValHelper::MAD:
2467  {
2468  float mad_ = PVValHelper::getMAD(*iterator).value();
2469  float madErr_ = PVValHelper::getMAD(*iterator).error();
2470  trendPlot->SetBinContent(bin,mad_);
2471  trendPlot->SetBinError(bin,madErr_);
2472  break;
2473  }
2474  default:
2475  edm::LogWarning("PrimaryVertexValidation")<<"fillTrendPlotByIndex() "<<fitPar_<<" unknown estimator!"<<std::endl;
2476  break;
2477  }
2478 
2479  char bincenter[129];
2480  if(plotVar == PVValHelper::eta){
2481  auto etaBins = theDetails_.trendbins[PVValHelper::eta];
2482  sprintf(bincenter,"%.1f",(etaBins[bin-1]+etaBins[bin])/2.);
2483  trendPlot->GetXaxis()->SetBinLabel(bin,bincenter);
2484  } else if(plotVar == PVValHelper::phi){
2485  auto phiBins = theDetails_.trendbins[PVValHelper::phi];
2486  sprintf(bincenter,"%.f",(phiBins[bin-1]+phiBins[bin])/2.);
2487  trendPlot->GetXaxis()->SetBinLabel(bin,bincenter);
2488  } else {
2490  //edm::LogWarning("PrimaryVertexValidation")<<"fillTrendPlotByIndex() "<< plotVar <<" unknown track parameter!"<<std::endl;
2491  }
2492 
2493  }
2494 }
2495 
2496 //*************************************************************
2497 void PrimaryVertexValidation::fillMap(TH2F* trendMap, TH1F* residualsMapPlot[100][100], PVValHelper::estimator fitPar_)
2498 //*************************************************************
2499 {
2500 
2501  for ( int i=0; i<nBins_; ++i ) {
2502 
2503  char phibincenter[129];
2504  auto phiBins = theDetails_.trendbins[PVValHelper::phi];
2505  sprintf(phibincenter,"%.f",(phiBins[i]+phiBins[i+1])/2.);
2506 
2507  trendMap->GetYaxis()->SetBinLabel(i+1,phibincenter);
2508 
2509  for ( int j=0; j<nBins_; ++j ) {
2510 
2511  char etabincenter[129];
2512  auto etaBins = theDetails_.trendbins[PVValHelper::eta];
2513  sprintf(etabincenter,"%.1f",(etaBins[j]+etaBins[j+1])/2.);
2514 
2515  if(i==0) { trendMap->GetXaxis()->SetBinLabel(j+1,etabincenter); }
2516 
2517  switch (fitPar_)
2518  {
2519  case PVValHelper::MEAN:
2520  {
2521  float mean_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).first.value();
2522  float meanErr_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).first.error();
2523  trendMap->SetBinContent(j+1,i+1,mean_);
2524  trendMap->SetBinError(j+1,i+1,meanErr_);
2525  break;
2526  }
2527  case PVValHelper::WIDTH:
2528  {
2529  float width_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).second.value();
2530  float widthErr_ = PVValHelper::fitResiduals(residualsMapPlot[i][j]).second.error();
2531  trendMap->SetBinContent(j+1,i+1,width_);
2532  trendMap->SetBinError(j+1,i+1,widthErr_);
2533  break;
2534  }
2535  case PVValHelper::MEDIAN:
2536  {
2537  float median_ = PVValHelper::getMedian(residualsMapPlot[i][j]).value();
2538  float medianErr_ = PVValHelper::getMedian(residualsMapPlot[i][j]).error();
2539  trendMap->SetBinContent(j+1,i+1,median_);
2540  trendMap->SetBinError(j+1,i+1,medianErr_);
2541  break;
2542  }
2543  case PVValHelper::MAD:
2544  {
2545  float mad_ = PVValHelper::getMAD(residualsMapPlot[i][j]).value();
2546  float madErr_ = PVValHelper::getMAD(residualsMapPlot[i][j]).error();
2547  trendMap->SetBinContent(j+1,i+1,mad_);
2548  trendMap->SetBinError(j+1,i+1,madErr_);
2549  break;
2550  }
2551  default:
2552  edm::LogWarning("PrimaryVertexValidation:") <<" fillMap() "<<fitPar_<<" unknown estimator!"<<std::endl;
2553  }
2554  } // closes loop on eta bins
2555  } // cloeses loop on phi bins
2556 }
2557 
2558 //*************************************************************
2560 //*************************************************************
2561 {
2562  if( a.tracksSize() != b.tracksSize() )
2563  return a.tracksSize() > b.tracksSize() ? true : false ;
2564  else
2565  return a.chi2() < b.chi2() ? true : false ;
2566 }
2567 
2568 //*************************************************************
2569 bool PrimaryVertexValidation::passesTrackCuts(const reco::Track & track, const reco::Vertex & vertex,const std::string& qualityString_, double dxyErrMax_,double dzErrMax_, double ptErrMax_)
2570 //*************************************************************
2571 {
2572 
2573  math::XYZPoint vtxPoint(0.0,0.0,0.0);
2574  double vzErr =0.0, vxErr=0.0, vyErr=0.0;
2575  vtxPoint=vertex.position();
2576  vzErr=vertex.zError();
2577  vxErr=vertex.xError();
2578  vyErr=vertex.yError();
2579 
2580  double dxy=0.0, dz=0.0, dxysigma=0.0, dzsigma=0.0;
2581  dxy = track.dxy(vtxPoint);
2582  dz = track.dz(vtxPoint);
2583  dxysigma = sqrt(track.d0Error()*track.d0Error()+vxErr*vyErr);
2584  dzsigma = sqrt(track.dzError()*track.dzError()+vzErr*vzErr);
2585 
2586  if(track.quality(reco::TrackBase::qualityByName(qualityString_)) != 1)return false;
2587  if(std::abs(dxy/dxysigma) > dxyErrMax_) return false;
2588  if(std::abs(dz/dzsigma) > dzErrMax_) return false;
2589  if(track.ptError() / track.pt() > ptErrMax_) return false;
2590 
2591  return true;
2592 }
2593 
2594 
2595 //*************************************************************
2597 //*************************************************************
2598 {
2599 
2600  TH1F::SetDefaultSumw2(kTRUE);
2601 
2602  std::map<std::string, TH1*> h;
2603 
2604  // histograms of track quality (Data and MC)
2605  std::string types[] = {"all","sel"};
2606  for(const auto & type : types){
2607  h["pseudorapidity_"+type] =dir.make <TH1F>(("rapidity_"+type).c_str(),"track pseudorapidity; track #eta; tracks",100,-3., 3.);
2608  h["z0_"+type] = dir.make<TH1F>(("z0_"+type).c_str(),"track z_{0};track z_{0} (cm);tracks",80,-40., 40.);
2609  h["phi_"+type] = dir.make<TH1F>(("phi_"+type).c_str(),"track #phi; track #phi;tracks",80,-M_PI, M_PI);
2610  h["eta_"+type] = dir.make<TH1F>(("eta_"+type).c_str(),"track #eta; track #eta;tracks",80,-4., 4.);
2611  h["pt_"+type] = dir.make<TH1F>(("pt_"+type).c_str(),"track p_{T}; track p_{T} [GeV];tracks",100,0., 20.);
2612  h["p_"+type] = dir.make<TH1F>(("p_"+type).c_str(),"track p; track p [GeV];tracks",100,0., 20.);
2613  h["found_"+type] = dir.make<TH1F>(("found_"+type).c_str(),"n. found hits;n^{found}_{hits};tracks",30, 0., 30.);
2614  h["lost_"+type] = dir.make<TH1F>(("lost_"+type).c_str(),"n. lost hits;n^{lost}_{hits};tracks",20, 0., 20.);
2615  h["nchi2_"+type] = dir.make<TH1F>(("nchi2_"+type).c_str(),"normalized track #chi^{2};track #chi^{2}/ndf;tracks",100, 0., 20.);
2616  h["rstart_"+type] = dir.make<TH1F>(("rstart_"+type).c_str(),"track start radius; track innermost radius r (cm);tracks",100, 0., 20.);
2617  h["expectedInner_"+type] = dir.make<TH1F>(("expectedInner_"+type).c_str(),"n. expected inner hits;n^{expected}_{inner};tracks",10, 0., 10.);
2618  h["expectedOuter_"+type] = dir.make<TH1F>(("expectedOuter_"+type).c_str(),"n. expected outer hits;n^{expected}_{outer};tracks ",10, 0., 10.);
2619  h["logtresxy_"+type] = dir.make<TH1F>(("logtresxy_"+type).c_str(),"log10(track r-#phi resolution/#mum);log10(track r-#phi resolution/#mum);tracks",100, 0., 5.);
2620  h["logtresz_"+type] = dir.make<TH1F>(("logtresz_"+type).c_str(),"log10(track z resolution/#mum);log10(track z resolution/#mum);tracks",100, 0., 5.);
2621  h["tpullxy_"+type] = dir.make<TH1F>(("tpullxy_"+type).c_str(),"track r-#phi pull;pull_{r-#phi};tracks",100, -10., 10.);
2622  h["tpullz_"+type] = dir.make<TH1F>(("tpullz_"+type).c_str(),"track r-z pull;pull_{r-z};tracks",100, -50., 50.);
2623  h["tlogDCAxy_"+type] = dir.make<TH1F>(("tlogDCAxy_"+type).c_str(),"track log_{10}(DCA_{r-#phi});track log_{10}(DCA_{r-#phi});tracks",200, -5., 3.);
2624  h["tlogDCAz_"+type] = dir.make<TH1F>(("tlogDCAz_"+type).c_str(),"track log_{10}(DCA_{r-z});track log_{10}(DCA_{r-z});tracks",200, -5., 5.);
2625  h["lvseta_"+type] = dir.make<TH2F>(("lvseta_"+type).c_str(),"cluster length vs #eta;track #eta;cluster length",60,-3., 3., 20, 0., 20);
2626  h["lvstanlambda_"+type] = dir.make<TH2F>(("lvstanlambda_"+type).c_str(),"cluster length vs tan #lambda; tan#lambda;cluster length",60,-6., 6., 20, 0., 20);
2627  h["restrkz_"+type] = dir.make<TH1F>(("restrkz_"+type).c_str(),"z-residuals (track vs vertex);res_{z} (cm);tracks", 200, -5., 5.);
2628  h["restrkzvsphi_"+type] = dir.make<TH2F>(("restrkzvsphi_"+type).c_str(),"z-residuals (track - vertex) vs track #phi;track #phi;res_{z} (cm)", 12,-M_PI,M_PI,100, -0.5,0.5);
2629  h["restrkzvseta_"+type] = dir.make<TH2F>(("restrkzvseta_"+type).c_str(),"z-residuals (track - vertex) vs track #eta;track #eta;res_{z} (cm)", 12,-3.,3.,200, -0.5,0.5);
2630  h["pulltrkzvsphi_"+type] = dir.make<TH2F>(("pulltrkzvsphi_"+type).c_str(),"normalized z-residuals (track - vertex) vs track #phi;track #phi;res_{z}/#sigma_{res_{z}}", 12,-M_PI,M_PI,100, -5., 5.);
2631  h["pulltrkzvseta_"+type] = dir.make<TH2F>(("pulltrkzvseta_"+type).c_str(),"normalized z-residuals (track - vertex) vs track #eta;track #eta;res_{z}/#sigma_{res_{z}}", 12,-3.,3.,100, -5., 5.);
2632  h["pulltrkz_"+type] = dir.make<TH1F>(("pulltrkz_"+type).c_str(),"normalized z-residuals (track vs vertex);res_{z}/#sigma_{res_{z}};tracks", 100, -5., 5.);
2633  h["sigmatrkz0_"+type] = dir.make<TH1F>(("sigmatrkz0_"+type).c_str(),"z-resolution (excluding beam);#sigma^{trk}_{z_{0}} (cm);tracks", 100, 0., 5.);
2634  h["sigmatrkz_"+type] = dir.make<TH1F>(("sigmatrkz_"+type).c_str(),"z-resolution (including beam);#sigma^{trk}_{z} (cm);tracks", 100,0., 5.);
2635  h["nbarrelhits_"+type] = dir.make<TH1F>(("nbarrelhits_"+type).c_str(),"number of pixel barrel hits;n. hits Barrel Pixel;tracks", 10, 0., 10.);
2636  h["nbarrelLayers_"+type] = dir.make<TH1F>(("nbarrelLayers_"+type).c_str(),"number of pixel barrel layers;n. layers Barrel Pixel;tracks", 10, 0., 10.);
2637  h["nPxLayers_"+type] = dir.make<TH1F>(("nPxLayers_"+type).c_str(),"number of pixel layers (barrel+endcap);n. Pixel layers;tracks", 10, 0., 10.);
2638  h["nSiLayers_"+type] = dir.make<TH1F>(("nSiLayers_"+type).c_str(),"number of Tracker layers;n. Tracker layers;tracks", 20, 0., 20.);
2639  h["trackAlgo_"+type] = dir.make<TH1F>(("trackAlgo_"+type).c_str(),"track algorithm;track algo;tracks", 30, 0., 30.);
2640  h["trackQuality_"+type] = dir.make<TH1F>(("trackQuality_"+type).c_str(),"track quality;track quality;tracks", 7, -1., 6.);
2641  }
2642 
2643  return h;
2644 
2645 }
2646 
2647 //*************************************************************
2648 // Generic booker function
2649 //*************************************************************
2651  unsigned int theNOfBins,
2652  PVValHelper::residualType resType,
2653  PVValHelper::plotVariable varType,
2654  bool isNormalized){
2655 
2656  TH1F::SetDefaultSumw2(kTRUE);
2657 
2658  auto hash = std::make_pair(resType,varType);
2659 
2660  double down = theDetails_.range[hash].first;
2661  double up = theDetails_.range[hash].second;
2662 
2663  if(isNormalized){
2664  up = up/100.;
2665  down = down/100.;
2666  }
2667 
2668  std::vector<TH1F*> h;
2669  h.reserve(theNOfBins);
2670 
2671  if (theNOfBins==0) {
2672  edm::LogError("PrimaryVertexValidation") <<"bookResidualsHistogram() The number of bins cannot be identically 0" << std::endl;
2673  assert(false);
2674  }
2675 
2676  std::string s_resType = std::get<0>(PVValHelper::getTypeString(resType));
2677  std::string s_varType = std::get<0>(PVValHelper::getVarString(varType));
2678 
2679  std::string t_resType = std::get<1>(PVValHelper::getTypeString(resType));
2680  std::string t_varType = std::get<1>(PVValHelper::getVarString(varType));
2681  std::string units = std::get<2>(PVValHelper::getTypeString(resType));
2682 
2683  for(unsigned int i=0; i<theNOfBins;i++){
2684 
2685  TString title = (varType == PVValHelper::phi || varType == PVValHelper::eta) ?
2686  Form("%s vs %s - bin %i (%f < %s < %f);%s %s;tracks",t_resType.c_str(),t_varType.c_str(),i, theDetails_.trendbins[varType][i],t_varType.c_str(),theDetails_.trendbins[varType][i+1],t_resType.c_str(),units.c_str()) : 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());
2687 
2688  TH1F* htemp = dir.make<TH1F>(Form("histo_%s_%s_plot%i",s_resType.c_str(),s_varType.c_str(),i),
2689  //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()),
2690  title.Data(),
2692  h.push_back(htemp);
2693  }
2694 
2695  return h;
2696 
2697 }
2698 
2699 //*************************************************************
2700 void PrimaryVertexValidation::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_)
2701 //*************************************************************
2702 {
2703 
2704  using namespace reco;
2705 
2706  PVValHelper::fill(h,"pseudorapidity_"+ttype,tt->track().eta());
2707  PVValHelper::fill(h,"z0_"+ttype,tt->track().vz());
2708  PVValHelper::fill(h,"phi_"+ttype,tt->track().phi());
2709  PVValHelper::fill(h,"eta_"+ttype,tt->track().eta());
2710  PVValHelper::fill(h,"pt_"+ttype,tt->track().pt());
2711  PVValHelper::fill(h,"p_"+ttype,tt->track().p());
2712  PVValHelper::fill(h,"found_"+ttype,tt->track().found());
2713  PVValHelper::fill(h,"lost_"+ttype,tt->track().lost());
2714  PVValHelper::fill(h,"nchi2_"+ttype,tt->track().normalizedChi2());
2715  PVValHelper::fill(h,"rstart_"+ttype,(tt->track().innerPosition()).Rho());
2716 
2717  double d0Error=tt->track().d0Error();
2718  double d0=tt->track().dxy(beamSpot.position());
2719  double dz=tt->track().dz(beamSpot.position());
2720  if (d0Error>0){
2721  PVValHelper::fill(h,"logtresxy_"+ttype,log(d0Error/0.0001)/log(10.));
2722  PVValHelper::fill(h,"tpullxy_"+ttype,d0/d0Error);
2723  PVValHelper::fill(h,"tlogDCAxy_"+ttype,log(std::abs(d0/d0Error)));
2724 
2725  }
2726  //double z0=tt->track().vz();
2727  double dzError=tt->track().dzError();
2728  if(dzError>0){
2729  PVValHelper::fill(h,"logtresz_"+ttype,log(dzError/0.0001)/log(10.));
2730  PVValHelper::fill(h,"tpullz_"+ttype,dz/dzError);
2731  PVValHelper::fill(h,"tlogDCAz_"+ttype,log(std::abs(dz/dzError)));
2732  }
2733 
2734  //
2735  double wxy2_=pow(beamSpot.BeamWidthX(),2)+pow(beamSpot.BeamWidthY(),2);
2736 
2737  PVValHelper::fill(h,"sigmatrkz_"+ttype,sqrt(pow(tt->track().dzError(),2)+wxy2_/pow(tan(tt->track().theta()),2)));
2738  PVValHelper::fill(h,"sigmatrkz0_"+ttype,tt->track().dzError());
2739 
2740  // track vs vertex
2741  if( v.isValid()){ // && (v.ndof()<10.)) {
2742  // emulate clusterizer input
2743  //const TransientTrack & tt = theB_->build(&t); wrong !!!!
2744  //reco::TransientTrack tt = theB_->build(&t);
2745  //ttt->track().setBeamSpot(beamSpot); // need the setBeamSpot !
2746  double z=(tt->stateAtBeamLine().trackStateAtPCA()).position().z();
2747  double tantheta=tan((tt->stateAtBeamLine().trackStateAtPCA()).momentum().theta());
2748  double dz2= pow(tt->track().dzError(),2)+wxy2_/pow(tantheta,2);
2749 
2750  PVValHelper::fill(h,"restrkz_"+ttype,z-v.position().z());
2751  PVValHelper::fill(h,"restrkzvsphi_"+ttype,tt->track().phi(), z-v.position().z());
2752  PVValHelper::fill(h,"restrkzvseta_"+ttype,tt->track().eta(), z-v.position().z());
2753  PVValHelper::fill(h,"pulltrkzvsphi_"+ttype,tt->track().phi(), (z-v.position().z())/sqrt(dz2));
2754  PVValHelper::fill(h,"pulltrkzvseta_"+ttype,tt->track().eta(), (z-v.position().z())/sqrt(dz2));
2755 
2756  PVValHelper::fill(h,"pulltrkz_"+ttype,(z-v.position().z())/sqrt(dz2));
2757 
2758  double x1=tt->track().vx()-beamSpot.x0(); double y1=tt->track().vy()-beamSpot.y0();
2759 
2760  double kappa=-0.002998*fBfield_*tt->track().qoverp()/cos(tt->track().theta());
2761  double D0=x1*sin(tt->track().phi())-y1*cos(tt->track().phi())-0.5*kappa*(x1*x1+y1*y1);
2762  double q=sqrt(1.-2.*kappa*D0);
2763  double s0=(x1*cos(tt->track().phi())+y1*sin(tt->track().phi()))/q;
2764  // double s1;
2765  if (std::abs(kappa*s0)>0.001){
2766  //s1=asin(kappa*s0)/kappa;
2767  }else{
2768  //double ks02=(kappa*s0)*(kappa*s0);
2769  //s1=s0*(1.+ks02/6.+3./40.*ks02*ks02+5./112.*pow(ks02,3));
2770  }
2771  // sp.ddcap=-2.*D0/(1.+q);
2772  //double zdcap=tt->track().vz()-s1/tan(tt->track().theta());
2773 
2774  }
2775  //
2776 
2777  // collect some info on hits and clusters
2778  PVValHelper::fill(h,"nbarrelLayers_"+ttype,tt->track().hitPattern().pixelBarrelLayersWithMeasurement());
2779  PVValHelper::fill(h,"nPxLayers_"+ttype,tt->track().hitPattern().pixelLayersWithMeasurement());
2780  PVValHelper::fill(h,"nSiLayers_"+ttype,tt->track().hitPattern().trackerLayersWithMeasurement());
2781  PVValHelper::fill(h,"expectedInner_"+ttype,tt->track().hitPattern().numberOfHits(HitPattern::MISSING_INNER_HITS));
2782  PVValHelper::fill(h,"expectedOuter_"+ttype,tt->track().hitPattern().numberOfHits(HitPattern::MISSING_OUTER_HITS));
2783  PVValHelper::fill(h,"trackAlgo_"+ttype,tt->track().algo());
2784  PVValHelper::fill(h,"trackQuality_"+ttype,tt->track().qualityMask());
2785 
2786  //
2787  int longesthit=0, nbarrel=0;
2789  if ((**hit).isValid() && (**hit).geographicalId().det() == DetId::Tracker ){
2790  bool barrel = DetId((**hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
2791  //bool endcap = DetId::DetId((**hit).geographicalId()).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
2792  if (barrel){
2793  const SiPixelRecHit *pixhit = dynamic_cast<const SiPixelRecHit*>( &(**hit));
2794  edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> const& clust = (*pixhit).cluster();
2795  if (clust.isNonnull()) {
2796  nbarrel++;
2797  if (clust->sizeY()-longesthit>0) longesthit=clust->sizeY();
2798  if (clust->sizeY()>20.){
2799  PVValHelper::fill(h,"lvseta_"+ttype,tt->track().eta(), 19.9);
2800  PVValHelper::fill(h,"lvstanlambda_"+ttype,tan(tt->track().lambda()), 19.9);
2801  }else{
2802  PVValHelper::fill(h,"lvseta_"+ttype,tt->track().eta(), float(clust->sizeY()));
2803  PVValHelper::fill(h,"lvstanlambda_"+ttype,tan(tt->track().lambda()), float(clust->sizeY()));
2804  }
2805  }
2806  }
2807  }
2808  }
2809  PVValHelper::fill(h,"nbarrelhits_"+ttype,float(nbarrel));
2810  //-------------------------------------------------------------------
2811 }
2812 
2813 //define this as a plug-in
2815 
2816 
#define LogDebug(id)
std::vector< TH1F * > h_norm_dxy_modZ_
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const AlgebraicVector3 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix66 &theCovarianceMatrix, const MagneticField *field)
double qoverp() const
q / p
Definition: TrackBase.h:568
virtual char const * what() const
Definition: Exception.cc:141
static const std::string kSharedResource
Definition: TFileService.h:76
Definition: BitonicSort.h:8
double p() const
momentum vector magnitude
Definition: TrackBase.h:610
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
double z0() const
z coordinate
Definition: BeamSpot.h:68
T getUntrackedParameter(std::string const &, T const &) const
std::vector< TH1F * > n_IP3DPhiResiduals
Measurement1D getMedian(TH1F *histo)
std::vector< TH1F * > a_dxyEtaResiduals
TH1F * n_dzResidualsMap[nMaxBins_][nMaxBins_]
static uint32_t getLayer(uint16_t pattern)
Definition: HitPattern.h:700
std::vector< TH1F * > a_d3DEtaResiduals
double d0Error() const
error on d0
Definition: TrackBase.h:797
double longitudinalImpactParameterError() const
std::vector< TH1F * > n_reszPhiResiduals
std::vector< unsigned int > runControlNumbers_
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:78
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
void fillByIndex(std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
unsigned short lost() const
Number of lost (=invalid) hits on track.
Definition: Track.h:199
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static bool vtxSort(const reco::Vertex &a, const reco::Vertex &b)
const PerigeeTrajectoryError & perigeeError() const
std::pair< Measurement1D, Measurement1D > fitResiduals(TH1 *hist)
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
void setBeamSpot(const reco::BeamSpot &beamSpot)
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:556
void fillTrendPlot(TH1F *trendPlot, TH1F *residualsPlot[100], PVValHelper::estimator fitPar_, const std::string &var_)
const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< TH1F * > h_dxy_pT_
double zError() const
error on z
Definition: Vertex.h:123
TrackFilterForPVFindingBase * theTrackFilter_
TH1F * a_dxyResidualsMap[nMaxBins_][nMaxBins_]
std::map< std::string, TH1 * > hDA
TrackQuality
track quality
Definition: TrackBase.h:151
std::vector< TH1F * > a_IP3DEtaResiduals
Common base class.
const FreeTrajectoryState & theState() const
double theta() const
polar angle
Definition: TrackBase.h:574
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< float > generateBins(int n, float start, float range)
std::vector< TH1F * > n_dzPhiResiduals
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
Divides< arg, void > D0
Definition: Factorize.h:144
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:50
TH1F * n_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > n_d3DEtaResiduals
const HitPattern & hitPattern() const
unsigned int pxbLadder(const DetId &id) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
reco::TransientTrack build(const reco::Track *p) const
std::vector< TH1F * > h_norm_dz_Central_pT_
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
T y() const
Definition: PV3DBase.h:63
double error() const
Definition: Measurement1D.h:30
RunNumber_t run() const
const float mypT_bins_[nPtBins_+1]
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:640
float DOFUnbiasedVertex_[nMaxtracks_]
unsigned int pxbModule(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
double d3DFromMyVertex_[nMaxtracks_]
void fillTrendPlotByIndex(TH1F *trendPlot, std::vector< TH1F * > &h, PVValHelper::estimator fitPar_, PVValHelper::plotVariable plotVar=PVValHelper::END_OF_PLOTS)
std::vector< TH1F * > a_reszPhiResiduals
std::vector< TH1F * > a_IP2DPhiResiduals
float chi2ProbUnbiasedVertex_[nMaxtracks_]
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:622
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:493
std::vector< TH1F * > n_reszEtaResiduals
double dxyFromMyVertex_[nMaxtracks_]
virtual void endJob() override
Measurement1D getMAD(TH1F *histo)
std::map< std::string, TH1 * > bookVertexHistograms(const TFileDirectory &dir)
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:512
const Point & position() const
position
Definition: Vertex.h:109
static bool pixelBarrelHitFilter(uint16_t pattern)
Definition: HitPattern.h:575
std::vector< TH1F * > h_dz_modZ_
std::vector< TH1F * > h_dxy_modZ_
std::vector< TH1F * > a_dxEtaResiduals
bool isBFieldConsistentWithMode(const edm::EventSetup &iSetup) const
std::pair< bool, bool > pixelHitsCheck(const reco::TransientTrack &track)
TrajectoryStateClosestToBeamLine stateAtBeamLine() const
int numberOfValidStripTOBHits() const
Definition: HitPattern.h:868
plotLabels getVarString(plotVariable var)
double dzErrorFromMyVertex_[nMaxtracks_]
std::vector< TH1F * > n_dxyEtaBiasResiduals
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)
LuminosityBlockNumber_t luminosityBlock() const
static bool pixelEndcapHitFilter(uint16_t pattern)
Definition: HitPattern.h:585
std::vector< TH1F * > n_dxyEtaResiduals
double IPTsigFromMyVertex_[nMaxtracks_]
static bool validHitFilter(uint16_t pattern)
Definition: HitPattern.h:787
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
TrackAlgorithm algo() const
Definition: TrackBase.h:492
std::vector< TH1F * > a_dzPhiBiasResiduals
std::vector< TH1F * > h_norm_dxy_pT_
std::vector< TH1F * > a_dzEtaResiduals
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:682
float getHigh(residualType type, plotVariable plot)
int tracksUsedForVertexing_[nMaxtracks_]
float getLow(residualType type, plotVariable plot)
int iEvent
Definition: GenABIO.cc:230
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
virtual void beginJob() override
std::vector< TH1F * > a_dxyEtaBiasResiduals
int numberOfValidPixelBarrelHits() const
Definition: HitPattern.h:843
std::vector< TH1F * > h_norm_dxy_ladder_
const PerigeeTrajectoryParameters & perigeeParameters() const
std::vector< TH1F * > a_dzPhiResiduals
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:544
double yUnbiasedVertex_[nMaxtracks_]
T sqrt(T t)
Definition: SSEVec.h:18
virtual int dimension() const =0
double pt() const
track transverse momentum
Definition: TrackBase.h:616
std::vector< TH1F * > n_dxyPhiResiduals
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:758
int qualityMask() const
Definition: TrackBase.h:857
std::map< plotVariable, std::vector< float > > trendbins
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
def pv(vc)
Definition: MetAnalyzer.py:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double chi2() const
chi-squares
Definition: Vertex.h:98
double zUnbiasedVertex_[nMaxtracks_]
int numberOfValidStripTIDHits() const
Definition: HitPattern.h:863
double lambda() const
Lambda angle.
Definition: TrackBase.h:580
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
std::vector< TH1F * > h_dxy_ladder_
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:815
int numberOfValidStripTECHits() const
Definition: HitPattern.h:873
float chi2normUnbiasedVertex_[nMaxtracks_]
TH1F * n_d3DResidualsMap[nMaxBins_][nMaxBins_]
T * make(const Args &...args) const
make new ROOT object
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< TH1F * > a_dxyPhiResiduals
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
std::vector< TH1F * > a_dxyPhiBiasResiduals
edm::EDGetTokenT< reco::VertexCollection > theVertexCollectionToken
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
TH1F * a_d3DResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > h_dxy_ladderNoOverlap_
bool isValid() const
Definition: HandleBase.h:74
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
double IPLsigFromMyVertex_[nMaxtracks_]
#define LogTrace(id)
bool hasFirstLayerPixelHits(const reco::TransientTrack &track)
std::vector< TH1F * > n_dzEtaResiduals
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
double ndof() const
Definition: Vertex.h:105
void setMap(residualType type, plotVariable plot, float low, float high)
#define M_PI
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:634
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
bin
set the eta bin as selection string.
std::vector< TH1F * > n_IP3DEtaResiduals
unsigned int pxbLayer(const DetId &id) const
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:604
double dzError() const
error on dz
Definition: TrackBase.h:809
std::map< std::pair< residualType, plotVariable >, std::pair< float, float > > range
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:664
std::vector< TH1F * > h_norm_dz_pT_
Definition: DetId.h:18
GlobalPoint position() const
void fillMap(TH2F *trendMap, TH1F *residualsMapPlot[100][100], PVValHelper::estimator fitPar_)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
double xError() const
error on x
Definition: Vertex.h:119
std::vector< TH1F * > h_dz_pT_
plotLabels getTypeString(residualType type)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
void shrinkHistVectorToFit(std::vector< TH1F * > &h, unsigned int desired_size)
std::vector< TH1F * > n_dzEtaBiasResiduals
edm::Service< TFileService > fs
std::vector< TH1F * > h_dz_Central_pT_
const Track & track() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:445
bool isHit2D(const TrackingRecHit &hit) const
std::vector< TH1F * > h_dz_ladder_
std::vector< TH1F * > a_IP2DEtaResiduals
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:56
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
int pixelBarrelLayersWithMeasurement() const
Definition: HitPattern.cc:552
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
TrackClusterizerInZ * theTrackClusterizer_
bool isValid() const
double b
Definition: hdecay.h:120
std::vector< TH1F * > n_IP2DPhiResiduals
double xUnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > h_dxy_Central_pT_
double value() const
Definition: Measurement1D.h:28
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
int numberOfValidStripTIBHits() const
Definition: HitPattern.h:858
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:505
int numberOfValidPixelEndcapHits() const
Definition: HitPattern.h:848
float m_avg_current
Definition: RunInfo.h:29
edm::EDGetTokenT< reco::BeamSpot > theBeamspotToken
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken
EventID const & id() const
Pixel cluster – collection of neighboring pixels above threshold.
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:658
TString units(TString variable, Char_t axis)
double dzFromMyVertex_[nMaxtracks_]
fixed size matrix
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:194
std::vector< TH1F * > a_reszEtaResiduals
std::vector< TH1F * > bookResidualsHistogram(const TFileDirectory &dir, unsigned int theNOfBins, PVValHelper::residualType resType, PVValHelper::plotVariable varType, bool isNormalized=false)
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
double y0() const
y coordinate
Definition: BeamSpot.h:66
TH1F * a_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_dxPhiResiduals
std::vector< TH1F * > h_norm_dz_modZ_
int charge() const
track electric charge
Definition: TrackBase.h:562
const Point & position() const
position
Definition: BeamSpot.h:62
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_)
static const G4double kappa
double normalizedChi2() const
chi-squared divided by n.d.o.f.
Definition: Vertex.h:107
double dxyErrorFromMyVertex_[nMaxtracks_]
DetId geographicalId() const
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< TH1F * > a_dyEtaResiduals
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
std::vector< TH1F * > n_IP2DEtaResiduals
std::vector< TH1F * > h_norm_dz_ladder_
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:515
float sumOfWeightsUnbiasedVertex_[nMaxtracks_]
TH1F * n_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
double d3DErrorFromMyVertex_[nMaxtracks_]
std::vector< TH1F * > a_dyPhiResiduals
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:586
std::vector< TH1F * > h_dxy_ladderOverlap_
TH1F * a_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
T x() const
Definition: PV3DBase.h:62
PVValHelper::histodetails theDetails_
T const * product() const
Definition: ESHandle.h:86
TH1F * a_dzResidualsMap[nMaxBins_][nMaxBins_]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double yError() const
error on y
Definition: Vertex.h:121
float chi2UnbiasedVertex_[nMaxtracks_]
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
*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
std::vector< TH1F * > h_norm_dxy_Central_pT_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:628
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:652
Global3DVector GlobalVector
Definition: GlobalVector.h:10
int numberOfHits(HitCategory category) const
Definition: HitPattern.h:807
std::vector< TH1F * > a_dzEtaBiasResiduals
Our base class.
Definition: SiPixelRecHit.h:23
std::vector< TH1F * > a_IP3DPhiResiduals
std::vector< TH1F * > n_dzPhiBiasResiduals
double x0() const
x coordinate
Definition: BeamSpot.h:64
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109
double IP3DsigFromMyVertex_[nMaxtracks_]