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
55 
56 //
57 // class decleration
58 //
59 
60 class PrimaryVertexValidation : public edm::one::EDAnalyzer<edm::one::SharedResources> {
61 
62  public:
65 
66  private:
67  virtual void beginJob();
68  virtual void analyze(const edm::Event&, const edm::EventSetup&);
69  virtual void endJob();
70  bool isHit2D(const TrackingRecHit &hit) const;
72  std::pair<bool,bool> pixelHitsCheck(const reco::TransientTrack track);
73  std::pair<Double_t,Double_t> getMedian(TH1F *histo);
74  std::pair<Double_t,Double_t> getMAD(TH1F *histo);
75  std::pair<std::pair<Double_t,Double_t>, std::pair<Double_t,Double_t> > fitResiduals(TH1 *hist);
76  void fillTrendPlot(TH1F* trendPlot, TH1F *residualsPlot[100], TString fitPar_, TString var_);
77  static bool vtxSort( const reco::Vertex & a, const reco::Vertex & b );
78  bool passesTrackCuts(const reco::Track & track, const reco::Vertex & vertex,std::string qualityString_, double dxyErrMax_,double dzErrMax_, double ptErrMax_);
79  std::map<std::string, TH1*> bookVertexHistograms(TFileDirectory dir);
80  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);
81  void add(std::map<std::string, TH1*>& h, TH1* hist);
82  void fill(std::map<std::string, TH1*>& h, std::string s, double x);
83  void fill(std::map<std::string, TH1*>& h, std::string s, double x, double y);
84  void fillMap(TH2F* trendMap, TH1F* residualsMapPlot[100][100], TString fitPar_);
85 
86  inline double square(double x){
87  return x*x;
88  }
89 
90  // ----------member data ---------------------------
92  int Nevt_;
93 
96 
97  // setting of the number of plots
98  static const int nMaxBins_ = 100; // maximum number of bookable histograms
99 
100  // Output
102  bool lightNtupleSwitch_; // switch to keep only info for daily validation
104 
105  // requirements on the vertex
106  double vertexZMax_;
107 
108  // requirements on the probe
109  bool askFirstLayerHit_; // ask hit in the first layer of pixels
110  bool doBPix_;
111  bool doFPix_;
112  double ptOfProbe_;
113  double etaOfProbe_;
114  bool isPhase1_;
115  int nBins_; // actual number of histograms
116  std::vector<unsigned int> runControlNumbers_;
117 
118  bool debug_;
120 
124 
125  TTree* rootTree_;
126 
127  // Root-Tuple variables :
128  //=======================
129  void SetVarToZero();
130 
131  static const int nMaxtracks_ = 1000;
132  static const int cmToum = 10000;
133 
134  float phiSect_;
135  float etaSect_;
136 
137  // event-related quantities
138  int nTracks_;
140  int nClus_;
142  unsigned int RunNumber_;
143  unsigned int EventNumber_;
148 
152 
153  double BSx0_;
154  double BSy0_;
155  double BSz0_;
156  double Beamsigmaz_;
157  double Beamdxdz_;
158  double BeamWidthX_;
159  double BeamWidthY_;
160  double wxy2_;
161 
162  // track-related quantities
163  double pt_[nMaxtracks_];
164  double p_[nMaxtracks_];
175  double eta_[nMaxtracks_];
177  double phi_[nMaxtracks_];
182  double dz_[nMaxtracks_];
183  double dxy_[nMaxtracks_];
184  double dxyBs_[nMaxtracks_];
185  double dzBs_[nMaxtracks_];
198 
202 
206 
210 
213 
214  // histogram for max(eta)
215  TH1F* h_etaMax;
216  TH1F* h_nbins;
217 
218  // ---- directly histograms // ===> unbiased residuals
219 
220  // absolute residuals
221 
224 
227 
230 
233 
236 
239 
242 
245 
246  // normalized residuals
247 
250 
253 
256 
259 
262 
265 
266  // for the maps
267 
271 
275 
276  // ---- trends as function of phi
277 
282 
287 
292 
297 
298  // ---- medians and MAD
299 
304 
309 
314 
319 
320  // 2D residuals
321 
322  TH2F* a_dxyVsPhi;
323  TH2F* a_dzVsPhi;
324 
325  TH2F* n_dxyVsPhi;
326  TH2F* n_dzVsPhi;
327 
328  TH2F* a_dxyVsEta;
329  TH2F* a_dzVsEta;
330 
331  TH2F* n_dxyVsEta;
332  TH2F* n_dzVsEta;
333 
334  // 2D maps
335 
337  TH2F* a_dzMeanMap;
338 
340  TH2F* n_dzMeanMap;
341 
344 
347 
348  // ---- directly histograms =================> biased residuals
349 
350  // absolute residuals
351 
354 
357 
358  // normalized BiasResiduals
359 
362 
365 
366  // for the maps
367 
370 
373 
374  // ---- trends as function of phi
375 
380 
385 
390 
395 
396  // ---- medians and MAD
397 
402 
407 
412 
417 
418  // 2D maps
419 
422 
425 
428 
431 
432  // check event
433  TH1F* h_nTracks;
434  TH1F* h_nClus;
436  TH1F* h_runNumber;
443  TH1F* h_BSx0;
444  TH1F* h_BSy0;
445  TH1F* h_BSz0;
446  TH1F* h_Beamsigmaz;
448  TH1F* h_BeamWidthY;
449 
450  // check probe
451 
454 
455  TH1F* h_probeP_;
456  TH1F* h_probePt_;
457  TH1F* h_probeEta_;
458  TH1F* h_probePhi_;
463 
466 
469 
472 
476 
484 
485  TH1F* h_probeHits_;
494 
495  // check vertex
496 
504 
509 
510  std::map<std::string, TH1*> hDA;
511 
512 };
513 
514 #endif
TH1F * n_dzResidualsMap[nMaxBins_][nMaxBins_]
TH1F * a_IP3DEtaResiduals[nMaxBins_]
std::vector< unsigned int > runControlNumbers_
static bool vtxSort(const reco::Vertex &a, const reco::Vertex &b)
TH1F * n_IP2DPhiResiduals[nMaxBins_]
TrackFilterForPVFindingBase * theTrackFilter_
TH1F * a_dxyResidualsMap[nMaxBins_][nMaxBins_]
std::map< std::string, TH1 * > hDA
TH1F * n_dxyEtaBiasResiduals[nMaxBins_]
PrimaryVertexValidation(const edm::ParameterSet &)
std::pair< Double_t, Double_t > getMAD(TH1F *histo)
TH1F * n_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
float DOFUnbiasedVertex_[nMaxtracks_]
TH1F * a_dzPhiBiasResiduals[nMaxBins_]
bool passesTrackCuts(const reco::Track &track, const reco::Vertex &vertex, std::string qualityString_, double dxyErrMax_, double dzErrMax_, double ptErrMax_)
double d3DFromMyVertex_[nMaxtracks_]
TH1F * n_dzEtaBiasResiduals[nMaxBins_]
virtual void analyze(const edm::Event &, const edm::EventSetup &)
float chi2ProbUnbiasedVertex_[nMaxtracks_]
double dxyFromMyVertex_[nMaxtracks_]
double dzErrorFromMyVertex_[nMaxtracks_]
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)
TH1F * a_dxyPhiBiasResiduals[nMaxBins_]
double IPTsigFromMyVertex_[nMaxtracks_]
std::pair< Double_t, Double_t > getMedian(TH1F *histo)
void fillMap(TH2F *trendMap, TH1F *residualsMapPlot[100][100], TString fitPar_)
TH1F * a_IP2DEtaResiduals[nMaxBins_]
int tracksUsedForVertexing_[nMaxtracks_]
TH1F * n_IP2DEtaResiduals[nMaxBins_]
std::pair< bool, bool > pixelHitsCheck(const reco::TransientTrack track)
bool hasFirstLayerPixelHits(const reco::TransientTrack track)
TH1F * n_reszEtaResiduals[nMaxBins_]
TH1F * n_dzPhiBiasResiduals[nMaxBins_]
double yUnbiasedVertex_[nMaxtracks_]
std::pair< std::pair< Double_t, Double_t >, std::pair< Double_t, Double_t > > fitResiduals(TH1 *hist)
TH1F * n_IP3DEtaResiduals[nMaxBins_]
double zUnbiasedVertex_[nMaxtracks_]
TH1F * a_reszPhiResiduals[nMaxBins_]
float chi2normUnbiasedVertex_[nMaxtracks_]
TH1F * n_d3DResidualsMap[nMaxBins_][nMaxBins_]
edm::EDGetTokenT< reco::VertexCollection > theVertexCollectionToken
TH1F * a_d3DResidualsMap[nMaxBins_][nMaxBins_]
double IPLsigFromMyVertex_[nMaxtracks_]
TH1F * a_IP2DPhiResiduals[nMaxBins_]
bool isHit2D(const TrackingRecHit &hit) const
TH1F * n_dxyPhiBiasResiduals[nMaxBins_]
TrackClusterizerInZ * theTrackClusterizer_
double b
Definition: hdecay.h:120
double xUnbiasedVertex_[nMaxtracks_]
TH1F * a_dxyEtaBiasResiduals[nMaxBins_]
edm::EDGetTokenT< reco::BeamSpot > theBeamspotToken
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken
double dzFromMyVertex_[nMaxtracks_]
TH1F * n_IP3DPhiResiduals[nMaxBins_]
double a
Definition: hdecay.h:121
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
void fill(std::map< std::string, TH1 * > &h, std::string s, double x)
TH1F * a_reszEtaResiduals[nMaxBins_]
TH1F * a_dxyBiasResidualsMap[nMaxBins_][nMaxBins_]
TH1F * a_IP3DPhiResiduals[nMaxBins_]
TH1F * n_dxyResidualsMap[nMaxBins_][nMaxBins_]
double dxyErrorFromMyVertex_[nMaxtracks_]
dbl *** dir
Definition: mlp_gen.cc:35
TH1F * n_reszPhiResiduals[nMaxBins_]
float sumOfWeightsUnbiasedVertex_[nMaxtracks_]
TH1F * n_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
double d3DErrorFromMyVertex_[nMaxtracks_]
TH1F * a_dzBiasResidualsMap[nMaxBins_][nMaxBins_]
TH1F * a_dzEtaBiasResiduals[nMaxBins_]
void fillTrendPlot(TH1F *trendPlot, TH1F *residualsPlot[100], TString fitPar_, TString var_)
TH1F * a_dzResidualsMap[nMaxBins_][nMaxBins_]
float chi2UnbiasedVertex_[nMaxtracks_]
std::map< std::string, TH1 * > bookVertexHistograms(TFileDirectory dir)
double IP3DsigFromMyVertex_[nMaxtracks_]