]>
Commit | Line | Data |
---|---|---|
09b20ad1 | 1 | //------------------------------------------------------------------------------ |
2 | // Implementation of the AliComparisonTask class. It compares properties of the | |
3 | // reconstructed and MC particle tracks under several conditions. | |
4 | // As the input it requires the TTree with AliRecInfo and AliMCInfo branches. | |
5 | // The comparison output histograms are stored | |
6 | // in the comparison objects: AliComparisonRes, AliComparisonEff, | |
7 | // AliComparisonDEdx and AliComparisonDCA. Each of these objects also contains | |
8 | // selection cuts which were used during filling the histograms. | |
9 | // | |
10 | // Author: J.Otwinowski 04/02/2008 | |
11 | //------------------------------------------------------------------------------ | |
12 | ||
13 | #include "iostream" | |
14 | ||
15 | #include "TChain.h" | |
16 | #include "TTree.h" | |
17 | #include "TH1F.h" | |
18 | #include "TCanvas.h" | |
19 | #include "TList.h" | |
20 | #include "TFile.h" | |
21 | ||
22 | #include "AliAnalysisTask.h" | |
23 | #include "AliAnalysisManager.h" | |
24 | #include "AliESDEvent.h" | |
25 | #include "AliESDInputHandler.h" | |
26 | #include "AliESDVertex.h" | |
27 | #include "AliMagFMaps.h" | |
28 | #include "AliTracker.h" | |
29 | #include "AliGeomManager.h" | |
30 | ||
31 | #include "AliMCInfo.h" | |
32 | #include "AliESDRecInfo.h" | |
33 | #include "AliMCInfoCuts.h" | |
34 | #include "AliRecInfoCuts.h" | |
35 | #include "AliComparisonRes.h" | |
36 | #include "AliComparisonEff.h" | |
37 | #include "AliComparisonDEdx.h" | |
38 | #include "AliComparisonDCA.h" | |
39 | #include "AliComparisonTask.h" | |
40 | ||
41 | using namespace std; | |
42 | ||
43 | ClassImp(AliComparisonTask) | |
44 | ||
45 | Int_t AliComparisonTask::evtNumber = 0; | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliComparisonTask::AliComparisonTask(const char *name) | |
49 | : AliAnalysisTask(name, "") | |
50 | , fTree(0) | |
51 | , fInfoMC(0) | |
52 | , fInfoRC(0) | |
53 | , fCompRes(0) | |
54 | , fCompEff(0) | |
55 | , fCompDEdx(0) | |
56 | , fCompDCA(0) | |
57 | , fOutput(0) | |
58 | , fMagField(0) | |
59 | , fMagFMap(0) | |
60 | , fGeom(0) | |
61 | { | |
62 | // Constructor | |
63 | ||
64 | // Define input and output slots here | |
65 | DefineInput(0, TChain::Class()); | |
66 | DefineOutput(0, TList::Class()); | |
67 | ||
68 | // set default mag. field | |
69 | SetMagField(); | |
70 | ||
71 | // set default geometry | |
72 | SetGeometry(); | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliComparisonTask::~AliComparisonTask() | |
77 | { | |
78 | if(fOutput) delete fOutput; fOutput =0; | |
79 | if(fMagFMap) delete fMagFMap; fMagFMap =0; | |
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | void AliComparisonTask::ConnectInputData(Option_t *) | |
84 | { | |
85 | // Connect input data | |
86 | // Called once | |
87 | ||
88 | fTree = dynamic_cast<TTree*> (GetInputData(0)); | |
89 | if (!fTree) { | |
90 | Printf("ERROR: Could not read chain from input slot 0"); | |
91 | } else { | |
92 | fTree->SetBranchStatus("*",1); | |
93 | } | |
94 | ||
95 | if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) { | |
96 | fTree->GetBranch("MC")->SetAddress(&fInfoMC); | |
97 | fTree->GetBranch("RC")->SetAddress(&fInfoRC); | |
98 | } else { | |
99 | Printf("ERROR: Could not get MC and RC branches"); | |
100 | } | |
101 | ||
102 | // set mag. field map | |
103 | fMagFMap = new AliMagFMaps("Maps","Maps", 2, 1., 10., fMagField); | |
104 | AliTracker::SetFieldMap(fMagFMap,kFALSE); | |
105 | ||
106 | // set geommetry | |
107 | AliGeomManager::LoadGeometry(fGeom); | |
108 | } | |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | void AliComparisonTask::CreateOutputObjects() | |
112 | { | |
113 | // Create histograms | |
114 | // Called once | |
115 | fOutput = new TList; | |
116 | fOutput->SetOwner(); | |
117 | ||
118 | if(fCompRes) fOutput->Add(fCompRes); | |
119 | else | |
120 | Printf("WARNING: AliComparisonRes is not added to the output"); | |
121 | ||
122 | if(fCompEff) fOutput->Add(fCompEff); | |
123 | else | |
124 | Printf("WARNING: AliComparisonEff is not added to the output"); | |
125 | ||
126 | if(fCompDEdx) fOutput->Add(fCompDEdx); | |
127 | else | |
128 | Printf("WARNING: AliComparisonDEdx is not added to the output"); | |
129 | ||
130 | if(fCompDCA) fOutput->Add(fCompDCA); | |
131 | else | |
132 | Printf("WARNING: AliComparisonDCA is not added to the output"); | |
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | Bool_t AliComparisonTask::ReadEntry(Int_t evt) | |
137 | { | |
138 | Long64_t centry = fTree->LoadTree(evt); | |
139 | if(centry < 0) return kFALSE; | |
140 | ||
141 | if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) { | |
142 | fTree->GetBranch("MC")->SetAddress(&fInfoMC); | |
143 | fTree->GetBranch("RC")->SetAddress(&fInfoRC); | |
144 | } else { | |
145 | Printf("ERROR: Could not get MC and RC branches"); | |
146 | return kFALSE; | |
147 | } | |
148 | fTree->GetEntry(evt); | |
149 | ||
150 | return kTRUE; | |
151 | } | |
152 | //_____________________________________________________________________________ | |
153 | void AliComparisonTask::Exec(Option_t *) | |
154 | { | |
155 | // Main loop | |
156 | // Called for each event | |
157 | ||
158 | if (!fInfoMC && !fInfoRC) { | |
159 | Printf("ERROR: fInfoMC && fInfoRC not available"); | |
160 | return; | |
161 | } | |
162 | ||
163 | // Process comparison | |
164 | Bool_t status = ReadEntry(evtNumber); | |
165 | if(status == kTRUE) | |
166 | { | |
167 | if(fCompRes) fCompRes->Exec(fInfoMC,fInfoRC); | |
168 | if(fCompEff) fCompEff->Exec(fInfoMC,fInfoRC); | |
169 | if(fCompDEdx) fCompDEdx->Exec(fInfoMC,fInfoRC); | |
170 | if(fCompDCA) fCompDCA->Exec(fInfoMC,fInfoRC); | |
171 | } | |
172 | ||
173 | if( !( evtNumber % 10000) ) { | |
174 | cout << evtNumber << endl; | |
175 | } | |
176 | evtNumber++; | |
177 | ||
178 | // Post output data. | |
179 | PostData(0, fOutput); | |
180 | } | |
181 | ||
182 | //_____________________________________________________________________________ | |
183 | void AliComparisonTask::Terminate(Option_t *) | |
184 | { | |
185 | // Called once at the end of the event loop | |
186 | cout << "Terminate " << endl; | |
187 | ||
188 | TFile *out = new TFile("Output.root","RECREATE"); | |
189 | out->cd(); | |
190 | ||
191 | fOutput = dynamic_cast<TList*> (GetOutputData(0)); | |
192 | if (!fOutput) { | |
193 | Printf("ERROR: fOutput not available"); | |
194 | return; | |
195 | } | |
196 | ||
197 | fCompRes = dynamic_cast<AliComparisonRes*> (fOutput->FindObject("AliComparisonRes")); | |
198 | if (!fCompRes) { | |
199 | Printf("WARNING: AliComparisonRes not available"); | |
200 | return; | |
201 | } | |
202 | ||
203 | fCompEff = dynamic_cast<AliComparisonEff*> (fOutput->FindObject("AliComparisonEff")); | |
204 | if (!fCompEff) { | |
205 | Printf("WARNING: AliComparisonEff not available"); | |
206 | return; | |
207 | } | |
208 | ||
209 | fCompDEdx = dynamic_cast<AliComparisonDEdx*> (fOutput->FindObject("AliComparisonDEdx")); | |
210 | if (!fCompDEdx) { | |
211 | Printf("WARNING: AliComparisonDEdx not available"); | |
212 | return; | |
213 | } | |
214 | ||
215 | fCompDCA = dynamic_cast<AliComparisonDCA*> (fOutput->FindObject("AliComparisonDCA")); | |
216 | if (!fCompDCA) { | |
217 | Printf("WARNING: AliComparisonDCA not available"); | |
218 | return; | |
219 | } | |
220 | ||
221 | fOutput->Write(); | |
222 | out->Close(); | |
223 | } |