]>
Commit | Line | Data |
---|---|---|
7cc34f08 | 1 | /**************************************************************************\r |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r | |
3 | * *\r | |
4 | * Author: The ALICE Off-line Project. *\r | |
5 | * Contributors are mentioned in the code where appropriate. *\r | |
6 | * *\r | |
7 | * Permission to use, copy, modify and distribute this software and its *\r | |
8 | * documentation strictly for non-commercial purposes is hereby granted *\r | |
9 | * without fee, provided that the above copyright notice appears in all *\r | |
10 | * copies and that both the copyright notice and this permission notice *\r | |
11 | * appear in the supporting documentation. The authors make no claims *\r | |
12 | * about the suitability of this software for any purpose. It is *\r | |
13 | * provided "as is" without express or implied warranty. *\r | |
14 | **************************************************************************/\r | |
15 | \r | |
16 | //------------------------------------------------------------------------------\r | |
17 | // Implementation of the AliPerformanceTask class. It checks reconstruction performance \r | |
18 | // for the reconstructed vs MC particle tracks under several conditions. For real data \r | |
19 | // the control QA histograms are filled.\r | |
20 | //\r | |
21 | // The comparison output objects deriving from AliPerformanceObject \r | |
22 | // (e.g. AliPerformanceRes, AliPerformanceEff, AliPerformanceDEdx, AliPerformanceDCA ...) \r | |
23 | // are stored in the output file (details in description of these classes).\r | |
24 | // \r | |
25 | // Author: J.Otwinowski 01/04/2009 \r | |
26 | //------------------------------------------------------------------------------\r | |
27 | \r | |
28 | #include "iostream"\r | |
29 | \r | |
30 | #include "TChain.h"\r | |
31 | #include "TTree.h"\r | |
32 | #include "TH1F.h"\r | |
33 | #include "TCanvas.h"\r | |
34 | #include "TList.h"\r | |
35 | #include "TFile.h"\r | |
36 | \r | |
37 | #include "AliAnalysisTask.h"\r | |
38 | #include "AliAnalysisManager.h"\r | |
39 | #include "AliESDEvent.h"\r | |
40 | #include "AliESDfriend.h"\r | |
41 | #include "AliMCEvent.h"\r | |
42 | #include "AliESDInputHandler.h"\r | |
43 | #include "AliMCEventHandler.h"\r | |
44 | #include "AliESDVertex.h"\r | |
45 | #include "AliMagF.h"\r | |
46 | #include "AliTracker.h"\r | |
47 | #include "AliGeomManager.h"\r | |
48 | \r | |
49 | #include "AliMCInfo.h"\r | |
50 | #include "AliESDRecInfo.h"\r | |
51 | #include "AliMCInfoCuts.h"\r | |
52 | #include "AliRecInfoCuts.h"\r | |
53 | #include "AliComparisonObject.h"\r | |
54 | #include "AliPerformanceObject.h"\r | |
55 | #include "AliPerformanceTask.h"\r | |
56 | \r | |
57 | using namespace std;\r | |
58 | \r | |
59 | ClassImp(AliPerformanceTask)\r | |
60 | \r | |
61 | //_____________________________________________________________________________\r | |
62 | AliPerformanceTask::AliPerformanceTask() \r | |
63 | : AliAnalysisTask("Performance","Detector Performance")\r | |
64 | , fESD(0)\r | |
65 | , fESDfriend(0)\r | |
66 | , fMC(0)\r | |
67 | , fOutput(0)\r | |
68 | , fPitList(0)\r | |
69 | , fCompList(0)\r | |
70 | , fUseMCInfo(kFALSE)\r | |
71 | , fUseESDfriend(kFALSE)\r | |
72 | {\r | |
73 | // Dummy Constructor\r | |
74 | // should not be used\r | |
75 | }\r | |
76 | \r | |
77 | //_____________________________________________________________________________\r | |
78 | AliPerformanceTask::AliPerformanceTask(const char *name, const char *title) \r | |
79 | : AliAnalysisTask(name, title)\r | |
80 | , fESD(0)\r | |
81 | , fESDfriend(0)\r | |
82 | , fMC(0)\r | |
83 | , fOutput(0)\r | |
84 | , fPitList(0)\r | |
85 | , fCompList(0)\r | |
86 | , fUseMCInfo(kFALSE)\r | |
87 | , fUseESDfriend(kFALSE)\r | |
88 | {\r | |
89 | // Constructor\r | |
90 | \r | |
91 | // Define input and output slots here\r | |
92 | DefineInput(0, TChain::Class());\r | |
93 | DefineOutput(0, TList::Class());\r | |
94 | \r | |
95 | // create the list for comparison objects\r | |
96 | fCompList = new TList;\r | |
97 | }\r | |
98 | \r | |
99 | //_____________________________________________________________________________\r | |
100 | AliPerformanceTask::~AliPerformanceTask()\r | |
101 | {\r | |
102 | if(fOutput) delete fOutput; fOutput =0; \r | |
103 | if(fCompList) delete fCompList; fCompList =0; \r | |
104 | }\r | |
105 | \r | |
106 | //_____________________________________________________________________________\r | |
107 | void AliPerformanceTask::ConnectInputData(Option_t *) \r | |
108 | {\r | |
109 | // Connect input data \r | |
110 | // Called once\r | |
111 | \r | |
112 | TTree *tree = dynamic_cast<TTree*> (GetInputData(0));\r | |
113 | if (!tree) {\r | |
114 | Printf("ERROR: Could not read chain from input slot 0");\r | |
115 | return;\r | |
116 | }\r | |
117 | \r | |
118 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
119 | if (!esdH) {\r | |
120 | Printf("ERROR: Could not get ESDInputHandler");\r | |
121 | } else {\r | |
122 | fESD = esdH->GetEvent();\r | |
123 | \r | |
124 | if(fUseESDfriend)\r | |
125 | {\r | |
126 | fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r | |
127 | if(!fESDfriend) {\r | |
128 | Printf("ERROR: ESD friends not available");\r | |
129 | }\r | |
130 | }\r | |
131 | }\r | |
132 | \r | |
133 | // use MC information\r | |
134 | if(fUseMCInfo) {\r | |
135 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r | |
136 | if (!eventHandler) {\r | |
137 | Printf("ERROR: Could not retrieve MC event handler");\r | |
138 | } else {\r | |
139 | fMC = eventHandler->MCEvent();\r | |
140 | }\r | |
141 | }\r | |
142 | }\r | |
143 | \r | |
144 | //_____________________________________________________________________________\r | |
145 | Bool_t AliPerformanceTask::AddPerformanceObject(AliPerformanceObject *pObj) \r | |
146 | {\r | |
147 | // add comparison object to the list\r | |
148 | if(pObj == 0) {\r | |
149 | Printf("ERROR: Could not add comparison object");\r | |
150 | return kFALSE;\r | |
151 | }\r | |
152 | \r | |
153 | // add object to the list\r | |
154 | fCompList->AddLast(pObj);\r | |
155 | \r | |
156 | return kTRUE;\r | |
157 | }\r | |
158 | \r | |
159 | //_____________________________________________________________________________\r | |
160 | void AliPerformanceTask::CreateOutputObjects()\r | |
161 | {\r | |
162 | // Create histograms\r | |
163 | // Called once\r | |
164 | \r | |
165 | // create output list\r | |
166 | fOutput = new TList;\r | |
167 | fOutput->SetOwner();\r | |
168 | fPitList = fOutput->MakeIterator();\r | |
169 | \r | |
170 | // add comparison objects to the output\r | |
171 | AliPerformanceObject *pObj=0;\r | |
172 | Int_t count=0;\r | |
173 | TIterator *pitCompList = fCompList->MakeIterator();\r | |
174 | pitCompList->Reset();\r | |
175 | while(( pObj = (AliPerformanceObject *)pitCompList->Next()) != NULL) {\r | |
176 | fOutput->Add(pObj);\r | |
177 | count++;\r | |
178 | }\r | |
179 | Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r | |
180 | }\r | |
181 | \r | |
182 | //_____________________________________________________________________________\r | |
183 | void AliPerformanceTask::Exec(Option_t *) \r | |
184 | {\r | |
185 | // Main loop\r | |
186 | // Called for each event\r | |
187 | \r | |
188 | AliPerformanceObject *pObj=0;\r | |
189 | \r | |
190 | if (!fESD) {\r | |
191 | Printf("ERROR: ESD event not available");\r | |
192 | return;\r | |
193 | }\r | |
194 | \r | |
195 | if (fUseMCInfo && !fMC) {\r | |
196 | Printf("ERROR: MC event not available");\r | |
197 | return;\r | |
198 | }\r | |
199 | \r | |
200 | if(fUseESDfriend)\r | |
201 | {\r | |
202 | if(!fESDfriend) {\r | |
203 | Printf("ERROR: ESD friends not available");\r | |
204 | }\r | |
205 | }\r | |
206 | \r | |
207 | // Process comparison\r | |
208 | fPitList->Reset();\r | |
209 | while(( pObj = (AliPerformanceObject *)fPitList->Next()) != NULL) {\r | |
210 | pObj->Exec(fMC,fESD,fESDfriend,fUseMCInfo,fUseESDfriend);\r | |
211 | }\r | |
212 | \r | |
213 | // Post output data.\r | |
214 | PostData(0, fOutput);\r | |
215 | }\r | |
216 | \r | |
217 | //_____________________________________________________________________________\r | |
218 | void AliPerformanceTask::Terminate(Option_t *) \r | |
219 | {\r | |
220 | // Called one at the end \r | |
221 | \r | |
222 | // check output data\r | |
223 | fOutput = dynamic_cast<TList*> (GetOutputData(0));\r | |
224 | if (!fOutput) {\r | |
225 | Printf("ERROR: AliPerformanceTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r | |
226 | return;\r | |
227 | }\r | |
228 | }\r | |
229 | \r | |
230 | //_____________________________________________________________________________\r | |
231 | Bool_t AliPerformanceTask::Notify()\r | |
232 | {\r | |
233 | static Int_t count = 0;\r | |
234 | count++;\r | |
235 | Printf("Processing %d. file", count);\r | |
236 | \r | |
237 | return kTRUE;\r | |
238 | }\r |