5 #include "Sti/StiHit.h"
8 #include "StEvent/StTpcHit.h"
10 #include "StEvent/StTpcHit.h"
12 #include "StiCATpcTrackerInterface.h"
15 #ifdef PRINT_FIT_ERR_STATISTIC
17 #endif // PRINT_FIT_ERR_STATISTIC
20 #define OVERLAP_REJECTION
23 Bool_t StiCATpcSeedFinder::SeedsCompareStatus(
const Seed_t a,
const Seed_t b)
25 return (a.total_hits < b.total_hits);
31 if (!mSeeds || mSeeds->size()==0) {
33 caTrackerInt.SetNewEvent();
35 auto *map = &StiToolkit::instance()->getHitContainer()->hits();
39 caTrackerInt.SetHits(*map);
41 mSeeds = &caTrackerInt.GetSeeds();
42 if (!mSeeds->size()) { mEnded = 2;
return 0;}
43 sort(mSeeds->begin(), mSeeds->end(),SeedsCompareStatus );
46 while (mSeeds->size()) {
48 Seed_t &aSeed = mSeeds->back();
49 vector<StiHit*> _seedHits;
50 int nHits = aSeed.vhit.size();
59 if (ah==bh)
return false;
68 double ax = ah->
x_g(),ay = ah->y_g();
69 double bx = bh->
x_g(),by = bh->y_g();
70 return (ax-bx)*(ax+bx) + (ay-by)*(ay+by)>0;
73 StiHit *preHit = aSeed.vhit[ 0]->hit;
74 StiHit *endHit = aSeed.vhit[nHits-1]->hit;
76 #ifdef StiCATpcSeedFinderBLOG
77 int unsRxy=0,unsPad=0,reUsed=0;
78 #endif //StiCATpcSeedFinderBLOG
80 for (
int iHit=0;iHit<nHits-1;iHit++)
83 #ifdef StiCATpcSeedFinderBLOG
86 double rXYsti = hit->
rxy();
87 double rXYste = sthit->position().perp();
88 assert(fabs(rXYsti-rXYste)<1e-3);
89 int padrow0 = ((
StTpcHit*)(aSeed.vhit[iHit ]->hit->stHit()))->padrow();
90 int padrow1 = ((
StTpcHit*)(aSeed.vhit[iHit+1]->hit->stHit()))->padrow();
91 StiDebug::Count(
"XlocOfPad",padrow0, hit->
x());
92 StiDebug::Count(
"RxyOfPad",padrow0, rXYste);
93 StiDebug::Count(
"AngLoc",atan2(hit->y(),hit->
x())/3.1415*180);
94 if (padrow0<=padrow1) {
96 double rxy = sqrt(pow(hit->
x_g(),2)+pow(hit->y_g(),2));
97 double z = hit->z_g();
98 StiDebug::Count(
"UnsPadXY",aSeed.vhit[iHit+1]->hit->x_g(), aSeed.vhit[iHit+1]->hit->y_g());
99 StiDebug::Count(
"UnsPadZR",z, rxy);
101 #endif //StiCATpcSeedFinderBLOG
103 if (myLambda(aSeed.vhit[iHit],aSeed.vhit[iHit+1]))
continue;
104 if (!sortIt) sortIt = 100+iHit;
106 #ifdef StiCATpcSeedFinderBLOG
108 double rxy = sqrt(pow(hit->
x_g(),2)+pow(hit->y_g(),2));
109 double z = hit->z_g();
110 StiDebug::Count(
"UnsHitXY",aSeed.vhit[iHit+1]->hit->x_g(), aSeed.vhit[iHit+1]->hit->y_g());
111 StiDebug::Count(
"UnsHitZR",z, rxy);
112 static int printIt = 0;
113 if (!printIt)
continue;
115 for (
int iHit=0;iHit<nHits-1;iHit++) {
116 StiHit *hit = aSeed.vhit[iHit]->hit;
if (!hit)
continue;
117 double rxy = sqrt(pow(hit->
x_g(),2)+pow(hit->y_g(),2));
118 double z = hit->z_g();
119 printf(
"hit[%d] %p Rxy=%g\t Z=%g\n",iHit,hit,rxy,z);
122 #endif //StiCATpcSeedFinderBLOG
128 std::sort(aSeed.vhit.begin(), aSeed.vhit.end(), myLambda);
129 if (preHit != aSeed.vhit[ 0]->hit) begEndFail+=1;
130 if (endHit != aSeed.vhit[nHits-1]->hit) begEndFail+=2;
133 for (
int iHit=0;iHit<nHits;iHit++)
135 StiHit *
hit = aSeed.vhit[iHit]->hit;
if (!hit)
continue;
138 #ifdef StiCATpcSeedFinderBLOG
140 double rxy = sqrt(pow(hit->
x_g(),2)+pow(hit->y_g(),2));
142 if (hit == preHit) {StiDebug::Count(
"SameHitXY",hit->
x_g(),hit->y_g());
143 StiDebug::Count(
"SameHitZR",hit->z_g(),rxy );}
144 else {StiDebug::Count(
"SkipHitXY",hit->
x_g(),hit->y_g());
145 StiDebug::Count(
"SkipHitZR",hit->z_g(),rxy );}
146 #endif //StiCATpcSeedFinderBLOG
148 if (!iHit || iHit == nHits-1) {
150 #ifdef StiCATpcSeedFinderBLOG
151 StiDebug::Count(
"BegEndXY" ,hit->
x_g(),hit->y_g());
152 StiDebug::Count(
"BegEndZR" ,hit->z_g(),rxy );
153 #endif //StiCATpcSeedFinderBLOG
159 _seedHits.push_back(hit);
162 #ifdef StiCATpcSeedFinderBLOG
165 double pct = unsPad*100./nHits;
166 StiDebug::Count(
"UnsPad_Pct",unsPad, pct);
170 double pct = unsRxy*100./nHits;
171 StiDebug::Count(
"UnsRxy_Pct",unsRxy, pct);
175 double pct = reUsed*100./nHits;
176 StiDebug::Count(
"Reused_Pct",reUsed, pct);
178 #endif //StiCATpcSeedFinderBLOG
181 if (_seedHits.size() >=4) {
185 track->initialize0(_seedHits, &aSeed.firstNodePars, &aSeed.lastNodePars );
187 track->initialize0(_seedHits);
189 mSeeds->pop_back(); mEnded = !mSeeds->size();
190 if (!track && !mEnded)
continue;
193 mEnded = 3;
return 0;
Definition of Kalman Track.
virtual StiTrack * findTrack(double rMin=0)
Find the next track.
Abstract definition of a Track.
const Float_t & x() const
Return the local x, y, z values.
Float_t x_g() const
Return the global x, y, z values.
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
Definition of Kalman Track.
void Run()
Copy data to CATracker. Run CATracker. Copy tracks in fSeeds.
UInt_t timesUsed() const
Return the number of times this hit was assigned to a track.
float rxy() const
Return the rxy.
const StMeasuredPoint * stHit() const
static StiCATpcTrackerInterface & Instance()
Instance.