- fg = 0;
- return;
-}
-
-//_____________________________________________________________________
-AliITSgeom::AliITSgeom(const char *filename){
-////////////////////////////////////////////////////////////////////////
-// The constructor for the AliITSgeom class. All of the data to fill
-// this structure is read in from the file given my the input filename.
-////////////////////////////////////////////////////////////////////////
- FILE *pf;
- Int_t i;
- ITS_geom *g;
- Int_t l,a,d;
- Float_t x,y,z,o,p,q,r,s,t;
- Double_t oor,pr,qr,rr,sr,tr; // Radians
- Double_t lr[9];
- Double_t si; // sin(angle)
- Double_t PI = TMath::Pi(), byPI = PI/180.;
-
- pf = fopen(filename,"r");
-
- fNlayers = 6; // set default number of ladders
- fNlad = new Int_t[fNlayers];
- fNdet = new Int_t[fNlayers];
- // find the number of ladders and detectors in this geometry.
- for(i=0;i<fNlayers;i++){fNlad[i]=fNdet[i]=0;} // zero out arrays
- for(;;){ // for ever loop
- i = fscanf(pf,"%d %d %d %f %f %f %f %f %f %f %f %f",
- &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
- if(i==EOF) break;
- if(l<1 || l>fNlayers) {
- printf("error in file %s layer=%d min is 1 max is %d/n",
- filename,l,fNlayers);
- continue;
- }// end if l
- if(fNlad[l-1]<a) fNlad[l-1] = a;
- if(fNdet[l-1]<d) fNdet[l-1] = d;
- } // end for ever loop
- // counted the number of ladders and detectors now allocate space.
- fg = new ITS_geom* [fNlayers];
- for(i=0;i<fNlayers;i++){
- fg[i] = 0;
- l = fNlad[i]*fNdet[i];
- fg[i] = new ITS_geom[l]; // allocate space for transforms
- } // end for i
-
- // Set up Shapes for a default configuration of 6 layers.
- fShape = new TObjArray;
- AddShape((TObject *) new AliITSgeomSPD()); // shape 0
- AddShape((TObject *) new AliITSgeomSDD()); // shape 1
- AddShape((TObject *) new AliITSgeomSPD()); // shape 2
-
- // prepare to read in transforms
- rewind(pf); // start over reading file
- for(;;){ // for ever loop
- i = fscanf(pf,"%d %d %d %f %f %f %f %f %f %f %f %f",
- &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
- if(i==EOF) break;
- if(l<1 || l>fNlayers) {
- printf("error in file %s layer=%d min is 1 max is %d/n",
- filename,l,fNlayers);
- continue;
- }// end if l
- l--; a--; d--; // shift layer, ladder, and detector counters to zero base
- i = d + a*fNdet[l]; // position of this detector
- g = &(fg[l][i]);
-
- oor = byPI*o;
- pr = byPI*p;
- qr = byPI*q;
- rr = byPI*r;
- sr = byPI*s;
- tr = byPI*t;
-
- g->fx0 = x;
- g->fy0 = y;
- g->fz0 = z;
-//
- si = sin(oor);if(o== 90.0) si = +1.0;
- if(o==270.0) si = -1.0;
- if(o== 0.0||o==180.) si = 0.0;
- lr[0] = si * cos(pr);
- lr[1] = si * sin(pr);
- lr[2] = cos(oor);if(o== 90.0||o==270.) lr[2] = 0.0;
- if(o== 0.0) lr[2] = +1.0;
- if(o==180.0) lr[2] = -1.0;
-//
- si = sin(qr);if(q== 90.0) si = +1.0;
- if(q==270.0) si = -1.0;
- if(q== 0.0||q==180.) si = 0.0;
- lr[3] = si * cos(rr);
- lr[4] = si * sin(rr);
- lr[5] = cos(qr);if(q== 90.0||q==270.) lr[5] = 0.0;
- if(q== 0.0) lr[5] = +1.0;
- if(q==180.0) lr[5] = -1.0;
-//
- si = sin(sr);if(s== 90.0) si = +1.0;
- if(s==270.0) si = -1.0;
- if(s== 0.0||s==180.) si = 0.0;
- lr[6] = si * cos(tr);
- lr[7] = si * sin(tr);
- lr[8] = cos(sr);if(s== 90.0||s==270.0) lr[8] = 0.0;
- if(s== 0.0) lr[8] = +1.0;
- if(s==180.0) lr[8] = -1.0;
- // Normalize these elements
- for(a=0;a<3;a++){// reuse float Si and integers a and d.
- si = 0.0;
- for(d=0;d<3;d++) si += lr[3*a+d]*lr[3*a+d];
- si = TMath::Sqrt(1./si);
- for(d=0;d<3;d++) g->fr[3*a+d] = lr[3*a+d] = si*lr[3*a+d];
- } // end for a
- // get angles from matrix up to a phase of 180 degrees.
- oor = atan2(lr[7],lr[8]);if(oor<0.0) oor += 2.0*PI;
- pr = asin(lr[2]); if(pr<0.0) pr += 2.0*PI;
- qr = atan2(lr[3],lr[0]);if(qr<0.0) qr += 2.0*PI;
- g->frx = oor;
- g->fry = pr;
- g->frz = qr;
- // l = layer-1 at this point.
- if(l==0||l==1) g->fShapeIndex = 0; // SPD's
- else if(l==2||l==3) g->fShapeIndex = 1; // SDD's
- else if(l==4||l==5) g->fShapeIndex = 2; // SSD's
- } // end for ever loop
- fclose(pf);
-}
-
-//________________________________________________________________________
-AliITSgeom::AliITSgeom(AliITSgeom &source){
-////////////////////////////////////////////////////////////////////////
-// The copy constructor for the AliITSgeom class. It calls the
-// = operator function. See the = operator function for more details.
-////////////////////////////////////////////////////////////////////////
-
- *this = source; // Just use the = operator for now.
-
- return;
-}
-
-//________________________________________________________________________
-void AliITSgeom::operator=(AliITSgeom &source){
-////////////////////////////////////////////////////////////////////////
-// The = operator function for the AliITSgeom class. It makes an
-// independent copy of the class in such a way that any changes made
-// to the copied class will not affect the source class in any way.
-// This is required for many ITS alignment studies where the copied
-// class is then modified by introducing some misalignment.
-////////////////////////////////////////////////////////////////////////
- Int_t i,j,k;
-
- if(this == &source) return; // don't assign to ones self.
-
- // if there is an old structure allocated delete it first.
- if(fg != 0){
- for(i=0;i<fNlayers;i++) delete[] fg[i];
- delete[] fg;
- } // end if fg != 0
- if(fNlad != 0) delete[] fNlad;
- if(fNdet != 0) delete[] fNdet;
-
- fNlayers = source.fNlayers;
- fNlad = new Int_t[fNlayers];
- for(i=0;i<fNlayers;i++) fNlad[i] = source.fNlad[i];
- fNdet = new Int_t[fNlayers];
- for(i=0;i<fNlayers;i++) fNdet[i] = source.fNdet[i];
- fShape = new TObjArray(*(source.fShape));//This does not make a proper copy.
- fg = new ITS_geom* [fNlayers];
- for(i=0;i<fNlayers;i++){
- fg[i] = new ITS_geom[fNlad[i]*fNdet[i]];
- for(j=0;j<(fNlad[i]*fNdet[i]);j++){
- fg[i][j].fShapeIndex = source.fg[i][j].fShapeIndex;
- fg[i][j].fx0 = source.fg[i][j].fx0;
- fg[i][j].fy0 = source.fg[i][j].fy0;
- fg[i][j].fz0 = source.fg[i][j].fz0;
- fg[i][j].frx = source.fg[i][j].frx;
- fg[i][j].fry = source.fg[i][j].fry;
- fg[i][j].frz = source.fg[i][j].frz;
- for(k=0;k<9;k++) fg[i][j].fr[k] = source.fg[i][j].fr[k];
- } // end for j
- } // end for i
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(Int_t lay,Int_t lad,Int_t det,
- const Double_t *g,Double_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the global ALICE Cartesian coordinate
-// to local active volume detector Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the layer,
-// ladder, and detector numbers. The global coordinates are entered by
-// the three element Double_t array g and the local coordinate values
-// are returned by the three element Double_t array l. The order of the
-// three elements are g[0]=x, g[1]=y, and g[2]=z, similarly for l.
-////////////////////////////////////////////////////////////////////////
- Double_t x,y,z;
- ITS_geom *gl;
-
- lay--; lad--; det--;
- gl = &(fg[lay][fNdet[lay]*lad+det]);
-
- x = g[0] - gl->fx0;
- y = g[1] - gl->fy0;
- z = g[2] - gl->fz0;
- l[0] = gl->fr[0]*x + gl->fr[1]*y + gl->fr[2]*z;
- l[1] = gl->fr[3]*x + gl->fr[4]*y + gl->fr[5]*z;
- l[2] = gl->fr[6]*x + gl->fr[7]*y + gl->fr[8]*z;
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(const Int_t *id,const Double_t *g,Double_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the local active volume detector Cartesian
-// coordinate to global ALICE Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the id[0]=layer,
-// id[1]=ladder, and id[2]=detector numbers. The local coordinates are
-// entered by the three element Double_t array l and the global coordinate
-// values are returned by the three element Double_t array g. The order of the
-// three elements are l[0]=x, l[1]=y, and l[2]=z, similarly for g.
-////////////////////////////////////////////////////////////////////////
- GtoL(id[0],id[1],id[2],g,l);
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(const Int_t index,const Double_t *g,Double_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the local active volume detector Cartesian
-// coordinate to global ALICE Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the detector
-// index numbers (see GetModuleIndex and GetModuleID). The local
-// coordinates are entered by the three element Double_t array l and the
-// global coordinate values are returned by the three element Double_t array g.
-// The order of the three elements are l[0]=x, l[1]=y, and l[2]=z, similarly
-// for g.
-////////////////////////////////////////////////////////////////////////
- Int_t lay,lad,det;
-
- this->GetModuleId(index,lay,lad,det);
-
- GtoL(lay,lad,det,g,l);
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(Int_t lay,Int_t lad,Int_t det,
- const Float_t *g,Float_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the global ALICE Cartesian coordinate
-// to local active volume detector Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the layer,
-// ladder, and detector numbers. The global coordinates are entered by
-// the three element Float_t array g and the local coordinate values
-// are returned by the three element Float_t array l. The order of the
-// three elements are g[0]=x, g[1]=y, and g[2]=z, similarly for l.
-////////////////////////////////////////////////////////////////////////
- Int_t i;
- Double_t gd[3],ld[3];
-
- for(i=0;i<3;i++) gd[i] = (Double_t) g[i];
- GtoL(lay,lad,det,(Double_t *)gd,(Double_t *)ld);
- for(i=0;i<3;i++) l[i] = (Float_t) ld[i];
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(const Int_t *id,const Float_t *g,Float_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the local active volume detector Cartesian
-// coordinate to global ALICE Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the Int_t array id,
-// id[0]=layer, id[1]=ladder, and id[2]=detector numbers. The local
-// coordinates are entered by the three element Float_t array l and the
-// global coordinate values are returned by the three element Float_t array g.
-// The order of the three elements are l[0]=x, l[1]=y, and l[2]=z, similarly
-// for g. The order of the three elements are g[0]=x, g[1]=y, and g[2]=z,
-// similarly for l.
-////////////////////////////////////////////////////////////////////////
- Int_t i;
- Double_t gd[3],ld[3];
-
- for(i=0;i<3;i++) gd[i] = (Double_t) g[i];
- GtoL(id[0],id[1],id[2],(Double_t *)gd,(Double_t *)ld);
- for(i=0;i<3;i++) l[i] = (Float_t) ld[i];
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::GtoL(const Int_t index,const Float_t *g,Float_t *l){
-////////////////////////////////////////////////////////////////////////
-// The function that does the local active volume detector Cartesian
-// coordinate to global ALICE Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the detector
-// index numbers (see GetModuleIndex and GetModuleID). The local
-// coordinates are entered by the three element Float_t array l and the
-// global coordinate values are returned by the three element Float_t array g.
-// The order of the three elements are l[0]=x, l[1]=y, and l[2]=z, similarly
-// for g.
-////////////////////////////////////////////////////////////////////////
- Int_t lay,lad,det;
- Int_t i;
- Double_t gd[3],ld[3];
-
- this->GetModuleId(index,lay,lad,det);
-
- for(i=0;i<3;i++) gd[i] = (Double_t) g[i];
- GtoL(lay,lad,det,(Double_t *)gd,(Double_t *)ld);
- for(i=0;i<3;i++) l[i] = (Float_t) ld[i];
- return;
-}
-//________________________________________________________________________
-void AliITSgeom::LtoG(Int_t lay,Int_t lad,Int_t det,
- const Double_t *l,Double_t *g){
-////////////////////////////////////////////////////////////////////////
-// The function that does the local active volume detector Cartesian
-// coordinate to global ALICE Cartesian coordinate transformation.
-// The local detector coordinate system is determined by the layer,
-// ladder, and detector numbers. The local coordinates are entered by
-// the three element Float_t array l and the global coordinate values
-// are returned by the three element Float_t array g. The order of the
-// three elements are l[0]=x, l[1]=y, and l[2]=z, similarly for g.
-////////////////////////////////////////////////////////////////////////
- Double_t x,y,z;
- ITS_geom *gl;
-
- lay--; lad--; det--;
- gl = &(fg[lay][fNdet[lay]*lad+det]);
-
- x = gl->fr[0]*l[0] + gl->fr[3]*l[1] + gl->fr[6]*l[2];
- y = gl->fr[1]*l[0] + gl->fr[4]*l[1] + gl->fr[7]*l[2];
- z = gl->fr[2]*l[0] + gl->fr[5]*l[1] + gl->fr[8]*l[2];
- g[0] = x + gl->fx0;
- g[1] = y + gl->fy0;
- g[2] = z + gl->fz0;