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