27using std::numeric_limits;
39 , fMaxNofMissingHits()
50 const vector<lit::parallel::LitScalTrack*>& trackSeeds,
51 vector<lit::parallel::LitScalTrack*>&
tracks)
54 fUsedSeedsSet.clear();
56 fHitData.SetNofStations(fLayout.GetNofStations());
58 for (fIteration = 0; fIteration < fNofIterations; fIteration++) {
63 InitTrackSeeds(trackSeeds);
69 for_each(fTracks.begin(), fTracks.end(),
DeleteObject());
74 static int eventNo = 0;
75 cout <<
"LitTrackFinderNN::DoFind: eventNo=" << eventNo++ << endl;
80 unsigned int nofHits =
hits.size();
81 for (
unsigned int iHit = 0; iHit < nofHits; iHit++) {
83 if (fUsedHitsSet.find(hit->
refId) != fUsedHitsSet.end()) {
93 unsigned int nofSeeds = trackSeeds.size();
94 for (
unsigned int iTrack = 0; iTrack < nofSeeds; iTrack++) {
103 PropagateVirtualStations(par);
107 fTracks.push_back(track);
113 unsigned char nofVirtualStations = fLayout.GetNofVirtualStations();
114 unsigned char nofSteps = (nofVirtualStations - 1) / 2;
115 for (
unsigned char iStep = 0; iStep < nofSteps; iStep++) {
147 if (nofVirtualStations == 1) {
157 unsigned char nofSteps = (nofVirtualStations - 1) / 2;
158 for (
unsigned char iStep = 0; iStep < nofSteps; iStep++) {
189 unsigned int nofTracks = fTracks.size();
190 for (
unsigned int iTrack = 0; iTrack < nofTracks; iTrack++) {
193 unsigned char nofStations = fLayout.GetNofStations();
194 for (
int iStation = 0; iStation < nofStations; iStation++) {
198 fscal zMin = fHitData.GetMinZPos(iStation);
201 const vector<int>& bins = fHitData.GetZPosBins(iStation);
202 map<int, LitTrackParamScal> binParamMap;
203 vector<int>::const_iterator itBins;
204 for (itBins = bins.begin(); itBins != bins.end(); itBins++) {
212 map<int, LitTrackParamScal>::iterator itMap;
213 for (itMap = binParamMap.begin(); itMap != binParamMap.end(); itMap++) {
214 (*itMap).second = par;
217 PropagateToStation(iStation, tpar);
226 fscal minChiSq = numeric_limits<fscal>::max();
229 const vector<LitScalPixelHit*>&
hits = fHitData.GetHits(iStation);
230 unsigned int nofHits =
hits.size();
231 for (
unsigned int iHit = 0; iHit < nofHits; iHit++) {
233 int bin = fHitData.GetBinByZPos(iStation, hit->
Z);
234 assert(binParamMap.find(bin) != binParamMap.end());
241 fscal maxErrX = fHitData.GetMaxErrX(iStation);
242 fscal devX = fSigmaCoef[fIteration] * (
sqrt(tpar.
C0 + maxErrX * maxErrX));
243 fscal maxErrY = fHitData.GetMaxErrY(iStation);
244 fscal devY = fSigmaCoef[fIteration] * (
sqrt(tpar.
C5 + maxErrY * maxErrY));
245 bool hitInside = (hit->
X < (tpar.
X + devX)) && (hit->
X > (tpar.
X - devX)) && (hit->
Y < (tpar.
Y + devY))
246 && (hit->
Y > (tpar.
Y - devY));
247 if (!hitInside)
continue;
249 fscal chi = numeric_limits<fscal>::max();
251 bool hitInValidationGate = chi < fChiSqStripHitCut[fIteration];
252 if (hitInValidationGate && chi < minChiSq) {
259 if (minHit != NULL) {
279 unsigned int nofTracks = fTracks.size();
280 for (
unsigned int iTrack = 0; iTrack < nofTracks; iTrack++) {
289 unsigned int nofTracks = fTracks.size();
290 for (
unsigned int iTrack = 0; iTrack < nofTracks; iTrack++) {
295 for (
unsigned int iHit = 0; iHit < track->
GetNofHits(); iHit++) {
303 unsigned int nofTracks = fTracks.size();
304 for (
unsigned int iTrack = 0; iTrack < nofTracks; iTrack++) {
static vector< vector< QAHit > > hits
friend fvec sqrt(const fvec &a)
Functions for calculation of the material effects.
Parallel implementation of the nearest neighbor tracking algorithm.
Implementation of the track selection algorithms.
Functor class for convenient memory release.
bool IsEmpty() const
Check if field was set.
static const fscal EPSILON
bool IsEmpty() const
Check if material was set.
fscal GetMaterial(fscal x, fscal y) const
Return material thickness in silicon equivalent for (X, Y) position (scalar version).
Base class for scalar pixel hits.
void IncChiSq(fscal dChiSq)
Increases chi square by dChiSq.
void SetPreviousTrackId(unsigned short previousTrackId)
Sets previous trackId.
const LitTrackParamScal & GetParamFirst() const
Returns first parameter of the track.
void SetNofMissingHits(unsigned short nofMissingHits)
Sets number of missing hits.
unsigned short GetPreviousTrackId() const
Return Previous track index.
void SetNDF(unsigned short NDF)
Sets number of degrees of freedom.
unsigned short GetNofHits() const
Returns number of hits in track.
const LitTrackParamScal & GetParamLast() const
Returns last parameter of the track.
unsigned short GetNofMissingHits() const
Returns number of missing hits.
bool IsGood() const
Returns true if track is good.
void SetParamLast(const LitTrackParamScal ¶m)
Sets last track parameter.
const LitScalPixelHit * GetHit(unsigned short index) const
Returns pointer to the hit.
void SetParamFirst(const LitTrackParamScal ¶m)
Sets first track parameter.
void AddHit(const LitScalPixelHit *hit)
Adds hit to track.
void SetLastStationId(unsigned short lastStationId)
Set last station ID.
const LitVirtualStation< T > & GetVirtualStation(unsigned char virtualStation) const
Return virtual station by index.
unsigned char GetNofVirtualStations() const
Return number of virtual stations.
virtual ~LitTrackFinderNN()
Destructor.
void CopyToOutput(vector< lit::parallel::LitScalTrack * > &tracks)
Copy tracks to output array.
void PropagateVirtualStations(LitTrackParamScal &par)
void ArrangeHits(const vector< lit::parallel::LitScalPixelHit * > &hits)
LitTrackFinderNN()
Constructor.
void RemoveHits()
Write already used hits to a used hits set.
void DoFind(const vector< lit::parallel::LitScalPixelHit * > &hits, const vector< lit::parallel::LitScalTrack * > &trackSeeds, vector< lit::parallel::LitScalTrack * > &tracks)
Main function for track reconstruction.
void InitTrackSeeds(const vector< lit::parallel::LitScalTrack * > &trackSeeds)
Initialize track seeds and copy to local array.
void FollowTracks()
Follow tracks through detector.
void PropagateToStation(unsigned char stationId, LitTrackParamScal &par)
Virtual detector station which stores information needed for track propagation.
const LitFieldGrid & GetField() const
const LitMaterialGrid & GetMaterial() const
LitTrackParam< fscal > LitTrackParamScal
Scalar version of LitTrackParam.
void LitRK4Extrapolation(LitTrackParam< T > &par, T zOut, const LitFieldGrid &field1, const LitFieldGrid &field2, const LitFieldGrid &field3)
void LitFiltration(LitTrackParam< T > &par, const LitPixelHit< T > &hit, T &chiSq)
Function implements Kalman filter update step for pixel hit.
void LitLineExtrapolation(LitTrackParam< T > &par, T zOut)
Line track extrapolation for the field free regions.
void DoSelectSharedHits(vector< LitScalTrack * > &tracks)
void LitAddMaterial(LitTrackParam< T > &par, T siliconThickness)
unsigned short NDF(const LitScalTrack &track)
Returns number of degrees of freedom for the track.