KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
List of all members | Public Member Functions | Private Attributes | List of all members
KVHistoManipulator Class Reference

Toolkit for various operations on histograms & graphs not provided by ROOT.

Definition at line 35 of file KVHistoManipulator.h.

Public Member Functions

 KVHistoManipulator ()
 Default constructor. More...
 
virtual ~KVHistoManipulator (void)
 
Int_t Apply_TCutG (TH2 *hh, TCutG *cut, TString mode="in")
 
void ApplyCurrentLimitsToAllCanvas (Bool_t AlsoLog=kFALSE)
 
TH1CentreeReduite (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.)
 
TH2CentreeReduiteX (TH2 *hh, Int_t nx=-1, Double_t xmin=-1., Double_t xmax=-1.)
 
TH2CentreeReduiteY (TH2 *hh, Int_t ny=-1, Double_t ymin=-1., Double_t ymax=-1.)
 
TGraphComputeNewGraphFrom (TGraph *g0, TGraph *g1, const TString &formula)
 
TGraphComputeNewGraphFrom (TList *lgr, TString formula)
 
TH1CumulatedHisto (TH1 *hh, Double_t xmin, Double_t xmax, const TString &direction="C", Option_t *norm="surf")
 
TH1CumulatedHisto (TH1 *hh, TString direction="C", Int_t bmin=-1, Int_t bmax=-1, Option_t *norm="surf")
 
Int_t CutStatBin (TH1 *hh, Int_t stat_min=-1, Int_t stat_max=-1)
 
void DefineLineStyle (TAttLine *ob, TString line)
 
void DefineMarkerStyle (TAttMarker *ob, TString marker)
 
void DefinePattern (TAxis *ax, TString title="42 0.08 0.8", TString label="42 0.05 0.005")
 
