-//___________________________________________________________________________
-Int_t AliITSgeom::GetStartDet(const Int_t dtype){
- /////////////////////////////////////////////////////////////////////////
- // returns the starting module index value for a give type of detector id
- /////////////////////////////////////////////////////////////////////////
-
- switch(dtype){
- case 0:
- return GetModuleIndex(1,1,1);
- break;
- case 1:
- return GetModuleIndex(3,1,1);
- break;
- case 2:
- return GetModuleIndex(5,1,1);
- break;
- default:
- printf("<AliITSgeom::GetFirstDet> undefined detector type\n");
- return 0;
- } // end switch
-
- printf("<AliITSgeom::GetFirstDet> undefined detector type\n");
- return 0;
-}
-
-//___________________________________________________________________________
-Int_t AliITSgeom::GetLastDet(const Int_t dtype){
- /////////////////////////////////////////////////////////////////////////
- // returns the last module index value for a give type of detector id
- /////////////////////////////////////////////////////////////////////////
-
- switch(dtype){
- case 0:
- return GetLastSPD();
- break;
- case 1:
- return GetLastSDD();
- break;
- case 2:
- return GetLastSSD();
- break;
- default:
- printf("<AliITSgeom::GetLastDet> undefined detector type\n");
- return 0;
- } // end switch
-
- printf("<AliITSgeom::GetLastDet> undefined detector type\n");
- return 0;
-}
-
-//___________________________________________________________________________
-void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other){
-////////////////////////////////////////////////////////////////////////
-// This function was primarily created for diagnostic reasons. It
-// print to a file pointed to by the file pointer fp the difference
-// between two AliITSgeom classes. The format of the file is basicly,
-// define d? to be the difference between the same element of the two
-// classes. For example dfrx = this->fGm[i][j].frx - other->fGm[i][j].frx.
-// if(at least one of dfx0, dfy0, dfz0,dfrx,dfry,dfrz are non zero) then print
-// layer ladder detector dfx0 dfy0 dfz0 dfrx dfry dfrz
-// if(at least one of the 9 elements of dfr[] are non zero) then print
-// layer ladder detector dfr[0] dfr[1] dfr[2]
-// dfr[3] dfr[4] dfr[5]
-// dfr[6] dfr[7] dfr[8]
-// Only non zero values are printed to save space. The differences are
-// typical written to a file because there are usually a lot of numbers
-// printed out and it is usually easier to read them in some nice editor
-// rather than zooming quickly past you on a screen. fprintf is used to
-// do the printing. The fShapeIndex difference is not printed at this time.
-////////////////////////////////////////////////////////////////////////
- Int_t i,j,idt[3],ido[3];
- Double_t tt[3],to[3]; // translation
- Double_t rt[3],ro[3]; // phi in radians
- Double_t mt[3][3],mo[3][3]; // matrixes
- AliITSgeomMatrix *gt,*go;
- Bool_t t;
-
- for(i=0;i<this->fNmodules;i++){
- gt = this->GetGeomMatrix(i);
- go = other->GetGeomMatrix(i);
- gt->GetIndex(idt);
- go->GetIndex(ido);
- t = kFALSE;
- for(i=0;i<3;i++) t = t&&idt[i]!=ido[i];
- if(t) fprintf(fp,"%4.4d %1.1d %2.2d %2.2d %1.1d %2.2d %2.2d\n",i,
- idt[0],idt[1],idt[2],ido[0],ido[1],ido[2]);
- gt->GetTranslation(tt);
- go->GetTranslation(to);
- gt->GetAngles(rt);
- go->GetAngles(ro);
- t = kFALSE;
- for(i=0;i<3;i++) t = t&&tt[i]!=to[i];
- if(t) fprintf(fp,"%1.1d %2.2d %2.2d dTrans=%f %f %f drot=%f %f %f\n",
- idt[0],idt[1],idt[2],
- tt[0]-to[0],tt[1]-to[1],tt[2]-to[2],
- rt[0]-ro[0],rt[1]-ro[1],rt[2]-ro[2]);
- t = kFALSE;
- gt->GetMatrix(mt);
- go->GetMatrix(mo);
- for(i=0;i<3;i++)for(j=0;j<3;j++) t = mt[i][j] != mo[i][j];
- if(t){
- fprintf(fp,"%1.1d %2.2d %2.2d dfr= %e %e %e\n",
- idt[0],idt[1],idt[2],
- mt[0][0]-mo[0][0],mt[0][1]-mo[0][1],mt[0][2]-mo[0][2]);
- fprintf(fp," dfr= %e %e %e\n",
- mt[1][0]-mo[1][0],mt[1][1]-mo[1][1],mt[1][2]-mo[1][2]);
- fprintf(fp," dfr= %e %e %e\n",
- mt[2][0]-mo[2][0],mt[2][1]-mo[2][1],mt[2][2]-mo[2][2]);
- } // end if t
- } // end for i
- return;
-}
-
-//___________________________________________________________________________
-void AliITSgeom::PrintData(FILE *fp,
- const Int_t lay,const Int_t lad,const Int_t det){
-////////////////////////////////////////////////////////////////////////
-// This function prints out the coordinate transformations for
-// the particular detector defined by layer, ladder, and detector
-// to the file pointed to by the File pointer fp. fprintf statements
-// are used to print out the numbers. The format is
-// layer ladder detector Trans= fx0 fy0 fz0 rot= frx fry frz Shape=fShapeIndex
-// dfr= fr[0] fr[1] fr[2]
-// dfr= fr[3] fr[4] fr[5]
-// dfr= fr[6] fr[7] fr[8]
-// By indicating which detector, some control over the information
-// is given to the user. The output it written to the file pointed
-// to by the file pointer fp. This can be set to stdout if you want.
-////////////////////////////////////////////////////////////////////////
- AliITSgeomMatrix *gt;
- Double_t t[3],r[3],m[3][3];
-
- gt = this->GetGeomMatrix(GetModuleIndex(lay,lad,det));
- gt->GetTranslation(t);
- gt->GetAngles(r);
- fprintf(fp,"%1.1d %2.2d %2.2d Trans=%f %f %f rot=%f %f %f Shape=%d\n",
- lay,lad,det,t[0],t[1],t[2],r[0],r[1],r[2],
- gt->GetDetectorIndex());
- gt->GetMatrix(m);
- fprintf(fp," dfr= %e %e %e\n",m[0][0],m[0][1],m[0][2]);
- fprintf(fp," dfr= %e %e %e\n",m[1][0],m[1][1],m[1][2]);
- fprintf(fp," dfr= %e %e %e\n",m[2][0],m[2][1],m[2][2]);
- return;
-}
-//___________________________________________________________________________
-ofstream & AliITSgeom::PrintGeom(ofstream &R__b){
-////////////////////////////////////////////////////////////////////////
-// The default Streamer function "written by ROOT" doesn't write out
-// the arrays referenced by pointers. Therefore, a specific Streamer function
-// has to be written. This function should not be modified but instead added
-// on to so that older versions can still be read. The proper handling of
-// the version dependent streamer function hasn't been written do to the lack
-// of finding an example at the time of writing.
-////////////////////////////////////////////////////////////////////////
- // Stream an object of class AliITSgeom.
- Int_t i;
+//______________________________________________________________________
+Int_t AliITSgeom::GetNDetTypes(Int_t &max)const{
+ // Finds and returns the number of detector types used and the
+ // maximum detector type value. Only counts id >=0 (no undefined
+ // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
+ // Inputs:
+ // none.
+ // Outputs:
+ // The maximum detector type used
+ // Return:
+ // The number of detector types used
+ Int_t i,*n,id;
+
+ max = -1;
+ for(i=0;i<GetIndexMax();i++){
+ id = GetModuleType(i);
+ if(id>max) max=id;
+ } // end for i
+ n = new Int_t[max+1];
+ for(i=0;i<max;i++) n[i] = 0;
+ for(i=0;i<GetIndexMax();i++){
+ id = GetModuleType(i);
+ if(id>-1)n[id]++; // note id=-1 => undefined.
+ } // end for i
+ id = 0;
+ for(i=0;i<max;i++) if(n[i]!=0) id++;
+ delete[] n;
+ return id+1;
+}
+//______________________________________________________________________
+Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const{
+ // Finds and returns the number of detector types used and the
+ // number of each detector type. Only counts id >=0 (no undefined
+ // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
+ // Inputs:
+ // none.
+ // Outputs:
+ // The maximum detector type used
+ // Return:
+ // The number of detector types used
+ Int_t i,j,*n,id,max;
+
+ max = -1;
+ for(i=0;i<GetIndexMax();i++){
+ id = GetModuleType(i);
+ if(id>max) max=id;
+ } // end for i
+ n = new Int_t[max+1];
+ for(i=0;i<max;i++) n[i] = 0;
+ for(i=0;i<GetIndexMax();i++){
+ id = GetModuleType(i);
+ if(id>-1)n[id]++; // note id=-1 => undefined.
+ } // end for i
+ id = 0;
+ for(i=0;i<=max;i++) if(n[i]!=0) id++;
+ maxs.Set(id);
+ j = 0;
+ for(i=0;i<=max;i++) if(n[i]!=0){
+ maxs[j] = n[i];
+ types[j++] = (AliITSDetector) i;
+ } // end for i/end if
+ delete[] n;
+ return id;
+}
+//______________________________________________________________________
+Int_t AliITSgeom::GetStartDet(Int_t dtype)const{
+ // returns the starting module index value for a give type of detector id.
+ // This assumes that the detector types are different on different layers
+ // and that they are not mixed up.
+ // Inputs:
+ // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
+ // and 2 for SSD.
+ // Outputs:
+ // none.
+ // Return:
+ // the module index for the first occurrence of that detector type.
+
+ switch(dtype){
+ case 0:
+ return GetModuleIndex(1,1,1);
+ break;
+ case 1:
+ return GetModuleIndex(3,1,1);
+ break;
+ case 2:
+ return GetModuleIndex(5,1,1);
+ break;
+ default:
+ Warning("GetStartDet","undefined detector type %d",dtype);
+ return 0;
+ } // end switch
+
+ Warning("GetStartDet","undefined detector type %d",dtype);
+ return 0;
+}
+//______________________________________________________________________
+Int_t AliITSgeom::GetLastDet(Int_t dtype)const{
+ // returns the last module index value for a give type of detector id.
+ // This assumes that the detector types are different on different layers
+ // and that they are not mixed up.
+ // Inputs:
+ // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
+ // and 2 for SSD.
+ // Outputs:
+ // Return:
+ // the module index for the last occurrence of that detector type.
+
+ switch((AliITSDetector)dtype){
+ case kSPD:
+ return GetModuleIndex(3,1,1)-1;
+ break;
+ case kSDD:
+ return GetModuleIndex(5,1,1)-1;
+ break;
+ case kSSD:
+ return GetIndexMax()-1;
+ break;
+ case kSSDp: case kSDDp: case kND:
+ default:
+ Warning("GetLastDet","undefined detector type %d",dtype);
+ return 0;
+ } // end switch
+
+ Warning("GetLastDet","undefined detector type %d",dtype);
+ return 0;
+}
+//______________________________________________________________________
+Bool_t AliITSgeom::IsInside(Int_t module,Double_t point[3])const{
+ // Determins if the give point is inside of the module as defined
+ // by this set of coordinate transforms.
+ // Inputs:
+ // Int_t module The module to be checked
+ // Double_t point[3] A 3 vector global point
+ // Outputs:
+ // none.
+ // Return:
+ // kTRUE if point is inside of module, kFALSE otherwise.
+ Double_t l[3],dx,dy,dz;
+ AliITSDetector idet = (AliITSDetector)(this->GetGeomMatrix(module)->
+ GetDetectorIndex());
+
+ this->GtoL(module,point,l);
+ switch(idet){
+ case kSPD:{
+ AliITSgeomSPD *spd = (AliITSgeomSPD*)(fShape.At((Int_t)idet));
+ dx = spd->GetDx();
+ dy = spd->GetDy();
+ dz = spd->GetDz();}
+ break;
+ case kSDD: case kSDDp:{
+ AliITSgeomSDD *sdd = (AliITSgeomSDD*)(fShape.At((Int_t)idet));
+ dx = sdd->GetDx();
+ dy = sdd->GetDy();
+ dz = sdd->GetDz();}
+ break;
+ case kSSD: case kSSDp:{
+ AliITSgeomSSD *ssd = (AliITSgeomSSD*)(fShape.At((Int_t)idet));
+ dx = ssd->GetDx();
+ dy = ssd->GetDy();
+ dz = ssd->GetDz();}
+ break;
+ default: // Detector not defined.
+ return kFALSE;
+ break;
+ }// end switch
+ if(TMath::Abs(l[0])>dx) return kFALSE;
+ if(TMath::Abs(l[2])>dz) return kFALSE;
+ if(TMath::Abs(l[1])>dy) return kFALSE;
+ return kTRUE;
+}
+//______________________________________________________________________
+void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other)const{
+ // This function was primarily created for diagnostic reasons. It
+ // print to a file pointed to by the file pointer fp the difference
+ // between two AliITSgeom classes. The format of the file is basically,
+ // define d? to be the difference between the same element of the two
+ // classes. For example dfrx = this->GetGeomMatrix(i)->frx
+ // - other->GetGeomMatrix(i)->frx.
+ // if(at least one of dfx0, dfy0, dfz0,dfrx,dfry,dfrz are non zero) then
+ // print layer ladder detector dfx0 dfy0 dfz0 dfrx dfry dfrz
+ // if(at least one of the 9 elements of dfr[] are non zero) then print
+ // layer ladder detector dfr[0] dfr[1] dfr[2]
+ // dfr[3] dfr[4] dfr[5]
+ // dfr[6] dfr[7] dfr[8]
+ // Only non zero values are printed to save space. The differences are
+ // typical written to a file because there are usually a lot of numbers
+ // printed out and it is usually easier to read them in some nice editor
+ // rather than zooming quickly past you on a screen. fprintf is used to
+ // do the printing. The fShapeIndex difference is not printed at this time.
+ // Inputs:
+ // FILE *fp A file pointer to an opened file for writing
+ // in which the results of the comparison will
+ // be written.
+ // AliITSgeom *other The other AliITSgeom class to which this one is
+ // being compared.
+ // Outputs:
+ // none.
+ // Return:
+ // none.
+ Int_t i,j,idt[3],ido[3];
+ Double_t tt[3],to[3]; // translation
+ Double_t rt[3],ro[3]; // phi in radians
+ Double_t mt[3][3],mo[3][3]; // matrices
+ AliITSgeomMatrix *gt,*go;
+ Bool_t t;