// $Id$
-#include <sstream>
-
-#include <Riostream.h>
-#include <TList.h>
-#include <TObjString.h>
-#include <TSystem.h>
+#include "AliMUONPedestalSubprocessor.h"
#include "AliCDBMetaData.h"
#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUON2DStoreValidator.h"
-#include "AliMUONCalibParam2F.h"
-#include "AliMUONConstants.h"
-#include "AliMUONObjectPair.h"
-#include "AliMUONPedestalSubprocessor.h"
+#include "AliMUONCalibParamNF.h"
#include "AliMUONPreprocessor.h"
-#include "AliMUONVDataIterator.h"
+#include "AliMUONTrackerIO.h"
+#include "AliMpConstants.h"
#include "AliMpDDLStore.h"
+#include "TObjString.h"
+#include <Riostream.h>
+#include <TList.h>
+#include <TObjString.h>
+#include <TSystem.h>
+#include <sstream>
-///
+//-----------------------------------------------------------------------------
/// \class AliMUONPedestalSubprocessor
///
/// Implementation of AliMUONVSubprocessor class to deal with MUON TRK pedestals.
///---------------------------------------------------------------------------\n
///
/// \author L. Aphecetche
-///
+//-----------------------------------------------------------------------------
/// \cond CLASSIMP
ClassImp(AliMUONPedestalSubprocessor)
"Upload MUON Tracker pedestals to OCDB"),
fPedestals(0x0)
{
- // default ctor
+ /// default ctor
}
//_____________________________________________________________________________
AliMUONPedestalSubprocessor::~AliMUONPedestalSubprocessor()
{
- // dtor
+ /// dtor
delete fPedestals;
}
TList* sources = Master()->GetFileSources(kSystem,kId);
TIter next(sources);
TObjString* o(0x0);
+ Int_t n(0);
+
while ( ( o = static_cast<TObjString*>(next()) ) )
{
TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
- Bool_t ok = ReadFile(fileName.Data());
- if (!ok)
+ Int_t ok = ReadFile(fileName.Data());
+ if (ok>0)
{
- Master()->Log(Form("Could not read file %s",fileName.Data()));
+ n += ok;
}
}
+
+ if (!n)
+ {
+ Master()->Log("Failed to read any pedestals");
+ delete fPedestals;
+ fPedestals = 0;
+ }
delete sources;
}
UInt_t
AliMUONPedestalSubprocessor::Process(TMap* /*dcsAliasMap*/)
{
- // Store the pedestals into the CDB
+ /// Store the pedestals into the CDB
- if (!fPedestals) return 0;
-
- Master()->Log("Validating pedestals");
+ if (!fPedestals)
+ {
+ // this is the only reason to fail for the moment : getting no pedestal
+ // at all.
+ return 1;
+ }
+
AliMUON2DStoreValidator validator;
- TObjArray* missing =
- validator.Validate(*fPedestals,AliMUONCalibParam2F::InvalidFloatValue());
+
+ Master()->Log("Validating");
+
+ TObjArray* chambers = validator.Validate(*fPedestals);
- if (missing)
+ if (chambers)
{
+ // we hereby report what's missing, but this is not a reason to fail ;-)
+ // the only reason to fail would be if we got no pedestal at all
TList lines;
lines.SetOwner(kTRUE);
- validator.Report(lines,*missing);
+
+ validator.Report(lines,*chambers);
+
TIter next(&lines);
- TObjString* l;
- while ( ( l = static_cast<TObjString*>(next())) )
+ TObjString* line;
+
+ while ( ( line = static_cast<TObjString*>(next()) ) )
{
- Master()->Log(l->GetName());
+ Master()->Log(line->String().Data());
}
- return 0;
}
Master()->Log("Storing pedestals");
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("MUON TRK");
- metaData.SetComment("Computed by AliMUONPedestalSubprocessor $Id$");
+ TString comment("Computed by AliMUONPedestalSubprocessor $Id$");
+ comment.ReplaceAll("$","");
+ metaData.SetComment(comment.Data());
Bool_t validToInfinity = kTRUE;
- UInt_t result = Master()->Store("Calib", "Pedestals", fPedestals, &metaData, 0, validToInfinity);
+ Bool_t result = Master()->Store("Calib", "Pedestals", fPedestals, &metaData, 0, validToInfinity);
- return result;
+ return ( result != kTRUE ); // return 0 if everything is ok.
}
//_____________________________________________________________________________
-Bool_t
+Int_t
AliMUONPedestalSubprocessor::ReadFile(const char* filename)
{
- // Read the pedestals from an ASCII file.
- // Format of that file is one line per channel :
- //---------------------------------------------------------------------------
- // BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA
- //---------------------------------------------------------------------------
- //
- // Return kFALSE if reading was not successfull.
- //
+ /// Read the pedestals from an ASCII file. \n
+ /// Format of that file is one line per channel : \n
+ ///-------------------------------------------------------------------------\n
+ /// BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA \n
+ ///-------------------------------------------------------------------------\n
+ /// \n
+ /// Return kFALSE if reading was not successfull. \n
+ ///
TString sFilename(gSystem->ExpandPathName(filename));
Master()->Log(Form("Reading %s",sFilename.Data()));
- std::ifstream in(sFilename.Data());
- if (!in.good())
- {
- return kFALSE;
- }
- char line[80];
- Int_t busPatchID, manuID, manuChannel;
- Float_t pedMean, pedSigma;
- static const Int_t kNchannels(64);
- static Bool_t replace(kFALSE);
+ Int_t n = AliMUONTrackerIO::ReadPedestals(sFilename.Data(),*fPedestals);
- while ( in.getline(line,80) )
+ switch (n)
{
- if ( line[0] == '/' && line[1] == '/' ) continue;
- std::istringstream sin(line);
- sin >> busPatchID >> manuID >> manuChannel >> pedMean >> pedSigma;
- Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID);
- AliDebug(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d MEAN %7.2f SIGMA %7.2f",
- busPatchID,detElemID,manuID,manuChannel,pedMean,pedSigma));
-
- AliMUONVCalibParam* ped =
- static_cast<AliMUONVCalibParam*>(fPedestals->Get(detElemID,manuID));
-
- if (!ped)
- {
- ped = new AliMUONCalibParam2F(kNchannels,AliMUONCalibParam2F::InvalidFloatValue());
- fPedestals->Set(detElemID,manuID,ped,replace);
- }
- ped->SetValueAsFloat(manuChannel,0,pedMean);
- ped->SetValueAsFloat(manuChannel,1,pedSigma);
+ case -1:
+ Master()->Log(Form("Could not open %s",sFilename.Data()));
+ break;
}
- in.close();
- return kTRUE;
+
+ return n;
}
AliMUONPedestalSubprocessor::Print(Option_t* opt) const
{
/// ouput to screen
- AliMUONVDataIterator* it = fPedestals->Iterator();
- AliMUONObjectPair* p;
-
- while ( ( p = static_cast<AliMUONObjectPair*>(it->Next() ) ) )
- {
- AliMUONVCalibParam* value = static_cast<AliMUONVCalibParam*>(p->Value());
- value->Print(opt);
- }
+ if (fPedestals) fPedestals->Print("",opt);
}