]>
Commit | Line | Data |
---|---|---|
dc0b1641 | 1 | // |
7984e5f7 | 2 | // Class to do the sharing correction for MC data. |
dc0b1641 | 3 | // |
7984e5f7 | 4 | // Input: |
5 | // - AliESDFMD object - from reconstruction | |
6 | // - Kinematics | |
7 | // - Track-References | |
8 | // | |
9 | // Output: | |
10 | // - AliESDFMD object - copy of input, but with signals merged | |
11 | // | |
12 | // Corrections used: | |
13 | // - None | |
14 | // | |
15 | // Histograms: | |
16 | // - For each ring (FMD1i, FMD2i, FMD2o, FMD3i, FMD3o) the distribution of | |
17 | // signals before and after the filter. | |
18 | // - For each ring (see above), an array of distributions of number of | |
19 | // hit strips for each vertex bin (if enabled - see Init method) | |
20 | // | |
dc0b1641 | 21 | #include "AliFMDMCSharingFilter.h" |
22 | #include <AliESDFMD.h> | |
23 | #include <AliMCEvent.h> | |
24 | #include <AliTrackReference.h> | |
25 | #include <AliStack.h> | |
26 | #include <TAxis.h> | |
27 | #include <TList.h> | |
28 | #include <TH1.h> | |
29 | #include <TMath.h> | |
dc0b1641 | 30 | #include "AliFMDStripIndex.h" |
31 | #include <AliLog.h> | |
32 | #include <TROOT.h> | |
33 | #include <iostream> | |
34 | #include <iomanip> | |
35 | ||
36 | ClassImp(AliFMDMCSharingFilter) | |
37 | #if 0 | |
38 | ; // This is for Emacs | |
39 | #endif | |
40 | ||
41 | ||
dc0b1641 | 42 | //____________________________________________________________________ |
43 | AliFMDMCSharingFilter::AliFMDMCSharingFilter(const char* title) | |
44 | : AliFMDSharingFilter(title), | |
45 | fFMD1i(0), | |
46 | fFMD2i(0), | |
47 | fFMD2o(0), | |
48 | fFMD3i(0), | |
49 | fFMD3o(0), | |
50 | fSumEta(0) | |
51 | { | |
7984e5f7 | 52 | // |
53 | // Constructor | |
54 | // | |
55 | // Parameters: | |
56 | // title Title of object - not significant | |
57 | // | |
dc0b1641 | 58 | fFMD1i = new TH2D("FMD1i_corr", "Merged vs MC", 21, -.5, 20.5, 100, 0, 20); |
59 | fFMD2i = new TH2D("FMD2i_corr", "Merged vs MC", 21, -.5, 20.5, 100, 0, 20); | |
60 | fFMD2o = new TH2D("FMD2o_corr", "Merged vs MC", 21, -.5, 20.5, 100, 0, 20); | |
61 | fFMD3i = new TH2D("FMD3i_corr", "Merged vs MC", 21, -.5, 20.5, 100, 0, 20); | |
62 | fFMD3o = new TH2D("FMD3o_corr", "Merged vs MC", 21, -.5, 20.5, 100, 0, 20); | |
63 | fFMD1i->SetYTitle("#Delta E/#Delta_{mip} (ESD)"); | |
64 | fFMD1i->SetXTitle("Hits (MC)"); | |
65 | fFMD2i->SetYTitle("#Delta E/#Delta_{mip} (ESD)"); | |
66 | fFMD2i->SetXTitle("Hits (MC)"); | |
67 | fFMD2o->SetYTitle("#Delta E/#Delta_{mip} (ESD)"); | |
68 | fFMD2o->SetXTitle("Hits (MC)"); | |
69 | fFMD3i->SetYTitle("#Delta E/#Delta_{mip} (ESD)"); | |
70 | fFMD3i->SetXTitle("Hits (MC)"); | |
71 | fFMD3o->SetYTitle("#Delta E/#Delta_{mip} (ESD)"); | |
72 | fFMD3o->SetXTitle("Hits (MC)"); | |
73 | fFMD1i->SetDirectory(0); | |
74 | fFMD2i->SetDirectory(0); | |
75 | fFMD2o->SetDirectory(0); | |
76 | fFMD3i->SetDirectory(0); | |
77 | fFMD3o->SetDirectory(0); | |
78 | fSumEta = new TH1D("mcSumEta", "MC INEL Truth", 200, -4, 6); | |
79 | fSumEta->SetXTitle("#eta"); | |
80 | fSumEta->SetYTitle("dN_{ch}/d#eta"); | |
81 | fSumEta->SetDirectory(0); | |
82 | fSumEta->Sumw2(); | |
83 | fSumEta->SetMarkerColor(kOrange+2); | |
84 | fSumEta->SetMarkerStyle(22); | |
85 | fSumEta->SetFillColor(0); | |
86 | fSumEta->SetFillStyle(0); | |
87 | ||
88 | } | |
89 | ||
90 | //____________________________________________________________________ | |
91 | AliFMDMCSharingFilter::AliFMDMCSharingFilter(const AliFMDMCSharingFilter& o) | |
92 | : AliFMDSharingFilter(o), | |
93 | fFMD1i(o.fFMD1i), | |
94 | fFMD2i(o.fFMD2i), | |
95 | fFMD2o(o.fFMD2o), | |
96 | fFMD3i(o.fFMD3i), | |
97 | fFMD3o(o.fFMD3o), | |
98 | fSumEta(o.fSumEta) | |
99 | { | |
7984e5f7 | 100 | // |
101 | // Copy constructor | |
102 | // | |
103 | // Parameters: | |
104 | // o Object to copy from | |
105 | // | |
dc0b1641 | 106 | } |
107 | ||
108 | //____________________________________________________________________ | |
109 | AliFMDMCSharingFilter::~AliFMDMCSharingFilter() | |
110 | { | |
7984e5f7 | 111 | // |
112 | // Destructor | |
113 | // | |
dc0b1641 | 114 | if (fFMD1i) delete fFMD1i; |
115 | if (fFMD2i) delete fFMD2i; | |
116 | if (fFMD2o) delete fFMD2o; | |
117 | if (fFMD3i) delete fFMD3i; | |
118 | if (fFMD3o) delete fFMD3o; | |
119 | if (fSumEta) delete fSumEta; | |
120 | } | |
121 | ||
122 | //____________________________________________________________________ | |
123 | AliFMDMCSharingFilter& | |
124 | AliFMDMCSharingFilter::operator=(const AliFMDMCSharingFilter& o) | |
125 | { | |
7984e5f7 | 126 | // |
127 | // Assignment operator | |
128 | // | |
129 | // Parameters: | |
130 | // o Object to assign from | |
131 | // | |
132 | // Return: | |
133 | // Reference to this | |
134 | // | |
dc0b1641 | 135 | AliFMDSharingFilter::operator=(o); |
136 | return *this; | |
137 | } | |
138 | ||
139 | //____________________________________________________________________ | |
140 | void | |
141 | AliFMDMCSharingFilter::StoreParticle(UShort_t d, | |
142 | Char_t r, | |
143 | UShort_t s, | |
144 | UShort_t t, | |
145 | AliESDFMD& output) const | |
146 | { | |
7984e5f7 | 147 | // |
148 | // Store a particle hit in FMD<i>dr</i>[<i>s,t</i>] in @a output | |
149 | // | |
150 | // Parameters: | |
151 | // d Detector | |
152 | // r Ring | |
153 | // s Sector | |
154 | // t Strip | |
155 | // output Output ESD object | |
156 | // | |
dc0b1641 | 157 | Double_t old = output.Multiplicity(d,r,s,t); |
158 | if (old == AliESDFMD::kInvalidMult) old = 0; | |
159 | output.SetMultiplicity(d,r,s,t,old+1); | |
160 | } | |
161 | ||
162 | //____________________________________________________________________ | |
163 | Bool_t | |
164 | AliFMDMCSharingFilter::FilterMC(const AliESDFMD& input, | |
165 | const AliMCEvent& event, | |
166 | Double_t vz, | |
167 | AliESDFMD& output) | |
168 | { | |
7984e5f7 | 169 | // |
170 | // Filter the input AliESDFMD object | |
171 | // | |
172 | // Parameters: | |
173 | // input Input (from ESD) - used for eta | |
174 | // lowFlux If this is a low-flux event | |
175 | // output Output AliESDFMD object | |
176 | // | |
177 | // Return: | |
178 | // True on success, false otherwise | |
179 | // | |
dc0b1641 | 180 | output.Clear(); |
181 | ||
182 | // Copy eta values to output | |
183 | for (UShort_t ed = 1; ed <= 3; ed++) { | |
184 | UShort_t nq = (ed == 1 ? 1 : 2); | |
185 | for (UShort_t eq = 0; eq < nq; eq++) { | |
186 | Char_t er = (eq == 0 ? 'I' : 'O'); | |
187 | UShort_t ns = (eq == 0 ? 20 : 40); | |
188 | UShort_t nt = (eq == 0 ? 512 : 256); | |
189 | for (UShort_t es = 0; es < ns; es++) | |
190 | for (UShort_t et = 0; et < nt; et++) | |
191 | output.SetEta(ed, er, es, et, input.Eta(ed, er, es, et)); | |
192 | } | |
193 | } | |
194 | AliStack* stack = const_cast<AliMCEvent&>(event).Stack(); | |
195 | Int_t nTracks = event.GetNumberOfTracks(); | |
196 | for (Int_t iTr = 0; iTr < nTracks; iTr++) { | |
197 | AliMCParticle* particle = | |
198 | static_cast<AliMCParticle*>(event.GetTrack(iTr)); | |
199 | ||
200 | // Check the returned particle | |
201 | if (!particle) continue; | |
202 | ||
203 | // Check if this charged and a primary | |
204 | Bool_t isCharged = particle->Charge() != 0; | |
205 | if (!isCharged) continue; | |
206 | Bool_t isPrimary = stack->IsPhysicalPrimary(iTr); | |
207 | ||
208 | // Fill 'dn/deta' histogram | |
209 | if (isPrimary) fSumEta->Fill(particle->Eta()); | |
210 | ||
211 | Int_t nTrRef = particle->GetNumberOfTrackReferences(); | |
212 | Int_t longest = -1; | |
213 | Double_t angle = 0; | |
214 | UShort_t oD = 0, oS = 1024, oT = 1024; | |
215 | Char_t oR = '\0'; | |
216 | for (Int_t iTrRef = 0; iTrRef < nTrRef; iTrRef++) { | |
217 | AliTrackReference* ref = particle->GetTrackReference(iTrRef); | |
218 | ||
219 | // Check existence | |
220 | if (!ref) continue; | |
221 | ||
222 | // Check that we hit an FMD element | |
223 | if (ref->DetectorId() != AliTrackReference::kFMD) | |
224 | continue; | |
225 | ||
226 | // Get the detector coordinates | |
227 | UShort_t d, s, t; | |
228 | Char_t r; | |
229 | AliFMDStripIndex::Unpack(ref->UserId(), d, r, s, t); | |
230 | if (oD > 0 && oR != '\0' && (d != oD || r != oR)) { | |
231 | longest = -1; | |
232 | StoreParticle(oD, oR, oS, oT, output); | |
233 | } | |
234 | ||
235 | oD = d; | |
236 | oR = r; | |
237 | oS = s; | |
238 | oT = t; | |
239 | ||
240 | // The longest passage is determined through the angle | |
241 | Double_t x = ref->X(); | |
242 | Double_t y = ref->Y(); | |
243 | Double_t z = ref->Z()-vz; | |
244 | Double_t rr = TMath::Sqrt(x*x+y*y); | |
245 | Double_t theta= TMath::ATan2(rr,z); | |
246 | Double_t ang = TMath::Abs(TMath::Pi()-theta); | |
247 | if (ang > angle) { | |
248 | longest = iTrRef; | |
249 | angle = ang; | |
250 | } | |
251 | } // Loop over track references | |
252 | if (longest < 0) continue; | |
253 | ||
254 | // Get the reference corresponding to the longest path through the detector | |
255 | AliTrackReference* ref = particle->GetTrackReference(longest); | |
256 | ||
257 | // Get the detector coordinates | |
258 | UShort_t d, s, t; | |
259 | Char_t r; | |
260 | AliFMDStripIndex::Unpack(ref->UserId(), d, r, s, t); | |
261 | ||
262 | StoreParticle(d,r,s,t,output); | |
263 | } // Loop over tracks | |
264 | return kTRUE; | |
265 | } | |
266 | ||
267 | //____________________________________________________________________ | |
268 | void | |
269 | AliFMDMCSharingFilter::CompareResults(const AliESDFMD& esd, | |
270 | const AliESDFMD& mc) | |
271 | { | |
7984e5f7 | 272 | // |
273 | // Compare the result of merging to the monte-carlo truth. This | |
274 | // fills the correlation histograms | |
275 | // | |
276 | // Parameters: | |
277 | // esd ESD after sharing correction | |
278 | // mc MC ESD | |
279 | // | |
280 | ||
dc0b1641 | 281 | // Copy eta values to output |
282 | for (UShort_t d = 1; d <= 3; d++) { | |
283 | UShort_t nq = (d == 1 ? 1 : 2); | |
284 | for (UShort_t q = 0; q < nq; q++) { | |
285 | Char_t r = (q == 0 ? 'I' : 'O'); | |
286 | UShort_t ns = (q == 0 ? 20 : 40); | |
287 | UShort_t nt = (q == 0 ? 512 : 256); | |
288 | TH2* co = 0; | |
289 | switch (d) { | |
290 | case 1: co = fFMD1i; break; | |
291 | case 2: co = (q == 0 ? fFMD2i : fFMD2o); break; | |
292 | case 3: co = (q == 0 ? fFMD3i : fFMD3o); break; | |
293 | } | |
294 | ||
295 | for (UShort_t s = 0; s < ns; s++) { | |
296 | for (UShort_t t = 0; t < nt; t++) { | |
297 | Float_t mEsd = esd.Multiplicity(d, r, s, t); | |
298 | Float_t mMc = mc.Multiplicity(d, r, s, t); | |
299 | ||
300 | co->Fill(mMc, mEsd); | |
301 | } | |
302 | } | |
303 | } | |
304 | } | |
305 | } | |
306 | ||
307 | //____________________________________________________________________ | |
308 | void | |
309 | AliFMDMCSharingFilter::DefineOutput(TList* dir) | |
310 | { | |
7984e5f7 | 311 | // |
312 | // Define the output histograms. These are put in a sub list of the | |
313 | // passed list. The histograms are merged before the parent task calls | |
314 | // AliAnalysisTaskSE::Terminate | |
315 | // | |
316 | // Parameters: | |
317 | // dir Directory to add to | |
318 | // | |
dc0b1641 | 319 | AliFMDSharingFilter::DefineOutput(dir); |
320 | TList* d = static_cast<TList*>(dir->FindObject(GetName())); | |
321 | TList* cd = new TList; | |
322 | cd->SetName("esd_mc_comparion"); | |
323 | d->Add(cd); | |
324 | cd->Add(fFMD1i); | |
325 | cd->Add(fFMD2i); | |
326 | cd->Add(fFMD2o); | |
327 | cd->Add(fFMD3i); | |
328 | cd->Add(fFMD3o); | |
329 | dir->Add(fSumEta); | |
330 | } | |
331 | ||
332 | //____________________________________________________________________ | |
333 | void | |
334 | AliFMDMCSharingFilter::ScaleHistograms(TList* dir, Int_t nEvents) | |
335 | { | |
7984e5f7 | 336 | // |
337 | // Scale the histograms to the total number of events | |
338 | // | |
339 | // Parameters: | |
340 | // dir Where the output is | |
341 | // nEvents Number of events | |
342 | // | |
dc0b1641 | 343 | AliFMDSharingFilter::ScaleHistograms(dir, nEvents); |
344 | TH1D* sumEta = static_cast<TH1D*>(dir->FindObject("mcSumEta")); | |
345 | if (!sumEta) { | |
346 | AliWarning(Form("No mcSumEta histogram found in output list")); | |
347 | return; | |
348 | } | |
349 | sumEta->Scale(1. / nEvents, "width"); | |
350 | } | |
351 | ||
352 | //____________________________________________________________________ | |
353 | void | |
354 | AliFMDMCSharingFilter::Print(Option_t* option) const | |
355 | { | |
7984e5f7 | 356 | // |
357 | // Print information | |
358 | // | |
359 | // Parameters: | |
360 | // option Not used | |
361 | // | |
dc0b1641 | 362 | char ind[gROOT->GetDirLevel()+1]; |
363 | for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' '; | |
364 | ind[gROOT->GetDirLevel()] = '\0'; | |
365 | AliFMDSharingFilter::Print(option); | |
366 | } | |
367 | ||
368 | //____________________________________________________________________ | |
369 | // | |
370 | // EOF | |
371 | // |