]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraAODTrackCuts.cxx
75a70729dccc066ed4e585c821468beeb8d514b7
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / AliSpectraAODTrackCuts.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 //-----------------------------------------------------------------
18 //         AliSpectraAODTrackCuts class
19 //-----------------------------------------------------------------
20
21 #include "TChain.h"
22 #include "TTree.h"
23 #include "TLegend.h"
24 #include "TH1F.h"
25 #include "TH2F.h"
26 #include "TCanvas.h"
27 #include "AliAnalysisTask.h"
28 #include "AliAnalysisManager.h"
29 #include "AliAODTrack.h"
30 #include "AliAODMCParticle.h"
31 #include "AliAODEvent.h"
32 #include "AliAODInputHandler.h"
33 #include "AliAnalysisTaskESDfilter.h"
34 #include "AliAnalysisDataContainer.h"
35 #include "AliSpectraAODTrackCuts.h"
36 #include "AliSpectraAODHistoManager.h"
37 #include <iostream>
38
39 using namespace std;
40
41 ClassImp(AliSpectraAODTrackCuts)
42
43
44 AliSpectraAODTrackCuts::AliSpectraAODTrackCuts(const char *name) : TNamed(name, "AOD Track Cuts"), fIsSelected(0), fTrackBits(0), fEtaCut(0), fDCACut(0), fPCut(0), fPtCut(0), fPtCutTOFMatching(0),fQvecCutMin(0),fQvecCutMax(0), fHistoCuts(0), fTrack(0)
45
46 {
47    // Constructor
48    fHistoCuts = new TH1I("fTrkCuts", "Track Cuts", kNTrkCuts, -0.5, kNTrkCuts - 0.5);
49    fEtaCut = 100000.0; // default value of eta cut ~ no cut
50    fDCACut = 100000.0; // default value of dca cut ~ no cut
51    fPCut = 100000.0; // default value of p cut ~ no cut
52    fPtCut = 100000.0; // default value of pt cut ~ no cut 
53    fPtCutTOFMatching=0.6; //default value fot matching with TOF
54    fQvecCutMin = -100000.0; // default value of qvec cut ~ no cut 
55    fQvecCutMax = 100000.0; // default value of qvec cut ~ no cut 
56    
57 }
58
59 //_______________________________________________________
60 Bool_t AliSpectraAODTrackCuts::IsSelected(AliAODTrack * track)
61 {
62 // Returns true if Track Cuts are selected and applied
63    if (!track)
64    {
65       printf("ERROR: Could not receive track");
66       return kFALSE;
67    }
68    fTrack = track;
69    fIsSelected = (CheckTrackType() && CheckEtaCut() && CheckDCACut() && CheckPCut() && CheckPtCut() && CheckTOFMatching());
70    return fIsSelected ;
71 }
72 //_________________________________________________________
73
74 Bool_t AliSpectraAODTrackCuts::CheckTrackType()
75 {
76    // Check track cuts
77    if (fTrack->TestFilterBit(fTrackBits)) return kTRUE;
78    fHistoCuts->Fill(kTrkBit);
79    return kFALSE;
80 }
81 //________________________________________________________
82 Bool_t AliSpectraAODTrackCuts::CheckEtaCut()
83 {
84    // Check eta cut
85    if (fTrack->Eta() < fEtaCut && fTrack->Eta() > - fEtaCut) return kTRUE;
86    fHistoCuts->Fill(kTrkEta);
87    return kFALSE;
88 }
89 //_______________________________________________________
90 Bool_t AliSpectraAODTrackCuts::CheckDCACut()
91 {
92    // Check DCA cut
93    if (fTrack->DCA() < fDCACut) return kTRUE;
94    fHistoCuts->Fill(kTrkDCA);
95    return kFALSE;
96 }
97 //________________________________________________________
98 Bool_t AliSpectraAODTrackCuts::CheckPCut()
99 {
100    // Check P cut
101    if (fTrack->P() < fPCut) return kTRUE;
102    fHistoCuts->Fill(kTrkP);
103    return kFALSE;
104 }
105 //_______________________________________________________
106 Bool_t AliSpectraAODTrackCuts::CheckPtCut()
107 {
108     // check Pt cut
109 //    if ((fTrack->Pt() < fPtCut) && (fTrack->Pt() > 0.3 )) return kTRUE;
110    if (fTrack->Pt() < fPtCut) return kTRUE;
111     fHistoCuts->Fill(kTrkPt);
112     return kFALSE;
113 }
114
115 //_______________________________________________________
116 Bool_t AliSpectraAODTrackCuts::CheckTOFMatching()
117 {
118   // check Pt cut
119   //    if ((fTrack->Pt() < fPtCut) && (fTrack->Pt() > 0.3 )) return kTRUE;
120   
121   if (fTrack->Pt() < fPtCutTOFMatching) return kTRUE;
122   else{
123     UInt_t status; 
124     status=fTrack->GetStatus();
125     if((status&AliAODTrack::kTOFout)==0 || (status&AliAODTrack::kTIME)==0){
126       fHistoCuts->Fill(kTOFMatching);
127       return kFALSE; //tof matching and PID
128     } 
129     return kTRUE;
130   }
131 }
132 //_______________________________________________________
133 void AliSpectraAODTrackCuts::PrintCuts() const
134 {
135   // Print cuts
136     cout << "Track Cuts" << endl;
137     cout << " > TrackBit\t" << fTrackBits << endl;
138     cout << " > Eta cut\t" << fEtaCut << endl;
139     cout << " > DCA cut\t" << fDCACut << endl;
140     cout << " > P cut\t" << fPCut << endl;
141     cout << " > Pt cut \t" << fPtCut << endl;
142     cout << " > Q vactor Min \t" << fQvecCutMin << endl;
143     cout << " > Q vactor Max \t" << fQvecCutMax << endl;
144 }
145 //_______________________________________________________
146 void AliSpectraAODTrackCuts::SetTrackType(UInt_t bit)
147 {
148    // Set the type of track to be used. The argument should be the bit number. The mask is produced automatically.
149    fTrackBits = (0x1 << (bit - 1));
150 }
151 //_______________________________________________________
152
153 Long64_t AliSpectraAODTrackCuts::Merge(TCollection* list)
154 {
155   // Merge a list of AliSpectraAODTrackCuts objects with this.
156   // Returns the number of merged objects (including this).
157
158   //  AliInfo("Merging");
159
160   if (!list)
161     return 0;
162
163   if (list->IsEmpty())
164     return 1;
165
166   TIterator* iter = list->MakeIterator();
167   TObject* obj;
168
169   // collections of all histograms
170   TList collections;
171
172   Int_t count = 0;
173
174   while ((obj = iter->Next())) {
175     AliSpectraAODTrackCuts* entry = dynamic_cast<AliSpectraAODTrackCuts*> (obj);
176     if (entry == 0) 
177       continue;
178
179     TH1I * histo = entry->GetHistoCuts();      
180     collections.Add(histo);
181     count++;
182   }
183   
184   fHistoCuts->Merge(&collections);
185   
186   delete iter;
187
188   return count+1;
189 }
190