00001
00002 #ifdef DO_TPCCATRACKER
00003 #include "StiTpcSeedFinder.h"
00004 #include "StiToolkit.h"
00005 #include "StiHit.h"
00006 #include "StMessMgr.h"
00007 #include "StTpcHit.h"
00008 #include "StiKalmanTrack.h"
00009 #include "StiKalmanTrackFinder.h"
00010
00011 #include "StiTPCCATrackerInterface.h"
00012
00013
00014 #ifdef PRINT_FIT_ERR_STATISTIC
00015 #include <map>
00016 #endif // PRINT_FIT_ERR_STATISTIC
00017
00018
00019 #define OVERLAP_REJECTION
00020
00021 Bool_t StiTpcSeedFinder::SeedsCompareStatus(const Seed_t a, const Seed_t b){
00022 return (a.total_hits < b.total_hits);
00023 }
00024
00025 void StiTpcSeedFinder::findTpcTracks(StiTPCCATrackerInterface &caTrackerInt) {
00026 #ifdef PRINT_FIT_ERR_STATISTIC
00027 static std::map<int,unsigned int> statusMap;
00028 #endif // PRINT_FIT_ERR_STATISTIC
00029
00030
00031
00032 HitMapToVectorAndEndType& map = StiToolkit::instance()->getHitContainer()->hits();
00033
00034
00035
00036 caTrackerInt.SetHits(map);
00037 caTrackerInt.Run();
00038 vector<Seed_t> &seeds = caTrackerInt.GetSeeds();
00039
00040
00041 sort(seeds.begin(), seeds.end(),SeedsCompareStatus );
00042 #ifdef PRINT_SEED_STATISTIC
00043 Int_t nSeed = 0;
00044 #endif // PRINT_SEED_STATISTIC
00045 while (! seeds.empty()) {
00046 Seed_t &aSeed = seeds.back();
00047 vector<StiHit*> _seedHits;
00048 for (vector<SeedHit_t *>::iterator hitb = aSeed.vhit.begin(); hitb != aSeed.vhit.end(); hitb++) {
00049 StiHit *hit = (*hitb)->hit;
00050 if (!hit || hit->timesUsed()) continue;
00051 _seedHits.push_back(hit);
00052 }
00053 seeds.pop_back();
00054 #ifdef PRINT_SEED_STATISTIC
00055 cout<< "seed: " << nSeed++ << "\t" <<aSeed.total_hits<<" total hits ";
00056 cout << " no. unused hits " << _seedHits.size();
00057 #endif // PRINT_SEED_STATISTIC
00058 if (_seedHits.size() < 4) {
00059 #ifdef PRINT_SEED_STATISTIC
00060 cout << endl;
00061 #endif // PRINT_SEED_STATISTIC
00062 continue;
00063 }
00064 StiKalmanTrack* track = StiToolkit::instance()->getTrackFactory()->getInstance();
00065
00066
00067 track->initialize0(_seedHits, &aSeed.firstNodePars, &aSeed.lastNodePars );
00068 StiKalmanTrackFinder *finderTmp = (StiKalmanTrackFinder *)track->getTrackFinder();
00069 int status = finderTmp->Fit(track);
00070 #ifdef PRINT_FIT_ERR_STATISTIC
00071 StiKalmanTrackFinder::PrintFitStatus(status,track);
00072
00073 if ( statusMap.find(status) != statusMap.end() ) statusMap[status]++;
00074 else statusMap[status] = 1;
00075 #endif // PRINT_FIT_ERR_STATISTIC
00076
00077 if (status){
00078 BFactory::Free(track);
00079 continue;
00080 }
00081 track->setSeedHitCount(track->getSeedHitCount()+100);
00082 }
00083
00084 #ifdef PRINT_FIT_ERR_STATISTIC
00085 cout << " ---- Fit status statistic. ---- " << endl;
00086 for ( std::map<int, unsigned int>::iterator it = statusMap.begin(); it != statusMap.end(); it++) {
00087 cout << (*it).second << " entries for:" << endl;
00088 StiKalmanTrackFinder::PrintFitStatus((*it).first,0);
00089 }
00090 #endif // PRINT_FIT_ERR_STATISTIC
00091 }
00092 #endif
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132