]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODHistoManager.cxx
Axis and pr range fix
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / AliSpectraAODHistoManager.cxx
CommitLineData
c88234ad 1
2/**************************************************************************
3 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17//-----------------------------------------------------------------
18// AliSpectraAODHistoManager class
19//-----------------------------------------------------------------
20
21#include "TChain.h"
22#include "TTree.h"
23#include "TLegend.h"
24#include "TH1.h"
25#include "TH1F.h"
26#include "TH2F.h"
27#include "TCanvas.h"
28#include "AliAnalysisTask.h"
29#include "AliAnalysisManager.h"
30#include "AliAODTrack.h"
31#include "AliAODMCParticle.h"
32#include "AliAODEvent.h"
33#include "AliAODInputHandler.h"
34#include "AliAnalysisTaskESDfilter.h"
35#include "AliAnalysisDataContainer.h"
36#include "AliSpectraAODHistoManager.h"
37#include <iostream>
38
39using namespace std;
40
41ClassImp(AliSpectraAODHistoManager)
42
43
44using namespace AliSpectraNameSpace;
45
46AliSpectraAODHistoManager::AliSpectraAODHistoManager(const char *name): TNamed(name, "AOD Spectra Histo Manager"), fOutputList(0)
47{
48 // ctor
49 fOutputList = new TList;
50 fOutputList->SetOwner();
51 Bool_t oldStatus = TH1::AddDirectoryStatus();
52 TH1::AddDirectory(kFALSE);
53 for (Int_t ihist = 0; ihist < kNHist ; ihist++)
54 {
823864bf 55 if (ihist <= kNPtGenHist) BookPtGenHistogram(kHistName[ihist]); // PT histos
56 if (ihist > kNPtGenHist && ihist <= kNPtRecHist) BookPtRecHistogram(kHistName[ihist]); // PT histos
57 if (ihist > kNPtRecHist && ihist <= kNHistPID) BookPIDHistogram(kHistName[ihist]); // PID histos
58 if (ihist > kNHistPID && ihist <= kNHistNSig) BookNSigHistogram(kHistName[ihist]); // NSigmaSep histos
59 if (ihist > kNHistNSig) BookqVecHistogram(kHistName[ihist]); // qDistr histos
c88234ad 60 }
823864bf 61 //adding quickly o plot to check the centrality distr in two different ways
62 TH2F *hist=new TH2F("CentCheck","CentCheck",1000,0,100,1000,0,100);
63 hist->SetXTitle("fAOD->GetCentrality()->GetCentralityPercentile(V0M)");
64 hist->SetYTitle("fAOD->GetHeader()->GetCentralityP()->GetCentralityPercentileUnchecked(V0M)");
65 hist->Sumw2();
66 fOutputList->Add(hist);
67
c88234ad 68 TH1::AddDirectory(oldStatus);
69
70}
823864bf 71
c88234ad 72//_______________________________________________________
823864bf 73
74TH2F* AliSpectraAODHistoManager::BookPtGenHistogram(const char * name)
c88234ad 75{
76 // Return a pt histogram with predefined binning, set the ID and add it to the output list
77 AliInfo(Form("Booking pt histogram %s", name));
823864bf 78
79 //standard histo
80 const Double_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0};
81 Int_t nbinsTempl=52;
82
83 TH2F * hist = new TH2F(name,Form("P_{T} distribution (%s)", name),nbinsTempl,templBins,2,-0.5,1.5);//need to be at least 1 becuase the generated are filled with (pt,IsPhysPrim)
84 hist->GetXaxis()->SetTitle("generated P_{T} (GeV / c)");
85 hist->GetYaxis()->SetTitle("DCA xy");
86 hist->SetMarkerStyle(kFullCircle);
87 hist->Sumw2();
88 fOutputList->Add(hist);
89
90 return hist;
91}
c88234ad 92
823864bf 93
94//_______________________________________________________
95TH2F* AliSpectraAODHistoManager::BookPtRecHistogram(const char * name)
96{
97 // Return a pt histogram with predefined binning, set the ID and add it to the output list
98 AliInfo(Form("Booking pt histogram %s", name));
99
100 //standard histo
101 const Double_t templBins[] = {0.05,0.1,0.12,0.14,0.16,0.18,0.20,0.25,0.30,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0};
102 Int_t nbinsTempl=52;
103
104 TH2F * hist = new TH2F(name,Form("reconstructed P_{T} distribution (%s)", name),nbinsTempl,templBins,3000,-3,3);//need to be at least 1 becuase the generated are filled with (pt,IsPhysPrim)
c88234ad 105 hist->GetXaxis()->SetTitle("P_{T} (GeV / c)");
823864bf 106 hist->GetYaxis()->SetTitle("DCA xy");
c88234ad 107 hist->SetMarkerStyle(kFullCircle);
108 hist->Sumw2();
109 fOutputList->Add(hist);
110
111 return hist;
112}
823864bf 113
c88234ad 114//_____________________________________________________________________________
115
116TH2F* AliSpectraAODHistoManager::BookPIDHistogram(const char * name)
117{
118 // Return a pt histogram with predefined binning, set the ID and add it to the output list
119 AliInfo(Form("Booking pt histogram %s", name));
120
6522a8cb 121 TH2F * hist = new TH2F(name, Form("Particle Identification (%s)", name), 200, 0, 2.5, 2000, -1000, 1000);
823864bf 122 hist->GetXaxis()->SetTitle("(GeV / c)");
123 hist->GetYaxis()->SetTitle("PID signal");
c88234ad 124// hist->Sumw2();
125 fOutputList->Add(hist);
126
127 return hist;
128}
129
823864bf 130//_____________________________________________________________________________
131
132TH2F* AliSpectraAODHistoManager::BookNSigHistogram(const char * name)
133{
134 // Return a pt histogram with predefined binning, set the ID and add it to the output list
135 AliInfo(Form("Booking pt histogram %s", name));
136
6522a8cb 137 TH2F * hist = new TH2F(name, Form("Particle Identification (%s)", name), 200, 0, 2.5, 2000,-40, 40);
823864bf 138 hist->GetXaxis()->SetTitle("P (GeV / c)");
139 hist->GetYaxis()->SetTitle("TPC");
140 //hist->Sumw2();
141 fOutputList->Add(hist);
142
143 return hist;
144}
145
146//_____________________________________________________________________________
147
148TH2F* AliSpectraAODHistoManager::BookqVecHistogram(const char * name)
149{
150 // Return a pt histogram with predefined binning, set the ID and add it to the output list
151 AliInfo(Form("Booking q Vector histogram %s", name));
152
153 TH2F * hist = new TH2F(name, Form("q Vector distribution vs Centrality (%s)", name), 100, 0, 10, 100, 0, 100);
154 hist->GetXaxis()->SetTitle("q vector");
155 hist->GetYaxis()->SetTitle("Centrality (V0)");
156 // hist->Sumw2();
157 fOutputList->Add(hist);
158
159 return hist;
160}
161
162
163//_____________________________________________________________________________
164
165TH1F* AliSpectraAODHistoManager::GetPtHistogram1D(const char * name,Double_t minDCA,Double_t maxDCA)
166{
167 // //return the projection of the TH2 (pt,DCA) in the DCA bin range [firstDCAbin,lastDCAbin]
168 // //if minDCA=-1 && maxDCA=-1 the projection is done using the full DCA range
169 TH2F *hist=(TH2F*)fOutputList->FindObject(name);
170 TH1F *outhist=0x0;
6522a8cb 171 if(minDCA==-1 && maxDCA==-1)outhist=(TH1F*)hist->ProjectionX("_px",0,-1,"e");
823864bf 172 else {
173 Int_t firstbin=hist->GetYaxis()->FindBin(minDCA);
6522a8cb 174 Int_t lastbin=hist->GetYaxis()->FindBin(maxDCA-0.00000001);
823864bf 175 Printf("firstbin: %d lastbin: %d",firstbin,lastbin);
6522a8cb 176 outhist=(TH1F*)hist->ProjectionX("_px",firstbin,lastbin,"e");
823864bf 177 }
178 Printf("Entries outhist: %.0f Entries hist: %.0f",outhist->GetEntries(),hist->GetEntries());
179 return outhist;
180}
181
182//_____________________________________________________________________________
183
184TH1F* AliSpectraAODHistoManager::GetDCAHistogram1D(const char * name,Double_t minPt,Double_t maxPt)
185{
186 // //return the projection of the TH2 (pt,DCA) in the DCA bin range [firstDCAbin,lastDCAbin]
187 // //if minPt=-1 && maxPt=-1 the projection is done using the full DCA range
188 TH2F *hist=(TH2F*)fOutputList->FindObject(name);
189 TH1F *outhist=0x0;
6522a8cb 190 if(minPt==-1 && maxPt==-1)outhist=(TH1F*)hist->ProjectionY("_py",0,-1,"e");
823864bf 191 else {
192 Int_t firstbin=hist->GetXaxis()->FindBin(minPt);
6522a8cb 193 Int_t lastbin=hist->GetXaxis()->FindBin(maxPt-0.0000001);
194 outhist=(TH1F*)hist->ProjectionY("_py",firstbin,lastbin,"e");
195 Printf("GetDCAHistogram1D(%s) BinRange:%d %d Pt Range: %f %f",hist->GetName(),firstbin,lastbin,hist->GetXaxis()->GetBinLowEdge(firstbin),hist->GetXaxis()->GetBinLowEdge(firstbin)+hist->GetXaxis()->GetBinWidth(lastbin));
823864bf 196 }
197 return outhist;
198}
199
200//_____________________________________________________________________________
c88234ad 201
202Long64_t AliSpectraAODHistoManager::Merge(TCollection* list)
203{
204 // Merge a list of AliSpectraAODHistoManager objects with this.
205 // Returns the number of merged objects (including this).
206
207 // AliInfo("Merging");
208
209 if (!list)
210 return 0;
211
212 if (list->IsEmpty())
213 return 1;
214
215 TIterator* iter = list->MakeIterator();
216 TObject* obj;
217
218 // collections of all histograms
219 TList collections;
220
221 Int_t count = 0;
222
223 while ((obj = iter->Next())) {
224 AliSpectraAODHistoManager* entry = dynamic_cast<AliSpectraAODHistoManager*> (obj);
225 if (entry == 0)
226 continue;
227
228 TList * hlist = entry->GetOutputList();
229 collections.Add(hlist);
230 count++;
231 }
232
233 fOutputList->Merge(&collections);
234
235 delete iter;
236
237 return count+1;
238}
239