1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include "AliMUONTrackerIO.h"
21 /// \class AliMUONTrackerIO
23 /// Reader class for ASCII calibration files for MUON tracker :
24 /// converts those ASCII files into AliMUONVStore (suitable to e.g. feed
27 /// \author Laurent Aphecetche, Subatech
30 ClassImp(AliMUONTrackerIO)
34 #include "AliMUONCalibParamNF.h"
35 #include "AliMUONVStore.h"
36 #include "AliMpConstants.h"
37 #include "AliMpDDLStore.h"
38 #include <Riostream.h>
40 #include <TObjString.h>
44 //_____________________________________________________________________________
45 AliMUONTrackerIO::AliMUONTrackerIO()
50 //_____________________________________________________________________________
51 AliMUONTrackerIO::~AliMUONTrackerIO()
56 //_____________________________________________________________________________
58 AliMUONTrackerIO::ReadPedestals(const char* filename, AliMUONVStore& pedStore)
60 /// Read pedestal file (produced by the MUONTRKda.exe program for instance)
61 /// and append the read values into the given VStore
63 TString sFilename(gSystem->ExpandPathName(filename));
65 std::ifstream in(sFilename.Data());
68 return kCannotOpenFile;
72 Int_t busPatchID, manuID, manuChannel;
73 Float_t pedMean, pedSigma;
76 while ( in.getline(line,1024) )
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));
86 AliMUONVCalibParam* ped =
87 static_cast<AliMUONVCalibParam*>(pedStore.FindObject(detElemID,manuID));
91 ped = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),
93 AliMUONVCalibParam::InvalidFloatValue());
96 ped->SetValueAsFloat(manuChannel,0,pedMean);
97 ped->SetValueAsFloat(manuChannel,1,pedSigma);
106 //_____________________________________________________________________________
108 AliMUONTrackerIO::ReadGains(const char* filename, AliMUONVStore& gainStore,
111 /// Read gain file (produced by the MUONTRKda.exe program for instance)
112 /// and append the read values into the given VStore
116 TString sFilename(gSystem->ExpandPathName(filename));
118 std::ifstream in(sFilename.Data());
121 return kCannotOpenFile;
125 Int_t busPatchID, manuID, manuChannel;
129 const Int_t kSaturation(3000); // FIXME: how to get this number ?
137 while ( in.getline(line,1024) )
139 if ( strlen(line) < 10 ) continue;
140 if ( line[0] == '/' && line[1] == '/' )
143 if ( sline.Contains("DUMMY") )
145 AliDebugClass(1,"Got a dummy file here");
148 if ( sline.Contains("* Run") )
150 TObjArray* a = sline.Tokenize(":");
151 if ( a->GetLast() >= 1 )
153 TString s = static_cast<TObjString*>(a->At(1))->String();
154 runNumber = s.Atoi();
155 AliDebugClass(1,Form("runNumber is %d",runNumber));
158 if ( sline.Contains("DAC values") )
160 nDAC = TString(sline(2,sline.Length()-2)).Atoi();
161 AliDebugClass(1,Form("# of DAC values = %d",nDAC));
166 runs = new Int_t[nDAC];
167 dac = new Int_t[nDAC];
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 )
174 in.getline(line,1024);
176 sscanf(line,"// %d %d",&a,&b);
179 AliDebugClass(1,Form("RUN %d is DAC %d",runs[iDAC],dac[iDAC]));
185 AliErrorClass(Form("Something went wrong, as I get too big nDAC = %d",nDAC));
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;
203 AliMUONVCalibParam* gain =
204 static_cast<AliMUONVCalibParam*>(gainStore.FindObject(detElemID,manuID));
208 gain = new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),detElemID,manuID,0);
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);
225 comment = Form("RUN %d",runNumber);
228 for ( Int_t i = 0; i < nDAC; ++i )
230 comment += Form(";(RUN %d = DAC %d)",runs[i],dac[i]);
239 //_____________________________________________________________________________
241 AliMUONTrackerIO::ReadCapacitances(const char* file, AliMUONVStore& capaStore)
243 /// Read capacitance file
244 /// and append the read values into the given VStore
246 ifstream in(gSystem->ExpandPathName(file));
247 if (in.bad()) return kCannotOpenFile;
252 Int_t serialNumber(-1);
253 AliMUONVCalibParam* param(0x0);
255 while ( in.getline(line,1024,'\n') )
257 if ( isdigit(line[0]) )
259 serialNumber = atoi(line);
260 param = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
263 AliErrorClass(Form("serialNumber %d appears several times !",serialNumber));
266 param = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
267 Bool_t ok = capaStore.Add(param);
270 AliErrorClass(Form("Could not set serialNumber=%d",serialNumber));
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);