]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliAnalysisTaskJpsiCorrelation.cxx
* additional variables forAsako
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliAnalysisTaskJpsiCorrelation.cxx
1 /*************************************************************************
2 * Copyright(c) 1998-2009, 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 ///////////////////////////////////////////////////////////////////////////
17 //                                                                       //
18 //                        Analysis task for J/psi - hadron correlations  //
19 //                                                                       //
20 ///////////////////////////////////////////////////////////////////////////
21
22 #include <iostream>
23 using namespace std;
24
25 #include <TChain.h>
26 #include <TH1D.h>
27
28 #include <AliCFContainer.h>
29 #include <AliInputEventHandler.h>
30 #include <AliESDInputHandler.h>
31 #include <AliAODInputHandler.h>
32 #include <AliAnalysisManager.h>
33 #include <AliVEvent.h>
34 #include <AliTriggerAnalysis.h>
35 #include <AliESDtrackCuts.h>
36
37 #include "AliDielectron.h"
38 #include "AliDielectronHistos.h"
39 #include "AliDielectronCF.h"
40 #include "AliDielectronMC.h"
41 #include "AliAnalysisTaskMultiDielectron.h"
42
43 #include "AliAnalysisTaskJpsiCorrelation.h"
44 ClassImp(AliAnalysisTaskJpsiCorrelation)
45
46 //_________________________________________________________________________________
47 AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation() :
48   AliAnalysisTaskMultiDielectron(),
49   fTreesList(),
50   fESD(0x0),
51   fESDTrackCuts(0x0),
52   fIdxDielectron(0),
53   fNjpsiPerEvent(0),
54   fSign(0),
55   fJpsiM(0.0),
56   fJpsiPt(0.0),
57   fJpsiPhi(0.0),
58   fJpsiTheta(0.0),
59   fJpsiY(0.0),
60   fTrackPt(0.0),
61   fTrackPhi(0.0),
62   fTrackTheta(0.0),
63   fTrackEta(0.0),
64   fMultiDieleOutputs(0)
65 {
66   //
67   // Constructor
68   //
69   cout << "AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation()" << endl;
70 }
71
72 //_________________________________________________________________________________
73 AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation(const char *name) :
74   AliAnalysisTaskMultiDielectron(name),
75   fTreesList(),
76   fESD(0x0),
77   fESDTrackCuts(0x0),
78   fIdxDielectron(0),
79   fNjpsiPerEvent(0),
80   fSign(0),
81   fJpsiM(0.0),
82   fJpsiPt(0.0),
83   fJpsiPhi(0.0),
84   fJpsiTheta(0.0),
85   fJpsiY(0.0),
86   fTrackPt(0.0),
87   fTrackPhi(0.0),
88   fTrackTheta(0.0),
89   fTrackEta(0.0),
90   fMultiDieleOutputs(0)
91 {
92   //
93   // Constructor
94   //
95   /*
96   // Done in the AliAnalysisTaskMultiDielectron(name) constructor
97   DefineInput(0,TChain::Class());
98   DefineOutput(1, TList::Class());
99   DefineOutput(2, TList::Class());
100   DefineOutput(3, TH1D::Class());
101   */
102   // Add other outputs here
103   fMultiDieleOutputs = GetNoutputs();  // number of output slots in the mother analysis task
104   DefineOutput(fMultiDieleOutputs, TList::Class());
105 }
106
107
108 //_________________________________________________________________________________
109 void AliAnalysisTaskJpsiCorrelation::UserCreateOutputObjects()
110 {
111   //
112   // Add all histogram manager histogram lists to the output TList
113   //
114   cout << "AliAnalysisTaskJpsiCorrelation::UserCreateOutputObjects()" << endl;
115   AliAnalysisTaskMultiDielectron::UserCreateOutputObjects();
116
117   if (!fTreesList.IsEmpty()) return; //already initialised
118   fTreesList.SetOwner();
119
120   TIter nextDie(&fListDielectron);
121   AliDielectron *die=0;
122   while ( (die=static_cast<AliDielectron*>(nextDie())) ){
123     TTree* tree=new TTree(die->GetName(), die->GetTitle());
124     tree->Branch("idxDielectron",&fIdxDielectron,"fIdxDielectron/I");
125     tree->Branch("nJpsiPerEvent",&fNjpsiPerEvent,"fNjpsiPerEvent/I");
126     tree->Branch("sign",&fSign,"fSign/I");
127     tree->Branch("jpsiM",&fJpsiM,"fJpsiM/D");
128     tree->Branch("jpsiPt",&fJpsiPt,"fJpsiPt/D");
129     tree->Branch("jpsiPhi",&fJpsiPhi,"fJpsiPhi/D");
130     tree->Branch("jpsiTheta",&fJpsiTheta,"fJpsiTheta/D");
131     tree->Branch("jpsiY",&fJpsiY,"fJpsiY/D");
132     tree->Branch("trackPt",&fTrackPt,"fTrackPt/D");
133     tree->Branch("trackPhi",&fTrackPhi,"fTrackPhi/D");
134     tree->Branch("trackTheta",&fTrackTheta,"fTrackTheta/D");
135     tree->Branch("trackEta",&fTrackEta,"fTrackEta/D");
136     fTreesList.Add(tree);
137   }
138   
139   /*
140   PostData(1, &fListHistos);
141   PostData(2, &fListCF);
142   PostData(3, fEventStat);
143   */
144   PostData(fMultiDieleOutputs, &fTreesList);
145 }
146
147 //_________________________________________________________________________________
148 void AliAnalysisTaskJpsiCorrelation::UserExec(Option_t *option)
149 {
150   //
151   // Main loop. Called for every event
152   //
153   //cout << "AliAnalysisTaskJpsiCorrelation::UserExec(Option_t *option)" << endl;
154   if(fTreesList.IsEmpty()) return;
155   AliAnalysisTaskMultiDielectron::UserExec(option);
156
157   //cout << "ndielectrons = " << fListDielectron.GetEntries() << endl;    
158
159   AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> 
160     (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
161   if (!esdH) {
162     AliError("Could not get ESDInputHandler");
163     return;
164   } 
165
166   fESD = esdH->GetEvent();
167   
168   if (!fESD) {
169     AliError("fESD not available");
170     return;
171   }
172     
173   //Process event in all AliDielectron instances
174   TIter nextDie(&fListDielectron);
175   AliDielectron *die=0;
176   Int_t idie=0;
177   while ( (die=static_cast<AliDielectron*>(nextDie())) ){
178     //cout << "idie = " << idie << endl;
179     die->Process(fESD);
180     for(Int_t isign=0; isign<=2; ++isign) {
181       //cout << "isign = " << isign << endl;
182       Int_t nCandidates=0;
183       if(die->GetPairArray(isign))
184         nCandidates = die->GetPairArray(isign)->GetEntriesFast();
185       if(nCandidates<1) continue;
186       cout << "candidates = " << nCandidates << endl;
187       
188       fIdxDielectron = idie;
189       fSign = isign;
190       fNjpsiPerEvent = nCandidates;
191       
192       for(Int_t iCandidate=0; iCandidate<nCandidates; ++iCandidate) {
193         TIter nextPair(die->GetPairArray(isign));
194         AliDielectronPair* pair = NULL;
195         while ((pair = static_cast<AliDielectronPair*>(nextPair()))) {
196
197           fJpsiM     = pair->M();
198           fJpsiPt    = pair->Pt();
199           fJpsiPhi   = pair->Phi();
200           fJpsiTheta = pair->Theta();
201           fJpsiY     = pair->Y();
202           cout << "jpsiM = " << fJpsiM << endl;
203           cout << "jpsiPt = " << fJpsiPt << endl;
204           cout << "jpsiPhi = " << fJpsiPhi << endl;
205           cout << "jpsiTheta = " << fJpsiTheta << endl;
206           cout << "jpsiY = " << fJpsiY << endl;
207           
208           AliESDtrack* d1 = static_cast<AliESDtrack*>(pair->GetFirstDaughter());
209           AliESDtrack* d2 = static_cast<AliESDtrack*>(pair->GetSecondDaughter());
210           
211           for (Int_t idx = 0; idx < fESD->GetNumberOfTracks(); idx++) {
212             AliESDtrack* esdTrack = fESD->GetTrack(idx);
213             if(!esdTrack) continue;
214             if(esdTrack==d1) continue;
215             if(esdTrack==d2) continue;
216             if(!fESDTrackCuts->AcceptTrack(esdTrack)) continue;
217             
218             fTrackPt = esdTrack->Pt();
219             fTrackPhi = esdTrack->Phi();
220             fTrackTheta = esdTrack->Theta();
221             fTrackEta = esdTrack->Eta();
222
223             cout << "trackPt = " << fTrackPt << endl;
224             cout << "trackPhi = " << fTrackPhi << endl;
225             cout << "trackTheta = " << fTrackTheta << endl;
226             cout << "trackEta = " << fTrackEta << endl;
227
228             ((TTree*)fTreesList.At(idie))->Fill();
229           }
230         }
231       }
232     }
233     
234     ++idie;
235   }
236   
237   PostData(fMultiDieleOutputs, &fTreesList);
238 }
239
240 //_________________________________________________________________________________
241 void AliAnalysisTaskJpsiCorrelation::FinishTaskOutput()
242 {
243   //
244   // Finish function, called after all events 
245   //
246   cout << "AliAnalysisTaskJpsiCorrelation::FinishTaskOutput()" << endl;
247   AliAnalysisTaskMultiDielectron::FinishTaskOutput();
248 }