# ALICE:tmp

# cast

- http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=12265&p=53018&hilit=_cast+static_cast+dynamic_cast#p53018
- http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=5075&p=20365&hilit=_cast+static_cast+dynamic_cast#p20365

# after

- http://www.pp.rhul.ac.uk/~cowan/stat_course.html (aposn prve tri lekcie)
- http://www.physi.uni-heidelberg.de/~nberger/teaching/ws11/statistics.php
- http://www.physi.uni-heidelberg.de/~nberger/teaching/ws12/statistics/statistics.php !!!!!! OKOKOK !!!!!!
- http://www.physi.uni-heidelberg.de/~nberger/teaching/ws13/statistics/statistics.php (je tu viac stranok preverit)

TH1::Divide
use sumw2 before filling the histogram !!!

Rene Brun If a histogram has associated error bars (TH1::Sumw2() has been called), the resulting error bars are also computed assuming independent histograms. In case of divisions, binomial errors are also supported.

The Add, Divide and Multiply functions also exist to add, divide or multiply an histogram by a function. If an histogram has associated errors bars (TH1::Sumw2), the resulting error bar are also computing assuming independent histograms In case of divisions, Binomial errors are also supported

– h1.SetError(const double *error), set the bin errors equal to array error (if you know the errors aren't gaussian) – h1.Sumw2(), create a structure to keep the sum of weights (if you scale the histogram the errors are correctly modified)

line 27(h->Sumw2()): This is a crucial step for the sum and ratio of histograms to handle errors properly. The method TH1::Sumw2 causes the squares of weights to be stored inside the histogram (equivalent to the number of entries per bin if weights of 1 are used). This information is needed to correctly calculate the errors of each bin entry when the methods TH1::Add and TH1::Divide are applied.

http://root.cern.ch/drupal/content/binned-data

A (1-dimensional) histogram is defined as the collection of the N pairs (1, n1), (2, n2), ..., (N, nN) and it is usually implemented as an array in which the first value of the pair (i, ni) is the index of the element containing the value ni.

Algorithm to compute the errors per bin If TH1::Sumw2 has been called for the histogram, the error computed is the square root of the sum of the square of weights for this bin. If not, the error computed is the square root of the bin content.

Associate error bars with this histogram (see TH1F::Sumw2())

Hi,

If the histogram represent counts, thus when each entry that is filled has a weight=1, the statistical error in each bin is computed as SQRT(N), where N is the number of entries in each bin, which by definition is in this case equal to the bin content.

If you are filling the histogram with a weight different than one, then the bin content is equal to the sum of the weight in each bin (different than the number of entries in each bin). The statistical error in this case con be approximately computed from SQRT( sum of weight^2) in each bin. However, in order to have the histogram doing this, you ned to set the option TH1::Sumw2(). By doing this the histogram will store the bin sum of weight square, that can be used to compute the errors.

So you should use this option when your histogram is filled with weights different than one.

Best Regards

Lorenzo

Your data points are counts (or weighted counts) ? If this is the case you should also set the errors as the square root of the sum of the weight square for each bin.

Lorenzo

If you have an histogram filled with counts and scaled with some weights you can use the weighted likelihood method. But you need to call Sumw2() and also not just SetBinContent() but also SetBinError() on your histogram, since the errors are not anymore the square root of the content. Note that if you call, as in your code, only Sumw2() and SetBinContent() the errors are set to zero.

Best Regards

Lorenzo

I have a TH1F. How to get its median value?
Is there some function which does this?

You can use the function TH1::GetQuantiles
and you use 0.5 as the probability value
Lorenzo

Another advanced note: If you know what you're doing, you can use the same trick that ROOT uses when it creates the histogram you create with commands like tree1->Draw("zv"). The trick is:

TH1* hist = new TH1D(...); // define your histogram hist->SetBit(TH1::kCanRebin); // allow the histogram to re-bin itself hist->Sumw2(); // so the error bars are correct after re-binning

“Re-binning” means that if a value is supplied to the histogram that's outside its limits, it will adjust those limits automatically. It does this by summing existing bins then doubling the bin width; the bin limits change, while the number of histogram bins remains constant.

A tangent I can indulge in, now that you know about filling histograms: Suppose you're told to fill two histograms, then add them together. If you do this, you'll want to call the "Sumw2" method of both histograms before you fill them; e.g.,

TH1* hist1 = new TH1D(...); TH1* hist2 = new TH1D(...); hist1->Sumw2(); hist2->Sumw2(); // Fill your histograms hist1->Fill(...); hist2->Fill(...); // Add hist2 to the contents of hist1: hist1->Add(hist2);

If you forget Sumw2, then your error bars after the math operation won't be correct. General rule: If you're going to perform histogram arithmetic, use Sumw2 (which means "sum the squares of the weights"). Some physicists use Sumw2 all the time, just in case.

– Use any time (zeby sumw2) you're weighting/scaling or doing an operation such as adding or dividing histograms – If in doubt, use Sumw2() it doesn’t hurt. The weights are 1 by default.

TH1::Sumw2() • Create structure to store sum of squares of weights • if histogram is already ﬁlled, the sum of squares of weights is ﬁlled with the existing bin contents • The error per bin will be computed as sqrt(sum of squares of weight) for each bin. • This function is automatically called when the histogram is created if the static function TH1::SetDefaultSumw2 has been called before In summary:

- Scaling => use sumw2
- Adding/Subtracting => use sumw2 if a histogram is weighted
- Multiplying/Dividing => use sumw2 if a histogram is weighted

Poisson je priblizenie binomial, ked average of successes is much smaller than possible number. v Principe OK, ale kukat do MiniSymposium09.ppt

- http://iktp.tu-dresden.de/IKTP/Seminare/IS2010/Christian_Gumpert.pdf
- TH1::Divide uses normal approximation which fails for ε → 1 or 0 → confidence intervals have bad coverage
- only one (bayesian) method for a proper error calculation is supported
- no reasonable results for weighted histograms
- external fitting routine (TBinomialEfficiencyFitter)

Sometimes events might have different weights

- Prescales.
- Changing a parent spectrum.
- Correcting for efficiencies.
- The weight is an extra parameter in the Fill method.

The error on a histogram bin is just √N - Poisson statistics But what if you’re using weights.

- Call Sumw2() before filling.
- The error is actually √(Σwi2) (Think about this, try w=1)
- The errors are usually calculated on the fly. (The errors are usually calculated on the fly., You need to call Sumw2() to save the errors if doing any operations on/with the histogram.)

# HTML5 SVG Demo (embed with img src);;;; http://edutechwiki.unige.ch/en/Using_SVG_with_HTML5_tutorial

A nice green circle that was embeded using the img element:

xrdgsiproxy destroy xrdgsiproxy init xrdgsiproxy info xrdcp tree800.root root://skaf.saske.sk:1098//musinsky/

root [0] TProof::Open("") +++ Starting PROOF-Lite with 4 workers +++ Opening connections to workers: OK (4 workers) Setting up worker servers: OK (4 workers)

gEnv->SetValue("XSec.GSI.DelegProxy", "2") // dovolim aby sa proxy rozdistrubuovalo aj na workers TProof::Open("alice-caf.cern.ch") TProof::Open("skaf.saske.sk") gProof->Exec(".!hostname") gProof->Exec("gROOT->GetVersion()") gProof->Exec("gSystem->Load(\"libGeom.so\")") TProof::Open("alice-caf.cern.ch", "workers=2") TProof::Open("alice-caf.cern.ch", "masteronly") gProof->ShowPackages() drwxr-xr-x 3 alicaf z2 4096 Oct 29 23:19 VO_ALICE@AliRoot::v5-02-07-AN gProof->EnablePackage("VO_ALICE@AliRoot::v5-02-07a-AN") gProof->ShowDataSets() /default/sahn/LHC10e_000130354_pass2 | 95 | /esdTree | 1.838e+05| 20 GB | 93 % gProof->ShowDataSets("/default/sahn/LHC10e_00013*") gProof->ShowDataSets("/alice/*") // for all data gProof->ShowDataSets("/alice/sim/*") // for sim data gProof->ShowDataSets("/alice/data/*") // for real data

http://www.w3.org/TR/SVG11/linking.html