/*
$Log$
+Revision 1.17 2002/10/31 10:16:40 hristov
+Minor corrections for warnings on Alpha
+
+Revision 1.16 2002/10/22 14:45:40 alibrary
+Introducing Riostream.h
+
+Revision 1.15 2002/10/14 14:57:00 hristov
+Merging the VirtualMC branch to the main development branch (HEAD)
+
+Revision 1.13.6.1 2002/06/10 17:51:15 hristov
+Merged with v3-08-02
+
+Revision 1.14 2002/05/19 18:17:03 hristov
+Changes needed by ICC/IFC compiler (Intel)
+
+Revision 1.13 2002/01/28 21:49:19 nilsen
+Fixed a logical bug in functions GtoLPositionError, LtoGPositionError,
+GtoLPositionErrorTracking, and LtoGPositionErrorTracking.
+
+Revision 1.12 2001/10/12 22:07:20 nilsen
+A patch for C++ io manipulation functions so that they will work both
+with GNU gcc 2.96 and GNU gcc 3.01 compilers. Needs to be tested with
+other platforms.
+
+Revision 1.11 2001/09/04 14:54:31 hristov
+Const multidimentional arrays cause problems in the CINT dictionary on HP, const removed
+
+Revision 1.10 2001/08/24 21:06:37 nilsen
+Added more documentation, fixed up some coding violations, and some
+forward declorations.
+
+Revision 1.9 2001/03/23 15:21:56 nilsen
+Added Cylinderical Coordinates for use with Tracking. Fixed a but in the
+Streamer, It was not setting a value for frot[3] as it should when reading.
+
+Revision 1.8 2001/02/09 00:00:57 nilsen
+Fixed compatibility problem with HP unix {ios::fmtflags -> Int_t}. Fixed
+bugs in iostream based streamers used to read and write .det files. Fixed
+some detector sizes. Fixed bugs in some default-special constructors.
+
+Revision 1.7 2001/02/03 00:00:30 nilsen
+New version of AliITSgeom and related files. Now uses automatic streamers,
+set up for new formatted .det file which includes detector information.
+Additional smaller modifications are still to come.
+
+Revision 1.5 2000/10/02 16:32:35 barbera
+Forward declaration added
+
Revision 1.1.2.6 2000/10/02 15:52:05 barbera
Forward declaration added
A new class to hold the matrix information needed by AliITSgeom.
*/
-#include <iostream.h>
+
+////////////////////////////////////////////////////////////////////////
+// This is the implementation file for AliITSgeomMatrix class. It
+// contains the routines to manipulate, setup, and queary the geometry
+// of a given ITS module. An ITS module may be one of at least three
+// ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
+// and variations of these in size and/or layout. These routines let
+// one go between ALICE global coordiantes (cm) to a given modules
+// specific local coordinates (cm).
+////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
#include <TMath.h>
#include <TBuffer.h>
+#include <TClass.h>
#include "AliITSgeomMatrix.h"
fid[i] = 0;
frot[i] = ftran[i] = 0.0;
for(j=0;j<3;j++) fm[i][j] = 0.0;
+ fCylR = fCylPhi = 0.0;
}// end for i
fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
}
this->fid[i] = sourse.fid[i];
this->frot[i] = sourse.frot[i];
this->ftran[i] = sourse.ftran[i];
+ this->fCylR = sourse.fCylR;
+ this->fCylPhi = sourse.fCylPhi;
for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
}// end for i
}
this->fid[i] = sourse.fid[i];
this->frot[i] = sourse.frot[i];
this->ftran[i] = sourse.ftran[i];
+ this->fCylR = sourse.fCylR;
+ this->fCylPhi = sourse.fCylPhi;
for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
}// end for i
}
*/
//End_Html
////////////////////////////////////////////////////////////////////////
- Int_t i;
+ Int_t i;
- fDetectorIndex = idt; // a value never defined.
- for(i=0;i<3;i++){
- fid[i] = id[i];
- frot[i] = rot[i];
- ftran[i] = tran[i];
- }// end for i
- this->MatrixFromAngle();
+ fDetectorIndex = idt; // a value never defined.
+ for(i=0;i<3;i++){
+ fid[i] = id[i];
+ frot[i] = rot[i];
+ ftran[i] = tran[i];
+ }// end for i
+ fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+ fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+ if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+ this->MatrixFromAngle();
}
//----------------------------------------------------------------------
AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
*/
//End_Html
////////////////////////////////////////////////////////////////////////
- Int_t i,j;
+ Int_t i,j;
- fDetectorIndex = idt; // a value never defined.
- for(i=0;i<3;i++){
- fid[i] = id[i];
- ftran[i] = tran[i];
- for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
- }// end for i
- this->AngleFromMatrix();
+ fDetectorIndex = idt; // a value never defined.
+ for(i=0;i<3;i++){
+ fid[i] = id[i];
+ ftran[i] = tran[i];
+ for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
+ }// end for i
+ fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+ fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+ if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+ this->AngleFromMatrix();
}
//----------------------------------------------------------------------
void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
fid[i] = id[i];
ftran[i] = tran[i];
}// end for i
+ fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+ fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+ if(fCylPhi<0.0) fCylPhi += TMath::Pi();
this->MatrixFromSixAngles(rotd);
}
//----------------------------------------------------------------------
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionError(Double_t g[3][3],
+void AliITSgeomMatrix::GtoLPositionError( Double_t g[3][3],
Double_t l[3][3]){
////////////////////////////////////////////////////////////////////////
// Given an Uncertainty matrix in Global coordinates it is rotated so that
////////////////////////////////////////////////////////////////////////
Int_t i,j,k,m;
- for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
- l[i][m] = fm[j][i]*g[j][k]*fm[k][m];
- // g = R^t l R
+ for(i=0;i<3;i++)for(m=0;m<3;m++){
+ l[i][m] = 0.0;
+ for(j=0;j<3;j++)for(k=0;k<3;k++)
+ l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
+ } // end for i,m
+ // g = R^t l R
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGPositionError(Double_t l[3][3],
+void AliITSgeomMatrix::LtoGPositionError( Double_t l[3][3],
Double_t g[3][3]){
////////////////////////////////////////////////////////////////////////
// Given an Uncertainty matrix in Local coordinates it is rotated so that
////////////////////////////////////////////////////////////////////////
Int_t i,j,k,m;
- for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
- g[i][m] = fm[i][j]*l[j][k]*fm[m][k];
- // g = R l R^t
+ for(i=0;i<3;i++)for(m=0;m<3;m++){
+ g[i][m] = 0.0;
+ for(j=0;j<3;j++)for(k=0;k<3;k++)
+ g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
+ } // end for i,m
+ // g = R l R^t
return;
}
//----------------------------------------------------------------------
l[2] = +l0[2];
} // end if
return;
- return;
}
//----------------------------------------------------------------------
void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionErrorTracking(Double_t g[3][3],
+void AliITSgeomMatrix::GtoLPositionErrorTracking( Double_t g[3][3],
Double_t l[3][3]){
////////////////////////////////////////////////////////////////////////
// A slightly different coordinate system is used when tracking.
//End_Html
////////////////////////////////////////////////////////////////////////
Int_t i,j,k,m;
- Double_t Rt[3][3];
- Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
- Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
+ Double_t rt[3][3];
+ Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
+ Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
- Rt[i][k] = A0[i][j]*fm[j][k];
+ rt[i][k] = a0[i][j]*fm[j][k];
else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
- Rt[i][k] = A1[i][j]*fm[j][k];
- for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
- l[i][m] = Rt[j][i]*g[j][k]*Rt[k][m];
- // g = R^t l R
+ rt[i][k] = a1[i][j]*fm[j][k];
+ for(i=0;i<3;i++)for(m=0;m<3;m++){
+ l[i][m] = 0.0;
+ for(j=0;j<3;j++)for(k=0;k<3;k++)
+ l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
+ } // end for i,m
+ // g = R^t l R
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGPositionErrorTracking(Double_t l[3][3],
+void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
Double_t g[3][3]){
////////////////////////////////////////////////////////////////////////
// A slightly different coordinate system is used when tracking.
//End_Html
////////////////////////////////////////////////////////////////////////
Int_t i,j,k,m;
- Double_t Rt[3][3];
- Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
- Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
+ Double_t rt[3][3];
+ Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
+ Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
- Rt[i][k] = A0[i][j]*fm[j][k];
+ rt[i][k] = a0[i][j]*fm[j][k];
else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
- Rt[i][k] = A1[i][j]*fm[j][k];
- for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
- g[i][m] = Rt[i][j]*l[j][k]*Rt[m][k];
- // g = R l R^t
+ rt[i][k] = a1[i][j]*fm[j][k];
+ for(i=0;i<3;i++)for(m=0;m<3;m++){
+ g[i][m] = 0.0;
+ for(j=0;j<3;j++)for(k=0;k<3;k++)
+ g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
+ } // end for i,m
+ // g = R l R^t
return;
}
//----------------------------------------------------------------------
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::print(ostream *os){
+void AliITSgeomMatrix::PrintComment(ostream *os){
+////////////////////////////////////////////////////////////////////////
+// output format used by Print..
+////////////////////////////////////////////////////////////////////////
+ *os << "fDetectorIndex fid[0] fid[1] fid[2] ftran[0] ftran[1] ftran[2] ";
+ *os << "fm[0][0] fm[0][1] fm[0][2] fm[1][0] fm[1][1] fm[1][2] ";
+ *os << "fm[2][0] fm[2][1] fm[2][2] ";
+ return;
+}
+//----------------------------------------------------------------------
+void AliITSgeomMatrix::Print(ostream *os){
////////////////////////////////////////////////////////////////////////
// Standard output format for this class.
////////////////////////////////////////////////////////////////////////
Int_t i,j;
-
+#if defined __GNUC__
+#if __GNUC__ > 2
+ ios::fmtflags fmt;
+#else
+ Int_t fmt;
+#endif
+#else
+#if defined __ICC || defined __ECC
+ ios::fmtflags fmt;
+#else
+ Int_t fmt;
+#endif
+#endif
+
+ fmt = os->setf(ios::scientific); // set scientific floating point output
*os << fDetectorIndex << " ";
for(i=0;i<3;i++) *os << fid[i] << " ";
- for(i=0;i<3;i++) *os << frot[i] << " ";
- for(i=0;i<3;i++) *os << ftran[i] << " ";
- for(i=0;i<3;i++)for(j=0;j<3;j++) *os << fm[i][j] << " ";
+// for(i=0;i<3;i++) *os << frot[i] << " "; // Redundant with fm[][].
+ for(i=0;i<3;i++) *os << setprecision(16) << ftran[i] << " ";
+ for(i=0;i<3;i++)for(j=0;j<3;j++) *os << setprecision(16) <<
+ fm[i][j] << " ";
*os << endl;
+ os->flags(fmt); // reset back to old formating.
return;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::read(istream *is){
+void AliITSgeomMatrix::Read(istream *is){
////////////////////////////////////////////////////////////////////////
// Standard input format for this class.
////////////////////////////////////////////////////////////////////////
*is >> fDetectorIndex;
for(i=0;i<3;i++) *is >> fid[i];
- for(i=0;i<3;i++) *is >> frot[i];
+// for(i=0;i<3;i++) *is >> frot[i]; // Redundant with fm[][].
for(i=0;i<3;i++) *is >> ftran[i];
for(i=0;i<3;i++)for(j=0;j<3;j++) *is >> fm[i][j];
+ AngleFromMatrix(); // compute angles frot[].
+ fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+ fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+ if(fCylPhi<0.0) fCylPhi += TMath::Pi();
return;
}
+//______________________________________________________________________
+void AliITSgeomMatrix::Streamer(TBuffer &R__b){
+ // Stream an object of class AliITSgeomMatrix.
+
+ if (R__b.IsReading()) {
+ AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
+ fCylR = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+ fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+ this->AngleFromMatrix();
+ if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+ } else {
+ AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
+ }
+}
//----------------------------------------------------------------------
ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
////////////////////////////////////////////////////////////////////////
// Standard output streaming function.
////////////////////////////////////////////////////////////////////////
- p.print(&os);
+ p.Print(&os);
return os;
}
//----------------------------------------------------------------------
// Standard input streaming function.
////////////////////////////////////////////////////////////////////////
- r.read(&is);
+ r.Read(&is);
return is;
}
//----------------------------------------------------------------------
-void AliITSgeomMatrix::Streamer(TBuffer &R__b){
-////////////////////////////////////////////////////////////////////////
-// Stream an object of class AliITSgeomMatrix.
-////////////////////////////////////////////////////////////////////////
-
- UInt_t R__s, R__c;
- if (R__b.IsReading()) {
- Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
- if (R__v==1) {
- R__b >> fDetectorIndex;
- R__b.ReadStaticArray(fid);
- R__b.ReadStaticArray(frot);
- R__b.ReadStaticArray(ftran);
- R__b.ReadStaticArray((double*)fm);
- R__b.CheckByteCount(R__s, R__c, AliITSgeomMatrix::IsA());
- } // end if R__v
- } else { // R__b.IsWriting()
- R__c = R__b.WriteVersion(AliITSgeomMatrix::IsA(), kTRUE);
- R__b << fDetectorIndex;
- R__b.WriteArray(fid, 3);
- R__b.WriteArray(frot, 3);
- R__b.WriteArray(ftran, 3);
- R__b.WriteArray((double*)fm, 9);
- R__b.SetByteCount(R__c, kTRUE);
- } // end if R__b.IsReading()||IsWriting()
-}
-//______________________________________________________________________