00001 //_____________________________________________________________________________ 00010 00011 #include <string> 00012 00013 #include "Algorithm/AlgConfig.h" 00014 #include "MessageService/MsgService.h" 00015 00016 #include "CandFitTrackSA/ConstFT.h" 00017 #include "CandFitTrackSA/DataFT.h" 00018 #include "CandFitTrackSA/MatrixCalculator.h" 00019 00020 #include "CandFitTrackSA/FitStateFactory.h" 00021 #include "CandFitTrackSA/FitStateConverged.h" 00022 #include "CandFitTrackSA/FitContext.h" 00023 00024 CVSID("$Id: FitStateConverged.cxx,v 1.3 2006/02/13 03:50:22 avva Exp $"); 00025 00026 // The ID of class Line 00027 static const std::string CONVERGED_FIT_STATE = "Converged"; 00028 00029 // Create an anonymous namespace 00030 // to make the function invisible from other modules 00031 namespace { 00032 00033 FitState* CreateConvergedFS() { return new FitStateConverged; } 00034 00035 // register block 00036 bool registered = FitStateFactory::Instance().RegisterFitState( 00037 CONVERGED_FIT_STATE, CreateConvergedFS); 00038 } // namespace 00039 00040 00044 const std::string& FitStateConverged::Name() const 00045 { 00046 return CONVERGED_FIT_STATE; 00047 } 00048 00049 00053 void FitStateConverged::Iterate(FitContext& context) const 00054 { 00055 // reset number of iterations 00056 context.fNIterationsStep = 0; 00057 // reset number of diverging iterations 00058 context.fNTriesDiverges = 0; 00059 00060 // save fit parameters as last good fit 00061 FitResult result = context.fMatCalc.GetFitResult(); 00062 context.fLastGoodFit = result; 00063 ++context.fTimesConverged; 00064 00065 if ( context.fConvergenceMaster.NextStep() ) { 00066 if ( ! context.fConvergenceMaster.MaskIsValid() ) { 00067 // apply the next mask 00068 context.fData.SetUHitUse( context.fConvergenceMaster.GetMaskUCur() ); 00069 context.fData.SetVHitUse( context.fConvergenceMaster.GetMaskVCur() ); 00070 context.fConvergenceMaster.SetMaskIsValid(kTRUE); 00071 MSG("FitTrackSA",Msg::kInfo) << "Updated U, V Masks.\n"; 00072 } 00073 context.fDChi2 = ConstFT::InitialDChi2; 00074 context.SetState(FitStateFactory::Instance().GetFitState("Iterating")); 00075 //context.Print(); 00076 MSG("FitTrackSA",Msg::kInfo) << "Switched from Converged to Iterating\n"; 00077 } else { 00078 context.SetState(FitStateFactory::Instance().GetFitState("Final")); 00079 //context.Print(); 00080 MSG("FitTrackSA",Msg::kInfo) << "Switched from Converged to Final\n"; 00081 return; 00082 } 00083 } 00084
1.3.9.1