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 /**********************************
17 * analysis task for nested loops *
19 * authors: Naomi van der Kolk *
22 * (snelling@nikhef.nl) *
25 * *******************************/
29 class AliAnalysisTaskSE;
31 #include "Riostream.h"
32 #include "AliFlowEventSimple.h"
33 #include "AliAnalysisTaskNestedLoops.h"
34 #include "AliFlowAnalysisWithNestedLoops.h"
36 ClassImp(AliAnalysisTaskNestedLoops)
38 //================================================================================================================
40 AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops(const char *name, Bool_t useParticleWeights):
41 AliAnalysisTaskSE(name),
45 fUseParticleWeights(useParticleWeights),
46 fUsePhiWeights(kFALSE),
47 fUsePtWeights(kFALSE),
48 fUseEtaWeights(kFALSE),
52 cout<<"AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops(const char *name, Bool_t useParticleWeights)"<<endl;
54 // Define input and output slots here
55 // Input slot #0 works with an AliFlowEventSimple
56 DefineInput(0, AliFlowEventSimple::Class());
57 // Input slot #1 is needed for the weights input file:
58 if(useParticleWeights)
60 DefineInput(1, TList::Class());
62 // Output slot #0 is reserved
63 // Output slot #1 writes into a TList container
64 DefineOutput(1, TList::Class());
67 AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops():
72 fUseParticleWeights(kFALSE),
73 fUsePhiWeights(kFALSE),
74 fUsePtWeights(kFALSE),
75 fUseEtaWeights(kFALSE),
79 cout<<"AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops()"<<endl;
82 //================================================================================================================
84 void AliAnalysisTaskNestedLoops::UserCreateOutputObjects()
86 // Called at every worker node to initialize
87 cout<<"AliAnalysisTaskNestedLoops::UserCreateOutputObjects()"<<endl;
90 fNL = new AliFlowAnalysisWithNestedLoops();
92 if(fUseParticleWeights)
94 // Pass the flags to class:
95 if(fUsePhiWeights) fNL->SetUsePhiWeights(fUsePhiWeights);
96 if(fUsePtWeights) fNL->SetUsePtWeights(fUsePtWeights);
97 if(fUseEtaWeights) fNL->SetUseEtaWeights(fUseEtaWeights);
98 // Get data from input slot #1 which is used for weights:
101 fWeightsList = (TList*)GetInputData(1);
103 // Pass the list with weights to class:
104 if(fWeightsList) fNL->SetWeightsList(fWeightsList);
109 if(fNL->GetHistList())
111 fListHistos = fNL->GetHistList();
112 // fListHistos->Print();
115 Printf("ERROR: Could not retrieve histogram list (NL, Task::UserCreateOutputObjects()) !!!!");
118 PostData(1,fListHistos);
120 } // end of void AliAnalysisTaskNestedLoops::UserCreateOutputObjects()
122 //================================================================================================================
124 void AliAnalysisTaskNestedLoops::UserExec(Option_t *)
126 // main loop (called for each event)
127 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
135 cout<<"WARNING: No input data (NL, Task::UserExec()) !!!!"<<endl;
139 PostData(1,fListHistos);
142 //================================================================================================================
144 void AliAnalysisTaskNestedLoops::Terminate(Option_t *)
146 //accessing the merged output list:
147 fListHistos = (TList*)GetOutputData(1);
149 fNL = new AliFlowAnalysisWithNestedLoops();
153 fNL->GetOutputHistograms(fListHistos);
155 PostData(1,fListHistos);
158 cout<<" WARNING: histogram list pointer is empty (NL, Task::Terminate()) !!!!"<<endl;
162 } // end of void AliAnalysisTaskNestedLoops::Terminate(Option_t *)