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 *
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 #include "Riostream.h" //needed as include
19 #include "TFile.h" //needed as include
23 class AliAnalysisTask;
24 #include "AliAnalysisManager.h"
26 #include "AliESDEvent.h"
27 #include "AliESDInputHandler.h"
29 #include "AliAODEvent.h"
30 #include "AliAODInputHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliMCEvent.h"
35 #include "../../CORRFW/AliCFManager.h"
37 #include "AliAnalysisTaskScalarProduct.h"
38 #include "AliFlowEventSimpleMaker.h"
39 #include "AliFlowAnalysisWithScalarProduct.h"
40 #include "AliFlowCommonHist.h"
42 // AliAnalysisTaskScalarProduct:
44 // analysis task for Scalar Product Method
46 // Author: Naomi van der Kolk (kolk@nikhef.nl)
48 ClassImp(AliAnalysisTaskScalarProduct)
50 //________________________________________________________________________
51 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t on) :
52 AliAnalysisTask(name, ""),
66 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
68 // Define input and output slots here
69 // Input slot #0 works with a TChain
70 DefineInput(0, TChain::Class());
71 // Output slot #0 writes into a TList container
72 DefineOutput(0, TList::Class());
74 DefineOutput(1, TList::Class());
75 DefineOutput(2, TList::Class()); }
78 //________________________________________________________________________
79 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
93 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
96 //________________________________________________________________________
97 AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
103 // histograms are in the output list and deleted when the output
104 // list is deleted by the TSelector dtor
107 // delete fListHistos;
108 // fListHistos = NULL;
112 //________________________________________________________________________
113 void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
115 // Connect ESD or AOD here
117 cout<<"AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)"<<endl;
119 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
121 Printf("ERROR: Could not read chain from input slot 0");
123 // Disable all branches and enable only the needed ones
124 if (fAnalysisType == "MC") {
125 // we want to process only MC
126 tree->SetBranchStatus("*", kFALSE);
128 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
131 Printf("ERROR: Could not get ESDInputHandler");
133 fESD = esdH->GetEvent();
136 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
137 tree->SetBranchStatus("*", kFALSE);
138 tree->SetBranchStatus("Tracks.*", kTRUE);
140 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
143 Printf("ERROR: Could not get ESDInputHandler");
145 fESD = esdH->GetEvent();
147 else if (fAnalysisType == "AOD") {
148 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
151 Printf("ERROR: Could not get AODInputHandler");
154 fAOD = aodH->GetEvent();
158 Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
165 //________________________________________________________________________
166 void AliAnalysisTaskScalarProduct::CreateOutputObjects()
168 // Called at every worker node to initialize
169 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
171 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
172 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
177 fEventMaker = new AliFlowEventSimpleMaker();
179 fSP = new AliFlowAnalysisWithScalarProduct() ;
183 if (fSP->GetHistList()) {
184 //fSP->GetHistList()->Print();
185 fListHistos = fSP->GetHistList();
186 fListHistos->Print();
188 else {Printf("ERROR: Could not retrieve histogram list"); }
191 //________________________________________________________________________
192 void AliAnalysisTaskScalarProduct::Exec(Option_t *)
195 // Called for each event
198 if (fAnalysisType == "MC") {
200 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
201 // This handler can return the current MC event
203 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
205 Printf("ERROR: Could not retrieve MC event handler");
209 AliMCEvent* mcEvent = eventHandler->MCEvent();
211 Printf("ERROR: Could not retrieve MC event");
215 fCFManager1->SetEventInfo(mcEvent);
216 fCFManager2->SetEventInfo(mcEvent);
219 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
220 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
225 else if (fAnalysisType == "ESD") {
227 Printf("ERROR: fESD not available");
230 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
233 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
237 else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
239 Printf("ERROR: fESD not available");
242 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
244 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
246 Printf("ERROR: Could not retrieve MC event handler");
250 AliMCEvent* mcEvent = eventHandler->MCEvent();
252 Printf("ERROR: Could not retrieve MC event");
256 fCFManager1->SetEventInfo(mcEvent);
257 fCFManager2->SetEventInfo(mcEvent);
259 //lee yang zeros analysis
260 AliFlowEventSimple* fEvent=NULL;
261 if (fAnalysisType == "ESDMC0") {
262 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
263 } else if (fAnalysisType == "ESDMC1") {
264 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
271 else if (fAnalysisType == "AOD") {
273 Printf("ERROR: fAOD not available");
276 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
279 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
280 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
285 //fListHistos->Print();
286 PostData(0,fListHistos);
289 PostData(2,fQADiff); }
292 //________________________________________________________________________
293 void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
295 // Called once at the end of the query -- do not call in case of CAF
297 // PostData(0,fListHistos);
299 fListHistos = (TList*)GetOutputData(0);
300 cout << "histgram list in Terminate" << endl;
302 fListHistos->Print();
304 else { cout << "histgram list pointer is empty" << endl; }