BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//____________________________________________________________________
// 
// 
// 

//____________________________________________________________________
//
// $Id: BrTrack.cxx,v 1.2 2001/08/14 19:26:23 pchristi Exp $
// $Author: pchristi $
// $Date: 2001/08/14 19:26:23 $
// $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov>
//
#ifndef BRAT_BrTrack
#include "BrTrack.h"
#endif

#ifndef ROOT_TMath
#include "TMath.h"
#endif

#ifndef BRAT_BrModule
#include "BrModule.h"
#endif

#ifndef WIN32
#include <iostream>
#include <iomanip>
#else
#include <iostream.h>
#include <iomanip.h>
#endif

//____________________________________________________________________

ClassImp(BrTrack);

//____________________________________________________________________
 BrTrack::BrTrack()
  : BrLine3D()
{
  // Default constructor
  ClearCovariance();
  fQuality = 0;
}

//  //___________________________________________________________________
//  BrTrack::BrTrack(const BrTrack &track)
//    : BrLine3D(track)
//  {
//    // Copy constructor
//    // 
//    SetQuality(track.GetQuality());

//    // Copy covariance matrix
//    for(Int_t i = 0; i < 4; i++) 
//      for(Int_t j = 0; j < 4; j++) 
//        SetCovariance(i, j, track.GetCovariance(i, j));
  
  
//  }
//  //____________________________________________________________________
//  BrTrack::~BrTrack()
//  {
//    // Default constructor - empty
//  }

//____________________________________________________________________
 void BrTrack::ClearCovariance()
{
  // Set all elements to 0
  for(Int_t i = 0; i < 4; i++)
    for(Int_t j = 0; j < 4; j++)
      SetCovariance(i, j, 0);
}

//____________________________________________________________________
 void BrTrack::Draw(Option_t *option = "")
{
  // Currently empty. Could as default draw a straight line and be 
  // overwritten in other hit modules
  return;
}

//____________________________________________________________________
 Float_t BrTrack::GetCovariance(Int_t x, Int_t y) const
{
  // return covariance element x, y
  // x and y should be {0, 1, 2, 3}
  // The order is {xslope, x, yslope, y}
  if (x > 3 || x < 0 || y > 3 || y < 0) {
    
    Warning("GetCovariance", "(%d, %d) not a valid index", x, y);
    return 0;
  }
  
  const Int_t index = x + y*4;
  return fCovMatrix[index];
}
//____________________________________________________________________
 Float_t BrTrack::GetPosError(Int_t index) const
{
  // return error on position 
  // 0 = x, 1 = y
  if (index > 1 || index < 0) {
    
    Warning("GetPosError", "%d not a valid index", index);
    return 0;
  }
  index = 2*index + 1; // 1, 3
  
  Float_t error = TMath::Sqrt(GetCovariance(index, index));
  return error;
}

//____________________________________________________________________
 Float_t BrTrack::GetSlopeError(Int_t index) const
{
  // return error on slope 
  // 0 = x, 1 = y
  // Note that the errors are calculated for slope z == 1
  // but the stored slope is normed to 1 so we scale the error with
  // 1/slope z 
  if (index > 1 || index < 0) {
    
    Warning("GetPosError", "%d not a valid index", index);
    return 0;
  }
  index = 2*index; // 0, 2
  
  Float_t error = TMath::Sqrt(GetCovariance(index, index));
  if(GetSlope()[2] > 0)
    error /= GetSlope()[2];
  
  return error;
}
  
//____________________________________________________________________
 void BrTrack::GetXYPositionAtZ(Float_t &x, Float_t &y, Float_t z) 
{
  // Return the x and y position at z for the track
  if(GetSlope()[2] == 0) {
    Warning("GetXYPositionAtZ", "z slope is 0");
    return;
  }
  
  Float_t t = (z-GetPos()[2])/GetSlope()[2];
  x = GetPos()[0] + t*GetSlope()[0];
  y = GetPos()[1] + t*GetSlope()[1];
}

//____________________________________________________________________
 void BrTrack::Print(Option_t* option = "") const
{
  // Print out the position and error, slope and error 
  // option c prints the covariance matrix as well
  cout << "Position : ";
  GetPos().Print();
  cout  << "Error    : ";
  cout << "(" << GetPosError(0) << ", " << GetPosError(1)
       << ", ?)" << endl;
  cout << "Slope : ";
  GetSlope().Print();
  cout  << "Error    : ";
  cout << "(" << GetSlopeError(0) << ", " << GetSlopeError(1)
       << ", ?)" << endl;
  cout << "Quality : " << fQuality << endl;

  TString opt(option);
  opt.ToLower(); 
  
  if (opt.Contains("c")) {
    //print the covariance matrix
    for(Int_t i = 0; i < 4; i++) {
      cout << "t";
      for(Int_t j = 0; j < 4; j++) {
	cout << setw(5) << setprecision(2) << GetCovariance(i, j);
      }
      cout << endl;
    }
  }
}

//____________________________________________________________________
 void BrTrack::SetCovariance(Int_t x, Int_t y, Float_t value)
{
  // set covariance element x, y
  // x and y should be {0, 1, 2, 3}
  // The order is {xslope, x, yslope, y}
  if (x > 3 || x < 0 || y > 3 || y < 0) {
    
    Warning("SetCovariance", "(%d, %d) not a valid index", x, y);
    return;
  }
  
  const Int_t index = x + y*4;
  fCovMatrix[index] = value;
}


//____________________________________________________________________
//
// $Log: BrTrack.cxx,v $
// Revision 1.2  2001/08/14 19:26:23  pchristi
// Removed detructors and copy constructors where the default was ok.
//
// Revision 1.1.1.1  2001/06/21 14:55:03  hagel
// Initial revision of brat2
//
// Revision 1.1  2001/06/17 17:41:58  pchristi
// The new tracking classes.
//
//



This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS