]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/EVCHAR/AliCentralityBy1D.cxx
follow the old and nasty naming for consistency: FilterEvents_Trees.root
[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);
b40f1c0b 83 //cout << "START: " << start_bin << " " << fMultLowBound << " " << fPercentXsec << endl;
bfea6519 84 for (int ibin=1; ibin<=htemp->GetNbinsX(); ibin++) {
85
86 if (ibin>=start_bin)
87 hpercent->SetBinContent(ibin, fPercentXsec *
88 htemp->Integral(ibin,htemp->GetNbinsX()) /
89 htemp->Integral(start_bin,htemp->GetNbinsX()));
90 else
91 hpercent->SetBinContent(ibin, 100);
b40f1c0b 92
93 //if (ibin<700) cout << ibin << " " << hpercent->GetBinContent(ibin) << endl;
94 }
bfea6519 95
96 SaveHisto(htemp,hpercent,outrootfile);
97
e6f3f2fe 98 }
bfea6519 99
e6f3f2fe 100 // close inrootfile, outrootfile
101 inrootfile->Close();
102 outrootfile->Close();
103
104}
105
bfea6519 106void AliCentralityBy1D::SaveHisto(TH1F *hist1, TH1F *hist2, TFile *outrootfile) {
e6f3f2fe 107 outrootfile->cd();
a0de3fd1 108 hist1->Write();
109 hist2->Write();
110
111 // int n=12;
112 // Float_t x1[n];
113 // Float_t centrality[]= {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.,90.,100.};
114 // for (int i=n-1; i>=0; i--) {
115 // x1[i] = hist2->GetBinCenter(hist2->FindLastBinAbove(centrality[i]));
116 // cout << x1[i] << ",";
117 // }
118 // cout << endl;
119
e6f3f2fe 120}
121
122
123