#include "AliMUONCalibParamNF.h"
#include "AliMUONConstants.h"
#include "AliMUONPreprocessor.h"
+#include "AliMUONTrackerIO.h"
#include "AliMpConstants.h"
#include "AliMpDDLStore.h"
#include <Riostream.h>
#include <TSystem.h>
#include <sstream>
-///
+//-----------------------------------------------------------------------------
/// \class AliMUONGainSubprocessor
///
/// Implementation of AliMUONVSubprocessor class to deal with MUON TRK Gains.
///
/// \author L. Aphecetche
///
+//-----------------------------------------------------------------------------
/// \cond CLASSIMP
ClassImp(AliMUONGainSubprocessor)
: AliMUONVSubprocessor(master,
"Gains",
"Upload MUON Tracker Gains to OCDB"),
-fGains(0x0)
+fGains(0x0),
+fSkip(kFALSE),
+fComment("")
{
/// default ctor
}
}
//_____________________________________________________________________________
-void
+Bool_t
AliMUONGainSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
{
/// When starting a new run, reads in the Gains ASCII files.
const Int_t kSystem = AliMUONPreprocessor::kDAQ;
const char* kId = "GAINS";
+ fComment = "";
+ fSkip = kFALSE;
+
delete fGains;
fGains = new AliMUON2DMap(kTRUE);
- Master()->Log(Form("Reading Gain files for Run %d startTime %ld endTime %ld",
+ Master()->Log(Form("Reading Gain files for Run %d startTime %u endTime %u",
run,startTime,endTime));
TList* sources = Master()->GetFileSources(kSystem,kId);
{
TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
Int_t ok = ReadFile(fileName.Data());
- if (!ok)
+ if (ok>0)
{
- Master()->Log(Form("Could not read file %s",fileName.Data()));
+ n += ok;
}
- else
+ else if ( ok == AliMUONTrackerIO::kDummyFile )
{
- n += ok;
+ // not an interesting file.
+ fSkip = kTRUE;
+ break;
}
}
- if (!n)
+ delete sources;
+
+ if ( fSkip )
+ {
+ delete fGains;
+ fGains = 0x0;
+ }
+
+ if (!n && !fSkip)
{
Master()->Log("Failed to read any Gains");
delete fGains;
- fGains = 0;
+ fGains = 0x0;
+ return kFALSE;
}
- delete sources;
+
+ return kTRUE;
}
//_____________________________________________________________________________
if (!fGains)
{
// this is the only reason to fail for the moment : getting no Gain
- // at all.
- return 1;
+ // at all, except if the input file was a dummy one
+ if ( fSkip )
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
}
AliMUON2DStoreValidator validator;
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("MUON TRK");
- metaData.SetComment("Computed by AliMUONGainSubprocessor $Id$");
+ metaData.SetComment(Form("Computed by AliMUONGainSubprocessor "
+ "$Id$ ; %s",fComment.Data()));
Bool_t validToInfinity = kTRUE;
Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity);
///
/// Return kFALSE if reading was not successfull.
///
-
+
TString sFilename(gSystem->ExpandPathName(filename));
Master()->Log(Form("Reading %s",sFilename.Data()));
-
- std::ifstream in(sFilename.Data());
- if (!in.good())
+
+ Int_t n = AliMUONTrackerIO::ReadGains(sFilename.Data(),*fGains,fComment);
+
+ switch (n)
{
- return 0;
+ case AliMUONTrackerIO::kCannotOpenFile:
+ Master()->Log(Form("Could not open %s",sFilename.Data()));
+ break;
+ case AliMUONTrackerIO::kFormatError:
+ Master()->Log(Form("File %s is not of the expected format",sFilename.Data()));
+ break;
+ case AliMUONTrackerIO::kDummyFile:
+ Master()->Log(Form("File %s is a dummy one. That's fine. I won't do anything then ;-)",sFilename.Data()));
+ break;
+ default:
+ break;
}
- char line[256];
- Int_t busPatchID, manuID, manuChannel;
- Float_t a0, a1;
- Int_t thres;
- Int_t qual;
- const Int_t kSaturation(3000); // FIXME: how to get this number ?
-
- static const Int_t kNchannels(AliMpConstants::ManuNofChannels());
- Int_t n(0);
- while ( in.getline(line,256) )
- {
- if ( strlen(line) < 10 ) continue;
- if ( line[0] == '/' && line[1] == '/' ) continue;
-
- sscanf(line,"%d %d %d %f %f %d %x",&busPatchID,&manuID,&manuChannel,
- &a0,&a1,&thres,&qual);
- AliDebug(3,Form("line=%s",line));
- Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID);
- AliDebug(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d A0 %7.2f "
- "A1 %e THRES %5d QUAL %x",
- busPatchID,detElemID,manuID,manuChannel,a0,a1,thres,qual));
- if ( qual == 0 ) continue;
-
- AliMUONVCalibParam* gain =
- static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemID,manuID));
-
- if (!gain)
- {
- gain = new AliMUONCalibParamNF(5,kNchannels,detElemID,manuID,0);
- fGains->Add(gain);
- }
- gain->SetValueAsFloat(manuChannel,0,a0);
- gain->SetValueAsFloat(manuChannel,1,a1);
- gain->SetValueAsInt(manuChannel,2,thres);
- gain->SetValueAsInt(manuChannel,3,qual);
- gain->SetValueAsInt(manuChannel,4,kSaturation);
- ++n;
- }
- in.close();
return n;
}