]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackerIO.cxx
Removing obsolete files
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerIO.cxx
CommitLineData
81028269 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
b09247a2 18#include <cstdlib>
81028269 19#include "AliMUONTrackerIO.h"
20
21/// \class AliMUONTrackerIO
22///
23/// Reader class for ASCII calibration files for MUON tracker :
24/// converts those ASCII files into AliMUONVStore (suitable to e.g. feed
25/// the OCDB).
26///
27/// \author Laurent Aphecetche, Subatech
28
29/// \cond CLASSIMP
30ClassImp(AliMUONTrackerIO)
31/// \endcond
32
33#include "AliLog.h"
34#include "AliMUONCalibParamNF.h"
35#include "AliMUONVStore.h"
36#include "AliMpConstants.h"
37#include "AliMpDDLStore.h"
38#include <Riostream.h>
39#include <TClass.h>
40#include <TObjString.h>
41#include <TSystem.h>
42#include <sstream>
43
44//_____________________________________________________________________________
45AliMUONTrackerIO::AliMUONTrackerIO()
46{
47 /// ctor
48}
49
50//_____________________________________________________________________________
51AliMUONTrackerIO::~AliMUONTrackerIO()
52{
53 /// dtor
54}
55
56//_____________________________________________________________________________
57Int_t
58AliMUONTrackerIO::ReadPedestals(const char* filename, AliMUONVStore& pedStore)
59{
60 /// Read pedestal file (produced by the MUONTRKda.exe program for instance)
61 /// and append the read values into the given VStore
62
63 TString sFilename(gSystem->ExpandPathName(filename));
64
65 std::ifstream in(sFilename.Data());
66 if (!in.good())
67 {
68 return kCannotOpenFile;
69 }
70
71 char line[1024];
72 Int_t busPatchID, manuID, manuChannel;
73 Float_t pedMean, pedSigma;
74 Int_t n(0);
75
76 while ( in.getline(line,1024) )
77 {
78 AliDebugClass(3,Form("line=%s",line));
79 if ( line[0] == '/' && line[1] == '/' ) continue;
80 std::istringstream sin(line);
81 sin >> busPatchID >> manuID >> manuChannel >> pedMean >> pedSigma;
82 Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID);
83 AliDebugClass(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d MEAN %7.2f SIGMA %7.2f",
84 busPatchID,detElemID,manuID,manuChannel,pedMean,pedSigma));
85
86 AliMUONVCalibParam* ped =
87 static_cast<AliMUONVCalibParam*>(pedStore.FindObject(detElemID,manuID));
88
89 if (!ped)
90 {
91 ped = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),
92 detElemID,manuID,
93 AliMUONVCalibParam::InvalidFloatValue());
94 pedStore.Add(ped);
95 }
96 ped->SetValueAsFloat(manuChannel,0,pedMean);
97 ped->SetValueAsFloat(manuChannel,1,pedSigma);
98 ++n;
99 }
100
101 in.close();
102
103 return n;
104}
105
106//_____________________________________________________________________________
107Int_t
108AliMUONTrackerIO::ReadGains(const char* filename, AliMUONVStore& gainStore,
109 TString& comment)
110{
111 /// Read gain file (produced by the MUONTRKda.exe program for instance)
112 /// and append the read values into the given VStore
113
114 comment = "";
115
116 TString sFilename(gSystem->ExpandPathName(filename));
117
118 std::ifstream in(sFilename.Data());
119 if (!in.good())
120 {
121 return kCannotOpenFile;
122 }
123
124 char line[1024];
125 Int_t busPatchID, manuID, manuChannel;
126 Float_t a0, a1;
127 Int_t thres;
128 UInt_t qual;
129 const Int_t kSaturation(3000); // FIXME: how to get this number ?
130 Int_t n(0);
131 Int_t runNumber(-1);
132 Int_t* runs(0x0);
133 Int_t* dac(0x0);
134 Int_t nDAC(0);
135 Int_t iDAC(0);
136
137 while ( in.getline(line,1024) )
138 {
139 if ( strlen(line) < 10 ) continue;
140 if ( line[0] == '/' && line[1] == '/' )
141 {
142 TString sline(line);
143 if ( sline.Contains("DUMMY") )
144 {
145 AliDebugClass(1,"Got a dummy file here");
146 return kDummyFile;
147 }
148 if ( sline.Contains("* Run") )
149 {
150 TObjArray* a = sline.Tokenize(":");
151 if ( a->GetLast() >= 1 )
152 {
153 TString s = static_cast<TObjString*>(a->At(1))->String();
154 runNumber = s.Atoi();
155 AliDebugClass(1,Form("runNumber is %d",runNumber));
156 }
157 }
158 if ( sline.Contains("DAC values") )
159 {
160 nDAC = TString(sline(2,sline.Length()-2)).Atoi();
161 AliDebugClass(1,Form("# of DAC values = %d",nDAC));
162 if ( nDAC > 0 )
163 {
164 if ( nDAC < 100 )
165 {
166 runs = new Int_t[nDAC];
167 dac = new Int_t[nDAC];
168 // skip two lines
169 in.getline(line,1024);
170 in.getline(line,1024);
171 // then get run and dac values
172 for ( Int_t i = 0; i < nDAC; ++i )
173 {
174 in.getline(line,1024);
175 Int_t a,b;
176 sscanf(line,"// %d %d",&a,&b);
177 runs[iDAC] = a;
178 dac[iDAC] = b;
179 AliDebugClass(1,Form("RUN %d is DAC %d",runs[iDAC],dac[iDAC]));
180 ++iDAC;
181 }
182 }
183 else
184 {
185 AliErrorClass(Form("Something went wrong, as I get too big nDAC = %d",nDAC));
186 nDAC = 0;
187 return kFormatError;
188 }
189 }
190 }
191 continue;
192 }
193
194 sscanf(line,"%d %d %d %f %f %d %x",&busPatchID,&manuID,&manuChannel,
195 &a0,&a1,&thres,&qual);
196 AliDebugClass(3,Form("line=%s",line));
197 Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID);
198 AliDebugClass(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d A0 %7.2f "
199 "A1 %e THRES %5d QUAL %x",
200 busPatchID,detElemID,manuID,manuChannel,a0,a1,thres,qual));
201 if ( qual == 0 ) continue;
202
203 AliMUONVCalibParam* gain =
204 static_cast<AliMUONVCalibParam*>(gainStore.FindObject(detElemID,manuID));
205
206 if (!gain)
207 {
208 gain = new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),detElemID,manuID,0);
209 gainStore.Add(gain);
210 }
211 gain->SetValueAsFloat(manuChannel,0,a0);
212 gain->SetValueAsFloat(manuChannel,1,a1);
213 gain->SetValueAsInt(manuChannel,2,thres);
214 gain->SetValueAsInt(manuChannel,3,qual);
215 gain->SetValueAsInt(manuChannel,4,kSaturation);
216 ++n;
217 }
218
219 in.close();
220
221 comment = "";
222
223 if ( runNumber > 0 )
224 {
225 comment = Form("RUN %d",runNumber);
226 }
227
228 for ( Int_t i = 0; i < nDAC; ++i )
229 {
230 comment += Form(";(RUN %d = DAC %d)",runs[i],dac[i]);
231 }
232
233 delete[] runs;
234 delete[] dac;
235
236 return n;
237}
238
239//_____________________________________________________________________________
240Int_t
241AliMUONTrackerIO::ReadCapacitances(const char* file, AliMUONVStore& capaStore)
242{
243 /// Read capacitance file
244 /// and append the read values into the given VStore
245
246 ifstream in(gSystem->ExpandPathName(file));
247 if (in.bad()) return kCannotOpenFile;
248
249 Int_t ngenerated(0);
250
251 char line[1024];
252 Int_t serialNumber(-1);
253 AliMUONVCalibParam* param(0x0);
254
255 while ( in.getline(line,1024,'\n') )
256 {
257 if ( isdigit(line[0]) )
258 {
259 serialNumber = atoi(line);
260 param = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
261 if (param)
262 {
263 AliErrorClass(Form("serialNumber %d appears several times !",serialNumber));
630711ed 264 continue;
81028269 265 }
266 param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
267 Bool_t ok = capaStore.Add(param);
268 if (!ok)
269 {
270 AliErrorClass(Form("Could not set serialNumber=%d",serialNumber));
271 continue;
272 }
273 continue;
274 }
275 Int_t channel;
276 Float_t capaValue;
277 Float_t injectionGain;
278 sscanf(line,"%d %f %f",&channel,&capaValue,&injectionGain);
279 AliDebugClass(1,Form("SerialNumber %10d Channel %3d Capa %f injectionGain %f",
280 serialNumber,channel,capaValue,injectionGain));
281 param->SetValueAsFloat(channel,0,capaValue);
282 param->SetValueAsFloat(channel,1,injectionGain);
283 ++ngenerated;
284 }
285
286 in.close();
287
288 return ngenerated;
289}