13#ifdef TRKRECO_DEBUG_DETAIL
20#include "TrkReco/T3DLineFitter.h"
21#include "TrkReco/T3DLine.h"
22#define HEP_SHORT_NAMES
25#include "MdcTables/MdcTables.h"
26#include "CLHEP/Matrix/Vector.h"
27#include "CLHEP/Matrix/SymMatrix.h"
28#include "CLHEP/Matrix/Matrix.h"
29#include "TrkReco/TMLink.h"
30#include "TrkReco/TTrackBase.h"
32#include "MdcCalibFunSvc/IMdcCalibFunSvc.h"
33#include "MdcCalibFunSvc/MdcCalibFunSvc.h"
35#include "GaudiKernel/MsgStream.h"
36#include "GaudiKernel/AlgFactory.h"
37#include "GaudiKernel/ISvcLocator.h"
38#include "GaudiKernel/IMessageSvc.h"
39#include "GaudiKernel/IDataProviderSvc.h"
40#include "GaudiKernel/IDataManagerSvc.h"
41#include "GaudiKernel/SmartDataPtr.h"
42#include "GaudiKernel/IDataProviderSvc.h"
43#include "GaudiKernel/PropertyMgr.h"
44#include "GaudiKernel/IJobOptionsSvc.h"
45#include "GaudiKernel/IMessageSvc.h"
46#include "GaudiKernel/Bootstrap.h"
47#include "GaudiKernel/StatusCode.h"
49#include "GaudiKernel/ContainedObject.h"
50#include "GaudiKernel/SmartRef.h"
51#include "GaudiKernel/SmartRefVector.h"
52#include "GaudiKernel/ObjectVector.h"
53#include "EventModel/EventModel.h"
55#include "EvTimeEvent/RecEsTime.h"
57using CLHEP::HepVector;
58using CLHEP::HepSymMatrix;
59using CLHEP::HepMatrix;
87 bool m_sag,
int m_prop,
bool m_tof)
89 _sag(m_sag),_propagation(m_prop),_tof(
m_tof){
107 double& distance,
double& err)
const{
110 double _t0_bes = -1.;
112 Gaudi::svcLocator()->service(
"MessageSvc",
msgSvc);
113 MsgStream log(
msgSvc,
"TCosmicFitter");
115 IDataProviderSvc* eventSvc = NULL;
116 Gaudi::svcLocator()->service(
"EventDataSvc", eventSvc);
118 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc,
"/Event/Recon/RecEsTimeCol");
120 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
121 _t0_bes = (*iter_evt)->getTest();
123 log << MSG::WARNING <<
"Could not find RecEsTimeCol" << endreq;
132 if((onWire.x()*onTrack.y()-onWire.y()*onTrack.x())<0) leftRight =
WireHitLeft;
166 double Tfly = _t0_bes/220.*(110.-onWire.y());
173 int side = leftRight;
182 Gaudi::svcLocator() -> service(
"MdcCalibFunSvc", l_mdcCalFunSvc);
183 double T0 = l_mdcCalFunSvc->
getT0(layerId,wire);
187 double timeWalk = l_mdcCalFunSvc->
getTimeWalk(layerId, rawadc);
189 double drifttime =
time -T0-timeWalk;
191 dist = l_mdcCalFunSvc->
driftTimeToDist(drifttime,layerId, wire, side, 0.0);
192 edist = l_mdcCalFunSvc->
getSigma(layerId, side, dist, 0.0);
206 distance = (double) dist;
207 err = (double) edist;
228 unsigned nCores = cores.length();
234 if ((nStereoCores == 0) && (nCores > 3)) flag2D =
true;
235 else if ((nStereoCores < 2) || (nCores - nStereoCores < 3))
265 for (
unsigned j=0;j<4;j++) dchi2da[j]=0;
270 while(
TMLink* l = cores[i++]){
278 if (onWire.cross(onTrack).z() < 0.) leftRight =
WireHitLeft;
283 drift(
t, * l, t0Offset, distance, eDistance);
284 l->
drift(distance,0);
285 l->
drift(distance,1);
288 double eDistance2 = eDistance * eDistance;
293 double vmag =
v.mag();
294 double dDistance = vmag - distance;
298 this->dxda(*l,
t, dxda, dyda, dzda, vw);
302 ? ((
v.x() * (1. - vw.x() * vw.x()) -
303 v.y() * vw.x() * vw.y() -
v.z() * vw.x() * vw.z())
305 (
v.y() * (1. - vw.y() * vw.y()) -
306 v.z() * vw.y() * vw.z() -
v.x() * vw.y() * vw.x())
308 (
v.z() * (1. - vw.z() * vw.z()) -
309 v.x() * vw.z() * vw.x() -
v.y() * vw.z() * vw.y())
310 * dzda) / vmag :
Vector(4,0);
312 std::cout <<
" in fit " << onTrack <<
", " << onWire;
315 dchi2da += (dDistance / eDistance2) * dDda;
316 d2chi2d2a += vT_times_v(dDda) / eDistance2;
317 double pChi2 = dDistance * dDistance / eDistance2;
321 l->
update(onTrack, onWire, leftRight, pChi2);
325 double change = chi2Old - chi2;
327 if (fabs(change) < 1.0e-5)
break;
334 f = dchi2da.sub(1,2);
335 e = d2chi2d2a.sub(1,2);
343 da = solve(d2chi2d2a, dchi2da);
357 Eb = d2chi2d2a.sub(1,3);
358 Ec = Eb.inverse(err);
367 Ea = d2chi2d2a.inverse(err);
380 t._ndf = nCores - dim;
397 const double cosPhi0 =
t.cosPhi0();
398 const double sinPhi0 =
t.sinPhi0();
399 const double dr =
t.dr();
403 const double t_t = (onWire -
t.x0()).dot(k)/k.mag2();
411 wireBackwardPosition,
418 const double v_k =
v.dot(k);
419 const double tvk = v_k*v_k-k.mag2();
420 if(tvk==0)
return(-1);
426 HepVector3D(-dr*sinPhi0-t_t*cosPhi0,dr*cosPhi0-t_t*sinPhi0,0),
445 for(
int i=0;i<4;i++){
446 const double v_dkda =
v.dot(dkda[i]);
448 const double dtda = dx0da[i].dot(kvkv)/tvk
449 + d.dot(dkda[i]-v_dkda*
v)/tvk
450 - d.dot(kvkv)*2*(v_k*v_dkda-k.dot(dkda[i]))/(tvk*tvk);
452 const HepVector3D dxda3D = dxda_t[i] + dtda*dxdt_a;
454 dxda[i] = dxda3D.x();
455 dyda[i] = dxda3D.y();
456 dzda[i] = dxda3D.z();
NTuple::Array< double > m_tof
CLHEP::HepSymMatrix SymMatrix
const HepPoint3D ORIGIN
Constants.
#define TFitAlreadyFitted
unsigned NStereoHits(const AList< TMLink > &links)
returns # of stereo hits.
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
HepGeom::Vector3D< double > HepVector3D
virtual double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const =0
virtual double getSigma(int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const =0
virtual double getT0(int layid, int cellid) const =0
virtual double getTimeWalk(int layid, double Q) const =0
T3DLineFitter(const std::string &name)
Constructor.
virtual int fit(TTrackBase &) const
virtual ~T3DLineFitter()
Destructor.
A class to represent a track in tracking.
struct MdcRec_wirhit * reccdc(void) const
returns a pointer to RECMDC_WIRHIT.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
A class to represent a wire in MDC.
unsigned localId(void) const
returns local id in a wire layer.
unsigned layerId(void) const
returns layer id.
const HepVector3D & direction(void) const
returns direction vector of the wire.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
const HepPoint3D & backwardPosition(void) const
returns position in backward endplate.
void wirePosition(float zPosition, HepPoint3D &xyPosition, HepPoint3D &backwardPosition, HepVector3D &direction) const
calculates position and direction vector with sag correction.
A class to fit a TTrackBase object.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & positionOnWire(void) const
returns the closest point on wire to a track.
const HepPoint3D & positionOnTrack(void) const
returns the closest point on track to wire.
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
void update(const HepPoint3D &onTrack, const HepPoint3D &onWire, unsigned leftRight, double pull)
sets results of fitting.
float dDrift(void) const
returns/sets drift distance error.
float drift(void) const
returns/sets drift distance.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
A virtual class for a track class in tracking.
virtual unsigned objectType(void) const
returns object type.