]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TPC/AliPerformanceTask.cxx
Summary and trend extraction for TPC with modified AliPerformanceTPC
[u/mrichter/AliRoot.git] / PWG1 / TPC / AliPerformanceTask.cxx
CommitLineData
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
636e5a51 26// Changes by M.Knichel and H.Erdal 27/07/2010\r
7cc34f08 27//------------------------------------------------------------------------------\r
28\r
29#include "iostream"\r
30\r
31#include "TChain.h"\r
32#include "TTree.h"\r
33#include "TH1F.h"\r
34#include "TCanvas.h"\r
35#include "TList.h"\r
36#include "TFile.h"\r
37\r
38#include "AliAnalysisTask.h"\r
39#include "AliAnalysisManager.h"\r
40#include "AliESDEvent.h"\r
41#include "AliESDfriend.h"\r
42#include "AliMCEvent.h"\r
43#include "AliESDInputHandler.h"\r
44#include "AliMCEventHandler.h"\r
45#include "AliESDVertex.h"\r
46#include "AliMagF.h"\r
47#include "AliTracker.h"\r
48#include "AliGeomManager.h"\r
49\r
50#include "AliMCInfo.h"\r
51#include "AliESDRecInfo.h"\r
52#include "AliMCInfoCuts.h"\r
53#include "AliRecInfoCuts.h"\r
54#include "AliComparisonObject.h"\r
55#include "AliPerformanceObject.h"\r
56#include "AliPerformanceTask.h"\r
57\r
58using namespace std;\r
59\r
60ClassImp(AliPerformanceTask)\r
61\r
62//_____________________________________________________________________________\r
63AliPerformanceTask::AliPerformanceTask() \r
a26a028b 64 : AliAnalysisTaskSE("Performance")\r
7cc34f08 65 , fESD(0)\r
66 , fESDfriend(0)\r
67 , fMC(0)\r
68 , fOutput(0)\r
69 , fPitList(0)\r
70 , fCompList(0)\r
71 , fUseMCInfo(kFALSE)\r
72 , fUseESDfriend(kFALSE)\r
636e5a51 73 , fUseHLT(kFALSE)\r
7cc34f08 74{\r
75 // Dummy Constructor\r
76 // should not be used\r
77}\r
78\r
79//_____________________________________________________________________________\r
a26a028b 80AliPerformanceTask::AliPerformanceTask(const char *name, const char */*title*/) \r
81 : AliAnalysisTaskSE(name)\r
7cc34f08 82 , fESD(0)\r
83 , fESDfriend(0)\r
84 , fMC(0)\r
85 , fOutput(0)\r
86 , fPitList(0)\r
87 , fCompList(0)\r
88 , fUseMCInfo(kFALSE)\r
89 , fUseESDfriend(kFALSE)\r
636e5a51 90 , fUseHLT(kFALSE)\r
7cc34f08 91{\r
92 // Constructor\r
93\r
94 // Define input and output slots here\r
65b3a5e1 95 DefineOutput(1, TList::Class());\r
7cc34f08 96\r
97 // create the list for comparison objects\r
98 fCompList = new TList;\r
99}\r
100\r
101//_____________________________________________________________________________\r
102AliPerformanceTask::~AliPerformanceTask()\r
103{\r
a04e8f74 104 if(fOutput) delete fOutput; fOutput = 0; \r
105 if(fCompList) delete fCompList; fCompList = 0; \r
7cc34f08 106}\r
107\r
7cc34f08 108//_____________________________________________________________________________\r
109Bool_t AliPerformanceTask::AddPerformanceObject(AliPerformanceObject *pObj) \r
110{\r
111 // add comparison object to the list\r
112 if(pObj == 0) {\r
113 Printf("ERROR: Could not add comparison object");\r
114 return kFALSE;\r
115 }\r
116\r
117 // add object to the list\r
118 fCompList->AddLast(pObj);\r
119 \r
120return kTRUE;\r
121}\r
122\r
123//_____________________________________________________________________________\r
a26a028b 124void AliPerformanceTask::UserCreateOutputObjects()\r
7cc34f08 125{\r
126 // Create histograms\r
127 // Called once\r
128\r
129 // create output list\r
130 fOutput = new TList;\r
131 fOutput->SetOwner();\r
132 fPitList = fOutput->MakeIterator();\r
133\r
134 // add comparison objects to the output\r
135 AliPerformanceObject *pObj=0;\r
136 Int_t count=0;\r
137 TIterator *pitCompList = fCompList->MakeIterator();\r
138 pitCompList->Reset();\r
139 while(( pObj = (AliPerformanceObject *)pitCompList->Next()) != NULL) {\r
140 fOutput->Add(pObj);\r
141 count++;\r
142 }\r
143 Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
144}\r
145\r
146//_____________________________________________________________________________\r
a26a028b 147void AliPerformanceTask::UserExec(Option_t *) \r
7cc34f08 148{\r
149 // Main loop\r
150 // Called for each event\r
636e5a51 151\r
152 // Decide whether to use HLT or Offline ESD\r
153 if(fUseHLT){\r
154\r
155 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> \r
156 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
157 \r
158 if (!esdH) {\r
159 printf("ERROR: Could not get ESDInputHandler");\r
160 return;\r
161 } \r
162 fESD = esdH->GetHLTEvent();\r
163 }// end if fUseHLT\r
164 else \r
165 fESD = (AliESDEvent*) (InputEvent());\r
166\r
a26a028b 167 if(fUseESDfriend)\r
168 {\r
169 fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r
170 if(!fESDfriend) {\r
171 Printf("ERROR: ESD friends not available");\r
172 }\r
173 }\r
174 \r
175 if(fUseMCInfo) {\r
176 fMC = MCEvent();\r
177 } \r
7cc34f08 178\r
a26a028b 179 //\r
7cc34f08 180 AliPerformanceObject *pObj=0;\r
181\r
182 if (!fESD) {\r
183 Printf("ERROR: ESD event not available");\r
184 return;\r
185 }\r
186 \r
187 if (fUseMCInfo && !fMC) {\r
188 Printf("ERROR: MC event not available");\r
189 return;\r
190 }\r
191\r
192 if(fUseESDfriend)\r
193 {\r
194 if(!fESDfriend) {\r
195 Printf("ERROR: ESD friends not available");\r
196 }\r
197 }\r
198\r
199 // Process comparison\r
200 fPitList->Reset();\r
201 while(( pObj = (AliPerformanceObject *)fPitList->Next()) != NULL) {\r
202 pObj->Exec(fMC,fESD,fESDfriend,fUseMCInfo,fUseESDfriend);\r
203 }\r
204\r
205 // Post output data.\r
65b3a5e1 206 PostData(1, fOutput);\r
7cc34f08 207}\r
208\r
209//_____________________________________________________________________________\r
210void AliPerformanceTask::Terminate(Option_t *) \r
211{\r
9ca899e5 212 // Called once at the end \r
7cc34f08 213 \r
214 // check output data\r
2ac70243 215 fOutput = dynamic_cast<TList*> (GetOutputData(1));\r
7cc34f08 216 if (!fOutput) {\r
9ca899e5 217 Printf("ERROR: AliPerformanceTask::Terminate(): fOutput data not avaiable ..." );\r
7cc34f08 218 return;\r
219 }\r
636e5a51 220\r
221 AliPerformanceObject* pObj=0;\r
222 TIterator* itOut = fOutput->MakeIterator(); \r
223 itOut->Reset();\r
224 while(( pObj = dynamic_cast<AliPerformanceObject*>(itOut->Next())) != NULL) {\r
225 pObj->Analyse();\r
226 }\r
227\r
7cc34f08 228}\r
229\r
230//_____________________________________________________________________________\r
231Bool_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