#include #include #include "AMPTOOLS_DATAIO/ROOTDataReader.h" #include "AMPTOOLS_AMPS/Uniform.h" #include "MinuitInterface/MinuitMinimizationManager.h" #include "IUAmpTools/AmpToolsInterface.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[]) { // set default parameters bool locUseMinosFlag = false; bool locPrintAmplitudesFlag = 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 == "-p") locPrintAmplitudesFlag = true; if(arg == "-h") { cout << endl << " Usage for: " << argv[0] << endl << endl; cout << " -n use MINOS instead of MIGRAD" << endl; cout << " -p Print first 10 events (kinematics, amplitudes, intensities) to screen" << 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 AmpToolsInterface::registerAmplitude(BreitWigner()); AmpToolsInterface::registerAmplitude(HCAmplitude_Chain()); AmpToolsInterface::registerAmplitude(TChannel_Basic()); AmpToolsInterface::registerAmplitude(Uniform()); // Register Data Reader AmpToolsInterface::registerDataReader(ROOTDataReader()); AmpToolsInterface locAmpToolsInterface(cfgInfo); cout << "NEGATIVE LOG-LIKELIHOOD BEFORE MINIMIZATION: " << locAmpToolsInterface.likelihood() << endl; MinuitMinimizationManager* locFitManager = locAmpToolsInterface.minuitMinimizationManager(); locFitManager->setMaxIterations(10000); /************************************** PRINT TO SCREEN ***************************************/ //Print kinematics, amplitudes, and intensities to screen if(locPrintAmplitudesFlag) { unsigned int locNumEventsToPrint = 10; string locReactionName = cfgInfo->reactionList()[0]->reactionName(); DataReader* locDataReader = locAmpToolsInterface.genMCReader(locReactionName); for(unsigned int i = 0; i < locNumEventsToPrint; ++i) { Kinematics* locKinematics = locDataReader->getEvent(); locAmpToolsInterface.printEventDetails(locReactionName, locKinematics); delete locKinematics; } return 0; } /**************************************** PERFORM FIT *****************************************/ // Perform fit if(locUseMinosFlag) locFitManager->minosMinimization(); else locFitManager->migradMinimization(); // Get Fit Status bool 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); return 0; }