]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0CalibData.cxx
updated for e-h analysis
[u/mrichter/AliRoot.git] / T0 / AliT0CalibData.cxx
CommitLineData
dc7ca31d 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
94249139 20// class for T0 calibration TM--AM_6-02-2006 //
dc7ca31d 21// //
22///////////////////////////////////////////////////////////////////////////////
23
dc7ca31d 24#include "AliT0CalibData.h"
e0bba6cc 25#include "AliT0LookUpValue.h"
94249139 26#include "AliT0LookUpKey.h"
dc7ca31d 27#include "AliLog.h"
dc7ca31d 28
7d95281b 29#include <Riostream.h>
dc7ca31d 30
94249139 31//#include <string>
dc7ca31d 32
cdf48647 33using std::ifstream;
dc7ca31d 34ClassImp(AliT0CalibData)
35
36//________________________________________________________________
29d3e0eb 37 AliT0CalibData::AliT0CalibData(): TNamed(),
29d3e0eb 38 fLookup(0),
39 fNumberOfTRMs(0)
dc7ca31d 40
41{
42 //
43}
44
45//________________________________________________________________
94c27e4f 46AliT0CalibData::AliT0CalibData(const char* name):TNamed(),
94c27e4f 47 fLookup(0),
48 fNumberOfTRMs(0)
dc7ca31d 49{
50 TString namst = "Calib_";
51 namst += name;
52 SetName(namst.Data());
53 SetTitle(namst.Data());
54
55}
56
57//________________________________________________________________
58AliT0CalibData::AliT0CalibData(const AliT0CalibData& calibda) :
94c27e4f 59 TNamed(calibda),
94c27e4f 60 fLookup(0),
61 fNumberOfTRMs(0)
62
dc7ca31d 63{
64// copy constructor
65 SetName(calibda.GetName());
66 SetTitle(calibda.GetName());
67
68
69}
70
71//________________________________________________________________
72AliT0CalibData &AliT0CalibData::operator =(const AliT0CalibData& calibda)
73{
74// assignment operator
75 SetName(calibda.GetName());
76 SetTitle(calibda.GetName());
77
78 return *this;
79}
80
81//________________________________________________________________
82AliT0CalibData::~AliT0CalibData()
83{
e0bba6cc 84 //
dc7ca31d 85}
e0bba6cc 86//________________________________________________________________
87void AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChannel) const
88{
94249139 89 // print lookup table
90
924bc12a 91 AliT0LookUpKey* lookkey; //= new AliT0LookUpKey();
c41ceaac 92 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
94249139 93 printf("Number Of TRMs in setup %i\n",GetNumberOfTRMs());
5325480c 94
256d4943 95 iTRM=0; iTDC=0; Int_t chain=0; iChannel=0;
96
97 for (Int_t ik=0; ik<105; ik++){
98 lookvalue->SetTRM(iTRM);
99 lookvalue->SetTDC(iTDC);
100 lookvalue->SetChain(chain);
101 lookvalue->SetChannel(iChannel);
102
103 if (iChannel<6) iChannel +=2;
104 else {iChannel = 0; iTDC++;}
105 if(ik==57) { iTDC=0; iChannel=0; iTRM=1;}
106
107 printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i %i\n",iTRM, iTDC,chain, iChannel);
108 lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
256d4943 109 // TString name= lookkey->GetChannelName();
110 // cout<<name.Data()<<endl;
111 if (lookkey)
112 {
113 TString name= lookkey->GetChannelName();
94249139 114 /* cout<<" lookup KEY!!! "<<name.Data()<<" "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" "
256d4943 115 <<lookvalue->GetTDC()<<" "
116 << lookvalue->GetChain()<<" "
94249139 117 <<lookvalue->GetChannel()<<endl;*/
256d4943 118 }
119 }
c41ceaac 120
e0bba6cc 121}
5325480c 122//________________________________________________________________
dc7ca31d 123
e0bba6cc 124void AliT0CalibData::ReadAsciiLookup(const Char_t *filename)
125{
94249139 126 // read lookup table from ascii file
127
c41ceaac 128 Int_t key, trm, tdc, chain, channel;
e0bba6cc 129
130 if(filename == 0){
131 AliError(Form("Please, specify file with database")) ;
132 return ;
133 }
134
e0bba6cc 135
136 ifstream lookup;
137 lookup.open(filename);
c41ceaac 138 if(!lookup)
139 {
29d3e0eb 140 AliError(Form("!!!!!!!!!!!!!!No look up table in CDB!" ));
141
c41ceaac 142 }
e0bba6cc 143 Char_t varname[11];
5325480c 144 Int_t ntrms;
145 if(lookup)
e0bba6cc 146 {
5325480c 147 lookup>>ntrms;
5325480c 148 // fNumberOfTRMs=ntrms;
149 SetNumberOfTRMs(ntrms);
150 while(!lookup.eof())
151 {
152 AliT0LookUpKey * lookkey= new AliT0LookUpKey();
153 AliT0LookUpValue * lookvalue= new AliT0LookUpValue();
154
155 lookup>>varname>>key>>trm>>chain>>tdc>>channel;
156 lookvalue->SetTRM(trm);
157 lookvalue->SetTDC(tdc);
158 lookvalue->SetChain(chain);
159 lookvalue->SetChannel(channel);
160 lookkey->SetKey(key);
256d4943 161 lookkey->SetChannelName(varname);
5325480c 162
163 fLookup.Add((TObject*)lookvalue,(TObject*)lookkey);
164
165 }
166
167 lookup.close();
ca7c0417 168
e0bba6cc 169 }
e0bba6cc 170}
e0bba6cc 171//________________________________________________________________
172
173Int_t AliT0CalibData::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
174{
94249139 175 // read number of channel according physical addres
176
e0bba6cc 177
178 AliT0LookUpKey * lookkey;//= new AliT0LookUpKey();
179 AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel);
180
ca7c0417 181 lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
182
e0bba6cc 183 return lookkey->GetKey();
184
185}
186