#include "THaAvgVertex.h"
#include "THaTrackingModule.h"
#include "THaTrackInfo.h"
#include "TMath.h"
#include "VarDef.h"
#include <iostream>
ClassImp(THaAvgVertex)
THaAvgVertex::THaAvgVertex( const char* name, const char* description,
const char* spectro1, const char* spectro2 ) :
THaPhysicsModule(name,description),
fName1(spectro1), fName2(spectro2), fSpectro1(NULL), fSpectro2(NULL)
{
Clear();
}
THaAvgVertex::~THaAvgVertex()
{
DefineVariables( kDelete );
}
void THaAvgVertex::Clear( Option_t* opt )
{
THaPhysicsModule::Clear(opt);
VertexClear();
}
Int_t THaAvgVertex::DefineVariables( EMode mode )
{
if( mode == kDefine && fIsSetup ) return kOK;
fIsSetup = ( mode == kDefine );
return DefineVarsFromList( THaVertexModule::GetRVarDef(), mode );
}
THaAnalysisObject::EStatus THaAvgVertex::Init( const TDatime& run_time )
{
if( THaPhysicsModule::Init( run_time ) != kOK )
return fStatus;
fSpectro1 = dynamic_cast<THaVertexModule*>
( FindModule( fName1.Data(), "THaVertexModule"));
if( !fSpectro1 )
return fStatus;
fSpectro2 = dynamic_cast<THaVertexModule*>
( FindModule( fName2.Data(), "THaVertexModule"));
return fStatus;
}
Int_t THaAvgVertex::Process( const THaEvData& )
{
static const int N = 2;
THaVertexModule* t[N] = { fSpectro1, fSpectro2 };
if( !IsOK() ) return -1;
if( !t[0]->HasVertex() ) return 1;
if( !t[1]->HasVertex() ) return 2;
fVertex.SetXYZ( 0.0, 0.0, 0.0 );
Double_t sigsum = 0.0;
for( Int_t it=0; it<N; it++ ) {
Double_t sigma = t[it]->GetVertexError()(2);
Double_t sig2 = sigma*sigma;
if( sig2 > 0.0 ) {
sigsum += 1.0/sig2;
for( Int_t i=0; i<3; i++ ) {
Double_t x = t[it]->GetVertex()(i);
fVertex(i) += x/sig2;
}
}
}
if( sigsum > 0.0 ) {
fVertex *= 1.0/sigsum;
}
fVertexOK = kTRUE;
return 0;
}
Last change: Sat Nov 7 21:26:42 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.