]>
Commit | Line | Data |
---|---|---|
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> |
b80faac0 | 19 | #include <iostream> |
81028269 | 20 | #include "AliMUONTrackerIO.h" |
21 | ||
22 | /// \class AliMUONTrackerIO | |
23 | /// | |
24 | /// Reader class for ASCII calibration files for MUON tracker : | |
25 | /// converts those ASCII files into AliMUONVStore (suitable to e.g. feed | |
26 | /// the OCDB). | |
27 | /// | |
28 | /// \author Laurent Aphecetche, Subatech | |
29 | ||
b80faac0 | 30 | using std::ostringstream; |
31 | using std::istringstream; | |
32 | using std::cout; | |
33 | using std::endl; | |
81028269 | 34 | /// \cond CLASSIMP |
35 | ClassImp(AliMUONTrackerIO) | |
36 | /// \endcond | |
37 | ||
6c870207 | 38 | #include "AliDCSValue.h" |
81028269 | 39 | #include "AliLog.h" |
7eafe398 | 40 | #include "AliMUONCalibParamND.h" |
81028269 | 41 | #include "AliMUONCalibParamNF.h" |
42 | #include "AliMUONVStore.h" | |
43 | #include "AliMpConstants.h" | |
44 | #include "AliMpDDLStore.h" | |
6c870207 | 45 | #include "AliMpDEManager.h" |
7eafe398 | 46 | #include "AliMpDetElement.h" |
81028269 | 47 | #include <Riostream.h> |
48 | #include <TClass.h> | |
49 | #include <TObjString.h> | |
50 | #include <TSystem.h> | |
51 | #include <sstream> | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | AliMUONTrackerIO::AliMUONTrackerIO() | |
55 | { | |
56 | /// ctor | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliMUONTrackerIO::~AliMUONTrackerIO() | |
61 | { | |
62 | /// dtor | |
63 | } | |
64 | ||
7eafe398 | 65 | //_____________________________________________________________________________ |
66 | Int_t | |
67 | AliMUONTrackerIO::ReadOccupancy(const char* filename,AliMUONVStore& occupancyMap) | |
68 | { | |
69 | /// Read occupancy file created by online DA | |
70 | /// and append values to the occupancyMap store. | |
71 | /// Expected format of the file is : | |
72 | /// busPatchId manuId sumofn nevt | |
73 | ||
74 | TString sFilename(gSystem->ExpandPathName(filename)); | |
75 | ||
76 | std::ifstream in(sFilename.Data()); | |
77 | if (!in.good()) | |
78 | { | |
79 | return kCannotOpenFile; | |
80 | } | |
81 | ||
82 | TString datastring; | |
83 | ostringstream stream; | |
84 | char line[1024]; | |
85 | while ( in.getline(line,1024) ) | |
86 | stream << line << "\n"; | |
7eafe398 | 87 | |
88 | in.close(); | |
89 | ||
ca913045 | 90 | return DecodeOccupancy(stream.str().c_str(),occupancyMap); |
7eafe398 | 91 | |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | Int_t | |
ca913045 | 96 | AliMUONTrackerIO::DecodeOccupancy(const char* data, AliMUONVStore& occupancyMap) |
7eafe398 | 97 | { |
98 | /// Decode occupancy string created append values to the occupancyMap store. | |
99 | /// Expected format of the file is : | |
100 | /// busPatchId manuId sumofn nevt | |
101 | ||
102 | if ( ! AliMpDDLStore::Instance(kFALSE) ) | |
103 | { | |
104 | AliErrorClass("Mapping not loaded. Cannot work"); | |
33d94e07 | 105 | return kNoMapping; |
7eafe398 | 106 | } |
107 | ||
108 | char line[1024]; | |
ca913045 | 109 | istringstream in(data); |
7eafe398 | 110 | |
111 | Int_t n(0); | |
112 | ||
113 | while ( in.getline(line,1024) ) | |
114 | { | |
115 | AliDebugClass(3,Form("line=%s",line)); | |
116 | if ( line[0] == '/' && line[1] == '/' ) continue; | |
117 | std::istringstream sin(line); | |
118 | ||
119 | Int_t busPatchId, manuId; | |
120 | Int_t numberOfEvents; | |
121 | Double_t sumn; | |
122 | ||
123 | sin >> busPatchId >> manuId >> sumn >> numberOfEvents; | |
124 | ||
33d94e07 | 125 | if ( busPatchId == -1 && manuId == -1 && sumn == 0 && numberOfEvents == 0 ) |
126 | { | |
127 | /// DA could not produce information (because run failed somehow). | |
128 | /// That's OK, but let the world know about it | |
129 | return kNoInfoFile; | |
130 | } | |
131 | ||
7eafe398 | 132 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId); |
133 | ||
134 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
135 | ||
136 | Int_t numberOfChannelsInManu = -1; | |
137 | ||
138 | if (de) numberOfChannelsInManu = de->NofChannelsInManu(manuId); | |
139 | ||
140 | if ( numberOfChannelsInManu <= 0 ) | |
141 | { | |
142 | AliErrorClass(Form("BP %5d DE %5d MANU %5d nchannels=%d",busPatchId,detElemId,manuId,numberOfChannelsInManu)); | |
143 | continue; | |
144 | } | |
145 | ||
146 | AliMUONVCalibParam* occupancy = | |
147 | static_cast<AliMUONVCalibParam*>(occupancyMap.FindObject(detElemId,manuId)); | |
148 | if (occupancy) | |
149 | { | |
150 | AliErrorClass(Form("DE %5d MANU %5d is already there ?!",detElemId,manuId)); | |
151 | continue; | |
152 | } | |
153 | ||
154 | occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0); | |
155 | ||
156 | occupancyMap.Add(occupancy); | |
157 | ||
158 | occupancy->SetValueAsDouble(0,0,sumn); | |
159 | occupancy->SetValueAsDouble(0,1,sumn); // with only 0 and 1s, sumw = sumw2 = sumn | |
160 | occupancy->SetValueAsDouble(0,2,sumn); | |
161 | occupancy->SetValueAsInt(0,3,numberOfChannelsInManu); | |
162 | occupancy->SetValueAsInt(0,4,numberOfEvents); | |
163 | ++n; | |
164 | } | |
165 | ||
166 | return n; | |
167 | } | |
168 | ||
81028269 | 169 | //_____________________________________________________________________________ |
170 | Int_t | |
171 | AliMUONTrackerIO::ReadPedestals(const char* filename, AliMUONVStore& pedStore) | |
172 | { | |
173 | /// Read pedestal file (produced by the MUONTRKda.exe program for instance) | |
174 | /// and append the read values into the given VStore | |
cba13f7c | 175 | /// To be used when the input is a file (for instance when reading data |
176 | /// from the OCDB). | |
81028269 | 177 | |
178 | TString sFilename(gSystem->ExpandPathName(filename)); | |
179 | ||
180 | std::ifstream in(sFilename.Data()); | |
181 | if (!in.good()) | |
182 | { | |
183 | return kCannotOpenFile; | |
184 | } | |
185 | ||
06a51226 | 186 | ostringstream stream; |
187 | char line[1024]; | |
188 | while ( in.getline(line,1024) ) | |
189 | stream << line << "\n"; | |
06a51226 | 190 | |
cba13f7c | 191 | in.close(); |
192 | ||
ca913045 | 193 | return DecodePedestals(stream.str().c_str(),pedStore); |
cba13f7c | 194 | |
195 | } | |
196 | ||
197 | //_____________________________________________________________________________ | |
198 | Int_t | |
ca913045 | 199 | AliMUONTrackerIO::DecodePedestals(const char* data, AliMUONVStore& pedStore) |
cba13f7c | 200 | { |
201 | /// Read pedestal Data (produced by the MUONTRKda.exe program for instance) | |
202 | /// and append the read values into the given VStore | |
203 | /// To be used when the input is a TString (for instance when getting data | |
204 | /// from AMORE DB). | |
205 | ||
81028269 | 206 | char line[1024]; |
207 | Int_t busPatchID, manuID, manuChannel; | |
208 | Float_t pedMean, pedSigma; | |
209 | Int_t n(0); | |
ca913045 | 210 | istringstream in(data); |
81028269 | 211 | |
212 | while ( in.getline(line,1024) ) | |
213 | { | |
214 | AliDebugClass(3,Form("line=%s",line)); | |
215 | if ( line[0] == '/' && line[1] == '/' ) continue; | |
216 | std::istringstream sin(line); | |
217 | sin >> busPatchID >> manuID >> manuChannel >> pedMean >> pedSigma; | |
218 | Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID); | |
6c870207 | 219 | |
220 | if ( !AliMpDEManager::IsValidDetElemId(detElemID) ) | |
221 | { | |
222 | AliErrorClass(Form("Got an invalid DE = %d from busPatchId=%d manuId=%d", | |
223 | detElemID,busPatchID,manuID)); | |
224 | continue; | |
225 | } | |
226 | ||
81028269 | 227 | AliDebugClass(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d MEAN %7.2f SIGMA %7.2f", |
228 | busPatchID,detElemID,manuID,manuChannel,pedMean,pedSigma)); | |
cba13f7c | 229 | |
81028269 | 230 | AliMUONVCalibParam* ped = |
231 | static_cast<AliMUONVCalibParam*>(pedStore.FindObject(detElemID,manuID)); | |
81028269 | 232 | if (!ped) |
233 | { | |
234 | ped = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(), | |
235 | detElemID,manuID, | |
236 | AliMUONVCalibParam::InvalidFloatValue()); | |
237 | pedStore.Add(ped); | |
238 | } | |
239 | ped->SetValueAsFloat(manuChannel,0,pedMean); | |
240 | ped->SetValueAsFloat(manuChannel,1,pedSigma); | |
241 | ++n; | |
242 | } | |
81028269 | 243 | |
244 | return n; | |
245 | } | |
246 | ||
247 | //_____________________________________________________________________________ | |
248 | Int_t | |
249 | AliMUONTrackerIO::ReadGains(const char* filename, AliMUONVStore& gainStore, | |
250 | TString& comment) | |
251 | { | |
252 | /// Read gain file (produced by the MUONTRKda.exe program for instance) | |
253 | /// and append the read values into the given VStore | |
cba13f7c | 254 | /// To be used when the input is a file (for instance when reading data |
255 | /// from the OCDB). | |
81028269 | 256 | |
257 | comment = ""; | |
258 | ||
259 | TString sFilename(gSystem->ExpandPathName(filename)); | |
260 | ||
261 | std::ifstream in(sFilename.Data()); | |
262 | if (!in.good()) | |
263 | { | |
264 | return kCannotOpenFile; | |
265 | } | |
266 | ||
cba13f7c | 267 | ostringstream stream; |
268 | char line[1024]; | |
269 | while ( in.getline(line,1024) ) | |
270 | stream << line << "\n"; | |
cba13f7c | 271 | |
272 | in.close(); | |
273 | ||
ca913045 | 274 | return DecodeGains(stream.str().c_str(),gainStore,comment); |
cba13f7c | 275 | |
276 | } | |
277 | ||
278 | //_____________________________________________________________________________ | |
279 | Int_t | |
ca913045 | 280 | AliMUONTrackerIO::DecodeGains(const char* data, AliMUONVStore& gainStore, |
281 | TString& comment) | |
cba13f7c | 282 | { |
283 | /// Read gain file (produced by the MUONTRKda.exe program for instance) | |
284 | /// and append the read values into the given VStore | |
ca913045 | 285 | /// To be used when the input is a string (for instance when getting data |
cba13f7c | 286 | /// from AMORE DB). |
287 | ||
81028269 | 288 | char line[1024]; |
ca913045 | 289 | istringstream in(data); |
81028269 | 290 | Int_t busPatchID, manuID, manuChannel; |
291 | Float_t a0, a1; | |
292 | Int_t thres; | |
293 | UInt_t qual; | |
294 | const Int_t kSaturation(3000); // FIXME: how to get this number ? | |
295 | Int_t n(0); | |
296 | Int_t runNumber(-1); | |
297 | Int_t* runs(0x0); | |
298 | Int_t* dac(0x0); | |
299 | Int_t nDAC(0); | |
1ccd531d | 300 | Int_t nInit(0),f1nbp(0),f2nbp(0); |
81028269 | 301 | |
302 | while ( in.getline(line,1024) ) | |
303 | { | |
304 | if ( strlen(line) < 10 ) continue; | |
305 | if ( line[0] == '/' && line[1] == '/' ) | |
306 | { | |
307 | TString sline(line); | |
308 | if ( sline.Contains("DUMMY") ) | |
309 | { | |
310 | AliDebugClass(1,"Got a dummy file here"); | |
7ae72085 | 311 | delete [] runs; |
312 | delete [] dac; | |
81028269 | 313 | return kDummyFile; |
314 | } | |
315 | if ( sline.Contains("* Run") ) | |
316 | { | |
317 | TObjArray* a = sline.Tokenize(":"); | |
318 | if ( a->GetLast() >= 1 ) | |
319 | { | |
320 | TString s = static_cast<TObjString*>(a->At(1))->String(); | |
321 | runNumber = s.Atoi(); | |
322 | AliDebugClass(1,Form("runNumber is %d",runNumber)); | |
323 | } | |
324 | } | |
325 | if ( sline.Contains("DAC values") ) | |
326 | { | |
327 | nDAC = TString(sline(2,sline.Length()-2)).Atoi(); | |
328 | AliDebugClass(1,Form("# of DAC values = %d",nDAC)); | |
329 | if ( nDAC > 0 ) | |
330 | { | |
331 | if ( nDAC < 100 ) | |
332 | { | |
31244123 | 333 | delete[] runs; |
334 | delete[] dac; | |
81028269 | 335 | runs = new Int_t[nDAC]; |
336 | dac = new Int_t[nDAC]; | |
337 | // skip two lines | |
338 | in.getline(line,1024); | |
18ec51a0 | 339 | sline = line; |
340 | if (!sline.Contains("* nInit =")) | |
341 | { | |
342 | AliErrorClass("Improper format : was expecting nInit= line..."); | |
343 | } | |
344 | else | |
345 | { | |
346 | sscanf(line,"// * nInit = %d * f1nbp = %d * f2nbp = %d",&nInit,&f1nbp,&f2nbp); | |
347 | AliDebugClass(1,Form("nInit = %d",nInit)); | |
348 | AliDebugClass(1,Form("f1nbp = %d",f1nbp)); | |
349 | AliDebugClass(1,Form("f2nbp = %d",f2nbp)); | |
350 | } | |
351 | in.getline(line,1024); | |
81028269 | 352 | in.getline(line,1024); |
353 | // then get run and dac values | |
ca913045 | 354 | Int_t iDAC(0); |
81028269 | 355 | for ( Int_t i = 0; i < nDAC; ++i ) |
356 | { | |
357 | in.getline(line,1024); | |
358 | Int_t a,b; | |
359 | sscanf(line,"// %d %d",&a,&b); | |
360 | runs[iDAC] = a; | |
361 | dac[iDAC] = b; | |
362 | AliDebugClass(1,Form("RUN %d is DAC %d",runs[iDAC],dac[iDAC])); | |
363 | ++iDAC; | |
364 | } | |
365 | } | |
366 | else | |
367 | { | |
368 | AliErrorClass(Form("Something went wrong, as I get too big nDAC = %d",nDAC)); | |
369 | nDAC = 0; | |
7ae72085 | 370 | delete [] runs; |
371 | delete [] dac; | |
81028269 | 372 | return kFormatError; |
373 | } | |
374 | } | |
375 | } | |
376 | continue; | |
377 | } | |
378 | ||
379 | sscanf(line,"%d %d %d %f %f %d %x",&busPatchID,&manuID,&manuChannel, | |
380 | &a0,&a1,&thres,&qual); | |
381 | AliDebugClass(3,Form("line=%s",line)); | |
382 | Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID); | |
6c870207 | 383 | |
384 | if ( !AliMpDEManager::IsValidDetElemId(detElemID) ) | |
385 | { | |
386 | AliErrorClass(Form("Got an invalid DE = %d from busPatchId=%d manuId=%d", | |
387 | detElemID,busPatchID,manuID)); | |
388 | continue; | |
389 | } | |
390 | ||
81028269 | 391 | AliDebugClass(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d A0 %7.2f " |
392 | "A1 %e THRES %5d QUAL %x", | |
393 | busPatchID,detElemID,manuID,manuChannel,a0,a1,thres,qual)); | |
394 | if ( qual == 0 ) continue; | |
395 | ||
396 | AliMUONVCalibParam* gain = | |
397 | static_cast<AliMUONVCalibParam*>(gainStore.FindObject(detElemID,manuID)); | |
398 | ||
cba13f7c | 399 | if (!gain) |
81028269 | 400 | { |
401 | gain = new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),detElemID,manuID,0); | |
402 | gainStore.Add(gain); | |
403 | } | |
404 | gain->SetValueAsFloat(manuChannel,0,a0); | |
405 | gain->SetValueAsFloat(manuChannel,1,a1); | |
406 | gain->SetValueAsInt(manuChannel,2,thres); | |
407 | gain->SetValueAsInt(manuChannel,3,qual); | |
408 | gain->SetValueAsInt(manuChannel,4,kSaturation); | |
409 | ++n; | |
410 | } | |
cba13f7c | 411 | |
81028269 | 412 | comment = ""; |
413 | ||
414 | if ( runNumber > 0 ) | |
415 | { | |
416 | comment = Form("RUN %d",runNumber); | |
417 | } | |
418 | ||
419 | for ( Int_t i = 0; i < nDAC; ++i ) | |
420 | { | |
421 | comment += Form(";(RUN %d = DAC %d)",runs[i],dac[i]); | |
422 | } | |
1ccd531d | 423 | comment += Form(";(nDAC = %d)",nDAC); |
424 | comment += Form(";(nInit = %d)",nInit); | |
425 | comment += Form(";(f1nbp = %d)",f1nbp); | |
426 | comment += Form(";(f2nbp = %d)",f2nbp); | |
81028269 | 427 | |
428 | delete[] runs; | |
429 | delete[] dac; | |
430 | ||
431 | return n; | |
432 | } | |
433 | ||
434 | //_____________________________________________________________________________ | |
435 | Int_t | |
ca913045 | 436 | AliMUONTrackerIO::ReadCapacitances(const char* filename, AliMUONVStore& capaStore) |
81028269 | 437 | { |
438 | /// Read capacitance file | |
439 | /// and append the read values into the given VStore | |
440 | ||
ca913045 | 441 | TString sFilename(gSystem->ExpandPathName(filename)); |
442 | ||
443 | std::ifstream in(sFilename.Data()); | |
444 | if (!in.good()) | |
445 | { | |
446 | return kCannotOpenFile; | |
447 | } | |
448 | ||
449 | ostringstream stream; | |
450 | char line[1024]; | |
451 | while ( in.getline(line,1024) ) | |
452 | stream << line << "\n"; | |
453 | ||
454 | in.close(); | |
455 | ||
456 | return DecodeCapacitances(stream.str().c_str(),capaStore); | |
457 | } | |
458 | ||
459 | //_____________________________________________________________________________ | |
460 | Int_t | |
461 | AliMUONTrackerIO::DecodeCapacitances(const char* data, AliMUONVStore& capaStore) | |
462 | { | |
463 | /// Read capacitances and append the read values into the given VStore | |
464 | /// To be used when the input is a string (for instance when getting data | |
465 | /// from AMORE DB). | |
81028269 | 466 | |
467 | Int_t ngenerated(0); | |
468 | ||
469 | char line[1024]; | |
470 | Int_t serialNumber(-1); | |
471 | AliMUONVCalibParam* param(0x0); | |
ca913045 | 472 | istringstream in(data); |
473 | ||
81028269 | 474 | while ( in.getline(line,1024,'\n') ) |
475 | { | |
476 | if ( isdigit(line[0]) ) | |
477 | { | |
478 | serialNumber = atoi(line); | |
479 | param = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber)); | |
480 | if (param) | |
481 | { | |
482 | AliErrorClass(Form("serialNumber %d appears several times !",serialNumber)); | |
630711ed | 483 | continue; |
81028269 | 484 | } |
485 | param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); | |
486 | Bool_t ok = capaStore.Add(param); | |
487 | if (!ok) | |
488 | { | |
489 | AliErrorClass(Form("Could not set serialNumber=%d",serialNumber)); | |
490 | continue; | |
491 | } | |
492 | continue; | |
493 | } | |
9b780418 | 494 | |
495 | if (!param) continue; | |
496 | ||
81028269 | 497 | Int_t channel; |
498 | Float_t capaValue; | |
499 | Float_t injectionGain; | |
500 | sscanf(line,"%d %f %f",&channel,&capaValue,&injectionGain); | |
501 | AliDebugClass(1,Form("SerialNumber %10d Channel %3d Capa %f injectionGain %f", | |
502 | serialNumber,channel,capaValue,injectionGain)); | |
503 | param->SetValueAsFloat(channel,0,capaValue); | |
504 | param->SetValueAsFloat(channel,1,injectionGain); | |
505 | ++ngenerated; | |
506 | } | |
507 | ||
81028269 | 508 | return ngenerated; |
509 | } | |
6c870207 | 510 | |
511 | //_____________________________________________________________________________ | |
512 | Int_t | |
042cd64e | 513 | AliMUONTrackerIO::ReadConfig(const char* filename, AliMUONVStore& confStore) |
6c870207 | 514 | { |
515 | /// Read config file (produced by the MUONTRKda.exe program for instance) | |
516 | /// and append the read values into the given VStore | |
517 | /// To be used when the input is a file (for instance when reading data | |
518 | /// from the OCDB). | |
6c870207 | 519 | |
520 | TString sFilename(gSystem->ExpandPathName(filename)); | |
521 | ||
522 | std::ifstream in(sFilename.Data()); | |
523 | if (!in.good()) | |
524 | { | |
525 | return kCannotOpenFile; | |
526 | } | |
527 | ||
6c870207 | 528 | ostringstream stream; |
529 | char line[1024]; | |
530 | while ( in.getline(line,1024) ) | |
531 | stream << line << "\n"; | |
6c870207 | 532 | |
533 | in.close(); | |
534 | ||
042cd64e | 535 | return DecodeConfig(stream.str().c_str(),confStore); |
6c870207 | 536 | } |
537 | ||
538 | //_____________________________________________________________________________ | |
539 | Int_t | |
042cd64e | 540 | AliMUONTrackerIO::DecodeConfig(const char* data, AliMUONVStore& confStore) |
6c870207 | 541 | { |
542 | /// Read config data (produced by the MUONTRKda.exe program for instance) | |
543 | /// and append the read values into the given VStore | |
544 | /// To be used when the input is a TString (for instance when getting data | |
545 | /// from AMORE DB). | |
6c870207 | 546 | |
547 | char line[1024]; | |
548 | Int_t busPatchID, manuID; | |
549 | Int_t n(0); | |
ca913045 | 550 | istringstream in(data); |
6c870207 | 551 | |
552 | while ( in.getline(line,1024) ) | |
553 | { | |
554 | AliDebugClass(3,Form("line=%s",line)); | |
555 | if ( line[0] == '#' ) | |
556 | { | |
6c870207 | 557 | continue; |
558 | } | |
559 | std::istringstream sin(line); | |
560 | sin >> busPatchID >> manuID; | |
561 | ||
562 | Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID); | |
563 | ||
564 | if ( !AliMpDEManager::IsValidDetElemId(detElemID) ) | |
565 | { | |
566 | AliErrorClass(Form("Got an invalid DE = %d from busPatchId=%d manuId=%d", | |
567 | detElemID,busPatchID,manuID)); | |
568 | continue; | |
569 | } | |
570 | ||
571 | AliMUONVCalibParam* conf = | |
572 | static_cast<AliMUONVCalibParam*>(confStore.FindObject(detElemID,manuID)); | |
573 | if (!conf) | |
574 | { | |
575 | conf = new AliMUONCalibParamNF(1,1,detElemID,manuID,1); | |
576 | confStore.Add(conf); | |
577 | } | |
578 | ++n; | |
579 | } | |
580 | ||
581 | return n; | |
582 | } | |
583 | ||
584 | //_____________________________________________________________________________ | |
585 | Int_t | |
ca913045 | 586 | AliMUONTrackerIO::WriteConfig(ofstream& out, const AliMUONVStore& confStore) |
6c870207 | 587 | { |
588 | /// Write the conf store as an ASCII file | |
589 | /// Note that we are converting (back) the detElemId into a busPatchId | |
590 | /// Return the number of lines written | |
591 | ||
592 | if ( !AliMpDDLStore::Instance() ) | |
593 | { | |
594 | cout << "ERROR: mapping not loaded. Cannot work" << endl; | |
595 | return 0; | |
596 | } | |
597 | ||
598 | TIter next(confStore.CreateIterator()); | |
599 | AliMUONVCalibParam* param; | |
600 | Int_t n(0); | |
601 | ||
602 | while ( (param=static_cast<AliMUONVCalibParam*>(next())) ) | |
603 | { | |
604 | Int_t detElemId = param->ID0(); | |
605 | Int_t manuId = param->ID1(); | |
606 | ||
607 | Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); | |
608 | ++n; | |
609 | ||
610 | out << busPatchId << " " << manuId << endl; | |
611 | } | |
612 | return n; | |
613 | } | |
614 |