]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHVSubprocessor.cxx
Fixing error in documentation/comments.
[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 "AliMUONHVNamer.h"
31 #include "AliMUONPreprocessor.h"
32
33 #include "AliMpDEIterator.h"
34 #include "AliMpDEManager.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)
49 : AliMUONVSubprocessor(master,
50                        "HV",
51                        "Get MUON Tracker HV values from DCS")
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   AliMUONHVNamer hvNamer;
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;
115   Bool_t kNoAliases(kTRUE);
116   Int_t aliasNotFound(0);
117   Int_t valueNotFound(0);
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     {
125       ++aliasNotFound;
126     }
127     else
128     {
129       kNoAliases = kFALSE;
130       TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
131       if (!values)
132       {
133         ++valueNotFound;
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     }
142   }
143   
144   if ( kNoAliases ) 
145   {
146     Master()->Log("ERROR : no DCS values found");
147     return 1;
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));
158   }
159   
160   Master()->Log("INFO Aliases successfully read in");
161   
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   
169   Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
170   
171   return ( result != kTRUE); // return 0 if everything is ok
172 }
173