]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/EVCHAR/AliCentralityBy1D.cxx
1) include NetParticle classes in PWGCFebyeLinkDef.h (was not done in last commit...
[u/mrichter/AliRoot.git] / PWGPP / EVCHAR / AliCentralityBy1D.cxx
CommitLineData
e6f3f2fe 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* Origin: Alberica Toia, CERN, Alberica.Toia@cern.ch */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// class to determine centrality percentiles from 1D distributions //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24#include <TNamed.h>
bfea6519 25#include <TH1F.h>
e6f3f2fe 26#include <TString.h>
27#include <TFile.h>
28#include <TMath.h>
29#include <TROOT.h>
30#include <TH2F.h>
31#include <TF1.h>
32#include <TStyle.h>
33#include <TGraphErrors.h>
34#include <vector>
35#include "AliCentralityBy1D.h"
36
37
38ClassImp(AliCentralityBy1D)
39
40//______________________________________________________________________________
41
42
bfea6519 43AliCentralityBy1D::AliCentralityBy1D():
44 fInrootfilename(0),
45 fOutrootfilename(0),
46 fHistnames()
47{
e6f3f2fe 48 // standard constructor
49}
50
51AliCentralityBy1D::~AliCentralityBy1D() {
52 // destructor
53}
54
bfea6519 55void AliCentralityBy1D::MakePercentiles() {
56 TH1F *htemp;
57 TFile *inrootfile;
e6f3f2fe 58 TFile *outrootfile;
bfea6519 59
e6f3f2fe 60 // open inrootfile, outrootfile
bfea6519 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");
66
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));
71 if (!htemp) {
72 TList *list = (TList*) (inrootfile->Get("CentralityStat"));
73 htemp = (TH1F*) (list->FindObject(*hni));
74 }
75
76 TH1F *hpercent = (TH1F*) htemp->Clone("hpercent");
77 TString name=htemp->GetName();
78 name.Append("_percentile");
79 hpercent->SetNameTitle(name.Data(),name.Data());
80 hpercent->Reset();
81
82 int start_bin=htemp->FindBin(fMultLowBound);
83 for (int ibin=1; ibin<=htemp->GetNbinsX(); ibin++) {
84
85 if (ibin>=start_bin)
86 hpercent->SetBinContent(ibin, fPercentXsec *
87 htemp->Integral(ibin,htemp->GetNbinsX()) /
88 htemp->Integral(start_bin,htemp->GetNbinsX()));
89 else
90 hpercent->SetBinContent(ibin, 100);
91 }
92
93 SaveHisto(htemp,hpercent,outrootfile);
94
e6f3f2fe 95 }
bfea6519 96
e6f3f2fe 97 // close inrootfile, outrootfile
98 inrootfile->Close();
99 outrootfile->Close();
100
101}
102
bfea6519 103void AliCentralityBy1D::SaveHisto(TH1F *hist1, TH1F *hist2, TFile *outrootfile) {
e6f3f2fe 104 outrootfile->cd();
a0de3fd1 105 hist1->Write();
106 hist2->Write();
107
108 // int n=12;
109 // Float_t x1[n];
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] << ",";
114 // }
115 // cout << endl;
116
e6f3f2fe 117}
118
119
120