AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONPreprocessor.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 
18 #include "AliMUONPreprocessor.h"
19 
20 #include "AliCDBEntry.h"
21 #include "AliLog.h"
22 #include "AliMUONGMSSubprocessor.h"
23 #include "AliMUONHVSubprocessor.h"
25 #include "AliMpCDB.h"
26 #include "AliMpDDLStore.h"
27 #include "AliMpDataMap.h"
28 #include "AliMpDataStreams.h"
29 #include "AliMpSegmentation.h"
30 #include "AliShuttleInterface.h"
31 #include "Riostream.h"
32 #include "TObjArray.h"
33 
34 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
44 
48 
49 //_____________________________________________________________________________
50 AliMUONPreprocessor::AliMUONPreprocessor(const char* detName, AliShuttleInterface* shuttle)
51 : AliPreprocessor(detName, shuttle),
52  fIsValid(kFALSE),
53  fIsApplicable(kTRUE),
54  fSubprocessors(new TObjArray()),
55  fProcessDCS(kFALSE)
56 {
58 }
59 
60 //_____________________________________________________________________________
62 {
64  delete fSubprocessors;
65 }
66 
67 //_____________________________________________________________________________
68 void
70 {
72  fSubprocessors->Clear();
73  fProcessDCS = kFALSE;
74  fIsValid = kFALSE;
75  fIsApplicable = kTRUE;
76 }
77 
78 //_____________________________________________________________________________
79 void
81 {
83  fSubprocessors->Add(sub);
84  if ( processDCS == kTRUE ) fProcessDCS = processDCS;
85 }
86 
87 //_____________________________________________________________________________
88 void
89 AliMUONPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
90 {
92 
93  // Delete previous mapping
95 
96  if ( ! IsApplicable() ) {
97  Log(Form("WARNING-RunType=%s is not one I should handle.",GetRunType()));
98  return;
99  }
100 
101  // Load mapping from CDB for this run
102  AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "MappingData");
103  if (!cdbEntry)
104  {
105  Log("Could not get MappingData from OCDB !");
106  fIsValid = kFALSE;
107  }
108  else
109  {
110  AliMpDataMap* dataMap = dynamic_cast<AliMpDataMap*>(cdbEntry->GetObject());
111  if (!dataMap)
112  {
113  Log("DataMap is not of the expected type. That is bad...");
114  fIsValid = kFALSE;
115  }
116  else
117  {
118  AliMpDataStreams dataStreams(dataMap);
119  AliMpDDLStore::ReadData(dataStreams);
120  }
121  }
122 
123  Int_t nok(0);
124 
125  if (IsValid())
126  {
127  // loop over subtasks and initialize them
128  for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
129  {
130  Bool_t ok = Subprocessor(i)->Initialize(run,startTime,endTime);
131  if (ok) ++nok;
132  }
133  if (nok != fSubprocessors->GetLast()+1) fIsValid = kFALSE;
134  }
135  Log(Form("Initialize was %s",( IsValid() ? "fine" : "NOT OK")));
136 }
137 
138 //_____________________________________________________________________________
139 UInt_t
141 {
143 
144  if (!IsValid())
145  {
146  Log("Will not run as not properly initialized");
147  return 99;
148  }
149 
150  if (!IsApplicable())
151  {
152  Log("Nothing to do for me");
153  return 0;
154  }
155 
156  UInt_t rv(0);
157 
158  for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
159  {
160  rv += Subprocessor(i)->Process(dcsAliasMap);
161  }
162 
163  return rv;
164 }
165 
166 //_____________________________________________________________________________
167 void
168 AliMUONPreprocessor::Print(Option_t* opt) const
169 {
171  cout << "<AliMUONPreprocessor> subprocessors :" << endl;
172  for ( Int_t i=0; i <= fSubprocessors->GetLast(); ++i )
173  {
174  Subprocessor(i)->Print(opt);
175  }
176 }
177 
178 //_____________________________________________________________________________
181 {
183  if ( i >= 0 && i <= fSubprocessors->GetLast() )
184  {
185  return static_cast<AliMUONVSubprocessor*>(fSubprocessors->At(i));
186  }
187  return 0x0;
188 }
Bool_t IsApplicable()
Whether we should do something or not.
AliCDBEntry * GetFromOCDB(const char *pathLevel2, const char *pathLevel3)
Publish AliPreprocessor::GetFromOCDB function.
#define TObjArray
Bool_t IsValid() const
Whether we can be used (e.g. whether we were properly initialized)
AliMUONVSubprocessor * Subprocessor(Int_t i) const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
virtual void Print(Option_t *opt="") const
virtual Bool_t Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
Base class for a shuttle sub-task for MUON (either TRK or TRG)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
TObject class containing a map of strings to strings.
Definition: AliMpDataMap.h:21
void Add(AliMUONVSubprocessor *subProcessor, Bool_t processDCS=kFALSE)
static AliMpDDLStore * ReadData(const AliMpDataStreams &dataStreams, Bool_t warn=true)
virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
void Log(const char *message)
Publish AliPreprocessor::Log function.
Bool_t fIsValid
! whether we were correctly initialized
Bool_t fIsApplicable
! whether we have something to do
static void UnloadAll()
Definition: AliMpCDB.cxx:520
Bool_t fProcessDCS
! whether the current subprocessor(s) needs DCS or not
TObjArray * fSubprocessors
! sub processors to execute
Shuttle preprocessor for MUON subsystems (TRK and TRG)
virtual UInt_t Process(TMap *dcsAliasMap)=0
Process this sub-task.
virtual UInt_t Process(TMap *dcsAliasMap)
Mapping data streams provider.