void DefinePattern (TF1 *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")
 
void DefinePattern (TGraph *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")
 
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")
 
void DefineStyle (TObject *ob, TString line, TString marker)
 
void DefineTitle (TF1 *ob, TString xtit, TString ytit)
 
void DefineTitle (TGraph *ob, TString xtit, TString ytit)
 
void DefineTitle (TH1 *ob, TString xtit, TString ytit)
 
TGraphDivideGraphs (TGraph *G1, TGraph *G2)
 
TGraphExtractMeanAndSigmaFromProfile (TProfile *pf, TGraph *&sigma)
 
Double_t GetChisquare (TH1 *h1, TF1 *f1, Bool_t norm=kTRUE, Bool_t err=kTRUE, Double_t *para=nullptr)
 
Double_t GetCorrelationFactor (TH2 *hh)
 
TH1GetDerivative (TH1 *hh, Int_t order)
 
Double_t GetLikelihood (TH1 *h1, TF1 *f1, Bool_t norm=kTRUE, Double_t *para=nullptr)
 
std::vector< Double_tGetLimits (TGraph *G1)
 
std::vector< Double_tGetLimits (TMultiGraph *mgr)
 
std::vector< Double_tGetLimits (TProfile *G1)
 
std::vector< Double_tGetLimits (TSeqCollection *mgr)
 
TGraphErrorsGetMomentEvolution (TH2 *hh, TString momentx, TString momenty, TString axis="Y", Double_t stat_min=0)
 
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 GetXWithLimits (TH1 *ob, Double_t val, Double_t xmin=-1.0, Double_t xmax=-1.0, Double_t eps=1.e-07, Int_t nmax=50)
 
KVListGive_ProjectionList (TH2 *hh, Double_t MinIntegral=-1, TString axis="X")
 
void init (void)
 
Bool_t IsVisDebug () const
 
TGraphLinkGraphs (TGraph *grx, TGraph *gry)
 
TGraphErrorsMakeGraphFrom (TProfile *pf, Bool_t Error=kTRUE)
 
TH1MakeHistoRescaleX (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)
 
TH1MakeHistoRescaleX (TH1 *hist1, TH1 *hist2, TF1 *scale_func, Int_t npoints=2, Option_t *opt="", 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)
 
TGraphPermuteAxis (TGraph *gr)
 
TH2PermuteAxis (TH2 *hh)
 
TH2RenormaliseHisto (TH2 *hh, Double_t valmin, Double_t valmax, TString axis="X", Double_t valref=1)
 
TH2RenormaliseHisto (TH2 *hh, Int_t bmin=-1, Int_t bmax=-1, TString axis="X", Double_t valref=1)
 
TF1RescaleX (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 RescaleX (TH1 *hist1, TH1 *hist2, TF1 *scale_func, Int_t npoints=2, 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)
 
KVNumberListSaucisson (TH1 *hh, Int_t ntranches=10)
 
TGraphScaleGraph (const TGraph *hh, const TString &axis, const TF1 &f1, const TF1 &f2=TF1("f2", "x")) const
 
TGraphScaleGraph (const TGraph *hh, TF1 *fx=nullptr, TF1 *fy=nullptr) const
 
TH1ScaleHisto (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="")
 
void SetVisDebug (Bool_t on=kTRUE)
 

Private Attributes

TCanvasfVDCanvas
 used for visual debugging More...
 
Bool_t kVisDebug
 = kTRUE for visual debugging More...
 

#include <KVHistoManipulator.h>

Constructor & Destructor Documentation

◆ KVHistoManipulator()

KVHistoManipulator::KVHistoManipulator ( )

Default constructor.

Definition at line 33 of file KVHistoManipulator.cpp.

◆ ~KVHistoManipulator()

KVHistoManipulator::~KVHistoManipulator ( void  )
virtual

Definition at line 46 of file KVHistoManipulator.cpp.

Member Function Documentation

◆ Apply_TCutG()

Int_t KVHistoManipulator::Apply_TCutG ( TH2 hh,
TCutG cut,
TString  mode = "in" 
)

IMPORTANT l'histo est modifie

Applique une selection sur un histo 2D a partir d'un TCutG; Si mode=In seules les cellules comprises dans le TCutG sont gardes mode=Out --> Inverse la fonction renvoie le nbre de cellules mis a zero Attention le test ne se fait que sur les valeurs centrales des cellules (GetBinCenter())

Definition at line 147 of file KVHistoManipulator.cpp.

◆ ApplyCurrentLimitsToAllCanvas()

void KVHistoManipulator::ApplyCurrentLimitsToAllCanvas ( Bool_t  AlsoLog = kFALSE)

Getthe limits of the histogram in the current pad and apply them to the others histogram drawn on the others pads

Definition at line 2528 of file KVHistoManipulator.cpp.

◆ CentreeReduite()

TH1 * KVHistoManipulator::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. 
)

Exemple d utilisation de la methode KVHistoManipulator::ScaleHisto avec ici L'obtention des distributions centrees reduites

Definition at line 414 of file KVHistoManipulator.cpp.

◆ CentreeReduiteX()

TH2 * KVHistoManipulator::CentreeReduiteX ( TH2 hh,
Int_t  nx = -1,
Double_t  xmin = -1.,
Double_t  xmax = -1. 
)

Exemple d utilisation de la methode KVHistoManipulator::ScaleHisto avec ici L'obtention des distributions centrees reduites

Definition at line 450 of file KVHistoManipulator.cpp.

◆ CentreeReduiteY()

TH2 * KVHistoManipulator::CentreeReduiteY ( TH2 hh,
Int_t  ny = -1,
Double_t  ymin = -1.,
Double_t  ymax = -1. 
)

Exemple d utilisation de la methode KVHistoManipulator::ScaleHisto avec ici L'obtention des distributions centrees reduites

Definition at line 480 of file KVHistoManipulator.cpp.

◆ ComputeNewGraphFrom() [1/2]

TGraph * KVHistoManipulator::ComputeNewGraphFrom ( TGraph g0,
TGraph g1,
const TString formula 
)

Definition at line 2276 of file KVHistoManipulator.cpp.

◆ ComputeNewGraphFrom() [2/2]

TGraph * KVHistoManipulator::ComputeNewGraphFrom ( TList lgr,
TString  formula 
)

generalization of the previous method ComputeNewGraphFrom(TGraph* g0, TGraph* g1, TString formula)

create a new TGraph from the combination of the graph in the list new errors are not computed x-values are unchanged from a given list "lgr", compute expression indicated in the "formula", with the following prescription : the "i" position of the graph in the list will correspond to the "[i]" parameters of the formula for each points of the graphs, the formula is computed with the y-values of the graphs and the new y-value is set to the new graph Examples if there is 2 graphs in the list, and the formula "[0]+[1]" is set, the method will give a new TGraph with the sum of the y-values of the two TGraphs

Definition at line 2322 of file KVHistoManipulator.cpp.

◆ CumulatedHisto() [1/2]

TH1 * KVHistoManipulator::CumulatedHisto ( TH1 hh,
Double_t  xmin,
Double_t  xmax,
const TString direction = "C",
Option_t norm = "surf" 
)

Cumule le contenu de l histo hh entre xmin et xmax et retourne l histo correspondant Voir CumulatedHisto(TH1* ,TString ,Int_t ,Int_t , Option_t*).

Definition at line 2089 of file KVHistoManipulator.cpp.

◆ CumulatedHisto() [2/2]

TH1 * KVHistoManipulator::CumulatedHisto ( TH1 hh,
TString  direction = "C",
Int_t  bmin = -1,
Int_t  bmax = -1,
Option_t norm = "surf" 
)

Cumule le contenu de l histo hh entre bin bmin et bmax et retourne l histo correspondant Si direction="C" (default): SetBinContent(n) = GetBinContent(bmin)+GetBinContent(bmin+1)+ ... + GetBinContent(n) Si direction="D": SetBinContent(n) = GetBinContent(bmax)+GetBinContent(bmax-1)+ ... + GetBinContent(n)

Donne en sortie l histogramme transforme celui ci a pour nom "nom_de_histo_input"_cumulated

IMPORTANT l'histo d'entree n'est pas modifie

si bmin=-1, bmin=1 si bmax=-1, bmax=GetNbinsX()

Avec norm = "surf" (default) l'integral de l histo cumule est egale a 1 Avec norm = "max" le contenu de l'histogram est renormalise de facon a ce que le maximum soit 1

Definition at line 641 of file KVHistoManipulator.cpp.

◆ CutStatBin()

Int_t KVHistoManipulator::CutStatBin ( TH1 hh,
Int_t  stat_min = -1,
Int_t  stat_max = -1 
)

IMPORTANT l'histo est modifie

Efface les bins dont la statistique est hors de l 'intervalle ]stat_min,stat_max[ l'erreur et le contenu sont mis a zero le nombre d entree (GetEntries) reste inchange pour les TH1 cela correspond a GetBinContent(xx) pour les TH2 cela correspond a GetBinContent(xx,yy) --> cellules pour les TProfile cela correspond a GetBinEntries(xx) la fonction renvoie le nbre de bins ou cellules mis a zero si stat_min ou stat_max sont egales à -1 la borne associée n'est pas prise en compte

Definition at line 69 of file KVHistoManipulator.cpp.

◆ DefineLineStyle()

void KVHistoManipulator::DefineLineStyle ( TAttLine ob,
TString  line 
)

Definition at line 1449 of file KVHistoManipulator.cpp.

◆ DefineMarkerStyle()

void KVHistoManipulator::DefineMarkerStyle ( TAttMarker ob,
TString  marker 
)

Definition at line 1475 of file KVHistoManipulator.cpp.

◆ DefinePattern() [1/4]

void KVHistoManipulator::DefinePattern ( TAxis ax,
TString  title = "42 0.08 0.8",
TString  label = "42 0.05 0.005" 
)

Definition at line 1414 of file KVHistoManipulator.cpp.

◆ DefinePattern() [2/4]

void KVHistoManipulator::DefinePattern ( TF1 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" 
)

Definition at line 1400 of file KVHistoManipulator.cpp.

◆ DefinePattern() [3/4]

void KVHistoManipulator::DefinePattern ( TGraph 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" 
)

Definition at line 1386 of file KVHistoManipulator.cpp.

◆ DefinePattern() [4/4]

void KVHistoManipulator::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" 
)

Definition at line 1372 of file KVHistoManipulator.cpp.

◆ DefineStyle()

void KVHistoManipulator::DefineStyle ( TObject ob,
TString  line,
TString  marker 
)

Definition at line 1501 of file KVHistoManipulator.cpp.

◆ DefineTitle() [1/3]

void KVHistoManipulator::DefineTitle ( TF1 ob,
TString  xtit,
TString  ytit 
)

Definition at line 1547 of file KVHistoManipulator.cpp.

◆ DefineTitle() [2/3]

void KVHistoManipulator::DefineTitle ( TGraph ob,
TString  xtit,
TString  ytit 
)

Definition at line 1532 of file KVHistoManipulator.cpp.

◆ DefineTitle() [3/3]

void KVHistoManipulator::DefineTitle ( TH1 ob,
TString  xtit,
TString  ytit 
)

Definition at line 1517 of file KVHistoManipulator.cpp.

◆ DivideGraphs()

TGraph * KVHistoManipulator::DivideGraphs ( TGraph G1,
TGraph G2 
)

Create and fill a TGraph containing, for each point in G1 and G2, the value of (y1/y2). G1 & G2 should have the same number of points, with the same x-coordinates i.e. x1 = x2 for all points if any y2 value = 0, we set the corresponding point's y=0

Definition at line 2245 of file KVHistoManipulator.cpp.

◆ ExtractMeanAndSigmaFromProfile()

TGraph * KVHistoManipulator::ExtractMeanAndSigmaFromProfile ( TProfile pf,
TGraph *&  sigma 
)

Extract mean and standard deviation (if generated with mode "profs") or error on mean (with "prof") from TProfile and put their evolution in 2 TGraphs.

Returns
Pointer to graph containing mean values
Parameters
sigmaPointer to graph containing standard deviation

Example of use:

TGraph* sig_graf;
TGraph* mean_graf = HM.ExtractMeanAndSigmaFromProfile(pf, sig_graf);

Definition at line 1302 of file KVHistoManipulator.cpp.

◆ GetChisquare()

Double_t KVHistoManipulator::GetChisquare ( TH1 h1,
TF1 f1,
Bool_t  norm = kTRUE,
Bool_t  err = kTRUE,
Double_t para = nullptr 
)

Camcul du chi2 entre un histogramme et une fonction donnée Warning : ne prend en compte que les bins avec une stat>0 de l histogramme norm = kTRUE (default), normalise la valeur du Chi2 au nombre de bin pris en compte err = kTRUE (default), prend en compte les erreurs du contenu des bins dans le calcul (si celle ci est >0)

Definition at line 2110 of file KVHistoManipulator.cpp.

◆ GetCorrelationFactor()

Double_t KVHistoManipulator::GetCorrelationFactor ( TH2 hh)

Calcul le coefficient de correlation entre les variables X et Y d'un bidim... Equivalent a TH2F::GetCorrelationFactor() de ROOT

Definition at line 991 of file KVHistoManipulator.cpp.

◆ GetDerivative()

TH1 * KVHistoManipulator::GetDerivative ( TH1 hh,
Int_t  order 
)

retourne la derivee d ordre 0, 1 ou 2 d'un histogramme 0 -> correspond a un lissage (smooth) de la distribution 1 et 2 correspondent aux derivees premieres et deuxiemes

0 -> derivee zero Yi = 1/35*(-3yi-2 + 12yi-1 +17yi +12yi1 -3yi2) 1 -> derivee premiere Y'i = 1/12h*(yi-2 - 8yi-1 +8yi1 -1yi2) 2 -> derivee seconde Y''i = 1/7h/h*(2yi-2 -1 yi-1 -2yi -1yi1 +2yi2) les derivees pour les bins 1,2 et n-1,n ne sont pas calculees

IMPORTANT l'histo d'entree n'est pas modifie

Definition at line 735 of file KVHistoManipulator.cpp.

◆ GetLikelihood()

Double_t KVHistoManipulator::GetLikelihood ( TH1 h1,
TF1 f1,
Bool_t  norm = kTRUE,
Double_t para = nullptr 
)

Calcul du chi2 entre un histogramme et une fonction donnée Warning : ne prend en compte que les bins avec une stat>0 de l histogramme norm = kTRUE (default), normalise la valeur du Chi2 au nombre de bin pris en compte err = kTRUE (default), prend en compte les erreurs du contenu des bins dans le calcul (si celle ci est >0)

Definition at line 2189 of file KVHistoManipulator.cpp.

◆ GetLimits() [1/4]

std::vector< Double_t > KVHistoManipulator::GetLimits ( TGraph G1)

xmin -> limits[0]; ymin -> limits[1]; xmax -> limits[2]; ymax -> limits[3];

Definition at line 2376 of file KVHistoManipulator.cpp.

◆ GetLimits() [2/4]

std::vector< Double_t > KVHistoManipulator::GetLimits ( TMultiGraph mgr)

xmin -> limits[0]; ymin -> limits[1]; xmax -> limits[2]; ymax -> limits[3];

Definition at line 2411 of file KVHistoManipulator.cpp.

◆ GetLimits() [3/4]

std::vector< Double_t > KVHistoManipulator::GetLimits ( TProfile G1)

xmin -> limits[0]; ymin -> limits[1]; xmax -> limits[2]; ymax -> limits[3];

Definition at line 2450 of file KVHistoManipulator.cpp.

◆ GetLimits() [4/4]

std::vector< Double_t > KVHistoManipulator::GetLimits ( TSeqCollection mgr)

xmin -> limits[0]; ymin -> limits[1]; xmax -> limits[2]; ymax -> limits[3];

Definition at line 2492 of file KVHistoManipulator.cpp.

◆ GetMomentEvolution()

TGraphErrors * KVHistoManipulator::GetMomentEvolution ( TH2 hh,
TString  momentx,
TString  momenty,
TString  axis = "Y",
Double_t  stat_min = 0 
)

Renvoie un TGraph A partir d'un 2D histo, permet de tracer l'evolution d'un moment en fonction d'un autre moment ou d'un moment d'un axe en fonction de l'aure axe. Les TString momentx et momenty doivent etre des "Get like" methodes connues de TH1 comme GetMean, GetRMS ou GetKurtosis :

  • Si momenty="" -> on obtient l'evolution du moment momentx en fonction de la variable associée a l'autre axe.
  • Si momenty!="" -> on obtient l'evolution du moment momenty en fonction du momentx

Si TString axis = X la variable en X est le parametre d echantillonage et vice-versa

Exemple : GetMomentEvolution(histo,"GetMean","GetSkewness","X") -> Evolution de la skewness en fonction de la moyenne de l'observable en Y par tranche de l'observable X

Definition at line 831 of file KVHistoManipulator.cpp.

◆ GetX()

Double_t KVHistoManipulator::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 
)

