]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPreprocessor.cxx
add un-use functionality to clusters
[u/mrichter/AliRoot.git] / MUON / AliMUONPreprocessor.cxx
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"
24 #include "AliMUONPedestalSubprocessor.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 //-----------------------------------------------------------------------------
35 /// \class AliMUONPreprocessor
36 ///
37 /// Shuttle preprocessor for MUON subsystems (TRK and TRG)
38 /// 
39 /// It's simply a manager class that deals with a list of sub-tasks 
40 /// (of type AliMUONVSubprocessor).
41 ///
42 /// \author Laurent Aphecetche
43 //-----------------------------------------------------------------------------
44
45 /// \cond CLASSIMP
46 ClassImp(AliMUONPreprocessor)
47 /// \endcond
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 {
57   /// ctor
58 }
59
60 //_____________________________________________________________________________
61 AliMUONPreprocessor::~AliMUONPreprocessor()
62 {
63   /// dtor
64   delete fSubprocessors;
65 }
66
67 //_____________________________________________________________________________
68 void
69 AliMUONPreprocessor::ClearSubprocessors()
70 {
71   /// Empty our subprocessor list
72   fSubprocessors->Clear();
73   fProcessDCS = kFALSE;
74   fIsValid = kFALSE;
75   fIsApplicable = kTRUE;
76 }
77
78 //_____________________________________________________________________________
79 void
80 AliMUONPreprocessor::Add(AliMUONVSubprocessor* sub, Bool_t processDCS)
81 {
82   /// Add a subprocessor to our list of workers
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 {
91   /// Load mapping and initialize subtasks  
92
93   // Delete previous mapping
94   AliMpCDB::UnloadAll();
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   if (IsValid())
124   {
125     // loop over subtasks and initialize them
126     for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
127     {
128       Subprocessor(i)->Initialize(run,startTime,endTime);
129     }
130   }
131   Log(Form("Initialize was %s",( IsValid() ? "fine" : "NOT OK")));
132 }
133
134 //_____________________________________________________________________________
135 UInt_t
136 AliMUONPreprocessor::Process(TMap* dcsAliasMap)
137 {
138   /// loop over subtasks to make them work
139   
140   if (!IsValid())
141   {
142     Log("Will not run as not properly initialized");
143     return 99;
144   }
145   
146   if (!IsApplicable())
147   {
148     Log("Nothing to do for me");
149     return 0;
150   }
151   
152   UInt_t rv(0);
153   
154   for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
155   {
156     rv += Subprocessor(i)->Process(dcsAliasMap);
157   }
158   
159   return rv;
160 }
161
162 //_____________________________________________________________________________
163 void
164 AliMUONPreprocessor::Print(Option_t* opt) const
165 {
166   /// output to screen
167   cout << "<AliMUONPreprocessor> subprocessors :" << endl;
168   for ( Int_t i=0; i <= fSubprocessors->GetLast(); ++i )
169   {
170     Subprocessor(i)->Print(opt);
171   }
172 }
173
174 //_____________________________________________________________________________
175 AliMUONVSubprocessor*
176 AliMUONPreprocessor::Subprocessor(Int_t i) const
177 {
178   /// return i-th subprocessor
179   if ( i >= 0 && i <= fSubprocessors->GetLast() )
180   {
181     return static_cast<AliMUONVSubprocessor*>(fSubprocessors->At(i));
182   }
183   return 0x0;
184 }