// =====================================================================
//  $Id: Rs01EventAction.cc,v 1.4 2004/03/04 15:11:54 goiwai Exp $
//  $Name: CLDAQ-1-14-03 $
//  $Log: Rs01EventAction.cc,v $
//  Revision 1.4  2004/03/04 15:11:54  goiwai
//  ほとんどが関数名変更にともなう更新です。
//
//  Revision 1.3  2003/10/06 16:28:15  goiwai
//  *** empty log message ***
//
//  Revision 1.2  2003/07/30 16:14:41  goiwai
//  ファイルにコミットログをつけることにしました.
//
// =====================================================================
#include "TEvent.hh"
#include "TRunManager.hh"
#include "TOutputObjectFile.hh"
#include "TSoftwareInterruptRegisterModule.hh"
#include "TSoftwareScalerModule.hh"
#include "TCrate.hh"
#include "TReadoutBook.hh"
#include "TEnvironmentVariableTable.hh"

#include "Rs01EventAction.hh"
#include "Rs01RunAction.hh"
#include "Rs01RunSummary.hh"

Rs01EventAction::Rs01EventAction()
{;}

Rs01EventAction::~Rs01EventAction()
{;}

TReadoutList* Rs01EventAction::WaitTrigger()
{
  return theReadoutBook -> GetReadoutList( "EVENT" );
}

Tvoid Rs01EventAction::AtLast( TEvent& anEvent )
{
  Rs01RunAction* action =
    (Rs01RunAction*)( theRunManager -> GetRunAction() );
  action -> GetOutputFile() -> Write( anEvent.GetDataRecord() );

  Rs01RunSummary* summary = action -> GetRunSummary();
  Tint nev = summary -> GetNumberOfEvents();
  summary -> SetNumberOfEvents( ++ nev );

  theCrate -> GetModule( "EVENT ID" ) -> Update();
  return;
}
