16 hist->StatOverflows(kTRUE);
23 if (
h.count(
s) == 0) {
24 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram named " <<
s << std::endl;
34 if (
h.count(
s) == 0) {
35 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram named " <<
s << std::endl;
49 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram with index " <<
index 50 <<
" for array with size: " <<
h.size() <<
" tag: " <<
tag << std::endl;
59 h.erase(
h.begin() + desired_size,
h.end());
71 returnType = std::make_tuple(
"dxy",
"d_{xy}",
"[#mum]");
74 returnType = std::make_tuple(
"dx",
"d_{x}",
"[#mum]");
77 returnType = std::make_tuple(
"dy",
"d_{y}",
"[#mum]");
80 returnType = std::make_tuple(
"dz",
"d_{z}",
"[#mum]");
83 returnType = std::make_tuple(
"IP2D",
"IP_{2D}",
"[#mum]");
86 returnType = std::make_tuple(
"resz",
"z_{trk}-z_{vtx}",
"[#mum]");
89 returnType = std::make_tuple(
"IP3D",
"IP_{3D}",
"[#mum]");
92 returnType = std::make_tuple(
"d3D",
"d_{3D}",
"[#mum]");
98 returnType = std::make_tuple(
"norm_dxy",
"d_{xy}/#sigma_{d_{xy}}",
"");
101 returnType = std::make_tuple(
"norm_dx",
"d_{x}/#sigma_{d_{x}}",
"");
104 returnType = std::make_tuple(
"norm_dy",
"d_{y}/#sigma_{d_{y}}",
"");
107 returnType = std::make_tuple(
"norm_dz",
"d_{z}/#sigma_{d_{z}}",
"");
110 returnType = std::make_tuple(
"norm_IP2D",
"IP_{2D}/#sigma_{IP_{2D}}",
"");
113 returnType = std::make_tuple(
"norm_resz",
"z_{trk}-z_{vtx}/#sigma_{res_{z}}",
"");
116 returnType = std::make_tuple(
"norm_IP3D",
"IP_{3D}/#sigma_{IP_{3D}}",
"");
119 returnType = std::make_tuple(
"norm_d3D",
"d_{3D}/#sigma_{d_{3D}}",
"");
123 edm::LogWarning(
"PVValidationHelpers") <<
" getTypeString() unknown residual type: " <<
type << std::endl;
136 returnVar = std::make_tuple(
"phi",
"#phi",
"[rad]");
139 returnVar = std::make_tuple(
"eta",
"#eta",
"");
142 returnVar = std::make_tuple(
"pT",
"p_{T}",
"[GeV]");
145 returnVar = std::make_tuple(
"pTCentral",
"p_{T} |#eta|<1.",
"[GeV]");
148 returnVar = std::make_tuple(
"ladder",
"ladder number",
"");
151 returnVar = std::make_tuple(
"modZ",
"module number",
"");
154 edm::LogWarning(
"PVValidationHelpers") <<
" getVarString() unknown plot variable: " <<
var << std::endl;
164 std::vector<float>
v(
n);
166 std::iota(
v.begin(),
v.end(), 1.);
186 if (
histo->Integral() != 0) {
201 double x_lastBin =
histo->GetBinLowEdge(
nbins + 1);
205 TH1F* newHisto =
new TH1F(Finalname.c_str(), Finalname.c_str(),
nbins, 0., x_lastBin);
206 double* residuals =
new double[
nbins];
211 newHisto->Fill(residuals[
j],
weights[
j]);
218 newHisto->Delete(
"");
229 if (
hist->GetEntries() < 1) {
234 float sigma =
hist->GetRMS();
236 TF1
func(
"tmp",
"gaus",
mean - 1.5 * sigma,
mean + 1.5 * sigma);
239 sigma =
func.GetParameter(2);
244 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
245 if (
hist->GetFunction(
func.GetName())) {
246 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
251 float res_mean =
func.GetParameter(1);
252 float res_width =
func.GetParameter(2);
254 float res_mean_err =
func.GetParError(1);
255 float res_width_err =
func.GetParError(2);
260 std::pair<Measurement1D, Measurement1D>
result;
262 result = std::make_pair(resultM, resultW);
Measurement1D getMedian(TH1F *histo)
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)
edm::TypeWithDict returnType(const edm::FunctionWithDict &)
Abs< T >::type abs(const T &t)
void fill(std::map< std::string, TH1 *> &h, const std::string &s, double x)
void shrinkHistVectorToFit(std::vector< TH1F *> &h, unsigned int desired_size)
plotLabels getTypeString(residualType type)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
std::tuple< std::string, std::string, std::string > plotLabels
Log< level::Warning, false > LogWarning
void fillByIndex(std::vector< TH1F *> &h, unsigned int index, double x, std::string tag="")
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.