X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONGainSubprocessor.cxx;h=ed95018c53e15a50c0aab508d11c906a8c3cb43d;hb=01e3d4d7ed4aadd9301cde3debb526fea4ec5aff;hp=49d15c39ea4a1dffb0454dead20c07d6f28db4c9;hpb=d077973a47f526a506f3c73d95316147064dce38;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONGainSubprocessor.cxx b/MUON/AliMUONGainSubprocessor.cxx index 49d15c39ea4..ed95018c53e 100644 --- a/MUON/AliMUONGainSubprocessor.cxx +++ b/MUON/AliMUONGainSubprocessor.cxx @@ -15,39 +15,41 @@ // $Id$ +#include "AliMUONGainSubprocessor.h" + +#include "AliCDBMetaData.h" +#include "AliLog.h" #include "AliMUON2DMap.h" +#include "AliMUON2DStoreValidator.h" #include "AliMUONCalibParamNF.h" #include "AliMUONConstants.h" -#include "AliMUONObjectPair.h" -#include "AliMUONGainSubprocessor.h" #include "AliMUONPreprocessor.h" -#include "AliMUONVDataIterator.h" +#include "AliMUONTrackerIO.h" +#include "AliMpConstants.h" #include "AliMpDDLStore.h" -#include "AliMUON2DStoreValidator.h" - -#include "AliCDBMetaData.h" -#include "AliLog.h" - -#include #include #include #include +#include #include - #include -/// +//----------------------------------------------------------------------------- /// \class AliMUONGainSubprocessor /// /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK Gains. /// -/// Gains are read in from an ascii file, with the format : \n -///---------------------------------------------------------------------------\n -///BUS_PATCH MANU CHANNEL Ped. a0 a1 a2 xlim P(chi2) P(chi2)_2 \n -///---------------------------------------------------------------------------\n +/// Gains are read in from an ascii file, with the format : +/// +///--------------------------------------------------------------------------- +/// +///BUS_PATCH MANU CHANNEL a0 a1 thres Qual +/// +///--------------------------------------------------------------------------- /// /// \author L. Aphecetche /// +//----------------------------------------------------------------------------- /// \cond CLASSIMP ClassImp(AliMUONGainSubprocessor) @@ -58,7 +60,9 @@ AliMUONGainSubprocessor::AliMUONGainSubprocessor(AliMUONPreprocessor* master) : AliMUONVSubprocessor(master, "Gains", "Upload MUON Tracker Gains to OCDB"), -fGains(0x0) +fGains(0x0), +fSkip(kFALSE), +fComment("") { /// default ctor } @@ -71,7 +75,7 @@ AliMUONGainSubprocessor::~AliMUONGainSubprocessor() } //_____________________________________________________________________________ -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. @@ -79,6 +83,9 @@ AliMUONGainSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) const Int_t kSystem = AliMUONPreprocessor::kDAQ; const char* kId = "GAINS"; + fComment = ""; + fSkip = kFALSE; + delete fGains; fGains = new AliMUON2DMap(kTRUE); @@ -94,23 +101,35 @@ AliMUONGainSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) { 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; } //_____________________________________________________________________________ @@ -122,8 +141,15 @@ AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/) if (!fGains) { // this is the only reason to fail for the moment : getting no Gain - // at all. - return 0; + // at all, except if the input file was a dummy one + if ( fSkip ) + { + return 0; + } + else + { + return 1; + } } AliMUON2DStoreValidator validator; @@ -155,93 +181,48 @@ AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/) 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; - UInt_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity); + Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity); - return result; + return ( result != kTRUE ); // return 0 if everything is ok } //_____________________________________________________________________________ Int_t AliMUONGainSubprocessor::ReadFile(const char* filename) { - /// Read the Gains from an ASCII file. \n - /// Format of that file is one line per channel : \n - ///-------------------------------------------------------------------------\n - ///BUS_PATCH MANU CHANNEL Ped. a0 a1 a2 xlim P(chi2) P(chi2)_2 \n - ///-------------------------------------------------------------------------\n - /// \n - /// Return kFALSE if reading was not successfull. \n + /// Read the Gains from an ASCII file. + /// Format of that file is one line per channel : + ///------------------------------------------------------------------------- + ///BUS_PATCH MANU CHANNEL a0 a1 thres Qual + ///------------------------------------------------------------------------- + /// + /// 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()) - { - return 0; - } - char line[256]; - Int_t busPatchID, manuID, manuChannel; - Float_t ped; - Float_t a0, a1, a2; - Float_t xlim; - Float_t chi2, chi22; - - static const Int_t kNchannels(64); - static Bool_t replace(kFALSE); - Int_t n(0); - - while ( in.getline(line,256) ) - { - if ( strlen(line) < 10 ) continue; - if ( line[0] == '/' && line[1] == '/' ) continue; - std::istringstream sin(line); - AliDebug(3,Form("line=%s",line)); - sin >> busPatchID >> manuID >> manuChannel >> ped >> a0 >> a1 >> a2 >> xlim >> chi2 >> chi22; - Int_t detElemID = AliMpDDLStore::Instance()->GetDEfromBus(busPatchID); - AliDebug(3,Form("BUSPATCH %3d DETELEMID %4d MANU %3d CH %3d PED %7.2f A0 %7.2f A1 %7.2f A2 %7.2f" - " XLIM %7.2f CHI2 %7.2f CHI22 %7.2f", - busPatchID,detElemID,manuID,manuChannel,ped,a0,a1,a2,xlim,chi2,chi22)); - if ( a0==a1 && a1==a2 && a0==-2) continue; - - AliMUONVCalibParam* gain = - static_cast(fGains->Get(detElemID,manuID)); - if (!gain) - { - gain = new AliMUONCalibParamNF(6,kNchannels,0);//AliMUONVCalibParam::InvalidFloatValue()); - fGains->Set(detElemID,manuID,gain,replace); - } - gain->SetValueAsFloat(manuChannel,0,a0); - gain->SetValueAsFloat(manuChannel,1,a1); - gain->SetValueAsFloat(manuChannel,2,a2); - gain->SetValueAsFloat(manuChannel,3,xlim); - gain->SetValueAsFloat(manuChannel,4,chi2); - gain->SetValueAsFloat(manuChannel,5,chi22); - ++n; - } - in.close(); - return n; -} + Int_t n = AliMUONTrackerIO::ReadGains(sFilename.Data(),*fGains,fComment); - -//_____________________________________________________________________________ -void -AliMUONGainSubprocessor::Print(Option_t* opt) const -{ - /// ouput to screen - AliMUONVDataIterator* it = fGains->Iterator(); - AliMUONObjectPair* p; - - while ( ( p = static_cast(it->Next() ) ) ) + switch (n) { - AliMUONVCalibParam* value = static_cast(p->Value()); - value->Print(opt); - if ( it->IsOwner() ) delete p; + 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; } + + return n; }