]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPIDTOF.cxx
method added to add a run list (A.Pulvirenti)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDTOF.cxx
CommitLineData
35e49ca5 1//
2// Class AliRsnCutPIDTOF
3//
4// General implementation of a single cut strategy, which can be:
5// - a value contained in a given interval [--> IsBetween() ]
6// - a value equal to a given reference [--> MatchesValue()]
7//
8// In all cases, the reference value(s) is (are) given as data members
9// and each kind of cut requires a given value type (Int, UInt, Double),
10// but the cut check procedure is then automatized and chosen thanks to
11// an enumeration of the implemented cut types.
12// At the end, the user (or any other point which uses this object) has
13// to use the method IsSelected() to check if this cut has been passed.
14//
15// authors: Martin Vala (martin.vala@cern.ch)
16// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17//
18
19#include <Riostream.h>
20
21#include "AliESDtrack.h"
22#include "AliAODTrack.h"
23#include "AliESDpid.h"
24#include "AliTOFT0maker.h"
25#include "AliTOFcalib.h"
26#include "AliCDBManager.h"
27#include "AliVTrack.h"
28
29#include "AliRsnEvent.h"
30#include "AliRsnDaughter.h"
31#include "AliRsnCutPIDTOF.h"
32
33ClassImp(AliRsnCutPIDTOF)
34
35//Bool_t AliRsnCutPIDTOF::fgTOFcalibrateESD = kTRUE;
36Bool_t AliRsnCutPIDTOF::fgTOFcorrectTExp = kTRUE;
37Bool_t AliRsnCutPIDTOF::fgTOFuseT0 = kTRUE;
38Bool_t AliRsnCutPIDTOF::fgTOFtuneMC = kFALSE;
39Double_t AliRsnCutPIDTOF::fgTOFresolution = 100.0;
40AliTOFT0maker* AliRsnCutPIDTOF::fgTOFmaker = 0x0;
41AliTOFcalib* AliRsnCutPIDTOF::fgTOFcalib = 0x0;
42Int_t AliRsnCutPIDTOF::fgLastRun = -1;
43Int_t AliRsnCutPIDTOF::fgLastEventID = -1;
44AliESDEvent* AliRsnCutPIDTOF::fgLastEvent = 0x0;
45
46
47//_________________________________________________________________________________________________
b4082dee 48AliRsnCutPIDTOF::AliRsnCutPIDTOF(const char *name, AliPID::EParticleType pid, Bool_t isMC, Double_t min, Double_t max, Bool_t forceMatching) :
35e49ca5 49 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
50 fIsMC(isMC),
659ef4f0 51 fForceMatching(forceMatching),
b4082dee 52 fPIDtype(pid),
35e49ca5 53 fESDpid(),
54 fAODpid()
55{
56//
57// Default constructor.
58//
59}
60
61//_________________________________________________________________________________________________
62AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) :
63 AliRsnCut(copy),
64 fIsMC(copy.fIsMC),
659ef4f0 65 fForceMatching(copy.fForceMatching),
35e49ca5 66 fPIDtype(copy.fPIDtype),
67 fESDpid(copy.fESDpid),
68 fAODpid(copy.fAODpid)
69{
70//
71// Copy constructor
72//
73}
74
75//_________________________________________________________________________________________________
76AliRsnCutPIDTOF& AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF& copy)
77{
78//
79// Assignment operator
80//
81
82 fIsMC = copy.fIsMC;
659ef4f0 83 fForceMatching = copy.fForceMatching;
35e49ca5 84 fPIDtype = copy.fPIDtype;
85 fESDpid = copy.fESDpid;
86 fAODpid = copy.fAODpid;
87
88 return (*this);
89}
90
91//_________________________________________________________________________________________________
92Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object)
93{
94//
95// Cut checker.
96//
97
98 // coherence check
99 if (!TargetOK(object)) return kFALSE;
100
659ef4f0 101 // reject always non-track objects
35e49ca5 102 AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
103 if (!vtrack)
104 {
105 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
106 return kFALSE;
107 }
659ef4f0 108
109 // for non TOF-matched tracks, the TOF PID check cannot be done:
110 // -- if 'fForceMatching' is kTRUE
111 // all non matched tracks are rejected as if they didn't pass the cut
112 // -- if 'fForceMatching' is kFALSE
113 // all non matched tracks are ignored, as if they did pass the cut
35e49ca5 114 ULong_t status = (ULong_t)vtrack->GetStatus();
115 if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0)
116 {
117 AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF");
659ef4f0 118 if (fForceMatching)
119 return kFALSE;
120 else
121 return kTRUE;
35e49ca5 122 }
123
124 // retrieve real object type
125 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
126 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
127 if (esdTrack)
128 {
129 AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
130 ProcessCurrentEvent();
131 return CheckESD(esdTrack);
132 }
133 else if (aodTrack)
134 {
135 AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
136 return CheckAOD(aodTrack);
137 }
138 else
139 {
140 AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
141 return kFALSE;
142 }
143}
144
145//_________________________________________________________________________________________________
146void AliRsnCutPIDTOF::ProcessCurrentEvent()
147{
148//
149// Repeats the PID for current event.
150// In order to avoid to repeat the operation for each track
151// this function uses the data-member pointers to check
152// if current event was already processed or not.
153//
154
155 // get current event and skip if it is the same as before
156 AliESDEvent *esd = fgCurrentEvent->GetRefESD();
157 if (esd == fgLastEvent) return;
158
159 // if event has changed, get run number and
160 // reinitialize the calib and time maker
161 // if this has changed
162 Int_t run = esd->GetRunNumber();
163 if (run != fgLastRun)
164 {
165 AliInfo("============================================================================================");
166 AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run));
167 AliInfo("============================================================================================");
168 fgLastRun = run;
169
170 AliCDBManager::Instance()->SetDefaultStorage("raw://");
171 AliCDBManager::Instance()->SetRun(fgLastRun);
172
173 if (fgTOFmaker) delete fgTOFmaker;
174 if (fgTOFcalib) delete fgTOFcalib;
175
176 fgTOFcalib = new AliTOFcalib();
177 if (fIsMC)
178 {
179 fgTOFcalib->SetRemoveMeanT0(kFALSE);
180 fgTOFcalib->SetCalibrateTOFsignal(kFALSE);
181 }
182 else
183 {
184 fgTOFcalib->SetRemoveMeanT0(kTRUE);
185 fgTOFcalib->SetCalibrateTOFsignal(kTRUE);
186 }
187 if (fgTOFcorrectTExp) fgTOFcalib->SetCorrectTExp(kTRUE);
188 fgTOFcalib->Init();
189
190 fgTOFmaker = new AliTOFT0maker(&fESDpid, fgTOFcalib);
191 fgTOFmaker->SetTimeResolution(fgTOFresolution);
192 }
193
194 // repeat the calibration and PID computations
195 /*if (fgTOFcalibrateESD)*/ fgTOFcalib->CalibrateESD(esd);
196 if (fgTOFtuneMC) fgTOFmaker->TuneForMC(esd);
197 if (fgTOFuseT0)
198 {
199 fgTOFmaker->ComputeT0TOF(esd);
200 fgTOFmaker->ApplyT0TOF(esd);
201 fESDpid.MakePID(esd, kFALSE, 0.);
202 }
203}
204
205//_________________________________________________________________________________________________
206Bool_t AliRsnCutPIDTOF::CheckESD(AliESDtrack *track)
207{
208//
209// Check TOF particle identification for ESD tracks.
210// Uses the AlifESDpid odata member.
211//
212
213 // require a minimum length to have meaningful match
214 if (track->GetIntegratedLength() < 350.) return kFALSE;
215
216 // setup TOF PID response
217 AliTOFPIDResponse &tofrsp = fESDpid.GetTOFResponse();
218
219 // get info for computation
220 Double_t momentum = track->P();
221 Double_t time = track->GetTOFsignal();
222 Double_t timeint[AliPID::kSPECIES];
223 tofrsp.GetStartTime(momentum);
224 track->GetIntegratedTimes(timeint);
225 Double_t timeDiff = time - timeint[(Int_t)fPIDtype];
226 Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPIDtype], AliPID::ParticleMass(fPIDtype));
227
228 // port values to standard AliRsnCut checker
229 fCutValueD = timeDiff / sigmaRef;
230 return OkRangeD();
231}
232
233//_________________________________________________________________________________________________
234Bool_t AliRsnCutPIDTOF::CheckAOD(AliAODTrack *track)
235{
236//
237// check TOF particle identification for AOD tracks.
238// Uses the AliAODpidUtil data member.
239//
240
241 fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(track, fPIDtype);
242 return OkRangeD();
243}
a909ffad 244
245//_________________________________________________________________________________________________
246void AliRsnCutPIDTOF::Print(const Option_t *) const
247{
248//
249// Print information on this cut
250//
251
252 AliInfo(Form("Cut name, type : %s %s", GetName(), ClassName()));
253 AliInfo(Form("TOF PID cut range (sigmas): %.3f %.3f", fMinD, fMaxD));
254 AliInfo(Form("Unmatched tracks are : %s", (fForceMatching ? "rejected" : "accepted")));
255}