15 h[hist->GetName()]=
hist;
16 hist->StatOverflows(kTRUE);
24 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram named " << s << std::endl;
35 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram named " << s << std::endl;
46 if(index <= h.size()){
49 edm::LogWarning(
"PVValidationHelpers") <<
"Trying to fill non-existing Histogram with index " << index <<
" for array with size: "<<h.size()<<
" tag: "<< tag<< std::endl;
58 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;
138 returnVar = std::make_tuple(
"phi",
"#phi",
"[rad]");
141 returnVar = std::make_tuple(
"eta",
"#eta",
"");
144 returnVar = std::make_tuple(
"pT",
"p_{T}",
"[GeV]");
147 returnVar = std::make_tuple(
"pTCentral",
"p_{T} |#eta|<1.",
"[GeV]");
150 returnVar = std::make_tuple(
"ladder",
"ladder number",
"");
153 returnVar = std::make_tuple(
"modZ",
"module number",
"");
156 edm::LogWarning(
"PVValidationHelpers") <<
" getVarString() unknown plot variable: "<<var<<std::endl;
168 std::vector<float>
v(n);
169 float interval = range/(n-1);
170 std::iota(v.begin(),v.end(),1.);
176 std::for_each(
begin(v),
end(v), [&](
float&
a) { a = start+((a-1)*interval); });
189 if(histo->Integral()!=0){
190 histo->GetQuantiles(1, &median, &q);
204 int nbins = histo->GetNbinsX();
206 double x_lastBin = histo->GetBinLowEdge(nbins+1);
209 Finalname.append(HistoName);
210 TH1F *newHisto =
new TH1F(Finalname.c_str(),Finalname.c_str(),
nbins,0.,x_lastBin);
211 double *residuals =
new double[
nbins];
212 const float *
weights = histo->GetArray();
214 for (
int j = 0; j <
nbins; j++) {
215 residuals[j] =
std::abs(median - histo->GetBinCenter(j+1));
216 newHisto->Fill(residuals[j],weights[j]);
221 delete[] residuals; residuals=
nullptr;
222 newHisto->Delete(
"");
236 float mean = hist->GetMean();
237 float sigma = hist->GetRMS();
239 TF1
func(
"tmp",
"gaus", mean - 1.5*sigma, mean + 1.5*sigma);
240 if (0 == hist->Fit(&func,
"QNR")) {
241 mean = func.GetParameter(1);
242 sigma = func.GetParameter(2);
244 func.SetRange(mean - 2*sigma, mean + 2*sigma);
247 if (0 == hist->Fit(&func,
"Q0LR")) {
248 if (hist->GetFunction(func.GetName())) {
249 hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
254 float res_mean = func.GetParameter(1);
255 float res_width = func.GetParameter(2);
257 float res_mean_err = func.GetParError(1);
258 float res_width_err = func.GetParError(2);
263 std::pair<Measurement1D, Measurement1D>
result;
265 result = std::make_pair(resultM,resultW);
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)
edm::TypeWithDict returnType(const edm::FunctionWithDict &func)
Abs< T >::type abs(const T &t)
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)