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"
41 // AliAnalysisTaskScalarProduct:
43 // analysis task for Scalar Product Method
45 // Author: Naomi van der Kolk (kolk@nikhef.nl)
47 ClassImp(AliAnalysisTaskScalarProduct)
49 //________________________________________________________________________
50 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name) :
51 AliAnalysisTask(name, ""),
62 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
64 // Define input and output slots here
65 // Input slot #0 works with a TChain
66 DefineInput(0, TChain::Class());
67 // Output slot #0 writes into a TList container
68 DefineOutput(0, TList::Class());
72 //________________________________________________________________________
73 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
84 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
87 //________________________________________________________________________
88 AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
94 // histograms are in the output list and deleted when the output
95 // list is deleted by the TSelector dtor
98 // delete fListHistos;
99 // fListHistos = NULL;
103 //________________________________________________________________________
104 void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
106 // Connect ESD or AOD here
108 cout<<"AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)"<<endl;
110 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
112 Printf("ERROR: Could not read chain from input slot 0");
114 // Disable all branches and enable only the needed ones
115 if (fAnalysisType == "MC") {
116 cout<<"!!!!!reading MC kinematics only"<<endl;
117 // we want to process only MC
118 tree->SetBranchStatus("*", kFALSE);
120 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
123 Printf("ERROR: Could not get ESDInputHandler");
125 fESD = esdH->GetEvent();
128 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
129 cout<<"!!!!!reading the ESD only"<<endl;
130 tree->SetBranchStatus("*", kFALSE);
131 tree->SetBranchStatus("Tracks.*", kTRUE);
133 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
136 Printf("ERROR: Could not get ESDInputHandler");
138 fESD = esdH->GetEvent();
140 else if (fAnalysisType == "AOD") {
141 cout<<"!!!!!reading the AOD only"<<endl;
142 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
145 Printf("ERROR: Could not get AODInputHandler");
148 fAOD = aodH->GetEvent();
152 Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
159 //________________________________________________________________________
160 void AliAnalysisTaskScalarProduct::CreateOutputObjects()
162 // Called at every worker node to initialize
163 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
165 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
166 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
171 fEventMaker = new AliFlowEventSimpleMaker();
173 fSP = new AliFlowAnalysisWithScalarProduct() ;
177 if (fSP->GetHistList()) {
178 fSP->GetHistList()->Print();
179 fListHistos = fSP->GetHistList();
180 fListHistos->Print();
182 else {Printf("ERROR: Could not retrieve histogram list"); }
185 //________________________________________________________________________
186 void AliAnalysisTaskScalarProduct::Exec(Option_t *)
189 // Called for each event
192 if (fAnalysisType == "MC") {
194 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
195 // This handler can return the current MC event
197 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
199 Printf("ERROR: Could not retrieve MC event handler");
203 AliMCEvent* mcEvent = eventHandler->MCEvent();
205 Printf("ERROR: Could not retrieve MC event");
209 fCFManager1->SetEventInfo(mcEvent);
210 fCFManager2->SetEventInfo(mcEvent);
213 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
214 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
219 else if (fAnalysisType == "ESD") {
221 Printf("ERROR: fESD not available");
224 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
227 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
231 else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
233 Printf("ERROR: fESD not available");
236 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
238 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
240 Printf("ERROR: Could not retrieve MC event handler");
244 AliMCEvent* mcEvent = eventHandler->MCEvent();
246 Printf("ERROR: Could not retrieve MC event");
250 fCFManager1->SetEventInfo(mcEvent);
251 fCFManager2->SetEventInfo(mcEvent);
253 //lee yang zeros analysis
254 AliFlowEventSimple* fEvent=NULL;
255 if (fAnalysisType == "ESDMC0") {
256 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
257 } else if (fAnalysisType == "ESDMC1") {
258 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
265 else if (fAnalysisType == "AOD") {
267 Printf("ERROR: fAOD not available");
270 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
273 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
274 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
279 //fListHistos->Print();
280 PostData(0,fListHistos);
283 //________________________________________________________________________
284 void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
286 // Called once at the end of the query
288 // PostData(0,fListHistos);
290 fListHistos = (TList*)GetOutputData(0);
291 cout << "histgram list in Terminate" << endl;
294 fListHistos->Print();
298 cout << "histgram list pointer is empty" << endl;
301 // delete fEventMaker;