]>
Commit | Line | Data |
---|---|---|
a65a7e70 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | #include "iostream" | |
17 | ||
18 | #include "TChain.h" | |
19 | #include "TTree.h" | |
20 | #include "TH1F.h" | |
21 | #include "TCanvas.h" | |
22 | #include "TList.h" | |
23 | #include "TFile.h" | |
24 | ||
25 | #include "AliAnalysisTask.h" | |
26 | #include "AliAnalysisManager.h" | |
27 | #include "AliESDEvent.h" | |
28 | #include "AliESDInputHandler.h" | |
29 | #include "AliESDVertex.h" | |
30 | #include "AliTracker.h" | |
31 | #include "AliGeomManager.h" | |
32 | ||
33 | #include "AliCentrality.h" | |
34 | #include "AliESDVZERO.h" | |
35 | #include "AliMultiplicity.h" | |
36 | ||
37 | #include "AliESDtrackCuts.h" | |
38 | #include "AliMCEventHandler.h" | |
39 | #include "AlidNdPt.h" | |
40 | #include "AlidNdPtEventCuts.h" | |
41 | #include "AlidNdPtAcceptanceCuts.h" | |
42 | ||
43 | #include "AlidNdPtTask.h" | |
44 | ||
45 | using namespace std; | |
46 | ||
47 | ClassImp(AlidNdPtTask) | |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AlidNdPtTask::AlidNdPtTask(const char *name) | |
51 | : AliAnalysisTaskSE(name) | |
52 | , fESD(0) | |
53 | , fMC(0) | |
54 | , fOutput(0) | |
55 | , fPitList(0) | |
56 | , fCompList(0) | |
57 | , fUseMCInfo(kFALSE) | |
58 | { | |
59 | // Constructor | |
60 | ||
61 | // Define input and output slots here | |
62 | DefineOutput(1, TList::Class()); | |
63 | ||
64 | // create the list for comparison objects | |
65 | fCompList = new TList; | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | AlidNdPtTask::~AlidNdPtTask() | |
70 | { | |
71 | if(fOutput) delete fOutput; fOutput =0; | |
72 | if(fCompList) delete fCompList; fCompList =0; | |
73 | } | |
74 | ||
75 | //____________________________________________________________________________ | |
76 | Bool_t AlidNdPtTask::Notify() | |
77 | { | |
78 | static Int_t count = 0; | |
79 | count++; | |
80 | //Printf("Processing %d. file: %s", count, ((TTree*) GetInputData(0))->GetCurrentFile()->GetName()); | |
81 | TTree *chain = (TChain*)GetInputData(0); | |
82 | if(chain) | |
83 | Printf("Processing %d. file: %s", count, chain->GetCurrentFile()->GetName()); | |
84 | ||
85 | /* | |
86 | TChain *chain = (TChain*)GetInputData(0); | |
87 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
88 | if (!esdH) { | |
89 | Printf("ERROR: Could not get ESDInputHandler"); | |
90 | return kFALSE; | |
91 | } else { | |
92 | if(chain) | |
93 | Printf("chain->GetCurrentFile()->GetName() %s", chain->GetCurrentFile()->GetName()); | |
94 | } | |
95 | */ | |
96 | ||
97 | return kTRUE; | |
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj) | |
102 | { | |
103 | // add analysis object to the list | |
104 | if(pObj == 0) { | |
105 | Printf("ERROR: Could not add comparison object"); | |
106 | return kFALSE; | |
107 | } | |
108 | ||
109 | // add object to the list | |
110 | fCompList->AddLast(pObj); | |
111 | ||
112 | return kTRUE; | |
113 | } | |
114 | ||
115 | //_____________________________________________________________________________ | |
116 | void AlidNdPtTask::UserCreateOutputObjects() | |
117 | { | |
118 | // Create histograms | |
119 | // Called once | |
120 | ||
121 | OpenFile(1, "RECREATE"); | |
122 | ||
123 | // | |
124 | // create output list | |
125 | // | |
126 | fOutput = new TList; | |
127 | fOutput->SetOwner(); | |
128 | fPitList = fOutput->MakeIterator(); | |
129 | ||
130 | // add dNdPt analysis objects to the output | |
131 | AlidNdPt *pObj=0; | |
132 | Int_t count=0; | |
133 | TIterator *pitCompList = fCompList->MakeIterator(); | |
134 | pitCompList->Reset(); | |
135 | while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) { | |
136 | fOutput->Add(pObj); | |
137 | count++; | |
138 | } | |
139 | Printf("UserCreateOutputObjects(): Number of output objects: %d \n", count); | |
140 | ||
141 | PostData(1, fOutput); | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | void AlidNdPtTask::UserExec(Option_t *) | |
146 | { | |
147 | // | |
148 | // Called for each event | |
149 | // | |
150 | ||
151 | // ESD event | |
152 | fESD = (AliESDEvent*) (InputEvent()); | |
153 | if (!fESD) { | |
154 | Printf("ERROR: ESD event not available"); | |
155 | return; | |
156 | } | |
157 | ||
158 | // MC event | |
159 | if(fUseMCInfo) { | |
160 | fMC = MCEvent(); | |
161 | if (!fMC) { | |
162 | Printf("ERROR: MC event not available"); | |
163 | return; | |
164 | } | |
165 | } | |
166 | ||
167 | ||
168 | AlidNdPt *pObj = 0; | |
169 | fPitList->Reset(); | |
170 | while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) { | |
171 | pObj->Process(fESD,fMC); | |
172 | } | |
173 | ||
174 | ||
175 | // Post output data. | |
176 | PostData(1, fOutput); | |
177 | } | |
178 | ||
179 | //_____________________________________________________________________________ | |
180 | void AlidNdPtTask::FinishTaskOutput() | |
181 | { | |
182 | // | |
183 | // Called one at the end | |
184 | // locally on working node | |
185 | // | |
186 | // check output data | |
187 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
188 | if (!fOutput) { | |
189 | Printf("ERROR: AlidNdPtTask::FinishTaskOutput(): Output data not avaiable GetOutputData(1)==0x0 ..." ); | |
190 | return; | |
191 | } | |
192 | ||
193 | AlidNdPt* pObj=0; | |
194 | TIterator* itOut = fOutput->MakeIterator(); | |
195 | itOut->Reset(); | |
196 | while(( pObj = dynamic_cast<AlidNdPt*>(itOut->Next())) != NULL) { | |
197 | if(pObj->GetAnalyseOutput()) { | |
198 | pObj->Analyse(); | |
199 | } | |
200 | } | |
201 | ||
202 | // Post output data. | |
203 | PostData(1, fOutput); | |
204 | } | |
205 | ||
206 | //_____________________________________________________________________________ | |
207 | void AlidNdPtTask::Terminate(Option_t *) | |
208 | { | |
209 | // Called one at the end | |
210 | ||
211 | // check output data | |
212 | fOutput = dynamic_cast<TList*> (GetOutputData(1)); | |
213 | if (!fOutput) { | |
214 | Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." ); | |
215 | return; | |
216 | } | |
217 | } |