#include #include #include #include #include #include #include #include #include "AMPTOOLS_DATAIO/ROOTDataReader.h" #include "AMPTOOLS_AMPS/TwoPSAngles.h" #include "AMPTOOLS_AMPS/ThreePiAngles.h" #include "AMPTOOLS_AMPS/BreitWigner.h" #include "AMPTOOLS_AMPS/b1piAngAmp.h" #include "AMPTOOLS_AMPS/Uniform.h" #include "AMPTOOLS_AMPS/polCoef.h" #include "MinuitInterface/MinuitMinimizationManager.h" #include "IUAmpTools/AmpToolsInterface.h" #include "IUAmpTools/FitResults.h" #include "IUAmpTools/ConfigFileParser.h" #include "IUAmpTools/ConfigurationInfo.h" using std::complex; using namespace std; using namespace CLHEP; int main( int argc, char* argv[] ){ // set default parameters bool useMinos = false; string configfile; string seedfile; // parse command line for (int i = 1; i < argc; i++){ string arg(argv[i]); if (arg == "-c"){ if ((i+1 == argc) || (argv[i+1][0] == '-')) arg = "-h"; else configfile = argv[++i]; } if (arg == "-s"){ if ((i+1 == argc) || (argv[i+1][0] == '-')) arg = "-h"; else seedfile = argv[++i]; } if (arg == "-n") useMinos = true; if (arg == "-h"){ cout << endl << " Usage for: " << argv[0] << endl << endl; cout << " -n \t\t\t\t\t use MINOS instead of MIGRAD" << endl; cout << " -c \t\t\t\t config file" << endl; cout << " -s \t\t\t for seeding next fit based on this fit (optional)" << endl; exit(1);} } if (configfile.size() == 0){ cout << "No config file specified" << endl; exit(1); } ConfigFileParser parser(configfile); ConfigurationInfo* cfgInfo = parser.getConfigurationInfo(); cfgInfo->display(); AmpToolsInterface::registerAmplitude( BreitWigner() ); AmpToolsInterface::registerAmplitude( TwoPSAngles() ); AmpToolsInterface::registerAmplitude( ThreePiAngles() ); AmpToolsInterface::registerAmplitude( b1piAngAmp() ); AmpToolsInterface::registerAmplitude( polCoef() ); AmpToolsInterface::registerAmplitude( Uniform() ); AmpToolsInterface::registerDataReader( ROOTDataReader() ); AmpToolsInterface ati( cfgInfo ); cout << "LIKELIHOOD BEFORE MINIMIZATION: " << ati.likelihood() << endl; MinuitMinimizationManager* fitManager = ati.minuitMinimizationManager(); if( useMinos ){ fitManager->minosMinimization(); } else{ fitManager->migradMinimization(); } bool fitFailed = ( fitManager->status() != 0 && fitManager->eMatrixStatus() != 3 ); if( fitFailed ){ cout << "ERROR: fit failed use results with caution..." << endl; } cout << "LIKELIHOOD AFTER MINIMIZATION: " << ati.likelihood() << endl; ati.finalizeFit(); if( seedfile.size() != 0 && !fitFailed ){ ati.fitResults()->writeSeed( seedfile ); } return 0; }