]>
Commit | Line | Data |
---|---|---|
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 | ||
39 | using namespace std; | |
40 | ||
41 | ClassImp(AliSpectraAODHistoManager) | |
42 | ||
43 | ||
44 | using namespace AliSpectraNameSpace; | |
45 | ||
46 | AliSpectraAODHistoManager::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 | |
74 | TH2F* 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 | //_______________________________________________________ | |
95 | TH2F* 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 | ||
116 | TH2F* AliSpectraAODHistoManager::BookPIDHistogram(const char * name) | |
117 | { | |
118 | // Return a pt histogram with predefined binning, set the ID and add it to the output list | |
460eef36 | 119 | AliInfo(Form("Booking PID histogram %s", name)); |
c88234ad | 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 | ||
132 | TH2F* AliSpectraAODHistoManager::BookNSigHistogram(const char * name) | |
133 | { | |
134 | // Return a pt histogram with predefined binning, set the ID and add it to the output list | |
460eef36 | 135 | AliInfo(Form("Booking NSigma histogram %s", name)); |
823864bf | 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 | ||
148 | TH2F* 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 | ||
165 | TH1F* 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; | |
acef4f19 | 171 | Printf("--- Projecting %s on Xaxis[%f,%f]:",name,minDCA,maxDCA); |
172 | if(minDCA==-1 && maxDCA==-1){ | |
173 | outhist=(TH1F*)hist->ProjectionX("_px",0,-1,"e"); | |
174 | Printf("Full Range"); | |
175 | }else { | |
823864bf | 176 | Int_t firstbin=hist->GetYaxis()->FindBin(minDCA); |
acef4f19 | 177 | Int_t lastbin=hist->GetYaxis()->FindBin(maxDCA); |
823864bf | 178 | Printf("firstbin: %d lastbin: %d",firstbin,lastbin); |
6522a8cb | 179 | outhist=(TH1F*)hist->ProjectionX("_px",firstbin,lastbin,"e"); |
823864bf | 180 | } |
181 | Printf("Entries outhist: %.0f Entries hist: %.0f",outhist->GetEntries(),hist->GetEntries()); | |
182 | return outhist; | |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | ||
187 | TH1F* AliSpectraAODHistoManager::GetDCAHistogram1D(const char * name,Double_t minPt,Double_t maxPt) | |
188 | { | |
189 | // //return the projection of the TH2 (pt,DCA) in the DCA bin range [firstDCAbin,lastDCAbin] | |
190 | // //if minPt=-1 && maxPt=-1 the projection is done using the full DCA range | |
191 | TH2F *hist=(TH2F*)fOutputList->FindObject(name); | |
192 | TH1F *outhist=0x0; | |
acef4f19 | 193 | Printf("--- Projecting %s on Yaxis[%f,%f]:",name,minPt,maxPt); |
194 | if(minPt==-1 && maxPt==-1){ | |
195 | outhist=(TH1F*)hist->ProjectionY("_py",0,-1,"e"); | |
196 | Printf("Full Range"); | |
197 | }else { | |
823864bf | 198 | Int_t firstbin=hist->GetXaxis()->FindBin(minPt); |
acef4f19 | 199 | Int_t lastbin=hist->GetXaxis()->FindBin(maxPt); |
200 | Printf("firstbin: %d lastbin: %d",firstbin,lastbin); | |
6522a8cb | 201 | outhist=(TH1F*)hist->ProjectionY("_py",firstbin,lastbin,"e"); |
202 | 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 | 203 | } |
acef4f19 | 204 | Printf("Entries outhist: %.0f Entries hist: %.0f",outhist->GetEntries(),hist->GetEntries()); |
823864bf | 205 | return outhist; |
206 | } | |
207 | ||
208 | //_____________________________________________________________________________ | |
c88234ad | 209 | |
210 | Long64_t AliSpectraAODHistoManager::Merge(TCollection* list) | |
211 | { | |
212 | // Merge a list of AliSpectraAODHistoManager objects with this. | |
213 | // Returns the number of merged objects (including this). | |
214 | ||
215 | // AliInfo("Merging"); | |
216 | ||
217 | if (!list) | |
218 | return 0; | |
219 | ||
220 | if (list->IsEmpty()) | |
221 | return 1; | |
222 | ||
223 | TIterator* iter = list->MakeIterator(); | |
224 | TObject* obj; | |
225 | ||
226 | // collections of all histograms | |
227 | TList collections; | |
228 | ||
229 | Int_t count = 0; | |
230 | ||
231 | while ((obj = iter->Next())) { | |
232 | AliSpectraAODHistoManager* entry = dynamic_cast<AliSpectraAODHistoManager*> (obj); | |
233 | if (entry == 0) | |
234 | continue; | |
235 | ||
236 | TList * hlist = entry->GetOutputList(); | |
237 | collections.Add(hlist); | |
238 | count++; | |
239 | } | |
240 | ||
241 | fOutputList->Merge(&collections); | |
242 | ||
243 | delete iter; | |
244 | ||
245 | return count+1; | |
246 | } | |
247 | ||
c79cb435 | 248 | |
249 | TH1* AliSpectraAODHistoManager::GetHistogram1D(UInt_t histoType, UInt_t particleType, UInt_t charge) { | |
250 | // GetHistogram using particle ID and histogram type | |
251 | Int_t baseId = -1; | |
252 | ||
e8b0fe64 | 253 | if (particleType == kSpUndefined) { |
254 | AliError ("Trying to get histo for undefined particle"); | |
255 | return 0; | |
256 | } | |
257 | ||
c79cb435 | 258 | switch(histoType) { |
259 | case kHistPtGenTruePrimary: | |
260 | baseId = kHistPtGenTruePrimaryPionPlus; | |
261 | break; | |
262 | case kHistPtRecSigma: | |
263 | baseId = kHistPtRecSigmaPionPlus; | |
264 | break; | |
265 | case kHistPtRecTruePrimary: | |
266 | baseId = kHistPtRecTruePrimaryPionPlus; | |
267 | break; | |
2136acba | 268 | case kHistPtRecPrimary: |
269 | baseId = kHistPtRecPrimaryPionPlus; | |
270 | break; | |
c79cb435 | 271 | case kHistPtRecSigmaPrimary: |
272 | baseId = kHistPtRecSigmaPrimaryPionPlus; | |
273 | break; | |
274 | case kHistPtRecSigmaSecondaryMaterial: | |
275 | baseId = kHistPtRecSigmaSecondaryMaterialPionPlus; | |
276 | break; | |
277 | case kHistPtRecSigmaSecondaryWeakDecay: | |
278 | baseId = kHistPtRecSigmaSecondaryWeakDecayPionPlus; | |
279 | break; | |
e8b0fe64 | 280 | case kHistNSigTPC: |
281 | baseId = kHistNSigPionTPC; | |
282 | break; | |
283 | case kHistNSigTOF: | |
284 | baseId = kHistNSigPionTOF; | |
285 | break; | |
286 | case kHistNSigTPCTOF: | |
287 | baseId = kHistNSigPionTPCTOF; | |
288 | break; | |
c79cb435 | 289 | default: |
290 | baseId = -1; | |
291 | } | |
292 | ||
293 | if (baseId < 0) | |
2136acba | 294 | AliFatal(Form("Wrong histogram type %d", histoType)); |
c79cb435 | 295 | |
296 | baseId = baseId + particleType + 3*(charge); | |
297 | // cout << "ID " << baseId << endl; | |
298 | ||
299 | return GetHistogram(baseId); | |
300 | } | |
301 | ||
302 | TH2* AliSpectraAODHistoManager::GetHistogram2D(UInt_t histoType, UInt_t particleType, UInt_t charge){ | |
303 | // returns histo based on ids, casting it to TH2* | |
304 | return (TH2*) GetHistogram1D(histoType,particleType,charge); | |
305 | ||
306 | ||
307 | } |