
#include "AlgDeadChip.h"

#include "Algorithm/AlgConfig.h"
#include "Candidate/CandContext.h"
#include "MessageService/MsgService.h" 
#include "JobControl/JobCModuleRegistry.h"

#include "CandDeadChipHandle.h"
#include "RawChip.h"

#include "TObjArray.h"

//
// $Log $
//

ClassImp(AlgDeadChip)

CVSID("$Id: AlgDeadChip.cxx,v 1.1 2006/03/19 17:24:34 blake Exp $");

AlgDeadChip::AlgDeadChip()
{

}
  
AlgDeadChip::~AlgDeadChip()
{

}

void AlgDeadChip::RunAlg(AlgConfig & /*ac*/, CandHandle &ch, CandContext &cx)
{
  MSG("AlgDeadChip", Msg::kDebug) << " AlgDeadChip::RunAlg(...) " << endl;

  CandDeadChipHandle& cdh = dynamic_cast<CandDeadChipHandle&>(ch);

  TObjArray* tmparray = (TObjArray*)(cx.GetDataIn());

  for(Int_t i=0;i<1+tmparray->GetLast();i++){
    RawChip* chip = (RawChip*)(tmparray->At(i));
    cdh.AddRawChip(chip);
  }
  
  MSG("DataQuality", Msg::kVerbose) << endl  
    << "   NEW CANDDEADCHIPHANDLE " << endl
    << "   ====================== " << endl
    << "    Entries=" << 1+tmparray->GetLast() << "|" << cdh.GetEntries() << endl
    << "    RawChannelId=" << cdh.GetChannelId().GetChAdd() << endl
    << "    Adc=" << cdh.GetAdc() << endl
    << "    Tdc=" << cdh.GetTdc() << endl
    << "    ErrorCode=" << cdh.GetErrorCode() << endl
    << "    TriggerRate=" << cdh.GetTriggerRate() << endl
    << "    ChipStatus=" << cdh.GetChipStatus() << endl;

  return;
}

void AlgDeadChip::Trace(const char * /* c */) const
{

}


