-//_____________________________________________________________________
-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 or,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 laders 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 laders 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
-
- // prepair 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, lader, and detector counters to zero base
- i = d + a*fNdet[l]; // position of this detector
- g = &(fg[l][i]);
-
- or = 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(or);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(or);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(r== 90.0) si = +1.0;
- if(r==270.0) si = -1.0;
- if(r== 0.0||r==180.) si = 0.0;
- lr[6] = si * cos(tr);
- lr[7] = si * sin(tr);
- lr[8] = cos(sr);if(r== 90.0||r==270.0) lr[8] = 0.0;
- if(r== 0.0) lr[8] = +1.0;
- if(r==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.
- or = atan2(lr[7],lr[8]);if(or<0.0) or += 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 = or;
- 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.
-////////////////////////////////////////////////////////////////////////
- source = *this; // 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;
-}