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 "AliMUONGainSubprocessor.h"
20 #include "AliCDBMetaData.h"
22 #include "AliMUON2DMap.h"
23 #include "AliMUON2DStoreValidator.h"
24 #include "AliMUONCalibParamNF.h"
25 #include "AliMUONConstants.h"
26 #include "AliMUONPreprocessor.h"
27 #include "AliMUONTrackerIO.h"
28 #include "AliMpConstants.h"
29 #include "AliMpDDLStore.h"
30 #include <Riostream.h>
32 #include <TObjString.h>
33 #include <TObjString.h>
37 //-----------------------------------------------------------------------------
38 /// \class AliMUONGainSubprocessor
40 /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK Gains.
42 /// Gains are read in from an ascii file, with the format :
44 ///---------------------------------------------------------------------------
46 ///BUS_PATCH MANU CHANNEL a0 a1 thres Qual
48 ///---------------------------------------------------------------------------
50 /// \author L. Aphecetche
52 //-----------------------------------------------------------------------------
55 ClassImp(AliMUONGainSubprocessor)
58 //_____________________________________________________________________________
59 AliMUONGainSubprocessor::AliMUONGainSubprocessor(AliMUONPreprocessor* master)
60 : AliMUONVSubprocessor(master,
62 "Upload MUON Tracker Gains to OCDB"),
70 //_____________________________________________________________________________
71 AliMUONGainSubprocessor::~AliMUONGainSubprocessor()
77 //_____________________________________________________________________________
79 AliMUONGainSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
81 /// When starting a new run, reads in the Gains ASCII files.
83 const Int_t kSystem = AliMUONPreprocessor::kDAQ;
84 const char* kId = "GAINS";
90 fGains = new AliMUON2DMap(kTRUE);
92 Master()->Log(Form("Reading Gain files for Run %d startTime %u endTime %u",
93 run,startTime,endTime));
95 TList* sources = Master()->GetFileSources(kSystem,kId);
100 while ( ( o = static_cast<TObjString*>(next()) ) )
102 TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
103 Int_t ok = ReadFile(fileName.Data());
108 else if ( ok == AliMUONTrackerIO::kDummyFile )
110 // not an interesting file.
126 Master()->Log("Failed to read any Gains");
135 //_____________________________________________________________________________
137 AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/)
139 /// Store the Gains into the CDB
143 // this is the only reason to fail for the moment : getting no Gain
144 // at all, except if the input file was a dummy one
155 AliMUON2DStoreValidator validator;
157 Master()->Log("Validating");
159 TObjArray* chambers = validator.Validate(*fGains);
163 // we hereby report what's missing, but this is not a reason to fail ;-)
164 // the only reason to fail would be if we got no Gain at all
166 lines.SetOwner(kTRUE);
168 validator.Report(lines,*chambers);
173 while ( ( line = static_cast<TObjString*>(next()) ) )
175 Master()->Log(line->String().Data());
179 Master()->Log("Storing Gains");
181 AliCDBMetaData metaData;
182 metaData.SetBeamPeriod(0);
183 metaData.SetResponsible("MUON TRK");
184 metaData.SetComment(Form("Computed by AliMUONGainSubprocessor "
185 "$Id$ ; %s",fComment.Data()));
187 Bool_t validToInfinity = kTRUE;
188 Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity);
190 return ( result != kTRUE ); // return 0 if everything is ok
193 //_____________________________________________________________________________
195 AliMUONGainSubprocessor::ReadFile(const char* filename)
197 /// Read the Gains from an ASCII file.
198 /// Format of that file is one line per channel :
199 ///-------------------------------------------------------------------------
200 ///BUS_PATCH MANU CHANNEL a0 a1 thres Qual
201 ///-------------------------------------------------------------------------
203 /// Return kFALSE if reading was not successfull.
206 TString sFilename(gSystem->ExpandPathName(filename));
208 Master()->Log(Form("Reading %s",sFilename.Data()));
210 Int_t n = AliMUONTrackerIO::ReadGains(sFilename.Data(),*fGains,fComment);
214 case AliMUONTrackerIO::kCannotOpenFile:
215 Master()->Log(Form("Could not open %s",sFilename.Data()));
217 case AliMUONTrackerIO::kFormatError:
218 Master()->Log(Form("File %s is not of the expected format",sFilename.Data()));
220 case AliMUONTrackerIO::kDummyFile:
221 Master()->Log(Form("File %s is a dummy one. That's fine. I won't do anything then ;-)",sFilename.Data()));