コード例 #1
0
//..........................
//To take the current value of a parameter into the instance
void TripleFixedResModel::setParameters( ParameterSet & parameters )
{
	eventResolution = parameters.GetPhysicsParameter( eventResolutionName )->GetValue();
	resScale = parameters.GetPhysicsParameter( resScaleName )->GetValue();
	resScale2 = parameters.GetPhysicsParameter( resScale2Name )->GetValue();
	resScale3 = parameters.GetPhysicsParameter( resScale3Name )->GetValue();
	resFrac2 = parameters.GetPhysicsParameter( timeResFrac2Name )->GetValue();
	resFrac3 = parameters.GetPhysicsParameter( timeResFrac3Name )->GetValue();
	return;
}
コード例 #2
0
ParameterSet* VectoredFeldmanCousins::getParameterSet( ParameterSet* inputSet, ResultParameterSet* inputResult )
{
	// Model 1 nuisence parameters are not changed
	if( nuisenceModel == 0 )
	{
		return new ParameterSet( *inputSet );
	}
	// Model 2 nuisence parameters are varied within 1 sigma of their true value
	else if( nuisenceModel == 1 )
	{
		ParameterSet* tempSet = new ParameterSet( *inputSet );
		vector<string> all_params = tempSet->GetAllNames();
		for( vector<string>::iterator param_i = all_params.begin(); param_i != all_params.end(); ++param_i )
		{
			PhysicsParameter* thisParameter = tempSet->GetPhysicsParameter( *param_i );
			ResultParameter* thisResult = inputResult->GetResultParameter( *param_i );
			if( thisParameter->GetType() != "Fixed" && !thisResult->GetScanStatus() )
			{
				TRandom3* rand_gen = RapidFitRandom::GetRandomFunction();
				double new_value = rand_gen->Gaus( thisResult->GetValue(), thisResult->GetError() );
				thisParameter->SetBlindedValue( new_value );
				thisParameter->SetStepSize( thisResult->GetError() );
			}
		}
		return tempSet;
	}
	else
	{
		cout << endl << "\t\tUNKNOWN NUICENCE MODEL, NOT DOING ANTYTHING!!!!" << endl << endl;
		nuisenceModel = 0;
		return this->getParameterSet( inputSet, inputResult );
	}
}
コード例 #3
0
bool ParameterSet::operator== ( const ParameterSet& input_rhs )
{
	bool names_match=true;
	vector<string> input_names_lhs = this->allNames;
	vector<string> input_names_rhs = input_rhs.allNames;
	//	Simple logical check for all wanted objects
	if( input_names_rhs.size() < input_names_lhs.size() ) return false;

	//	Check to see if wanted objects exist
	for( unsigned int i=0; i< input_names_lhs.size(); ++i )
	{
		//int this_index = StringProcessing::VectorContains( &input_names_rhs, &(input_names_lhs[i]) );
		input_rhs.GetPhysicsParameter( allInternalNames[i] );
		int this_index = allInternalNames[i].GetIndex();
		if( this_index == -1 )
		{
			names_match = false;
			break;
		}
	}

	if( !names_match )
	{
		return false;
	}
	else
	{
		//	Finally if needed compare the numerical values
		bool changed = false;
		for( unsigned int i=0; i< input_names_lhs.size(); ++i )
		{
			double lhs_val = this->GetPhysicsParameter( allInternalNames[i] )->GetValue();
			double rhs_val = input_rhs.GetPhysicsParameter( allForeignNames[i] )->GetValue();
			if( lhs_val != rhs_val )
			{
				changed = true;
				break;
			}
		}
		return !changed;
		//if( !changed ) return true;
		//else return false;
	}
}
コード例 #4
0
//..........................
//To take the current value of a parameter into the instance
void DoubleFixedResModel::setParameters( ParameterSet & parameters )
{
	if( parameters.GetPhysicsParameter( ResolutionScaleName )->isFixed() &&
		parameters.GetPhysicsParameter( Resolution1Name )->isFixed() &&
		parameters.GetPhysicsParameter( Resolution2Name )->isFixed() &&
		parameters.GetPhysicsParameter( Resolution2FractionName )->isFixed() )
	{
		isCacheValid = true;
	}
	else
	{
		isCacheValid = ( ResolutionScale == parameters.GetPhysicsParameter( ResolutionScaleName )->GetValue() );
		isCacheValid = isCacheValid && ( Resolution1 == parameters.GetPhysicsParameter( Resolution1Name )->GetValue() );
		isCacheValid = isCacheValid && ( Resolution2 == parameters.GetPhysicsParameter( Resolution2Name )->GetValue() );
		isCacheValid = isCacheValid && ( Resolution2Fraction == parameters.GetPhysicsParameter( Resolution2FractionName )->GetValue() );
	}
	ResolutionScale = parameters.GetPhysicsParameter( ResolutionScaleName )->GetValue();
	Resolution1 = parameters.GetPhysicsParameter( Resolution1Name )->GetValue();
	Resolution2 = parameters.GetPhysicsParameter( Resolution2Name )->GetValue();
	Resolution2Fraction = parameters.GetPhysicsParameter( Resolution2FractionName )->GetValue();
	return;
}
コード例 #5
0
ファイル: FumiliWrapper.cpp プロジェクト: abmorris/RapidFit
//Use Migrad to minimise the given function
void FumiliWrapper::Minimise()
{
	ParameterSet * newParameters = RapidFunction->GetParameterSet();
	vector<string> allNames = newParameters->GetAllNames();
	//	int numParams = allNames.size();

	/*
	// Fill a vector of doubles for each set of physics parameters that you
	// want to sample. What about case where Apara_sq + Aperp_sq > 1?
	vector< vector<double> > positions;
	PhysicsBottle* bottle = NewFunction->GetPhysicsBottle();
	ParameterSet* parameters = bottle->GetParameterSet();
	vector<string> names = parameters->GetAllNames();
	double nsteps = 1;
	for( int k = 0; k < names.size(); ++k)
	{
	for( int j = 0; j < nsteps; ++j)
	{
	vector<double> tempPos;
	for( int i = 0; i < names.size(); ++i )
	{
	double value;
	if ( i != k )
	{
	value = parameters->GetPhysicsParameter(names[i])->GetValue();
	}
	else
	{
	double min = parameters->GetPhysicsParameter(names[i])->GetMinimum();
	double max = parameters->GetPhysicsParameter(names[i])->GetMaximum();
	double step = (max - min)/nsteps;
	value = min + j * step;
	}
	tempPos.push_back(value);
	}
	positions.push_back(tempPos);
	}
	}
	*/

	// Fill a vector of doubles for each set of observables
	vector< vector<double> > positions;
	PhysicsBottle* bottle = RapidFunction->GetPhysicsBottle();
	PhaseSpaceBoundary* boundary = bottle->GetResultDataSet(0)->GetBoundary();
	vector<string> names = boundary->GetAllNames();

	vector<double> observableSteps;
	int nsteps = 10;

	// Could make this faster...
	for ( int step = 0; step < nsteps; ++step)
	{
		vector<double> tempPos;
		for( unsigned int observable = 0; observable < names.size(); ++observable )
		{
			if ( !boundary->GetConstraint(names[observable])->IsDiscrete() )
			{
				double min = boundary->GetConstraint(names[observable])->GetMinimum();
				double max = boundary->GetConstraint(names[observable])->GetMinimum();
				double delta = (max - min)/nsteps;
				double position = min + step*delta;
				tempPos.push_back( position );
			}
			else
			{
				double value = boundary->GetConstraint(names[observable])->CreateObservable()->GetValue();
				tempPos.push_back( value );
			}
		}
		positions.push_back(tempPos);
	}

	// Now, get the FumiliFCNBase function which will be passed to the Fumili minimiser
	FumiliStandardMaximumLikelihoodFCN fumFCN( *function, positions );

	// Setup the minimiser
	MnFumiliMinimize fumili( fumFCN, *( function->GetMnUserParameters() ), (unsigned)Quality);//MINUIT_QUALITY);

	// Do the minimisation
	FunctionMinimum minimum = fumili( (unsigned)maxSteps, bestTolerance );//(int)MAXIMUM_MINIMISATION_STEPS, FINAL_GRADIENT_TOLERANCE );

	// Once we have the FunctionMinimum, code same as in other Wrappers
	//Create the fit results
	const MnUserParameters * minimisedParameters = &minimum.UserParameters();
	ResultParameterSet * fittedParameters = new ResultParameterSet( allNames );
	for ( unsigned int nameIndex = 0; nameIndex < allNames.size(); ++nameIndex)
	{
		string parameterName = allNames[nameIndex];
		PhysicsParameter * oldParameter = newParameters->GetPhysicsParameter( parameterName );
		double parameterValue = minimisedParameters->Value( parameterName.c_str() );
		double parameterError = minimisedParameters->Error( parameterName.c_str() );

		fittedParameters->SetResultParameter( parameterName, parameterValue, oldParameter->GetOriginalValue(), parameterError,
				-oldParameter->GetMinimum(), oldParameter->GetMaximum(),
				oldParameter->GetType(), oldParameter->GetUnit() );
	}

	int fitStatus;
	if ( !minimum.HasCovariance() )
	{
		fitStatus = 0;
	}
	else if ( !minimum.HasAccurateCovar() )
	{
		fitStatus = 1;
	}
	else if ( minimum.HasMadePosDefCovar() )
	{
		fitStatus = 2;
	}
	else
	{
		fitStatus = 3;
	}

	PhysicsBottle* newBottle = RapidFunction->GetPhysicsBottle();
	fitResult = new FitResult( minimum.Fval(), fittedParameters, fitStatus, newBottle  );
}