Return value of abscissa X for which the interpolated value of the histogram contents is equal to the given value, val. We use the false position method (which should always converge...) eps is required precision, i.e. convergence condition is that no further change in result greater than eps is found. nmax = maximum number of iterations A solution is searched for X between the limits Xmin and Xmax of the X axis of the histo unless arguments (xmin,xmax) are given to bracket the search

Definition at line 1569 of file KVHistoManipulator.cpp.

◆ GetXWithLimits()

Double_t KVHistoManipulator::GetXWithLimits ( TH1 ob,
Double_t  val,
Double_t  xmin = -1.0,
Double_t  xmax = -1.0,
Double_t  eps = 1.e-07,
Int_t  nmax = 50 
)
inline

See method GetX(): the only difference is the order of the arguments

Definition at line 120 of file KVHistoManipulator.h.

◆ Give_ProjectionList()

KVList * KVHistoManipulator::Give_ProjectionList ( TH2 hh,
Double_t  MinIntegral = -1,
TString  axis = "X" 
)

Retourne une liste contenant les projections par tranche de l'axe (TString axis="X" ou "Y") remplissant une condition leur integral qui doit etre superieur à MinIntegral (=-1 par defaut) si axis="X", les projections sur l'axe Y de l'histogramme est fait pour chaque bin de l'axe X

