1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////////
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
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
35 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
36 // M. Vala (martin.vala@cern.ch)
38 ////////////////////////////////////////////////////////////////////////////////
40 #include "AliESDtrackCuts.h"
41 #include "AliESDpid.h"
42 #include "AliAODPid.h"
43 #include "AliCentrality.h"
45 #include "AliRsnEvent.h"
46 #include "AliRsnDaughter.h"
47 #include "AliRsnMother.h"
48 #include "AliRsnPairDef.h"
49 #include "AliRsnDaughterDef.h"
51 #include "AliRsnValue.h"
55 //_____________________________________________________________________________
56 AliRsnValue::AliRsnValue() :
62 // Default constructor without arguments.
63 // Initialize data members to meaningless values.
64 // This method is provided for ROOT streaming,
65 // but should never be used directly by a user.
69 //_____________________________________________________________________________
70 AliRsnValue::AliRsnValue
71 (const char *name, Int_t nbins, Double_t min, Double_t max) :
77 // Main constructor (version 1).
78 // This constructor defines in meaningful way all data members,
79 // and defined a fixed binnings, subdividing the specified interval
80 // into that many bins as specified in the integer argument.
82 // This method is also the entry point for all instances
83 // of this class which don't need to do binning (e.g.: TNtuple inputs),
84 // since arguments 3 to 5 have default values which don't create any
85 // binning array, in order not to allocate memory when this is useless.
88 SetBins(nbins, min, max);
91 //_____________________________________________________________________________
92 AliRsnValue::AliRsnValue
93 (const char *name, Double_t min, Double_t max, Double_t step) :
99 // Main constructor (version 2).
100 // This constructor defines in meaningful way all data members
101 // and creates enough equal bins of the specified size to cover
102 // the required interval.
105 SetBins(min, max, step);
108 //_____________________________________________________________________________
109 AliRsnValue::AliRsnValue
110 (const char *name, Int_t nbins, Double_t *array) :
116 // Main constructor (version 3).
117 // This constructor defines in meaningful way all data members
118 // and creates a set of variable bins delimited by the passed array.
121 SetBins(nbins, array);
124 //_____________________________________________________________________________
125 AliRsnValue::AliRsnValue(const AliRsnValue& copy) :
127 fComputedValue(copy.fComputedValue),
128 fBinArray(copy.fBinArray)
132 // Duplicates the binning array and copies all settings.
136 //_____________________________________________________________________________
137 AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy)
140 // Assignment operator.
141 // Works like copy constructor.
144 AliRsnTarget::operator=(copy);
146 fComputedValue = copy.fComputedValue;
147 fBinArray = copy.fBinArray;
152 //_____________________________________________________________________________
153 void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
156 // Set binning for the axis in equally spaced bins
157 // where the number of bins, minimum and maximum are given.
165 fBinArray.Set(nbins + 1);
167 Double_t mymax = TMath::Max(min, max);
168 Double_t mymin = TMath::Min(min, max);
171 Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
173 fBinArray[0] = mymin;
174 for (k = 1; k <= nbins; k++) fBinArray[k] = fBinArray[k - 1] + binSize;
177 //_____________________________________________________________________________
178 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
181 // Set binning for the axis in equally spaced bins
182 // where the bin size, minimum and maximum are given.
185 Double_t dblNbins = TMath::Abs(max - min) / step;
186 Int_t intNbins = ((Int_t)dblNbins) + 1;
188 SetBins(intNbins, min, max);
191 //_____________________________________________________________________________
192 void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
195 // Set binning for the axis in unequally spaced bins
196 // using the same way it is done in TAxis
205 fBinArray.Set(nbins);
206 for (i = 0; i < nbins; i++) fBinArray[i] = array[i];
209 //_____________________________________________________________________________
210 Bool_t AliRsnValue::Eval(TObject *, Bool_t)
213 // Evaluation of the required value.
214 // Checks that the passed object is of the right type
215 // and if this check is successful, computes the required value.
216 // The output of the function tells if computing was successful,
217 // and the values must be taken with GetValue().
220 AliWarning("This method must be overridden by derived classes");
224 //_____________________________________________________________________________
225 void AliRsnValue::Print(Option_t *option) const
228 // Print informations about this object
231 AliInfo("=== VALUE INFO =================================================");
232 AliInfo(Form(" Name : %s", GetName()));
233 AliInfo(Form(" Current computed value: %f", fComputedValue));
234 if (!strcmp(option, "BINS")) {
236 for (i = 0; i < fBinArray.GetSize(); i++) {
237 AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i]));