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