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 
11 #ifndef PLOTTING_MACRO
13 #define COUT edm::LogWarning("PVValidationHelpers")
14 #else
15 #include <iostream>
16 #define COUT std::cout << "PVValidationHelpers: "
17 #endif
18 
20 
21 namespace PVValHelper {
22 
23  const double max_eta_phase0 = 2.5;
24  const double max_eta_phase1 = 2.7;
25 
26  // helper logarithmic bin generator
27 
28  template <typename T, size_t N>
29  std::array<T, N + 1> makeLogBins(const T& min, const T& max) {
30  const T minLog10 = std::log10(min);
31  const T maxLog10 = std::log10(max);
32  const T width = (maxLog10 - minLog10) / N;
33  std::array<T, N + 1> ret;
34  ret[0] = std::pow(10, minLog10);
35  const T mult = std::pow(10, width);
36  for (size_t i = 1; i <= N; ++i) {
37  ret[i] = ret[i - 1] * mult;
38  }
39  return ret;
40  }
41 
42  // helper data formats
43 
44  enum estimator { MEAN = 1, WIDTH = 2, MEDIAN = 3, MAD = 4, UNKWN = -1 };
45 
46  enum residualType {
47  dxy = 1,
48  dx = 2,
49  dy = 3,
50  dz = 4,
51  IP2D = 5,
52  resz = 6,
53  IP3D = 7,
54  d3D = 8,
55 
56  norm_dxy = 9,
57  norm_dx = 10,
58  norm_dy = 11,
59  norm_dz = 12,
60  norm_IP2D = 13,
61  norm_resz = 14,
62  norm_IP3D = 15,
63  norm_d3D = 16,
65  };
66 
67  enum plotVariable {
68  phi = 1,
69  eta = 2,
70  pT = 3,
71  pTCentral = 4,
72  ladder = 5,
73  modZ = 6,
75  };
76 
77  struct histodetails {
78  int histobins;
79  std::map<std::pair<residualType, plotVariable>, std::pair<float, float>> range;
80  std::map<plotVariable, std::vector<float>> trendbins;
81 
82  void setMap(residualType type, plotVariable plot, float low, float high) {
83  assert(low < high);
84  range[std::make_pair(type, plot)] = std::make_pair(low, high);
85  }
86 
87  std::pair<float, float> getRange(residualType type, plotVariable plot) {
88  if (range.find(std::make_pair(type, plot)) != range.end()) {
89  return range[std::make_pair(type, plot)];
90  } else {
91  COUT << "Trying to get range for non-existent combination " << std::endl;
92  return std::make_pair(0., 0.);
93  }
94  }
95 
97  if (range.find(std::make_pair(type, plot)) != range.end()) {
98  return range[std::make_pair(type, plot)].first;
99  } else {
100  COUT << "Trying to get low end of range for non-existent combination " << std::endl;
101  return 0.;
102  }
103  }
104 
106  if (range.find(std::make_pair(type, plot)) != range.end()) {
107  return range[std::make_pair(type, plot)].second;
108  } else {
109  COUT << "Trying get high end of range for non-existent combination " << std::endl;
110  return 0.;
111  }
112  }
113  };
114 
115  typedef std::tuple<std::string, std::string, std::string> plotLabels;
116 
117  // helper methods
118 
119  void add(std::map<std::string, TH1*>& h, TH1* hist);
120 
121  void fill(std::map<std::string, TH1*>& h, const std::string& s, double x);
122 
123  void fill(std::map<std::string, TH1*>& h, const std::string& s, double x, double y);
124 
125  void fillByIndex(std::vector<TH1F*>& h, unsigned int index, double x, std::string tag = "");
126 
127  void shrinkHistVectorToFit(std::vector<TH1F*>& h, unsigned int desired_size);
128 
130 
132 
133  std::vector<float> generateBins(int n, float start, float range);
134 
136 
137  Measurement1D getMAD(TH1F* histo);
138 
139  std::pair<Measurement1D, Measurement1D> fitResiduals(TH1* hist);
140 
141 }; // namespace PVValHelper
142 
143 #endif
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
PVValHelper::getVarString
plotLabels getVarString(plotVariable var)
Definition: PVValidationHelpers.cc:130
PVValHelper::histodetails
Definition: PVValidationHelpers.h:77
PVValHelper::resz
Definition: PVValidationHelpers.h:52
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
PVValHelper::max_eta_phase1
const double max_eta_phase1
Definition: PVValidationHelpers.h:24
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PVValHelper::norm_IP2D
Definition: PVValidationHelpers.h:60
PVValHelper::WIDTH
Definition: PVValidationHelpers.h:44
min
T min(T a, T b)
Definition: MathUtil.h:58
PVValHelper::fill
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
Definition: PVValidationHelpers.cc:20
PVValHelper::getTypeString
plotLabels getTypeString(residualType type)
Definition: PVValidationHelpers.cc:63
Measurement1D.h
PVValHelper::fillByIndex
void fillByIndex(std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
Definition: PVValidationHelpers.cc:42
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cms::cuda::assert
assert(be >=bs)
PVValHelper::histodetails::histobins
int histobins
Definition: PVValidationHelpers.h:78
PVValHelper::plotVariable
plotVariable
Definition: PVValidationHelpers.h:67
plotFactory.plot
plot
Definition: plotFactory.py:109
PVValHelper::END_OF_TYPES
Definition: PVValidationHelpers.h:64
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
PVValHelper::norm_resz
Definition: PVValidationHelpers.h:61
alignCSCRings.s
s
Definition: alignCSCRings.py:92
PVValHelper::UNKWN
Definition: PVValidationHelpers.h:44
PVValHelper::histodetails::trendbins
std::map< plotVariable, std::vector< float > > trendbins
Definition: PVValidationHelpers.h:80
PVValHelper::norm_d3D
Definition: PVValidationHelpers.h:63
PVValHelper::estimator
estimator
Definition: PVValidationHelpers.h:44
compare.hist
hist
Definition: compare.py:376
PVValHelper::max_eta_phase0
const double max_eta_phase0
Definition: PVValidationHelpers.h:23
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PVValHelper::makeLogBins
std::array< T, N+1 > makeLogBins(const T &min, const T &max)
Definition: PVValidationHelpers.h:29
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PVValHelper::pT
Definition: PVValidationHelpers.h:70
PVValHelper::pTCentral
Definition: PVValidationHelpers.h:71
N
#define N
Definition: blowfish.cc:9
PVValHelper::histodetails::getHigh
float getHigh(residualType type, plotVariable plot)
Definition: PVValidationHelpers.h:105
PVValHelper::modZ
Definition: PVValidationHelpers.h:73
PVValHelper::norm_dxy
Definition: PVValidationHelpers.h:56
h
PVValHelper::END_OF_PLOTS
Definition: PVValidationHelpers.h:74
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PVValHelper::norm_dx
Definition: PVValidationHelpers.h:57
PVValHelper::getMedian
Measurement1D getMedian(TH1F *histo)
Definition: PVValidationHelpers.cc:178
PVValHelper::IP3D
Definition: PVValidationHelpers.h:53
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
PVValHelper::MAD
Definition: PVValidationHelpers.h:44
PVValHelper::norm_IP3D
Definition: PVValidationHelpers.h:62
PVValHelper::residualType
residualType
Definition: PVValidationHelpers.h:46
PVValHelper::dy
Definition: PVValidationHelpers.h:49
PVValHelper::norm_dy
Definition: PVValidationHelpers.h:58
PVValHelper::histodetails::getLow
float getLow(residualType type, plotVariable plot)
Definition: PVValidationHelpers.h:96
PVValHelper::generateBins
std::vector< float > generateBins(int n, float start, float range)
Definition: PVValidationHelpers.cc:161
PVValHelper::MEAN
Definition: PVValidationHelpers.h:44
PVValHelper::d3D
Definition: PVValidationHelpers.h:54
COUT
#define COUT
Definition: PVValidationHelpers.h:13
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
PVValHelper::dxy
Definition: PVValidationHelpers.h:47
PVValHelper::dz
Definition: PVValidationHelpers.h:50
T
long double T
Definition: Basic3DVectorLD.h:48
PVValHelper::MEDIAN
Definition: PVValidationHelpers.h:44
PVValHelper::getMAD
Measurement1D getMAD(TH1F *histo)
Definition: PVValidationHelpers.cc:194
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
PVValHelper
Definition: PVValidationHelpers.h:21
VarParsing.mult
mult
Definition: VarParsing.py:659
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
PVValHelper::histodetails::getRange
std::pair< float, float > getRange(residualType type, plotVariable plot)
Definition: PVValidationHelpers.h:87
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
PVValHelper::histodetails::setMap
void setMap(residualType type, plotVariable plot, float low, float high)
Definition: PVValidationHelpers.h:82
PVValHelper::histodetails::range
std::map< std::pair< residualType, plotVariable >, std::pair< float, float > > range
Definition: PVValidationHelpers.h:79
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
PVValHelper::dx
Definition: PVValidationHelpers.h:48
PVValHelper::plotLabels
std::tuple< std::string, std::string, std::string > plotLabels
Definition: PVValidationHelpers.h:115
PVValHelper::IP2D
Definition: PVValidationHelpers.h:51
PVValHelper::shrinkHistVectorToFit
void shrinkHistVectorToFit(std::vector< TH1F * > &h, unsigned int desired_size)
Definition: PVValidationHelpers.cc:56
PVValHelper::norm_dz
Definition: PVValidationHelpers.h:59
PVValHelper::fitResiduals
std::pair< Measurement1D, Measurement1D > fitResiduals(TH1 *hist)
Definition: PVValidationHelpers.cc:223