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 **************************************************************************/
18 #include "AliMUONTrackerIO.h"
20 /// \class AliMUONTrackerIO
22 /// Reader class for ASCII calibration files for MUON tracker :
23 /// converts those ASCII files into AliMUONVStore (suitable to e.g. feed
26 /// \author Laurent Aphecetche, Subatech
29 ClassImp(AliMUONTrackerIO)
33 #include "AliMUONCalibParamNF.h"
34 #include "AliMUONVStore.h"
35 #include "AliMpConstants.h"
36 #include "AliMpDDLStore.h"
37 #include <Riostream.h>
39 #include <TObjString.h>
43 //_____________________________________________________________________________
44 AliMUONTrackerIO::AliMUONTrackerIO()
49 //_____________________________________________________________________________
50 AliMUONTrackerIO::~AliMUONTrackerIO()
55 //_____________________________________________________________________________
57 AliMUONTrackerIO::ReadPedestals(const char* filename, AliMUONVStore& pedStore)
59 /// Read pedestal file (produced by the MUONTRKda.exe program for instance)
60 /// and append the read values into the given VStore
62 TString sFilename(gSystem->ExpandPathName(filename));
64 std::ifstream in(sFilename.Data());
67 return kCannotOpenFile;
71 Int_t busPatchID, manuID, manuChannel;
72 Float_t pedMean, pedSigma;
75 while ( in.getline(line,1024) )
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));
85 AliMUONVCalibParam* ped =
86 static_cast<AliMUONVCalibParam*>(pedStore.FindObject(detElemID,manuID));
90 ped = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),
92 AliMUONVCalibParam::InvalidFloatValue());
95 ped->SetValueAsFloat(manuChannel,0,pedMean);
96 ped->SetValueAsFloat(manuChannel,1,pedSigma);
105 //_____________________________________________________________________________
107 AliMUONTrackerIO::ReadGains(const char* filename, AliMUONVStore& gainStore,
110 /// Read gain file (produced by the MUONTRKda.exe program for instance)
111 /// and append the read values into the given VStore
115 TString sFilename(gSystem->ExpandPathName(filename));
117 std::ifstream in(sFilename.Data());
120 return kCannotOpenFile;
124 Int_t busPatchID, manuID, manuChannel;
128 const Int_t kSaturation(3000); // FIXME: how to get this number ?
136 while ( in.getline(line,1024) )
138 if ( strlen(line) < 10 ) continue;
139 if ( line[0] == '/' && line[1] == '/' )
142 if ( sline.Contains("DUMMY") )
144 AliDebugClass(1,"Got a dummy file here");
147 if ( sline.Contains("* Run") )
149 TObjArray* a = sline.Tokenize(":");
150 if ( a->GetLast() >= 1 )
152 TString s = static_cast<TObjString*>(a->At(1))->String();
153 runNumber = s.Atoi();
154 AliDebugClass(1,Form("runNumber is %d",runNumber));
157 if ( sline.Contains("DAC values") )
159 nDAC = TString(sline(2,sline.Length()-2)).Atoi();
160 AliDebugClass(1,Form("# of DAC values = %d",nDAC));
165 runs = new Int_t[nDAC];
166 dac = new Int_t[nDAC];
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 )
173 in.getline(line,1024);
175 sscanf(line,"// %d %d",&a,&b);
178 AliDebugClass(1,Form("RUN %d is DAC %d",runs[iDAC],dac[iDAC]));
184 AliErrorClass(Form("Something went wrong, as I get too big nDAC = %d",nDAC));
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;
202 AliMUONVCalibParam* gain =
203 static_cast<AliMUONVCalibParam*>(gainStore.FindObject(detElemID,manuID));
207 gain = new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),detElemID,manuID,0);
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);
224 comment = Form("RUN %d",runNumber);
227 for ( Int_t i = 0; i < nDAC; ++i )
229 comment += Form(";(RUN %d = DAC %d)",runs[i],dac[i]);
238 //_____________________________________________________________________________
240 AliMUONTrackerIO::ReadCapacitances(const char* file, AliMUONVStore& capaStore)
242 /// Read capacitance file
243 /// and append the read values into the given VStore
245 ifstream in(gSystem->ExpandPathName(file));
246 if (in.bad()) return kCannotOpenFile;
251 Int_t serialNumber(-1);
252 AliMUONVCalibParam* param(0x0);
254 while ( in.getline(line,1024,'\n') )
256 if ( isdigit(line[0]) )
258 serialNumber = atoi(line);
259 param = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
262 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);