BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
//  $Id: BrDetectorTrack.cxx,v 1.1.1.1 2001/06/21 14:55:03 hagel Exp $
//
//

#include "BrDetectorTrack.h"
#include <iomanip.h>

ClassImp(BrDetectorTrack)

/////////////////////////////////////////////////////////////
//
// BrDetectorTrack is a BRAHMS data class for storing information for 
// a track 
//
//////////////////////////////////////////////////////////////

 BrDetectorTrack::BrDetectorTrack() {
  fId      = 0;
  fGroupId = 0;
  for(Int_t i=0;i<3;i++) {
    fPos[i]   = 0.0;
    fAlpha[i] = 0.0;
  }
  fFlag    = 0;
  fQuality = 0.0;
  fLocalTrackId = 0;
  fLocalTrack = 0;
}
//_____________________________________________________________
 void BrDetectorTrack::SetPos(const Float_t* val){
  fPos[0] = val[0];
  fPos[1] = val[1];
  fPos[2] = val[2];
}

//_____________________________________________________________
 void BrDetectorTrack::SetAlpha(const Float_t* val){
  fAlpha[0] = val[0];
  fAlpha[1] = val[1];
  fAlpha[2] = val[2];
}

//_____________________________________________________________
 Float_t BrDetectorTrack::RelativeOverlap(const BrDetectorTrack *dt_p, Float_t zl, Float_t r)
{
    //
    // Calculate the relative overlap between "this" track and the given track
    //
    // Parameters:
    //   In:  dt_p   pointer to the other track
    //        zl     length of detector (in local z direction)
    //        r      radius of cylinder around tracks
    //
    // Algorithm:
    //   A cylinder of radius r is put around each track.
    //   The relative overlap is defined as the ratio between
    //     the volume of the overlap region of two cylinders
    //   and
    //     the volume of the cylinder around "this" track is calculated.
    //   The cylinders are distorted in order to have a circular intersection
    //   between the cylinders and planes at arbitrary z.
    //
    // Requires:
    //   The tracks are parametrized as:
    //     x = ax * z + bx
    //     y = ay * z + by
    //   

    const Float_t twor  = 2*r;
    const Float_t halfl = zl/2;

    // Difference between the two tracks
    const Float_t dax = GetAlpha()[0] - dt_p->GetAlpha()[0];
    const Float_t day = GetAlpha()[1] - dt_p->GetAlpha()[1];
    const Float_t dbx = GetPos()[0]   - dt_p->GetPos()[0];
    const Float_t dby = GetPos()[1]   - dt_p->GetPos()[1];

    Float_t overlap = 0;
     
    const Float_t a = dax*dax + day*day;
    if (a == 0) {
        // Tracks are parallell
        const Float_t d = BrMath::Sqrt(dbx*dbx+dby*dby)/twor;
        if (d < 1)
            overlap = BrMath::ACos(d)-d*BrMath::Sqrt(1-d*d);
    } else {
        const Float_t b = (dax*dbx+day*dby)/a;
        const Float_t c = (dbx*dbx+dby*dby)/a;
        Float_t d = b*b-c+twor*twor/a;
        if (d > 0) {
            // Cylinders intersect
            d = BrMath::Sqrt(d);
            Float_t zn = -b - d;
            Float_t zx = -b + d;
            if (zn < -halfl) zn = -halfl;
            if (zx >  halfl) zx =  halfl;
            if (zn < zx) {
	      // Cylinders intersect inside the detector
	      //
	      // Integrate
	      //   acos(d(z)/(2r))-d(z)/(2r)*sqrt(1-(d(z)/(2r))**2)
	      // where
	      //   d(z)/(2r)=sqrt(a*((z+2*b)*z+c))/(2*r)
	      // from zn to zx
	      // 
	      // Quick and dirty implementation: Simple N-point rule
	      const Int_t   n  = 5;
	      const Float_t dz = (zx-zn)/n;
	      for (Int_t i = 0; i < n; i++) {
		Float_t z = zn + dz*(i+0.5);
		d = BrMath::Sqrt(a*((z+2*b)*z+c))/twor;
		overlap += BrMath::ACos(d)-d*BrMath::Sqrt(1-d*d);
	      }
	      overlap *= dz/zl;
            }
        }
    }

    return overlap/(BrMath::Pi/2);
}

//_____________________________________________________________
ostream& operator<< (ostream & os,BrDetectorTrack *track_p)
{

 os<<"Detector track"<<endl;
 os<<"Track origin = (";
 os<<setw(8)<<track_p->GetPos()[0]<<",";
 os<<setw(8)<<track_p->GetPos()[1]<<",";
 os<<setw(8)<<track_p->GetPos()[2]<<")n";
 os<<"Track vector = (";
 os<<setw(8)<<track_p->GetAlpha()[0]<<",";
 os<<setw(8)<<track_p->GetAlpha()[1]<<",";
 os<<setw(8)<<track_p->GetAlpha()[2]<<")";
 os<<endl;
return os;
}

 BrLine3D BrDetectorTrack::GetTrackLine() {
  BrLine3D line(fPos,fAlpha);
  return line;
}


//  $Log: BrDetectorTrack.cxx,v $
//  Revision 1.1.1.1  2001/06/21 14:55:03  hagel
//  Initial revision of brat2
//
//  Revision 1.12  2001/04/18 20:18:43  videbaek
//  moved cvs log
//
//  Revision 1.11  2000/05/05 09:50:30  bjornhs
//  Added RelativeOverlap in BrLocalTrack
//
//  Revision 1.10  2000/04/28 21:18:58  videbaek
//  Updates to BrLocalTrack. Added fit method; Status is changed. Uses
//  MarkAsBad, IsBad instead of fixed 999.
//  Cleanup of BrModuleMatchtrack. Added histohgrams.
//  Changed LocalTrack and LocalTracking to use IsBad etc.
//
//  Revision 1.9  2000/01/18 18:41:18  videbaek
//  ved covariance to output.
//
//  Revision 1.8  1999/04/02 15:29:48  hagel
//  Zero elements in constructor BrDetectorTrack.cxx
//
//  Revision 1.7  1999/03/07 22:38:03  videbaek
//  Added DetectorHit and BrLocalTrackingModule as a more general way to
//  deal with local tracks and hits. Initial insertion. Not fully debugged.
//  Cosmetic changes to other modules.
//
//  Revision 1.6  1999/03/07 00:00:46  hagel
//
//  Revision 1.5  1999/02/26 21:14:41  hagel
//  Minor changes to make compatible with BrFSTrackingModule
//
//  Revision 1.4  1998/12/04 21:35:58  videbaek
//  Started updating structures for tracking. Using BrVector3D
//  in many places where double* or float* was used before.
//  Fix type SHLIB->$(SHLIB) .. in makefile
//



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