38 #include "StFgtSimpleCosmicTrackAlgo.h"
39 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
40 #include "StRoot/StEvent/StFgtCollection.h"
41 #include "StRoot/StEvent/StFgtPoint.h"
44 StFgtSimpleCosmicTrackAlgo::StFgtSimpleCosmicTrackAlgo():mIsInitialized(0) {
49 Int_t StFgtSimpleCosmicTrackAlgo::Init() {
55 Int_t StFgtSimpleCosmicTrackAlgo::makeCosmicTracks(
StFgtPointCollection& points, StFgtCosmicTrackVec& tracks, Int_t eventCounter) {
58 Float_t chi2x=0, chi2y=0, chi2=0, chiMin=99999;
59 Float_t x_0=0, y_0=0, trackX_0=0, trackY_0=0;
60 Float_t a=1, b=1, trackA=1, trackB=1;
61 Float_t dX=0, dY=0, trackdX=0, trackdY=0, hitX=0, hitY=0;
62 Bool_t isTrack=
false, isTrueTrack=
false;
63 Float_t XoS=0, YoS=0, ZoS=0, OoS=0,
64 XXoS=0, YYoS=0, ZZoS=0, ZXoS=0, ZYoS=0,
66 Int_t quad0Id, quad1Id, quad2Id;
67 Float_t x0,y0,z0,r0,phi0,x1,y1,z1,r1,phi1,x2,y2,z2,r2,phi2;
69 const StSPtrVecFgtPoint &pointVec = points.getPointVec();
70 StSPtrVecFgtPointConstIterator pointIter0, pointIter1, pointIter2;
72 for( pointIter0 = pointVec.begin(); pointIter0 != pointVec.end(); ++pointIter0 ) {
73 quad0Id = (*pointIter0)->getDisc();
74 r0 = (*pointIter0)->getPositionR();
75 phi0 = (*pointIter0)->getPositionPhi();
76 x0 = r0*cos(phi0+.2618);
77 y0 = r0*sin(phi0+.2618);
80 for( pointIter1 = pointVec.begin(); pointIter1 != pointVec.end(); ++pointIter1) {
81 quad1Id = (*pointIter1)->getDisc();
82 r1 = (*pointIter1)->getPositionR();
83 phi1 = (*pointIter1)->getPositionPhi();
84 x1 = r1*cos(phi1+.2618);
85 y1 = r1*sin(phi1+.2618);
88 for( pointIter2 = pointVec.begin(); pointIter2 != pointVec.end(); ++pointIter2) {
89 quad2Id = (*pointIter2)->getDisc();
90 r2 = (*pointIter2)->getPositionR();
91 phi2 = (*pointIter2)->getPositionPhi();
92 x2 = r2*cos(phi2+.2618);
93 y2 = r2*sin(phi2+.2618);
96 XoS = (x0+x1+x2)/sigma;
97 YoS = (y0+y1+y2)/sigma;
98 ZoS = (z0+z1+z2)/sigma;
100 XXoS = (x0*x0+x1*x1+x2*x2)/sigma;
101 YYoS = (y0*y0+y1*y1+y2*y2)/sigma;
102 ZZoS = (z0*z0+z1*z1+z2*z2)/sigma;
103 ZXoS = (x0*z0+x1*z1+x2*z2)/sigma;
104 ZYoS = (y0*z0+y1*z1+y2*z2)/sigma;
107 Float_t denominator = ZZoS*OoS-ZoS*ZoS;
108 if(denominator != 0) {
109 a = (ZXoS*OoS-XoS*ZoS)/denominator;
110 x_0 = (ZZoS*XoS-ZXoS*ZoS)/denominator;
111 b = (ZYoS*OoS-YoS*ZoS)/denominator;
112 y_0 = (ZZoS*YoS-ZYoS*ZoS)/denominator;
114 chi2x = (x0-(a*z0+x_0))*(x0-(a*z0+x_0))/sigma + (x1-(a*z1+x_0))*(x1-(a*z1+x_0))/sigma + (x2-(a*z2+x_0))*(x2-(a*z2+x_0))/sigma;
115 chi2y = (y0-(b*z0+y_0))*(y0-(b*z0+y_0))/sigma + (y1-(b*z1+y_0))*(y1-(b*z1+y_0))/sigma + (y2-(b*z2+y_0))*(y2-(b*z2+y_0))/sigma;
117 chi2 = (chi2x+chi2y)/2;
118 if(chi2x<4 && chi2y<4) {
147 tracks.push_back(
StFgtCosmicTrack (eventCounter, trackA, trackB, trackX_0, trackY_0, trackdX, trackdY, chiMin, hitX, hitY, isTrueTrack) );