Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2015, 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 : #include <TClonesArray.h>
17 : #include <TBits.h>
18 : #include <TObjArray.h>
19 :
20 : #include <AliAODEvent.h>
21 : #include <AliAODTrack.h>
22 : #include <AliAODTrackSelection.h>
23 : #include <AliESDtrack.h>
24 : #include <AliESDtrackCuts.h>
25 :
26 : /// \cond CLASSIMP
27 170 : ClassImp(AliAODTrackSelection)
28 : /// \endcond
29 :
30 : /**
31 : * Main constructor, initialises fields with 0 (or NULL). For ROOT I/O, not intended
32 : * to be used by the users.
33 : */
34 : AliAODTrackSelection::AliAODTrackSelection() :
35 0 : AliVTrackSelection(),
36 0 : fFilterBits(0)
37 0 : {
38 0 : }
39 :
40 : /**
41 : * Main Constructor, initalising also track cuts and filter bits. In case the initial cuts
42 : * is a nullpointer, only filter bits are used for the track selection. This constructor is
43 : * intended to be used by the users.
44 : *
45 : * \param cuts Inital track cut object (of type AliESDtrackCuts, can be a nullpointer)
46 : * \param filterbits Filter bits required
47 : */
48 : AliAODTrackSelection::AliAODTrackSelection(AliVCuts* cuts, UInt_t filterbits):
49 0 : AliVTrackSelection(),
50 0 : fFilterBits(filterbits)
51 0 : {
52 0 : AddTrackCuts(cuts);
53 0 : }
54 :
55 : /**
56 : * Function checks whether track is accepted under the given track selection cuts.
57 : * The function can handle AliAODTrack and AliPicoTrack, while for AliPico track an
58 : * AliAODTrack is expected to be the underlying structure. If it is not possible to
59 : * access an AOD track from the input track, the object will not be selected. Otherwise
60 : * first the status bits are checked (if requested), and if further track cuts (of type
61 : * AliESDtrackCuts) are provided, the track is converted to an ESD track for further checks.
62 : *
63 : * \param trk: Track to check
64 : * \return true if selected, false otherwise
65 : */
66 : bool AliAODTrackSelection::IsTrackAccepted(AliVTrack * const trk)
67 : {
68 0 : AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(trk);
69 0 : if(!aodt){
70 0 : AliError("Failed getting AOD track");
71 0 : return kFALSE;
72 : }
73 :
74 0 : fTrackBitmap.ResetAllBits();
75 : Int_t cutcounter(0);
76 0 : if (fFilterBits) {
77 0 : if(aodt->TestFilterBit(fFilterBits)) fTrackBitmap.SetBitNumber(cutcounter);
78 : cutcounter++;
79 0 : }
80 0 : if (fListOfCuts) {
81 0 : for (TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
82 0 : AliVCuts *trackCuts = static_cast<AliVCuts*>(*cutIter);
83 0 : if (trackCuts->IsA() == AliESDtrackCuts::Class()) {
84 : // If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before
85 0 : AliESDtrack copyTrack(aodt);
86 0 : if (trackCuts->IsSelected(©Track)) fTrackBitmap.SetBitNumber(cutcounter);
87 0 : }
88 : else{
89 0 : if (trackCuts->IsSelected(aodt)) fTrackBitmap.SetBitNumber(cutcounter);
90 : }
91 0 : cutcounter++;
92 : }
93 0 : }
94 :
95 0 : if (fSelectionModeAny){
96 : // In case of ANY one of the cuts need to be fulfilled (equivalent to one but set)
97 0 : return fTrackBitmap.CountBits() > 0 || cutcounter == 0;
98 : }
99 : else {
100 : // In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set)
101 0 : return fTrackBitmap.CountBits() == cutcounter;
102 : }
103 0 : }
|