New class used for primary vertex finding (AliITSVertexerTracks)
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Feb 2003 16:12:53 +0000 (16:12 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Feb 2003 16:12:53 +0000 (16:12 +0000)
ITS/AliITSStrLine.cxx [new file with mode: 0644]
ITS/AliITSStrLine.h [new file with mode: 0644]

diff --git a/ITS/AliITSStrLine.cxx b/ITS/AliITSStrLine.cxx
new file mode 100644 (file)
index 0000000..3d912d7
--- /dev/null
@@ -0,0 +1,139 @@
+/**************************************************************************
+ * 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 <Riostream.h>
+#include <TMath.h>
+#include <TObject.h>
+#include <TObjArray.h>
+#include <TTree.h>
+#include <TClonesArray.h>
+#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 <<fCd[i]<<"; ";
+  cout <<endl;
+  cout <<"Known point: ";
+  for(Int_t i=0;i<3;i++)cout <<fP0[i]<<"; ";
+  cout <<endl;
+  cout <<"Current value for the parameter: "<<fTpar<<endl;
+  cout <<" Debug flag: "<<fDebug<<endl;
+}
+
+//________________________________________________________
+Int_t AliITSStrLine::Crossrphi(AliITSStrLine *line){
+  // Cross 2 lines in the X-Y plane
+  Double_t p2[3];
+  Double_t cd2[3];
+  line->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;
+}
diff --git a/ITS/AliITSStrLine.h b/ITS/AliITSStrLine.h
new file mode 100644 (file)
index 0000000..3654d6e
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef ALIITSSTRLINE_H
+#define ALIITSSTRLINE_H
+/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+///////////////////////////////////////////////////////////////////
+//                                                               //
+// A straight line is coded as a point (3 Double_t) and           //
+// 3 direction cosines                                           //
+//                                                               //
+///////////////////////////////////////////////////////////////////
+
+
+class AliITSStrLine : public TObject {
+
+ public:
+    AliITSStrLine();        // default constructor
+    AliITSStrLine(Double_t *point, Double_t *cd);  // standard constructor
+    virtual ~AliITSStrLine(); // destructor
+    void PrintStatus() const;
+    void SetP0(Double_t *point) {for(Int_t i=0;i<3;i++)fP0[i]=point[i];}
+    void SetCd(Double_t *cd) {for(Int_t i=0;i<3;i++)fCd[i]=cd[i];}
+    void SetDebug(Int_t dbfl = 0){fDebug = dbfl; }  
+    void GetP0(Double_t *point) {for(Int_t i=0;i<3;i++)point[i]=fP0[i];}
+    void GetCd(Double_t *cd) {for(Int_t i=0;i<3;i++)cd[i]=fCd[i];}
+    void GetCurrentPoint(Double_t *point);
+    Int_t Crossrphi(AliITSStrLine *line);
+    Int_t Cross(AliITSStrLine *line,Double_t *point);
+ private:
+    void SetPar(Double_t par){fTpar = par;}
+ protected:
+    Double_t fP0[3];           // given point
+    Double_t fCd[3];           // direction cosines
+    Double_t fTpar;            //! parameter 
+    Int_t   fDebug;           //! debug flag - verbose printing if >0
+  ClassDef(AliITSStrLine,1);
+};
+
+#endif