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