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