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():
48 // standard constructor
51 AliCentralityBy1D::~AliCentralityBy1D() {
55 void AliCentralityBy1D::MakePercentiles() {
60 // open inrootfile, outrootfile
61 std::cout << "input file " << fInrootfilename << std::endl;
62 std::cout << "output file " << fOutrootfilename << std::endl;
63 inrootfile = new TFile(fInrootfilename,"OPEN");
64 //outrootfile = new TFile(fOutrootfilename,"RECREATE");
65 outrootfile = new TFile(fOutrootfilename,"UPDATE");
67 // loop over all distribution names
68 std::vector<TString>::const_iterator hni;
69 for(hni=fHistnames.begin(); hni!=fHistnames.end(); hni++) {
70 htemp = (TH1F*) (inrootfile->Get(*hni));
72 TList *list = (TList*) (inrootfile->Get("CentralityStat"));
73 htemp = (TH1F*) (list->FindObject(*hni));
76 TH1F *hpercent = (TH1F*) htemp->Clone("hpercent");
77 TString name=htemp->GetName();
78 name.Append("_percentile");
79 hpercent->SetNameTitle(name.Data(),name.Data());
82 int start_bin=htemp->FindBin(fMultLowBound);
83 for (int ibin=1; ibin<=htemp->GetNbinsX(); ibin++) {
86 hpercent->SetBinContent(ibin, fPercentXsec *
87 htemp->Integral(ibin,htemp->GetNbinsX()) /
88 htemp->Integral(start_bin,htemp->GetNbinsX()));
90 hpercent->SetBinContent(ibin, 100);
93 SaveHisto(htemp,hpercent,outrootfile);
97 // close inrootfile, outrootfile
103 void AliCentralityBy1D::SaveHisto(TH1F *hist1, TH1F *hist2, TFile *outrootfile) {
110 // Float_t centrality[]= {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.,90.,100.};
111 // for (int i=n-1; i>=0; i--) {
112 // x1[i] = hist2->GetBinCenter(hist2->FindLastBinAbove(centrality[i]));
113 // cout << x1[i] << ",";