1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: The ALICE Off-line Project. *
\r
5 * Contributors are mentioned in the code where appropriate. *
\r
7 * Permission to use, copy, modify and distribute this software and its *
\r
8 * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * without fee, provided that the above copyright notice appears in all *
\r
10 * copies and that both the copyright notice and this permission notice *
\r
11 * appear in the supporting documentation. The authors make no claims *
\r
12 * about the suitability of this software for any purpose. It is *
\r
13 * provided "as is" without express or implied warranty. *
\r
14 **************************************************************************/
\r
21 #include "TCanvas.h"
\r
25 #include "AliAnalysisTask.h"
\r
26 #include "AliAnalysisManager.h"
\r
27 #include "AliESDEvent.h"
\r
28 #include "AliESDInputHandler.h"
\r
29 #include "AliESDVertex.h"
\r
30 #include "AliTracker.h"
\r
31 #include "AliGeomManager.h"
\r
33 #include "AliCentrality.h"
\r
34 #include "AliESDVZERO.h"
\r
35 #include "AliMultiplicity.h"
\r
37 #include "AliESDtrackCuts.h"
\r
38 #include "AliMCEventHandler.h"
\r
39 #include "dNdPt/AlidNdPt.h"
\r
40 #include "dNdPt/AlidNdPtEventCuts.h"
\r
41 #include "dNdPt/AlidNdPtAcceptanceCuts.h"
\r
43 #include "dNdPt/AlidNdPtTask.h"
\r
45 using namespace std;
\r
47 ClassImp(AlidNdPtTask)
\r
49 //_____________________________________________________________________________
\r
50 AlidNdPtTask::AlidNdPtTask(const char *name)
\r
51 : AliAnalysisTaskSE(name)
\r
57 , fUseMCInfo(kFALSE)
\r
58 , fUseCentrality(0) // default = off
\r
59 , fUseCentralityBin(0)
\r
63 // Define input and output slots here
\r
64 DefineOutput(1, TList::Class());
\r
66 // create the list for comparison objects
\r
67 fCompList = new TList;
\r
70 //_____________________________________________________________________________
\r
71 AlidNdPtTask::~AlidNdPtTask()
\r
73 if(fOutput) delete fOutput; fOutput =0;
\r
74 if(fCompList) delete fCompList; fCompList =0;
\r
77 //____________________________________________________________________________
\r
78 Bool_t AlidNdPtTask::Notify()
\r
80 static Int_t count = 0;
\r
82 //Printf("Processing %d. file: %s", count, ((TTree*) GetInputData(0))->GetCurrentFile()->GetName());
\r
83 TTree *chain = (TChain*)GetInputData(0);
\r
85 Printf("Processing %d. file: %s", count, chain->GetCurrentFile()->GetName());
\r
88 TChain *chain = (TChain*)GetInputData(0);
\r
89 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
91 Printf("ERROR: Could not get ESDInputHandler");
\r
95 Printf("chain->GetCurrentFile()->GetName() %s", chain->GetCurrentFile()->GetName());
\r
102 //_____________________________________________________________________________
\r
103 Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj)
\r
105 // add analysis object to the list
\r
107 Printf("ERROR: Could not add comparison object");
\r
111 // add object to the list
\r
112 fCompList->AddLast(pObj);
\r
117 //_____________________________________________________________________________
\r
118 void AlidNdPtTask::UserCreateOutputObjects()
\r
120 // Create histograms
\r
123 OpenFile(1, "RECREATE");
\r
126 // create output list
\r
128 fOutput = new TList;
\r
129 fOutput->SetOwner();
\r
130 fPitList = fOutput->MakeIterator();
\r
132 // add dNdPt analysis objects to the output
\r
135 TIterator *pitCompList = fCompList->MakeIterator();
\r
136 pitCompList->Reset();
\r
137 while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {
\r
138 fOutput->Add(pObj);
\r
141 Printf("UserCreateOutputObjects(): Number of output objects: %d \n", count);
\r
143 if(fUseCentrality) {
\r
144 Printf("Use Centrality - Bin %d", fUseCentralityBin);
\r
147 PostData(1, fOutput);
\r
150 //_____________________________________________________________________________
\r
151 void AlidNdPtTask::UserExec(Option_t *)
\r
154 // Called for each event
\r
158 fESD = (AliESDEvent*) (InputEvent());
\r
160 Printf("ERROR: ESD event not available");
\r
168 Printf("ERROR: MC event not available");
\r
173 // Process analysis
\r
174 Bool_t process = kTRUE;
\r
176 // Check fo centrality
\r
177 if (fUseCentrality) {
\r
178 if ( CalculateCentralityBin() != fUseCentralityBin ) {
\r
184 AlidNdPt *pObj = 0;
\r
186 while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {
\r
187 pObj->Process(fESD,fMC);
\r
192 // Post output data.
\r
193 PostData(1, fOutput);
\r
196 //_____________________________________________________________________________
\r
197 void AlidNdPtTask::Terminate(Option_t *)
\r
199 // Called one at the end
\r
201 // check output data
\r
202 fOutput = dynamic_cast<TList*> (GetOutputData(1));
\r
204 Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );
\r
209 //________________________________________________________________________
\r
210 Int_t AlidNdPtTask::CalculateCentralityBin(){
\r
211 // Get Centrality bin
\r
213 Int_t centrality = -1;
\r
214 Float_t centralityF = -1;
\r
216 if (fUseCentrality == 0)
\r
219 AliCentrality *esdCentrality = fESD->GetCentrality();
\r
221 // New : 2010-11-18 JMT
\r
222 if ( fUseCentrality == 1 )
\r
223 centralityF = esdCentrality->GetCentralityPercentile("V0M");
\r
224 else if ( fUseCentrality == 2 )
\r
225 centralityF = esdCentrality->GetCentralityPercentile("CL1");
\r
226 else if ( fUseCentrality == 3 )
\r
227 centralityF = esdCentrality->GetCentralityPercentile("TRK");
\r
228 if (centralityF == 0.)
\r
229 centralityF = 100.;
\r
231 if ( centralityF >= 0. && centralityF < 5.) centrality = 0;
\r
232 else if ( centralityF >= 5. && centralityF < 10.) centrality = 5;
\r
233 else if ( centralityF >= 10. && centralityF < 20.) centrality = 10;
\r
234 else if ( centralityF >= 20. && centralityF < 30.) centrality = 20;
\r
235 else if ( centralityF >= 30. && centralityF < 40.) centrality = 30;
\r
236 else if ( centralityF >= 40. && centralityF < 50.) centrality = 40;
\r
237 else if ( centralityF >= 50. && centralityF < 60.) centrality = 50;
\r
238 else if ( centralityF >= 60. && centralityF < 70.) centrality = 60;
\r
239 else if ( centralityF >= 70. && centralityF < 80.) centrality = 70;
\r
240 else if ( centralityF >= 80. && centralityF < 90.) centrality = 80;
\r
241 else if ( centralityF >= 90. && centralityF <=100.) centrality = 90;
\r