CMS 3D CMS Logo

PVValidationHelpers.h
Go to the documentation of this file.
1 #ifndef ALIGNMENT_OFFLINEVALIDATION_PVVALIDATIONHELPER_H
2 #define ALIGNMENT_OFFLINEVALIDATION_PVVALIDATIONHELPER_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <cassert>
8 #include <utility>
9 #include "TH1.h"
10 
13 
14 namespace PVValHelper {
15 
16  // helper data formats
17 
18  enum estimator
19  { MEAN = 1,
20  WIDTH = 2,
21  MEDIAN = 3,
22  MAD = 4,
23  UNKWN = -1
24  };
25 
27  { dxy = 1,
28  dx = 2,
29  dy = 3,
30  dz = 4,
31  IP2D = 5,
32  resz = 6,
33  IP3D = 7,
34  d3D = 8,
35 
36  norm_dxy = 9,
37  norm_dx = 10,
38  norm_dy = 11,
39  norm_dz = 12,
40  norm_IP2D = 13,
41  norm_resz = 14,
42  norm_IP3D = 15,
43  norm_d3D = 16,
45  };
46 
48  { phi = 1,
49  eta = 2,
50  pT = 3,
51  pTCentral = 4,
52  ladder = 5,
53  modZ = 6,
55  };
56 
57  struct histodetails{
58 
59  int histobins;
60  std::map<std::pair<residualType,plotVariable>,std::pair<float,float>> range;
61  std::map<plotVariable,std::vector<float> > trendbins;
62 
63  void setMap(residualType type,plotVariable plot,float low,float high){
64  assert(low<high);
65  range[std::make_pair(type,plot)] = std::make_pair(low,high);
66  }
67 
68  std::pair<float,float> getRange(residualType type,plotVariable plot){
69  if (range.find(std::make_pair(type,plot)) != range.end()) {
70  return range[std::make_pair(type,plot)];
71  } else {
72  edm::LogWarning("PVValidationHelpers") << "Trying to get range for non-existent combination "<< std::endl;
73  return std::make_pair(0.,0.);
74  }
75  }
76 
78  if (range.find(std::make_pair(type,plot)) != range.end()) {
79  return range[std::make_pair(type,plot)].first;
80  } else {
81  edm::LogWarning("PVValidationHelpers") << "Trying to get low end of range for non-existent combination "<< std::endl;
82  return 0.;
83  }
84  }
85 
87  if (range.find(std::make_pair(type,plot)) != range.end()) {
88  return range[std::make_pair(type,plot)].second;
89  } else {
90  edm::LogWarning("PVValidationHelpers") << "Trying get high end of range for non-existent combination "<< std::endl;
91  return 0.;
92  }
93  }
94  };
95 
96  typedef std::tuple<std::string,std::string,std::string> plotLabels;
97 
98  // helper methods
99 
100  void add(std::map<std::string,TH1*>& h, TH1* hist);
101 
102  void fill(std::map<std::string, TH1*>& h,const std::string& s, double x);
103 
104  void fill(std::map<std::string, TH1*>& h,const std::string& s, double x, double y);
105 
106  void fillByIndex(std::vector<TH1F*>& h, unsigned int index, double x,std::string tag="");
107 
108  void shrinkHistVectorToFit(std::vector<TH1F*>&h, unsigned int desired_size);
109 
110  plotLabels getTypeString (residualType type);
111 
112  plotLabels getVarString (plotVariable var);
113 
114  std::vector<float> generateBins(int n, float start, float range);
115 
117 
118  Measurement1D getMAD(TH1F *histo);
119 
120  std::pair<Measurement1D, Measurement1D> fitResiduals(TH1 *hist);
121 
122 };
123 
124 #endif
Definition: start.py:1
type
Definition: HCALResponse.h:21
Measurement1D getMedian(TH1F *histo)
void fillByIndex(std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
std::tuple< std::string, std::string, std::string > plotLabels
std::pair< Measurement1D, Measurement1D > fitResiduals(TH1 *hist)
std::vector< float > generateBins(int n, float start, float range)
Measurement1D getMAD(TH1F *histo)
plotLabels getVarString(plotVariable var)
float getHigh(residualType type, plotVariable plot)
float getLow(residualType type, plotVariable plot)
std::map< plotVariable, std::vector< float > > trendbins
void setMap(residualType type, plotVariable plot, float low, float high)
std::map< std::pair< residualType, plotVariable >, std::pair< float, float > > range
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
plotLabels getTypeString(residualType type)
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::pair< float, float > getRange(residualType type, plotVariable plot)