<commit_before>/**************************************************************************
* 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 "AliMUONPedestalSubprocessor.h"

#include "AliCDBMetaData.h"
#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUON2DStoreValidator.h"
#include "AliMUONCalibParamNF.h"
#include "AliMUONPreprocessor.h"
#include "AliMUONTrackerIO.h"
#include "AliMpConstants.h"
#include "AliMpDDLStore.h"
#include "TObjString.h"
#include <Riostream.h>
#include <TList.h>
#include <TObjString.h>
#include <TSystem.h>
#include <sstream>

//-----------------------------------------------------------------------------
/// \class AliMUONPedestalSubprocessor
///
/// Implementation of AliMUONVSubprocessor class to deal with MUON TRK pedestals.
///
/// Pedestals are read in from an ascii file, with the format :               \n
///---------------------------------------------------------------------------\n
/// BUS_PATCH MANU_ADDR CHANNEL      MEAN       SIGMA                         \n
///---------------------------------------------------------------------------\n
///
/// \author <NAME>
//-----------------------------------------------------------------------------

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

//_____________________________________________________________________________
AliMUONPedestalSubprocessor::AliMUONPedestalSubprocessor(AliMUONPreprocessor* master)
: AliMUONVSubprocessor(master,
                       "Pedestals",
                       "Upload MUON Tracker pedestals to OCDB"),
fPedestals(0x0),
fConfig(0x0),
fConfigChanged(kFALSE)
{
  /// default ctor
}

//_____________________________________________________________________________
AliMUONPedestalSubprocessor::~AliMUONPedestalSubprocessor()
{
  /// dtor
  delete fPedestals;
  delete fConfig;
}

//_____________________________________________________________________________
Bool_t 
AliMUONPedestalSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
{
  /// When starting a new run, reads in the pedestals ASCII files.
  
  const Int_t kSystem = AliMUONPreprocessor::kDAQ;
  const char* kId = "PEDESTALS";
  
  delete fPedestals;
  fPedestals = new AliMUON2DMap(kTRUE);
  
  delete fConfig;
  fConfig = new AliMUON2DMap(kTRUE);
  
  Master()->Log(Form("Reading pedestal files for Run %d startTime %ld endTime %ld",
                     run,startTime,endTime));
  
  TList* sources = Master()->GetFileSources(kSystem,kId);
  TIter next(sources);
  TObjString* o(0x0);
  Int_t n(0);
  Int_t npedFiles(0);
  
  while ( ( o = static_cast<TObjString*>(next()) ) )
  {
    TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
    Int_t ok = ReadPedestalFile(fileName.Data());
    if (ok>0)
    {
      n += ok;
      ++npedFiles;
    }
  }

  delete sources;
  
  if (!n)
  {
    Master()->Log("Failed to read any pedestals");
    delete fPedestals;
    fPedestals = 0;
    delete fConfig;
    fConfig = 0;
    return kFALSE;
  }
  
  const char* kIdConf = "CONFIG";

  sources = Master()->GetFileSources(kSystem,kIdConf);
  TIter nextConf(sources);
  Int_t nconf(0);
  Int_t nconfFiles(0);
  
  fConfigChanged = kFALSE;
  
  while ( ( o = static_cast<TObjString*>(nextConf()) ) )
  {
    TString fileName(Master()->GetFile(kSystem,kIdConf,o->GetName()));
    Int_t ok = ReadConfigFile(fileName.Data());
    if (ok>0)
    {
      nconf += ok;
      ++nconfFiles;
    }
  }
  
  delete sources;
  
  if ( npedFiles != nconfFiles )
  {
    Master()->Log(Form("ERROR : Number of config files (%d) different from number of pedestal files (%d)",nconfFiles,npedFiles));
    delete fPedestals;
    fPedestals = 0;
    delete fConfig;
    fConfig = 0;
    return kFALSE;
  }
  
  return kTRUE;
}

//_____________________________________________________________________________
UInt_t <commit_msg>Force configuration upload for any incomplete setup (which of course should not be the norm...)<commit_after>/**************************************************************************
* 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 "AliMUONPedestalSubprocessor.h"

#include "AliCDBMetaData.h"
#include "AliDAQ.h"
#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUON2DStoreValidator.h"
#include "AliMUONCalibParamNF.h"
#include "AliMUONPreprocessor.h"
#include "AliMUONTrackerIO.h"
#include "AliMpConstants.h"
#include "AliMpDDLStore.h"
#include "TObjString.h"
#include <Riostream.h>
#include <TList.h>
#include <TObjString.h>
#include <TSystem.h>
#include <sstream>

//-----------------------------------------------------------------------------
/// \class AliMUONPedestalSubprocessor
///
/// Implementation of AliMUONVSubprocessor class to deal with MUON TRK pedestals.
///
/// Pedestals are read in from an ascii file, with the format :               \n
///---------------------------------------------------------------------------\n
/// BUS_PATCH MANU_ADDR CHANNEL      MEAN       SIGMA                         \n
///---------------------------------------------------------------------------\n
///
/// \author <NAME>
//-----------------------------------------------------------------------------

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

//_____________________________________________________________________________
AliMUONPedestalSubprocessor::AliMUONPedestalSubprocessor(AliMUONPreprocessor* master)
: AliMUONVSubprocessor(master,
                       "Pedestals",
                       "Upload MUON Tracker pedestals to OCDB"),
fPedestals(0x0),
fConfig(0x0),
fConfigChanged(kFALSE)
{
  /// default ctor
}

//_____________________________________________________________________________
AliMUONPedestalSubprocessor::~AliMUONPedestalSubprocessor()
{
  /// dtor
  delete fPedestals;
  delete fConfig;
}

//_____________________________________________________________________________
Bool_t 
AliMUONPedestalSubprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
{
  /// When starting a new run, reads in the pedestals ASCII files.
  
  const Int_t kSystem = AliMUONPreprocessor::kDAQ;
  const char* kId = "PEDESTALS";
  
  delete fPedestals;
  fPedestals = new AliMUON2DMap(kTRUE);
  
  delete fConfig;
  fConfig = new AliMUON2DMap(kTRUE);
  
  Master()->Log(Form("Reading pedestal files for Run %d startTime %ld endTime %ld",
                     run,startTime,endTime));
  
  TList* sources = Master()->GetFileSources(kSystem,kId);
  TIter next(sources);
  TObjString* o(0x0);
  Int_t n(0);
  Int_t npedFiles(0);
  
  while ( ( o = static_cast<TObjString*>(next()) ) )
  {
    TString fileName(Master()->GetFile(kSystem,kId,o->GetName()));
    Int_t ok = ReadPedestalFile(fileName.Data());
    if (ok>0)
    {
      n += ok;
      ++npedFiles;
    }
  }

  delete sources;
  
  if (!n)
  {
    Master()->Log("Failed to read any pedestals");
    delete fPedestals;
    fPedestals = 0;
    delete fConfig;
    fConfig = 0;
    return kFALSE;
  }
  
  const char* kIdConf = "CONFIG";

  sources = Master()->GetFileSources(kSystem,kIdConf);
  TIter nextConf(sources);
  Int_t nconf(0);
  Int_t nconfFiles(0);
  
  fConfigChanged = kFALSE;
  
  while ( ( o = static_cast<TObjString*>(nextConf()) ) )
  {
    TString fileName(Master()->GetFile(kSystem,kIdConf,o->GetName()));
    Int_t ok = ReadConfigFile(fileName.Data());
    if (ok>0)
    {
      nconf += ok;
      ++nconfFiles;
    }
  }
  
  delete sources;
  
  if ( npedFiles != nconfFiles )
  {
    Master()->Log(Form("ERROR : Number of config files (%d) different from number of pedestal files (%d)",nconfFiles,npedFiles));
    delete fPedestals;
    fPedestals = 0;
    delete fConfig;
    fConfig = 0;
    return kFALSE;
  }
  
  if ( nconfFiles > 0 && nconfFiles < AliDAQ::NumberOfLdcs("MUONTRK") )
  {
    // force a writing of the configuration for any incomplete configuration
    fConfigChanged = kTRUE;
  }
  
  return kTRUE;
}

//_____________________________________________________________________________
UInt_t 
{'fraction_non_alphanumeric': 0.1881438093314482, 'fraction_numerical': 0.005756412845889719, 'mean_word_length': 2.405433287482806, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4608484', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2751, 'n_words': 699}