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