95 vx0 = v[0] * m[0] + v[1] * m[1] + v[2] * m[2];
96 vy0 = v[0] * m[3] + v[1] * m[4] + v[2] * m[5];
97 vz0 = v[0] * m[6] + v[1] * m[7] + v[2] * m[8];
101 fX0 = p[0] * m[0] + p[1] * m[1] + p[2] * m[2];
102 fY0 = p[0] * m[3] + p[1] * m[4] + p[2] * m[5];
103 fZ0 = p[0] * m[6] + p[1] * m[7] + p[2] * m[8];
112 if (range) {r1 = range[0]; r2 = range[1];}
114 fRange[0] = 0.0; fRange[1] =
TMath::Pi();
115 SetRange(r1,r2,rType);
124 fX0 = fY0 = fZ0 = fVt = fPhi0 = fVz =
fAxis[0] =
fAxis[1] = 0.0;
163 r[0] = range[0]; r[1] = range[1];
165 r[0] = 0.0; r[1] = 1.0;
215 for(
Int_t i=0; i<3; i++)
218 for(
Int_t i=0; i<2; i++)
239 ((
THelix&)helix).THelix::Copy(*
this);
258 for (
Int_t i=0; i<3; i++)
262 delete ((
THelix&)obj).fRotMat;
291 std::cout <<
" THelix Printing N=" <<
fN<<
" Option="<<option<<std::endl;
307 out<<
"helix = new THelix("<<fX0<<
","<<fY0<<
","<<fZ0<<
","
311 <<quote<<
fOption<<quote<<
");"<<std::endl;
315 out<<
" helix->Draw();"<<std::endl;
327 Error(
"SetAxis()",
"Impossible! axis length %lf <= 0!", len);
330 fAxis[0] = axis[0]/len;
331 fAxis[1] = axis[1]/len;
332 fAxis[2] = axis[2]/len;
366 if ( fW != 0 && fVz != 0 ) {
372 for (i=0; i<2; i++ ) {
373 a[i] = fW / fVt * (range[i] -
fX0);
374 if ( a[i] < -1 || a[i] > 1 ) {
376 "range out of bound (%lf:%lf): %lf. Default used: %lf",
377 fX0-fVt/fW, fX0+fVt/fW, range[i],
fRange[i]);
381 fRange[i] = ( fPhi0 + halfpi - phase ) / fW;
386 for (i=0; i<2; i++ ) {
387 a[i] = fW / fVt * (range[i] -
fY0);
388 if ( a[i] < -1 || a[i] > 1 ) {
390 "range out of bound (%lf:%lf): %lf. Default used: %lf",
391 fY0-fVt/fW, fY0+fVt/fW, range[i],
fRange[i]);
395 fRange[i] = ( fPhi0 - phase ) / fW;
401 for (i=0; i<2; i++ ) {
406 "Vz = 0 and attempts to set range along helix axis!");
414 printf(
"setting range in lab axes is not implemented yet\n");
417 Error(
"SetRange()",
"unknown range type %d", rType);
420 }
else if ( fW == 0 ) {
431 "Vx = 0 and attempts to set range on helix x axis!");
441 "Vy = 0 and attempts to set range on helix y axis!");
451 "Vz = 0 and attempts to set range on helix z axis!");
458 printf(
"setting range in lab axes is not implemented yet\n");
461 Error(
"SetRange()",
"unknown range type %d", rType);
464 }
else if ( fVz == 0 ) {
474 "Vx = 0 and attempts to set range on helix x axis!");
484 "Vy = 0 and attempts to set range on helix y axis!");
490 "Vz = 0 and attempts to set range on helix z axis!");
495 printf(
"setting range in lab axes is not implemented yet\n");
498 Error(
"SetRange()",
"unknown range type %d", rType);
513 if (nSeg < THelix::fgMinNSeg) {
522 for (i=0; i<=nSeg; i++) {
524 if (i==nSeg) t =
fRange[1];
525 else t =
fRange[0] + dt * i;
526 phase2 = -fW * t +
fPhi0;
529 zl[i] = fZ0 + fVz *
t;
536 for (i=0; i<=nSeg; i++) {
537 xg = xl[i] * m[0] + yl[i] * m[3] + zl[i] * m[6] ;
538 yg = xl[i] * m[1] + yl[i] * m[4] + zl[i] * m[7] ;
539 zg = xl[i] * m[2] + yl[i] * m[5] + zl[i] * m[8] ;
543 delete[] xl;
delete[] yl;
delete[] zl;
553 range[0] =
r1; range[1] =
r2;
588 fRotMat =
new TRotMatrix(
"HelixRotMat",
"Master frame -> Helix frame",
589 theta1, phi1, theta2, phi2, theta3, phi3 );
604 while ( phi1 - phi0 > pi ) phi1 -= twopi;
605 while ( phi1 - phi0 < -pi ) phi1 += twopi;
607 while ( phi2 - phi0 > pi ) phi2 -= twopi;
608 while ( phi2 - phi0 < -pi ) phi2 += twopi;
620 void THelix::Streamer(
TBuffer &R__b)
630 TPolyLine3D::Streamer(R__b);
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void SetRotMatrix()
Set the rotational matrix according to the helix axis.
virtual void SetPolyLine(Int_t n, Option_t *option="")
Re-initialize polyline with n points (0,0,0).
virtual void SetAxis(Double_t *axis)
Set a new axis for the helix. This will make a new rotation matrix.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Buffer base class used for serializing objects.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
A 3-dimensional polyline.
virtual void Copy(TObject &helix) const
Copy this helix to obj.
virtual Int_t ReadStaticArray(Bool_t *b)=0
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual ~THelix()
Helix destructor.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
ClassImp(THelix) void THelix
Set all helix parameters.
THelix & operator=(const THelix &)
assignment operator
Double_t ATan2(Double_t, Double_t)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Copy(TObject &object) const
Copy this to obj.
virtual void Print(Option_t *option="") const
Dump this helix with its attributes.
THelix()
Helix default constructor.
Manages a detector rotation matrix.
unsigned int r1[N_CITIES]
TPolyLine3D & operator=(const TPolyLine3D &polylin)
assignment operator
virtual void SetRange(Double_t *range, EHelixRangeType rtype=kHelixZ)
Set a new range for the helix. This will remake the polyline.
void SetHelix(Double_t *xyz, Double_t *v, Double_t w, Double_t *range=0, EHelixRangeType type=kUnchanged, Double_t *axis=0)
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
THelix has two different constructors.
Mother of all ROOT objects.
typedef void((*Func_t)())
virtual void Draw(Option_t *option="")
Draw this helix with its current attributes.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Double_t Sqrt(Double_t x)
unsigned int r2[N_CITIES]
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Double_t FindClosestPhase(Double_t phi0, Double_t cosine)
Finds the closest phase to phi0 that gives cos(phase) = cosine.