Public Member Functions | Private Member Functions | Private Attributes

WCSimNtupleWriter Class Reference

#include "WCSimNtupleWriter.hh"

List of all members.

Public Member Functions

 WCSimNtupleWriter ()
 ~WCSimNtupleWriter ()
void Initialize ()
void UseNtuple (const char *ntuple)
void SetFileName (const char *filename)
void Run (Int_t entries=-1)
void Run (Int_t i1, Int_t i2)

Private Member Functions

void BuildNtuple ()

Private Attributes

WCSimRecofReco
WCSimRecoEventfRecoEvent
WCSimTrueEventfTrueEvent
WCSimNtuplefNtuple
TString fNtupleName
TString fNtpFileName

Detailed Description

Definition at line 13 of file WCSimNtupleWriter.hh.


Constructor & Destructor Documentation

WCSimNtupleWriter::WCSimNtupleWriter (  ) 
WCSimNtupleWriter::~WCSimNtupleWriter (  ) 

Definition at line 30 of file WCSimNtupleWriter.cc.

References fReco.

{
  if( fReco ) delete fReco;
}


Member Function Documentation

void WCSimNtupleWriter::BuildNtuple (  )  [private]

Definition at line 35 of file WCSimNtupleWriter.cc.

References fNtpFileName, fNtuple, fNtupleName, fReco, WCSimRecoFactory::Instance(), WCSimNtupleFactory::Instance(), WCSimNtupleFactory::MakeNtuple(), WCSimRecoFactory::MakeReco(), WCSimNtuple::Reset(), and WCSimNtuple::SetFileName().

Referenced by Run().

{
  std::cout << " *** WCSimNtupleWriter::BuildNtuple() *** " << std::endl;

  // Building Ntuple
  if( fNtuple ){
    fNtuple->Reset();
  }
  else{
    fNtuple = WCSimNtupleFactory::Instance()->MakeNtuple(fNtupleName.Data());
  }

  // Set File Name
  if( fNtuple ){
    fNtuple->SetFileName(fNtpFileName.Data());
  }

  // Building Reconstruction
  if( !fReco ){
    fReco = WCSimRecoFactory::Instance()->MakeReco();
  }

  return;
}

void WCSimNtupleWriter::Initialize (  ) 
void WCSimNtupleWriter::Run ( Int_t  i1,
Int_t  i2 
)

Definition at line 65 of file WCSimNtupleWriter.cc.

References BuildNtuple(), WCSimNtuple::CloseFile(), WCSimNtuple::Fill(), fNtuple, fReco, fRecoEvent, fTrueEvent, WCSimInterface::GetNumEvents(), WCSimInterface::LoadEvent(), WCSimInterface::RecoEvent(), WCSimReco::Run(), WCSimInterface::TouchData(), WCSimInterface::TouchEvent(), WCSimGeometry::TouchGeometry(), and WCSimInterface::TrueEvent().

{
  std::cout << " *** WCSimNtupleWriter::Run() *** " << std::endl;

  // check for events
  // ================
  if( WCSimInterface::TouchData()==0 ){
    return;
  }

  if( WCSimGeometry::TouchGeometry()==0 ){
    return;
  }

  // number of entries
  // =================
  Int_t ilast = i2;
  if( ilast<0 || ilast>WCSimInterface::GetNumEvents() ){
    ilast = WCSimInterface::GetNumEvents();
  }

  Int_t ifirst = i1;
  if( ifirst>ilast ){
    return;
  }

  // build ntuple 
  // ============
  this->BuildNtuple();

  // check ntuple
  // ============
  if( fNtuple==0 ){
    std::cout << "  <warning> failed to build ntuple! " << std::endl;
    return;
  }

  // loop over events
  // ================
  std::cout << "  running from " << ifirst << " to " << ilast 
                         << " (" << ilast-ifirst << " entries) " << std::endl;

  for( Int_t ievent=ifirst; ievent<ilast; ievent++ ){  
    std::cout << " ===== Next Event: [" << ievent << "/" << ilast << "] ===== " << std::endl;

    WCSimInterface::LoadEvent(ievent);

    // process this event
    // ==================
    if( WCSimInterface::TouchEvent() ){

      // create new event
      fRecoEvent = WCSimInterface::RecoEvent();
      fTrueEvent = WCSimInterface::TrueEvent();

      // run reconstruction
      fReco->Run(fRecoEvent);

      // write to ntuple
      fNtuple->Fill( fTrueEvent, fRecoEvent );

    }
  }

  // close file
  // ==========
  fNtuple->CloseFile();

  return;
}

void WCSimNtupleWriter::Run ( Int_t  entries = -1  ) 

Definition at line 60 of file WCSimNtupleWriter.cc.

{
  this->Run(0,entries);
}

void WCSimNtupleWriter::SetFileName ( const char *  filename  )  [inline]

Definition at line 22 of file WCSimNtupleWriter.hh.

References fNtpFileName.

{ fNtpFileName = filename; }

void WCSimNtupleWriter::UseNtuple ( const char *  ntuple  )  [inline]

Definition at line 21 of file WCSimNtupleWriter.hh.

References fNtupleName.

{ fNtupleName = ntuple; }


Member Data Documentation

Definition at line 38 of file WCSimNtupleWriter.hh.

Referenced by BuildNtuple(), and SetFileName().

Definition at line 35 of file WCSimNtupleWriter.hh.

Referenced by BuildNtuple(), and Run().

TString WCSimNtupleWriter::fNtupleName [private]

Definition at line 37 of file WCSimNtupleWriter.hh.

Referenced by BuildNtuple(), and UseNtuple().

Definition at line 31 of file WCSimNtupleWriter.hh.

Referenced by BuildNtuple(), Run(), and ~WCSimNtupleWriter().

Definition at line 32 of file WCSimNtupleWriter.hh.

Referenced by Run().

Definition at line 33 of file WCSimNtupleWriter.hh.

Referenced by Run().


The documentation for this class was generated from the following files: