CMS 3D CMS Logo

DcxHit.cc

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DcxHit.cc,v 1.5 2007/01/15 22:16:28 gutsche Exp $
00004 //
00005 // Description:
00006 //      Class Implementation for |DcxHit|: drift chamber hit that can compute
00007 //      derivatives and plot itself.
00008 //
00009 // Environment:
00010 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00011 //      Attempted port to CMSSW
00012 //
00013 // Author List:
00014 //      A. Snyder, S. Wagner
00015 //
00016 // Copyright Information:
00017 //      Copyright (C) 1995      SLAC
00018 //
00019 //------------------------------------------------------------------------
00020 
00021 //babar #include "BaBar/BaBar.hh"
00022 //babar #include "DcxReco/DcxHit.hh"
00023 //babar #include "DcxReco/DcxHel.hh"
00024 //babar #include "AbsEnv/AbsEnv.hh"
00025 //babar #include "DchEnv/DchEnv.hh"
00026 //babar #include "DchGeom/DchDetector.hh"
00027 //babar #include "DchGeom/DchLayer.hh"
00028 //babar #include "DchData/DchDigi.hh"
00029 //babar #include "DchCalib/DchTimeToDist.hh"
00030 #include <iomanip>
00031 #include <cmath>
00032 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHel.hh"
00033 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
00034 
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036 
00037 using std::cout;
00038 using std::endl;
00039 using std::ostream;
00040 
00041 DcxHit::DcxHit(float sx, float sy, float sz, float wx, float wy, float wz,
00042                float c0, float cresol) 
00043               :_wx(wx),_wy(wy),_wz(wz),_c0(c0),_cresol(cresol)
00044 {
00045 //  edm::LogInfo("RoadSearch") << "try to make a cms DcxHit " << _c0 << " " << _cresol;
00046   _layernumber=0;
00047   if (_wz<0.0){_wx=-_wx;_wy=-_wy;_wz=-_wz;}
00048   _s = false; if (_wz<0.9975)_s=true; 
00049   if (_s){
00050     double rad=sqrt(sx*sx+sy*sy);
00051     if ((20.0<rad)&&(rad<30.0))_layernumber=2;
00052     if ((30.0<rad)&&(rad<38.0))_layernumber=4;
00053     if ((58.0<rad)&&(rad<66.0))_layernumber=10;
00054     if ((66.0<rad)&&(rad<74.0))_layernumber=12;
00055 //    edm::LogInfo("RoadSearch") << "stereo rad layer " << rad << " " << _layernumber 
00056 //                               << " " << _wx << " " << _wy << " " << _wz;
00057     _x = sx-sz*_wx/_wz; _y = sy-sz*_wy/_wz; 
00058   }else{
00059     _x = sx; _y = sy; 
00060     double rad=sqrt(_x*_x+_y*_y);
00061     if ((20.0<rad)&&(rad<30.0))_layernumber=1;
00062     if ((30.0<rad)&&(rad<38.0))_layernumber=3;
00063     if ((38.0<rad)&&(rad<46.0))_layernumber=5;
00064     if ((46.0<rad)&&(rad<58.0))_layernumber=7;
00065     if ((58.0<rad)&&(rad<66.0))_layernumber=9;
00066     if ((66.0<rad)&&(rad<74.0))_layernumber=11;
00067     if ((74.0<rad)&&(rad<83.0))_layernumber=13;
00068     if ((83.0<rad)&&(rad<92.0))_layernumber=15;
00069     if ((92.0<rad)&&(rad<100.0))_layernumber=17;
00070     if ((100.0<rad)&&(rad<120.0))_layernumber=19;
00071 //    edm::LogInfo("RoadSearch") << "axial layer " << _x << " " << _y;
00072   }
00073   _wirenumber=0;
00074   _superlayer=1+(_layernumber-1)/4;
00075   _t=0.0;
00076   _p = 0.0;//cms layerPtr->phiOffset() + _wirenumber*layerPtr->dPhi();
00077   double deltaz = 0.0;//cms  is symmetric detector 
00078   double pw=atan2(_y,_x);
00079   _pw=pw; 
00080 //  double tst=_s;  
00081 //  _wx=-tst*sin(pw); _wy= tst*cos(pw); 
00082 //  _wz=1.0-tst*tst; if (_wz>0.0){_wz=sqrt(_wz);}else{_wz=0.0;} 
00083   _x -= deltaz*_wx/_wz; _y -= deltaz*_wy/_wz;
00084   _sp = sin(_p); _cp = cos(_p);
00085   _d=d();
00086   _consterr = 1;
00087   _e = _cresol;
00088 // note _v is a total cludge
00089   _v=0.0018; 
00090 //cms  if ( (_t-_c0) > 0.0 )_v=_d/(_t-_c0);
00091   _xpos = _x - _d*_sp; _ypos = _y + _d*_cp;
00092   _xneg = _x + _d*_sp; _yneg = _y - _d*_cp;
00093   usedonhel=0;
00094 }
00095 
00096 //babar DcxHit::DcxHit(const DchDigi *pdcdatum, float c0, float cresol) 
00097 //babar         :_dchhit(0),_pdcdatum(pdcdatum),_c0(c0),_cresol(cresol)
00098 //babar {
00099 //babar   process();
00100 //babar }
00101 
00102 //babar DcxHit::DcxHit(const DchHit  *pdchhit,  float c0,  float cresol) 
00103 //babar         :_dchhit(pdchhit),_pdcdatum(pdchhit->digi()),
00104 //babar          _c0(c0),_cresol(cresol)
00105 //babar {
00106 //babar   process();
00107 //babar }
00108 
00109 void 
00110 DcxHit::process()
00111 {
00112 //babar   _wirenumber=_pdcdatum->wirenumber();
00113 //babar   _layernumber=_pdcdatum->layernumber();
00114 //babar   _t2d=gblEnv->getDch()->getDchTimeToDist(_layernumber,_wirenumber);
00115 //babar   _superlayer=1+(_layernumber-1)/4;
00116 //babar   _t=_pdcdatum->TdcTime();
00117 //babar   const DchDetector* geomPtr = gblEnv->getDch()->getDchDetector(); // pointer to geometry
00118 //babar   const DchLayer* layerPtr=geomPtr->getDchLayer(_layernumber);     // pointer to layer
00119 //babar   _x = layerPtr->xWire(_wirenumber);  
00120 //babar   _y = layerPtr->yWire(_wirenumber); 
00121 //babar   _s = layerPtr->stereo(); 
00122 //babar   _p = layerPtr->phiOffset() + _wirenumber*layerPtr->dPhi();
00123 //babar   double deltaz = geomPtr->zOffSet(); 
00124 //babar   double tst=_s;  double pw=atan2(_y,_x);
00125 //babar   _pw=pw; 
00126 //babar   _wx=-tst*sin(pw); _wy= tst*cos(pw); 
00127 //babar   _wz=1.0-tst*tst; if (_wz>0.0){_wz=sqrt(_wz);}else{_wz=0.0;} 
00128 //babar   _x -= deltaz*_wx/_wz; _y -= deltaz*_wy/_wz;
00129 //babar   _sp = sin(_p); _cp = cos(_p);
00130 //babar   _d=d();
00131   _consterr = 1;
00132   _e = _cresol;
00133 // note _v is a total cludge
00134   _v=0.0018; 
00135 //babar   if ( (_t-_c0) > 0.0 )_v=_d/(_t-_c0);
00136 //babar   _xpos = _x - _d*_sp; _ypos = _y + _d*_cp;
00137 //babar   _xneg = _x + _d*_sp; _yneg = _y - _d*_cp;
00138   usedonhel=0;
00139 }
00140 
00141 //DcxHit destructor
00142 DcxHit::~DcxHit( )
00143 {
00144  ; 
00145 }
00146 
00147 float 
00148 DcxHit::d(DcxHel &hel)const 
00149 {
00150   hel.Doca(*this); // changes hel's internal state...
00151   return d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
00152            hel.Doca_Wamb(),hel.Doca_Eang());
00153 }//endof d
00154 
00155 float 
00156 DcxHit::pull(DcxHel &hel)const 
00157 {// compute pulls for |hel|
00158 //  float doca=hel.Doca(*this); if(hel.Mode() == 0)doca=fabs(doca);
00159 //  return (d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
00160 //           hel.Doca_Wamb(),hel.Doca_Eang())-doca)/e(doca);
00161   return residual(hel)/e();
00162 }//endof pull
00163 
00164 float 
00165 DcxHit::residual(DcxHel &hel)const 
00166 { // compute residuals for |hel|
00167   float doca=hel.Doca(*this);
00168   if(hel.Mode() == 0)doca=fabs(doca);
00169 //  doca += v()*hel.T0();
00170   return d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
00171            hel.Doca_Wamb(),hel.Doca_Eang())-doca;
00172 }//endof residual
00173 
00174 std::vector<float>
00175 DcxHit::derivatives(DcxHel &hel)const 
00176 { // compute derivatives for |hel|
00177   std::vector<float> deriv=hel.derivatives(*this);
00178   float dtemp=d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
00179                 hel.Doca_Wamb(),hel.Doca_Eang());
00180   deriv[0]=dtemp-deriv[0];
00181 //  deriv[0] -= v()*hel.T0();
00182   float ewire=e(dtemp);
00183   for(unsigned int i=0; i<deriv.size(); i++) {deriv[i]/=ewire;}
00184   return deriv;
00185 }//endof derivatives
00186 
00187 void 
00188 DcxHit::print(ostream &o,int i)const 
00189 {
00190       o << " Digi # " << i  
00191         << " Layer # " << Layer() 
00192         << " SuperLayer # " << SuperLayer() 
00193         << " Wire # " << WireNo() 
00194 //        << " Drift dist (cm) " << d() 
00195 //        << " Drift err  (cm) " << e() 
00196         << " Drift time (ns) " << t();
00197 }//endof print

Generated on Tue Jun 9 17:45:40 2009 for CMSSW by  doxygen 1.5.4