AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONGainSubprocessor.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15 
16 // $Id$
17 
19 
20 #include "AliCDBMetaData.h"
21 #include "AliLog.h"
22 #include "AliMUON2DMap.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>
31 #include <TList.h>
32 #include <TObjString.h>
33 #include <TObjString.h>
34 #include <TSystem.h>
35 #include <sstream>
36 
37 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
53 
57 
58 //_____________________________________________________________________________
60 : AliMUONVSubprocessor(master,
61  "Gains",
62  "Upload MUON Tracker Gains to OCDB"),
63 fGains(0x0),
64 fSkip(kFALSE),
65 fComment("")
66 {
68 }
69 
70 //_____________________________________________________________________________
72 {
74  delete fGains;
75 }
76 
77 //_____________________________________________________________________________
78 Bool_t
79 AliMUONGainSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
80 {
82 
83  const Int_t kSystem = AliMUONPreprocessor::kDAQ;
84  const char* kId = "GAINS";
85 
86  fComment = "";
87  fSkip = kFALSE;
88 
89  delete fGains;
90  fGains = new AliMUON2DMap(kTRUE);
91 
92  Master()->Log(Form("Reading Gain files for Run %d startTime %u endTime %u",
93  run,startTime,endTime));
94 
95  TList* sources = Master()->GetFileSources(kSystem,kId);
96  TIter next(sources);
97  TObjString* o(0x0);
98  Int_t n(0);
99 
100  while ( ( o = static_cast<TObjString*>(next()) ) )
101  {
102  TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
103  Int_t ok = ReadFile(fileName.Data());
104  if (ok>0)
105  {
106  n += ok;
107  }
108  else if ( ok == AliMUONTrackerIO::kDummyFile )
109  {
110  // not an interesting file.
111  fSkip = kTRUE;
112  break;
113  }
114  }
115 
116  delete sources;
117 
118  if ( fSkip )
119  {
120  delete fGains;
121  fGains = 0x0;
122  }
123 
124  if (!n && !fSkip)
125  {
126  Master()->Log("Failed to read any Gains");
127  delete fGains;
128  fGains = 0x0;
129  return kFALSE;
130  }
131 
132  return kTRUE;
133 }
134 
135 //_____________________________________________________________________________
136 UInt_t
137 AliMUONGainSubprocessor::Process(TMap* /*dcsAliasMap*/)
138 {
140 
141  if (!fGains)
142  {
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
145  if ( fSkip )
146  {
147  return 0;
148  }
149  else
150  {
151  return 1;
152  }
153  }
154 
155  AliMUON2DStoreValidator validator;
156 
157  Master()->Log("Validating");
158 
159  TObjArray* chambers = validator.Validate(*fGains);
160 
161  if (chambers)
162  {
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
165  TList lines;
166  lines.SetOwner(kTRUE);
167 
168  validator.Report(lines,*chambers);
169 
170  TIter next(&lines);
171  TObjString* line;
172 
173  while ( ( line = static_cast<TObjString*>(next()) ) )
174  {
175  Master()->Log(line->String().Data());
176  }
177  }
178 
179  Master()->Log("Storing Gains");
180 
181  AliCDBMetaData metaData;
182  metaData.SetBeamPeriod(0);
183  metaData.SetResponsible("MUON TRK");
184  metaData.SetComment(Form("Computed by AliMUONGainSubprocessor "
185  "$Id$ ; %s",fComment.Data()));
186 
187  Bool_t validToInfinity = kTRUE;
188  Bool_t result = Master()->Store("Calib", "Gains", fGains, &metaData, 0, validToInfinity);
189 
190  return ( result != kTRUE ); // return 0 if everything is ok
191 }
192 
193 //_____________________________________________________________________________
194 Int_t
196 {
205 
206  TString sFilename(gSystem->ExpandPathName(filename));
207 
208  Master()->Log(Form("Reading %s",sFilename.Data()));
209 
210  Int_t n = AliMUONTrackerIO::ReadGains(sFilename.Data(),*fGains,fComment);
211 
212  switch (n)
213  {
215  Master()->Log(Form("Could not open %s",sFilename.Data()));
216  break;
218  Master()->Log(Form("File %s is not of the expected format",sFilename.Data()));
219  break;
221  Master()->Log(Form("File %s is a dummy one. That's fine. I won't do anything then ;-)",sFilename.Data()));
222  break;
223  default:
224  break;
225  }
226 
227  return n;
228 }
AliMUONVStore * fGains
! Gains for the MUON TRK
AliMUONPreprocessor * Master() const
Return the pointer to our master.
#define TObjArray
file is a dummy one (e.g. some intermediate gain files from the DA)
Bool_t fSkip
! whether we should skip this run (because it's dummy)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TString fComment
! comment for OCDB entry
Base class for a shuttle sub-task for MUON (either TRK or TRG)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
Int_t ReadFile(const char *filename)
static Int_t ReadGains(const char *filename, AliMUONVStore &gainStore, TString &comment)
UInt_t Process(TMap *dcsAliasMap)
Process this sub-task.
void Log(const char *message)
Publish AliPreprocessor::Log function.
TObjArray * Validate(const AliMUONVStore &store, Float_t invalidFloatValue, AliMUONVStore *config=0x0)
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
cannot open given file
void Report(TList &lines) const
Reports what is missing, trying to be as concise as possible.
TList * GetFileSources(Int_t system, const char *id)
Publish AliPreprocessor::GetFileSources function.
Bool_t Store(const char *pathLevel2, const char *pathLevel3, TObject *object, AliCDBMetaData *metaData, Int_t validityStart=0, Bool_t validityInfinite=kFALSE)
Publish AliPreprocessor::Store function.
Bool_t Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
Implementation of AliMUONVSubprocessor for MUON TRK Gains.
Shuttle preprocessor for MUON subsystems (TRK and TRG)
Determine which channels, manus, DEs, stations are missing from a 2DStore.