Reverting back the TPC set branch (Marian)
[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"
93d8751c 34#include "AliMpHVNamer.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//_____________________________________________________________________________
48AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master)
49: AliMUONVSubprocessor(master,
50 "HV",
51 "Get MUON Tracker HV values from DCS")
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
93d8751c 71 AliMpHVNamer hvNamer;
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 {
88 case AliMp::kStation1:
89 case AliMp::kStation2:
90 {
91 for ( int i = 0; i <3; ++i)
92 {
93 aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId,i)));
94 }
95 }
96 break;
97 case AliMp::kStation345:
98 {
99 aliases.Add(new TObjString(hvNamer.DCSHVChannelName(detElemId)));
100 for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
101 {
102 aliases.Add(new TObjString(hvNamer.DCSHVSwitchName(detElemId,i)));
103 }
104 }
105 break;
106 default:
107 break;
108 };
109
110 deIt.Next();
111 }
112
113 TIter next(&aliases);
114 TObjString* alias;
c75c6131 115 Bool_t kNoAliases(kTRUE);
116 Int_t aliasNotFound(0);
117 Int_t valueNotFound(0);
45824ef1 118
119 while ( ( alias = static_cast<TObjString*>(next()) ) )
120 {
121 TString aliasName(alias->String());
122 TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
123 if (!hvPair)
124 {
c75c6131 125 ++aliasNotFound;
45824ef1 126 }
127 else
128 {
bec1918d 129 kNoAliases = kFALSE;
37f5fa19 130 TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
45824ef1 131 if (!values)
132 {
c75c6131 133 ++valueNotFound;
45824ef1 134 }
135 else
136 {
137 //FIXME : should insure here that values are only the ones within run
138 //limits (startTime<timestamp<endTime)
139 hv.Add(new TObjString(aliasName.Data()),values);
140 }
141 }
c75c6131 142 }
143
144 if ( kNoAliases )
145 {
146 Master()->Log("ERROR : no DCS values found");
d489129d 147 return 1;
c75c6131 148 }
149
150 if ( aliasNotFound )
151 {
152 Master()->Log(Form("WARNING %d aliases not found",aliasNotFound));
153 }
154
155 if ( valueNotFound )
156 {
157 Master()->Log(Form("WARNING %d values not found",valueNotFound));
45824ef1 158 }
159
c75c6131 160 Master()->Log("INFO Aliases successfully read in");
d3f57575 161
45824ef1 162 AliCDBMetaData metaData;
163 metaData.SetBeamPeriod(0);
164 metaData.SetResponsible("MUON TRK");
165 metaData.SetComment("Computed by AliMUONHVSubprocessor $Id$");
166
167 Bool_t validToInfinity(kFALSE);
168
d489129d 169 Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
45824ef1 170
d489129d 171 return ( result != kTRUE); // return 0 if everything is ok
45824ef1 172}
173