]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnValue.cxx
Added macros for D0 analysis config with rsn package (Massimo)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnValue.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 "AliESDtrackCuts.h"
41 #include "AliESDpid.h"
42 #include "AliAODPid.h"
43 #include "AliCentrality.h"
44
45 #include "AliRsnEvent.h"
46 #include "AliRsnDaughter.h"
47 #include "AliRsnMother.h"
48 #include "AliRsnPairDef.h"
49 #include "AliRsnDaughterDef.h"
50
51 #include "AliRsnValue.h"
52
53 ClassImp(AliRsnValue)
54
55 //_____________________________________________________________________________
56 AliRsnValue::AliRsnValue(const char *name, AliRsnTarget::ETargetType type) :
57    AliRsnTarget(name, type),
58    fUseMCInfo(kFALSE),
59    fComputedValue(0.0),
60    fBinArray(0)
61 {
62 //
63 // Constructor.
64 // Initializes the binning to an empty array.
65 //
66 }
67
68 //_____________________________________________________________________________
69 AliRsnValue::AliRsnValue(const AliRsnValue &copy) :
70    AliRsnTarget(copy),
71    fUseMCInfo(copy.fUseMCInfo),
72    fComputedValue(copy.fComputedValue),
73    fBinArray(copy.fBinArray)
74 {
75 //
76 // Copy constructor.
77 // Duplicates the binning array and copies all settings.
78 //
79 }
80
81 //_____________________________________________________________________________
82 AliRsnValue &AliRsnValue::operator=(const AliRsnValue &copy)
83 {
84 //
85 // Assignment operator.
86 // Works like copy constructor.
87 //
88
89    AliRsnTarget::operator=(copy);
90    if (this == &copy)
91       return *this;
92    fUseMCInfo = copy.fUseMCInfo;
93    fComputedValue = copy.fComputedValue;
94    fBinArray = copy.fBinArray;
95
96    return (*this);
97 }
98
99 //_____________________________________________________________________________
100 void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
101 {
102 //
103 // Set binning for the axis in equally spaced bins
104 // where the number of bins, minimum and maximum are given.
105 //
106
107    if (!nbins) {
108       fBinArray.Set(0);
109       return;
110    }
111
112    fBinArray.Set(nbins + 1);
113
114    Double_t mymax = TMath::Max(min, max);
115    Double_t mymin = TMath::Min(min, max);
116
117    Int_t    k = 0;
118    Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
119
120    fBinArray[0] = mymin;
121    for (k = 1; k <= nbins; k++) fBinArray[k] = fBinArray[k - 1] + binSize;
122 }
123
124 //_____________________________________________________________________________
125 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
126 {
127 //
128 // Set binning for the axis in equally spaced bins
129 // where the bin size, minimum and maximum are given.
130 //
131
132    Double_t dblNbins = TMath::Abs(max - min) / step;
133    Int_t    intNbins = (Int_t) (dblNbins + 0.5);
134
135    SetBins(intNbins, min, max);
136 }
137
138 //_____________________________________________________________________________
139 void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
140 {
141 //
142 // Set binning for the axis in unequally spaced bins
143 // using the same way it is done in TAxis
144 //
145
146    if (!nbins) {
147       fBinArray.Set(0);
148       return;
149    }
150
151    Int_t i;
152    fBinArray.Set(nbins);
153    for (i = 0; i < nbins; i++) fBinArray[i] = array[i];
154 }
155
156 //_____________________________________________________________________________
157 Bool_t AliRsnValue::Eval(TObject *)
158 {
159 //
160 // Evaluation of the required value.
161 // Checks that the passed object is of the right type
162 // and if this check is successful, computes the required value.
163 // The output of the function tells if computing was successful,
164 // and the values must be taken with GetValue().
165 //
166
167    AliWarning("This method must be overridden by derived classes");
168    return kTRUE;
169 }
170
171 //_____________________________________________________________________________
172 void AliRsnValue::Print(Option_t *option) const
173 {
174 //
175 // Print informations about this object.
176 // If one specifies option "BINS" all bin limits are also printed.
177 //
178
179    AliInfo("=== VALUE INFO =================================================");
180    AliInfo(Form(" Name                  : %s", GetName()));
181    AliInfo(Form(" Current computed value: %f", fComputedValue));
182    if (!strcmp(option, "BINS")) {
183       Int_t i;
184       for (i = 0; i < fBinArray.GetSize(); i++) {
185          AliInfo(Form(" Bin limit #%03d        = %f", i, fBinArray[i]));
186       }
187    }
188 }