Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / MUON / AliMUONHVSubprocessor.cxx
CommitLineData
45824ef1 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
2ab3623b 16// $Id$
3d1463c8 17
18//-----------------------------------------------------------------------------
45824ef1 19/// \class AliMUONHVSubprocessor
20///
21/// A subprocessor to read HV values for one run
22///
23/// It simply creates a copy of the dcsAliasMap w/o information
24/// from the MUON TRK, and dumps this copy into the CDB
25///
78649106 26/// \author Laurent Aphecetche, Subatech
3d1463c8 27//-----------------------------------------------------------------------------
45824ef1 28
29#include "AliMUONHVSubprocessor.h"
45824ef1 30#include "AliMUONPreprocessor.h"
31
32#include "AliMpDEIterator.h"
33#include "AliMpDEManager.h"
49e110ec 34#include "AliMpDCSNamer.h"
45824ef1 35
36#include "AliCDBMetaData.h"
37#include "AliLog.h"
38
39#include "Riostream.h"
40#include "TMap.h"
41#include "TObjString.h"
42
43/// \cond CLASSIMP
44ClassImp(AliMUONHVSubprocessor)
45/// \endcond
46
47//_____________________________________________________________________________
39d66ea2 48AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master, Bool_t includeHVcurrents)
45824ef1 49: AliMUONVSubprocessor(master,
50 "HV",
39d66ea2 51 "Get MUON Tracker HV values from DCS"), fIncludeHVCurrents(includeHVcurrents)
45824ef1 52{
53 /// ctor
54}
55
56//_____________________________________________________________________________
57AliMUONHVSubprocessor::~AliMUONHVSubprocessor()
58{
59 /// dtor
60}
61
62//_____________________________________________________________________________
45824ef1 63UInt_t
64AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
65{
66 /// Make another alias map from dcsAliasMap, considering only MUON TRK aliases.
67
68 TMap hv;
69 hv.SetOwner(kTRUE);
70
49e110ec 71 AliMpDCSNamer hvNamer("TRACKER");
45824ef1 72
73 AliMpDEIterator deIt;
74
75 deIt.First();
76
77 TObjArray aliases;
78 aliases.SetOwner(kTRUE);
79
80 // we first generate a list of expected MCH DCS aliases we'll then look for
81
82 while ( !deIt.IsDone() )
83 {
84 Int_t detElemId = deIt.CurrentDEId();
85
86 switch ( AliMpDEManager::GetStationType(detElemId) )
87 {
4e51cfd2 88 case AliMp::kStation12:
45824ef1 89 {
90 for ( int i = 0; i <3; ++i)
91 {
1d5cf0f2 92 aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i)));
39d66ea2 93 if ( fIncludeHVCurrents )
94 {
95 aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i,AliMpDCSNamer::kDCSI)));
96 }
45824ef1 97 }
98 }
99 break;
100 case AliMp::kStation345:
101 {
1d5cf0f2 102 aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId)));
39d66ea2 103 if ( fIncludeHVCurrents )
104 {
105 aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,0,AliMpDCSNamer::kDCSI)));
106 }
45824ef1 107 for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
108 {
1d5cf0f2 109 aliases.Add(new TObjString(hvNamer.DCSSwitchAliasName(detElemId,i)));
45824ef1 110 }
111 }
112 break;
113 default:
114 break;
115 };
116
117 deIt.Next();
118 }
119
120 TIter next(&aliases);
121 TObjString* alias;
c75c6131 122 Bool_t kNoAliases(kTRUE);
123 Int_t aliasNotFound(0);
124 Int_t valueNotFound(0);
45824ef1 125
d0275990 126 TObjArray temporaryOut; // due to a bug in PVSS some iMon aliases cause problem
127 // we remove them for the moment.
128 temporaryOut.SetOwner(kTRUE);
129
130 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat10.actual.iMon"));
131 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat11.actual.iMon"));
132 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat12.actual.iMon"));
133 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat10.actual.iMon"));
134 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat11.actual.iMon"));
135 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat12.actual.iMon"));
136 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat10.actual.iMon"));
137 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat11.actual.iMon"));
138 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat12.actual.iMon"));
139 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat10.actual.iMon"));
140 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat11.actual.iMon"));
141 temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat12.actual.iMon"));
142 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat10.actual.iMon"));
143 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat11.actual.iMon"));
144 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat12.actual.iMon"));
145 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat10.actual.iMon"));
146 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat11.actual.iMon"));
147 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat12.actual.iMon"));
148 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat10.actual.iMon"));
149 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat11.actual.iMon"));
150 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat12.actual.iMon"));
151 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat10.actual.iMon"));
152 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat11.actual.iMon"));
153 temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat12.actual.iMon"));
154
45824ef1 155 while ( ( alias = static_cast<TObjString*>(next()) ) )
156 {
157 TString aliasName(alias->String());
d0275990 158
159 if ( temporaryOut.FindObject(alias->String().Data() ) )
160 {
161 // skip problematic aliases
162 continue;
163 }
164
45824ef1 165 TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
166 if (!hvPair)
167 {
c75c6131 168 ++aliasNotFound;
45824ef1 169 }
170 else
171 {
bec1918d 172 kNoAliases = kFALSE;
37f5fa19 173 TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
45824ef1 174 if (!values)
175 {
c75c6131 176 ++valueNotFound;
45824ef1 177 }
178 else
179 {
39d66ea2 180 RemoveValuesOutsideRun(values);
45824ef1 181 hv.Add(new TObjString(aliasName.Data()),values);
182 }
183 }
c75c6131 184 }
185
186 if ( kNoAliases )
187 {
188 Master()->Log("ERROR : no DCS values found");
d489129d 189 return 1;
c75c6131 190 }
191
192 if ( aliasNotFound )
193 {
194 Master()->Log(Form("WARNING %d aliases not found",aliasNotFound));
195 }
196
197 if ( valueNotFound )
198 {
199 Master()->Log(Form("WARNING %d values not found",valueNotFound));
45824ef1 200 }
201
c75c6131 202 Master()->Log("INFO Aliases successfully read in");
d3f57575 203
45824ef1 204 AliCDBMetaData metaData;
205 metaData.SetBeamPeriod(0);
206 metaData.SetResponsible("MUON TRK");
207 metaData.SetComment("Computed by AliMUONHVSubprocessor $Id$");
208
209 Bool_t validToInfinity(kFALSE);
210
d489129d 211 Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
45824ef1 212
d489129d 213 return ( result != kTRUE); // return 0 if everything is ok
45824ef1 214}
215