]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFResponseParams.cxx
free arrays before of return in PropagateBack
[u/mrichter/AliRoot.git] / TOF / AliTOFResponseParams.cxx
CommitLineData
5b4ed716 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// *
19// * this class defines the TOF object to be stored
20// * in OCDB in order to have TOF response correction
21// * and actual resolution
22// *
23// *
24// *
25// *
26
27#include "AliTOFResponseParams.h"
28#include "TGraph.h"
29
30ClassImp(AliTOFResponseParams)
31
32//_________________________________________________________
33
34AliTOFResponseParams::AliTOFResponseParams() :
35 TObject()
36{
37 /*
38 * default constructor
39 */
40
41 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
42 fNPoints[ipart] = 0;
43}
44
45//_________________________________________________________
46
47AliTOFResponseParams::AliTOFResponseParams(Int_t *nPoints) :
48 TObject()
49{
50 /*
51 * default constructor
52 */
53
54 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
55 fNPoints[ipart] = nPoints[ipart] < fgkMaxPoints ? nPoints[ipart] : fgkMaxPoints;
56}
57
58//_________________________________________________________
59
60AliTOFResponseParams::~AliTOFResponseParams()
61{
62 /*
63 * default destructor
64 */
65
66}
67
68//_________________________________________________________
69
70AliTOFResponseParams::AliTOFResponseParams(const AliTOFResponseParams &source) :
71 TObject(source)
72{
73 /*
74 * copy constructor
75 */
76
77 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++) {
78 fNPoints[ipart] = source.fNPoints[ipart];
79 for (Int_t ipoint = 0; ipoint < fNPoints[ipart]; ipoint++) {
80 fP[ipart][ipoint] = source.fP[ipart][ipoint];
81 fTExpCorr[ipart][ipoint] = source.fTExpCorr[ipart][ipoint];
82 }
83 }
84
85}
86
87//_________________________________________________________
88
89AliTOFResponseParams &
90AliTOFResponseParams::operator=(const AliTOFResponseParams &source)
91{
92 /*
93 * operator=
94 */
95
96 if (this == &source) return *this;
97 TObject::operator=(source);
98
99 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++) {
100 fNPoints[ipart] = source.fNPoints[ipart];
101 for (Int_t ipoint = 0; ipoint < fNPoints[ipart]; ipoint++) {
102 fP[ipart][ipoint] = source.fP[ipart][ipoint];
103 fTExpCorr[ipart][ipoint] = source.fTExpCorr[ipart][ipoint];
104 }
105 }
106
107 return *this;
108}
109
110//_________________________________________________________
111
112TGraph *
113AliTOFResponseParams::DrawGraph(Int_t ipart, Option_t* option)
114{
115 /*
116 * draw
117 */
118
119 if (ipart >= AliPID::kSPECIES) return NULL;
120 if (fNPoints[ipart] == 0) return NULL;
121
122 TGraph *graph = new TGraph(fNPoints[ipart], fP[ipart], fTExpCorr[ipart]);
123 graph->Draw(option);
124 return graph;
125}
126
127//_________________________________________________________
128
129Double_t
130AliTOFResponseParams::EvalTExpCorr(Int_t ipart, Double_t p)
131{
132 /*
133 * eval corr
134 */
135
136 if (ipart >= AliPID::kSPECIES) return 0.;
137 if (fNPoints[ipart] == 0) return 0.;
138 if (p < fP[ipart][0]) return fTExpCorr[ipart][0];
139 if (p >= fP[ipart][fNPoints[ipart] - 1]) return fTExpCorr[ipart][fNPoints[ipart] - 1];
140
141 Int_t ipoint;
142 for (ipoint = 0; ipoint < fNPoints[ipart] - 1; ipoint++)
143 if (p >= fP[ipart][ipoint] && p < fP[ipart][ipoint + 1]) break;
144 Double_t coeff = (fTExpCorr[ipart][ipoint + 1] - fTExpCorr[ipart][ipoint]) / (fP[ipart][ipoint + 1] - fP[ipart][ipoint]);
145 Double_t corr = fTExpCorr[ipart][ipoint] + coeff * (p - fP[ipart][ipoint]);
146 return corr;
147}