]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TPC/AliPerformanceTask.cxx
7f79de8b2902aff7f9b1c1699d8fe46128761d44
[u/mrichter/AliRoot.git] / PWG1 / TPC / AliPerformanceTask.cxx
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   : AliAnalysisTaskSE("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   : AliAnalysisTaskSE(name)\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(1, 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 Bool_t AliPerformanceTask::AddPerformanceObject(AliPerformanceObject *pObj) \r
108 {\r
109   // add comparison object to the list\r
110   if(pObj == 0) {\r
111     Printf("ERROR: Could not add comparison object");\r
112     return kFALSE;\r
113   }\r
114 \r
115   // add object to the list\r
116   fCompList->AddLast(pObj);\r
117        \r
118 return kTRUE;\r
119 }\r
120 \r
121 //_____________________________________________________________________________\r
122 void AliPerformanceTask::UserCreateOutputObjects()\r
123 {\r
124   // Create histograms\r
125   // Called once\r
126 \r
127   // create output list\r
128   fOutput = new TList;\r
129   fOutput->SetOwner();\r
130   fPitList = fOutput->MakeIterator();\r
131 \r
132   // add comparison objects to the output\r
133   AliPerformanceObject *pObj=0;\r
134   Int_t count=0;\r
135   TIterator *pitCompList = fCompList->MakeIterator();\r
136   pitCompList->Reset();\r
137   while(( pObj = (AliPerformanceObject *)pitCompList->Next()) != NULL) {\r
138     fOutput->Add(pObj);\r
139     count++;\r
140   }\r
141   Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
142 }\r
143 \r
144 //_____________________________________________________________________________\r
145 void AliPerformanceTask::UserExec(Option_t *) \r
146 {\r
147   // Main loop\r
148   // Called for each event\r
149   fESD = (AliESDEvent*) (InputEvent());\r
150   if(fUseESDfriend)\r
151     {\r
152       fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r
153       if(!fESDfriend) {\r
154         Printf("ERROR: ESD friends not available");\r
155       }\r
156     }\r
157   \r
158   if(fUseMCInfo) {\r
159       fMC = MCEvent();\r
160   }  \r
161 \r
162   //\r
163   AliPerformanceObject *pObj=0;\r
164 \r
165   if (!fESD) {\r
166     Printf("ERROR: ESD event not available");\r
167     return;\r
168   }\r
169   \r
170   if (fUseMCInfo && !fMC) {\r
171     Printf("ERROR: MC event not available");\r
172     return;\r
173   }\r
174 \r
175   if(fUseESDfriend)\r
176   {\r
177     if(!fESDfriend) {\r
178     Printf("ERROR: ESD friends not available");\r
179     }\r
180   }\r
181 \r
182   // Process comparison\r
183   fPitList->Reset();\r
184   while(( pObj = (AliPerformanceObject *)fPitList->Next()) != NULL) {\r
185     pObj->Exec(fMC,fESD,fESDfriend,fUseMCInfo,fUseESDfriend);\r
186   }\r
187 \r
188   // Post output data.\r
189   PostData(1, fOutput);\r
190 }\r
191 \r
192 //_____________________________________________________________________________\r
193 void AliPerformanceTask::Terminate(Option_t *) \r
194 {\r
195   // Called one at the end \r
196   \r
197   // check output data\r
198   fOutput = dynamic_cast<TList*> (GetOutputData(0));\r
199   if (!fOutput) {\r
200     Printf("ERROR: AliPerformanceTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
201     return;\r
202   }\r
203 }\r
204 \r
205 //_____________________________________________________________________________\r
206 Bool_t AliPerformanceTask::Notify()\r
207 {\r
208   static Int_t count = 0;\r
209   count++;\r
210   Printf("Processing %d. file", count);\r
211 \r
212   return kTRUE;\r
213 }\r