// @(#)root/geom:$Id$
// Author: Andrei Gheata   28/04/04

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGeoHelix
#define ROOT_TGeoHelix


#ifndef ROOT_TObject
#include "TObject.h"
#endif

class TGeoHMatrix;

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TGeoHelix - A helix defined by:                                        //
//     x = (1/c) * COS(phi)                                               //
//     y = (1/c) * SIN(phi)                                               //
//     z = s * alfa                                                       //
// where:                                                                 //
//     c = 1/Rxy  - curvature in XY plane                                 //
//     phi        - phi angle                                             //
//     S = 2*PI*s - vertical separation between helix loops               //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

class TGeoHelix  : public TObject
{
private :
   Double_t           fC;              // curvature in XY plane
   Double_t           fS;              // Z step of the helix / 2*PI
   Double_t           fStep;           // current step
   Double_t           fPhi;            // phi angle
   Double_t           fPointInit[3];   // initial point
   Double_t           fDirInit[3];     // normalized initial direction
   Double_t           fPoint[3];       // point after a step
   Double_t           fDir[3];         // direction after a step
   Double_t           fB[3];           // normalized direction for magnetic field
   Int_t              fQ;              // right/left-handed (+/- 1) - "charge"
   TGeoHMatrix       *fMatrix;         // transformation of local helix frame to MARS

   TGeoHelix(const TGeoHelix&);             // Not implemented
   TGeoHelix &operator=(const TGeoHelix&);  // Not implemented
public:
   enum EGeoHelixTypes {
      kHelixNeedUpdate =   BIT(16),
      kHelixStraigth   =   BIT(17),
      kHelixCircle     =   BIT(18)
   };
   // constructors
   TGeoHelix();
   TGeoHelix(Double_t curvature, Double_t step, Int_t charge=1);
   // destructor
   virtual ~TGeoHelix();

   void            InitPoint(Double_t x0, Double_t y0, Double_t z0);
   void            InitPoint(Double_t *point);
   void            InitDirection(Double_t dirx, Double_t diry, Double_t dirz, Bool_t is_normalized=kTRUE);
   void            InitDirection(Double_t *dir, Bool_t is_normalized=kTRUE);

   Double_t        ComputeSafeStep(Double_t epsil=1E-6) const;
   const Double_t *GetCurrentPoint() const {return fPoint;}
   const Double_t *GetCurrentDirection() const {return fDir;}
   Double_t        GetXYcurvature() const {return fC;}
   Double_t        GetStep() const {return fStep;}
   Double_t        GetTotalCurvature() const;
   Bool_t          IsRightHanded() const {return (fQ>0)?kFALSE:kTRUE;} // a positive charge in B field makes a left-handed helix

   void            ResetStep();
   Double_t        StepToPlane(Double_t *point, Double_t *norm);
//   Double_t       *StepToPlane(Double_t a, Double_t b, Double_t c);

   void            SetCharge(Int_t charge);
   void            SetXYcurvature(Double_t curvature);
   void            SetField(Double_t bx, Double_t by, Double_t bz, Bool_t is_normalized=kTRUE);
   void            SetHelixStep(Double_t hstep);

   void            Step(Double_t step);

   void            UpdateHelix();

   ClassDef(TGeoHelix, 1)              // helix class
};

#endif

 TGeoHelix.h:1
 TGeoHelix.h:2
 TGeoHelix.h:3
 TGeoHelix.h:4
 TGeoHelix.h:5
 TGeoHelix.h:6
 TGeoHelix.h:7
 TGeoHelix.h:8
 TGeoHelix.h:9
 TGeoHelix.h:10
 TGeoHelix.h:11
 TGeoHelix.h:12
 TGeoHelix.h:13
 TGeoHelix.h:14
 TGeoHelix.h:15
 TGeoHelix.h:16
 TGeoHelix.h:17
 TGeoHelix.h:18
 TGeoHelix.h:19
 TGeoHelix.h:20
 TGeoHelix.h:21
 TGeoHelix.h:22
 TGeoHelix.h:23
 TGeoHelix.h:24
 TGeoHelix.h:25
 TGeoHelix.h:26
 TGeoHelix.h:27
 TGeoHelix.h:28
 TGeoHelix.h:29
 TGeoHelix.h:30
 TGeoHelix.h:31
 TGeoHelix.h:32
 TGeoHelix.h:33
 TGeoHelix.h:34
 TGeoHelix.h:35
 TGeoHelix.h:36
 TGeoHelix.h:37
 TGeoHelix.h:38
 TGeoHelix.h:39
 TGeoHelix.h:40
 TGeoHelix.h:41
 TGeoHelix.h:42
 TGeoHelix.h:43
 TGeoHelix.h:44
 TGeoHelix.h:45
 TGeoHelix.h:46
 TGeoHelix.h:47
 TGeoHelix.h:48
 TGeoHelix.h:49
 TGeoHelix.h:50
 TGeoHelix.h:51
 TGeoHelix.h:52
 TGeoHelix.h:53
 TGeoHelix.h:54
 TGeoHelix.h:55
 TGeoHelix.h:56
 TGeoHelix.h:57
 TGeoHelix.h:58
 TGeoHelix.h:59
 TGeoHelix.h:60
 TGeoHelix.h:61
 TGeoHelix.h:62
 TGeoHelix.h:63
 TGeoHelix.h:64
 TGeoHelix.h:65
 TGeoHelix.h:66
 TGeoHelix.h:67
 TGeoHelix.h:68
 TGeoHelix.h:69
 TGeoHelix.h:70
 TGeoHelix.h:71
 TGeoHelix.h:72
 TGeoHelix.h:73
 TGeoHelix.h:74
 TGeoHelix.h:75
 TGeoHelix.h:76
 TGeoHelix.h:77
 TGeoHelix.h:78
 TGeoHelix.h:79
 TGeoHelix.h:80
 TGeoHelix.h:81
 TGeoHelix.h:82
 TGeoHelix.h:83
 TGeoHelix.h:84
 TGeoHelix.h:85
 TGeoHelix.h:86
 TGeoHelix.h:87
 TGeoHelix.h:88
 TGeoHelix.h:89
 TGeoHelix.h:90
 TGeoHelix.h:91
 TGeoHelix.h:92
 TGeoHelix.h:93
 TGeoHelix.h:94