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::SetMultLowBound(Float_t mult) {
67 void AliCentralityBy1D::MakePercentiles(TString infilename) {
72 // open inrootfile, outrootfile
73 inrootfile = new TFile(infilename);
74 outrootfile = new TFile(outrootfilename,"RECREATE");
76 // loop over all distribution names
78 vector<TString>::const_iterator hni;
79 for(hni=histnames.begin(); hni!=histnames.end(); hni++) {
80 thist = MakePercentHisto(*hni);
81 TH1D *htemp = (TH1D*) (inrootfile->Get(*hni));
82 SaveHisto(htemp,thist,outrootfile);
85 // close inrootfile, outrootfile
91 TH1D * AliCentralityBy1D::MakePercentHisto(TString hdistributionName) {
92 TH1D *htemp = (TH1D*) (inrootfile->Get(hdistributionName));
93 // TList *list = (TList*) (inrootfile->Get("chist"));
94 // TH1D *htemp = (TH1D*) (list->FindObject(hdistributionName));
95 TH1D *hpercent = (TH1D*) htemp->Clone("hpercent");
96 hpercent->SetName(hdistributionName.Append("_percentile"));
99 int start_bin=htemp->FindBin(multLowBound);
100 for (int ibin=1; ibin<=htemp->GetNbinsX(); ibin++) {
103 hpercent->SetBinContent(ibin, percentXsec *
104 htemp->Integral(ibin,htemp->GetNbinsX()) /
105 htemp->Integral(start_bin,htemp->GetNbinsX()));
107 hpercent->SetBinContent(ibin, 100);
115 void AliCentralityBy1D::SaveHisto(TH1D *hist1, TH1D *hist2, TFile *outrootfile) {
122 // Float_t centrality[]= {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.,90.,100.};
123 // for (int i=n-1; i>=0; i--) {
124 // x1[i] = hist2->GetBinCenter(hist2->FindLastBinAbove(centrality[i]));
125 // cout << x1[i] << ",";