////////////////////////////////////////////////////////////////////////
//
// Manage the input of Rootfile in SOC format. Takes a root file with a
// soc tree inside and provide the information to the analysis part of
// RAT.
//
// Author: P G Jones <p.g.jones@qmul.ac.uk> - contact person
//
// REVISION HISTORY:
//  04 Oct 2012 : P.Jones - First revision
//   2014-04-26 : P. Jones - Refactor run knowledge.
//   2015-05-25 : D. Auty - Added code to allow part runs
//
////////////////////////////////////////////////////////////////////

#ifndef __RAT_InSOCProducer__
#define __RAT_InSOCProducer__

#include <RAT/Producer.hh>

#include <TChain.h>

#include <string>

class G4UIcmdWithAString;
class G4UIcommand;

namespace RAT
{
namespace DS
{
  class Run;
}

class InSOCProducer : public Producer
{
public:
  // Construct, set the ProcBlock to NULL
  InSOCProducer();

  // Construct with a ProcBlock
  //
  // block: block to use
  InSOCProducer( ProcBlock* block );

  // Override the G4UImessenger (from Producer) set method
  //
  // command: command to set
  // newValue: new value to set
  void SetNewValue( G4UIcommand* command, G4String newValue );

  // Override the G4UImessenger (from Producer) get method
  //
  // command: command to query
  // Returns the command value
  G4String GetCurrentValue( G4UIcommand* command );

protected:
  // Load the file into the TChains
  //
  // fileName: file to load and read
  void LoadFile( const std::string& fileName );

  // Read the events from the TChains
  void ReadEntries();

  // Initialise the producer
  void Init();

  TChain fSOCTree; // The DS::SOC TTree
  TChain fRunTree; // The DS::Run TTree

  G4UIcmdWithAString* fLoadCmd; // Command to load a defined file
  G4UIcommand* fLoadDefaultCmd; // Command to load a file
  G4UIcommand* fReadCmd; // Command to Start reading
};

} // namespace RAT

#endif