]>
Commit | Line | Data |
---|---|---|
7cc34f08 | 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 AliComparisonTask class. It compares properties of the \r | |
18 | // reconstructed and MC particle tracks under several conditions. \r | |
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 | |
23 | // The comparison output objects deriving from AliComparisonObject \r | |
24 | // (e.g. AliComparisonRes, AliComparisonEff, AliComparisonDEdxA, AliComparisonDCA ...) \r | |
25 | // are stored in the output file (details in description of these classes).\r | |
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 | |
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 "AliComparisonTask.h"\r | |
58 | \r | |
59 | using namespace std;\r | |
60 | \r | |
61 | ClassImp(AliComparisonTask)\r | |
62 | \r | |
63 | Int_t AliComparisonTask::fEvtNumber = 0;\r | |
64 | \r | |
65 | //_____________________________________________________________________________\r | |
66 | AliComparisonTask::AliComparisonTask(const char *name) \r | |
67 | : AliAnalysisTask(name, "")\r | |
68 | , fTree(0)\r | |
69 | , fInfoMC(0)\r | |
70 | , fInfoRC(0)\r | |
71 | , fOutput(0)\r | |
72 | , fPitList(0)\r | |
73 | , fCompList(0)\r | |
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 | |
81 | // create the list for comparison objects\r | |
82 | fCompList = new TList;\r | |
83 | }\r | |
84 | \r | |
85 | //_____________________________________________________________________________\r | |
86 | AliComparisonTask::~AliComparisonTask()\r | |
87 | {\r | |
88 | if(fOutput) delete fOutput; fOutput =0; \r | |
89 | if(fCompList) delete fCompList; fCompList =0; \r | |
90 | }\r | |
91 | \r | |
92 | //_____________________________________________________________________________\r | |
93 | void 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 | |
111 | }\r | |
112 | \r | |
113 | //_____________________________________________________________________________\r | |
114 | Bool_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 | |
121 | \r | |
122 | // add object to the list\r | |
123 | fCompList->AddLast(pObj);\r | |
124 | \r | |
125 | return kTRUE;\r | |
126 | }\r | |
127 | \r | |
128 | //_____________________________________________________________________________\r | |
129 | void AliComparisonTask::CreateOutputObjects()\r | |
130 | {\r | |
131 | // Create histograms\r | |
132 | // Called once\r | |
133 | \r | |
134 | // create output list\r | |
135 | fOutput = new TList;\r | |
136 | fOutput->SetOwner();\r | |
137 | fPitList = fOutput->MakeIterator();\r | |
138 | \r | |
139 | AliComparisonObject *pObj=0;\r | |
140 | Int_t count=0;\r | |
141 | \r | |
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 | |
150 | }\r | |
151 | \r | |
152 | //_____________________________________________________________________________\r | |
153 | Bool_t AliComparisonTask::ReadEntry(Int_t evt) \r | |
154 | {\r | |
155 | // Read entry from the tree\r | |
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 | |
168 | return kTRUE;\r | |
169 | }\r | |
170 | //_____________________________________________________________________________\r | |
171 | void AliComparisonTask::Exec(Option_t *) \r | |
172 | {\r | |
173 | // Main loop\r | |
174 | // Called for each event\r | |
175 | \r | |
176 | AliComparisonObject *pObj=0;\r | |
177 | \r | |
178 | if (!fInfoMC && !fInfoRC) {\r | |
179 | Printf("ERROR: fInfoMC && fInfoRC not available");\r | |
180 | return;\r | |
181 | }\r | |
182 | \r | |
183 | // Process comparison\r | |
184 | Bool_t status = ReadEntry(fEvtNumber);\r | |
185 | if(status == kTRUE) \r | |
186 | {\r | |
187 | fPitList->Reset();\r | |
188 | while(( pObj = (AliComparisonObject *)fPitList->Next()) != NULL) {\r | |
189 | pObj->Exec(fInfoMC,fInfoRC);\r | |
190 | }\r | |
191 | }\r | |
192 | \r | |
193 | if( !( fEvtNumber % 10000) ) { \r | |
194 | cout << fEvtNumber << endl;\r | |
195 | }\r | |
196 | fEvtNumber++;\r | |
197 | \r | |
198 | // Post output data.\r | |
199 | PostData(0, fOutput);\r | |
200 | }\r | |
201 | \r | |
202 | //_____________________________________________________________________________\r | |
203 | void AliComparisonTask::Terminate(Option_t *) \r | |
204 | {\r | |
205 | // Called one at the end \r | |
206 | \r | |
207 | // check output data\r | |
208 | fOutput = dynamic_cast<TList*> (GetOutputData(0));\r | |
209 | if (!fOutput) {\r | |
210 | Printf("ERROR: AliComparisonTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r | |
211 | return;\r | |
212 | }\r | |
213 | }\r |