#include #include #include #include using namespace RAT; using namespace RAT::Methods; using namespace std; void FixedSeed::ConvertStringValue( const std::string& value, int& vertex, double& result ) { Tokenizer tokenizer( value ); if( tokenizer.Next() == Tokenizer::TYPE_INTEGER ) vertex = tokenizer.AsInt(); else throw Processor::ParamInvalid( value, "Must be a vertex (int) first." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) result = tokenizer.AsDouble(); else throw Processor::ParamInvalid( value, "Must be a double." ); } void FixedSeed::ConvertStringVector( const std::string& value, int& vertex, TVector3& vector ) { Tokenizer tokenizer( value ); if( tokenizer.Next() == Tokenizer::TYPE_INTEGER ) vertex = tokenizer.AsInt(); else throw Processor::ParamInvalid( value, "Must be a vertex (int) first." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetX( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetY( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetZ( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); } void FixedSeed::ConvertStringVector( const std::string& value, int& vertex, ROOT::Math::XYZVectorF& vector ) { Tokenizer tokenizer( value ); if( tokenizer.Next() == Tokenizer::TYPE_INTEGER ) vertex = tokenizer.AsInt(); else throw Processor::ParamInvalid( value, "Must be a vertex (int) first." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetX( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetY( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); if( tokenizer.Next() == Tokenizer::TYPE_DOUBLE ) vector.SetZ( tokenizer.AsDouble() ); else throw Processor::ParamInvalid( value, "Must be a double." ); } void FixedSeed::SetS( const std::string& name, const std::string& value ) { int vertex = 0; if( name == string( "position" ) ) { TVector3 vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetPosition( vector ); } else if( name == string( "posPositionError" ) ) { ROOT::Math::XYZVectorF vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetPositivePositionError( vector ); } else if( name == string( "negPositionError" ) ) { ROOT::Math::XYZVectorF vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetNegativePositionError( vector ); } else if( name == string( "positionErrors" ) ) { ROOT::Math::XYZVectorF vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetPositionErrors( vector ); } else if( name == string( "direction" ) ) { TVector3 vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetDirection( vector ); } else if( name == string( "posDirectionError" ) ) { TVector3 vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetPositiveDirectionError( vector ); } else if( name == string( "negDirectionError" ) ) { TVector3 vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetNegativeDirectionError( vector ); } else if( name == string( "directionErrors" ) ) { TVector3 vector; ConvertStringVector( value, vertex, vector ); fFitVertices[vertex].SetDirectionErrors( vector ); } else if( name == string( "time" ) ) { double time; ConvertStringValue( value, vertex, time ); fFitVertices[vertex].SetTime( time ); } else if( name == string( "posTimeError" ) ) { double timeError; ConvertStringValue( value, vertex, timeError ); fFitVertices[vertex].SetPositiveTimeError( timeError ); } else if( name == string( "negTimeError" ) ) { double timeError; ConvertStringValue( value, vertex, timeError ); fFitVertices[vertex].SetNegativeTimeError( timeError ); } else if( name == string( "timeErrors" ) ) { double timeError; ConvertStringValue( value, vertex, timeError ); fFitVertices[vertex].SetTimeErrors( timeError ); } else throw Processor::ParamUnknown( name ); } DS::FitResult FixedSeed::GetBestFit() { for( map::iterator iTer = fFitVertices.begin(); iTer != fFitVertices.end(); ++iTer ) fFitResult.SetVertex( iTer->first, iTer->second ); return fFitResult; }