]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliComparisonTask.cxx
copy TRD performance train to PWG1
[u/mrichter/AliRoot.git] / PWG1 / AliComparisonTask.cxx
CommitLineData
b4126c69 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
6d1c79ca 16//------------------------------------------------------------------------------\r
17// Implementation of the AliComparisonTask class. It compares properties of the \r
18// reconstructed and MC particle tracks under several conditions. \r
b4126c69 19// As the input it requires the tree with AliRecInfo and AliMCInfo branches. Such\r
20// tree can be prepared in advance by runing AliGenInfoMaker and then AliRecInfoMaker\r
21// (details in description of these classes).\r
22//\r
3baa4bfd 23// The comparison output objects deriving from AliComparisonObject \r
24// (e.g. AliComparisonRes, AliComparisonEff, AliComparisonDEdxA, AliComparisonDCA ...) \r
b4126c69 25// are stored in the output file (details in description of these classes).\r
6d1c79ca 26// \r
27// Author: J.Otwinowski 04/02/2008 \r
28//------------------------------------------------------------------------------\r
29\r
30#include "iostream"\r
31\r
32#include "TChain.h"\r
33#include "TTree.h"\r
34#include "TH1F.h"\r
35#include "TCanvas.h"\r
36#include "TList.h"\r
37#include "TFile.h"\r
38\r
39#include "AliAnalysisTask.h"\r
40#include "AliAnalysisManager.h"\r
41#include "AliESDEvent.h"\r
42#include "AliESDInputHandler.h"\r
43#include "AliESDVertex.h"\r
f7a1cc68 44#include "AliMagF.h"\r
6d1c79ca 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
3baa4bfd 56#include "AliComparisonObject.h"\r
6d1c79ca 57#include "AliComparisonTask.h"\r
58\r
59using namespace std;\r
60\r
61ClassImp(AliComparisonTask)\r
62\r
ac909664 63Int_t AliComparisonTask::fEvtNumber = 0;\r
6d1c79ca 64\r
65//_____________________________________________________________________________\r
66AliComparisonTask::AliComparisonTask(const char *name) \r
67 : AliAnalysisTask(name, "")\r
68 , fTree(0)\r
69 , fInfoMC(0)\r
70 , fInfoRC(0)\r
6d1c79ca 71 , fOutput(0)\r
ac909664 72 , fPitList(0)\r
3baa4bfd 73 , fCompList(0)\r
6d1c79ca 74{\r
75 // Constructor\r
76\r
77 // Define input and output slots here\r
78 DefineInput(0, TChain::Class());\r
79 DefineOutput(0, TList::Class());\r
80\r
3baa4bfd 81 // create the list for comparison objects\r
82 fCompList = new TList;\r
6d1c79ca 83}\r
84\r
85//_____________________________________________________________________________\r
86AliComparisonTask::~AliComparisonTask()\r
87{\r
88 if(fOutput) delete fOutput; fOutput =0; \r
3baa4bfd 89 if(fCompList) delete fCompList; fCompList =0; \r
6d1c79ca 90}\r
91\r
92//_____________________________________________________________________________\r
93void AliComparisonTask::ConnectInputData(Option_t *) \r
94{\r
95 // Connect input data \r
96 // Called once\r
97\r
98 fTree = dynamic_cast<TTree*> (GetInputData(0));\r
99 if (!fTree) {\r
100 Printf("ERROR: Could not read chain from input slot 0");\r
101 } else {\r
102 fTree->SetBranchStatus("*",1);\r
103 }\r
104\r
105 if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) {\r
106 fTree->GetBranch("MC")->SetAddress(&fInfoMC);\r
107 fTree->GetBranch("RC")->SetAddress(&fInfoRC);\r
108 } else {\r
109 Printf("ERROR: Could not get MC and RC branches");\r
110 }\r
3baa4bfd 111}\r
112\r
113//_____________________________________________________________________________\r
114Bool_t AliComparisonTask::AddComparisonObject(AliComparisonObject *pObj) \r
115{\r
116 // add comparison object to the list\r
117 if(pObj == 0) {\r
118 Printf("ERROR: Could not add comparison object");\r
119 return kFALSE;\r
120 }\r
6d1c79ca 121\r
3baa4bfd 122 // add object to the list\r
123 fCompList->AddLast(pObj);\r
124 \r
125return kTRUE;\r
6d1c79ca 126}\r
127\r
128//_____________________________________________________________________________\r
129void AliComparisonTask::CreateOutputObjects()\r
130{\r
131 // Create histograms\r
132 // Called once\r
133\r
3baa4bfd 134 // create output list\r
6d1c79ca 135 fOutput = new TList;\r
136 fOutput->SetOwner();\r
ac909664 137 fPitList = fOutput->MakeIterator();\r
6d1c79ca 138\r
3baa4bfd 139 AliComparisonObject *pObj=0;\r
140 Int_t count=0;\r
6d1c79ca 141\r
3baa4bfd 142 // add comparison objects to the output\r
143 TIterator *pitCompList = fCompList->MakeIterator();\r
144 pitCompList->Reset();\r
145 while(( pObj = (AliComparisonObject *)pitCompList->Next()) != NULL) {\r
146 fOutput->Add(pObj);\r
147 count++;\r
148 }\r
149 Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
6d1c79ca 150}\r
151\r
152//_____________________________________________________________________________\r
153Bool_t AliComparisonTask::ReadEntry(Int_t evt) \r
154{\r
3baa4bfd 155// Read entry from the tree\r
6d1c79ca 156 Long64_t centry = fTree->LoadTree(evt);\r
157 if(centry < 0) return kFALSE;\r
158\r
159 if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) {\r
160 fTree->GetBranch("MC")->SetAddress(&fInfoMC);\r
161 fTree->GetBranch("RC")->SetAddress(&fInfoRC);\r
162 } else {\r
163 Printf("ERROR: Could not get MC and RC branches");\r
164 return kFALSE;\r
165 }\r
166 fTree->GetEntry(evt);\r
167\r
168return kTRUE;\r
169}\r
170//_____________________________________________________________________________\r
171void AliComparisonTask::Exec(Option_t *) \r
172{\r
173 // Main loop\r
174 // Called for each event\r
175\r
3baa4bfd 176 AliComparisonObject *pObj=0;\r
177\r
6d1c79ca 178 if (!fInfoMC && !fInfoRC) {\r
179 Printf("ERROR: fInfoMC && fInfoRC not available");\r
180 return;\r
181 }\r
182\r
183 // Process comparison\r
ac909664 184 Bool_t status = ReadEntry(fEvtNumber);\r
6d1c79ca 185 if(status == kTRUE) \r
186 {\r
ac909664 187 fPitList->Reset();\r
188 while(( pObj = (AliComparisonObject *)fPitList->Next()) != NULL) {\r
3baa4bfd 189 pObj->Exec(fInfoMC,fInfoRC);\r
190 }\r
6d1c79ca 191 }\r
192\r
ac909664 193 if( !( fEvtNumber % 10000) ) { \r
194 cout << fEvtNumber << endl;\r
6d1c79ca 195 }\r
ac909664 196 fEvtNumber++;\r
6d1c79ca 197\r
198 // Post output data.\r
199 PostData(0, fOutput);\r
200}\r
201\r
202//_____________________________________________________________________________\r
203void AliComparisonTask::Terminate(Option_t *) \r
204{\r
b4126c69 205 // Called one at the end \r
206 \r
207 // check output data\r
6d1c79ca 208 fOutput = dynamic_cast<TList*> (GetOutputData(0));\r
209 if (!fOutput) {\r
b4126c69 210 Printf("ERROR: AliComparisonTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
6d1c79ca 211 return;\r
212 }\r
6d1c79ca 213}\r