]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliStrLine.cxx
First V0 MC Analysis from H.Ricaud
[u/mrichter/AliRoot.git] / STEER / AliStrLine.cxx
index 5a6ab1d65d4310d4f708d8063b8796ed1c946ad2..d551919fd8852d5c61c4eed73abb0b99d0224eee 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
+/* $Id$ */
+
 ///////////////////////////////////////////////////////////////////
 //                                                               //
 // A straight line is coded as a point (3 Double_t) and           //
 // 3 direction cosines                                           //
 //                                                               //
 ///////////////////////////////////////////////////////////////////
+
 #include <Riostream.h>
 #include <TTree.h>
+#include <TMath.h>
+
 #include "AliStrLine.h"
 
 ClassImp(AliStrLine)
 
 //________________________________________________________
-AliStrLine::AliStrLine() {
+AliStrLine::AliStrLine() :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+ {
   // Default constructor
   for(Int_t i=0;i<3;i++) {
     fP0[i] = 0.;
+    fSigma2P0[i] = 0.;
     fCd[i] = 0.;
   }
-  fTpar = 0.;
-  SetDebug();
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = 0.;
+}
+
+//________________________________________________________
+AliStrLine::AliStrLine(Double_t *point, Double_t *cd,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
+  // Standard constructor
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  for(Int_t i=0;i<3;i++){ 
+    fSigma2P0[i] = 0.;
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = 0.;
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
 }
 
 //________________________________________________________
-AliStrLine::AliStrLine(Double_t *point, Double_t *cd) {
+AliStrLine::AliStrLine(Float_t *pointf, Float_t *cdf,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
+  // Standard constructor - with float arguments
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  Double_t point[3];
+  Double_t cd[3];
+  for(Int_t i=0;i<3;i++){
+    point[i] = pointf[i];
+    cd[i] = cdf[i];
+    fSigma2P0[i] = 0.;
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = 0.;
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+
+//________________________________________________________
+AliStrLine::AliStrLine(Double_t *point, Double_t *sig2point, Double_t *cd,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
   // Standard constructor
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  for(Int_t i=0;i<3;i++){ 
+    fSigma2P0[i] = sig2point[i];
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = 0.;
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+
+//________________________________________________________
+AliStrLine::AliStrLine(Float_t *pointf, Float_t *sig2point, Float_t *cdf,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
+  // Standard constructor - with float arguments
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  Double_t point[3];
+  Double_t cd[3];
+  for(Int_t i=0;i<3;i++){
+    point[i] = pointf[i];
+    cd[i] = cdf[i];
+    fSigma2P0[i] = sig2point[i];
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = 0.;
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+//________________________________________________________
+AliStrLine::AliStrLine(Double_t *point, Double_t *sig2point, Double_t *wmat, Double_t *cd,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
+  // Standard constructor
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  for(Int_t i=0;i<3;i++){ 
+    fSigma2P0[i] = sig2point[i];
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = wmat[i];
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+
+//________________________________________________________
+AliStrLine::AliStrLine(Float_t *pointf, Float_t *sig2point, Float_t *wmat, Float_t *cdf,Bool_t twopoints) :
+  TObject(),
+  fTpar(0),
+  fDebug(0)
+{
+  // Standard constructor - with float arguments
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  Double_t point[3];
+  Double_t cd[3];
+  for(Int_t i=0;i<3;i++){
+    point[i] = pointf[i];
+    cd[i] = cdf[i];
+    fSigma2P0[i] = sig2point[i];
+  }
+  for(Int_t i=0;i<9;i++) fWMatrix[i] = wmat[i];
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+//________________________________________________________
+void AliStrLine::InitDirection(Double_t *point, Double_t *cd){
+  // Initialization from a point and a direction
   Double_t norm = 0.;
   for(Int_t i=0;i<3;i++)norm+=cd[i]*cd[i];
   if(norm) {
@@ -53,6 +217,15 @@ AliStrLine::AliStrLine(Double_t *point, Double_t *cd) {
   SetDebug();
 }
 
+//________________________________________________________
+void AliStrLine::InitTwoPoints(Double_t *pA, Double_t *pB){
+  // Initialization from the coordinates of two
+  // points in the space
+  Double_t cd[3];
+  for(Int_t i=0;i<3;i++)cd[i] = pB[i]-pA[i];
+  InitDirection(pA,cd);
+}
+
 //________________________________________________________
 AliStrLine::~AliStrLine() {
   // destructor
@@ -68,6 +241,9 @@ void AliStrLine::PrintStatus() const {
   cout <<"Known point: ";
   for(Int_t i=0;i<3;i++)cout <<fP0[i]<<"; ";
   cout <<endl;
+  cout <<"Error on known point: ";
+  for(Int_t i=0;i<3;i++)cout <<TMath::Sqrt(fSigma2P0[i])<<"; ";
+  cout <<endl;
   cout <<"Current value for the parameter: "<<fTpar<<endl;
   cout <<" Debug flag: "<<fDebug<<endl;
 }
@@ -154,7 +330,7 @@ Int_t AliStrLine::Cross(AliStrLine *line, Double_t *point){
 }
 
 //___________________________________________________________
-Double_t AliStrLine::GetDCA(AliStrLine *line){
+Double_t AliStrLine::GetDCA(AliStrLine *line) const{
   //Returns the distance of closest approach between two lines
   Double_t p2[3];
   Double_t cd2[3];
@@ -195,3 +371,10 @@ void AliStrLine::GetCurrentPoint(Double_t *point) const {
   // 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;
 }
+
+//________________________________________________________
+Double_t AliStrLine::GetDistFromPoint(Double_t *point) const {
+  // computes distance from point 
+  AliStrLine tmp(point,(Double_t *)fCd,kFALSE);
+  return this->GetDCA(&tmp);
+}