#include "THaPrimaryKine.h"
#include "THaSecondaryKine.h"
#include "THaTrackingModule.h"
#include "VarDef.h"
#include "TLorentzVector.h"
#include "TVector3.h"
#include "TMath.h"
#include "TRotation.h"
using namespace std;
ClassImp(THaSecondaryKine)
THaSecondaryKine::THaSecondaryKine( const char* name, const char* description,
const char* secondary_spectro,
const char* primary_kine,
Double_t secondary_mass ) :
THaPhysicsModule(name,description), fMX(secondary_mass),
fSpectroName(secondary_spectro), fSpectro(NULL),
fPrimaryName(primary_kine), fPrimary(NULL)
{
}
THaSecondaryKine::~THaSecondaryKine()
{
DefineVariables( kDelete );
}
void THaSecondaryKine::Clear( Option_t* opt )
{
THaPhysicsModule::Clear(opt);
fTheta_xq = fPhi_xq = fTheta_bq = fPhi_bq = fXangle = fPmiss
= fPmiss_x = fPmiss_y = fPmiss_z = fEmiss = fMrecoil = fErecoil
= fTX = fTB = fPX_cm = fTheta_x_cm = fPhi_x_cm = fTheta_b_cm
= fPhi_b_cm = fTX_cm = fTB_cm = fTtot_cm = fMandelS = fMandelT
= fMandelU = fPrecoil_x = fPrecoil_y = fPrecoil_z = kBig;
fX.SetXYZT(kBig,kBig,kBig,kBig);
fB.SetXYZT(kBig,kBig,kBig,kBig);
}
Int_t THaSecondaryKine::DefineVariables( EMode mode )
{
if( mode == kDefine && fIsSetup ) return kOK;
fIsSetup = ( mode == kDefine );
RVarDef vars[] = {
{ "th_xq", "Polar angle of detected particle with q (rad)",
"fTheta_xq" },
{ "ph_xq", "Azimuth of detected particle with scattering plane (rad)",
"fPhi_xq" },
{ "th_bq", "Polar angle of recoil system with q (rad)", "fTheta_bq" },
{ "ph_bq", "Azimuth of recoil system with scattering plane (rad)",
"fPhi_bq" },
{ "xangle", "Angle of detected particle with scattered electron (rad)",
"fXangle" },
{ "pmiss", "Missing momentum magnitude (GeV), nuclear physics "
"definition (-pB)", "fPmiss" },
{ "pmiss_x", "x-component of p_miss wrt q (GeV)", "fPmiss_x" },
{ "pmiss_y", "y-component of p_miss wrt q (GeV)", "fPmiss_y" },
{ "pmiss_z", "z-component of p_miss, along q (GeV)", "fPmiss_z" },
{ "emiss", "Missing energy (GeV), nuclear physics definition "
"omega-Tx-Tb", "fEmiss" },
{ "Mrecoil", "Invariant mass of recoil system (GeV)", "fMrecoil" },
{ "Erecoil", "Total energy of recoil system (GeV)", "fErecoil" },
{ "Prec_x", "x-component of recoil system in lab (GeV/c)", "fB.X()" },
{ "Prec_y", "y-component of recoil system in lab (GeV/c)", "fB.Y()" },
{ "Prec_z", "z-component of recoil system in lab (GeV/c)", "fB.Z()" },
{ "tx", "Kinetic energy of detected particle (GeV)", "fTX" },
{ "tb", "Kinetic energy of recoil system (GeV)", "fTB" },
{ "px_cm", "Magnitude of X momentum in CM system (GeV)", "fPX_cm" },
{ "thx_cm", "Polar angle of X in CM system wrt q (rad)", "fTheta_x_cm" },
{ "phx_cm", "Azimuth of X in CM system wrt q (rad)", "fPhi_x_cm" },
{ "thb_cm", "Polar angle of recoil systm in CM wrt q (rad)",
"fTheta_b_cm" },
{ "phb_cm", "Azimuth of recoil system in CM wrt q (rad)", "fPhi_b_cm" },
{ "tx_cm", "Kinetic energy of X in CM (GeV)", "fTX_cm" },
{ "tb_cm", "Kinetic energy of B in CM (GeV)", "fTB_cm" },
{ "t_tot_cm", "Total CM kinetic energy", "fTtot_cm" },
{ "MandelS", "Mandelstam s for secondary vertex (GeV^2)", "fMandelS" },
{ "MandelT", "Mandelstam t for secondary vertex (GeV^2)", "fMandelT" },
{ "MandelU", "Mandelstam u for secondary vertex (GeV^2)", "fMandelU" },
{ 0 }
};
return DefineVarsFromList( vars, mode );
}
THaAnalysisObject::EStatus THaSecondaryKine::Init( const TDatime& run_time )
{
if( THaPhysicsModule::Init( run_time ) != kOK )
return fStatus;
fSpectro = dynamic_cast<THaTrackingModule*>
( FindModule( fSpectroName.Data(), "THaTrackingModule"));
if( fStatus ) return fStatus;
fPrimary = dynamic_cast<THaPrimaryKine*>
( FindModule( fPrimaryName.Data(), "THaPrimaryKine"));
return fStatus;
}
Int_t THaSecondaryKine::Process( const THaEvData& )
{
if( !IsOK() ) return -1;
THaTrackInfo* trkifo = fSpectro->GetTrackInfo();
if( !trkifo || !trkifo->IsOK() ) return 1;
if( !fPrimary->DataValid() ) return 2;
const TVector3& pX3 = trkifo->GetPvect();
fX.SetVectM( pX3, fMX );
const TLorentzVector* pA = fPrimary->GetA();
const TLorentzVector* pA1 = fPrimary->GetA1();
const TLorentzVector* pQ = fPrimary->GetQ();
const TLorentzVector* pP1 = fPrimary->GetP1();
Double_t omega = fPrimary->GetOmega();
fB = *pA1 - fX;
fXangle = fX.Angle( pP1->Vect());
TRotation rot_to_q;
rot_to_q.SetZAxis( pQ->Vect(), pP1->Vect()).Invert();
TVector3 xq = fX.Vect();
TVector3 bq = fB.Vect();
xq *= rot_to_q;
bq *= rot_to_q;
fTheta_xq = xq.Theta();
fPhi_xq = xq.Phi();
fTheta_bq = bq.Theta();
fPhi_bq = bq.Phi();
TVector3 p_miss = -bq;
fPmiss = p_miss.Mag();
fPmiss_x = p_miss.X();
fPmiss_y = p_miss.Y();
fPmiss_z = p_miss.Z();
fMrecoil = fB.M();
fTX = fX.E() - fMX;
fTB = fB.E() - fMrecoil;
fEmiss = omega - fTX - fTB;
fErecoil = fB.E();
fPrecoil_x = fB.X();
fPrecoil_y = fB.Y();
fPrecoil_z = fB.Z();
Double_t beta = pA1->P()/(pA1->E());
TVector3 boost(0.,0.,-beta);
TRotation rot_to_A1;
rot_to_A1.SetZAxis( pA1->Vect(), pP1->Vect()).Invert();
TVector3 x_cm_vect = fX.Vect();
x_cm_vect *= rot_to_A1;
TLorentzVector x_cm(x_cm_vect,fX.E());
x_cm.Boost(boost);
TLorentzVector b_cm(-x_cm.Vect(), pA1->E()-x_cm.E());
fPX_cm = x_cm.P();
fTheta_x_cm = x_cm.Theta();
fPhi_x_cm = x_cm.Phi();
fTheta_b_cm = b_cm.Theta();
fPhi_b_cm = b_cm.Phi();
fTX_cm = x_cm.E() - fMX;
fTB_cm = b_cm.E() - fMrecoil;
fTtot_cm = fTX_cm + fTB_cm;
fMandelS = (*pQ+*pA).M2();
fMandelT = (*pQ-fX).M2();
fMandelU = (*pQ-fB).M2();
fDataValid = true;
return 0;
}
Int_t THaSecondaryKine::ReadRunDatabase( const TDatime& date )
{
Int_t err = THaPhysicsModule::ReadRunDatabase( date );
if( err ) return err;
FILE* f = OpenRunDBFile( date );
if( !f ) return kFileError;
if ( fMX <= 0.0 ) {
TString name(fPrefix), tag("MX"); name += tag;
Int_t st = LoadDBvalue( f, date, name.Data(), fMX );
if( st )
LoadDBvalue( f, date, tag.Data(), fMX );
if( fMX <= 0.0 ) fMX = 0.938;
}
fclose(f);
return 0;
}
void THaSecondaryKine::SetMX( Double_t m )
{
if( !IsInit())
fMX = m;
else
PrintInitError("SetMX()");
}
void THaSecondaryKine::SetSpectrometer( const char* name )
{
if( !IsInit())
fSpectroName = name;
else
PrintInitError("SetSpectrometer()");
}
void THaSecondaryKine::SetPrimary( const char* name )
{
if( !IsInit())
fPrimaryName = name;
else
PrintInitError("SetPrimary()");
}
Last change: Sat Nov 7 21:26:51 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.