1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
18 // Analysis task for J/psi - hadron correlations //
20 ///////////////////////////////////////////////////////////////////////////
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>
37 #include "AliDielectron.h"
38 #include "AliDielectronHistos.h"
39 #include "AliDielectronCF.h"
40 #include "AliDielectronMC.h"
41 #include "AliAnalysisTaskMultiDielectron.h"
43 #include "AliAnalysisTaskJpsiCorrelation.h"
44 ClassImp(AliAnalysisTaskJpsiCorrelation)
46 //_________________________________________________________________________________
47 AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation() :
48 AliAnalysisTaskMultiDielectron(),
69 cout << "AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation()" << endl;
72 //_________________________________________________________________________________
73 AliAnalysisTaskJpsiCorrelation::AliAnalysisTaskJpsiCorrelation(const char *name) :
74 AliAnalysisTaskMultiDielectron(name),
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());
102 // Add other outputs here
103 fMultiDieleOutputs = GetNoutputs(); // number of output slots in the mother analysis task
104 DefineOutput(fMultiDieleOutputs, TList::Class());
108 //_________________________________________________________________________________
109 void AliAnalysisTaskJpsiCorrelation::UserCreateOutputObjects()
112 // Add all histogram manager histogram lists to the output TList
114 cout << "AliAnalysisTaskJpsiCorrelation::UserCreateOutputObjects()" << endl;
115 AliAnalysisTaskMultiDielectron::UserCreateOutputObjects();
117 if (!fTreesList.IsEmpty()) return; //already initialised
118 fTreesList.SetOwner();
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);
140 PostData(1, &fListHistos);
141 PostData(2, &fListCF);
142 PostData(3, fEventStat);
144 PostData(fMultiDieleOutputs, &fTreesList);
147 //_________________________________________________________________________________
148 void AliAnalysisTaskJpsiCorrelation::UserExec(Option_t *option)
151 // Main loop. Called for every event
153 //cout << "AliAnalysisTaskJpsiCorrelation::UserExec(Option_t *option)" << endl;
154 if(fTreesList.IsEmpty()) return;
155 AliAnalysisTaskMultiDielectron::UserExec(option);
157 //cout << "ndielectrons = " << fListDielectron.GetEntries() << endl;
159 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>
160 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
162 AliError("Could not get ESDInputHandler");
166 fESD = esdH->GetEvent();
169 AliError("fESD not available");
173 //Process event in all AliDielectron instances
174 TIter nextDie(&fListDielectron);
175 AliDielectron *die=0;
177 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
178 //cout << "idie = " << idie << endl;
180 for(Int_t isign=0; isign<=2; ++isign) {
181 //cout << "isign = " << isign << endl;
183 if(die->GetPairArray(isign))
184 nCandidates = die->GetPairArray(isign)->GetEntriesFast();
185 if(nCandidates<1) continue;
186 cout << "candidates = " << nCandidates << endl;
188 fIdxDielectron = idie;
190 fNjpsiPerEvent = nCandidates;
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()))) {
198 fJpsiPt = pair->Pt();
199 fJpsiPhi = pair->Phi();
200 fJpsiTheta = pair->Theta();
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;
208 AliESDtrack* d1 = static_cast<AliESDtrack*>(pair->GetFirstDaughter());
209 AliESDtrack* d2 = static_cast<AliESDtrack*>(pair->GetSecondDaughter());
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;
218 fTrackPt = esdTrack->Pt();
219 fTrackPhi = esdTrack->Phi();
220 fTrackTheta = esdTrack->Theta();
221 fTrackEta = esdTrack->Eta();
223 cout << "trackPt = " << fTrackPt << endl;
224 cout << "trackPhi = " << fTrackPhi << endl;
225 cout << "trackTheta = " << fTrackTheta << endl;
226 cout << "trackEta = " << fTrackEta << endl;
228 ((TTree*)fTreesList.At(idie))->Fill();
237 PostData(fMultiDieleOutputs, &fTreesList);
240 //_________________________________________________________________________________
241 void AliAnalysisTaskJpsiCorrelation::FinishTaskOutput()
244 // Finish function, called after all events
246 cout << "AliAnalysisTaskJpsiCorrelation::FinishTaskOutput()" << endl;
247 AliAnalysisTaskMultiDielectron::FinishTaskOutput();