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 %ld endTime %ld",
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.
124 Master()->Log("Failed to read any Gains");
132 //_____________________________________________________________________________
134 AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/)
136 /// Store the Gains into the CDB
140 // this is the only reason to fail for the moment : getting no Gain
141 // at all, except if the input file was a dummy one
152 AliMUON2DStoreValidator validator;
154 Master()->Log("Validating");
156 TObjArray* chambers = validator.Validate(*fGains);
160 // we hereby report what's missing, but this is not a reason to fail ;-)
161 // the only reason to fail would be if we got no Gain at all
163 lines.SetOwner(kTRUE);
165 validator.Report(lines,*chambers);
170 while ( ( line = static_cast<TObjString*>(next()) ) )
172 Master()->Log(line->String().Data());
176 Master()->Log("Storing Gains");
178 AliCDBMetaData metaData;
179 metaData.SetBeamPeriod(0);
180 metaData.SetResponsible("MUON TRK");
181 metaData.SetComment(Form("Computed by AliMUONGainSubprocessor "
182 "$Id$ ; %s",fComment.Data()));
184 Bool_t validToInfinity = kTRUE;
185 Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity);
187 return ( result != kTRUE ); // return 0 if everything is ok
190 //_____________________________________________________________________________
192 AliMUONGainSubprocessor::ReadFile(const char* filename)
194 /// Read the Gains from an ASCII file.
195 /// Format of that file is one line per channel :
196 ///-------------------------------------------------------------------------
197 ///BUS_PATCH MANU CHANNEL a0 a1 thres Qual
198 ///-------------------------------------------------------------------------
200 /// Return kFALSE if reading was not successfull.
203 TString sFilename(gSystem->ExpandPathName(filename));
205 Master()->Log(Form("Reading %s",sFilename.Data()));
207 Int_t n = AliMUONTrackerIO::ReadGains(sFilename.Data(),*fGains,fComment);
211 case AliMUONTrackerIO::kCannotOpenFile:
212 Master()->Log(Form("Could not open %s",sFilename.Data()));
214 case AliMUONTrackerIO::kFormatError:
215 Master()->Log(Form("File %s is not of the expected format",sFilename.Data()));
217 case AliMUONTrackerIO::kDummyFile:
218 Master()->Log(Form("File %s is a dummy one. That's fine. I won't do anything then ;-)",sFilename.Data()));