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 "AliMUONPedestalSubprocessor.h"
20 #include "AliCDBMetaData.h"
22 #include "AliMUON2DMap.h"
23 #include "AliMUON2DStoreValidator.h"
24 #include "AliMUONCalibParamNF.h"
25 #include "AliMUONPreprocessor.h"
26 #include "AliMUONTrackerIO.h"
27 #include "AliMpConstants.h"
28 #include "AliMpDDLStore.h"
29 #include "TObjString.h"
30 #include <Riostream.h>
32 #include <TObjString.h>
36 //-----------------------------------------------------------------------------
37 /// \class AliMUONPedestalSubprocessor
39 /// Implementation of AliMUONVSubprocessor class to deal with MUON TRK pedestals.
41 /// Pedestals are read in from an ascii file, with the format : \n
42 ///---------------------------------------------------------------------------\n
43 /// BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA \n
44 ///---------------------------------------------------------------------------\n
46 /// \author L. Aphecetche
47 //-----------------------------------------------------------------------------
50 ClassImp(AliMUONPedestalSubprocessor)
53 //_____________________________________________________________________________
54 AliMUONPedestalSubprocessor::AliMUONPedestalSubprocessor(AliMUONPreprocessor* master)
55 : AliMUONVSubprocessor(master,
57 "Upload MUON Tracker pedestals to OCDB"),
63 //_____________________________________________________________________________
64 AliMUONPedestalSubprocessor::~AliMUONPedestalSubprocessor()
70 //_____________________________________________________________________________
72 AliMUONPedestalSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
74 /// When starting a new run, reads in the pedestals ASCII files.
76 const Int_t kSystem = AliMUONPreprocessor::kDAQ;
77 const char* kId = "PEDESTALS";
80 fPedestals = new AliMUON2DMap(kTRUE);
82 Master()->Log(Form("Reading pedestal files for Run %d startTime %ld endTime %ld",
83 run,startTime,endTime));
85 TList* sources = Master()->GetFileSources(kSystem,kId);
90 while ( ( o = static_cast<TObjString*>(next()) ) )
92 TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
93 Int_t ok = ReadFile(fileName.Data());
102 Master()->Log("Failed to read any pedestals");
109 //_____________________________________________________________________________
111 AliMUONPedestalSubprocessor::Process(TMap* /*dcsAliasMap*/)
113 /// Store the pedestals into the CDB
117 // this is the only reason to fail for the moment : getting no pedestal
122 AliMUON2DStoreValidator validator;
124 Master()->Log("Validating");
126 TObjArray* chambers = validator.Validate(*fPedestals);
130 // we hereby report what's missing, but this is not a reason to fail ;-)
131 // the only reason to fail would be if we got no pedestal at all
133 lines.SetOwner(kTRUE);
135 validator.Report(lines,*chambers);
140 while ( ( line = static_cast<TObjString*>(next()) ) )
142 Master()->Log(line->String().Data());
146 Master()->Log("Storing pedestals");
148 AliCDBMetaData metaData;
149 metaData.SetBeamPeriod(0);
150 metaData.SetResponsible("MUON TRK");
151 TString comment("Computed by AliMUONPedestalSubprocessor $Id$");
152 comment.ReplaceAll("$","");
153 metaData.SetComment(comment.Data());
155 Bool_t validToInfinity = kTRUE;
156 Bool_t result = Master()->Store("Calib", "Pedestals", fPedestals, &metaData, 0, validToInfinity);
158 return ( result != kTRUE ); // return 0 if everything is ok.
161 //_____________________________________________________________________________
163 AliMUONPedestalSubprocessor::ReadFile(const char* filename)
165 /// Read the pedestals from an ASCII file. \n
166 /// Format of that file is one line per channel : \n
167 ///-------------------------------------------------------------------------\n
168 /// BUS_PATCH MANU_ADDR CHANNEL MEAN SIGMA \n
169 ///-------------------------------------------------------------------------\n
171 /// Return kFALSE if reading was not successfull. \n
174 TString sFilename(gSystem->ExpandPathName(filename));
176 Master()->Log(Form("Reading %s",sFilename.Data()));
178 Int_t n = AliMUONTrackerIO::ReadPedestals(sFilename.Data(),*fPedestals);
183 Master()->Log(Form("Could not open %s",sFilename.Data()));
191 //_____________________________________________________________________________
193 AliMUONPedestalSubprocessor::Print(Option_t* opt) const
196 if (fPedestals) fPedestals->Print("",opt);