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