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  void beginJob() override;
75  void analyze(const edm::Event&, const edm::EventSetup&) override;
76  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 
145  // actual number of histograms
146  int nBins_;
147 
148  // limits of the pt binned plots range
149  const double minPt_;
150  const double maxPt_;
151 
152  std::vector<unsigned int> runControlNumbers_;
153 
154  bool debug_;
156 
157  // force to use beamspot in the vertex fit
159 
163 
164  TTree* rootTree_;
165 
166  // Root-Tuple variables :
167  //=======================
168  void SetVarToZero();
169 
170  static const int nMaxtracks_ = 1000;
171  static const int cmToum = 10000;
172  static const int nPtBins_ = 48;
173 
174  unsigned int nLadders_= 20;
175  unsigned int nModZ_ = 8;
176 
177  // 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)
178 
179  // 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
180  //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.};
181 
182  std::array<float,nPtBins_+1> mypT_bins_;
183 
184  // event-related quantities
185  int nTracks_;
187  int nClus_;
189  unsigned int RunNumber_;
190  unsigned int EventNumber_;
195 
199 
200  double BSx0_;
201  double BSy0_;
202  double BSz0_;
203  double Beamsigmaz_;
204  double Beamdxdz_;
205  double BeamWidthX_;
206  double BeamWidthY_;
207  double wxy2_;
208 
209  // track-related quantities
210  double pt_[nMaxtracks_];
211  double p_[nMaxtracks_];
222  double eta_[nMaxtracks_];
224  double phi_[nMaxtracks_];
229  double dz_[nMaxtracks_];
230  double dxy_[nMaxtracks_];
231  double dxyBs_[nMaxtracks_];
232  double dzBs_[nMaxtracks_];
245 
249 
253 
257 
260 
262 
267 
270 
271  // histogram for sanity check
272  TH1F* h_etaMax;
273  TH1F* h_nbins;
274  TH1F* h_nLadders;
275  TH1F* h_pTinfo;
276 
277  // ---- directly histograms // ===> unbiased residuals
278 
279  // absolute residuals
280 
281  std::vector<TH1F*> a_dxyPhiResiduals;
282  std::vector<TH1F*> a_dxyEtaResiduals;
283 
284  std::vector<TH1F*> a_dxPhiResiduals;
285  std::vector<TH1F*> a_dxEtaResiduals;
286 
287  std::vector<TH1F*> a_dyPhiResiduals;
288  std::vector<TH1F*> a_dyEtaResiduals;
289 
290  std::vector<TH1F*> a_dzPhiResiduals;
291  std::vector<TH1F*> a_dzEtaResiduals;
292 
293  std::vector<TH1F*> a_IP2DPhiResiduals;
294  std::vector<TH1F*> a_IP2DEtaResiduals;
295 
296  std::vector<TH1F*> a_IP3DPhiResiduals;
297  std::vector<TH1F*> a_IP3DEtaResiduals;
298 
299  std::vector<TH1F*> a_reszPhiResiduals;
300  std::vector<TH1F*> a_reszEtaResiduals;
301 
302  std::vector<TH1F*> a_d3DPhiResiduals;
303  std::vector<TH1F*> a_d3DEtaResiduals;
304 
305  // normalized residuals
306 
307  std::vector<TH1F*> n_dxyPhiResiduals;
308  std::vector<TH1F*> n_dxyEtaResiduals;
309 
310  std::vector<TH1F*> n_dzPhiResiduals;
311  std::vector<TH1F*> n_dzEtaResiduals;
312 
313  std::vector<TH1F*> n_IP2DPhiResiduals;
314  std::vector<TH1F*> n_IP2DEtaResiduals;
315 
316  std::vector<TH1F*> n_IP3DPhiResiduals;
317  std::vector<TH1F*> n_IP3DEtaResiduals;
318 
319  std::vector<TH1F*> n_reszPhiResiduals;
320  std::vector<TH1F*> n_reszEtaResiduals;
321 
322  std::vector<TH1F*> n_d3DPhiResiduals;
323  std::vector<TH1F*> n_d3DEtaResiduals;
324 
325  // for the maps
326 
330 
334 
335  // ---- trends as function of phi and eta
336 
341 
346 
351 
356 
357  // ---- trends as a function of pT
358 
363 
368 
373 
378 
379  // --- trend as a function of the ladder/module number
380 
385 
390 
395 
400 
401  // ---- medians and MAD
402 
407 
412 
417 
422 
423  // 2D residuals
424 
425  TH2F* a_dxyVsPhi;
426  TH2F* a_dzVsPhi;
427 
428  TH2F* n_dxyVsPhi;
429  TH2F* n_dzVsPhi;
430 
431  TH2F* a_dxyVsEta;
432  TH2F* a_dzVsEta;
433 
434  TH2F* n_dxyVsEta;
435  TH2F* n_dzVsEta;
436 
437  // 2D maps
438 
440  TH2F* a_dzMeanMap;
441 
443  TH2F* n_dzMeanMap;
444 
447 
450 
451  //
452  // ---- directly histograms
453  // biased residuals
454 
455  // absolute residuals
456 
457  std::vector<TH1F*> a_dxyPhiBiasResiduals;
458  std::vector<TH1F*> a_dxyEtaBiasResiduals;
459 
460  std::vector<TH1F*> a_dzPhiBiasResiduals;
461  std::vector<TH1F*> a_dzEtaBiasResiduals;
462 
463  // normalized BiasResiduals
464 
465  std::vector<TH1F*> n_dxyPhiBiasResiduals;
466  std::vector<TH1F*> n_dxyEtaBiasResiduals;
467 
468  std::vector<TH1F*> n_dzPhiBiasResiduals;
469  std::vector<TH1F*> n_dzEtaBiasResiduals;
470 
471  // for the maps
472 
475 
478 
479  // ---- trends as function of phi / eta
480 
485 
490 
495 
500 
501  // ---- medians and MAD
502 
507 
512 
517 
522 
523  // 2D maps
524 
527 
530 
533 
536 
537  // check event
538  TH1F* h_nTracks;
539  TH1F* h_nClus;
541  TH1F* h_runNumber;
551  TH1F* h_BSx0;
552  TH1F* h_BSy0;
553  TH1F* h_BSz0;
554  TH1F* h_Beamsigmaz;
556  TH1F* h_BeamWidthY;
557 
558  // check probe
559 
562 
563  TH1F* h_probeP_;
564  TH1F* h_probePt_;
566  TH1F* h_probeEta_;
567  TH1F* h_probePhi_;
572 
575 
578 
581 
585 
593 
594  TH1F* h_probeHits_;
603 
607 
608  // check vertex
609 
617 
622 
623  std::map<std::string, TH1*> hDA;
624 
625  // histograms for the plots as function of pT
626 
627  std::vector<TH1F*> h_dxy_pT_;
628  std::vector<TH1F*> h_dz_pT_;
629  std::vector<TH1F*> h_norm_dxy_pT_;
630  std::vector<TH1F*> h_norm_dz_pT_;
631 
632  std::vector<TH1F*> h_dxy_Central_pT_;
633  std::vector<TH1F*> h_dz_Central_pT_;
634  std::vector<TH1F*> h_norm_dxy_Central_pT_;
635  std::vector<TH1F*> h_norm_dz_Central_pT_;
636 
637  // histograms for the plots as function of module ladder and number
638 
639  std::vector<TH1F*> h_dxy_modZ_;
640  std::vector<TH1F*> h_dz_modZ_;
641  std::vector<TH1F*> h_norm_dxy_modZ_;
642  std::vector<TH1F*> h_norm_dz_modZ_;
643 
644  std::vector<TH1F*> h_dxy_ladderOverlap_;
645  std::vector<TH1F*> h_dxy_ladderNoOverlap_;
646 
647  std::vector<TH1F*> h_dxy_ladder_;
648  std::vector<TH1F*> h_dz_ladder_;
649  std::vector<TH1F*> h_norm_dxy_ladder_;
650  std::vector<TH1F*> h_norm_dz_ladder_;
651 
652 };
653 
654 #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_
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_]
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
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
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_]
std::array< float, nPtBins_+1 > mypT_bins_
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_]