Definition at line 1034 of file KVHistoManipulator.cpp.

◆ init()

void KVHistoManipulator::init ( void  )
inline

Definition at line 41 of file KVHistoManipulator.h.

◆ IsVisDebug()

Bool_t KVHistoManipulator::IsVisDebug ( ) const
inline

Definition at line 61 of file KVHistoManipulator.h.

◆ LinkGraphs()

TGraph * KVHistoManipulator::LinkGraphs ( TGraph grx,
TGraph gry 
)

A partir de deux graphs ayant le meme nombre de points et le meme axe X, cette methode produit un graph correspondant a la correlation entre les deux axes Y Les inputs peuvent etre aussi bien des TGraph que des TGraphErrors dans ce dernier cas les barres d erreurs sont prises en compte

Definition at line 946 of file KVHistoManipulator.cpp.

◆ MakeGraphFrom()

TGraphErrors * KVHistoManipulator::MakeGraphFrom ( TProfile pf,
Bool_t  Error = kTRUE 
)

Cree un graph à partir d un histo

L'utilisateur doit effacer ce TGraph apres utilisation

Definition at line 1258 of file KVHistoManipulator.cpp.

◆ MakeHistoRescaleX() [1/2]

TH1 * KVHistoManipulator::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 
)

Uses RescaleX(TH1* hist1, TH1* hist2, Int_t degree, Double_t* params, Double_t eps) to find a polynomial transformation of 'hist1' abscissa so that its distribution resembles that of 'hist2', then generates a new rescaled version of 'hist1'.

