X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSgeom.cxx;h=287e67870e6a5bb3ee18e035a9c132941929d1e8;hb=b9bd355cb3b2bfee9ede9f6bff3db12c26e2cf5d;hp=58d8100c36ca48d67090411566276e3f62a4afa1;hpb=5613046a1b2a05291a25f1d4d241a84a00f87bae;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSgeom.cxx b/ITS/AliITSgeom.cxx index 58d8100c36c..287e67870e6 100644 --- a/ITS/AliITSgeom.cxx +++ b/ITS/AliITSgeom.cxx @@ -165,6 +165,7 @@ fShape(0,0) // Array of shapes and detector information. fShape.SetOwner(kTRUE); return; } + //______________________________________________________________________ AliITSgeom::AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads, const Int_t *ndets,Int_t mods): @@ -183,13 +184,15 @@ fShape(5,0) // Array of shapes and detector information. // Int_t itype the type of transformation kept. // bit 0 => Standard GEANT // bit 1 => ITS tracking - // bit 2 => A change in the coordinate system has been made. - // others are still to be defined as needed. - // Int_t nlayers The number of ITS layers also set the size of the arrays - // Int_t *nlads an array of the number of ladders for each layer. This - // array must be nlayers long. - // Int_t *ndets an array of the number of detectors per ladder for each + // bit 2 => A change in the coordinate system + // has been made. others are still to be defined + // as needed. + // Int_t nlayers The number of ITS layers also set the size of + // the arrays + // Int_t *nlads an array of the number of ladders for each // layer. This array must be nlayers long. + // Int_t *ndets an array of the number of detectors per ladder + // for each layer. This array must be nlayers long. // Int_t mods The number of modules. Typically the sum of all the // detectors on every layer and ladder. // Outputs: @@ -209,13 +212,15 @@ void AliITSgeom::Init(Int_t itype,Int_t nlayers,const Int_t *nlads, // Int_t itype the type of transformation kept. // bit 0 => Standard GEANT // bit 1 => ITS tracking - // bit 2 => A change in the coordinate system has been made. - // others are still to be defined as needed. - // Int_t nlayers The number of ITS layers also set the size of the arrays - // Int_t *nlads an array of the number of ladders for each layer. This - // array must be nlayers long. - // Int_t *ndets an array of the number of detectors per ladder for each + // bit 2 => A change in the coordinate system + // has been made. others are still to be defined + // as needed. + // Int_t nlayers The number of ITS layers also set the size of + // the arrays + // Int_t *nlads an array of the number of ladders for each // layer. This array must be nlayers long. + // Int_t *ndets an array of the number of detectors per ladder + // for each layer. This array must be nlayers long. // Int_t mods The number of modules. Typically the sum of all the // detectors on every layer and ladder. // Outputs: @@ -465,8 +470,9 @@ void AliITSgeom::WriteNewFile(const char *filename)const{ *fp << ", kSDD=" << (Int_t) kSDD << ", kSSD=" << (Int_t) kSSD; *fp << ", kSSDp=" << (Int_t) kSSDp << ", and kSDDp=" << (Int_t) kSDDp; *fp << "*/" << endl; - *fp << "Version "<< fVersion.Length()<<" " << fVersion.Data() << endl;//This should be consistent - // with the geometry version. + *fp << "Version "<< fVersion.Length()<<" " << fVersion.Data() << endl;// + // This should be consistent + // with the geometry version. *fp << "fTrans " << fTrans << endl; *fp << "fNmodules " << fNmodules << endl; *fp << "fNlayers " << fNlayers << endl; @@ -562,8 +568,8 @@ fShape(0,0) // TObjArray of detector geom. &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t); if(l>lm) lm = l; if(l<1 || l>fNlayers) { - printf("error in file %s layer=%d min. is 1 max is %d Trying new format\n", - filename,l,fNlayers); + printf("error in file %s layer=%d min. is 1 max is %d" + " Trying new format\n",filename,l,fNlayers); fclose(pf); ReadNewFile(filename); return; @@ -599,8 +605,8 @@ fShape(0,0) // TObjArray of detector geom. sscanf(buff,"%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(l<1 || l>fNlayers) { - Warning("AliITSgeom","error in file %s layer=%d min. is 1 max is %d", - filename,l,fNlayers); + Warning("AliITSgeom","error in file %s layer=%d" + " min. is 1 max is %d",filename,l,fNlayers); continue; }// end if l id[0] = l;id[1] = a;id[2] = d; @@ -628,9 +634,20 @@ fShape(0,0) // TObjArray of detector geom. } // end while ever loop fclose(pf); } - //______________________________________________________________________ -AliITSgeom::AliITSgeom(const AliITSgeom &source) : TObject(source){ +AliITSgeom::AliITSgeom(const AliITSgeom &source) : +TObject(source), +fVersion(source.fVersion), // Transformation version. +fTrans(source.fTrans), // Flag to keep track of which transformation +fNmodules(source.fNmodules),// The total number of modules +fNlayers(source.fNlayers), // The number of layers. +fNlad(source.fNlad), // Array of the number of ladders/layer(layer) +fNdet(source.fNdet), // Array of the number of detector/ladder(layer) +fGm(source.fGm.GetSize(),source.fGm.LowerBound()),// Structure of + // translation and rotation. +fShape(source.fShape.GetSize(),source.fShape.LowerBound())// Array of shapes + // and detector information. +{ // The copy constructor for the AliITSgeom class. It calls the // = operator function. See the = operator function for more details. // Inputs: @@ -640,11 +657,37 @@ AliITSgeom::AliITSgeom(const AliITSgeom &source) : TObject(source){ // none. // Return: // none. + Int_t i,n; - *this = source; // Just use the = operator for now. + n = source.fGm.GetLast()+1; + for(i=source.fGm.LowerBound();ifVersion = source.fVersion; this->fTrans = source.fTrans; this->fNmodules = source.fNmodules; - this->fNlayers = source.fNlayers; - this->fNlad.Set(fNlayers,source.fNlad.GetArray()); - this->fNdet.Set(fNlayers,source.fNdet.GetArray()); - this->fShape.Expand(source.fShape.GetEntriesFast()); - for(i=0;ifShape.AddAt(new TObject(*(source.fShape.At(i))),i); - this->fShape.SetOwner(kTRUE); + this->fNlayers = source.fNlayers; + this->fNlad = source.fNlad; + this->fNdet = source.fNdet; this->fGm.Expand(this->fNmodules); - this->fGm.SetOwner(kTRUE); - for(i=0;ifNmodules;i++) - if(i<0||i>=fGm.GetSize()){ - Error("ReadNewFile","i<0||i>=fGm.GetSize()=%d", - i,fGm.GetSize()); - return *this; - } // end if - this->fGm.AddAt(new TObject(*(source.fGm.At(i))),i); + for(i=source.fGm.LowerBound();ifShape.Expand(source.fShape.GetEntriesFast()); + for(i=source.fShape.LowerBound();iGetGeomMatrix(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 @@ -909,8 +1012,9 @@ void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other)const{ // 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. + // 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: @@ -974,8 +1078,9 @@ void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const{ // 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. // Inputs: - // FILE *fp A file pointer to an opened file for writing in which - // the results of the comparison will be written. + // FILE *fp A file pointer to an opened file for + // writing in which the results of the + // comparison will be written. // Int_t lay The layer number. Starting from 1. // Int_t lad The ladder number. Starting from 1. // Int_t det The detector number. Starting from 1. @@ -999,109 +1104,109 @@ void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const{ return; } //______________________________________________________________________ -ofstream & AliITSgeom::PrintGeom(ofstream &rb)const{ +void AliITSgeom::PrintGeom(ostream *wb)const{ // Stream out an object of class AliITSgeom to standard output. // Intputs: - // ofstream &rb The output streaming buffer. + // ofstream *wb The output streaming buffer. // Outputs: // none. // Return: - // ofstream &rb The output streaming buffer. + // none. Int_t i,nshapes; - rb.setf(ios::scientific); - rb << fTrans << " "; - rb << fNmodules << " "; - rb << fNlayers << " "; - for(i=0;isetf(ios::scientific); + *wb << fTrans << " "; + *wb << fNmodules << " "; + *wb << fNlayers << " "; + for(i=0;i> fTrans >> fNmodules >> fNlayers; + *rb >> fTrans >> fNmodules >> fNlayers; fNlad.Set(fNlayers); fNdet.Set(fNlayers); - for(i=0;i> fNlad[i]; - for(i=0;i> fNdet[i]; + for(i=0;i> fNlad[i]; + for(i=0;i> fNdet[i]; fGm.Expand(fNmodules); fGm.SetOwner(kTRUE); for(i=0;i=fGm.GetSize()){ Error("ReadGeom","i<0||i>=fGm.GetSize()=%d", i,fGm.GetSize()); - return rb; + return; } // end if fGm.AddAt(new AliITSgeomMatrix,i); - rb >> *(GetGeomMatrix(i)); + *rb >> *(GetGeomMatrix(i)); } // end for i - rb >> i; + *rb >> i; fShape.Expand(i); fShape.SetOwner(kTRUE); for(i=0;i> j; + *rb >> j; switch (j){ case kSPD:{ AliITSgeomSPD *s = new AliITSgeomSPD(); - rb >> *s; + *rb >> *s; fShape.AddAt(s,kSPD);} break; case kSDD:{ AliITSgeomSDD *s = new AliITSgeomSDD(); - rb >> *s; + *rb >> *s; fShape.AddAt(s,kSDD);} break; case kSSD:{ AliITSgeomSSD *s = new AliITSgeomSSD(); - rb >> *s; + *rb >> *s; fShape.AddAt(s,kSSD);} break; case kSSDp:{ AliITSgeomSSD *s = new AliITSgeomSSD(); - rb >> *s; + *rb >> *s; fShape.AddAt(s,kSSDp);} break; case kSDDp:{ AliITSgeomSDD *s = new AliITSgeomSDD(); - rb >> *s; + *rb >> *s; fShape.AddAt(s,kSDDp);} break; } // end switch } // end for i - return rb; + return; } //______________________________________________________________________ // The following routines modify the transformation of "this" @@ -1125,8 +1230,8 @@ void AliITSgeom::GlobalChange(const Float_t *tran,const Float_t *rot){ // respect to the beam line, except for an effective rotation about the // beam axis which will just rotate the ITS as a hole about the beam axis. // Intputs: - // Float_t *tran A 3 element array representing the global translations. - // the elements are x,y,z in cm. + // Float_t *tran A 3 element array representing the global + // translations. the elements are x,y,z in cm. // Float_t *rot A 3 element array representing the global rotation // angles about the three axis x,y,z in radians // Outputs: @@ -1174,8 +1279,9 @@ void AliITSgeom::GlobalCylindericalChange(const Float_t *tran, // line, except for an effective rotation about the beam axis which will // just rotate the ITS as a hole about the beam axis. // Intputs: - // Float_t *tran A 3 element array representing the global translations. - // the elements are r,theta,z in cm/radians. + // Float_t *tran A 3 element array representing the global + // translations. the elements are r,theta,z in + // cm/radians. // Float_t *rot A 3 element array representing the global rotation // angles about the three axis x,y,z in radians // Outputs: @@ -1217,10 +1323,12 @@ void AliITSgeom::RandomChange(const Float_t *stran,const Float_t *srot){ // x y and z translations, and the three element array srot, // for the three rotation about the axis x y and z. // Intputs: - // Float_t *stran A 3 element array representing the global translations - // variances. The elements are x,y,z in cm. + // Float_t *stran A 3 element array representing the global + // translations variances. The elements are x, + // y,z in cm. // Float_t *srot A 3 element array representing the global rotation - // angles variances about the three axis x,y,z in radians. + // angles variances about the three axis x,y,z in + // radians. // Outputs: // none. // Return: @@ -1255,10 +1363,12 @@ void AliITSgeom::RandomCylindericalChange(const Float_t *stran, // in detector position allow for the simulation of a random uncertainty // in the detector positions of the ITS. // Intputs: - // Float_t *stran A 3 element array representing the global translations - // variances. The elements are r,theta,z in cm/radians. + // Float_t *stran A 3 element array representing the global + // translations variances. The elements are r, + // theta,z in cm/radians. // Float_t *srot A 3 element array representing the global rotation - // angles variances about the three axis x,y,z in radians. + // angles variances about the three axis x,y,z in + // radians. // Outputs: // none. // Return: @@ -1472,24 +1582,83 @@ Double_t AliITSgeom::GetAverageRadiusOfLayer(Int_t layer,Double_t &range)const{ return r; } //_______________________________________________________________________ -void AliITSgeom::DetLToTrackingV2(Int_t md, Float_t xin, Float_t zin, Float_t &yout, Float_t &zout) { +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") - Float_t x,y,z; Double_t rt[9];GetTrans(md,x,y,z);GetRotMatrix(md,rt); - Double_t al=TMath::ATan2(rt[1],rt[0])+TMath::Pi(); - yout=-(-xin+(x*TMath::Cos(al)+y*TMath::Sin(al))); - if(md<(GetModuleIndex(2,1,1)-1))yout*=-1; zout=-zin+(Double_t)z; -} + //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 - - Float_t x,y,z; Double_t rt[9];GetTrans(md,x,y,z);GetRotMatrix(md,rt); - Double_t al=TMath::ATan2(rt[1],rt[0])+TMath::Pi(); - xout=yin;if(md<(GetModuleIndex(2,1,1)-1))xout=-xout; - xout+=(x*TMath::Cos(al)+y*TMath::Sin(al)); - zout=-zin+(Double_t)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; +} +//---------------------------------------------------------------------- +