1 /*************************************************************************
2 * Copyright(c) 1998-2008, 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 *f
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 /**************************************
17 * analysis task for fitting *
20 * authors: Naomi van der Kolk *
23 * (snelling@nikhef.nl) *
26 * ***********************************/
28 #include "Riostream.h"
36 #include "AliAnalysisTask.h"
37 #include "AliAnalysisDataSlot.h"
38 #include "AliAnalysisDataContainer.h"
39 #include "AliAnalysisManager.h"
41 #include "AliESDEvent.h"
42 #include "AliESDInputHandler.h"
44 #include "AliAODEvent.h"
45 #include "AliAODInputHandler.h"
47 #include "AliMCEventHandler.h"
48 #include "AliMCEvent.h"
50 #include "../../CORRFW/AliCFManager.h"
52 #include "AliAnalysisTaskFittingQDistribution.h"
53 #include "AliFlowEventSimpleMaker.h"
54 #include "AliFittingQDistribution.h"
55 #include "AliFlowCommonConstants.h"
56 #include "AliFlowCommonHistResults.h"
57 #include "AliFittingFunctionsForQDistribution.h"
59 ClassImp(AliAnalysisTaskFittingQDistribution)
61 //================================================================================================================
63 AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(const char *name, Bool_t on):
64 AliAnalysisTask(name,""),
67 fFQDA(NULL),//Fitting Q_Distribution Analysis (FQDA) object
78 cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(const char *name)"<<endl;
80 // Define input and output slots here
81 // Input slot #0 works with a TChain
82 DefineInput(0, TChain::Class());
84 // Output slot #0 writes into a TList container
85 DefineOutput(0, TList::Class());
88 DefineOutput(1, TList::Class());
89 DefineOutput(2, TList::Class());
93 AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution():
96 fFQDA(NULL),//Fitting q-distribution Analysis (FQDA) object
107 cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution()"<<endl;
110 //================================================================================================================
112 void AliAnalysisTaskFittingQDistribution::ConnectInputData(Option_t *)
114 //connect ESD or AOD (called once)
115 cout<<"AliAnalysisTaskFittingQDistribution::ConnectInputData(Option_t *)"<<endl;
117 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
120 Printf("ERROR: Could not read chain from input slot 0");
124 //disable all branches and enable only the needed ones
125 if (fAnalysisType == "MC") {
126 // we want to process only MC
127 tree->SetBranchStatus("*", kFALSE);
129 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
132 Printf("ERROR: Could not get ESDInputHandler");
134 fESD = esdH->GetEvent();
137 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
138 tree->SetBranchStatus("*", kFALSE);
139 tree->SetBranchStatus("Tracks.*", kTRUE);
141 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
144 Printf("ERROR: Could not get ESDInputHandler");
146 fESD = esdH->GetEvent();
148 else if (fAnalysisType == "AOD") {
149 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
152 Printf("ERROR: Could not get AODInputHandler");
155 fAOD = aodH->GetEvent();
159 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
165 //================================================================================================================
167 void AliAnalysisTaskFittingQDistribution::CreateOutputObjects()
169 //called at every worker node to initialize
170 cout<<"AliAnalysisTaskFittingQDistribution::CreateOutputObjects()"<<endl;
176 if(!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC"))
178 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
183 fEventMaker = new AliFlowEventSimpleMaker();
186 fFQDA = new AliFittingQDistribution();
187 fFQDA->CreateOutputObjects();
189 if(fFQDA->GetHistList())
191 fListHistos = fFQDA->GetHistList();
192 //fListHistos->Print();
196 Printf("ERROR: Could not retrieve histogram list");
199 //PostData(0,fListHistos);
203 //================================================================================================================
205 void AliAnalysisTaskFittingQDistribution::Exec(Option_t *)
207 //main loop (called for each event)
208 if (fAnalysisType == "MC") {
209 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
210 // This handler can return the current MC event
212 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
214 Printf("ERROR: Could not retrieve MC event handler");
218 AliMCEvent* mcEvent = eventHandler->MCEvent();
220 Printf("ERROR: Could not retrieve MC event");
224 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
225 fCFManager1->SetEventInfo(mcEvent);
226 fCFManager2->SetEventInfo(mcEvent);
228 //fitting q-distribution
229 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
233 else if (fAnalysisType == "ESD") {
235 Printf("ERROR: fESD not available");
238 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
240 //fitting q-distribution
241 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
242 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
246 else if (fAnalysisType == "ESDMC0") {
248 Printf("ERROR: fESD not available");
251 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
253 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
255 Printf("ERROR: Could not retrieve MC event handler");
259 AliMCEvent* mcEvent = eventHandler->MCEvent();
261 Printf("ERROR: Could not retrieve MC event");
265 fCFManager1->SetEventInfo(mcEvent);
266 fCFManager2->SetEventInfo(mcEvent);
268 //fitting q-distribution
269 AliFlowEventSimple* fEvent=NULL;
270 if (fAnalysisType == "ESDMC0") {
271 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
272 } else if (fAnalysisType == "ESDMC1") {
273 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
280 else if (fAnalysisType == "AOD") {
282 Printf("ERROR: fAOD not available");
285 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
288 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
289 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
294 PostData(0,fListHistos);
302 //================================================================================================================
304 void AliAnalysisTaskFittingQDistribution::Terminate(Option_t *)
306 //accessing the output list
307 fListHistos = (TList*)GetOutputData(0);
308 //fListHistos->Print();
312 //final results (integrated flow)
313 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResultsFQD"));
316 TH1D *sigma2 = dynamic_cast<TH1D*>(fListHistos->FindObject("fSigma2"));
318 //common histograms to store the final results for the integrated flow
319 AliFlowCommonHistResults *commonHistRes = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResultsFQD"));
321 //average selected multiplicity (for int. flow)
322 TProfile *AvMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlowFQD"));
325 TH1D *qDist = dynamic_cast<TH1D*>(fListHistos->FindObject("fQDistributionFQD"));
327 //----------------------------------------------------
329 fFQDA = new AliFittingQDistribution();
331 fFQDA->SetIntFlowResults(intFlowResults);
332 fFQDA->SetSigma2(sigma2);
333 fFQDA->SetCommonHistsResults(commonHistRes);
335 fFQDA->SetAverageMultiplicity(AvMult);
336 fFQDA->SetQDistribution(qDist);
340 //----------------------------------------------------
344 cout<<"histogram list pointer is empty"<<endl;
348 //================================================================================================================