AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONConfigSubprocessor.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 "AliCDBEntry.h"
22 #include "AliDAQ.h"
23 #include "AliLog.h"
24 #include "AliMUON2DMap.h"
26 #include "AliMUONCalibParamNF.h"
27 #include "AliMUONPreprocessor.h"
28 #include "AliMUONTrackerIO.h"
29 #include "AliMpConstants.h"
30 #include "AliMpDDLStore.h"
31 #include "TObjString.h"
32 #include <Riostream.h>
33 #include <TList.h>
34 #include <TObjString.h>
35 #include <TSystem.h>
36 #include <sstream>
37 
38 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
50 
54 
55 //_____________________________________________________________________________
57 : AliMUONVSubprocessor(master,
58  "Config",
59  "Upload MUON Tracker readout configuration to OCDB"),
60 fConfig(0x0),
61 fConfigChanged(kFALSE)
62 {
64 }
65 
66 //_____________________________________________________________________________
68 {
70  delete fConfig;
71 }
72 
73 //_____________________________________________________________________________
74 Bool_t
76 {
79 
80  AliCDBEntry* entry = Master()->GetFromOCDB("Calib","Config");
81  if (!entry)
82  {
83  AliError("Could not get MUON/Calib/Config entry for current run ! That's not OK !");
84  return kTRUE;
85  }
86  AliMUONVStore* oldConfig = dynamic_cast<AliMUONVStore*>(entry->GetObject());
87  if (!oldConfig)
88  {
89  AliError("Could not get MUON/Calib/Config object for current run (wrong type ?) ! That's not OK !");
90  return kTRUE;
91  }
92 
93  if ( oldConfig->GetSize() != newConfig.GetSize() )
94  {
95  return kTRUE;
96  }
97 
98  TIter next(oldConfig->CreateIterator());
99  AliMUONVCalibParam* old;
100 
101  while ( ( old = static_cast<AliMUONVCalibParam*>(next()) ) )
102  {
103  Int_t detElemId = old->ID0();
104  Int_t manuId = old->ID1();
105 
106  if ( ! newConfig.FindObject(detElemId,manuId) )
107  {
108  // not found in new. Configurations are different. Return right now.
109  return kTRUE;
110  }
111  }
112 
113  // all tests OK. Configuration has not changed.
114  return kFALSE;
115 }
116 
117 
118 //_____________________________________________________________________________
119 Bool_t
120 AliMUONConfigSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
121 {
123 
124  const Int_t kSystem = AliMUONPreprocessor::kDAQ;
125  const char* kIdConf = "CONFIG";
126 
127  delete fConfig;
128  fConfig = new AliMUON2DMap(kTRUE);
129 
130  TList* sources = Master()->GetFileSources(kSystem,kIdConf);
131  TIter nextConf(sources);
132  Int_t nconf(0);
133  Int_t nconfFiles(0);
134  TObjString* o;
135 
136  while ( ( o = static_cast<TObjString*>(nextConf()) ) )
137  {
138  TString fileName(Master()->GetFile(kSystem,kIdConf,o->GetName()));
139  Int_t ok = ReadConfigFile(fileName.Data());
140  if (ok>0)
141  {
142  nconf += ok;
143  ++nconfFiles;
144  }
145  }
146 
147  delete sources;
148 
149  if ( nconfFiles == 0 )
150  {
151  delete fConfig;
152  fConfig = 0x0;
153  fConfigChanged = kFALSE;
154  AliInfo("No configuration files found for this run. That might be fine. Moving on...");
155  return kTRUE;
156  }
157 
159 
160  if (!fConfigChanged)
161  {
162  AliInfo("Will not upload the Configuration as it has not changed");
163  }
164 
165  return kTRUE;
166 }
167 
168 //_____________________________________________________________________________
169 UInt_t
171 {
174 
175  if (!fConfig)
176  {
177  return 0;
178  }
179 
180  if ( !fConfigChanged )
181  {
182  return 0;
183  }
184 
185  Master()->Log("Storing readout configuration, as it has changed");
186 
187  AliCDBMetaData metaData;
188  metaData.SetBeamPeriod(0);
189  metaData.SetResponsible("MUON TRK");
190  TString comment("Computed by AliMUONConfigSubprocessor $Id$");
191  comment.ReplaceAll("$","");
192  metaData.SetComment(comment.Data());
193 
194  Bool_t validToInfinity = kFALSE;
195  Bool_t result = Master()->Store("Calib", "Config", fConfig, &metaData, 0, validToInfinity);
196  return ( result != kTRUE ); // return 0 if everything is ok.
197 }
198 
199 //_____________________________________________________________________________
200 Int_t
202 {
208 
209  TString sFilename(gSystem->ExpandPathName(filename));
210 
211  Master()->Log(Form("Reading %s",sFilename.Data()));
212 
213  Int_t n = AliMUONTrackerIO::ReadConfig(sFilename.Data(),*fConfig);
214 
215  switch (n)
216  {
217  case -1:
218  Master()->Log(Form("Could not open %s",sFilename.Data()));
219  break;
220  }
221 
222  return n;
223 }
224 
225 
226 //_____________________________________________________________________________
227 void
229 {
231  if (fConfig) fConfig->Print("",opt);
232 }
233 
UInt_t Process(TMap *dcsAliasMap)
Process this sub-task.
virtual TIterator * CreateIterator() const =0
Return an iterator to loop over the whole store.
AliCDBEntry * GetFromOCDB(const char *pathLevel2, const char *pathLevel3)
Publish AliPreprocessor::GetFromOCDB function.
AliMUONPreprocessor * Master() const
Return the pointer to our master.
virtual void Print(Option_t *wildcard="") const
Print all objects whose name matches wildcard.
Int_t ReadConfigFile(const char *filename)
static TString comment
Definition: ConfigCosmic.C:131
virtual Int_t GetSize() const =0
The number of objects stored.
void Config()
Definition: ConfigKr.C:51
Bool_t HasConfigChanged(const AliMUONVStore &newConfig) const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Container of calibration values for a given number of channels.
Implementation of AliMUONVSubprocessor for MUON TRK config.
Base class for a shuttle sub-task for MUON (either TRK or TRG)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
AliMUONVStore * fConfig
! Configuration (i.e. list of (buspatch,manu)) for the MUON TRK
virtual Int_t ID0() const
First id of this object.
void Print(Option_t *opt="") const
void Log(const char *message)
Publish AliPreprocessor::Log function.
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
TList * GetFileSources(Int_t system, const char *id)
Publish AliPreprocessor::GetFileSources function.
Bool_t Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
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.
Shuttle preprocessor for MUON subsystems (TRK and TRG)
static Int_t ReadConfig(const char *filename, AliMUONVStore &confStore)
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
Bool_t fConfigChanged
! flag to trigger the saving of the configuration
virtual TObject * FindObject(const char *name) const
Find an object by name.