]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGUD/DIFFRACTIVE/xsAndTwoProng/AliCDMesonTracks.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGUD / DIFFRACTIVE / xsAndTwoProng / AliCDMesonTracks.cxx
CommitLineData
784b6a81 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15//
16// AliCDMesonTracks
17// for
18// AliAnalysisTaskCDMeson
19//
20// Author:
21// Felix Reidt <Felix.Reidt@cern.ch>
22//
23// class applies the track cuts and provides access to the tracks
24//
25//
26
27// ROOT classes
28#include "TObjArray.h"
29
30// AliRoot classes
31#include "AliESDEvent.h"
32#include "AliAODEvent.h"
33#include "AliESDtrackCuts.h"
34#include "AliVTrack.h"
35#include "AliMultiplicity.h"
36
37// header of the class itsself
38#include "AliCDMesonTracks.h"
f15c1f69 39#include "assert.h"
784b6a81 40
41
42//------------------------------------------------------------------------------
43AliCDMesonTracks::AliCDMesonTracks()
44 : fAODEvent(0x0)
45 , fESDEvent(0x0)
46 , fDoAOD(kFALSE)
47 , fDoSoft(kTRUE)
48 , fIsValid(kFALSE)
49 , fNTrk0(-999)
50 , fNch(-999)
51 , fNsoft(-999)
52 , fNcombined(-999)
53 , fNITSpureSA(-999)
54 , fNtrackletsCentralBarrel(-999)
55 , fNtrackletsForward(-999)
56 , fTracks(0x0)
57 , fSoftTracks(0x0)
58{
59 //
60 // constructor
61 //
62}
63
64
65//------------------------------------------------------------------------------
66AliCDMesonTracks::AliCDMesonTracks(const AliCDMesonTracks& tracks)
67 : fAODEvent(tracks.fAODEvent)
68 , fESDEvent(tracks.fESDEvent)
69 , fDoAOD(tracks.fDoAOD)
70 , fDoSoft(tracks.fDoSoft)
71 , fIsValid(tracks.fIsValid)
72 , fNTrk0(tracks.fNTrk0)
73 , fNch(tracks.fNch)
74 , fNsoft(tracks.fNsoft)
75 , fNcombined(tracks.fNcombined)
76 , fNITSpureSA(tracks.fNITSpureSA)
77 , fNtrackletsCentralBarrel(tracks.fNtrackletsCentralBarrel)
78 , fNtrackletsForward(tracks.fNtrackletsForward)
79 , fTracks(tracks.fTracks)
80 , fSoftTracks(tracks.fSoftTracks)
81{
82 //
83 // copy constructor
84 //
85}
86
87
88//------------------------------------------------------------------------------
89AliCDMesonTracks& AliCDMesonTracks::operator=(const AliCDMesonTracks& tracks)
90{
91 //
92 // assignment operator
93 //
94
95 if (this != &tracks) {
96 // create deep copy ...
97 }
98 return *this;
99}
100
101
102//------------------------------------------------------------------------------
103AliCDMesonTracks::~AliCDMesonTracks()
104{
105 //
106 // destructor
107 //
108
109 if (fTracks) {
110 fTracks->SetOwner(kTRUE);
111 fTracks->Clear();
112 delete fTracks;
113 fTracks = 0x0;
114 }
115 if (fSoftTracks) {
116 fSoftTracks->SetOwner(kTRUE);
117 fSoftTracks->Clear();
118 delete fSoftTracks;
119 fSoftTracks = 0x0;
120 }
121}
122
123
124//------------------------------------------------------------------------------
125Bool_t AliCDMesonTracks::ProcessEvent(AliAODEvent* aodEvent,
126 AliESDEvent* esdEvent,
127 Bool_t doSoft /* = kTRUE */)
128{
129 //
130 // this function controlls the processing of an event, after the processing is
131 // done, the results can be used via the getters
132 //
133
134 if ((aodEvent && esdEvent) || (!aodEvent && !esdEvent)) {
135 // only one event type is allowed, no event type is also not allowed
136 return fIsValid = fDoAOD = kFALSE;
137 }
138 else if (aodEvent) {
139 fAODEvent = aodEvent;
140 fESDEvent = 0x0;
141 fDoAOD = kTRUE;
142 }
143 else if (esdEvent) {
144 fAODEvent = 0x0;
145 fESDEvent = esdEvent;
146 fDoAOD = kFALSE;
147 }
148 fDoSoft = doSoft;
149
150 ApplyCuts();
151 if (!fDoAOD) GetRemainingTracklets();
152 fIsValid = kTRUE;
153 return kTRUE;
154}
155
156
157//------------------------------------------------------------------------------
158AliVTrack* AliCDMesonTracks::GetTrack(UInt_t index) const
159{
160 //
161 // provides access to the selected tracks, normal tracks have lower indices
162 // than soft tracks
163 //
164
165 if (!fIsValid) return 0x0; // cut selection wasn't properly done
166
167 if ((((Int_t)index >= fNch) && !fDoSoft) || // soft not enabled
168 ((Int_t)index >= fNcombined)) return 0x0; // soft enabled
169 // index out of range
170
171 if ((Int_t)index < fNch) return (AliVTrack*)((*fTracks)[index]);
172 else if ((Int_t)index < fNcombined) {
173 return (AliVTrack*)((*fSoftTracks)[index - fNch]);
174 }
175 else return 0x0; // something went wrong
176}
177
178
179//------------------------------------------------------------------------------
180Double_t AliCDMesonTracks::GetInvariantMass(Bool_t includeSoftTracks /*=kTRUE*/)
181{
182 //
183 // compute the invariant mass of all accepted tracks in the event
184 //
185
186 TLorentzVector sum;
187 for (Int_t iTrack = 0; iTrack < fTracks->GetEntriesFast(); ++iTrack) {
188 AliVTrack* track = (AliVTrack*)fTracks->UncheckedAt(iTrack);
189 TLorentzVector temp(track->Px(), track->Py(), track->Pz(), track->E());
190 sum += temp;
191 }
192 if (includeSoftTracks) {
193 for (Int_t iSoftTrack = 0; iSoftTrack < fSoftTracks->GetEntriesFast();
194 ++iSoftTrack) {
195 AliVTrack* track = (AliVTrack*)fSoftTracks->UncheckedAt(iSoftTrack);
196 TLorentzVector temp(track->Px(), track->Py(), track->Pz(), track->E());
197 sum += temp;
198 }
199 }
200 return sum.M();
201}
202
203
204//------------------------------------------------------------------------------
205void AliCDMesonTracks::ApplyCuts()
206{
207 //
208 // steers the track selection process
209 //
210
211 fNTrk0 = (fDoAOD) ?
212 fAODEvent->GetNumberOfTracks() : fESDEvent->GetNumberOfTracks();
213
214 fNch = -999;
215 fNsoft = -999;
216 fNcombined = -999;
217 fNITSpureSA = -999;
218
219 if (fDoAOD) {
220 CutTrack(fAODEvent); // ordinary tracks
221 CutTrack(fAODEvent, 2); // kITSpureSA
222 }
223 else {
224 CutTrack(fESDEvent); // ordinary tracks
225 CutTrack(fESDEvent, 2); // kITSpureSA
226 }
227
228 if (fDoSoft) { // do soft tracks
229 if (fDoAOD) {
230 CutTrack(fAODEvent, 1);
231 }
232 else {
233 CutTrack(fESDEvent, 1);
234 }
235
236 fNcombined = fNch + fNsoft;
237 for (Int_t iSoft = 0; iSoft < fNsoft; iSoft++) {
238 Int_t iTrk = 0;
239 while (iTrk < fNch) {
240 // TODO find some criterion to match them properly!
241 // check whether they are really complementary if not
242 // an error will be raised
243 // already contained in both arrays, exit loop
244 ++iTrk; // next track
245 }
246 }
247 }
248 else { // do not care about soft tracks
249 fNcombined = fNch;
250 }
251}
252
253
254//------------------------------------------------------------------------------
255void AliCDMesonTracks::CutTrack(AliESDEvent *ESDEvent, Int_t mode /* = 0 */)
256{
257 //
258 //CutTrack to be combined with the AOD function // TODO
259 //
260
261 const Double_t etacut = 0.9;
262
263 AliESDtrackCuts esdTrackCuts;
264
265 if (mode == 0) { // default mode
266 // cuts for normal tracks (ITS + TPC)
267 // i.e. GetStandardITSTPCTrackCuts2010(kTRUE);
268 // (same, just typed in full detail...)
269
270 if (fTracks) {
271 fTracks->Clear();
272 delete fTracks;
273 fTracks = 0x0;
274 }
275
276 // TPC
277 esdTrackCuts.SetMinNClustersTPC(70);
278 //esdTrackCuts.SetMinNCrossedRowsTPC(70);
279 //esdTrackCuts.SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
280
281 esdTrackCuts.SetMaxChi2PerClusterTPC(4);
282 esdTrackCuts.SetAcceptKinkDaughters(kFALSE);
283 esdTrackCuts.SetRequireTPCRefit(kTRUE);
284 // ITS
285 esdTrackCuts.SetRequireITSRefit(kTRUE);
286 esdTrackCuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD,
287 AliESDtrackCuts::kAny);
288 // 7*(0.0026+0.0050/pt^1.01)
289 esdTrackCuts.SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
290
291 esdTrackCuts.SetMaxDCAToVertexZ(2);
292 esdTrackCuts.SetDCAToVertex2D(kFALSE);
293 esdTrackCuts.SetRequireSigmaToVertex(kFALSE);
294
295 esdTrackCuts.SetEtaRange(-etacut, etacut);
296
297 fTracks = esdTrackCuts.GetAcceptedTracks(ESDEvent);
298 fNch = fTracks->GetEntriesFast();
299 }
300 else if (mode == 1) {
301 // cuts for soft tracks (ITS only - kITSsa)
302
303 if (fSoftTracks) {
304 fSoftTracks->Clear();
305 delete fSoftTracks;
306 fSoftTracks = 0x0;
307 }
308
309 esdTrackCuts.SetRequireITSStandAlone(kTRUE);
310 esdTrackCuts.SetRequireITSPureStandAlone(kFALSE);
311 esdTrackCuts.SetRequireITSRefit(kTRUE);
312 esdTrackCuts.SetMinNClustersITS(4);
313 esdTrackCuts.SetClusterRequirementITS(AliESDtrackCuts::kSPD,
314 AliESDtrackCuts::kAny);
315 esdTrackCuts.SetMaxChi2PerClusterITS(1.);
316 esdTrackCuts.SetMaxDCAToVertexXYPtDep("0.0595+0.0182/pt^1.55");
317
318 esdTrackCuts.SetEtaRange(-etacut, etacut);
319
320 fSoftTracks = esdTrackCuts.GetAcceptedTracks(ESDEvent);
321 fNsoft = fSoftTracks->GetEntriesFast();
322 }
323 else {
324 // cuts for ITSpureSA tracks used in order to get rid of them for noise
325 // studies
326
327 // selection according to cuts
328 esdTrackCuts.SetRequireITSPureStandAlone(kTRUE);
329
330 // do selection according to status bits (never tested!!!)
331 //for(Int_t itrack = 0; itrack < ESDEvent->GetNumberOfTracks(); itrack++){
332 // const AliESDtrack* esdtrack = ESDEvent->GetTrack(itrack);
333 // UInt64 status = esdtrack->GetStatus();
334 // if ((status & kITSpureSA) && !(status & kITSsa)){
335 // }
336 //}
337 TObjArray* arr = esdTrackCuts.GetAcceptedTracks(ESDEvent);
338 fNITSpureSA = arr->GetEntriesFast();
339 delete arr;
340 arr = 0x0;
341 }
342}
343
344
345//------------------------------------------------------------------------------
346void AliCDMesonTracks::CutTrack(AliAODEvent *AODEvent, Int_t mode /* = 0 */)
347{
348 //
349 // CutTrack for AODs
350 //
351
352 UInt_t bit = 0x0;
353 TObjArray* trks = 0x0;
354 Int_t* ntrks = 0x0;
355
356 if (mode == 0) { // default mode
357 // cuts for normal tracks (ITS + TPC)
358 // i.e. GetStandardITSTPCTrackCuts2010(kTRUE);
359 // (same, just typed in full detail...)
360 bit = 0x1 << 14;
361
362 // prepare storage
363 if (fTracks) {
364 fTracks->SetOwner(kTRUE);
365 fTracks->Clear();
366 }
367 else {
368 fTracks = new TObjArray();
369 fTracks->SetOwner(kTRUE);
370 }
371
372 // store where to put selected tracks
373 trks = fTracks;
374 ntrks = &fNch;
375 }
376 else if (mode == 1) {
377 // cuts for soft tracks (ITS only - kITSsa)
378 bit = 0x1 << 15;
379
380 if (fSoftTracks) {
381 fSoftTracks->SetOwner(kTRUE);
382 fSoftTracks->Clear();
383 }
384 else {
385 fSoftTracks = new TObjArray();
386 fSoftTracks->SetOwner(kTRUE);
387 }
388
389 // sotre where to put selected tracks
390 trks = fSoftTracks;
391 ntrks = &fNsoft;
392 }
393 else {
394 // cuts for ITSpureSA tracks used in order to get rid of them for noise
395 // studies
396 bit = 0x1 << 16;
397
398 // do not store tracks, just count them =>
399 trks = 0x0;
400 ntrks = &fNITSpureSA;
401 }
402
403 for (Int_t iTrk = 0; iTrk < AODEvent->GetNumberOfTracks(); iTrk++) {
f15c1f69 404 const AliAODTrack* trk = dynamic_cast<const AliAODTrack*>(AODEvent->GetTrack(iTrk));
405 assert(trk&&"Not a standard AOD");
784b6a81 406
407 if (trk->TestFilterBit(bit)) {
408 // test whether track was selected by that filter
409
410 if (trks) { // add tracks to TObjArray
411 trks->Add((TObject*)trk);
412 }
413 else { // just count them
414 ++(*ntrks);
415 }
416 }
417 }
418
419 if (trks) {
420 (*ntrks) = trks->GetEntriesFast();
421 }
422}
423
424
425//------------------------------------------------------------------------------
426void AliCDMesonTracks::GetRemainingTracklets()
427{
428 // determines the number of tracklets in an event, which are not assigned to
429 // tracks
430 // this is only possible running on ESDs, for AODs this information has to be
431 // preprocessed
432
433 if (!fESDEvent) return;
434 const AliMultiplicity *mult = fESDEvent->GetMultiplicity();
435
436 if (mult) {
437 // reset values
438 fNtrackletsCentralBarrel = 0;
439 fNtrackletsForward = 0;
440
441 for (Int_t iTracklet = 0; iTracklet < mult->GetNumberOfTracklets();
442 iTracklet++) {
443 Int_t id1 = -1, id2 = -1;
444 if (!mult->GetTrackletTrackIDs(iTracklet, 0, id1, id2)) {
445 float_t eta = mult->GetEta(iTracklet);
446
271604fd 447 if ((eta < -0.9) || (eta > 0.9)) {
784b6a81 448 ++fNtrackletsForward;
449 }
450 else {
451 ++fNtrackletsCentralBarrel;
452 }
453 }
454 }
455 }
456}