ROOT logo
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

// $Id$

//-----------------------------------------------------------------------------
/// \class AliMUONHVSubprocessor
///
/// A subprocessor to read HV values for one run
///
/// It simply creates a copy of the dcsAliasMap w/o information
/// from the MUON TRK, and dumps this copy into the CDB
///
/// \author Laurent Aphecetche, Subatech
//-----------------------------------------------------------------------------

#include "AliMUONHVSubprocessor.h"
#include "AliMUONPreprocessor.h"

#include "AliMpDEIterator.h"
#include "AliMpDEManager.h"
#include "AliMpDCSNamer.h"

#include "AliCDBMetaData.h"
#include "AliLog.h"

#include "Riostream.h"
#include "TMap.h"
#include "TObjString.h"

/// \cond CLASSIMP
ClassImp(AliMUONHVSubprocessor)
/// \endcond

//_____________________________________________________________________________
AliMUONHVSubprocessor::AliMUONHVSubprocessor(AliMUONPreprocessor* master, Bool_t includeHVcurrents)
: AliMUONVSubprocessor(master,
                       "HV",
                       "Get MUON Tracker HV values from DCS"), fIncludeHVCurrents(includeHVcurrents)
{
  /// ctor
}

//_____________________________________________________________________________
AliMUONHVSubprocessor::~AliMUONHVSubprocessor()
{
  /// dtor
}

