]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHVSubprocessor.cxx
changes for Vertex and Tracks classes
[u/mrichter/AliRoot.git] / MUON / AliMUONHVSubprocessor.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 //-----------------------------------------------------------------------------
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 ///
26 /// \author Laurent Aphecetche, Subatech
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONHVSubprocessor.h"
30 #include "AliMUONPreprocessor.h"
31
32 #include "AliMpDEIterator.h"
33 #include "AliMpDEManager.h"
34 #include "AliMpDCSNamer.h"
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
44 ClassImp(AliMUONHVSubprocessor)
45 /// \endcond
46
47 //_____________________________________________________________________________
48 AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master, Bool_t includeHVcurrents)
49 : AliMUONVSubprocessor(master,
50                        "HV",
51                        "Get MUON Tracker HV values from DCS"), fIncludeHVCurrents(includeHVcurrents)
52 {
53   /// ctor
54 }
55
56 //_____________________________________________________________________________
57 AliMUONHVSubprocessor::~AliMUONHVSubprocessor()
58 {
59   /// dtor
60 }
61
62 //_____________________________________________________________________________
63 UInt_t
64 AliMUONHVSubprocessor::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   
71   AliMpDCSNamer hvNamer("TRACKER");
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::kStation12:
89       {
90         for ( int i = 0; i <3; ++i)
91         {
92           aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i)));
93           if ( fIncludeHVCurrents )
94           {
95             aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i,AliMpDCSNamer::kDCSI)));
96           }
97         }
98       }
99       break;
100       case AliMp::kStation345:
101       {
102         aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId)));
103         if ( fIncludeHVCurrents )
104         {
105           aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,0,AliMpDCSNamer::kDCSI)));
106         }
107         for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
108         {
109           aliases.Add(new TObjString(hvNamer.DCSSwitchAliasName(detElemId,i)));
110         }
111       }
112       break;
113       default:
114         break;
115     };
116
117     deIt.Next();
118   }
119
120   TIter next(&aliases);
121   TObjString* alias;
122   Bool_t kNoAliases(kTRUE);
123   Int_t aliasNotFound(0);
124   Int_t valueNotFound(0);
125   
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   
155   while ( ( alias = static_cast<TObjString*>(next()) ) ) 
156   {
157     TString aliasName(alias->String());
158     
159     if ( temporaryOut.FindObject(alias->String().Data() ) )
160     {
161       // skip problematic aliases
162       continue;
163     }
164     
165     TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
166     if (!hvPair)
167     {
168       ++aliasNotFound;
169     }
170     else
171     {
172       kNoAliases = kFALSE;
173       TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
174       if (!values)
175       {
176         ++valueNotFound;
177       }
178       else
179       {
180         RemoveValuesOutsideRun(values);
181         hv.Add(new TObjString(aliasName.Data()),values);
182       }
183     }
184   }
185   
186   if ( kNoAliases ) 
187   {
188     Master()->Log("ERROR : no DCS values found");
189     return 1;
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));
200   }
201   
202   Master()->Log("INFO Aliases successfully read in");
203   
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   
211   Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
212   
213   return ( result != kTRUE); // return 0 if everything is ok
214 }
215