92 cout <<
"pointeur histogramme nul" << endl;
168 cout <<
"pointeur histogramme nul" << endl;
252 Bool_t fixed_bins = (nx != -1);
291 if (!gg)
return nullptr;
300 Double_t Xbin_width_corr = 1.0, Ybin_width_corr = 1.0;
304 Xbin_width_corr = orig_Xbin_width / new_Xbin_width;
309 Ybin_width_corr = orig_Ybin_width / new_Ybin_width;
317 if (abs == bmax) abs = bmin;
319 if (fx) resx = fx->
Eval(abs);
326 if (abs == bmax) abs = bmin;
328 if (fy) resy = fy->
Eval(abs);
331 hh->
GetBinContent(xx, yy)*Xbin_width_corr * Ybin_width_corr);
342 for (
int i = 0; i < nmax; i++) {
345 gg->
Fill(resx, Xbin_width_corr);
352 if (fy) resy = fy->
Eval(resy);
388 if (!gg)
return nullptr;
394 for (
Int_t nn = 0; nn < np; nn += 1) {
398 if (fx) xx2 = fx->
Eval(xx1);
400 if (fy) yy2 = fy->
Eval(yy1);
433 cout <<
"pointeur histogramme nul" << endl;
439 TF1 fx(
"fx", expression.
Data());
443 fy.reset(
new TF1(
"fy", expression.
Data()));
469 cout <<
"pointeur histogramme nul" << endl;
475 TF1 fx(
"fx", expression.
Data());
476 TH2* gg = (
TH2*)ScaleHisto(hh, &fx,
nullptr, nx, -1,
xmin,
xmax, -1., -1.);
499 cout <<
"pointeur histogramme nul" << endl;
505 TF1 fy(
"fy", expression.
Data());
506 TH2* gg = (
TH2*)ScaleHisto(hh,
nullptr, &fy, -1, ny, -1., -1.,
ymin,
ymax);
550 cout <<
"pointeur histogramme nul" << endl;
554 if (bmin == -1) bmin = 1;
566 for (
Int_t nx = bmin; nx <= bmax; nx += 1) {
580 else if (axis ==
"Y") {
584 for (
Int_t ny = bmin; ny <= bmax; ny += 1) {
597 cout <<
"l option TString axis doit etre X ou Y" << endl;
619 cout <<
"pointeur histogramme nul" << endl;
625 cout <<
"l option TString axis doit etre X ou Y" << endl;
673 cout <<
"pointeur histogramme nul" << endl;
677 if (direction !=
"C" && direction !=
"D") {
678 cout <<
"l option TString direction doit etre C ou D" << endl;
682 if (bmin < 1) bmin = 1;
690 if (direction ==
"C") {
715 if (!strcmp(norm,
"surf")) {
716 clone->
Scale(1. / big_sum);
718 else if (!strcmp(norm,
"max")) {
719 clone->
Scale(1. / sum);
724 cout <<
"cette methode n est pas prevue pour les TH2, TH3" << endl;
762 cout <<
"pointeur histogramme nul" << endl;
765 if (!(0 <= order && order <= 2)) {
766 cout <<
"ordre " << order <<
"n est pas implemente" << endl;
772 hname.
Form(
"%s_derivated_%d", hh->
GetName(), order);
791 else if (order == 1) {
793 dev = 1 / 12. /
h * (
803 dev = 1 / 7. / h2 * (
816 cout <<
"cette methode n est pas prevue pour les TH2, TH3" << endl;
861 if (axis !=
"X" && axis !=
"Y") {
862 cout <<
"GetMomentEvolution(TH2*,TString ,TString ,TString) Mauvaise syntaxe pour TString axis (X ou Y) " << endl;
868 cout <<
"GetMomentEvolution(TH2*,TString ,TString ,TString) TString momentx n'est pas une methode valide " << momentx.
Data() << endl;
874 unique_ptr<TMethodCall> cmy, Ecmy;
878 if (!cmy->IsValid()) {
879 cout <<
"GetMomentEvolution(TH2*,TString ,TString ,TString) TString momenty n'est pas une methode valide " << momenty.
Data() << endl;
887 fmt_histo.
Form(
"GetMomentEvolution_%s", hh->
GetName());
894 for (
Int_t nn = 1; nn <= nmax; nn += 1) {
898 if (stat > stat_min) {
908 Double_t valx, valy, Evaly = 0, Evalx = 0;
910 while (!lbins.
End()) {
915 if (Ecmx->IsValid()) Ecmx->Execute(hp,
"1", Evalx);
917 cmy->Execute(hp,
"1", valy);
918 if (Ecmy->IsValid()) Ecmy->Execute(hp,
"1", Evaly);
941 cout <<
"GetMomentEvolution(TH2*,TString ,TString ,TString) Aucun point dans le TGraph" << endl;
972 printf(
"ERREUR : KVHistoManipulator::LinkGraphs : les deux graphs n ont pas le meme nbre de points\n");
983 else corre =
new TGraph(npoints, xx, yy);
1032 Double_t rho = (meanxy - meanx * meany) / (sigmax * sigmay);
1054 cout <<
"pointeur histogramme nul" << endl;
1061 cout <<
"TH2" << endl;
1068 if (integ > MinIntegral) {
1077 else if (axis ==
"Y") {
1083 if (integ > MinIntegral) {
1092 cout <<
"l option TString axis doit etre X ou Y" << endl;
1098 cout <<
"cette methode n est prevue que pour les TH2 and sons" << endl;
1127 cout <<
"pointeur histogramme nul" << endl;
1133 for (
Int_t nx = 1; nx <= hh->
GetXaxis()->GetNbins(); nx += 1) {
1140 printf(
"integral du spectre %lf -> tranche de %lf\n", integral, integral / ntranches);
1146 if (tranche >= integral / ntranches) {
1191 cout <<
"pointeur histogramme nul" << endl;
1195 Error(
"PermuteAxis",
"methode definie uniquement pour les classes TH2 et filles");
1211 for (
Int_t xx = 1; xx <= nx; xx += 1) {
1212 for (
Int_t yy = 1; yy <= ny; yy += 1) {
1240 cout <<
"pointeur graph nul" << endl;
1244 Error(
"PermuteAxis",
"methode definie uniquement pour les classes TGraph et filles");
1279 cout <<
"pointeur histogramme nul" << endl;
1289 for (
Int_t xx = 1; xx <= nx; xx += 1) {
1332 for (
Int_t xx = 1; xx <= nx; xx += 1) {
1387 DefinePattern(ob->
GetXaxis(), titleX, labelX);
1388 DefinePattern(ob->
GetYaxis(), titleY, labelY);
1401 DefinePattern(ob->
GetXaxis(), titleX, labelX);
1402 DefinePattern(ob->
GetYaxis(), titleY, labelY);
1415 DefinePattern(ob->
GetXaxis(), titleX, labelX);
1416 DefinePattern(ob->
GetYaxis(), titleY, labelY);
1450 if (tok)
delete tok;
1466 if (ob->IsA()->InheritsFrom(
"TAttLine")) {
1467 if (!
line.IsNull()) {
1468 tok =
line.Tokenize(
" ");
1476 if (tok)
delete tok;
1492 if (ob->IsA()->InheritsFrom(
"TAttMarker")) {
1502 if (tok)
delete tok;
1609 ft =
spline->Eval(t) - val;
1611 for (
n = 1;
n <= nmax;
n++) {
1612 r = (fs * t - ft *
s) / (fs - ft);
1619 if (side == -1) fs /= 2;
1622 else if (fs * fr > 0) {
1625 if (side == +1) ft /= 2;
1721 RescaleX(hist1, hist2, fonc, npoints, direction,
xmin,
xmax, qmin, qmax, eps);
1722 for (i = 0; i < degree + 1; i++) {
1727 params[degree + 1] = chisquare;
1872 TF1* scalefunc = RescaleX(hist1, hist2, degree, params, npoints, direction,
xmin,
xmax, qmin, qmax, eps);
1880 TH1* scalehisto = ScaleHisto(hist1, scalefunc, 0, nx, -1, nxmin, nxmax, -1.0, -1.0,
"width");
1950 if (!fVDCanvas) fVDCanvas =
new TCanvas(
"VDCanvas",
"KVHistoManipulator::RescaleX");
1953 fVDCanvas->Divide(2, 2);
1963 Info(
"RescaleX",
"Calculating transformation of histo %s using reference histo %s, %d points of comparison",
1968 cum1 = CumulatedHisto(hist1,
xmin,
xmax, direction,
"max");
1969 cum2 = CumulatedHisto(hist2,
xmin,
xmax, direction,
"max");
1972 cum1 = CumulatedHisto(hist1, direction, -1, -1,
"max");
1973 cum2 = CumulatedHisto(hist2, direction, -1, -1,
"max");
1984 Double_t delta_q = (qmax - qmin) / (1.0 * (npoints - 1));
1985 for (i = 0; i < npoints; i++) quantiles[i] = qmin + i * delta_q;
1989 for (i = 0; i < npoints; i++) {
1990 X1[i] = GetX(cum1, quantiles[i], eps);
1991 X2[i] = GetX(cum2, quantiles[i], eps);
1993 for (i = 0; i < npoints; i++) {
1994 printf(
"COMPARISON: i=%d quantile=%f X1=%f X2=%f\n",
1995 i, quantiles[i], X1[i], X2[i]);
2000 if (kVisDebug) fitoptions =
"";
2001 if (fitgraph->
Fit(scale_func, fitoptions.
Data()) != 0) {
2002 Error(
"RescaleX",
"Fitting with function %s failed to converge",
2016 delete [] quantiles;
2074 RescaleX(hist1, hist2, scale_func, npoints, direction,
xmin,
xmax, qmin, qmax, eps);
2082 TH1* scalehisto = ScaleHisto(hist1, scale_func, 0, nx, -1, nxmin, nxmax, -1.0, -1.0,
"width");
2108 return CumulatedHisto(hh, direction, bmin, bmax, norm);
2183 printf(
"Warning, KVHistoManipulator::GetChisquare :\n\taucune cellule price en compte dans le calcul du Chi2 ...\n");
2186 return (norm ? chi2 / nbre : chi2);
2222 chi2 += fval - 1 * hval * logfval;
2235 chi2 += fval - 1 * hval * logfval;
2241 printf(
"Warning, KVHistoManipulator::GetChisquare :\n\taucune cellule price en compte dans le calcul du Chi2 ...\n");
2244 return (norm ? chi2 / nbre : chi2);
2266 if (G2->
GetN() != npoints) {
2267 Error(
"DivideGraphs",
"Graphs must have same number of points");
2271 AUTO_NEW_CTOR(
TGraph, Gdiv)(*G1);
2277 for (
int i = 0; i < npoints; i++) {
2278 if (Y2[i] != 0) Gdiv->SetPoint(i, X[i], Y1[i] / Y2[i]);
2279 else Gdiv->SetPoint(i, X[i], 0.);
2291 if (g1->
GetN() != npoints) {
2292 Error(
"ComputeNewGraphFrom",
"Graphs must have same number of points %d != %d", npoints, g1->
GetN());
2296 TF1 f1(
"func_ComputeNewGraphFrom", formula, 0, 1);
2298 Error(
"ComputeNewGraphFrom",
"formula %s for the operation is not valid or has not 2 parameters", formula.
Data());
2302 AUTO_NEW_CTOR(
TGraph, gfinal)();
2310 for (
Int_t ii = 0; ii < npoints; ii++) {
2312 if (x1[ii] != x0[ii])
2313 Warning(
"ComputeNewGraphFrom",
"X values are different for the same point %d : %lf %lf", ii, x0[ii], x1[ii]);
2315 gfinal->SetPoint(ii, x0[ii], result);
2336 std::vector<Double_t> limits(4);
2338 for (
Int_t ii = 0; ii < G1->
GetN(); ii += 1) {
2341 limits[0] = limits[2] = xx;
2342 limits[1] = limits[3] = yy;
2345 if (xx < limits[0]) limits[0] = xx;
2346 if (yy < limits[1]) limits[1] = yy;
2347 if (xx > limits[2]) limits[2] = xx;
2348 if (yy > limits[3]) limits[3] = yy;
2372 std::vector<Double_t> limits, temp;
2379 limits = GetLimits(
gr);
2382 temp = GetLimits(
gr);
2383 if (temp[0] < limits[0]) limits[0] = temp[0];
2384 if (temp[1] < limits[1]) limits[1] = temp[1];
2385 if (temp[2] > limits[2]) limits[2] = temp[2];
2386 if (temp[3] > limits[3]) limits[3] = temp[3];
2410 std::vector<Double_t> limits(4);
2420 limits[0] = limits[2] = xx;
2421 limits[1] = limits[3] = yy;
2424 if (xx < limits[0]) limits[0] = xx;
2425 if (yy < limits[1]) limits[1] = yy;
2426 if (xx > limits[2]) limits[2] = xx;
2427 if (yy > limits[3]) limits[3] = yy;
2453 std::vector<Double_t> temp, limits;
2459 limits = GetLimits(
gr);
2462 temp = GetLimits(
gr);
2463 if (temp[0] < limits[0]) limits[0] = temp[0];
2464 if (temp[1] < limits[1]) limits[1] = temp[1];
2465 if (temp[2] > limits[2]) limits[2] = temp[2];
2466 if (temp[3] > limits[3]) limits[3] = temp[3];
2489 TIter nextp(
gPad->GetListOfPrimitives());
2491 while ((obj = nextp())) {
2493 h1 =
dynamic_cast<TH1*
>(obj);
2520 std::cout << x1 <<
" " << x2 <<
" - " << y1 <<
" " << y2 <<
" - " << z1 <<
" " << z2 << std::endl;
2525 while ((pad =
cc->GetPad(nc))) {
2533 TIter nextq(
gPad->GetListOfPrimitives());
2535 while ((obj = nextq())) {
2537 h1 =
dynamic_cast<TH1*
>(obj);
KVHistoManipulator * gHistoManipulator
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
include TDocParser_001 C image html pict1_TDocParser_001 png width
double pow(double, double)
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Toolkit for various operations on histograms & graphs not provided by ROOT.
TF1 * RescaleX(TH1 *hist1, TH1 *hist2, Int_t degree, Double_t *params, Int_t npoints=-1, const Char_t *direction="C", Double_t xmin=-1, Double_t xmax=-1, Double_t qmin=0.05, Double_t qmax=0.95, Double_t eps=1.e-07)
void DefineMarkerStyle(TAttMarker *ob, TString marker)
TH1 * MakeHistoRescaleX(TH1 *hist1, TH1 *hist2, Int_t degree, Double_t *params, Option_t *opt="", Int_t npoints=-1, const Char_t *direction="C", Double_t xmin=-1, Double_t xmax=-1, Double_t qmin=0.05, Double_t qmax=0.95, Double_t eps=1.e-07)
TH2 * CentreeReduiteX(TH2 *hh, Int_t nx=-1, Double_t xmin=-1., Double_t xmax=-1.)
std::vector< Double_t > GetLimits(TGraph *G1)
TGraph * ComputeNewGraphFrom(TGraph *g0, TGraph *g1, const TString &formula)
TH2 * CentreeReduiteY(TH2 *hh, Int_t ny=-1, Double_t ymin=-1., Double_t ymax=-1.)
TH2 * PermuteAxis(TH2 *hh)
void DefineStyle(TObject *ob, TString line, TString marker)
Double_t GetX(TH1 *ob, Double_t val, Double_t eps=1.e-07, Int_t nmax=50, Double_t xmin=-1.0, Double_t xmax=-1.0)
Double_t GetChisquare(TH1 *h1, TF1 *f1, Bool_t norm=kTRUE, Bool_t err=kTRUE, Double_t *para=nullptr)
KVNumberList * Saucisson(TH1 *hh, Int_t ntranches=10)
TGraph * ScaleGraph(TGraph *hh, TF1 *fx, TF1 *fy)
TGraph * LinkGraphs(TGraph *grx, TGraph *gry)
void DefinePattern(TH1 *ob, TString titleX="42 0.08 0.8", TString titleY="42 0.07 1.2", TString labelX="42 0.05 0.005", TString labelY="42 0.05 0.006")
virtual ~KVHistoManipulator(void)
TH2 * RenormaliseHisto(TH2 *hh, Int_t bmin=-1, Int_t bmax=-1, TString axis="X", Double_t valref=1)
Int_t CutStatBin(TH1 *hh, Int_t stat_min=-1, Int_t stat_max=-1)
TGraphErrors * GetMomentEvolution(TH2 *hh, TString momentx, TString momenty, TString axis="Y", Double_t stat_min=0)
void DefineTitle(TH1 *ob, TString xtit, TString ytit)
TGraph * ExtractMeanAndSigmaFromProfile(TProfile *pf, TGraph *&sigma)
void ApplyCurrentLimitsToAllCanvas(Bool_t AlsoLog=kFALSE)
TH1 * CentreeReduite(TH1 *hh, Int_t nx=-1, Int_t ny=-1, Double_t xmin=-1., Double_t xmax=-1., Double_t ymin=-1., Double_t ymax=-1.)
TH1 * ScaleHisto(TH1 *hh, TF1 *fx, TF1 *fy=NULL, Int_t nx=-1, Int_t ny=-1, Double_t xmin=-1., Double_t xmax=-1., Double_t ymin=-1., Double_t ymax=-1., Option_t *norm="")
TGraph * DivideGraphs(TGraph *G1, TGraph *G2)
Double_t GetLikelihood(TH1 *h1, TF1 *f1, Bool_t norm=kTRUE, Double_t *para=nullptr)
KVList * Give_ProjectionList(TH2 *hh, Double_t MinIntegral=-1, TString axis="X")
TGraphErrors * MakeGraphFrom(TProfile *pf, Bool_t Error=kTRUE)
TH1 * CumulatedHisto(TH1 *hh, TString direction="C", Int_t bmin=-1, Int_t bmax=-1, Option_t *norm="surf")
TH1 * GetDerivative(TH1 *hh, Int_t order)
void DefineLineStyle(TAttLine *ob, TString line)
Double_t GetCorrelationFactor(TH2 *hh)
Int_t Apply_TCutG(TH2 *hh, TCutG *cut, TString mode="in")
Extended TList class which owns its objects by default.
Strings used to represent a set of ranges of values.
void Add(Int_t)
Add value 'n' to the list.
virtual void Add(TObject *obj)
virtual void SetTitleOffset(Float_t offset=1)
virtual void SetLabelSize(Float_t size=0.04)
virtual void SetTitleFont(Style_t font=62)
virtual void SetLabelOffset(Float_t offset=0.005)
virtual void SetLabelFont(Style_t font=62)
virtual void SetTitleSize(Float_t size=0.04)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual Int_t FindBin(const char *label)
virtual Double_t GetBinCenter(Int_t bin) const
virtual Double_t GetBinLowEdge(Int_t bin) const
virtual void SetRange(Int_t first=0, Int_t last=0)
virtual Double_t GetBinWidth(Int_t bin) const
virtual Double_t GetBinUpEdge(Int_t bin) const
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
virtual Int_t GetEntries() const
virtual Int_t GetNDF() const
virtual Double_t GetParameter(const TString &name) const
Double_t GetChisquare() const
virtual void SetRange(Double_t xmin, Double_t xmax)
virtual Int_t GetNpar() const
virtual Double_t Derivative(Double_t x, Double_t *params=0, Double_t epsilon=0.001) const
virtual void SetNpx(Int_t npx=100)
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
virtual void SetParameters(const Double_t *params)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetPointError(Double_t ex, Double_t ey)
virtual Int_t IsInside(Double_t x, Double_t y) const
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual Double_t * GetEX() const
virtual Double_t * GetEY() const
virtual void SetNameTitle(const char *name="", const char *title="")
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
virtual void SetTitle(const char *title)
virtual Double_t GetBinCenter(Int_t bin) const
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
virtual Double_t GetMean(Int_t axis=1) const
virtual Int_t GetDimension() const
virtual void Reset(Option_t *option="")
TObject * Clone(const char *newname=0) const
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetBinError(Int_t bin, Double_t error)
virtual Int_t Fill(const char *name, Double_t w)
virtual void SetMinimum(Double_t minimum=-1111)
Double_t GetRMS(Int_t axis=1) const
virtual void SetBinContent(Int_t bin, Double_t content)
virtual Double_t GetBinLowEdge(Int_t bin) const
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const
virtual void SetName(const char *name)
virtual Double_t GetBinContent(Int_t bin) const
virtual void SetBins(Int_t nx, const Double_t *xBins)
virtual void SetNameTitle(const char *name, const char *title)
virtual Double_t GetBinWidth(Int_t bin) const
virtual void Scale(Double_t c1=1, Option_t *option="")
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
virtual void Reset(Option_t *option="")
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
virtual Double_t GetBinContent(Int_t bin) const
virtual void SetBinContent(Int_t bin, Double_t content)
virtual TObject * At(Int_t idx) const
void InitWithPrototype(const char *function, const char *proto, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
TList * GetListOfGraphs() const
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
virtual const char * GetTitle() const
virtual void SetName(const char *name)
TObject * At(Int_t idx) const
virtual const char * ClassName() const
virtual TObject * DrawClone(Option_t *option="") const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void SetBinEntries(Int_t bin, Double_t w)
virtual Double_t GetBinEntries(Int_t bin) const
virtual Double_t GetBinError(Int_t bin) const
virtual Double_t GetBinContent(Int_t bin) const
virtual Double_t Uniform(Double_t x1, Double_t x2)
virtual TObject * At(Int_t idx) const=0
TObjArray * Tokenize(const TString &delim) const
const char * Data() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetOptStat(Int_t stat=1)
virtual Int_t GetLogz() const=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual Int_t GetLogy() const=0
virtual Int_t GetLogx() const=0
VecExpr< UnaryOp< Sqrt< T >, SVector< T, D >, T >, T, D > sqrt(const SVector< T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, SVector< T, D >, T >, T, D > fabs(const SVector< T, D > &rhs)
const long double cc
volumes
Double_t Power(Double_t x, Double_t y)
Double_t Sqrt(Double_t x)
Double_t Max(Double_t a, Double_t b)
void spline(double x[], double y[], int n, double yp1, double ypn, double *y2)