]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnValueDaughter.cxx
Updated macro for K* pA analysis
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnValueDaughter.cxx
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 ////////////////////////////////////////////////////////////////////////////////
17 //
18 //  This class contains all code which is used to compute any of the values
19 //  which can be of interest within a resonance analysis. Besides the obvious
20 //  invariant mass, it allows to compute other utility values on all possible
21 //  targets, in order to allow a wide spectrum of binning and checks.
22 //  When needed, this object can also define a binning in the variable which
23 //  it is required to compute, which is used for initializing axes of output
24 //  histograms (see AliRsnFunction).
25 //  The value computation requires this object to be passed the object whose
26 //  informations will be used. This object can be of any allowed input type
27 //  (track, Daughter, event), then this class must inherit from AliRsnTarget.
28 //  Then, when value computation is attempted, a check on target type is done
29 //  and computation is successful only if expected target matches that of the
30 //  passed object.
31 //  In some cases, the value computation can require a support external object,
32 //  which must then be passed to this class. It can be of any type inheriting
33 //  from TObject.
34 //
35 //  authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
36 //           M. Vala (martin.vala@cern.ch)
37 //
38 ////////////////////////////////////////////////////////////////////////////////
39
40 #include <Riostream.h>
41 #include "AliVVertex.h"
42 #include "AliMultiplicity.h"
43 #include "AliESDtrackCuts.h"
44 #include "AliESDpid.h"
45 #include "AliAODPid.h"
46 #include "AliCentrality.h"
47 #include "AliESDUtils.h"
48 #include "AliPIDResponse.h"
49
50 #include "AliRsnEvent.h"
51 #include "AliRsnDaughter.h"
52 #include "AliRsnMother.h"
53 #include "AliRsnDaughterDef.h"
54 #include "AliRsnDaughterDef.h"
55
56 #include "AliRsnValueDaughter.h"
57
58 ClassImp(AliRsnValueDaughter)
59
60 //_____________________________________________________________________________
61 AliRsnValueDaughter::AliRsnValueDaughter(const char *name, EType type) :
62    AliRsnValue(name, AliRsnTarget::kDaughter),
63    fType(type)
64 {
65 //
66 // Constructor
67 //
68 }
69
70 //_____________________________________________________________________________
71 AliRsnValueDaughter::AliRsnValueDaughter(const AliRsnValueDaughter &copy) :
72    AliRsnValue(copy),
73    fType(copy.fType)
74 {
75 //
76 // Copy constructor
77 //
78 }
79
80 //_____________________________________________________________________________
81 AliRsnValueDaughter &AliRsnValueDaughter::operator=(const AliRsnValueDaughter &copy)
82 {
83 //
84 // Assignment operator.
85 // Works like copy constructor.
86 //
87
88    AliRsnValue::operator=(copy);
89    if (this == &copy)
90       return *this;
91    fType = copy.fType;
92
93    return (*this);
94 }
95
96 //_____________________________________________________________________________
97 const char *AliRsnValueDaughter::GetTypeName() const
98 {
99 //
100 // This method returns a string to give a name to each possible
101 // computation value.
102 //
103
104    switch (fType) {
105       case kP:                         return "SingleTrackPtot";
106       case kPt:                        return "SingleTrackPt";
107       case kPtpc:                      return "SingleTrackPtpc";
108       case kEta:                       return "SingleTrackEta";
109       case kMass:                      return "SingleTrackMass";
110       case kITSsignal:                 return "SingleTrackITSsignal";
111       case kTPCsignal:                  return "SingleTrackTPCsignal";
112       case kTOFsignal:                  return "SingleTrackTOFsignal";
113       case kTPCnsigmaPi:                return "SingleTrackTPCnsigmaPion";
114       case kTPCnsigmaK:                 return "SingleTrackTPCnsigmaKaon";
115       case kTPCnsigmaP:                 return "SingleTrackTPCnsigmaProton";
116       case kTOFnsigmaPi:                return "SingleTrackTOFnsigmaPion";
117       case kTOFnsigmaK:                 return "SingleTrackTOFnsigmaKaon";
118       case kTOFnsigmaP:                 return "SingleTrackTOFnsigmaProton";
119       case kCharge:                     return "SingleTrackCharge";
120       case kPhi:                        return "SingleTrackPhi";
121       case kPhiOuterTPC:                return "SingleTrackPhiOuterTPC";
122       case kV0DCA:                      return "V0DCAToPrimaryVertex";
123       case kDaughterDCA:                return "V0DaughterDCA";
124       case kCosPointAng:                return "V0CosineOfPointingAngle";
125       case kLambdaProtonPIDCut:         return "V0LambdaProtonNsigma";
126       case kAntiLambdaAntiProtonPIDCut: return "V0AntiLambdaAntiProtonNsigma";
127       case kLambdaPionPIDCut:           return "V0LambdaPionNsigma";
128       case kAntiLambdaAntiPionPIDCut:   return "V0AntiLambdaPionNsigma";
129       default:                          return "Undefined";
130    }
131 }
132
133 //_____________________________________________________________________________
134 Bool_t AliRsnValueDaughter::Eval(TObject *object)
135 {
136 //
137 // Evaluation of the required value.
138 // Checks that the passed object is of the right type
139 // and if this check is successful, computes the required value.
140 // The output of the function tells if computing was successful,
141 // and the values must be taken with GetValue().
142 //
143
144    // coherence check, which also casts object
145    // to AliRsnTarget data members and returns kFALSE
146    // in case the object is NULL
147    if (!TargetOK(object)) return kFALSE;
148
149    // set a reference to the mother momentum
150    AliVParticle   *ref   = fDaughter->GetRef();
151    AliVParticle   *refMC = fDaughter->GetRefMC();
152    AliVTrack      *track = fDaughter->Ref2Vtrack();
153    AliESDv0       *v0esd = fDaughter->Ref2ESDv0();
154    AliAODv0       *v0aod = fDaughter->Ref2AODv0();
155    AliESDEvent    *lESDEvent = fEvent->GetRefESD();
156    
157    Double_t xPrimaryVertex = -999.9;
158    Double_t yPrimaryVertex = -999.9;
159    Double_t zPrimaryVertex = -999.9;
160    
161    if(lESDEvent){
162    
163    xPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetX();
164    yPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetY();
165    zPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetZ();
166    
167    }
168    
169    if (fUseMCInfo && !refMC) {
170       AliError("No MC");
171       return kFALSE;
172    }
173    if (!fUseMCInfo && !ref) {
174       AliError("No DATA");
175       return kFALSE;
176    }
177
178    // compute value depending on types in the enumeration
179    // if the type does not match any available choice, or if
180    // the computation is not doable due to any problem
181    // (not initialized support object, wrong values, risk of floating point errors)
182    // the method returng kFALSE and sets the computed value to a meaningless number
183    switch (fType) {
184       case kP:
185          fComputedValue = (fUseMCInfo ? refMC->P() : ref->P());
186          return kTRUE;
187       case kPt:
188          fComputedValue = (fUseMCInfo ? refMC->Pt() : ref->Pt());
189          return kTRUE;
190       case kEta:
191          fComputedValue = (fUseMCInfo ? refMC->Eta() : ref->Eta());
192          return kTRUE;
193       case kMass:
194          fComputedValue = (fUseMCInfo ? refMC->M() : ref->M());
195          return kTRUE;
196       case kPtpc:
197          if (track) {
198             fComputedValue = track->GetTPCmomentum();
199             return kTRUE;
200          } else {
201             AliWarning("Cannot get TPC momentum for non-track object");
202             fComputedValue = 0.0;
203             return kFALSE;
204          }
205       case kITSsignal:
206          if (track) {
207             fComputedValue = track->GetITSsignal();
208             return kTRUE;
209          } else {
210             AliWarning("Cannot get ITS signal for non-track object");
211             fComputedValue = 0.0;
212             return kFALSE;
213          }
214       case kTPCsignal:
215          if (track) {
216             fComputedValue = track->GetTPCsignal();
217             return kTRUE;
218          } else {
219             AliWarning("Cannot get TPC signal for non-track object");
220             fComputedValue = 0.0;
221             return kFALSE;
222          }
223       case kTOFsignal:
224          if (track) {
225             fComputedValue = track->GetTOFsignal();
226             return kTRUE;
227          } else {
228             AliWarning("Cannot get TOF signal for non-track object");
229             fComputedValue = 0.0;
230             return kFALSE;
231          }
232       case kTPCnsigmaPi:
233          if (track) {
234             AliPIDResponse *pid = fEvent->GetPIDResponse();
235             fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kPion);
236             return kTRUE;
237          } else {
238             AliWarning("Cannot get TOF signal for non-track object");
239             fComputedValue = 0.0;
240             return kFALSE;
241          }
242       case kTPCnsigmaK:
243          if (track) {
244             AliPIDResponse *pid = fEvent->GetPIDResponse();
245             fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kKaon);
246             return kTRUE;
247          } else {
248             AliWarning("Cannot get TOF signal for non-track object");
249             fComputedValue = 0.0;
250             return kFALSE;
251          }
252       case kTPCnsigmaP:
253          if (track) {
254             AliPIDResponse *pid = fEvent->GetPIDResponse();
255             fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kProton);
256             return kTRUE;
257          } else {
258             AliWarning("Cannot get TOF signal for non-track object");
259             fComputedValue = 0.0;
260             return kFALSE;
261          }
262       case kTOFnsigmaPi:
263          if (track) {
264             AliPIDResponse *pid = fEvent->GetPIDResponse();
265             fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kPion);
266             return kTRUE;
267          } else {
268             AliWarning("Cannot get TOF signal for non-track object");
269             fComputedValue = 0.0;
270             return kFALSE;
271          }
272       case kTOFnsigmaK:
273          if (track) {
274             AliPIDResponse *pid = fEvent->GetPIDResponse();
275             fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kKaon);
276             return kTRUE;
277          } else {
278             AliWarning("Cannot get TOF signal for non-track object");
279             fComputedValue = 0.0;
280             return kFALSE;
281          }
282       case kTOFnsigmaP:
283          if (track) {
284             AliPIDResponse *pid = fEvent->GetPIDResponse();
285             fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kProton);
286             return kTRUE;
287          } else {
288             AliWarning("Cannot get TOF signal for non-track object");
289             fComputedValue = 0.0;
290             return kFALSE;
291          }
292       case kNITSclusters:
293          if (track) {
294             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
295             if (trackESD) {
296                fComputedValue =  trackESD->GetITSclusters(0);
297             } else {
298                fComputedValue =  ((AliAODTrack *)track)->GetITSNcls();
299             }
300             return kTRUE;
301          } else {
302             AliWarning("Cannot get n ITS clusters for non-track object");
303             fComputedValue = 0.0;
304             return kFALSE;
305          }
306       case kNTPCclusters:
307          if (track) {
308             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
309             if (trackESD) {
310                fComputedValue =  trackESD->GetTPCclusters(0);
311             } else {
312                fComputedValue =  ((AliAODTrack *)track)->GetTPCNcls();
313             }
314             return kTRUE;
315          } else {
316             AliWarning("Cannot get n TPC clusters for non-track object");
317             fComputedValue = 0.0;
318             return kFALSE;
319          }
320       case kITSchi2:
321          if (track) {
322             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
323             if (trackESD) {
324                UShort_t nClustersITS = trackESD->GetITSclusters(0);
325                fComputedValue =  trackESD->GetITSchi2()/Float_t(nClustersITS);
326             } else {
327                fComputedValue = ((AliAODTrack *)track)->Chi2perNDF();
328             }
329             return kTRUE;
330          } else {
331             AliWarning("Cannot get ITS chi^2 for non-track object");
332             fComputedValue = 0.0;
333             return kFALSE;
334          }
335       case kTPCchi2:
336          if (track) {
337             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
338             if (trackESD) {
339                UShort_t nClustersTPC = trackESD->GetTPCclusters(0);
340                fComputedValue =  trackESD->GetTPCchi2()/Float_t(nClustersTPC);
341             } else {
342                fComputedValue = ((AliAODTrack *)track)->Chi2perNDF();
343             }
344             return kTRUE;
345          } else {
346             AliWarning("Cannot get TPC chi^2 for non-track object");
347             fComputedValue = 0.0;
348             return kFALSE;
349          }
350       case kDCAXY:
351          if (track) {
352             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
353             if (trackESD) {
354                Float_t b[2], bCov[3];
355                trackESD->GetImpactParameters(b, bCov);
356                fComputedValue =  b[0];
357             } else {
358                Double_t b[2]= {-999,-999}, cov[3];
359                AliAODVertex *vertex = fEvent->GetRefAOD()->GetPrimaryVertex();
360                if(vertex) {
361                   track->PropagateToDCA(vertex, fEvent->GetRefAOD()->GetMagneticField(),kVeryBig, b, cov);
362                   fComputedValue = b[0];
363                } else {
364                   fComputedValue = -999;
365                }
366             }
367             return kTRUE;
368          } else {
369             AliWarning("Cannot get TPC chi^2 for non-track object");
370             fComputedValue = 0.0;
371             return kFALSE;
372          }
373       case kDCAZ:
374          if (track) {
375             AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
376             if (trackESD) {
377                Float_t b[2], bCov[3];
378                trackESD->GetImpactParameters(b, bCov);
379                fComputedValue =  b[1];
380             } else {
381                Double_t b[2]= {-999,-999}, cov[3];
382                AliAODVertex *vertex = fEvent->GetRefAOD()->GetPrimaryVertex();
383                if(vertex) {
384                   track->PropagateToDCA(vertex, fEvent->GetRefAOD()->GetMagneticField(),kVeryBig, b, cov);
385                   fComputedValue = b[1];
386                } else {
387                   fComputedValue = -999;
388                }
389
390             }
391             return kTRUE;
392          } else {
393             AliWarning("Cannot get TPC chi^2 for non-track object");
394             fComputedValue = 0.0;
395             return kFALSE;
396          }
397
398      case kCharge:
399          fComputedValue = (fUseMCInfo ? refMC->Charge() : ref->Charge());
400          return kTRUE;
401    
402       case kPhi:         
403         fComputedValue = (fUseMCInfo ? (refMC->Phi()*TMath::RadToDeg()) : (ref->Phi()*TMath::RadToDeg()));      
404         return kTRUE;
405
406       case kPhiOuterTPC:    
407         if (track) {
408           Double_t pos[3]={0.,0.,0.};
409           Double_t phiOut = -999.0;
410           Double_t radius = 278.;//TPC outer (vessel) = 278 cm, TOF radius (active surf.) = 378 cm;  ref. PPR.1
411           AliExternalTrackParam etp; //thanks to Andrea and Cristina
412           etp.CopyFromVTrack(track);
413           if(etp.GetXYZAt(radius, 5., pos)){
414             phiOut=TMath::ATan2(pos[1],pos[0])*TMath::RadToDeg();
415             if (phiOut<0) phiOut+= (2*TMath::Pi()*TMath::RadToDeg());
416           }
417           fComputedValue = phiOut;      
418         } else {
419           AliWarning("Cannot get phi at outer TPC radius for non-track object");
420           fComputedValue = -99.0;
421           return kFALSE;
422         }
423         return kTRUE;
424
425       case kV0DCA:
426          if(v0esd) {
427            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
428            fComputedValue = v0ESD->GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
429            return kTRUE;
430          }
431          if(v0aod) {
432            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
433            fComputedValue = v0AOD->DcaV0ToPrimVertex();
434            return kTRUE;
435          }
436          else {
437           fComputedValue = -999;
438           return kFALSE;
439          }               
440       case kDaughterDCA:
441          if(v0esd) {
442            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
443            fComputedValue = v0ESD->GetDcaV0Daughters();
444            return kTRUE;
445          }
446          if(v0aod) {
447            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
448            fComputedValue = v0AOD->DcaV0Daughters();
449            return kTRUE;
450          }
451          else {
452           fComputedValue = -999;
453           return kFALSE;
454          }
455       case kCosPointAng:
456          if(v0esd) {
457            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
458            fComputedValue = v0ESD->GetV0CosineOfPointingAngle();
459            return kTRUE;         
460          }
461          if(v0aod) {
462            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
463            fComputedValue = TMath::Cos(v0AOD->OpenAngleV0());
464            return kTRUE;
465          }
466          else {
467           fComputedValue = -999;
468           return kFALSE;
469          }
470       case kLambdaProtonPIDCut:
471          if(v0esd && lESDEvent) {
472            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
473            // retrieve the V0 daughters
474            UInt_t lIdxPos      = (UInt_t) TMath::Abs(v0ESD->GetPindex());
475            AliESDtrack *pTrack = lESDEvent->GetTrack(lIdxPos);
476            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
477            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, AliPID::kProton));
478            return kTRUE;         
479          }
480          if(v0aod) {
481            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
482            AliAODTrack *pTrack = (AliAODTrack *) (v0AOD->GetSecondaryVtx()->GetDaughter(0));
483            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
484            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, AliPID::kProton));
485            return kTRUE;
486          }
487          else {
488           fComputedValue = -999;
489           return kFALSE;
490          }
491        case kAntiLambdaAntiProtonPIDCut:
492          if(v0esd && lESDEvent) {
493            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
494            // retrieve the V0 daughters
495            UInt_t lIdxNeg      = (UInt_t) TMath::Abs(v0ESD->GetNindex());
496            AliESDtrack *nTrack = lESDEvent->GetTrack(lIdxNeg);
497            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
498            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, AliPID::kProton));
499            return kTRUE;         
500          }
501          if(v0aod) {
502            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
503            AliAODTrack *nTrack = (AliAODTrack *) (v0AOD->GetSecondaryVtx()->GetDaughter(1));
504            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
505            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, AliPID::kProton));
506            return kTRUE;
507          }
508          else {
509           fComputedValue = -999;
510           return kFALSE;
511          }
512       case kLambdaPionPIDCut:
513          if(v0esd && lESDEvent) {
514            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
515            // retrieve the V0 daughters
516            UInt_t lIdxNeg      = (UInt_t) TMath::Abs(v0ESD->GetNindex());
517            AliESDtrack *nTrack = lESDEvent->GetTrack(lIdxNeg);
518            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
519            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, AliPID::kPion));
520            return kTRUE;         
521          }
522          if(v0aod) {
523            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
524            AliAODTrack *nTrack = (AliAODTrack *) (v0AOD->GetSecondaryVtx()->GetDaughter(1));
525            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
526            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, AliPID::kPion));
527            return kTRUE;
528          }
529          else {
530           fComputedValue = -999;
531           return kFALSE;
532          }
533        case kAntiLambdaAntiPionPIDCut:
534          if(v0esd && lESDEvent) {
535            AliESDv0 *v0ESD = dynamic_cast<AliESDv0 *>(v0esd);
536            // retrieve the V0 daughters
537            UInt_t lIdxPos      = (UInt_t) TMath::Abs(v0ESD->GetPindex());
538            AliESDtrack *pTrack = lESDEvent->GetTrack(lIdxPos);
539            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
540            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, AliPID::kPion));
541            return kTRUE;         
542          }
543          if(v0aod) {
544            AliAODv0 *v0AOD = dynamic_cast<AliAODv0 *>(v0aod);
545            AliAODTrack *pTrack = (AliAODTrack *) (v0AOD->GetSecondaryVtx()->GetDaughter(0));
546            AliPIDResponse *pid = fEvent->GetPIDResponse(); 
547            fComputedValue = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, AliPID::kPion));
548            return kTRUE;
549          }
550          else {
551           fComputedValue = -999;
552           return kFALSE;
553          }
554          
555       
556       default:
557          AliError(Form("[%s] Invalid value type for this computation", GetName()));
558          return kFALSE;
559    }
560 }