--- PamCut/CollectionActions/RefitTrackAction/RefitTrackAction.cpp 2010/05/11 15:32:09 1.1.2.2 +++ PamCut/CollectionActions/RefitTrackAction/RefitTrackAction.cpp 2010/06/07 13:33:15 1.1.2.4 @@ -11,15 +11,24 @@ long int RefitTrackAction::_currEvent = -1; TString RefitTrackAction::_currTrkParamsFile = ""; +float RefitTrackAction::_xmBackup[6], RefitTrackAction::_ymBackup[6]; +int RefitTrackAction::_layerXBackup[6], RefitTrackAction::_layerYBackup[6]; + void RefitTrackAction::OnGood(PamLevel2 *event) { + // Do something only if at least one track exists + if (event->GetTrkLevel2()->GetNTracks() == 0) + return; + // Reload the TRK parameters only if they have been changed (ie., if another instance of - // this class used a different set of parameters. + // this class used a different set of parameters). if (_trkParamsFile != _currTrkParamsFile) { TrkParams::Set(_trkParamsFile, 5); _currTrkParamsFile = _trkParamsFile; } + if (_sortingMethod) + event->SetSortingMethod(_sortingMethod); TrkTrack *trkTrack = event->GetTrack(0)->GetTrkTrack(); if (!trkTrack) return; @@ -50,12 +59,15 @@ } // Apply the gaussian spread + + cout << GetName() << " " << trkTrack->xm[0]; + cout.flush(); for (Int_t ip = 0; ip < 6; ip++) { // gaussian distributed random number Gauss(mean,sigma) (in cm) trkTrack->xm[ip] += _r3->Gaus(0., _spreadX); trkTrack->ym[ip] += _r3->Gaus(0., _spreadY); } - + cout << GetName() << " " << trkTrack->xm[0] << endl; // Mask the layers if (_maskedViews) { if ((_maskedViews & T1X) == T1X) @@ -88,4 +100,10 @@ trkTrack->FitReset(); int fail = 0; trkTrack->Fit(0, fail, 0); + + if (fail) { + // Set a flag for the badly-refitted tracks: chi2 < 0 + if (trkTrack->chi2 >= 0.) + trkTrack->chi2 = -1.; + } }