ATLAS Offline Software
Functions
TFCSPCAEnergyParametrization.cxx File Reference
#include "CLHEP/Random/RandGaussZiggurat.h"
#include "CLHEP/Random/RandFlat.h"
#include "ISF_FastCaloSimEvent/TFCSPCAEnergyParametrization.h"
#include "ISF_FastCaloSimEvent/FastCaloSim_CaloCell_ID.h"
#include "ISF_FastCaloSimEvent/TFCSSimulationState.h"
#include "ISF_FastCaloSimEvent/TFCSExtrapolationState.h"
#include "TFile.h"
#include "TKey.h"
#include "TClass.h"
#include "TMatrixD.h"
#include "TMatrixDSymEigen.h"
#include "TMath.h"
#include "TH1.h"
#include "CxxUtils/restrict.h"

Go to the source code of this file.

Functions

float interpolate_get_y (TH1 *hist, float x)
 

Function Documentation

◆ interpolate_get_y()

float interpolate_get_y ( TH1 *  hist,
float  x 
)

Definition at line 68 of file TFCSPCAEnergyParametrization.cxx.

68  {
69  float m = 0;
70  float n = 0;
71  float x1 = 1;
72  float x2 = 0;
73  float y1 = 0;
74  float y2 = 0;
75  if (x <= hist->GetBinCenter(1))
76  return hist->GetBinContent(1);
77  if (x >= hist->GetBinCenter(hist->GetNbinsX()))
78  return hist->GetBinContent(hist->GetNbinsX());
79 
80  int bin = hist->FindBin(x);
81  // is x above the bin center -> interpolate with next bin
82  if (x > hist->GetBinCenter(bin)) {
83  x1 = hist->GetBinCenter(bin);
84  y1 = hist->GetBinContent(bin);
85  x2 = hist->GetBinCenter(bin + 1);
86  y2 = hist->GetBinContent(bin + 1);
87  }
88 
89  // is x below bin center -> interpolate with previous bin
90  if (x <= hist->GetBinCenter(bin)) {
91  x1 = hist->GetBinCenter(bin - 1);
92  y1 = hist->GetBinContent(bin - 1);
93  x2 = hist->GetBinCenter(bin);
94  y2 = hist->GetBinContent(bin);
95  }
96 
97  m = (y1 - y2) / (x1 - x2);
98  n = y2 - m * x2;
99  return m * x + n;
100 }
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
plotmaker.hist
hist
Definition: plotmaker.py:148
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
bin
Definition: BinsDiffFromStripMedian.h:43
x
#define x
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
beamspotman.n
n
Definition: beamspotman.py:731
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18