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