CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DcxHit.cc
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: DcxHit.cc,v 1.6 2011/04/07 21:47:06 stevew Exp $
4 //
5 // Description:
6 // Class Implementation for |DcxHit|: drift chamber hit that can compute
7 // derivatives and plot itself.
8 //
9 // Environment:
10 // Software developed for the BaBar Detector at the SLAC B-Factory.
11 // Attempted port to CMSSW
12 //
13 // Author List:
14 // A. Snyder, S. Wagner
15 //
16 //------------------------------------------------------------------------
17 
18 //babar #include "BaBar/BaBar.hh"
19 //babar #include "DcxReco/DcxHit.hh"
20 //babar #include "DcxReco/DcxHel.hh"
21 //babar #include "AbsEnv/AbsEnv.hh"
22 //babar #include "DchEnv/DchEnv.hh"
23 //babar #include "DchGeom/DchDetector.hh"
24 //babar #include "DchGeom/DchLayer.hh"
25 //babar #include "DchData/DchDigi.hh"
26 //babar #include "DchCalib/DchTimeToDist.hh"
27 #include <iomanip>
28 #include <cmath>
29 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHel.hh"
30 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
31 
33 
34 using std::cout;
35 using std::endl;
36 using std::ostream;
37 
38 DcxHit::DcxHit(float sx, float sy, float sz, float wx, float wy, float wz,
39  float c0, float cresol)
40  :_wx(wx),_wy(wy),_wz(wz),_c0(c0),_cresol(cresol)
41 {
42 // edm::LogInfo("RoadSearch") << "try to make a cms DcxHit " << _c0 << " " << _cresol;
43  _layernumber=0;
44  if (_wz<0.0){_wx=-_wx;_wy=-_wy;_wz=-_wz;}
45  _s = false; if (_wz<0.9975)_s=true;
46  if (_s){
47  double rad=sqrt(sx*sx+sy*sy);
48  if ((20.0<rad)&&(rad<30.0))_layernumber=2;
49  if ((30.0<rad)&&(rad<38.0))_layernumber=4;
50  if ((58.0<rad)&&(rad<66.0))_layernumber=10;
51  if ((66.0<rad)&&(rad<74.0))_layernumber=12;
52 // edm::LogInfo("RoadSearch") << "stereo rad layer " << rad << " " << _layernumber
53 // << " " << _wx << " " << _wy << " " << _wz;
54  _x = sx-sz*_wx/_wz; _y = sy-sz*_wy/_wz;
55  }else{
56  _x = sx; _y = sy;
57  double rad=sqrt(_x*_x+_y*_y);
58  if ((20.0<rad)&&(rad<30.0))_layernumber=1;
59  if ((30.0<rad)&&(rad<38.0))_layernumber=3;
60  if ((38.0<rad)&&(rad<46.0))_layernumber=5;
61  if ((46.0<rad)&&(rad<58.0))_layernumber=7;
62  if ((58.0<rad)&&(rad<66.0))_layernumber=9;
63  if ((66.0<rad)&&(rad<74.0))_layernumber=11;
64  if ((74.0<rad)&&(rad<83.0))_layernumber=13;
65  if ((83.0<rad)&&(rad<92.0))_layernumber=15;
66  if ((92.0<rad)&&(rad<100.0))_layernumber=17;
67  if ((100.0<rad)&&(rad<120.0))_layernumber=19;
68 // edm::LogInfo("RoadSearch") << "axial layer " << _x << " " << _y;
69  }
70  _wirenumber=0;
71  _superlayer=1+(_layernumber-1)/4;
72  _t=0.0;
73  _p = 0.0;//cms layerPtr->phiOffset() + _wirenumber*layerPtr->dPhi();
74  double deltaz = 0.0;//cms is symmetric detector
75  double pw=atan2(_y,_x);
76  _pw=pw;
77 // double tst=_s;
78 // _wx=-tst*sin(pw); _wy= tst*cos(pw);
79 // _wz=1.0-tst*tst; if (_wz>0.0){_wz=sqrt(_wz);}else{_wz=0.0;}
80  _x -= deltaz*_wx/_wz; _y -= deltaz*_wy/_wz;
81  _sp = sin(_p); _cp = cos(_p);
82  _d=d();
83  _consterr = 1;
84  _e = _cresol;
85 // note _v is a total cludge
86  _v=0.0018;
87 //cms if ( (_t-_c0) > 0.0 )_v=_d/(_t-_c0);
88  _xpos = _x - _d*_sp; _ypos = _y + _d*_cp;
89  _xneg = _x + _d*_sp; _yneg = _y - _d*_cp;
90  usedonhel=0;
91 }
92 
93 //babar DcxHit::DcxHit(const DchDigi *pdcdatum, float c0, float cresol)
94 //babar :_dchhit(0),_pdcdatum(pdcdatum),_c0(c0),_cresol(cresol)
95 //babar {
96 //babar process();
97 //babar }
98 
99 //babar DcxHit::DcxHit(const DchHit *pdchhit, float c0, float cresol)
100 //babar :_dchhit(pdchhit),_pdcdatum(pdchhit->digi()),
101 //babar _c0(c0),_cresol(cresol)
102 //babar {
103 //babar process();
104 //babar }
105 
106 void
108 {
109 //babar _wirenumber=_pdcdatum->wirenumber();
110 //babar _layernumber=_pdcdatum->layernumber();
111 //babar _t2d=gblEnv->getDch()->getDchTimeToDist(_layernumber,_wirenumber);
112 //babar _superlayer=1+(_layernumber-1)/4;
113 //babar _t=_pdcdatum->TdcTime();
114 //babar const DchDetector* geomPtr = gblEnv->getDch()->getDchDetector(); // pointer to geometry
115 //babar const DchLayer* layerPtr=geomPtr->getDchLayer(_layernumber); // pointer to layer
116 //babar _x = layerPtr->xWire(_wirenumber);
117 //babar _y = layerPtr->yWire(_wirenumber);
118 //babar _s = layerPtr->stereo();
119 //babar _p = layerPtr->phiOffset() + _wirenumber*layerPtr->dPhi();
120 //babar double deltaz = geomPtr->zOffSet();
121 //babar double tst=_s; double pw=atan2(_y,_x);
122 //babar _pw=pw;
123 //babar _wx=-tst*sin(pw); _wy= tst*cos(pw);
124 //babar _wz=1.0-tst*tst; if (_wz>0.0){_wz=sqrt(_wz);}else{_wz=0.0;}
125 //babar _x -= deltaz*_wx/_wz; _y -= deltaz*_wy/_wz;
126 //babar _sp = sin(_p); _cp = cos(_p);
127 //babar _d=d();
128  _consterr = 1;
129  _e = _cresol;
130 // note _v is a total cludge
131  _v=0.0018;
132 //babar if ( (_t-_c0) > 0.0 )_v=_d/(_t-_c0);
133 //babar _xpos = _x - _d*_sp; _ypos = _y + _d*_cp;
134 //babar _xneg = _x + _d*_sp; _yneg = _y - _d*_cp;
135  usedonhel=0;
136 }
137 
138 //DcxHit destructor
139 DcxHit::~DcxHit( )
140 {
141  ;
142 }
143 
144 float
145 DcxHit::d(DcxHel &hel)const
146 {
147  hel.Doca(*this); // changes hel's internal state...
148  return d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
149  hel.Doca_Wamb(),hel.Doca_Eang());
150 }//endof d
151 
152 float
153 DcxHit::pull(DcxHel &hel)const
154 {// compute pulls for |hel|
155 // float doca=hel.Doca(*this); if(hel.Mode() == 0)doca=fabs(doca);
156 // return (d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
157 // hel.Doca_Wamb(),hel.Doca_Eang())-doca)/e(doca);
158  return residual(hel)/e();
159 }//endof pull
160 
161 float
162 DcxHit::residual(DcxHel &hel)const
163 { // compute residuals for |hel|
164  float doca=hel.Doca(*this);
165  if(hel.Mode() == 0)doca=fabs(doca);
166 // doca += v()*hel.T0();
167  return d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
168  hel.Doca_Wamb(),hel.Doca_Eang())-doca;
169 }//endof residual
170 
171 std::vector<float>
172 DcxHit::derivatives(DcxHel &hel)const
173 { // compute derivatives for |hel|
174  std::vector<float> deriv=hel.derivatives(*this);
175  float dtemp=d(hel.Doca_Zh(),hel.Doca_Tof(),hel.T0(),
176  hel.Doca_Wamb(),hel.Doca_Eang());
177  deriv[0]=dtemp-deriv[0];
178 // deriv[0] -= v()*hel.T0();
179  float ewire=e(dtemp);
180  for(unsigned int i=0; i<deriv.size(); i++) {deriv[i]/=ewire;}
181  return deriv;
182 }//endof derivatives
183 
184 void
185 DcxHit::print(ostream &o,int i)const
186 {
187  o << " Digi # " << i
188  << " Layer # " << Layer()
189  << " SuperLayer # " << SuperLayer()
190  << " Wire # " << WireNo()
191 // << " Drift dist (cm) " << d()
192 // << " Drift err (cm) " << e()
193  << " Drift time (ns) " << t();
194 }//endof print
int i
Definition: DBlmapReader.cc:9
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple cout
Definition: gather_cfg.py:121
tuple process
Definition: LaserDQM_cfg.py:3