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 **************************************************************************/
19 // * this class defines the TOF object to be stored
20 // * in OCDB in order to have TOF response correction
21 // * and actual resolution
27 #include "AliTOFResponseParams.h"
30 ClassImp(AliTOFResponseParams)
32 //_________________________________________________________
34 AliTOFResponseParams::AliTOFResponseParams() :
41 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
45 //_________________________________________________________
47 AliTOFResponseParams::AliTOFResponseParams(Int_t *nPoints) :
54 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
55 fNPoints[ipart] = nPoints[ipart] < fgkMaxPoints ? nPoints[ipart] : fgkMaxPoints;
58 //_________________________________________________________
60 AliTOFResponseParams::~AliTOFResponseParams()
68 //_________________________________________________________
70 AliTOFResponseParams::AliTOFResponseParams(const AliTOFResponseParams &source) :
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];
87 //_________________________________________________________
89 AliTOFResponseParams &
90 AliTOFResponseParams::operator=(const AliTOFResponseParams &source)
96 if (this == &source) return *this;
97 TObject::operator=(source);
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];
110 //_________________________________________________________
113 AliTOFResponseParams::DrawGraph(Int_t ipart, Option_t* option)
119 if (ipart >= AliPID::kSPECIES) return NULL;
120 if (fNPoints[ipart] == 0) return NULL;
122 TGraph *graph = new TGraph(fNPoints[ipart], fP[ipart], fTExpCorr[ipart]);
127 //_________________________________________________________
130 AliTOFResponseParams::EvalTExpCorr(Int_t ipart, Double_t p)
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];
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]);