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