degree = degree of polynomial to use params = array of dimension [degree+2], after rescaling it will contain the values of fitted parameters of polynomial, plus the Chi2/NDF of the fit: params[0] = a0 params[1] = a1 ... params[degree] = an params[degree+1] = Chisquare/NDF = Chisquare (NDF is always equal to 1)

npoints : by default (npoints=-1), we use npoints=degree+2 values of comparison of the two cumulative distributions (see method RescaleX). more comparison points can be used by setting npoints>=degree+2.

direction : by default ("C") we use the cumulative histogram summed from low x to high x. if direction="D", we use the cumulative histogram summed from high x to low x. xmin, xmax : range of values of abscissa used to build cumulative histograms. default (xmin=xmax=-1) include all values. qmin, qmax : minimum & maximum values of cumulative histograms used for the comparison (see method RescaleX). by default qmin=0.05, qmax=0.95.

eps = relative precision used to find comparison points of histos (default = 1.e-07)

OPTIONS

opt = "norm" : rescaled histogram normalised to have same integral as hist2 opt = "bins" : rescaled histogram will have same number of bins & same limits as hist2 opt = "normbins" | opt = "binsnorm" |--> rescaled histogram can be superposed and added to hist2

EXAMPLE OF USE

In the following example, we fill two histograms with different numbers of random values drawn from two Gaussian distributions with different centroids and widths. We also add to each histogram a 'pedestal' peak which is unrelated to the 'physical' distributions, and significant enough so that it does not permit a correct scaling of the physical part of the distribution.

