1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* Origin: Alberica Toia, CERN, Alberica.Toia@cern.ch */
18 ///////////////////////////////////////////////////////////////////////////////
20 // class to determine centrality percentiles from 1D distributions //
22 ///////////////////////////////////////////////////////////////////////////////
33 #include <TGraphErrors.h>
35 #include "AliCentralityBy1D.h"
38 ClassImp(AliCentralityBy1D)
40 //______________________________________________________________________________
43 AliCentralityBy1D::AliCentralityBy1D() {
44 // standard constructor
47 AliCentralityBy1D::~AliCentralityBy1D() {
51 void AliCentralityBy1D::AddHisto(TString name) {
52 histnames.push_back(name);
55 void AliCentralityBy1D::SetPercentileFile(TString filename) {
56 outrootfilename = filename;
59 void AliCentralityBy1D::SetPercentileCrossSection(Float_t xsec) {
63 void AliCentralityBy1D::MakePercentiles(TString infilename) {
68 // open inrootfile, outrootfile
69 inrootfile = new TFile(infilename);
70 outrootfile = new TFile(outrootfilename,"RECREATE");
72 // loop over all distribution names
74 vector<TString>::const_iterator hni;
75 for(hni=histnames.begin(); hni!=histnames.end(); hni++) {
76 thist = MakePercentHisto(*hni);
77 SaveHisto(thist,outrootfile);
80 // close inrootfile, outrootfile
86 TH1D * AliCentralityBy1D::MakePercentHisto(TString hdistributionName) {
87 TH1D *htemp = (TH1D*) (inrootfile->Get(hdistributionName));
88 TH1D *hpercent = (TH1D*) htemp->Clone("hpercent");
89 hpercent->SetName(hdistributionName.Append("_percentile"));
92 for (int ibin=1; ibin<=htemp->GetNbinsX(); ibin++) {
94 hpercent->SetBinContent(ibin, percentXsec *
95 htemp->Integral(ibin,htemp->GetNbinsX()) /
96 htemp->Integral(1,htemp->GetNbinsX()));
105 void AliCentralityBy1D::SaveHisto(TH1D *hist, TFile *outrootfile) {