#include "THaTrackOut.h"
#include <TLorentzVector.h>
#include <TTree.h>
#include "THaOutput.h"
#include "THaTrackingModule.h"
using namespace std;
THaTrackOut::THaTrackOut(const char* name, const char* description,
const char* src, Double_t pmass ) :
THaPhysicsModule(name,description), fM(pmass), fSrcName(src), fSrc(NULL)
{
fP4 = new TLorentzVector;
}
THaTrackOut::~THaTrackOut()
{
delete fP4;
}
void THaTrackOut::Clear( Option_t* )
{
fP4->SetXYZT(kBig,kBig,kBig,0);
}
void THaTrackOut::SetMass ( Double_t m )
{
fM = m;
}
void THaTrackOut::SetSpectrometer( const char* name )
{
if ( !IsInit())
fSrcName = name;
else
PrintInitError("SetSpectrometer()");
}
THaAnalysisObject::EStatus THaTrackOut::Init( const TDatime& run_time )
{
fSrc = dynamic_cast<THaTrackingModule*>
( FindModule( fSrcName.Data(), "THaTrackingModule"));
if ( !fSrc )
return fStatus;
if( THaPhysicsModule::Init( run_time ) != kOK )
return fStatus;
if( fM == 0.0 ) {
Warning( Here("Init"), "Particle mass not defined. Assuming mass of 0.0");
}
return fStatus;
}
Int_t THaTrackOut::InitOutput( THaOutput* output )
{
if (fOKOut) return 0;
if (!output) {
Error("InitOutput","Cannot get THaOutput object. Output initialization FAILED!");
return -2;
}
TTree* tree = output->GetTree();
if (!tree) {
Error("InitOutput","Cannot get Tree! Output initialization FAILED!");
return -3;
}
if ( tree->Branch(Form("%s.p4.",GetName()),"TLorentzVector",&fP4,4000) ) {
fOKOut = true;
}
if (fOKOut) return 0;
return -1;
}
Int_t THaTrackOut::Process( const THaEvData& )
{
if ( !IsOK() || !gHaRun ) return -1;
THaTrackInfo *trkifo = fSrc->GetTrackInfo();
if ( !trkifo || !trkifo->IsOK() ) return 1;
fP4->SetVectM( trkifo->GetPvect(), fM );
return 0;
}
ClassImp(THaTrackOut)
Last change: Sat Nov 7 21:26:53 2009
Last generated: 2009-11-07 21:26
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.