We can overcome the problem of the 'pedestal' by using the 'inverse cumulated distribution' and excluding the channels where the pedestals are present. The correct scaling of the physical distributions is recovered, as shown below: BEGIN_MACRO(source) { TH1F* h10 = new TH1F("h10","gaussian",4096,-.5,4095.5); TF1 g10("g10","gaus(0)",0,4100); g10.SetParameters(1,1095,233); h10->FillRandom("g10",56130); h10->SetBinContent(85,13425); TH1F* h20 = new TH1F("h20","gaussian",4096,-.5,4095.5); g10.SetParameters(1,1673,487); h20->FillRandom("g10",21370); h20->SetBinContent(78,17900); KVHistoManipulator HM2; HM2.SetVisDebug(); // turn on visual debugging -> create canvas showing rescaling procedure Double_t params0[10]; make rescaling using inverse cumulative distribution, limit to x=[100,4095] TH1* sc30 =HM2.MakeHistoRescaleX(h10,h20,1,params0,"binsnorm",5,"D",100,4095); return gROOT->GetListOfCanvases()->FindObject("VDCanvas"); } END_MACRO

Definition at line 1789 of file KVHistoManipulator.cpp.

◆ MakeHistoRescaleX() [2/2]

TH1 * KVHistoManipulator::MakeHistoRescaleX ( TH1 hist1,
TH1 hist2,
TF1 scale_func,
Int_t  npoints = 2,
Option_t opt = "",
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 
)

Uses RescaleX(TH1* hist1, TH1* hist2, TF1* scale_func, Int_t npoints, Double_t eps) to transform 'hist1' abscissa using TF1 'scale_func' so that its distribution resembles that of 'hist2', then generates a new rescaled version of 'hist1'.

npoints = number of points of comparison between the two histograms. Make sure this is sufficient for the TF1 used in the transformation. i.e. for a polynomial of degree 1 (a+bx), 2 points are enough, 3 will give a meaningful Chi^2 value. direction : by default ("C") we use the cumulative histogram summed from low x to high x. if direction="D", we use the cumulative histogram summed from high x to low x. xmin, xmax : range of values of abscissa used to build cumulative histograms. default (xmin=xmax=-1) include all values. qmin, qmax : minimum & maximum values of cumulative histograms used for the comparison (see method RescaleX). by default qmin=0.05, qmax=0.95. eps = relative precision used to find comparison points of histos (default = 1.e-07)

OPTIONS

opt = "norm" : rescaled histogram normalised to have same integral as hist2 opt = "bins" : rescaled histogram will have same number of bins & same limits as hist2 opt = "normbins" | opt = "binsnorm" |--> rescaled histogram can be superposed and added to hist2

Definition at line 2036 of file KVHistoManipulator.cpp.

◆ PermuteAxis() [1/2]

TGraph * KVHistoManipulator::PermuteAxis ( TGraph gr)

Cree un TGraph en intervertissant les axes

L'utilisateur doit effacer ce graph apres utilisation

Definition at line 1219 of file KVHistoManipulator.cpp.

◆ PermuteAxis() [2/2]

TH2 * KVHistoManipulator::PermuteAxis ( TH2 hh)

Cree un histo 2D en intervertissant les axes

L'utilisateur doit effacer cet histo apres utilisation

Definition at line 1170 of file KVHistoManipulator.cpp.

◆ RenormaliseHisto() [1/2]

TH2 * KVHistoManipulator::RenormaliseHisto ( TH2 hh,
Double_t  valmin,
Double_t  valmax,
TString  axis = "X",
Double_t  valref = 1 
)

Les bornes valmin, valmax definissent l'intervalle ou l on effectue la renormalisation On en derive les valeurs de bins pour la methode KVHistoManipulator::RenormaliseHisto(TH1 *hh,TString axis,Double_t valref,Int_t bmin,Int_t bmax)

Definition at line 599 of file KVHistoManipulator.cpp.

◆ RenormaliseHisto() [2/2]

TH2 * KVHistoManipulator::RenormaliseHisto ( TH2 hh,
Int_t  bmin = -1,
Int_t  bmax = -1,
TString  axis = "X",
Double_t  valref = 1 
)

Renormalisation de l histogramme 2D sous la contrainte d'une ditribution plate suivant X ou Y (signal de bimodalite par exemple) et donne en sortie l histogramme transforme celui ci a pour nom "nom_de_histo_input"_normalised

IMPORTANT l'histo d'entree n'est pas modifie

bmin, bmax : intervalle de bins ou l'on effectue la renormalisation (par defaut -1,-1 --> toute la plage) les contenus hors de l intervalle [bmin,bmax] sont remis a zero Si on veut une distribution plate en X ils indiquent l'intervalle sur cet axe x valref : valeur en stat de la distribution plate (par defaut 1)

ATTENTION la propagation des erreurs n est pas (pour l instant) implementee

Definition at line 521 of file KVHistoManipulator.cpp.

◆ RescaleX() [1/2]

TF1 * KVHistoManipulator::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 
)

Find the polynomial transformation of the X-axis of 1-D histogram hist1 so that the distribution ressembles that of histogram hist2. Returns a TF1 which can be used to rescale hist1 (hist1 and hist2 are not modified). User's responsibility to delete the TF1. After fitting, the array params is filled with: params[0] = a0 params[1] = a1 ... params[degree] = an params[degree+1] = Chisquare/NDF Therefore params MUST BE at least of dimension (degree+2)

npoints : by default (npoints=-1), we use npoints=degree+2 values of comparison of the two cumulative distributions (see below). more comparison points can be used by setting npoints>=degree+2. direction : by default ("C") we use the cumulative histogram summed from low x to high x. if direction="D", we use the cumulative histogram summed from high x to low x. xmin, xmax : range of values of abscissa used to build cumulative histograms. default (xmin=xmax=-1) include all values. qmin, qmax : minimum & maximum values of cumulative histograms used for the comparison (see below). by default qmin=0.05, qmax=0.95.

METHOD

'hist1' contains the distribution P1 of variable X1 'hist2' contains the distribution P2 of variable X2 Supposing that we can write X2=f_n(X1), with f_n(x)=a0 + a1*x + a2*x^2 + ... + an*x^n, what are the parameters of the polynomial for which P1(f_n(X1))=P2(X2) ?

Consider the cumulative distributions, C1(X1) and C2(X2). For npoints=2 we compare the 2 X1 & X2 values for which C1=C2=qmin, qmax For npoints=3 we compare the 3 X1 & X2 values for which C1=C2=qmin, qmin+(qmax-qmin)/2, qmax For npoints=4 we compare the 4 X1 & X2 values for which C1=C2=qmin, qmin+(qmax-qmin)/3, qmin+2*(qmax-qmin)/3, qmax etc. etc. In each case we fit the npoints couples (X1,X2) with f_n

Definition at line 1663 of file KVHistoManipulator.cpp.

◆ RescaleX() [2/2]

void KVHistoManipulator::RescaleX ( TH1 hist1,
TH1 hist2,
TF1 scale_func,
Int_t  npoints = 2,
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 
)

Find the transformation of the X-axis of 1-D histogram hist1 so that the distribution ressembles that of histogram hist2. The user provides a function f(x) (TF1* scale_func) which is supposed to transform the abscissa X1 of 'hist1' in such a way that P1(f(X1)) = P2(X2). We fit 'npoints' comparison points (see below), npoints>=2.

direction : by default ("C") we use the cumulative histogram summed from low x to high x. if direction="D", we use the cumulative histogram summed from high x to low x. xmin, xmax : range of values of abscissa used to build cumulative histograms. default (xmin=xmax=-1) include all values. qmin, qmax : minimum & maximum values of cumulative histograms used for the comparison (see below). by default qmin=0.05, qmax=0.95.

METHOD

'hist1' contains the distribution P1 of variable X1 'hist2' contains the distribution P2 of variable X2 Supposing that we can write X2=f(X1), we compare the abscissa of different points of the two cumulative distributions, C1(X1) and C2(X2). For npoints=2 we compare the 2 X1 & X2 values for which C1=C2=qmin, qmax For npoints=3 we compare the 3 X1 & X2 values for which C1=C2=qmin, qmin+(qmax-qmin)/2, qmax For npoints=4 we compare the 4 X1 & X2 values for which C1=C2=qmin, qmin+(qmax-qmin)/3, qmin+2*(qmax-qmin)/3, qmax etc. etc. In each case we fit the 'npoints' couples (X1,X2) with the TF1 pointed to by 'scale_func'

Definition at line 1910 of file KVHistoManipulator.cpp.

◆ Saucisson()

KVNumberList * KVHistoManipulator::Saucisson ( TH1 hh,
Int_t  ntranches = 10 
)

Donne les valeurs permettant de decouper l'integral d'un histograme en tranche de 10% de la stat total retourne une KVNumberList indiquant les delimitation des tranches

L'utilisateur doit effacer cette liste apres utilisation

Definition at line 1104 of file KVHistoManipulator.cpp.

◆ ScaleGraph() [1/2]

TGraph * KVHistoManipulator::ScaleGraph ( const TGraph hh,
const TString axis,
const TF1 f1,
const TF1 f2 = TF1("f2", "x") 
) const

Returns pointer to new graph whose X- and/or Y-coordinates are those of the input graph scaled according to the given function(s).

  • If axis="X", f1 is applied to X-coordinates
  • If axis="Y", f1 is applied to Y-coordinates
  • If axis="XY", f1 is applied to X-coordinates and f2 is applied to Y-coordinates

Definition at line 360 of file KVHistoManipulator.cpp.

◆ ScaleGraph() [2/2]

TGraph* KVHistoManipulator::ScaleGraph ( const TGraph hh,
TF1 fx = nullptr,
TF1 fy = nullptr 
) const
inline

◆ ScaleHisto()

TH1 * KVHistoManipulator::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 = "" 
)

Applique les transformations correspondantes aux fonctions (TF1 *) donnees en argument et donne en sortie l histogramme transforme celui ci a pour nom "nom_de_histo_input"_scaled

IMPORTANT l'histo d'entree n'est pas modifie

pour TH1 et TProfile n'est pris en compte que TF1 *fx; les parametres de la fonction doivent etre initialises avant. Si la fonction est un pointeur NULL, aucune transformation n est appliquee et l axe reste tel quel. L'intervalle de validite des fonctions TF1::SetRange est determine a partir des limites de l histo apres transformations nx xmin et xmax sont les parametres de binnage des histo si nx=-1, ceux ci sont recalcules automatiquement nx = nx_initial, xmin = fx(xmin), xmax = fx(xmax) si nx!=-1, xmin et xmax doivent etre aussi specifies il en est de meme pour l'axe y

OPTION: norm norm = "" (default) : no adjustment is made for the change in bin width due to the transformation norm = "width" : bin contents are adjusted for width change, so that the integral of the histogram contents taking into account the bin width (i.e. TH1::Integral("width")) is the same.

NOTE for 1D histos: If the binning of the scaled histogram is imposed by the user (nx!=-1), then in order to achieve a continuous scaled distribution we have to randomize X within each bin. This will only work if the bin contents of 'hh' are integer numbers, i.e. unnormalised raw data histogram.

Definition at line 213 of file KVHistoManipulator.cpp.

◆ SetVisDebug()

void KVHistoManipulator::SetVisDebug ( Bool_t  on = kTRUE)
inline

Turn on/off 'VisualDebugging' for RescaleX methods. After calling SetVisDebug(kTRUE), whenever the rescaling procedure is executed, a TCanvas is drawn showing 4 pads, which show: (1) the two histograms to be rescaled (2) the cumulative distributions of the two histograms (3) the fit to the comparison points of the two cumulative distributions (4) a comparison of the resulting rescaled histograms See MakeHistoRescaleX for an example.

Definition at line 49 of file KVHistoManipulator.h.

Member Data Documentation

◆ fVDCanvas

TCanvas* KVHistoManipulator::fVDCanvas
private

used for visual debugging

Definition at line 37 of file KVHistoManipulator.h.

◆ kVisDebug

Bool_t KVHistoManipulator::kVisDebug
private

= kTRUE for visual debugging

Definition at line 36 of file KVHistoManipulator.h.


The documentation for this class was generated from the following files: