+Double_t AliITSgeom::GetAverageRadiusOfLayer(Int_t layer,Double_t &range)const{
+ // Loops over all modules for a given layer and computes the
+ // average cylindrical radius (about the z axis) and the range of
+ // radii covered by this layer. Units, [cm] the Alice default unit.
+ // Input:
+ // Int_t layer The layer for which the average radii is to be found
+ // Output:
+ // Double_t &range The range of radii covered by this layer
+ // Return:
+ // The average radii for this layer.
+ Double_t r=0.0,rmin=1.0e6,rmax=-1.0,rp,t[3],l[3],dl[3];
+ Int_t n=0,i,j,lay,lad,det;
+ AliITSDetector idet;
+
+ for(i=0;i<GetIndexMax();i++) {
+ GetModuleId(i,lay,lad,det);
+ idet = GetModuleType(i);
+ if(lay!=layer) continue;
+ dl[0] = dl[1] = dl[2] = 0.0;
+ if(IsShapeDefined((Int_t)idet)) {
+ switch(idet){
+ case kSPD:{
+ dl[0] = ((AliITSgeomSPD*)GetShape(idet))->GetDx();
+ dl[1] = ((AliITSgeomSPD*)GetShape(idet))->GetDy();
+ dl[2] = ((AliITSgeomSPD*)GetShape(idet))->GetDz();
+ } break;
+ case kSDD: case kSDDp:{
+ dl[0] = ((AliITSgeomSDD*)GetShape(idet))->GetDx();
+ dl[1] = ((AliITSgeomSDD*)GetShape(idet))->GetDy();
+ dl[2] = ((AliITSgeomSDD*)GetShape(idet))->GetDz();
+ } break;
+ case kSSD: case kSSDp:{
+ dl[0] = ((AliITSgeomSSD*)GetShape(idet))->GetDx();
+ dl[1] = ((AliITSgeomSSD*)GetShape(idet))->GetDy();
+ dl[2] = ((AliITSgeomSSD*)GetShape(idet))->GetDz();
+ } break;
+ case kND:{
+ Warning("GetAverageRadiusOfLayer",
+ "idet=kND undefined detector type");
+ continue;
+ }break;
+ default:{
+ Warning("GetAverageRadiusOfLayer",
+ "idet=%d not a defined value",(Int_t)idet);
+ continue;
+ }break;
+ }// end switch.
+ } // end of
+ n++;
+ GetTransCyln(i,t);
+ rp = t[0];
+ r += rp;
+ if(rmin>rp) rmin = rp;
+ if(rmax<rp) rmax = rp;
+ for(j=0;j<8;j++){ // loop over the corners
+ l[0] = dl[0];if(j%2==0) l[0] = -dl[0];
+ l[1] = dl[1];if(j==2||j==3||j==6||j==7) l[1] = -dl[1];
+ l[2] = dl[2];if(j>3) l[2] = -dl[2];
+ LtoG(i,l,t);
+ rp = TMath::Sqrt(t[0]*t[0]+t[1]*t[1]);
+ if(rmin>rp) rmin = rp;
+ if(rmax<rp) rmax = rp;
+ } // end for j
+ } // end for i
+ r /= (Double_t)n;
+ range = TMath::Max(rmax-r,r-rmin);
+ return r;
+}
+//_______________________________________________________________________
+void AliITSgeom::DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
+ Float_t &yout,Float_t &zout) {
+
+ //Conversion from local coordinates on detectors to local
+ //coordinates used for tracking ("v2")
+ // Inputs:
+ // Int_t md Module number
+ // Float_t xin Standard local coordinate x
+ // Float_t zin Standard local coordinate z
+ // Output:
+ // Float_t yout Tracking local coordinate y
+ // Float_t zout Tracking local coordinate z
+ // Return:
+ // none.
+ Float_t x,y,z;
+ Double_t rt[9],al;
+
+ GetTrans(md,x,y,z);
+ GetRotMatrix(md,rt);
+ al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
+ yout = -(-xin+(x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al))));
+ if(md<(GetModuleIndex(2,1,1))) yout *= -1;
+ zout = -zin+z;
+}
+//_______________________________________________________________________
+void AliITSgeom::TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
+ Float_t &xout,Float_t &zout) {
+ //Conversion from local coordinates used for tracking ("v2") to
+ //local detector coordinates
+ // Inputs:
+ // Int_t md Module number
+ // Float_t yin Tracking local coordinate y
+ // Float_t zin Tracking local coordinate z
+ // Output:
+ // Float_t xout Standard local coordinate x
+ // Float_t zout Standard local coordinate z
+ // Return:
+ // none.
+ Float_t x,y,z;
+ Double_t rt[9],al;
+
+ GetTrans(md,x,y,z);
+ GetRotMatrix(md,rt);
+ al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
+ xout = yin;
+ if(md<(GetModuleIndex(2,1,1))) xout = -xout;
+ xout += (x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al)));
+ zout = -zin+z;
+}
+//----------------------------------------------------------------------
+ostream &operator<<(ostream &os,AliITSgeom &p){
+ // Standard output streaming function.
+ // Inputs:
+ // ostream os The output stream
+ // AliITSgeom p The AliITSgeom class to be printed out
+ // Outputs:
+ // none.
+ // Return:
+ // The input stream
+
+ p.PrintGeom(&os);
+ return os;
+}
+//----------------------------------------------------------------------
+istream &operator>>(istream &is,AliITSgeom &r){
+ // Standard input streaming function.
+ // Inputs:
+ // istream is The input stream
+ // AliITSgeom p The AliITSgeom class to be filled from this
+ // input stream
+ // Outputs:
+ // none.
+ // Return:
+ // The input stream
+
+ r.ReadGeom(&is);
+ return is;
+}
+//----------------------------------------------------------------------
+