StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgt2PointCosmicTrackAlgo.cxx
1 /***************************************************************************
2  *
3  * $Id: StFgt2PointCosmicTrackAlgo.cxx,v 1.1 2012/01/31 23:25:35 avossen Exp $
4  * Author: C. K. Riley (ckriley@bnl.gov), Oct. 11 2011
5  *
6  ***************************************************************************
7  *
8  * Description: 2PointAlgo CosmicTrack making algorithm takes 2 points
9  * from outer quads, fits actual hit to expected hit on middle quad
10  *
11  ***************************************************************************
12  *
13  * $Log: StFgt2PointCosmicTrackAlgo.cxx,v $
14  * Revision 1.1 2012/01/31 23:25:35 avossen
15  * moved StFgtCosmicTrackMaker to StFgtPool
16  *
17  * Revision 1.9 2011/11/25 20:24:59 ckriley
18  * now will look at all possible point combinations for tracks and pick the best one
19  *
20  * Revision 1.8 2011/11/16 22:15:07 ckriley
21  * now looks at all points on quadrants and gets best track
22  *
23  * Revision 1.7 2011/11/01 18:50:13 sgliske
24  * Updated to correspond with StEvent containers, take 2.
25  *
26  * Revision 1.6 2011/10/25 15:45:18 ckriley
27  * minor change
28  *
29  * Revision 1.4 2011/10/20 17:13:44 ckriley
30  * major update -> headers, tracks stored in StFgtEvent instead of StFgtDisc, changes to trackmaker and algorithms
31  *
32  *
33  **************************************************************************/
34 
35 #include "StFgt2PointCosmicTrackAlgo.h"
36 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
37 #include "StRoot/StEvent/StFgtCollection.h"
38 #include "StRoot/StEvent/StFgtPoint.h"
39 
40 
41 StFgt2PointCosmicTrackAlgo::StFgt2PointCosmicTrackAlgo():mIsInitialized(0) {
42  //nothing else to do....
43 };
44 
45 // initialize
46 Int_t StFgt2PointCosmicTrackAlgo::Init() {
47  mIsInitialized=true;
48  return kStOk;
49 };
50 
51 
52 Int_t StFgt2PointCosmicTrackAlgo::makeCosmicTracks(StFgtPointCollection& points, StFgtCosmicTrackVec& tracks, Int_t eventCounter) {
53 
54  // calculate track from 2 points on outer discs -> get 4 param for line
55  Float_t x_0=0, y_0=0, trackX_0=0, trackY_0=0;
56  Float_t a=1, b=1, trackA=1, trackB=1;
57  Float_t dX=0, dY=0, dR=0, trackdX=0, trackdY=0, trackdR=99999, hitX=0, hitY=0;
58  Bool_t isTrack=false, isTrueTrack=false;
59  Float_t XoS=0, YoS=0, ZoS=0, OoS=0,
60  XXoS=0, YYoS=0, ZZoS=0, ZXoS=0, ZYoS=0,
61  sigma=0.3*0.3;// +a*a*0.5*0.5;// assuming known Z and XY errors of 3mm
62  Int_t quad0Id, quad1Id, quad2Id;
63  Float_t x0,y0,z0,r0,phi0,x1,y1,z1,r1,phi1,x2,y2,z2,r2,phi2;
64 
65  const StSPtrVecFgtPoint &pointVec = points.getPointVec();
66  StSPtrVecFgtPointConstIterator pointIter0, pointIter1, pointIter2;
67 
68  for( pointIter0 = pointVec.begin(); pointIter0 != pointVec.end(); ++pointIter0 ) {
69  quad0Id = (*pointIter0)->getDisc();
70  r0 = (*pointIter0)->getPositionR();
71  phi0 = (*pointIter0)->getPositionPhi();
72  x0 = r0*cos(phi0+.2618);
73  y0 = r0*sin(phi0+.2618);
74  z0 = 30.48; // 12 inches in cm, top quadrant
75  if( quad0Id==0 ) {
76  for( pointIter1 = pointVec.begin(); pointIter1 != pointVec.end(); ++pointIter1) {
77  quad1Id = (*pointIter1)->getDisc();
78  r1 = (*pointIter1)->getPositionR();
79  phi1 = (*pointIter1)->getPositionPhi();
80  x1 = r1*cos(phi1+.2618);
81  y1 = r1*sin(phi1+.2618);
82  z1 = 15.24; // 6 inches in cm, middle quadrant
83  if( quad1Id==1 ) {
84  for( pointIter2 = pointVec.begin(); pointIter2 != pointVec.end(); ++pointIter2) {
85  quad2Id = (*pointIter2)->getDisc();
86  r2 = (*pointIter2)->getPositionR();
87  phi2 = (*pointIter2)->getPositionPhi();
88  x2 = r2*cos(phi2+.2618);
89  y2 = r2*sin(phi2+.2618);
90  z2 = 0.; // take origin as bottom quadrant
91  if( quad2Id==2 ) {
92  XoS = (x0+x1+x2)/sigma;
93  YoS = (y0+y1+y2)/sigma;
94  ZoS = (z0+z1+z2)/sigma;
95  OoS = 3/sigma;
96  XXoS = (x0*x0+x1*x1+x2*x2)/sigma;
97  YYoS = (y0*y0+y1*y1+y2*y2)/sigma;
98  ZZoS = (z0*z0+z1*z1+z2*z2)/sigma;
99  ZXoS = (x0*z0+x1*z1+x2*z2)/sigma;
100  ZYoS = (y0*z0+y1*z1+y2*z2)/sigma;
101 
102  // do two 2D cases. x = a*z + x_0 and y = b*z + y_0
103  Float_t denominator = ZZoS*OoS-ZoS*ZoS;
104  if(denominator != 0) {
105  a = (ZXoS*OoS-XoS*ZoS)/denominator;
106  x_0 = (ZZoS*XoS-ZXoS*ZoS)/denominator;
107  b = (ZYoS*OoS-YoS*ZoS)/denominator;
108  y_0 = (ZZoS*YoS-ZYoS*ZoS)/denominator;
109  }
110 
111  // look at middle disc -> extrapolate expected point from line -> does data fit expectation within a region pi*r^2? (use r=0.3cm)
112  dX = x1-(a*z1+x_0);
113  dY = y1-(b*z1+y_0);
114  dR=sqrt(dX*dX + dY*dY);
115  if(dR<0.3) {
116  //cout << "\nFound track in event " << eventCounter << "! (2-point fit)" << endl;
117  isTrack = true;
118  }
119 
120  // store track with smallest dR
121  if(dR<trackdR) {
122  trackdR=dR;
123  trackA=a;
124  trackB=b;
125  trackX_0=x_0;
126  trackY_0=y_0;
127  trackdX=dX;
128  trackdY=dY;
129  hitX=x1;
130  hitY=y1;
131  isTrueTrack=isTrack;
132  }
133  }
134  }
135  }
136  }
137  }
138  }
139 
140  // now must store values and a,b,x_0,y_0,dX,dY,dR in a container in StFgtEvent
141  // for now -> store dR instead of chi2 val
142 
143  tracks.push_back( StFgtCosmicTrack (eventCounter, trackA, trackB, trackX_0, trackY_0, trackdX, trackdY, trackdR, hitX, hitY, isTrueTrack) );
144 
145  return kStOk;
146 };
147 
Definition: Stypes.h:41