/************************************************************************** * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /////////////////////////////////////////////////////////////////// // // // A straight line is coded as a point (3 Double_t) and // // 3 direction cosines // // // /////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include "AliITSStrLine.h" ClassImp(AliITSStrLine) //________________________________________________________ AliITSStrLine::AliITSStrLine() { // Default constructor for(Int_t i=0;i<3;i++) { fP0[i] = 0.; fCd[i] = 0.; } fTpar = 0.; SetDebug(); } //________________________________________________________ AliITSStrLine::AliITSStrLine(Double_t *point, Double_t *cd) { // Standard constructor Double_t norm = 0.; for(Int_t i=0;i<3;i++)norm+=cd[i]*cd[i]; if(norm) { norm = TMath::Sqrt(norm); for(Int_t i=0;i<3;i++) cd[i]/=norm; } else { Error("AliITSStrLine","Null direction cosines!!!"); } SetP0(point); SetCd(cd); fTpar = 0.; SetDebug(); } //________________________________________________________ AliITSStrLine::~AliITSStrLine() { // destructor } //________________________________________________________ void AliITSStrLine::PrintStatus() const { // Print current status cout <<"=======================================================\n"; cout <<"Direction cosines: "; for(Int_t i=0;i<3;i++)cout <GetP0(p2); line->GetCd(cd2); Double_t a=fCd[0]; Double_t b=-cd2[0]; Double_t c=p2[0]-fP0[0]; Double_t d=fCd[1]; Double_t e=-cd2[1]; Double_t f=p2[1]-fP0[1]; Double_t deno = a*e-b*d; Int_t retcode = 0; if(deno != 0.) { fTpar = (c*e-b*f)/deno; } else { retcode = -1; } return retcode; } //________________________________________________________ Int_t AliITSStrLine::Cross(AliITSStrLine *line, Double_t *point){ // Looks for the crossing point estimated starting from the // DCA segment Double_t p2[3]; Double_t cd2[3]; line->GetP0(p2); line->GetCd(cd2); Int_t i; Double_t k1 = 0; for(i=0;i<3;i++)k1+=(fP0[i]-p2[i])*fCd[i]; Double_t k2 = 0; for(i=0;i<3;i++)k2+=(fP0[i]-p2[i])*cd2[i]; Double_t a11 = 0; for(i=0;i<3;i++)a11+=fCd[i]*cd2[i]; Double_t a22 = -a11; Double_t a21 = 0; for(i=0;i<3;i++)a21+=cd2[i]*cd2[i]; Double_t a12 = 0; for(i=0;i<3;i++)a12-=fCd[i]*fCd[i]; Double_t deno = a11*a22-a21*a12; if(deno == 0.) return -1; fTpar = (a11*k2-a21*k1) / deno; Double_t par2 = (k1*a22-k2*a12) / deno; line->SetPar(par2); Double_t point1[3]; Double_t point2[3]; GetCurrentPoint(point1); line->GetCurrentPoint(point2); for(i=0;i<3;i++)point[i]=(point1[i]+point2[i])/2.; return 0; } //________________________________________________________ void AliITSStrLine::GetCurrentPoint(Double_t *point){ // Fills the array point with the current value on the line for(Int_t i=0;i<3;i++)point[i]=fP0[i]+fCd[i]*fTpar; }