]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrBase.cxx
updates from gsi trunk
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / ConvCorrelations / AliAnaConvCorrBase.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        *
3  * ALICE Experiment at CERN, All rights reserved.                         *
4  *                                                                        *
5  * Primary Author: Svein Lindal <slindal@fys.uio.no>                      *
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 /// @file   AliAnaConvCorrBase.cxx
17 /// @author Svein Lindal
18 /// @brief  Base class for analysation of conversion particle - track correlations
19
20
21 #include "AliAnaConvCorrBase.h"
22 #include "AliAODTrack.h"
23
24 #include "TClonesArray.h"
25 #include "TH1F.h"
26 #include "TH3.h"
27 #include "TList.h"
28 #include "AliAODConversionParticle.h"
29
30 #include <iostream>
31
32 // Gamma - jet correlation analysis task
33 // Authors: Svein Lindal
34
35
36 using namespace std;
37 ClassImp(AliAnaConvCorrBase)
38
39 //________________________________________________________________________
40 AliAnaConvCorrBase::AliAnaConvCorrBase(TString name, TString title = "title") : TNamed(name, title),
41   fHistograms(NULL),
42   fAxesList(NULL), 
43   fAxistPt(),
44   fAxiscPt(), 
45   fAxisdEta(), 
46   fAxisdPhi(),
47   fSparse(NULL)
48 {
49   //Constructor
50
51   SetUpDefaultBins();
52   
53   fAxesList.SetOwner(kTRUE);
54
55
56 }
57
58
59 //________________________________________________________________________________
60 AliAnaConvCorrBase::~AliAnaConvCorrBase() {
61   ///destructor
62 }
63
64
65 void AliAnaConvCorrBase::CreateHistograms() {
66   CreateBaseHistograms();
67 }
68
69 ///________________________________________________________________________________
70 void AliAnaConvCorrBase::SetUpDefaultBins() {
71   //Set up default bins
72   Double_t ptbins[19] = {0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0, 10.0, 12.5, 15, 20, 25, 30, 50, 100};
73   fAxisdEta.Set(160, -1.6, 1.6);
74   fAxisdEta.SetNameTitle("dEta", "delta eta");
75   fAxesList.AddAt(&fAxisdEta, 0);
76
77   fAxisdPhi.Set(64, -TMath::PiOver2(), 3*TMath::PiOver2());
78   fAxisdPhi.SetNameTitle("dPhi", "delta Phi");
79   fAxesList.AddAt(&fAxisdPhi, 1);
80
81   fAxistPt.Set(18, ptbins);
82   fAxistPt.SetNameTitle("tPt", "trigger Pt");
83   fAxesList.AddAt(&fAxistPt, 2);
84
85   fAxiscPt.Set(18, ptbins);
86   fAxiscPt.SetNameTitle("cPt", "track Pt");
87   fAxesList.AddAt(&fAxiscPt, 3);
88
89   for(int iIso = 0; iIso < 2; iIso++) {
90     fHNTriggers[iIso] = NULL;
91   }
92 }
93
94 //________________________________________________________________________
95 void AliAnaConvCorrBase::CreateBaseHistograms() {
96   //Create histograms add, to outputlis
97
98   cout << "Creating histograms for "<< GetName() << endl;
99
100   fHistograms = new TList();
101   fHistograms->SetOwner(kFALSE);
102   fHistograms->SetName(fName);
103
104   for(int iIso = 0; iIso < 2; iIso++) {
105
106     fHNTriggers[iIso] = new TH1F(Form("%s_%s_fNTriggers", fName.Data(), (iIso==0)?"nonIso":"isolated"), 
107                                                                  Form("%s_%s_fNTriggers", fName.Data(), (iIso==0)?"nonIso":"isolated"), 
108                                                                  fAxistPt.GetNbins(), fAxistPt.GetXbins()->GetArray());
109     fHNTriggers[iIso]->Sumw2();
110     fHistograms->Add(fHNTriggers[iIso]);
111   
112   }
113
114   fSparse = CreateSparse(GetName(), GetTitle(), &fAxesList);
115   fHistograms->Add(fSparse);
116
117 }
118
119 ///________________________________________________________________________
120 THnSparseF * AliAnaConvCorrBase::CreateSparse(TString nameString, TString titleString, TList * axesList) {
121   //Create sparse
122   const Int_t dim = axesList->GetSize();
123   
124   cout << "dimesion: " << dim << endl;
125
126   TAxis * axes[dim];
127   Int_t   bins[dim];
128   Double_t min[dim];
129   Double_t max[dim];
130
131   for(Int_t i = 0; i<dim; i++) {
132         TAxis * axis = dynamic_cast<TAxis*>(axesList->At(i));
133         if(axis) axes[i] = axis;
134         else {
135           cout << "AliAnalysisTaskdPhi::CreateSparse: Error error, all the axes are not present in axis list" << endl;
136           return NULL;
137         }
138   }
139
140   for(Int_t i = 0; i<dim; i++) {
141         cout << axes[i]->GetTitle() << endl;
142         bins[i] = axes[i]->GetNbins(); 
143         min[i] = axes[i]->GetBinLowEdge(1);
144         max[i] = axes[i]->GetBinUpEdge(axes[i]->GetNbins());
145   }
146
147   THnSparseF * sparse = new THnSparseF(Form("%s", nameString.Data()), 
148                                                                            Form("%s", titleString.Data()), 
149                                                                            dim, bins, min, max);
150   
151   for(Int_t i = 0; i<dim; i++) {
152         sparse->GetAxis(i)->SetNameTitle(axes[i]->GetName(), axes[i]->GetTitle() );
153         if(axes[i]->GetXbins()->GetSize() > 0) {
154           sparse->SetBinEdges(i, axes[i]->GetXbins()->GetArray() );
155         }
156   }
157   return sparse;
158 }
159
160
161 ///____________________________________________________________________________
162 // void AliAnaConvCorrBase::FillTriggerCounters(Float_t tPt, Bool_t isolated){ 
163 //   //Fill histogram with trigger counters
164
165 //   fHNTriggers[0]->Fill(tPt);
166   
167 //   if(isolated) {
168 //     fHNTriggers[isolated]->Fill(tPt);
169     
170 //   }
171 // }
172
173 // ///_____________________________________________________________________________
174 // void AliAnaConvCorrBase::FillHistograms(Float_t tPt, Float_t cPt, Float_t dPhi, Float_t dEta, Bool_t isolated) {
175 //   //Fill histograms
176
177 //   if(dEta) { ;}
178 //   //fHdPhi[0]->Fill(tPt, cPt, dPhi);
179 //   if(isolated) {
180 //     //fHdPhi[isolated]->Fill(tPt, cPt, dPhi);
181 //   }
182 // }
183
184 //_______________________________________________________________________________
185
186 void AliAnaConvCorrBase::PrintStatistics()  { 
187   //Print some statistics between each file
188   for(Int_t i = 1; i <= fHNTriggers[0]->GetNbinsX(); i++) {
189     Int_t nTrig = (Int_t) fHNTriggers[0]->GetBinContent(i+1);
190     cout << "triggers: " << nTrig << endl;
191
192   }
193 }
194
195
196 //_______________________________________________________________________________
197 void AliAnaConvCorrBase::FillTriggerCounters(const AliAODConversionParticle * particle, Bool_t leading) {
198   fHNTriggers[leading]->Fill(particle->Pt());
199 }
200
201
202 //________________________________________________________________
203 void AliAnaConvCorrBase::CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, Int_t const tIDs[4], Bool_t isolated /*= kFALSE*/) {
204   //Correlate particle with tracks
205
206   FillTriggerCounters(particle, isolated);
207
208  Int_t nDim = fAxesList.GetSize();
209   Double_t dphivalues[nDim];
210   
211   for(int ij = 0; ij < tracks->GetEntriesFast(); ij++) {
212         AliVTrack * track = static_cast<AliVTrack*>(tracks->UncheckedAt(ij));
213         Int_t tid = track->GetID();
214
215         if((tid > 0) && (tid == tIDs[0] || tid == tIDs[1] || tid == tIDs[2] || tid == tIDs[3]) ) {
216           continue;
217         }
218         
219         dphivalues[1] = GetDPhi(particle->Phi() - track->Phi());
220         dphivalues[0] = particle->Eta() - track->Eta();
221         dphivalues[2] = particle->Pt();
222         dphivalues[3] = track->Pt();
223         if(nDim > 4) dphivalues[4] = particle->M();
224         fSparse->Fill(dphivalues);
225   }
226 }
227