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 "AliAnalysisTaskScalarProduct.h"
36 #include "AliFlowEventSimpleMaker.h"
37 #include "AliFlowAnalysisWithScalarProduct.h"
39 // AliAnalysisTaskScalarProduct:
41 // analysis task for Scalar Product Method
43 // Author: Naomi van der Kolk (kolk@nikhef.nl)
45 ClassImp(AliAnalysisTaskScalarProduct)
47 //________________________________________________________________________
48 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name) :
49 AliAnalysisTask(name, ""),
58 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
60 // Define input and output slots here
61 // Input slot #0 works with a TChain
62 DefineInput(0, TChain::Class());
63 // Output slot #0 writes into a TList container
64 DefineOutput(0, TList::Class());
68 //________________________________________________________________________
69 AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
75 // histograms are in the output list and deleted when the output
76 // list is deleted by the TSelector dtor
79 // delete fListHistos;
80 // fListHistos = NULL;
84 //________________________________________________________________________
85 void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
87 // Connect ESD or AOD here
89 cout<<"AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)"<<endl;
91 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
93 Printf("ERROR: Could not read chain from input slot 0");
95 // Disable all branches and enable only the needed ones
96 if (fAnalysisType == "MC") {
97 cout<<"!!!!!reading MC kinematics only"<<endl;
98 // we want to process only MC
99 tree->SetBranchStatus("*", kFALSE);
101 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
104 Printf("ERROR: Could not get ESDInputHandler");
106 fESD = esdH->GetEvent();
109 else if (fAnalysisType == "ESD") {
110 cout<<"!!!!!reading the ESD only"<<endl;
111 tree->SetBranchStatus("*", kFALSE);
112 tree->SetBranchStatus("Tracks.*", kTRUE);
114 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
117 Printf("ERROR: Could not get ESDInputHandler");
119 fESD = esdH->GetEvent();
121 else if (fAnalysisType == "AOD") {
122 cout<<"!!!!!reading the AOD only"<<endl;
123 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
126 Printf("ERROR: Could not get AODInputHandler");
129 fAOD = aodH->GetEvent();
133 Printf("!!!!!Wrong analysis type: Only ESD, AOD and MC types are allowed!");
140 //________________________________________________________________________
141 void AliAnalysisTaskScalarProduct::CreateOutputObjects()
143 // Called at every worker node to initialize
144 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
146 fEventMaker = new AliFlowEventSimpleMaker();
148 fSP = new AliFlowAnalysisWithScalarProduct() ;
152 if (fSP->GetHistList()) {
153 fSP->GetHistList()->Print();
154 // fListHistos = new TList(fSP->GetHistList());
155 fListHistos = fSP->GetHistList();
156 fListHistos->Print();
158 else {Printf("ERROR: Could not retrieve histogram list"); }
161 //________________________________________________________________________
162 void AliAnalysisTaskScalarProduct::Exec(Option_t *)
165 // Called for each event
168 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
169 // This handler can return the current MC event
171 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
173 Printf("ERROR: Could not retrieve MC event handler");
177 AliMCEvent* mcEvent = eventHandler->MCEvent();
179 Printf("ERROR: Could not retrieve MC event");
183 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
185 if (fAnalysisType == "MC") {
187 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent);
192 else if (fAnalysisType == "ESD") {
194 Printf("ERROR: fESD not available");
197 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
200 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
204 else if (fAnalysisType == "AOD") {
206 Printf("ERROR: fAOD not available");
209 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
212 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
217 PostData(0,fListHistos);
220 //________________________________________________________________________
221 void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
223 // Called once at the end of the query
225 // PostData(0,fListHistos);