]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/totEt/AliAnalysisEt.cxx
Updating AliRoot version in CreateAlienHandlerCaloEtSim.C, implementing default track...
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisEt.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies
3 //  Base class for ESD & MC analysis
4 //  - reconstruction and MonteCarlo output
5 // implementation file
6 //
7 //*-- Authors: Oystein Djuvsland (Bergen), David Silvermyr (ORNL)
8 //_________________________________________________________________________
9
10 #include "AliAnalysisEt.h"
11 #include "TMath.h"
12 #include "TList.h"
13 #include "TH1F.h"
14 #include "TH2F.h"
15 #include "TTree.h"
16 #include <iostream>
17 #include "AliAnalysisEtCuts.h"
18 #include "AliVEvent.h"
19 #include "TDatabasePDG.h"
20 #include "Rtypes.h"
21
22 using namespace std;
23 ClassImp(AliAnalysisEt);
24
25
26 AliAnalysisEt::AliAnalysisEt() :
27         fHistogramNameSuffix("")
28         ,fCuts(0)
29         ,fPdgDB(0)
30         ,fPiPlusCode(0)
31         ,fPiMinusCode(0)
32         ,fKPlusCode(0)
33         ,fKMinusCode(0)
34         ,fProtonCode(0)
35         ,fAntiProtonCode(0)
36         ,fLambdaCode(0)
37         ,fAntiLambdaCode(0)
38         ,fK0SCode(0)
39         ,fOmegaCode(0)
40         ,fAntiOmegaCode(0)
41         ,fXi0Code(0)
42         ,fAntiXi0Code(0)
43         ,fXiCode(0)
44         ,fAntiXiCode(0)
45         ,fSigmaCode(0)
46         ,fAntiSigmaCode(0)
47         ,fK0LCode(0)
48         ,fNeutronCode(0)
49         ,fAntiNeutronCode(0)
50         ,fEPlusCode(0)
51         ,fEMinusCode(0)
52         ,fPionMass(0)
53         ,fTotEt(0)
54         ,fTotEtAcc(0)
55         ,fTotNeutralEt(0)
56         ,fTotNeutralEtAcc(0)
57         ,fTotChargedEt(0)
58         ,fTotChargedEtAcc(0)
59         ,fMultiplicity(0)
60         ,fChargedMultiplicity(0)
61         ,fNeutralMultiplicity(0)
62         ,fBaryonEt(0)
63         ,fAntiBaryonEt(0)
64         ,fMesonEt(0)
65         ,fBaryonEtAcc(0)
66         ,fAntiBaryonEtAcc(0)
67         ,fMesonEtAcc(0)
68         ,fProtonEt(0)
69         ,fChargedKaonEt(0)
70         ,fMuonEt(0)
71         ,fElectronEt(0)
72         ,fProtonEtAcc(0)
73         ,fChargedKaonEtAcc(0)
74         ,fMuonEtAcc(0)
75         ,fElectronEtAcc(0)
76         ,fEtaCut(0)
77         ,fEtaCutAcc(0)
78         ,fPhiCutAccMin(0)
79         ,fPhiCutAccMax(0)
80         ,fDetectorRadius(0)
81         ,fClusterEnergyCut(0) 
82         ,fSingleCellEnergyCut(0)
83         ,fHistEt(0)
84         ,fHistChargedEt(0)
85         ,fHistNeutralEt(0)
86         ,fHistEtAcc(0)
87         ,fHistChargedEtAcc(0)
88         ,fHistNeutralEtAcc(0)
89         ,fHistMult(0)
90         ,fHistChargedMult(0)
91         ,fHistNeutralMult(0)
92         ,fHistPhivsPtPos(0)
93         ,fHistPhivsPtNeg(0)
94         ,fHistBaryonEt(0)
95         ,fHistAntiBaryonEt(0)
96         ,fHistMesonEt(0)
97         ,fHistBaryonEtAcc(0)
98         ,fHistAntiBaryonEtAcc(0)
99         ,fHistMesonEtAcc(0)
100         ,fHistProtonEt(0)
101         ,fHistChargedKaonEt(0)
102         ,fHistMuonEt(0)
103         ,fHistElectronEt(0)
104         ,fHistProtonEtAcc(0)
105         ,fHistChargedKaonEtAcc(0)
106         ,fHistMuonEtAcc(0)
107         ,fHistElectronEtAcc(0)
108         ,fHistEtRecvsEtMC(0)
109         ,fHistTMDeltaR(0)
110         ,fTree(0)
111         ,fEsdtrackCutsTPC(0)
112 {
113 }
114
115 AliAnalysisEt::~AliAnalysisEt()
116 {
117
118 }
119
120 void AliAnalysisEt::FillOutputList(TList *list)
121 { // histograms to be added to output
122     list->Add(fHistEt);
123     list->Add(fHistChargedEt);
124     list->Add(fHistNeutralEt);
125
126     list->Add(fHistEtAcc);
127     list->Add(fHistChargedEtAcc);
128     list->Add(fHistNeutralEtAcc);
129
130     list->Add(fHistMult);
131     list->Add(fHistChargedMult);
132     list->Add(fHistNeutralMult);
133
134     list->Add(fHistPhivsPtPos);
135     list->Add(fHistPhivsPtNeg);
136
137     list->Add(fHistBaryonEt);
138     list->Add(fHistAntiBaryonEt);
139     list->Add(fHistMesonEt);
140
141     list->Add(fHistBaryonEtAcc);
142     list->Add(fHistAntiBaryonEtAcc);
143     list->Add(fHistMesonEtAcc);
144
145     list->Add(fHistProtonEtAcc);
146     list->Add(fHistChargedKaonEtAcc);
147     list->Add(fHistMuonEtAcc);
148     list->Add(fHistElectronEtAcc);
149
150     list->Add(fHistEtRecvsEtMC);
151
152     list->Add(fHistTMDeltaR);
153
154     if (fCuts) {
155       if (fCuts->GetHistMakeTree()) {
156         list->Add(fTree);
157       }
158     }
159
160 }
161
162 void AliAnalysisEt::Init()
163 {// clear variables, set up cuts and PDG info
164   ResetEventValues();
165 }
166
167 void AliAnalysisEt::CreateHistograms()
168 { // create histograms..
169   // histogram binning for E_T, p_T and Multiplicity: defaults for p+p
170   Int_t nbinsEt = 1000;
171   Double_t minEt = 0.0001;
172   Double_t maxEt = 100;
173   Int_t nbinsPt = 200;
174   Double_t minPt = 0;
175   Double_t maxPt = 20;
176   Int_t nbinsMult = 200;
177   Double_t minMult = -0.5; // offset -0.5 to have integer bins centered around 0
178   Double_t maxMult = nbinsMult + minMult; // 1 bin per integer value
179
180   // see if we should change histogram limits etc, and possibly create a tree
181   if (fCuts) {
182     if (fCuts->GetHistMakeTree()) {
183       CreateTree();
184     }
185
186     nbinsMult = fCuts->GetHistNbinsMult();
187     minMult = fCuts->GetHistMinMult();
188     maxMult = fCuts->GetHistMaxMult();
189
190     nbinsEt = fCuts->GetHistNbinsTotEt();
191     minEt = fCuts->GetHistMinTotEt();
192     maxEt = fCuts->GetHistMaxTotEt();
193
194     nbinsPt = fCuts->GetHistNbinsParticlePt();
195     minPt = fCuts->GetHistMinParticlePt();
196     maxPt = fCuts->GetHistMaxParticlePt();
197   }
198
199     TString histname = "fHistEt" + fHistogramNameSuffix;
200     fHistEt = new TH1F(histname.Data(), "Total E_{T} Distribution", nbinsEt, minEt, maxEt);
201     fHistEt->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
202     fHistEt->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
203
204     histname = "fHistChargedEt" + fHistogramNameSuffix;
205     fHistChargedEt = new TH1F(histname.Data(), "Total Charged E_{T} Distribution", nbinsEt, minEt, maxEt);
206     fHistChargedEt->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
207     fHistChargedEt->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
208
209     histname = "fHistNeutralEt" + fHistogramNameSuffix;
210     fHistNeutralEt = new TH1F(histname.Data(), "Total Neutral E_{T} Distribution", nbinsEt, minEt, maxEt);
211     fHistNeutralEt->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
212     fHistNeutralEt->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
213
214     histname = "fHistEtAcc" + fHistogramNameSuffix;
215     fHistEtAcc = new TH1F(histname.Data(), "Total E_{T} Distribution in Acceptance", nbinsEt, minEt, maxEt);
216     fHistEtAcc->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
217     fHistEtAcc->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
218
219     histname = "fHistChargedEtAcc" + fHistogramNameSuffix;
220     fHistChargedEtAcc = new TH1F(histname.Data(), "Total Charged E_{T} Distribution in Acceptance", nbinsEt, minEt, maxEt);
221     fHistChargedEtAcc->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
222     fHistChargedEtAcc->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
223
224     histname = "fHistNeutralEtAcc" + fHistogramNameSuffix;
225     fHistNeutralEtAcc = new TH1F(histname.Data(), "Total Neutral E_{T} Distribution in Acceptance", nbinsEt, minEt, maxEt);
226     fHistNeutralEtAcc->GetXaxis()->SetTitle("E_{T} (GeV/c^{2})");
227     fHistNeutralEtAcc->GetYaxis()->SetTitle("dN/dE_{T} (c^{2}/GeV)");
228     std::cout << histname << std::endl;
229     histname = "fHistMult" + fHistogramNameSuffix;
230     fHistMult = new TH1F(histname.Data(), "Total Multiplicity", nbinsMult, minMult, maxMult);
231     fHistMult->GetXaxis()->SetTitle("N");
232     fHistMult->GetYaxis()->SetTitle("Multiplicity");
233
234     histname = "fHistChargedMult" + fHistogramNameSuffix;
235     fHistChargedMult = new TH1F(histname.Data(), "Charged Multiplicity", nbinsMult, minMult, maxMult);
236     fHistChargedMult->GetXaxis()->SetTitle("N");
237     fHistChargedMult->GetYaxis()->SetTitle("Multiplicity");
238
239     histname = "fHistNeutralMult" + fHistogramNameSuffix;
240     fHistNeutralMult = new TH1F(histname.Data(), "Neutral Multiplicity", nbinsMult, minMult, maxMult);
241     fHistNeutralMult->GetXaxis()->SetTitle("N");
242     fHistNeutralMult->GetYaxis()->SetTitle("Multiplicity");
243
244     histname = "fHistPhivsPtPos" + fHistogramNameSuffix;
245     fHistPhivsPtPos = new TH2F(histname.Data(), "Phi vs pT of positively charged tracks hitting the calorimeter",       200, 0, 2*TMath::Pi(), nbinsPt, minPt, maxPt);
246
247     histname = "fHistPhivsPtNeg" + fHistogramNameSuffix;
248     fHistPhivsPtNeg = new TH2F(histname.Data(), "Phi vs pT of negatively charged tracks hitting the calorimeter",       200, 0, 2*TMath::Pi(), nbinsPt, minPt, maxPt);
249
250     histname = "fHistBaryonEt" + fHistogramNameSuffix;
251     fHistBaryonEt = new TH1F(histname.Data(), "E_{T} for baryons",  nbinsEt, minEt, maxEt);
252
253     histname = "fHistAntiBaryonEt" + fHistogramNameSuffix;
254     fHistAntiBaryonEt = new TH1F(histname.Data(), "E_{T} for anti baryons",  nbinsEt, minEt, maxEt);
255
256     histname = "fHistMesonEt" + fHistogramNameSuffix;
257     fHistMesonEt = new TH1F(histname.Data(), "E_{T} for mesons",  nbinsEt, minEt, maxEt);
258
259     histname = "fHistBaryonEtAcc" + fHistogramNameSuffix;
260     fHistBaryonEtAcc = new TH1F(histname.Data(), "E_{T} for baryons in calorimeter acceptance",  nbinsEt, minEt, maxEt);
261
262     histname = "fHistAntiBaryonEtAcc" + fHistogramNameSuffix;
263     fHistAntiBaryonEtAcc = new TH1F(histname.Data(), "E_{T} for anti baryons in calorimeter acceptance",  nbinsEt, minEt, maxEt);
264
265     histname = "fHistMesonEtAcc" + fHistogramNameSuffix;
266     fHistMesonEtAcc = new TH1F(histname.Data(), "E_{T} for mesons in calorimeter acceptance",  nbinsEt, minEt, maxEt);
267
268     histname = "fHistProtonEt" + fHistogramNameSuffix;
269     fHistProtonEt = new TH1F(histname.Data(), "E_{T} for (anti-)protons", nbinsEt, minEt, maxEt);
270
271     histname = "fHistKaonEt" + fHistogramNameSuffix;
272     fHistChargedKaonEt = new TH1F(histname.Data(), "E_{T} for charged kaons", nbinsEt, minEt, maxEt);
273
274     histname = "fHistMuonEt" + fHistogramNameSuffix;
275     fHistMuonEt = new TH1F(histname.Data(), "E_{T} for muons", nbinsEt, minEt, maxEt);
276
277     histname = "fHistElectronEt" + fHistogramNameSuffix;
278     fHistElectronEt = new TH1F(histname.Data(), "E_{T} for electrons/positrons", nbinsEt, minEt, maxEt);
279
280     histname = "fHistProtonEtAcc" + fHistogramNameSuffix;
281     fHistProtonEtAcc = new TH1F(histname.Data(), "E_{T} for (anti-)protons in calorimeter acceptance", nbinsEt, minEt, maxEt);
282
283     histname = "fHistKaonEtAcc" + fHistogramNameSuffix;
284     fHistChargedKaonEtAcc = new TH1F(histname.Data(), "E_{T} for charged kaons in calorimeter acceptance", nbinsEt, minEt, maxEt);
285
286     histname = "fHistMuonEtAcc" + fHistogramNameSuffix;
287     fHistMuonEtAcc = new TH1F(histname.Data(), "E_{T} for muons in calorimeter acceptance", nbinsEt, minEt, maxEt);
288
289     histname = "fHistElectronEtAcc" + fHistogramNameSuffix;
290     fHistElectronEtAcc = new TH1F(histname.Data(), "E_{T} for electrons/positrons in calorimeter acceptance", nbinsEt, minEt, maxEt);
291
292     histname = "fHistEtRecvsEtMC" + fHistogramNameSuffix;
293     fHistEtRecvsEtMC = new TH2F(histname.Data(), "Reconstructed E_{t} vs MC E_{t}", nbinsEt, minEt, maxEt, nbinsEt, minEt, maxEt);
294
295     //
296     histname = "fHistTMDeltaR" + fHistogramNameSuffix;
297     fHistTMDeltaR = new TH1F(histname.Data(), "#Delta R for calorimeter clusters", 200, 0, 50);
298
299 }
300
301 void AliAnalysisEt::CreateTree()
302 { // create tree..
303   TString treename = "fTree" + fHistogramNameSuffix;
304   fTree = new TTree(treename, treename);
305   fTree->Branch("fTotEt",&fTotEt,"fTotEt/D");
306   fTree->Branch("fTotEtAcc",&fTotEtAcc,"fTotEtAcc/D");
307   fTree->Branch("fTotNeutralEt",&fTotNeutralEt,"fTotNeutralEt/D");
308   fTree->Branch("fTotNeutralEtAcc",&fTotNeutralEtAcc,"fTotNeutralEtAcc/D");
309   fTree->Branch("fTotChargedEt",&fTotChargedEt,"fTotChargedEt/D");
310   fTree->Branch("fTotChargedEtAcc",&fTotChargedEtAcc,"fTotChargedEtAcc/D");
311   fTree->Branch("fMultiplicity",&fMultiplicity,"fMultiplicity/I");
312   fTree->Branch("fChargedMultiplicity",&fChargedMultiplicity,"fChargedMultiplicity/I");
313   fTree->Branch("fNeutralMultiplicity",&fNeutralMultiplicity,"fNeutralMultiplicity/I");
314   fTree->Branch("fBaryonEt",&fBaryonEt,"fBaryonEt/D");
315   fTree->Branch("fAntiBaryonEt",&fAntiBaryonEt,"fAntiBaryonEt/D");
316   fTree->Branch("fMesonEt",&fMesonEt,"fMesonEt/D");
317   fTree->Branch("fBaryonEtAcc",&fBaryonEtAcc,"fBaryonEtAcc/D");
318   fTree->Branch("fAntiBaryonEtAcc",&fAntiBaryonEtAcc,"fAntiBaryonEtAcc/D");
319   fTree->Branch("fMesonEtAcc",&fMesonEtAcc,"fMesonEtAcc/D");
320   fTree->Branch("fProtonEt",&fProtonEt,"fProtonEt/D");
321   fTree->Branch("fChargedKaonEt",&fChargedKaonEt,"fChargedKaonEt/D");
322   fTree->Branch("fMuonEt",&fMuonEt,"fMuonEt/D");
323   fTree->Branch("fElectronEt",&fElectronEt,"fElectronEt/D");
324   fTree->Branch("fProtonEtAcc",&fProtonEtAcc,"fProtonEtAcc/D");
325   fTree->Branch("fChargedKaonEtAcc",&fChargedKaonEtAcc,"fChargedKaonEtAcc/D");
326   fTree->Branch("fMuonEtAcc",&fMuonEtAcc,"fMuonEtAcc/D");
327   fTree->Branch("fElectronEtAcc",&fElectronEtAcc,"fElectronEtAcc/D");
328
329   return;
330 }
331
332 void AliAnalysisEt::FillHistograms()
333 { // fill histograms..
334     fHistEt->Fill(fTotEt);
335     fHistChargedEt->Fill(fTotChargedEt);
336     fHistNeutralEt->Fill(fTotNeutralEt);
337
338     fHistEtAcc->Fill(fTotEtAcc);
339     fHistChargedEtAcc->Fill(fTotChargedEtAcc);
340     fHistNeutralEtAcc->Fill(fTotNeutralEtAcc);
341
342     fHistMult->Fill(fMultiplicity);
343     fHistChargedMult->Fill(fChargedMultiplicity);
344     fHistNeutralMult->Fill(fNeutralMultiplicity);
345
346     fHistBaryonEt->Fill(fBaryonEt);
347     fHistAntiBaryonEt->Fill(fAntiBaryonEt);
348     fHistMesonEt->Fill(fMesonEt);
349
350     fHistBaryonEtAcc->Fill(fBaryonEtAcc);
351     fHistAntiBaryonEtAcc->Fill(fAntiBaryonEtAcc);
352     fHistMesonEtAcc->Fill(fMesonEtAcc);
353  
354     fHistProtonEt->Fill(fProtonEt);
355     fHistChargedKaonEt->Fill(fChargedKaonEt);
356     fHistMuonEt->Fill(fMuonEt);
357     fHistElectronEt->Fill(fElectronEt);
358     
359     fHistProtonEtAcc->Fill(fProtonEtAcc);
360     fHistChargedKaonEtAcc->Fill(fChargedKaonEtAcc);
361     fHistMuonEtAcc->Fill(fMuonEtAcc);
362     fHistElectronEtAcc->Fill(fElectronEtAcc);
363
364     if (fCuts) {
365       if (fCuts->GetHistMakeTree()) {
366         fTree->Fill();
367       }
368     }
369
370 }
371
372 Int_t AliAnalysisEt::AnalyseEvent(AliVEvent *event)
373 { //this line is basically here to eliminate a compiler warning that event is not used.  Making it a virtual function did not work with the plugin.
374   cout << "This event has " << event->GetNumberOfTracks() << " tracks" << endl;
375   ResetEventValues();
376   return 0;
377 }
378
379 void AliAnalysisEt::ResetEventValues()
380 { // clear
381   fTotEt = 0;
382   fTotEtAcc = 0;
383   fTotNeutralEt = 0;
384   fTotNeutralEtAcc = 0;
385   fTotChargedEt  = 0;
386   fTotChargedEtAcc = 0;
387   fMultiplicity = 0;
388   fChargedMultiplicity = 0;
389   fNeutralMultiplicity = 0;
390   fBaryonEt = 0;
391   fAntiBaryonEt = 0;
392   fMesonEt = 0;
393   fBaryonEtAcc = 0;
394   fAntiBaryonEtAcc = 0;
395   fMesonEtAcc = 0;
396   fProtonEt = 0;
397   fChargedKaonEt = 0;
398   fMuonEt = 0;
399   fElectronEt = 0;
400   fProtonEtAcc = 0;
401   fChargedKaonEtAcc = 0;
402   fMuonEtAcc = 0;
403   fElectronEtAcc = 0;
404     
405   if (!fCuts || !fPdgDB || fPiPlusCode==0) { // some Init's needed
406     cout << __FILE__ << ":" << __LINE__ << " : Init " << endl;
407     if (!fCuts) {
408       cout << " setting up Cuts " << endl;
409       fCuts = new AliAnalysisEtCuts();
410     }
411     if(!fPdgDB) {
412       cout << " setting up PdgDB " << endl;
413       fPdgDB = new TDatabasePDG();
414     }
415     
416     if (fPiPlusCode==0) {
417       SetParticleCodes();
418     }
419   }
420   return;
421 }
422
423
424 void AliAnalysisEt::SetParticleCodes()
425 { // set PDG info    
426   fPionMass = fPdgDB->GetParticle("pi+")->Mass();
427   fPiPlusCode = fPdgDB->GetParticle("pi+")->PdgCode();
428   fPiMinusCode = fPdgDB->GetParticle("pi-")->PdgCode();
429   fKPlusCode = fPdgDB->GetParticle("K+")->PdgCode();
430   fKMinusCode = fPdgDB->GetParticle("K-")->PdgCode();
431   fProtonCode = fPdgDB->GetParticle("proton")->PdgCode();
432   fAntiProtonCode = fPdgDB->GetParticle("antiproton")->PdgCode();
433   fLambdaCode = fPdgDB->GetParticle("Lambda0")->PdgCode();
434   fAntiLambdaCode = fPdgDB->GetParticle("Lambda0_bar")->PdgCode();
435   fK0SCode = fPdgDB->GetParticle("K_S0")->PdgCode();
436   fOmegaCode = fPdgDB->GetParticle("Omega-")->PdgCode();
437   fAntiOmegaCode = fPdgDB->GetParticle("Omega+")->PdgCode();
438   fXi0Code = fPdgDB->GetParticle("Xi0")->PdgCode();
439   fAntiXi0Code = fPdgDB->GetParticle("Xi0_bar")->PdgCode();
440   fXiCode = fPdgDB->GetParticle("Xi-")->PdgCode();
441   fAntiXiCode = fPdgDB->GetParticle("Xi-_bar")->PdgCode();
442   fSigmaCode = fPdgDB->GetParticle("Sigma-")->PdgCode();
443   fAntiSigmaCode = fPdgDB->GetParticle("Sigma+")->PdgCode();
444   fK0LCode = fPdgDB->GetParticle("K_L0")->PdgCode();
445   fNeutronCode = fPdgDB->GetParticle("neutron")->PdgCode();
446   fAntiNeutronCode = fPdgDB->GetParticle("antineutron")->PdgCode();
447   fEPlusCode = fPdgDB->GetParticle("e+")->PdgCode();
448   fEMinusCode = fPdgDB->GetParticle("e-")->PdgCode();
449   cout << "Resetting Codes: Pion " << fPiPlusCode
450        << "," << fPiMinusCode 
451        << " Kaon " << fKPlusCode 
452        << "," << fKMinusCode << endl;
453 }
454