#include #include #include #include "AMPTOOLS_DATAIO/ROOTDataReader.h" #include "AMPTOOLS_AMPS/Uniform.h" #include "MinuitInterface/MinuitMinimizationManager.h" #include "IUAmpToolsMPI/AmpToolsInterfaceMPI.h" #include "IUAmpToolsMPI/DataReaderMPI.h" #include "IUAmpTools/FitResults.h" #include "IUAmpTools/ConfigFileParser.h" #include "IUAmpTools/ConfigurationInfo.h" #include "HCA_Amplitudes/HCAmplitude_Chain.h" #include "HCA_Amplitudes/BreitWigner.h" #include "HCA_Amplitudes/TChannel_Basic.h" using namespace std; using namespace CLHEP; int main(int argc, char* argv[]) { //Initialize MPI MPI_Init( &argc, &argv ); int locMPIRank, locMPISize; MPI_Comm_rank( MPI_COMM_WORLD, &locMPIRank ); MPI_Comm_size( MPI_COMM_WORLD, &locMPISize ); // set default parameters bool locUseMinosFlag = 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") locUseMinosFlag = true; if(arg == "-h") { cout << endl << " Usage for: " << argv[0] << endl << endl; cout << " -n use MINOS instead of MIGRAD" << endl; cout << " -c config file" << endl; cout << " -s for seeding next fit based on this fit (optional)" << endl; exit(1); } } if(configfile.empty()) { cout << "No config file specified" << endl; exit(1); } /***************************************** SETUP FIT ******************************************/ // Parse Config File ConfigFileParser parser(configfile); ConfigurationInfo* cfgInfo = parser.getConfigurationInfo(); cfgInfo->display(); // Register Amplitudes AmpToolsInterfaceMPI::registerAmplitude(BreitWigner()); AmpToolsInterfaceMPI::registerAmplitude(HCAmplitude_Chain()); AmpToolsInterfaceMPI::registerAmplitude(TChannel_Basic()); AmpToolsInterfaceMPI::registerAmplitude(Uniform()); // Register Data Reader AmpToolsInterfaceMPI::registerDataReader(DataReaderMPI()); AmpToolsInterfaceMPI locAmpToolsInterface(cfgInfo); /**************************************** PERFORM FIT *****************************************/ bool locFitFailed = false; if(locMPIRank == 0) //Only call on the master node { cout << "NEGATIVE LOG-LIKELIHOOD BEFORE MINIMIZATION: " << locAmpToolsInterface.likelihood() << endl; MinuitMinimizationManager* locFitManager = locAmpToolsInterface.minuitMinimizationManager(); locFitManager->setMaxIterations(10000); // Perform fit if(locUseMinosFlag) locFitManager->minosMinimization(); else locFitManager->migradMinimization(); // Get Fit Status locFitFailed = ((locFitManager->status() != 0) && (locFitManager->eMatrixStatus() != 3)); if(locFitFailed) cout << "ERROR: fit failed use results with caution..." << endl; cout << "NEGATIVE LOG-LIKELIHOOD AFTER MINIMIZATION: " << locAmpToolsInterface.likelihood() << endl; } locAmpToolsInterface.finalizeFit(); if(seedfile.size() != 0 && !locFitFailed) locAmpToolsInterface.fitResults()->writeSeed(seedfile); MPI_Finalize(); return 0; }