CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/L1Trigger/DTUtilities/src/DTTrigGeom.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: DTTrigGeom
00004 //
00005 //   Description: Muon Barrel Trigger Geometry
00006 //
00007 //
00008 //   Author List:
00009 //   C. Grandi
00010 //   Modifications: 
00011 //   S. Vanini : NEWGEO implementation
00012 //   S. Vanini 090902 : dumpLUT method implemented
00013 //   A. Gozzelino May 11th 2012: IEEE32toDSP method bug fix
00014 //--------------------------------------------------
00015 
00016 //-----------------------
00017 // This Class's Header --
00018 //-----------------------
00019 #include "L1Trigger/DTUtilities/interface/DTTrigGeom.h"
00020 
00021 //-------------
00022 // C Headers --
00023 //-------------
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 #include <iostream>
00029 #include <iomanip>
00030 #include <fstream>
00031 #include <sstream>
00032 #include <cstring>
00033 
00034 //-------------------------------
00035 // Collaborating Class Headers --
00036 //-------------------------------
00037 #include "Geometry/DTGeometry/interface/DTTopology.h"
00038 #include "Geometry/DTGeometry/interface/DTLayer.h"
00039 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
00040 #include "Geometry/DTGeometry/interface/DTChamber.h"
00041 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00042 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00043 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00044 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00045 
00046 using namespace std;
00047 
00048 //----------------
00049 // Constructors --
00050 //----------------
00051 
00052 DTTrigGeom::DTTrigGeom(DTChamber* stat, bool debug) : _stat(stat) , _debug(debug) {
00053 
00054   getGeom();
00055 
00056 }
00057 
00058 
00059 //--------------
00060 // Destructor --
00061 //--------------
00062 
00063 DTTrigGeom::~DTTrigGeom() {}
00064 
00065 
00066 //--------------
00067 // Operations --
00068 //--------------
00069 
00070 float 
00071 DTTrigGeom::phiSLOffset(){
00072   //sl1 offset respect to sl3 - in Front End view!!
00073   float x1 = tubePosInCh(1,1,1).x();
00074   float x3 = tubePosInCh(3,1,1).x();
00075   float offset = x1-x3;
00076   //   if(posFE(1)==1)        // Obsolete in
00077   //     offset = - offset;   // CMSSW
00078   
00079   return offset;
00080 }
00081 
00082 /* OBSOLETE - MAYBE - 19/06/06
00083 int
00084 DTTrigGeom::layerFEStaggering(int nsl, int nlay) const {
00085 
00086   NB the staggering is in FE view!
00087   return cell staggering respect to first wire in layer 1 in cell units
00088   the following is the default: staggering 0 of each layer 
00089      +---------+---------+---------+
00090      | 1  o    | 2  o    | 3  o    |
00091      +----+----+----+----+----+----+
00092           | 1  o    |  2 o    |
00093      +----+----+----+----+----+
00094      | 1  o    | 2  o    |
00095      +----+----+----+----+----+
00096           | 1  o    | 2  o    |
00097           +---------+---------+   ------------> x (y coming out of video) in SL frame
00098  
00099 
00100   int stag = 0;
00101 
00102   if(station()==4 && nsl==2){
00103     std::cout << "No theta superlayer in station 4!" << std::endl;
00104     return 0;
00105   }
00106   //position in chamber of wire 1 in layer 1
00107   LocalPoint posInCh_lay1      = tubePosInCh(nsl,1,1);
00108   //position in chamber of wire 1 in layer nlay
00109   int n1stwire = (nlay==4 ? 2 : 1); 
00110   LocalPoint posInCh_lay       = tubePosInCh(nsl,nlay,n1stwire);
00111 
00112  cout << endl;
00113  cout << nlay << posInCh_lay1 << posInCh_lay << endl;
00114  cout <<endl ;
00115 
00116 
00117   //NB PITCH-0.01 for computer approximation bug
00118   if(nsl==2){//SL2: first wire is toward positive y 
00119     stag = static_cast<int>((-posInCh_lay.y()+posInCh_lay1.y())/(_PITCH-0.01) + 0.5*(fmod(nlay,2.)==0?1:0));
00120   }
00121   else{//SL1 and SL3: first wire is toward negative x
00122           if (nlay==4) {
00123                   stag = static_cast<int>((+posInCh_lay.x()-posInCh_lay1.x()+_PITCH)/(_PITCH-0.01) + 0.5*(fmod(nlay,2.)==0?1:0));
00124           }
00125           else {
00126                 stag = static_cast<int>((+posInCh_lay.x()-posInCh_lay1.x())/(_PITCH-0.01) + 0.5*(fmod(nlay,2.)==0?1:0));
00127           }
00128   }
00129 
00130   //FEP=1 means in y negative in layer frame
00131   const DTLayer* lay  = _stat->superLayer(DTSuperLayerId(statId(),nsl))->layer(DTLayerId(statId(),nsl,nlay));
00132   const DTLayer* lay1 = _stat->superLayer(DTSuperLayerId(statId(),nsl))->layer(DTLayerId(statId(),nsl,1));   
00133 
00134   if(lay->getFEPosition()==1){ //FE staggering is reverted                                    //MODIFICARE DOPO!!!!!!
00135     int nWire  = lay->specificTopology().channels();  
00136     int nWire1 = lay1->specificTopology().channels();
00137     stag = - nWire + nWire1 - stag + (fmod(nlay,2.)==0?1:0);
00138   }
00139   return stag;
00140 }
00141 */
00142 
00143 int
00144 DTTrigGeom::mapTubeInFEch(int nsl, int nlay, int ntube) const {
00145   int nch = 0;
00146   if(station()==4 && nsl==2){
00147     std::cout << "No theta superlayer in station 4!" << std::endl;
00148   }
00149   else{
00150     // obsolete 19/06/2006  const DTLayer* lay = _stat->superLayer(DTSuperLayerId(statId(),nsl))->layer(DTLayerId(statId(),nsl,nlay));
00151           
00152 /* obsolete 19/6/06
00153  if(lay->getFEPosition()==0)         //FE is in Y negative: opposite numbering                
00154           nch = lay->specificTopology().channels() - ntube + 1;   
00155 //   if(lay->getFEPosition()==1)         //FE is in Y positive: same numbering digi-trig        
00156 //     nch = ntube;
00157 //  }
00158 */      
00159         // in new geometry depends on SL: theta tube numbering is reverted wrt hardware
00160         nch =ntube;
00161 /*      if(nsl==2){     
00162                 nch = lay->specificTopology().channels() - ntube + 1;
00163         }*/
00164   }
00165   return nch;
00166 }
00167 
00168 LocalPoint 
00169 DTTrigGeom::tubePosInCh(int nsl, int nlay, int ntube) const {
00170   if ( nlay==4 && ntube==1) {
00171     std::cout << "ATTENTION: no wire nuber 1 for 4th layer!!!" << std::endl;
00172     LocalPoint dummyLP(0,0,0);
00173     return dummyLP;
00174   }
00175   const DTSuperLayer* sl   = _stat->superLayer(DTSuperLayerId(statId(),nsl));
00176   const DTLayer* lay       = sl->layer(DTLayerId(statId(),nsl,nlay));
00177   
00178    float localX             = lay->specificTopology().wirePosition(ntube);
00179    LocalPoint posInLayer(localX,0,0);
00180    LocalPoint posInChamber  = _stat->surface().toLocal(lay->toGlobal(posInLayer));
00181    //obsolete 19/06/2006 GlobalPoint  posInCMS = lay->toGlobal(posInLayer);
00182   
00183  /* cout <<endl;
00184   cout << "tube " << ntube << " nlay " << nlay << endl;
00185   cout << "posinlayer " << posInLayer << "posinchamb " << posInChamber << "posinCMS " << posInCMS << endl;*/
00186   
00187   return posInChamber;
00188 }
00189 
00190 int
00191 DTTrigGeom::posFE(int sl) const {
00192    if( station()!=4 || sl!=2 ) {
00193      // obsolete 19/0602006 const DTLayer* lay  = _stat->superLayer(DTSuperLayerId(statId(),sl))->layer(DTLayerId(statId(),sl,1));
00194      return 1/*lay->getFEPosition()*/;                                               
00195    }
00196    else{
00197     std::cout << "No theta superlayer in station 4!" << std::endl;
00198     return 0;
00199   }
00200 }
00201 
00202 void
00203 DTTrigGeom::setGeom(const DTChamber* stat) {
00204 
00205   _stat=stat;
00206   getGeom();
00207 
00208 }
00209 
00210 void
00211 DTTrigGeom::getGeom() {
00212 
00213   // Geometrical constants of chamber
00214   // Cell width (cm)
00215   _PITCH = 4.2;
00216   // Cell height (cm)
00217   _H = 1.3;
00218   // azimuthal angle of normal to the chamber
00219   _PHICH = _stat->surface().toGlobal(LocalVector(0,0,-1)).phi();
00220 
00221   // superlayer positions and number of cells
00222   DTSuperLayer* sl[3];
00223   DTLayer* l1[3];
00224   int i = 0;
00225   for(i=0; i<3; i++) {
00226     if(station()==4&&i==1) { // No theta SL in MB4
00227       _ZSL[i] = -999;
00228       _NCELL[i] = 0;
00229     } else {
00230       sl[i] = (DTSuperLayer*) _stat->superLayer(DTSuperLayerId(statId(),i+1));
00231       l1[i] = (DTLayer*) sl[i]->layer(DTLayerId(statId(),i+1,1));
00232       _ZSL[i] = _stat->surface().toLocal(sl[i]->position()).z(); // - 1.5 * _H;
00233       //LocalPoint posInLayer=l1[i]->layType()->getWire(1)->positionInLayer();
00234       const DTTopology& tp=l1[i]->specificTopology();
00235       float  posX=tp.wirePosition(tp.firstChannel());
00236       LocalPoint posInLayer(posX,0,0);
00237       _NCELL[i] = l1[i]->specificTopology().channels();
00238     }
00239   }
00240 
00241   // debugging
00242   if(_debug){
00243     std::cout << setiosflags(std::ios::showpoint | std::ios::fixed) << std::setw(4) <<
00244       std::setprecision(1);
00245     std::cout << "Identification: wheel=" << wheel();
00246     std::cout << ", station=" << station();
00247     std::cout << ", sector=" << sector() << std::endl;
00248     GlobalPoint pp = _stat->toGlobal(LocalPoint(0,0,0));
00249     std::cout << "Position: Mag=" << pp.mag() << "cm, Phi=" << pp.phi()*180/3.14159;
00250     std::cout << " deg, Z=" << pp.z() << " cm" << std::endl;
00251     std::cout << "Rotation: ANGLE=" << phiCh()*180/3.14159 << std::endl;
00252     //if(wheel()==2&&sector()==2){ // only 1 sector-wheel
00253       std::cout << "Z of superlayers: phi=" << ZSL(1) << ", ";
00254       std::cout << ZSL(3) << " theta=" << ZSL(2);
00255       std::cout << " (DeltaY = " << distSL() << ")" << std::endl;
00256       std::cout << " ncell: sl 1 " <<  nCell(1) << " sl 2 " <<  nCell(2) <<
00257               " sl 3 " <<  nCell(3) << std::endl;   
00258     //}
00259   }
00260   // end debugging
00261 
00262 }
00263 
00264 float 
00265 DTTrigGeom::ZSL(int sl) const {
00266   if(sl<1||sl>3){
00267     std::cout << "DTTrigGeom::ZSL: wrong SL number: " << sl;
00268     std::cout << -999 << " returned" << std::endl;
00269     return -999;
00270   }
00271   return _ZSL[sl-1];
00272 }
00273 
00274 
00275 void 
00276 DTTrigGeom::dumpGeom() const {
00277   std::cout << "Identification: wheel=" << wheel();
00278   std::cout << ", station=" << station();
00279   std::cout << ", sector=" << sector() << std::endl;
00280   GlobalPoint pp = _stat->toGlobal(LocalPoint(0,0,0));
00281   std::cout << "Position: Mag=" << pp.mag() << "cm, Phi=" << pp.phi()*180/3.14159;
00282   std::cout << " deg, Z=" << pp.z() << " cm" << std::endl;
00283   std::cout << "Rotation: ANGLE=" << phiCh()*180/3.14159 << std::endl;
00284   std::cout << "Z of superlayers: phi=" << ZSL(1) << ", ";
00285   std::cout << ZSL(3) << " theta=" << ZSL(2) << std::endl;
00286   std::cout << "Number of cells: SL1=" << nCell(1) << " SL2=" << nCell(2) <<
00287     " SL3=" << nCell(3) << std::endl;
00288   std::cout << "First wire positions:" << std::endl;
00289   int ii=0;
00290   int jj=0;
00291   for( ii = 1; ii<=3; ii++ ) {
00292     if(station()!=4||ii!=2){
00293       for ( jj =1; jj<=4; jj++ ) {
00294         std::cout << "    SL=" << ii << ", lay=" << jj << ", wire 1 position=";
00295         if ( jj ==4)
00296           std::cout << tubePosInCh( ii, jj, 2) << std::endl;
00297         else
00298           std::cout << tubePosInCh( ii, jj, 1) << std::endl;
00299       }
00300     }
00301   }
00302 
00303   GlobalPoint gp1 = CMSPosition(DTBtiId(statId(),1,1)); 
00304   
00305 
00306   std::cout << "First BTI position:";
00307   std::cout << " SL1:" << localPosition(DTBtiId(statId(),1,1)) << std::endl;
00308   std::cout << " Position: R=" << gp1.perp() << "cm, Phi=" << gp1.phi()*180/3.14159 << " deg, Z=" << gp1.z() << " cm" << std::endl;
00309 
00310   if(station()!=4)
00311   {
00312         GlobalPoint gp2 = CMSPosition(DTBtiId(statId(),2,1)); 
00313         std::cout << " SL2:" << localPosition(DTBtiId(statId(),2,1))<< std::endl;
00314         std::cout << " Position: R=" << gp2.perp() << "cm, Phi=" << gp2.phi()*180/3.14159 << " deg, Z=" << gp2.z() << " cm" << std::endl;
00315   }
00316 
00317   GlobalPoint gp3 = CMSPosition(DTBtiId(statId(),3,1)); 
00318   std::cout << " SL3:" << localPosition(DTBtiId(statId(),3,1)) << std::endl;
00319   std::cout << " Position: R=" << gp3.perp() << "cm, Phi=" << gp3.phi()*180/3.14159 << " deg, Z=" << gp3.z() << " cm" << std::endl;
00320 
00321   std::cout << "First TRACO position:";
00322   std::cout << localPosition(DTTracoId(statId(),1)) << std::endl;
00323   std::cout << "******************************************************" << std::endl;
00324 }
00325 
00326 void 
00327 DTTrigGeom::dumpLUT(short int btic) {
00328 
00329   // chamber id
00330   int wh = wheel();
00331   int st = station();
00332   int se = sector();
00333 
00334   // open txt file 
00335   string name = "Lut_from_CMSSW_geom";
00336  /* name += "_wh_";
00337   if(wh<0)
00338         name += "-";
00339   name += abs(wh) + '0';
00340   name += "_st_";
00341   name += st + '0';
00342   name += "_se_";
00343   if(se<10)
00344         name += se + '0';
00345   else 
00346   {
00347         name += 1 + '0';
00348         name += (se-10) + '0';
00349   }
00350   */ 
00351   name += ".txt";
00352 
00353   ofstream fout;
00354   fout.open(name.c_str(),ofstream::app);
00355 
00356 // *** dump file header
00357 //  fout << "Identification: wheel\t" << wh;
00358 //  fout << "\tstation\t" << st;
00359 //  fout << "\tsector\t" << se;
00360   fout << wh;
00361   fout << "\t" << st;
00362   fout << "\t" << se;
00363 
00364   // SL shift
00365   float xBTI1_3         = localPosition( DTBtiId(DTSuperLayerId(wheel(),station(),sector(),3),1) ).x();
00366   float xBTI1_1         = localPosition( DTBtiId(DTSuperLayerId(wheel(),station(),sector(),1),1) ).x();
00367   float SL_shift        = xBTI1_3 - xBTI1_1;
00368   //  std::cout << " SL shift " << SL_shift << std::endl;
00369 
00370   // traco 1 and 2 global position
00371   LocalPoint traco1     = localPosition(DTTracoId(statId(),1));
00372   LocalPoint traco2     = localPosition(DTTracoId(statId(),2));
00373   GlobalPoint traco_1   = toGlobal(traco1);
00374   GlobalPoint traco_2   = toGlobal(traco2);
00375   // std::cout << " tr1 x " << traco_1.x() << " tr2 x " << traco_2.x() << std::endl;
00376 
00377   float d;
00378   float xcn;
00379   int xcn_sign;
00380   GlobalPoint pp = _stat->toGlobal(LocalPoint(0,0,ZcenterSL()));
00381   // std::cout << "Position: x=" << pp.x() << "cm, y=" << pp.y() << "cm, z=" << pp.z() << std::endl;  
00382     
00383   if(sector()==1 || sector() ==7){  
00384         d = fabs(traco_1.x());
00385         xcn = fabs(traco_1.y());
00386         // 110208 SV comment: this was inserted for a TRACO hardware bug
00387         if (SL_shift > 0) 
00388                 xcn = xcn+SL_shift;
00389         xcn_sign = static_cast<int>(pp.y()/fabs(pp.y()))*static_cast<int>(traco_1.y()/fabs(traco_1.y()));
00390         if(station() == 2 || (station() == 4 && sector() == 1)) 
00391                 xcn_sign = - xcn_sign;
00392         xcn = xcn*xcn_sign;
00393   }
00394   else {
00395         float m1 = (traco_2.y()-traco_1.y())/(traco_2.x()-traco_1.x());
00396         float q1 = traco_1.y()-m1*traco_1.x();
00397         float m = tan(phiCh());
00398         float xn = q1/(m-m1);
00399         float yn = m*xn;
00400   
00401         d = sqrt(xn*xn+yn*yn);
00402         xcn = sqrt( (xn-traco_1.x())*(xn-traco_1.x()) + (yn-traco_1.y())*(yn-traco_1.y()) );
00403         // 110208 SV comment: this was inserted for a TRACO hardware bug
00404         if (SL_shift > 0) 
00405                 xcn = xcn+SL_shift;
00406   
00407         float diff = (pp.x()-traco_1.x())*traco_1.y();
00408         xcn_sign = static_cast<int>(diff/fabs(diff));
00409         xcn = xcn*xcn_sign;
00410   }
00411   // std::cout << " d " << d << " xcn " << xcn << " sign " << xcn_sign << std::endl; 
00412   //fout << "\td\t" << d << "\txcn\t" << xcn << "\t"; 
00413   //fout << "btic\t" << btic << "\t";
00414 
00415 // *** dump TRACO LUT command
00416   fout << "\tA8";
00417   //short int btic = 31;
00418   //cout << "CHECK BTIC " << btic << endl;
00419   short int Low_byte = (btic & 0x00FF);   // output in hex bytes format with zero padding
00420   short int High_byte =( btic>>8 & 0x00FF);
00421   fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;   
00422     
00423   // convert parameters from IEE32 float to DSP float format
00424   short int DSPmantissa = 0;
00425   short int DSPexp = 0;
00426 
00427   // d parameter conversion and dump
00428   IEEE32toDSP(d, DSPmantissa, DSPexp);
00429   Low_byte = (DSPmantissa & 0x00FF);   // output in hex bytes format with zero padding
00430   High_byte =( DSPmantissa>>8 & 0x00FF);
00431   fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;   
00432   Low_byte = (DSPexp & 0x00FF);
00433   High_byte =( DSPexp>>8 & 0x00FF);
00434   fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;  
00435 
00436   // xnc parameter conversion and dump
00437   DSPmantissa = 0;
00438   DSPexp = 0;
00439   IEEE32toDSP(xcn, DSPmantissa, DSPexp);
00440   Low_byte = (DSPmantissa & 0x00FF);   // output in hex bytes format with zero padding
00441   High_byte =( DSPmantissa>>8 & 0x00FF);
00442   fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte;   
00443   Low_byte = (DSPexp & 0x00FF);
00444   High_byte =( DSPexp>>8 & 0x00FF);
00445   fout << setw(2) << setfill('0') << High_byte << setw(2) << setfill('0') << Low_byte;  
00446 
00447   // sign bits 
00448   Low_byte = (xcn_sign & 0x00FF);   // output in hex bytes format with zero padding
00449   High_byte =( xcn_sign>>8 & 0x00FF);
00450   fout << setw(2) << setfill('0') << hex << High_byte << setw(2) << setfill('0') << Low_byte << dec << "\n"; 
00451 
00452   fout.close();
00453 
00454   return;
00455  
00456 }
00457 
00458 /* 
00459 // A. Gozzelino May 11th 2012: Old and wrong definition
00460 void 
00461 DTTrigGeom::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp)
00462 {
00463   long int *pl=0, lm;
00464   bool sign=false;
00465 
00466   DSPmantissa = 0;
00467   DSPexp = 0;
00468 
00469   if( f!=0.0 )
00470   {
00471         memcpy(pl,&f,sizeof(float));
00472                 
00473         if((*pl & 0x80000000)!=0) 
00474                 sign=true;        
00475         lm = ( 0x800000 | (*pl & 0x7FFFFF)); // [1][23bit mantissa]
00476         lm >>= 9; //reduce to 15bits
00477         lm &= 0x7FFF;
00478         DSPexp = ((*pl>>23)&0xFF)-126;
00479         DSPmantissa = (short)lm;
00480         if(sign) 
00481                 DSPmantissa = - DSPmantissa;  // convert negative value in 2.s complement       
00482 
00483   }
00484   return;
00485 }
00486 */
00487 
00488 //*******************
00489 // A.Gozzelino May 11th 2012: bug fix in method IEEE32toDSP
00490 //******************
00491 
00492 void 
00493 DTTrigGeom::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp)
00494 {  
00495   long int lm;
00496   long int pl = 0;
00497   
00498   bool sign=false;
00499 
00500   DSPmantissa = 0;
00501   DSPexp = 0;
00502 
00503   if( f!=0.0 )
00504   {
00505         memcpy(&pl,&f,sizeof(float));
00506         
00507         if((pl & 0x80000000)!=0) 
00508                 sign=true;        
00509         lm = ( 0x800000 | (pl & 0x7FFFFF)); // [1][23bit mantissa]
00510         lm >>= 9; //reduce to 15bits
00511         lm &= 0x7FFF;
00512         DSPexp = ((pl>>23)&0xFF)-126;
00513         DSPmantissa = (short)lm;
00514         if(sign) 
00515                 DSPmantissa = - DSPmantissa;  // convert negative value in 2.s complement       
00516 
00517   }
00518   return;
00519 }
00520 //********************** end bug fix ****************
00521 
00522 LocalPoint 
00523 DTTrigGeom::localPosition(const DTBtiId id) const {
00524 /* obsolete!
00525   float x = 0;
00526   float y = 0;
00527   float z = ZSL(id.superlayer());
00528   if(id.superlayer()==2){
00529     // SL 2: Reverse numbering -------V
00530     y = Xwire1BTI1SL(id.superlayer()) - ((float)(id.bti()-1)-0.5)*cellPitch();
00531   } else {
00532     x = Xwire1BTI1SL(id.superlayer()) + ((float)(id.bti()-1)-0.5)*cellPitch();
00533   }
00534 */
00535 
00536 //NEWGEO
00537 /*  int nsl = id.superlayer();
00538   int tube = mapTubeInFEch(nsl,1,id.bti());
00539   LocalPoint p = tubePosInCh(nsl,1,tube);
00540   //traslation because z axes is in middle of SL, x/y axes on left I of first cell
00541   
00542   LocalPoint p1 = tubePosInCh (nsl,1,1);
00543   LocalPoint p2 = tubePosInCh (nsl,2,1); 
00544   cout << "nbti " << id.bti() << " tube " << tube << " localpoint" << p << endl;
00545   cout << "localpoint layer 1" << p1  << " localpoint layer 2" << p2 << endl;
00546   
00547   float xt = 0;
00548   float yt = 0;
00549   float zt = - cellH() * 3./2.;
00550   if(nsl==2)
00551     yt = - cellPitch()/2.; 
00552   else
00553     xt = + cellPitch()/2.; 
00554 
00555   if(posFE(nsl)==0){//FE in positive y
00556       xt = - xt;
00557       yt = - yt;
00558   }
00559   
00560   cout << "localpoint " << p << ' '  << xt << ' ' << yt << endl;
00561 
00562   return LocalPoint(p.x()+xt,p.y()+yt,p.z()+zt);*/
00563         
00564         int nsl = id.superlayer();
00565         const DTSuperLayer* sl   = _stat->superLayer(DTSuperLayerId(statId(),nsl));
00566         const DTLayer* lay       = sl->layer(DTLayerId(statId(),nsl,1));
00567         int tube = id.bti();
00568         float localX             = lay->specificTopology().wirePosition(tube);
00569         float xt = -cellPitch()/2.;
00570         float zt = -cellH() * 3./2.;
00571         //LocalPoint posInLayer1(localX+xt,yt,0); //Correction now y is left I of first cell of layer 1 y=0 and z in the middle of SL,
00572         LocalPoint posInLayer1(localX+xt,0,zt);
00573         LocalPoint posInChamber  = _stat->surface().toLocal(lay->toGlobal(posInLayer1));
00574         //GlobalPoint posInCMS = lay->toGlobal(posInLayer1);
00575 
00576         /* cout <<endl;
00577         cout << "tube " << ntube << " nlay " << nlay << endl;
00578         cout << "posinlayer " << posInLayer1 << "posinchamb " << posInChamber << "posinCMS " << posInCMS << endl;*/
00579         
00580         return posInChamber;
00581 }
00582 
00583 LocalPoint 
00584 DTTrigGeom::localPosition(const DTTracoId id) const {
00585 /* obsolete
00586   float x = Xwire1BTI1SL(1) +
00587     ( ( (float)(id.traco()) - 0.5 ) * DTConfig::NBTITC - 0.5 )*cellPitch();
00588   // half cell shift in SL1 of MB1 (since cmsim116)
00589   if(station()==1) x -= 0.5*cellPitch();
00590   float y = 0;
00591   float z = ZcenterSL();
00592 */
00593   //NEWGEO
00594   // position of first BTI in sl 3 on X
00595   float x = localPosition( DTBtiId(DTSuperLayerId(wheel(),station(),sector(),3),1) ).x();
00596 // 10/7/06 May be not needed anymore in new geometry
00597 //   if(posFE(3)==1)
00598 //     x -= (id.traco()-2)*DTConfig::NBTITC * cellPitch();
00599 //   if(posFE(3)==0)
00600     x += (id.traco()-2)*DTConfig::NBTITC * cellPitch();
00601 
00602   float y = 0;
00603   float z = ZcenterSL();
00604 
00605   return LocalPoint(x,y,z);
00606 }