]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnValuePair.cxx
Adding macro to plot <Ncoll>
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnValuePair.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, pair, 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
49 #include "AliRsnEvent.h"
50 #include "AliRsnDaughter.h"
51 #include "AliRsnMother.h"
52 #include "AliRsnPairDef.h"
53 #include "AliRsnDaughterDef.h"
54
55 #include "AliRsnMiniPair.h"
56
57 #include "AliRsnValuePair.h"
58
59 ClassImp(AliRsnValuePair)
60
61 //_____________________________________________________________________________
62 AliRsnValuePair::AliRsnValuePair(const char *name, EType type) :
63    AliRsnValue(name, AliRsnTarget::kMother),
64    fType(type)
65 {
66 //
67 // Constructor
68 //
69 }
70
71 //_____________________________________________________________________________
72 AliRsnValuePair::AliRsnValuePair(const AliRsnValuePair &copy) :
73    AliRsnValue(copy),
74    fType(copy.fType)
75 {
76 //
77 // Copy constructor
78 //
79 }
80
81 //_____________________________________________________________________________
82 AliRsnValuePair &AliRsnValuePair::operator=(const AliRsnValuePair &copy)
83 {
84 //
85 // Assignment operator.
86 // Works like copy constructor.
87 //
88
89    AliRsnValue::operator=(copy);
90    if (this == &copy)
91       return *this;
92    fType = copy.fType;
93
94    return (*this);
95 }
96
97 //_____________________________________________________________________________
98 const char *AliRsnValuePair::GetTypeName() const
99 {
100 //
101 // This method returns a string to give a name to each possible
102 // computation value.
103 //
104
105    switch (fType) {
106       case kPt:           return "PairPt";
107       case kPz:           return "PairPz";
108       case kInvMass:      return "PairInvMass";
109       case kInvMassRes:   return "PairInvMassResolution";
110       case kEta:          return "PairEta";
111       case kMt:           return "PairMt";
112       case kY:            return "PairY";
113       case kPtRatio:      return "PairPtRatio";
114       case kDipAngle:     return "PairDipAngle";
115       case kCosThetaStar: return "PairCosThetaStar";
116       case kAngleLeading: return "PairAngleToLeading";
117       case kDCAproduct:   return "DaughterDCAProduct";
118       default:            return "Undefined";
119    }
120 }
121
122 //_____________________________________________________________________________
123 Bool_t AliRsnValuePair::Eval(TObject *object)
124 {
125 //
126 // Evaluation of the required value.
127 // In this implementation, fills the member 4-vectors with data
128 // coming from the object passed as argument, and then returns the value
129 //
130
131    // coherence check, which also casts object
132    // to AliRsnTarget data members and returns kFALSE
133    // in case the object is NULL
134    if (!TargetOK(object)) return kFALSE;
135
136    // set a reference to the mother momentum
137    TLorentzVector &sum   = fMother->Sum(fUseMCInfo);
138    TLorentzVector &ref   = fMother->Ref(fUseMCInfo);
139    TLorentzVector &p1    = fMother->GetDaughter(0)->P(fUseMCInfo);
140    TLorentzVector &p2    = fMother->GetDaughter(1)->P(fUseMCInfo);
141
142    
143
144    // utility variables
145    Bool_t success;
146
147    // compute value depending on types in the enumeration
148    // if the type does not match any available choice, or if
149    // the computation is not doable due to any problem
150    // (not initialized support object, wrong values, risk of floating point errors)
151    // the method returng kFALSE and sets the computed value to a meaningless number
152    switch (fType) {
153       case kPt:
154          fComputedValue = sum.Perp();
155          return kTRUE;
156       case kInvMass:
157          fComputedValue = sum.M();
158          return kTRUE;
159       case kEta:
160          fComputedValue = sum.Eta();
161          return kTRUE;
162       case kInvMassRes:
163          fComputedValue  = fMother->Sum(kFALSE).M() - fMother->Sum(kTRUE).M();
164          fComputedValue /= fMother->Sum(kTRUE).M();
165          return kTRUE;
166       case kMt:
167          fComputedValue = ref.Mt();
168          return kTRUE;
169       case kY:
170          fComputedValue = ref.Rapidity();
171          return kTRUE;
172       case kPtRatio:
173          fComputedValue  = TMath::Abs(p1.Perp() - p2.Perp());
174          fComputedValue /= TMath::Abs(p1.Perp() + p2.Perp());
175          return kTRUE;
176       case kDipAngle:
177          fComputedValue  = p1.Perp() * p2.Perp() + p1.Z() * p2.Z();
178          fComputedValue /= p1.Mag() * p2.Mag();
179          return kTRUE;
180       case kCosThetaStar:
181          fComputedValue = fMother->CosThetaStar();
182          return kTRUE;
183       case kAngleLeading:
184          fComputedValue = fMother->AngleToLeading(success);
185          return success;
186       case kDCAproduct:      
187         fComputedValue = fMother->DCAproduct();
188         return kTRUE;
189       default:
190          AliError(Form("[%s] Invalid value type for this computation", GetName()));
191          return kFALSE;
192    }
193 }