//_____________________________________________________________________________
UInt_t
AliMUONHVSubprocessor::Process(TMap* dcsAliasMap)
{
  /// Make another alias map from dcsAliasMap, considering only MUON TRK aliases.

  TMap hv;
  hv.SetOwner(kTRUE);
  
  AliMpDCSNamer hvNamer("TRACKER");

  AliMpDEIterator deIt;

  deIt.First();
  
  TObjArray aliases;
  aliases.SetOwner(kTRUE);
  
  // we first generate a list of expected MCH DCS aliases we'll then look for
  
  while ( !deIt.IsDone() )
  {
    Int_t detElemId = deIt.CurrentDEId();
    
    switch ( AliMpDEManager::GetStationType(detElemId) )
    {
      case AliMp::kStation12:
      {
        for ( int i = 0; i <3; ++i)
        {
          aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i)));
          if ( fIncludeHVCurrents )
          {
            aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,i,AliMpDCSNamer::kDCSI)));
          }
        }
      }
      break;
      case AliMp::kStation345:
      {
        aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId)));
        if ( fIncludeHVCurrents )
        {
          aliases.Add(new TObjString(hvNamer.DCSAliasName(detElemId,0,AliMpDCSNamer::kDCSI)));
        }
        for ( int i = 0; i < hvNamer.NumberOfPCBs(detElemId); ++i)
        {
          aliases.Add(new TObjString(hvNamer.DCSSwitchAliasName(detElemId,i)));
        }
      }
      break;
      default:
        break;
    };

    deIt.Next();
  }

  TIter next(&aliases);
  TObjString* alias;
  Bool_t kNoAliases(kTRUE);
  Int_t aliasNotFound(0);
  Int_t valueNotFound(0);
  
  TObjArray temporaryOut; // due to a bug in PVSS some iMon aliases cause problem
  // we remove them for the moment.
  temporaryOut.SetOwner(kTRUE);
  
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber06Left/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber07Left/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber08Left/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvLeft/Chamber09Left/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber06Right/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber07Right/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber08Right/Slat12.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat10.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat11.actual.iMon"));
  temporaryOut.Add(new TObjString("MchHvLvRight/Chamber09Right/Slat12.actual.iMon"));
  
  while ( ( alias = static_cast<TObjString*>(next()) ) ) 
  {
    TString aliasName(alias->String());
    
    if ( temporaryOut.FindObject(alias->String().Data() ) )
    {
      // skip problematic aliases
      continue;
    }
    
    TPair* hvPair = static_cast<TPair*>(dcsAliasMap->FindObject(aliasName.Data()));
    if (!hvPair)
    {
      ++aliasNotFound;
    }
    else
    {
      kNoAliases = kFALSE;
      TObjArray* values = static_cast<TObjArray*>(hvPair->Value()->Clone());
      if (!values)
      {
        ++valueNotFound;
      }
      else
      {
        RemoveValuesOutsideRun(values);
        hv.Add(new TObjString(aliasName.Data()),values);
      }
    }
  }
  
  if ( kNoAliases ) 
  {
    Master()->Log("ERROR : no DCS values found");
    return 1;
  }
  
  if ( aliasNotFound ) 
  {
    Master()->Log(Form("WARNING %d aliases not found",aliasNotFound));
  }
  
  if ( valueNotFound )
  {
    Master()->Log(Form("WARNING %d values not found",valueNotFound));
  }
  
  Master()->Log("INFO Aliases successfully read in");
  
  AliCDBMetaData metaData;
  metaData.SetBeamPeriod(0);
  metaData.SetResponsible("MUON TRK");
  metaData.SetComment("Computed by AliMUONHVSubprocessor $Id$");
  
  Bool_t validToInfinity(kFALSE);
  
  Bool_t result = Master()->Store("Calib","HV",&hv,&metaData,0,validToInfinity);
  
  return ( result != kTRUE); // return 0 if everything is ok
}

 AliMUONHVSubprocessor.cxx:1
 AliMUONHVSubprocessor.cxx:2
 AliMUONHVSubprocessor.cxx:3
 AliMUONHVSubprocessor.cxx:4
 AliMUONHVSubprocessor.cxx:5
 AliMUONHVSubprocessor.cxx:6
 AliMUONHVSubprocessor.cxx:7
 AliMUONHVSubprocessor.cxx:8
 AliMUONHVSubprocessor.cxx:9
 AliMUONHVSubprocessor.cxx:10
 AliMUONHVSubprocessor.cxx:11
 AliMUONHVSubprocessor.cxx:12
 AliMUONHVSubprocessor.cxx:13
 AliMUONHVSubprocessor.cxx:14
 AliMUONHVSubprocessor.cxx:15
 AliMUONHVSubprocessor.cxx:16
 AliMUONHVSubprocessor.cxx:17
 AliMUONHVSubprocessor.cxx:18
 AliMUONHVSubprocessor.cxx:19
 AliMUONHVSubprocessor.cxx:20
 AliMUONHVSubprocessor.cxx:21
 AliMUONHVSubprocessor.cxx:22
 AliMUONHVSubprocessor.cxx:23
 AliMUONHVSubprocessor.cxx:24
 AliMUONHVSubprocessor.cxx:25
 AliMUONHVSubprocessor.cxx:26
 AliMUONHVSubprocessor.cxx:27
 AliMUONHVSubprocessor.cxx:28
 AliMUONHVSubprocessor.cxx:29
 AliMUONHVSubprocessor.cxx:30
 AliMUONHVSubprocessor.cxx:31
 AliMUONHVSubprocessor.cxx:32
 AliMUONHVSubprocessor.cxx:33
 AliMUONHVSubprocessor.cxx:34
 AliMUONHVSubprocessor.cxx:35
 AliMUONHVSubprocessor.cxx:36
 AliMUONHVSubprocessor.cxx:37
 AliMUONHVSubprocessor.cxx:38
 AliMUONHVSubprocessor.cxx:39
 AliMUONHVSubprocessor.cxx:40
 AliMUONHVSubprocessor.cxx:41
 AliMUONHVSubprocessor.cxx:42
 AliMUONHVSubprocessor.cxx:43
 AliMUONHVSubprocessor.cxx:44
 AliMUONHVSubprocessor.cxx:45
 AliMUONHVSubprocessor.cxx:46
 AliMUONHVSubprocessor.cxx:47
 AliMUONHVSubprocessor.cxx:48
 AliMUONHVSubprocessor.cxx:49
 AliMUONHVSubprocessor.cxx:50
 AliMUONHVSubprocessor.cxx:51
 AliMUONHVSubprocessor.cxx:52
 AliMUONHVSubprocessor.cxx:53
 AliMUONHVSubprocessor.cxx:54
 AliMUONHVSubprocessor.cxx:55
 AliMUONHVSubprocessor.cxx:56
 AliMUONHVSubprocessor.cxx:57
 AliMUONHVSubprocessor.cxx:58
 AliMUONHVSubprocessor.cxx:59
 AliMUONHVSubprocessor.cxx:60
 AliMUONHVSubprocessor.cxx:61
 AliMUONHVSubprocessor.cxx:62
 AliMUONHVSubprocessor.cxx:63
 AliMUONHVSubprocessor.cxx:64
 AliMUONHVSubprocessor.cxx:65
 AliMUONHVSubprocessor.cxx:66
 AliMUONHVSubprocessor.cxx:67
 AliMUONHVSubprocessor.cxx:68
 AliMUONHVSubprocessor.cxx:69
 AliMUONHVSubprocessor.cxx:70
 AliMUONHVSubprocessor.cxx:71
 AliMUONHVSubprocessor.cxx:72
 AliMUONHVSubprocessor.cxx:73
 AliMUONHVSubprocessor.cxx:74
 AliMUONHVSubprocessor.cxx:75
 AliMUONHVSubprocessor.cxx:76
 AliMUONHVSubprocessor.cxx:77
 AliMUONHVSubprocessor.cxx:78
 AliMUONHVSubprocessor.cxx:79
 AliMUONHVSubprocessor.cxx:80
 AliMUONHVSubprocessor.cxx:81
 AliMUONHVSubprocessor.cxx:82
 AliMUONHVSubprocessor.cxx:83
 AliMUONHVSubprocessor.cxx:84
 AliMUONHVSubprocessor.cxx:85
 AliMUONHVSubprocessor.cxx:86
 AliMUONHVSubprocessor.cxx:87
 AliMUONHVSubprocessor.cxx:88
 AliMUONHVSubprocessor.cxx:89
 AliMUONHVSubprocessor.cxx:90
 AliMUONHVSubprocessor.cxx:91
 AliMUONHVSubprocessor.cxx:92
 AliMUONHVSubprocessor.cxx:93
 AliMUONHVSubprocessor.cxx:94
 AliMUONHVSubprocessor.cxx:95
 AliMUONHVSubprocessor.cxx:96
 AliMUONHVSubprocessor.cxx:97
 AliMUONHVSubprocessor.cxx:98
 AliMUONHVSubprocessor.cxx:99
 AliMUONHVSubprocessor.cxx:100
 AliMUONHVSubprocessor.cxx:101
 AliMUONHVSubprocessor.cxx:102
 AliMUONHVSubprocessor.cxx:103
 AliMUONHVSubprocessor.cxx:104
 AliMUONHVSubprocessor.cxx:105
 AliMUONHVSubprocessor.cxx:106
 AliMUONHVSubprocessor.cxx:107
 AliMUONHVSubprocessor.cxx:108
 AliMUONHVSubprocessor.cxx:109
 AliMUONHVSubprocessor.cxx:110
 AliMUONHVSubprocessor.cxx:111
 AliMUONHVSubprocessor.cxx:112
 AliMUONHVSubprocessor.cxx:113
 AliMUONHVSubprocessor.cxx:114
 AliMUONHVSubprocessor.cxx:115
 AliMUONHVSubprocessor.cxx:116
 AliMUONHVSubprocessor.cxx:117
 AliMUONHVSubprocessor.cxx:118
 AliMUONHVSubprocessor.cxx:119
 AliMUONHVSubprocessor.cxx:120
 AliMUONHVSubprocessor.cxx:121
 AliMUONHVSubprocessor.cxx:122
 AliMUONHVSubprocessor.cxx:123
 AliMUONHVSubprocessor.cxx:124
 AliMUONHVSubprocessor.cxx:125
 AliMUONHVSubprocessor.cxx:126
 AliMUONHVSubprocessor.cxx:127
 AliMUONHVSubprocessor.cxx:128
 AliMUONHVSubprocessor.cxx:129
 AliMUONHVSubprocessor.cxx:130
 AliMUONHVSubprocessor.cxx:131
 AliMUONHVSubprocessor.cxx:132
 AliMUONHVSubprocessor.cxx:133
 AliMUONHVSubprocessor.cxx:134
 AliMUONHVSubprocessor.cxx:135
 AliMUONHVSubprocessor.cxx:136
 AliMUONHVSubprocessor.cxx:137
 AliMUONHVSubprocessor.cxx:138
 AliMUONHVSubprocessor.cxx:139
 AliMUONHVSubprocessor.cxx:140
 AliMUONHVSubprocessor.cxx:141
 AliMUONHVSubprocessor.cxx:142
 AliMUONHVSubprocessor.cxx:143
 AliMUONHVSubprocessor.cxx:144
 AliMUONHVSubprocessor.cxx:145
 AliMUONHVSubprocessor.cxx:146
 AliMUONHVSubprocessor.cxx:147
 AliMUONHVSubprocessor.cxx:148
 AliMUONHVSubprocessor.cxx:149
 AliMUONHVSubprocessor.cxx:150
 AliMUONHVSubprocessor.cxx:151
 AliMUONHVSubprocessor.cxx:152
 AliMUONHVSubprocessor.cxx:153
 AliMUONHVSubprocessor.cxx:154
 AliMUONHVSubprocessor.cxx:155
 AliMUONHVSubprocessor.cxx:156
 AliMUONHVSubprocessor.cxx:157
 AliMUONHVSubprocessor.cxx:158
 AliMUONHVSubprocessor.cxx:159
 AliMUONHVSubprocessor.cxx:160
 AliMUONHVSubprocessor.cxx:161
 AliMUONHVSubprocessor.cxx:162
 AliMUONHVSubprocessor.cxx:163
 AliMUONHVSubprocessor.cxx:164
 AliMUONHVSubprocessor.cxx:165
 AliMUONHVSubprocessor.cxx:166
 AliMUONHVSubprocessor.cxx:167
 AliMUONHVSubprocessor.cxx:168
 AliMUONHVSubprocessor.cxx:169
 AliMUONHVSubprocessor.cxx:170
 AliMUONHVSubprocessor.cxx:171
 AliMUONHVSubprocessor.cxx:172
 AliMUONHVSubprocessor.cxx:173
 AliMUONHVSubprocessor.cxx:174
 AliMUONHVSubprocessor.cxx:175
 AliMUONHVSubprocessor.cxx:176
 AliMUONHVSubprocessor.cxx:177
 AliMUONHVSubprocessor.cxx:178
 AliMUONHVSubprocessor.cxx:179
 AliMUONHVSubprocessor.cxx:180
 AliMUONHVSubprocessor.cxx:181
 AliMUONHVSubprocessor.cxx:182
 AliMUONHVSubprocessor.cxx:183
 AliMUONHVSubprocessor.cxx:184
 AliMUONHVSubprocessor.cxx:185
 AliMUONHVSubprocessor.cxx:186
 AliMUONHVSubprocessor.cxx:187
 AliMUONHVSubprocessor.cxx:188
 AliMUONHVSubprocessor.cxx:189
 AliMUONHVSubprocessor.cxx:190
 AliMUONHVSubprocessor.cxx:191
 AliMUONHVSubprocessor.cxx:192
 AliMUONHVSubprocessor.cxx:193
 AliMUONHVSubprocessor.cxx:194
 AliMUONHVSubprocessor.cxx:195
 AliMUONHVSubprocessor.cxx:196
 AliMUONHVSubprocessor.cxx:197
 AliMUONHVSubprocessor.cxx:198
 AliMUONHVSubprocessor.cxx:199
 AliMUONHVSubprocessor.cxx:200
 AliMUONHVSubprocessor.cxx:201
 AliMUONHVSubprocessor.cxx:202
 AliMUONHVSubprocessor.cxx:203
 AliMUONHVSubprocessor.cxx:204
 AliMUONHVSubprocessor.cxx:205
 AliMUONHVSubprocessor.cxx:206
 AliMUONHVSubprocessor.cxx:207
 AliMUONHVSubprocessor.cxx:208
 AliMUONHVSubprocessor.cxx:209
 AliMUONHVSubprocessor.cxx:210
 AliMUONHVSubprocessor.cxx:211
 AliMUONHVSubprocessor.cxx:212
 AliMUONHVSubprocessor.cxx:213
 AliMUONHVSubprocessor.cxx:214
 AliMUONHVSubprocessor.cxx:215