]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliPerformanceTask.cxx
Adding perfomrance tasks (Jacek)
[u/mrichter/AliRoot.git] / PWG1 / AliPerformanceTask.cxx
CommitLineData
777a0ba6 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, AliPerformanceDEdxA, 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 "AliMCEvent.h"\r
41#include "AliESDInputHandler.h"\r
42#include "AliMCEventHandler.h"\r
43#include "AliESDVertex.h"\r
44#include "AliMagF.h"\r
45#include "AliTracker.h"\r
46#include "AliGeomManager.h"\r
47\r
48#include "AliMCInfo.h"\r
49#include "AliESDRecInfo.h"\r
50#include "AliMCInfoCuts.h"\r
51#include "AliRecInfoCuts.h"\r
52#include "AliComparisonRes.h"\r
53#include "AliComparisonEff.h"\r
54#include "AliComparisonDEdx.h"\r
55#include "AliComparisonDCA.h"\r
56#include "AliComparisonObject.h"\r
57#include "AliPerformanceObject.h"\r
58#include "AliPerformanceTask.h"\r
59\r
60using namespace std;\r
61\r
62ClassImp(AliPerformanceTask)\r
63\r
64//_____________________________________________________________________________\r
65AliPerformanceTask::AliPerformanceTask() \r
66 : AliAnalysisTask("Performance","Detector Performance")\r
67 , fESD(0)\r
68 , fMC(0)\r
69 , fOutput(0)\r
70 , fPitList(0)\r
71 , fCompList(0)\r
72 , fUseMCInfo(kFALSE)\r
73{\r
74 // Dummy Constructor\r
75 // should not be used\r
76}\r
77\r
78//_____________________________________________________________________________\r
79AliPerformanceTask::AliPerformanceTask(const char *name, const char *title) \r
80 : AliAnalysisTask(name, title)\r
81 , fESD(0)\r
82 , fMC(0)\r
83 , fOutput(0)\r
84 , fPitList(0)\r
85 , fCompList(0)\r
86 , fUseMCInfo(kFALSE)\r
87{\r
88 // Constructor\r
89\r
90 // Define input and output slots here\r
91 DefineInput(0, TChain::Class());\r
92 DefineOutput(0, TList::Class());\r
93\r
94 // create the list for comparison objects\r
95 fCompList = new TList;\r
96}\r
97\r
98//_____________________________________________________________________________\r
99AliPerformanceTask::~AliPerformanceTask()\r
100{\r
101 if(fOutput) delete fOutput; fOutput =0; \r
102 if(fCompList) delete fCompList; fCompList =0; \r
103}\r
104\r
105//_____________________________________________________________________________\r
106void AliPerformanceTask::ConnectInputData(Option_t *) \r
107{\r
108 // Connect input data \r
109 // Called once\r
110\r
111 TTree *tree = dynamic_cast<TTree*> (GetInputData(0));\r
112 if (!tree) {\r
113 Printf("ERROR: Could not read chain from input slot 0");\r
114 return;\r
115 }\r
116\r
117 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
118 if (!esdH) {\r
119 Printf("ERROR: Could not get ESDInputHandler");\r
120 } else {\r
121 fESD = esdH->GetEvent();\r
122\r
123 // Enable only the needed branches\r
124 //esdH->SetActiveBranches("AliESDHeader Vertex Tracks");\r
125 }\r
126\r
127 // use MC information\r
128 if(fUseMCInfo) {\r
129 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r
130 if (!eventHandler) {\r
131 Printf("ERROR: Could not retrieve MC event handler");\r
132 } else {\r
133 fMC = eventHandler->MCEvent();\r
134 }\r
135 }\r
136}\r
137\r
138//_____________________________________________________________________________\r
139Bool_t AliPerformanceTask::AddPerformanceObject(AliPerformanceObject *pObj) \r
140{\r
141 // add comparison object to the list\r
142 if(pObj == 0) {\r
143 Printf("ERROR: Could not add comparison object");\r
144 return kFALSE;\r
145 }\r
146\r
147 // add object to the list\r
148 fCompList->AddLast(pObj);\r
149 \r
150return kTRUE;\r
151}\r
152\r
153//_____________________________________________________________________________\r
154void AliPerformanceTask::CreateOutputObjects()\r
155{\r
156 // Create histograms\r
157 // Called once\r
158\r
159 // create output list\r
160 fOutput = new TList;\r
161 fOutput->SetOwner();\r
162 fPitList = fOutput->MakeIterator();\r
163\r
164 // add comparison objects to the output\r
165 AliPerformanceObject *pObj=0;\r
166 Int_t count=0;\r
167 TIterator *pitCompList = fCompList->MakeIterator();\r
168 pitCompList->Reset();\r
169 while(( pObj = (AliPerformanceObject *)pitCompList->Next()) != NULL) {\r
170 fOutput->Add(pObj);\r
171 count++;\r
172 }\r
173 Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
174}\r
175\r
176//_____________________________________________________________________________\r
177void AliPerformanceTask::Exec(Option_t *) \r
178{\r
179 // Main loop\r
180 // Called for each event\r
181\r
182 AliPerformanceObject *pObj=0;\r
183\r
184 if (!fESD) {\r
185 Printf("ERROR: ESD event not available");\r
186 return;\r
187 }\r
188 \r
189 if (fUseMCInfo && !fMC) {\r
190 Printf("ERROR: MC event not available");\r
191 return;\r
192 }\r
193\r
194 // Process comparison\r
195 fPitList->Reset();\r
196 while(( pObj = (AliPerformanceObject *)fPitList->Next()) != NULL) {\r
197 pObj->Exec(fMC,fESD,fUseMCInfo);\r
198 }\r
199\r
200 // Post output data.\r
201 PostData(0, fOutput);\r
202}\r
203\r
204//_____________________________________________________________________________\r
205void AliPerformanceTask::Terminate(Option_t *) \r
206{\r
207 // Called one at the end \r
208 \r
209 // check output data\r
210 fOutput = dynamic_cast<TList*> (GetOutputData(0));\r
211 if (!fOutput) {\r
212 Printf("ERROR: AliPerformanceTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
213 return;\r
214 }\r
215}\r
216\r
217//_____________________________________________________________________________\r
218Bool_t AliPerformanceTask::Notify()\r
219{\r
220 static Int_t count = 0;\r
221 count++;\r
222 Printf("Processing %d. file", count);\r
223\r
224 return kTRUE;\r
225}\r