]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnPairDef.cxx
Package upgrade.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairDef.cxx
CommitLineData
06351446 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// ALIRSNPAIRDEF
18//
19// Definition of working parameters for a specific resonance analysis.
20// This object allows to define the particles to be used for computation
21// with respect to charge and PID type (included 'kUnknown'), and
22// the binning of the output histogram.
23// These definitions can then be used by many AliRsnPair objects
24// which can operate on the same track samples under different conditions.
25//
26// author: A. Pulvirenti
27// email : alberto.pulvirenti@ct.infn.it
28//
29
30#include <Riostream.h>
31
32#include "AliLog.h"
33#include "AliRsnDaughter.h"
34#include "AliRsnPairDef.h"
35
36ClassImp(AliRsnPairDef)
37
38//_____________________________________________________________________________
39AliRsnPairDef::AliRsnPairDef() :
40 TObject(),
41 fMotherPDG(0),
42 fNBins(0),
43 fMin(0.0),
44 fMax(0.0)
45{
46//
47// Empty constructor.
48// Initializes the data members to default values:
49// - no definition of particles in the pair;
50// - histogram binning undefined.
51// When using this constructor, all analysis elements (particles, histogram)
52// must be defined before starting event processing.
53//
54
55 Int_t i;
56 for (i = 0; i < 2; i++) {
57 fCharge[i] = '0';
58 fMass[i] = 0.0;
59 fType[i] = AliRsnPID::kUnknown;
60 }
61}
62
63//_____________________________________________________________________________
64AliRsnPairDef::AliRsnPairDef
65(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2,
66 Int_t nbins, Double_t min, Double_t max) :
67 TObject(),
68 fMotherPDG(0),
69 fNBins(0),
70 fMin(0.0),
71 fMax(0.0)
72{
73//
74// Constructor with arguments.
75// This constructor allows to define all the working parameters.
76//
77
78 SetPair(sign1, type1, sign2, type2);
79 SetBins(nbins, min, max);
80}
81
82//_____________________________________________________________________________
83AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
84 TObject(copy),
85 fMotherPDG(copy.fMotherPDG),
86 fNBins(0),
87 fMin(0.0),
88 fMax(0.0)
89{
90//
91// Copy constructor with standard behavior
92//
93
94 SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
95 SetBins(copy.fNBins, copy.fMin, copy.fMax);
96}
97
98//_____________________________________________________________________________
99const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
100{
101//
102// Assignment operator with standard behavior.
103//
104
105 fMotherPDG = copy.fMotherPDG;
106 SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
107 SetBins(copy.fNBins, copy.fMin, copy.fMax);
108
109 return (*this);
110}
111
112//_____________________________________________________________________________
113Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType type)
114{
115//
116// Set one element of the pair
117// and returns warnings if the type is not valid.
118//
119 if (i < 0 || i > 1) {
120 AliError("Index out of range");
121 return kFALSE;
122 }
123 if (charge != '+' && charge != '-') {
124 AliError(Form("Character '%c' not recognized as charge sign"));
125 return kFALSE;
126 }
127 if (type < AliRsnPID::kElectron && type > AliRsnPID::kUnknown) {
128 AliError("Type index out of enumeration range");
129 return kFALSE;
130 }
131 fCharge[i] = charge;
132 fType[i] = type;
133 fMass[i] = AliRsnPID::ParticleMass(type);
134 return kTRUE;
135}
136
137//_____________________________________________________________________________
138Bool_t AliRsnPairDef::SetPair
139(Char_t charge1, AliRsnPID::EType type1, Char_t charge2, AliRsnPID::EType type2)
140{
141//
142// Set both elements of the pair,
143// returning logical AND of check for each one.
144//
145
146 Bool_t part1 = SetPairElement(0, charge1, type1);
147 Bool_t part2 = SetPairElement(1, charge2, type2);
148 return (part1 && part2);
149}
150
151//_____________________________________________________________________________
152void AliRsnPairDef::CheckEdges()
153{
154//
155// Checks that histogram edges are appropriate,
156// otherwise swaps them.
157//
158 if (fMin > fMax) {
159 AliWarning(Form("min = %f -- max = %f --> swapping", fMin, fMax));
160 Double_t temp = fMin;
161 fMin = fMax;
162 fMax = temp;
163 }
164}
165
166//_____________________________________________________________________________
167Double_t AliRsnPairDef::ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1)
168{
169//
170// Compute a weight for filling the histograms:
171// probability of first track to be identified as 'type[0]' times
172// the probability of second track to be identified as 'type[1]',
173// according to the order of appearance in argument list.
174//
175
176 Double_t prob0 = d0->PIDProb()[fType[0]];
177 Double_t prob1 = d1->PIDProb()[fType[1]];
178
179 return prob0*prob1;
180}