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$

#include "AliMUONPreprocessor.h"

#include "AliCDBEntry.h"
#include "AliLog.h"
#include "AliMUONGMSSubprocessor.h"
#include "AliMUONHVSubprocessor.h"
#include "AliMUONPedestalSubprocessor.h"
#include "AliMpCDB.h"
#include "AliMpDDLStore.h"
#include "AliMpDataMap.h"
#include "AliMpDataStreams.h"
#include "AliMpSegmentation.h"
#include "AliShuttleInterface.h"
#include "Riostream.h"
#include "TObjArray.h"

//-----------------------------------------------------------------------------
/// \class AliMUONPreprocessor
///
/// Shuttle preprocessor for MUON subsystems (TRK and TRG)
/// 
/// It's simply a manager class that deals with a list of sub-tasks 
/// (of type AliMUONVSubprocessor).
///
/// \author Laurent Aphecetche
//-----------------------------------------------------------------------------

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

//_____________________________________________________________________________
AliMUONPreprocessor::AliMUONPreprocessor(const char* detName, AliShuttleInterface* shuttle)
: AliPreprocessor(detName, shuttle),
  fIsValid(kFALSE),
  fIsApplicable(kTRUE),
  fSubprocessors(new TObjArray()),
  fProcessDCS(kFALSE)
{
  /// ctor
}

//_____________________________________________________________________________
AliMUONPreprocessor::~AliMUONPreprocessor()
{
  /// dtor
  delete fSubprocessors;
}

//_____________________________________________________________________________
void
AliMUONPreprocessor::ClearSubprocessors()
{
  /// Empty our subprocessor list
  fSubprocessors->Clear();
  fProcessDCS = kFALSE;
  fIsValid = kFALSE;
  fIsApplicable = kTRUE;
}

//_____________________________________________________________________________
void
AliMUONPreprocessor::Add(AliMUONVSubprocessor* sub, Bool_t processDCS)
{
  /// Add a subprocessor to our list of workers
  fSubprocessors->Add(sub);
  if ( processDCS == kTRUE ) fProcessDCS = processDCS;
}

//_____________________________________________________________________________
void
AliMUONPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
{
  /// Load mapping and initialize subtasks  

  // Delete previous mapping
  AliMpCDB::UnloadAll();
  
  if ( ! IsApplicable() ) {
    Log(Form("WARNING-RunType=%s is not one I should handle.",GetRunType()));
    return;
  }   
  
  // Load mapping from CDB for this run
  AliCDBEntry* cdbEntry = GetFromOCDB("Calib", "MappingData");
  if (!cdbEntry)
  {
    Log("Could not get MappingData from OCDB !");
    fIsValid = kFALSE;
  }
  else
  {
    AliMpDataMap* dataMap = dynamic_cast<AliMpDataMap*>(cdbEntry->GetObject());
    if (!dataMap)
    {
      Log("DataMap is not of the expected type. That is bad...");
      fIsValid = kFALSE;
    }
    else
    {
      AliMpDataStreams dataStreams(dataMap);
      AliMpDDLStore::ReadData(dataStreams);
    }
  }
  
  Int_t nok(0);

  if (IsValid())
  {
    // loop over subtasks and initialize them
    for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
    {
      Bool_t ok = Subprocessor(i)->Initialize(run,startTime,endTime);
      if (ok) ++nok;
    }
    if (nok !=  fSubprocessors->GetLast()+1) fIsValid = kFALSE;
  }
  Log(Form("Initialize was %s",( IsValid() ? "fine" : "NOT OK")));
}

//_____________________________________________________________________________
UInt_t
AliMUONPreprocessor::Process(TMap* dcsAliasMap)
{
  /// loop over subtasks to make them work
  
  if (!IsValid())
  {
    Log("Will not run as not properly initialized");
    return 99;
  }
  
  if (!IsApplicable())
  {
    Log("Nothing to do for me");
    return 0;
  }
  
  UInt_t rv(0);
  
  for ( Int_t i = 0; i <= fSubprocessors->GetLast(); ++i )
  {
    rv += Subprocessor(i)->Process(dcsAliasMap);
  }
  
  return rv;
}

//_____________________________________________________________________________
void
AliMUONPreprocessor::Print(Option_t* opt) const
{
  /// output to screen
  cout << "<AliMUONPreprocessor> subprocessors :" << endl;
  for ( Int_t i=0; i <= fSubprocessors->GetLast(); ++i )
  {
    Subprocessor(i)->Print(opt);
  }
}

//_____________________________________________________________________________
AliMUONVSubprocessor*
AliMUONPreprocessor::Subprocessor(Int_t i) const
{
  /// return i-th subprocessor
  if ( i >= 0 && i <= fSubprocessors->GetLast() )
  {
    return static_cast<AliMUONVSubprocessor*>(fSubprocessors->At(i));
  }
  return 0x0;
}
 AliMUONPreprocessor.cxx:1
 AliMUONPreprocessor.cxx:2
 AliMUONPreprocessor.cxx:3
 AliMUONPreprocessor.cxx:4
 AliMUONPreprocessor.cxx:5
 AliMUONPreprocessor.cxx:6
 AliMUONPreprocessor.cxx:7
 AliMUONPreprocessor.cxx:8
 AliMUONPreprocessor.cxx:9
 AliMUONPreprocessor.cxx:10
 AliMUONPreprocessor.cxx:11
 AliMUONPreprocessor.cxx:12
 AliMUONPreprocessor.cxx:13
 AliMUONPreprocessor.cxx:14
 AliMUONPreprocessor.cxx:15
 AliMUONPreprocessor.cxx:16
 AliMUONPreprocessor.cxx:17
 AliMUONPreprocessor.cxx:18
 AliMUONPreprocessor.cxx:19
 AliMUONPreprocessor.cxx:20
 AliMUONPreprocessor.cxx:21
 AliMUONPreprocessor.cxx:22
 AliMUONPreprocessor.cxx:23
 AliMUONPreprocessor.cxx:24
 AliMUONPreprocessor.cxx:25
 AliMUONPreprocessor.cxx:26
 AliMUONPreprocessor.cxx:27
 AliMUONPreprocessor.cxx:28
 AliMUONPreprocessor.cxx:29
 AliMUONPreprocessor.cxx:30
 AliMUONPreprocessor.cxx:31
 AliMUONPreprocessor.cxx:32
 AliMUONPreprocessor.cxx:33
 AliMUONPreprocessor.cxx:34
 AliMUONPreprocessor.cxx:35
 AliMUONPreprocessor.cxx:36
 AliMUONPreprocessor.cxx:37
 AliMUONPreprocessor.cxx:38
 AliMUONPreprocessor.cxx:39
 AliMUONPreprocessor.cxx:40
 AliMUONPreprocessor.cxx:41
 AliMUONPreprocessor.cxx:42
 AliMUONPreprocessor.cxx:43
 AliMUONPreprocessor.cxx:44
 AliMUONPreprocessor.cxx:45
 AliMUONPreprocessor.cxx:46
 AliMUONPreprocessor.cxx:47
 AliMUONPreprocessor.cxx:48
 AliMUONPreprocessor.cxx:49
 AliMUONPreprocessor.cxx:50
 AliMUONPreprocessor.cxx:51
 AliMUONPreprocessor.cxx:52
 AliMUONPreprocessor.cxx:53
 AliMUONPreprocessor.cxx:54
 AliMUONPreprocessor.cxx:55
 AliMUONPreprocessor.cxx:56
 AliMUONPreprocessor.cxx:57
 AliMUONPreprocessor.cxx:58
 AliMUONPreprocessor.cxx:59
 AliMUONPreprocessor.cxx:60
 AliMUONPreprocessor.cxx:61
 AliMUONPreprocessor.cxx:62
 AliMUONPreprocessor.cxx:63
 AliMUONPreprocessor.cxx:64
 AliMUONPreprocessor.cxx:65
 AliMUONPreprocessor.cxx:66
 AliMUONPreprocessor.cxx:67
 AliMUONPreprocessor.cxx:68
 AliMUONPreprocessor.cxx:69
 AliMUONPreprocessor.cxx:70
 AliMUONPreprocessor.cxx:71
 AliMUONPreprocessor.cxx:72
 AliMUONPreprocessor.cxx:73
 AliMUONPreprocessor.cxx:74
 AliMUONPreprocessor.cxx:75
 AliMUONPreprocessor.cxx:76
 AliMUONPreprocessor.cxx:77
 AliMUONPreprocessor.cxx:78
 AliMUONPreprocessor.cxx:79
 AliMUONPreprocessor.cxx:80
 AliMUONPreprocessor.cxx:81
 AliMUONPreprocessor.cxx:82
 AliMUONPreprocessor.cxx:83
 AliMUONPreprocessor.cxx:84
 AliMUONPreprocessor.cxx:85
 AliMUONPreprocessor.cxx:86
 AliMUONPreprocessor.cxx:87
 AliMUONPreprocessor.cxx:88
 AliMUONPreprocessor.cxx:89
 AliMUONPreprocessor.cxx:90
 AliMUONPreprocessor.cxx:91
 AliMUONPreprocessor.cxx:92
 AliMUONPreprocessor.cxx:93
 AliMUONPreprocessor.cxx:94
 AliMUONPreprocessor.cxx:95
 AliMUONPreprocessor.cxx:96
 AliMUONPreprocessor.cxx:97
 AliMUONPreprocessor.cxx:98
 AliMUONPreprocessor.cxx:99
 AliMUONPreprocessor.cxx:100
 AliMUONPreprocessor.cxx:101
 AliMUONPreprocessor.cxx:102
 AliMUONPreprocessor.cxx:103
 AliMUONPreprocessor.cxx:104
 AliMUONPreprocessor.cxx:105
 AliMUONPreprocessor.cxx:106
 AliMUONPreprocessor.cxx:107
 AliMUONPreprocessor.cxx:108
 AliMUONPreprocessor.cxx:109
 AliMUONPreprocessor.cxx:110
 AliMUONPreprocessor.cxx:111
 AliMUONPreprocessor.cxx:112
 AliMUONPreprocessor.cxx:113
 AliMUONPreprocessor.cxx:114
 AliMUONPreprocessor.cxx:115
 AliMUONPreprocessor.cxx:116
 AliMUONPreprocessor.cxx:117
 AliMUONPreprocessor.cxx:118
 AliMUONPreprocessor.cxx:119
 AliMUONPreprocessor.cxx:120
 AliMUONPreprocessor.cxx:121
 AliMUONPreprocessor.cxx:122
 AliMUONPreprocessor.cxx:123
 AliMUONPreprocessor.cxx:124
 AliMUONPreprocessor.cxx:125
 AliMUONPreprocessor.cxx:126
 AliMUONPreprocessor.cxx:127
 AliMUONPreprocessor.cxx:128
 AliMUONPreprocessor.cxx:129
 AliMUONPreprocessor.cxx:130
 AliMUONPreprocessor.cxx:131
 AliMUONPreprocessor.cxx:132
 AliMUONPreprocessor.cxx:133
 AliMUONPreprocessor.cxx:134
 AliMUONPreprocessor.cxx:135
 AliMUONPreprocessor.cxx:136
 AliMUONPreprocessor.cxx:137
 AliMUONPreprocessor.cxx:138
 AliMUONPreprocessor.cxx:139
 AliMUONPreprocessor.cxx:140
 AliMUONPreprocessor.cxx:141
 AliMUONPreprocessor.cxx:142
 AliMUONPreprocessor.cxx:143
 AliMUONPreprocessor.cxx:144
 AliMUONPreprocessor.cxx:145
 AliMUONPreprocessor.cxx:146
 AliMUONPreprocessor.cxx:147
 AliMUONPreprocessor.cxx:148
 AliMUONPreprocessor.cxx:149
 AliMUONPreprocessor.cxx:150
 AliMUONPreprocessor.cxx:151
 AliMUONPreprocessor.cxx:152
 AliMUONPreprocessor.cxx:153
 AliMUONPreprocessor.cxx:154
 AliMUONPreprocessor.cxx:155
 AliMUONPreprocessor.cxx:156
 AliMUONPreprocessor.cxx:157
 AliMUONPreprocessor.cxx:158
 AliMUONPreprocessor.cxx:159
 AliMUONPreprocessor.cxx:160
 AliMUONPreprocessor.cxx:161
 AliMUONPreprocessor.cxx:162
 AliMUONPreprocessor.cxx:163
 AliMUONPreprocessor.cxx:164
 AliMUONPreprocessor.cxx:165
 AliMUONPreprocessor.cxx:166
 AliMUONPreprocessor.cxx:167
 AliMUONPreprocessor.cxx:168
 AliMUONPreprocessor.cxx:169
 AliMUONPreprocessor.cxx:170
 AliMUONPreprocessor.cxx:171
 AliMUONPreprocessor.cxx:172
 AliMUONPreprocessor.cxx:173
 AliMUONPreprocessor.cxx:174
 AliMUONPreprocessor.cxx:175
 AliMUONPreprocessor.cxx:176
 AliMUONPreprocessor.cxx:177
 AliMUONPreprocessor.cxx:178
 AliMUONPreprocessor.cxx:179
 AliMUONPreprocessor.cxx:180
 AliMUONPreprocessor.cxx:181
 AliMUONPreprocessor.cxx:182
 AliMUONPreprocessor.cxx:183
 AliMUONPreprocessor.cxx:184
 AliMUONPreprocessor.cxx:185
 AliMUONPreprocessor.cxx:186
 AliMUONPreprocessor.cxx:187
 AliMUONPreprocessor.cxx:188