CMS 3D CMS Logo

PrimaryVertexValidation.h
Go to the documentation of this file.
1 #ifndef PrimaryVertexValidation_h
2 #define PrimaryVertexValidation_h
3 
4 // system include files
5 #include <string>
6 #include <sstream>
7 #include <vector>
8 #include <map>
9 
10 // ROOT Included
11 #include "TFile.h"
12 #include "TH1D.h"
13 #include "TH1I.h"
14 #include "TH2D.h"
15 #include "TTree.h"
16 
17 // CMSSW includes
57 
58 //
59 // ancyllary enum for
60 // residuals moments estimation
61 //
62 
63 //
64 // class decleration
65 //
66 
67 class PrimaryVertexValidation : public edm::one::EDAnalyzer<edm::one::SharedResources> {
68 
69  public:
71  ~PrimaryVertexValidation() override;
72 
73  private:
74  virtual void beginJob() override;
75  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
76  virtual void endJob() override;
77  bool isBFieldConsistentWithMode(const edm::EventSetup& iSetup) const;
78  bool isHit2D(const TrackingRecHit &hit) const;
80  std::pair<bool,bool> pixelHitsCheck(const reco::TransientTrack& track);
82  Measurement1D getMAD(TH1F *histo);
83  std::pair<Measurement1D, Measurement1D > fitResiduals(TH1 *hist);
84 
85  void fillTrendPlot(TH1F* trendPlot, TH1F *residualsPlot[100], PVValHelper::estimator fitPar_, const std::string& var_);
86  void fillTrendPlotByIndex(TH1F* trendPlot,std::vector<TH1F*>& h, PVValHelper::estimator fitPar_,PVValHelper::plotVariable plotVar=PVValHelper::END_OF_PLOTS);
87 
88  static bool vtxSort( const reco::Vertex & a, const reco::Vertex & b );
89  bool passesTrackCuts(const reco::Track & track, const reco::Vertex & vertex,const std::string& qualityString_, double dxyErrMax_,double dzErrMax_, double ptErrMax_);
90 
91  std::vector<TH1F*> bookResidualsHistogram(const TFileDirectory& dir,unsigned int theNOfBins,PVValHelper::residualType resType,PVValHelper::plotVariable varType, bool isNormalized=false);
92  std::map<std::string, TH1*> bookVertexHistograms(const TFileDirectory& dir);
93 
94  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);
95  void add(std::map<std::string, TH1*>& h, TH1* hist);
96 
97  void fill(std::map<std::string, TH1*>& h,const std::string& s, double x);
98  void fill(std::map<std::string, TH1*>& h,const std::string& s, double x, double y);
99  void fillByIndex(std::vector<TH1F*>& h, unsigned int index, double x,std::string tag="");
100 
101  void shrinkHistVectorToFit(std::vector<TH1F*>&h,unsigned int desired_size);
102  std::tuple<std::string,std::string,std::string> getTypeString (PVValHelper::residualType type);
103  std::tuple<std::string,std::string,std::string> getVarString (PVValHelper::plotVariable var);
104 
105  void fillMap(TH2F* trendMap, TH1F* residualsMapPlot[100][100], PVValHelper::estimator fitPar_);
106 
107  inline double square(double x){
108  return x*x;
109  }
110 
111  // ----------member data ---------------------------
113  int Nevt_;
114 
117 
118  // setting of the number of plots
119  static const int nMaxBins_ = 100; // maximum number of bookable histograms
120 
121  // Output
123  bool lightNtupleSwitch_; // switch to keep only info for daily validation
125 
126  // histogram details
128 
129  // requirements on the vertex
130  double vertexZMax_;
131 
132  // integrated lumi (if info available)
133  double intLumi_;
134 
135  // requirements on the probe
136  bool askFirstLayerHit_; // ask hit in the first layer of pixels
137  bool doBPix_;
138  bool doFPix_;
139  double ptOfProbe_;
140  double pOfProbe_;
141  double etaOfProbe_;
143  bool isPhase1_;
144  int nBins_; // actual number of histograms
145  std::vector<unsigned int> runControlNumbers_;
146 
147  bool debug_;
149 
153 
154  TTree* rootTree_;
155 
156  // Root-Tuple variables :
157  //=======================
158  void SetVarToZero();
159 
160  static const int nMaxtracks_ = 1000;
161  static const int cmToum = 10000;
162  static const int nPtBins_ = 48;
163 
164  unsigned int nLadders_= 20;
165  unsigned int nModZ_ = 8;
166 
167  // pT binning as in paragraph 3.2 of CMS-PAS-TRK-10-005 (https://cds.cern.ch/record/1279383/files/TRK-10-005-pas.pdf)
168 
169  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
170  const float mypT_bins_[nPtBins_+1] = {0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.25,4.5,4.75,5.0,5.5,6.0,7.0,8.0,9.0,11.0,14.0,20.};
171 
172  // event-related quantities
173  int nTracks_;
175  int nClus_;
177  unsigned int RunNumber_;
178  unsigned int EventNumber_;
183 
187 
188  double BSx0_;
189  double BSy0_;
190  double BSz0_;
191  double Beamsigmaz_;
192  double Beamdxdz_;
193  double BeamWidthX_;
194  double BeamWidthY_;
195  double wxy2_;
196 
197  // track-related quantities
198  double pt_[nMaxtracks_];
199  double p_[nMaxtracks_];
210  double eta_[nMaxtracks_];
212  double phi_[nMaxtracks_];
217  double dz_[nMaxtracks_];
218  double dxy_[nMaxtracks_];
219  double dxyBs_[nMaxtracks_];
220  double dzBs_[nMaxtracks_];
233 
237 
241 
245 
248 
250 
255 
258 
259  // histogram for sanity check
260  TH1F* h_etaMax;
261  TH1F* h_nbins;
262  TH1F* h_nLadders;
263 
264  // ---- directly histograms // ===> unbiased residuals
265 
266  // absolute residuals
267 
268  std::vector<TH1F*> a_dxyPhiResiduals;
269  std::vector<TH1F*> a_dxyEtaResiduals;
270 
271  std::vector<TH1F*> a_dxPhiResiduals;
272  std::vector<TH1F*> a_dxEtaResiduals;
273 
274  std::vector<TH1F*> a_dyPhiResiduals;
275  std::vector<TH1F*> a_dyEtaResiduals;
276 
277  std::vector<TH1F*> a_dzPhiResiduals;
278  std::vector<TH1F*> a_dzEtaResiduals;
279 
280  std::vector<TH1F*> a_IP2DPhiResiduals;
281  std::vector<TH1F*> a_IP2DEtaResiduals;
282 
283  std::vector<TH1F*> a_IP3DPhiResiduals;
284  std::vector<TH1F*> a_IP3DEtaResiduals;
285 
286  std::vector<TH1F*> a_reszPhiResiduals;
287  std::vector<TH1F*> a_reszEtaResiduals;
288 
289  std::vector<TH1F*> a_d3DPhiResiduals;
290  std::vector<TH1F*> a_d3DEtaResiduals;
291 
292  // normalized residuals
293 
294  std::vector<TH1F*> n_dxyPhiResiduals;
295  std::vector<TH1F*> n_dxyEtaResiduals;
296 
297  std::vector<TH1F*> n_dzPhiResiduals;
298  std::vector<TH1F*> n_dzEtaResiduals;
299 
300  std::vector<TH1F*> n_IP2DPhiResiduals;
301  std::vector<TH1F*> n_IP2DEtaResiduals;
302 
303  std::vector<TH1F*> n_IP3DPhiResiduals;
304  std::vector<TH1F*> n_IP3DEtaResiduals;
305 
306  std::vector<TH1F*> n_reszPhiResiduals;
307  std::vector<TH1F*> n_reszEtaResiduals;
308 
309  std::vector<TH1F*> n_d3DPhiResiduals;
310  std::vector<TH1F*> n_d3DEtaResiduals;
311 
312  // for the maps
313 
317 
321 
322  // ---- trends as function of phi and eta
323 
328 
333 
338 
343 
344  // ---- trends as a function of pT
345 
350 
355 
360 
365 
366  // --- trend as a function of the ladder/module number
367 
372 
377 
382 
387 
388  // ---- medians and MAD
389 
394 
399 
404 
409 
410  // 2D residuals
411 
412  TH2F* a_dxyVsPhi;
413  TH2F* a_dzVsPhi;
414 
415  TH2F* n_dxyVsPhi;
416  TH2F* n_dzVsPhi;
417 
418  TH2F* a_dxyVsEta;
419  TH2F* a_dzVsEta;
420 
421  TH2F* n_dxyVsEta;
422  TH2F* n_dzVsEta;
423 
424  // 2D maps
425 
427  TH2F* a_dzMeanMap;
428 
430  TH2F* n_dzMeanMap;
431 
434 
437 
438  //
439  // ---- directly histograms
440  // biased residuals
441 
442  // absolute residuals
443 
444  std::vector<TH1F*> a_dxyPhiBiasResiduals;
445  std::vector<TH1F*> a_dxyEtaBiasResiduals;
446 
447  std::vector<TH1F*> a_dzPhiBiasResiduals;
448  std::vector<TH1F*> a_dzEtaBiasResiduals;
449 
450  // normalized BiasResiduals
451 
452  std::vector<TH1F*> n_dxyPhiBiasResiduals;
453  std::vector<TH1F*> n_dxyEtaBiasResiduals;
454 
455  std::vector<TH1F*> n_dzPhiBiasResiduals;
456  std::vector<TH1F*> n_dzEtaBiasResiduals;
457 
458  // for the maps
459 
462 
465 
466  // ---- trends as function of phi / eta
467 
472 
477 
482 
487 
488  // ---- medians and MAD
489 
494 
499 
504 
509 
510  // 2D maps
511 
514 
517 
520 
523 
524  // check event
525  TH1F* h_nTracks;
526  TH1F* h_nClus;
528  TH1F* h_runNumber;
538  TH1F* h_BSx0;
539  TH1F* h_BSy0;
540  TH1F* h_BSz0;
541  TH1F* h_Beamsigmaz;
543  TH1F* h_BeamWidthY;
544 
545  // check probe
546 
549 
550  TH1F* h_probeP_;
551  TH1F* h_probePt_;
552  TH1F* h_probeEta_;
553  TH1F* h_probePhi_;
558 
561 
564 
567 
571 
579 
580  TH1F* h_probeHits_;
589 
593 
594  // check vertex
595 
603 
608 
609  std::map<std::string, TH1*> hDA;
610 
611  // histograms for the plots as function of pT
612 
613  std::vector<TH1F*> h_dxy_pT_;
614  std::vector<TH1F*> h_dz_pT_;
615  std::vector<TH1F*> h_norm_dxy_pT_;
616  std::vector<TH1F*> h_norm_dz_pT_;
617 
618  std::vector<TH1F*> h_dxy_Central_pT_;
619  std::vector<TH1F*> h_dz_Central_pT_;
620  std::vector<TH1F*> h_norm_dxy_Central_pT_;
621  std::vector<TH1F*> h_norm_dz_Central_pT_;
622 
623  // histograms for the plots as function of module ladder and number
624 
625  std::vector<TH1F*> h_dxy_modZ_;
626  std::vector<TH1F*> h_dz_modZ_;
627  std::vector<TH1F*> h_norm_dxy_modZ_;
628  std::vector<TH1F*> h_norm_dz_modZ_;
629 
630  std::vector<TH1F*> h_dxy_ladderOverlap_;
631  std::vector<TH1F*> h_dxy_ladderNoOverlap_;
632 
633  std::vector<TH1F*> h_dxy_ladder_;
634  std::vector<TH1F*> h_dz_ladder_;
635  std::vector<TH1F*> h_norm_dxy_ladder_;
636  std::vector<TH1F*> h_norm_dz_ladder_;
637 
638 };
639 
640 #endif
std::vector< TH1F * > h_norm_dxy_modZ_
type
Definition: HCALResponse.h:21
std::vector< TH1F * > n_IP3DPhiResiduals
std::vector< TH1F * > a_dxyEtaResiduals
TH1F * n_dzResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_d3DEtaResiduals
std::vector< TH1F * > n_reszPhiResiduals
std::vector< unsigned int > runControlNumbers_
static bool vtxSort(const reco::Vertex &a, const reco::Vertex &b)
void fillTrendPlot(TH1F *trendPlot, TH1F *residualsPlot[100], PVValHelper::estimator fitPar_, const std::string &var_)
std::vector< TH1F * > h_dxy_pT_
TrackFilterForPVFindingBase * theTrackFilter_
TH1F * a_dxyResidualsMap[nMaxBins_][nMaxBins_]
std::map< std::string, TH1 * > hDA
std::vector< TH1F * > a_IP3DEtaResiduals
std::vector< TH1F * > n_dzPhiResiduals
std::vector< TH1F * > a_d3DPhiResiduals
std::vector< TH1F * > n_d3DPhiResiduals
PrimaryVertexValidation(const edm::ParameterSet &)
std::vector< TH1F * > n_dxyPhiBiasResiduals
TH1F * n_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > n_d3DEtaResiduals
std::vector< TH1F * > h_norm_dz_Central_pT_
const float mypT_bins_[nPtBins_+1]
float DOFUnbiasedVertex_[nMaxtracks_]
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_]
std::vector< TH1F * > n_reszEtaResiduals
double dxyFromMyVertex_[nMaxtracks_]
virtual void endJob() override
std::map< std::string, TH1 * > bookVertexHistograms(const TFileDirectory &dir)
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)
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)
std::vector< TH1F * > n_dxyEtaResiduals
double IPTsigFromMyVertex_[nMaxtracks_]
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
std::vector< TH1F * > a_dzPhiBiasResiduals
Measurement1D getMedian(TH1F *histo)
std::vector< TH1F * > h_norm_dxy_pT_
std::vector< TH1F * > a_dzEtaResiduals
int tracksUsedForVertexing_[nMaxtracks_]
std::vector< TH1F * > a_dxyEtaBiasResiduals
virtual void beginJob() override
std::vector< TH1F * > h_norm_dxy_ladder_
std::vector< TH1F * > a_dzPhiResiduals
double yUnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > n_dxyPhiResiduals
void fillByIndex(std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
double zUnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > h_dxy_ladder_
float chi2normUnbiasedVertex_[nMaxtracks_]
TH1F * n_d3DResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_dxyPhiResiduals
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_
void shrinkHistVectorToFit(std::vector< TH1F * > &h, unsigned int desired_size)
double IPLsigFromMyVertex_[nMaxtracks_]
bool hasFirstLayerPixelHits(const reco::TransientTrack &track)
std::vector< TH1F * > n_dzEtaResiduals
std::vector< TH1F * > n_IP3DEtaResiduals
std::vector< TH1F * > h_norm_dz_pT_
void fillMap(TH2F *trendMap, TH1F *residualsMapPlot[100][100], PVValHelper::estimator fitPar_)
std::tuple< std::string, std::string, std::string > getVarString(PVValHelper::plotVariable var)
std::vector< TH1F * > h_dz_pT_
std::vector< TH1F * > n_dzEtaBiasResiduals
std::vector< TH1F * > h_dz_Central_pT_
edm::Service< TFileService > fs
bool isHit2D(const TrackingRecHit &hit) const
std::vector< TH1F * > h_dz_ladder_
std::vector< TH1F * > a_IP2DEtaResiduals
std::tuple< std::string, std::string, std::string > getTypeString(PVValHelper::residualType type)
TrackClusterizerInZ * theTrackClusterizer_
double b
Definition: hdecay.h:120
std::vector< TH1F * > n_IP2DPhiResiduals
double xUnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > h_dxy_Central_pT_
Measurement1D getMAD(TH1F *histo)
edm::EDGetTokenT< reco::BeamSpot > theBeamspotToken
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken
double dzFromMyVertex_[nMaxtracks_]
double a
Definition: hdecay.h:121
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
std::vector< TH1F * > a_reszEtaResiduals
std::vector< TH1F * > bookResidualsHistogram(const TFileDirectory &dir, unsigned int theNOfBins, PVValHelper::residualType resType, PVValHelper::plotVariable varType, bool isNormalized=false)
TH1F * a_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
std::vector< TH1F * > a_dxPhiResiduals
std::vector< TH1F * > h_norm_dz_modZ_
TH1F * n_dxyResidualsMap[nMaxBins_][nMaxBins_]
bool passesTrackCuts(const reco::Track &track, const reco::Vertex &vertex, const std::string &qualityString_, double dxyErrMax_, double dzErrMax_, double ptErrMax_)
double dxyErrorFromMyVertex_[nMaxtracks_]
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< TH1F * > a_dyEtaResiduals
std::vector< TH1F * > n_IP2DEtaResiduals
std::vector< TH1F * > h_norm_dz_ladder_
float sumOfWeightsUnbiasedVertex_[nMaxtracks_]
TH1F * n_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
double d3DErrorFromMyVertex_[nMaxtracks_]
std::vector< TH1F * > a_dyPhiResiduals
std::vector< TH1F * > h_dxy_ladderOverlap_
TH1F * a_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
PVValHelper::histodetails theDetails_
std::pair< Measurement1D, Measurement1D > fitResiduals(TH1 *hist)
TH1F * a_dzResidualsMap[nMaxBins_][nMaxBins_]
float chi2UnbiasedVertex_[nMaxtracks_]
std::vector< TH1F * > h_norm_dxy_Central_pT_
std::vector< TH1F * > a_dzEtaBiasResiduals
std::vector< TH1F * > a_IP3DPhiResiduals
std::vector< TH1F * > n_dzPhiBiasResiduals
double IP3DsigFromMyVertex_[nMaxtracks_]