53 vector< IntensityManager* > intenManVec,
54 map< string, LikelihoodCalculator* > likCalcMap,
55 map< string, NormIntInterface* > normIntMap,
58 m_likelihoodTotal( 0 ),
60 m_intenManVec( intenManVec ),
61 m_likCalcMap( likCalcMap ),
62 m_normIntMap( normIntMap ),
63 m_minManager( minManager ),
64 m_parManager( parManager ),
65 m_createdFromFile( false ),
66 m_warnedAboutFreeParams( false ),
72 m_createdFromFile( true ),
73 m_warnedAboutFreeParams( false ),
81 if( m_createdFromFile ) {
83 for( map< string, NormIntInterface* >::iterator mapItr = m_normIntMap.begin();
84 mapItr != m_normIntMap.end();
87 delete mapItr->second;
95 map< string, double >::const_iterator reac = m_likelihoodMap.find( reaction );
97 if( reac == m_likelihoodMap.end () ){
99 cout <<
"FitResults ERROR: request for likelihood of unknown reaction: " << reaction << endl;
106 pair< double, double >
113 pair< double, double >
117 vector< string > knownAmps =
ampList();
118 for( vector< string >::const_iterator amp = amplitudes.begin();
119 amp != amplitudes.end(); ++amp ){
121 if( find( knownAmps.begin(), knownAmps.end(), *amp ) == knownAmps.end() ){
123 cout <<
"FitResults ERROR: request to compute intensity for unknown amplitude:\n\t" 137 vector< double > deriv( 3 * amplitudes.size() );
138 vector< double > parName( 3 * amplitudes.size() );
147 map< string, double > ampParameters =
ampParMap();
148 for( map< string, double >::iterator par = ampParameters.begin();
149 par != ampParameters.end();
154 int parIndex = m_parIndex.find( par->first )->second;
155 if( fabs( m_covMatrix[parIndex][parIndex] ) > 1E-20 ){
157 if( !m_warnedAboutFreeParams )
160 <<
"***************************************************************" << endl
161 <<
"* WARNING!: You are calculating an intensity that depends on *" << endl
162 <<
"* parameters that were floating in the fit. Unless the par-*" << endl
163 <<
"* ameters are amplitude scale factors only, THE ERROR ON *" << endl
164 <<
"* THE INTENSITY SHOULD BE CONSIDERED UNRELIABLE because the *" << endl
165 <<
"* software is assuming that the derivatives of the normali- *" << endl
166 <<
"* zation integrals with respect to the parameters are equal *" << endl
167 <<
"* to zero. (Fixing this involves numercially computing the *" << endl
168 <<
"* derivatives, which will be implemented in future versions *" << endl
169 <<
"* of AmpTools.) For now it is recommended that you repeat *" << endl
170 <<
"* the fit fixing the free parameter(s) at +- 1 sigma of the *" << endl
171 <<
"* parameter uncertainty to systematically probe how the *" << endl
172 <<
"* uncertainty on the intensity depends on the uncertainty *" << endl
173 <<
"* of the parameter. *" << endl
174 <<
"***************************************************************" << endl
177 m_warnedAboutFreeParams =
true;
185 for( vector< string >::const_iterator amp = amplitudes.begin();
186 amp != amplitudes.end(); ++amp ){
190 vector<string> ampNameParts = stringSplit( *amp,
"::" );
191 assert( ampNameParts.size() == 3 );
192 string reaction = ampNameParts[0];
198 int iRe = 3 * ( amp - amplitudes.begin() );
200 int iScale = iRe + 2;
207 map< string, int >::const_iterator idx1 = m_parIndex.find(
ampScaleName( *amp ) );
208 int IScale = ( idx1 == m_parIndex.end() ? -1 : idx1->second );
210 errorMatrix.push_back( vector< double >( 3 * amplitudes.size() ) );
211 errorMatrix.push_back( vector< double >( 3 * amplitudes.size() ) );
212 errorMatrix.push_back( vector< double >( 3 * amplitudes.size() ) );
218 for( vector< string >::const_iterator conjAmp = amplitudes.begin();
219 conjAmp != amplitudes.end(); ++conjAmp ) {
221 vector<string> conjAmpNameParts = stringSplit( *conjAmp,
"::" );
222 assert( conjAmpNameParts.size() == 3 );
223 string conjReaction = ampNameParts[0];
225 int jRe = 3 * ( conjAmp - amplitudes.begin() );
227 int jScale = jRe + 2;
234 map< string, int >::const_iterator idx2 = m_parIndex.find(
ampScaleName( *conjAmp ) );
235 int JScale = ( idx2 == m_parIndex.end() ? -1 : idx2->second );
241 complex< double > ampInt;
242 if( reaction == conjReaction ){
244 if (accCorrected) ampInt = m_normIntMap.find(reaction)->second->ampInt( *amp, *conjAmp );
245 else ampInt = m_normIntMap.find(reaction)->second->normInt( *amp, *conjAmp );
249 ampInt = complex< double >( 0 , 0 );
254 errorMatrix[iRe][jRe] = m_covMatrix[IRe][JRe];
255 errorMatrix[iRe][jIm] = m_covMatrix[IRe][JIm];
256 errorMatrix[iRe][jScale] =
257 ( JScale == -1 ? 0 : m_covMatrix[IRe][JScale] );
258 errorMatrix[iIm][jRe] = m_covMatrix[IIm][JRe];
259 errorMatrix[iIm][jIm] = m_covMatrix[IIm][JIm];
260 errorMatrix[iIm][jScale] =
261 ( JScale == -1 ? 0 : m_covMatrix[IIm][JScale] );
262 errorMatrix[iScale][jRe] =
263 ( IScale == -1 ? 0 : m_covMatrix[IScale][JRe] );
264 errorMatrix[iScale][jIm] =
265 ( IScale == -1 ? 0 : m_covMatrix[IScale][JIm] );
266 errorMatrix[iScale][jScale] =
267 ( IScale == -1 || JScale == -1 ? 0 : m_covMatrix[IScale][JScale] );
270 ( m_parValues[JRe] * real( ampInt ) + m_parValues[JIm] * imag( ampInt ) );
272 ( m_parValues[JIm] * real( ampInt ) - m_parValues[JRe] * imag( ampInt ) );
275 ( ( m_parValues[IRe] * m_parValues[JRe] + m_parValues[IIm] * m_parValues[JIm] ) * real( ampInt ) -
276 ( m_parValues[IIm] * m_parValues[JRe] - m_parValues[IRe] * m_parValues[JIm] ) * imag( ampInt ) );
278 deriv[iScale] += 2. *
ampScale( *conjAmp ) * (
279 ( m_parValues[IRe] * m_parValues[JRe] + m_parValues[IIm] * m_parValues[JIm]) * real( ampInt ) +
280 ( m_parValues[IRe] * m_parValues[JIm] - m_parValues[IIm] * m_parValues[JRe]) * imag( ampInt ));
282 intensity += intensityContrib;
288 for(
unsigned int i = 0; i < deriv.size(); ++i ){
289 for(
unsigned int j = 0; j < deriv.size(); ++j ){
291 variance += deriv[i] * deriv[j] * errorMatrix[i][j];
295 return pair< double, double >(
intensity,
sqrt( variance ) );
298 pair< double, double >
301 vector< string > knownAmps =
ampList();
302 if( ( find( knownAmps.begin(), knownAmps.end(), amp1 ) == knownAmps.end() ) ||
303 ( find( knownAmps.begin(), knownAmps.end(), amp2 ) == knownAmps.end() ) ){
305 cout <<
"FitResults ERROR: unkown amplitude(s) in phase difference calculation\n\t" 306 << amp1 <<
" and/or " << amp2 << endl;
310 vector<string> ampNameParts = stringSplit( amp1,
"::" );
311 assert( ampNameParts.size() == 3 );
312 string reaction1 = ampNameParts[0];
313 string sum1 = ampNameParts[1];
315 ampNameParts = stringSplit( amp2,
"::" );
316 assert( ampNameParts.size() == 3 );
317 string reaction2 = ampNameParts[0];
318 string sum2 = ampNameParts[1];
320 if( ( reaction1 != reaction2 ) || ( sum1 != sum2 ) ){
322 cout <<
"FitResults WARNING:: request to compute phase difference of " << endl
323 <<
" amplitudes from different sums or different" << endl
324 <<
" reactions which is not meaningful, returning 0. " << endl
325 <<
" amp1: " << amp1 << endl
326 <<
" amp2: " << amp2 << endl;
328 return pair< double, double >( 0, 0 );
334 vector< int > idx( 4 );
341 double a1Re = m_parValues[idx[0]];
342 double a1Im = m_parValues[idx[1]];
343 double a2Re = m_parValues[idx[2]];
344 double a2Im = m_parValues[idx[3]];
346 vector< double > pDeriv( 4 );
347 pDeriv[0] = ( -a1Im / ( a1Re * a1Re + a1Im * a1Im ) );
348 pDeriv[1] = ( a1Re / ( a1Re * a1Re + a1Im * a1Im ) );
349 pDeriv[2] = ( a2Im / ( a2Re * a2Re + a2Im * a2Im ) );
350 pDeriv[3] = ( -a2Re / ( a2Re * a2Re + a2Im * a2Im ) );
353 for(
unsigned int i = 0; i < pDeriv.size(); ++i ){
354 for(
unsigned int j = 0; j < pDeriv.size(); ++j ){
356 pVar += pDeriv[i] * pDeriv[j] * m_covMatrix[idx[i]][idx[j]];
360 return pair< double, double >( arg( complex< double > ( a1Re, a1Im ) ) -
361 arg( complex< double > ( a2Re, a2Im ) ),
368 map< string, NormIntInterface* >::const_iterator nameNormInt =
369 m_normIntMap.find( reactionName );
371 if( nameNormInt == m_normIntMap.end() ){
373 cout <<
"FitResults ERROR: requesting NormIntInterface for reaction " 374 <<
"that does not exist: " << reactionName << endl;
376 cout <<
" Returning a NULL pointer that may result in a segfault." 382 return nameNormInt->second;
388 string parName = amplitude +
"_re";
392 assert( m_parIndex.find( parName ) != m_parIndex.end() );
400 string parName = amplitude +
"_im";
404 assert( m_parIndex.find( parName ) != m_parIndex.end() );
415 vector<string> ampNameParts = stringSplit( amplitude,
"::" );
416 assert( ampNameParts.size() == 3 );
417 string reaction = ampNameParts[0];
419 map< string, int >::const_iterator reactIndexPair = m_reacIndex.find( reaction );
421 if( reactIndexPair == m_reacIndex.end() ){
423 cout <<
"FitResults::ampScaleName ERROR:: no such reaction: " << reaction << endl;
427 map< string, int >::const_iterator ampIndexPair =
428 m_ampIndex.at(reactIndexPair->second).find( amplitude );
430 if( ampIndexPair == m_ampIndex.at(reactIndexPair->second).end() ){
432 cout <<
"FitResults::ampScaleName ERROR:: no such amplitude: " << amplitude << endl;
436 return m_ampScaleNames.at( reactIndexPair->second ).at( ampIndexPair->second );
439 map< string, complex< double > >
442 map< string, complex< double > > ampMap;
444 vector< string > amps =
ampList();
445 for( vector< string >::iterator amp = amps.begin();
455 map< string, double >
458 map< string, double > ampMap;
460 vector< string > amps =
ampList();
461 for( vector< string >::iterator amp = amps.begin();
471 map< string, double >
474 map< string, double > parMap;
476 vector< ParameterInfo* > parList = m_cfgInfo->
parameterList();
478 for( vector< ParameterInfo* >::iterator par = parList.begin();
479 par != parList.end(); ++par ){
481 if( (**par).fixed() )
continue;
483 parMap[(**par).parName()] =
parValue( (**par).parName() );
495 return complex< double >( m_parValues[iRe], m_parValues[iIm] );
508 map< string, int >::const_iterator parIndexPair = m_parIndex.find( parName );
510 if( parIndexPair == m_parIndex.end() ){
512 cout <<
"FitResults:: ERROR: request for unknown parameter " << parName << endl
513 <<
" returning nan." << endl;
518 return m_parValues[parIndexPair->second];
530 map< string, int >::const_iterator par1Pair = m_parIndex.find( par1 );
531 map< string, int >::const_iterator par2Pair = m_parIndex.find( par2 );
533 if( par1Pair == m_parIndex.end() || par2Pair == m_parIndex.end() ){
535 cout <<
"FitResults:: ERROR: request for covaraince of unkown parameters " 536 << par1 <<
", " << par2 << endl
537 <<
" returning nan" << endl;
541 return m_covMatrix[par1Pair->second][par2Pair->second];
549 vector<string> ampNameParts = stringSplit( amplitude,
"::" );
550 assert( ampNameParts.size() == 3 );
551 string reaction = ampNameParts[0];
553 map< string, int >::const_iterator reactIndexPair = m_reacIndex.find( reaction );
555 if( reactIndexPair == m_reacIndex.end() ){
557 cout <<
"FitResults::ampScaleName ERROR:: no such reaction: " << reaction << endl;
561 map< string, int >::const_iterator ampIndexPair =
562 m_ampIndex.at(reactIndexPair->second).find( amplitude );
564 if( ampIndexPair == m_ampIndex.at(reactIndexPair->second).end() ){
566 cout <<
"FitResults::ampScaleName ERROR:: no such amplitude: " << amplitude << endl;
570 return m_ampScaleValues.at( reactIndexPair->second ).at( ampIndexPair->second );
576 vector< string > list;
578 for( vector< string >::const_iterator reacItr = m_reactionNames.begin();
579 reacItr != m_reactionNames.end();
582 vector< string > thisReacList =
ampList( *reacItr );
584 for( vector< string >::iterator ampItr = thisReacList.begin();
585 ampItr != thisReacList.end();
588 list.push_back( *ampItr );
598 map< string, int >::const_iterator reacIndex = m_reacIndex.find( reaction );
600 if( reacIndex == m_reacIndex.end() ){
602 cerr <<
"FitResults ERROR:: unkown reaction: " << reaction << endl;
606 return m_ampNames[reacIndex->second];
612 if( !m_createdFromFile ){
624 ofstream output( outFile.c_str() );
626 output.precision( 15 );
628 output <<
"*** DO NOT EDIT THIS FILE - IT IS FORMATTED FOR INPUT ***" << endl;
629 output <<
"+++ Reactions, Amplitudes, and Scale Parameters +++" << endl;
630 output <<
" " << m_numReactions << endl;
631 for(
int i = 0; i < m_numReactions; ++i ){
633 output <<
" " <<m_reactionNames[i] <<
"\t" << m_numAmps[i] << endl;
635 for(
int j = 0; j < m_ampNames[i].size(); ++j ) {
637 output <<
" " <<m_ampNames[i][j] <<
"\t" 638 << m_ampScaleNames[i][j] <<
"\t" 639 << m_ampScaleValues[i][j] << endl;
643 output <<
"+++ Likelihood Total and Partial Sums +++" << endl;
644 output <<
" " <<m_likelihoodTotal << endl;
645 for(
int i = 0; i < m_numReactions; ++i ){
647 output <<
" " <<m_reactionNames[i] <<
"\t" 648 << m_likelihoodMap.find(m_reactionNames[i])->second << endl;
651 output <<
"+++ Fitter Information +++" << endl;
652 output <<
" " <<
"lastMinuitCommand\t" << m_lastCommand << endl;
653 output <<
" " <<
"lastMinuitCommandStatus\t" << m_lastCommandStatus << endl;
654 output <<
" " <<
"eMatrixStatus\t" << m_eMatrixStatus << endl;
655 output <<
" " <<
"minuitPrecision\t" << m_precision << endl;
656 output <<
" " <<
"minuitStrategy\t" << m_strategy << endl;
657 output <<
" " <<
"estDistToMinimum\t" << m_estDistToMin << endl;
658 output <<
" " <<
"bestMinimum\t" << m_bestMin << endl;
660 output <<
"+++ Parameter Values and Errors +++" << endl;
661 output <<
" " << m_parNames.size() << endl;
662 for(
int i = 0; i < m_parNames.size(); ++i ){
664 output <<
" " <<m_parNames[i] <<
"\t" << m_parValues[i] << endl;
667 for(
int i = 0; i < m_parNames.size(); ++i ){
668 for(
int j = 0; j < m_parNames.size(); ++j ){
670 output <<
" " << m_covMatrix[i][j] <<
"\t";
679 output <<
"+++ Normalization Integrals +++" << endl;
681 for(
int i = 0; i < m_reactionNames.size(); ++i ){
683 string reac = m_reactionNames[i];
684 output <<
" " << reac << endl;
695 m_intenManVec[i]->termsAreRenormalized() );
699 output <<
"+++ Below these two lines is a config file that is +++" << endl;
700 output <<
"+++ functionally equivalent to that used in the fit. +++" << endl;
701 output << *m_cfgInfo;
709 ofstream output( outFile.c_str() );
710 output.precision( 15 );
712 vector< string > amps =
ampList();
713 for( vector< string >::const_iterator amp = amps.begin();
717 vector<string> parts = stringSplit( *amp,
"::" );
718 assert( parts.size() == 3 );
720 m_cfgInfo->
amplitude( parts[0], parts[1], parts[2] );
722 output <<
"initialize " << *amp <<
" cartesian " 726 if( ampInfo->fixed() )
729 if( ampInfo->real() )
735 map< string, double > ampPars =
ampParMap();
736 for( map< string, double >::const_iterator par = ampPars.begin();
737 par != ampPars.end();
740 output <<
"parameter " << par->first <<
" " << par->second;
744 if( parInfo->
fixed() )
748 output <<
" bounded " << parInfo->
lowerBound()
760 enum { kMaxLine = 256 };
764 ifstream input( inFile.c_str() );
768 cerr <<
"ERROR:: FitResults file does not exist: " << inFile << endl;
772 input.getline( line, kMaxLine );
773 input.getline( line, kMaxLine );
775 input >> m_numReactions;
777 m_reactionNames.resize( m_numReactions );
778 m_numAmps.resize( m_numReactions );
779 m_ampNames.resize( m_numReactions );
780 m_ampScaleNames.resize( m_numReactions );
781 m_ampScaleValues.resize( m_numReactions );
782 m_ampIndex.resize( m_numReactions );
784 for(
int i = 0; i < m_numReactions; ++i ){
786 input >> m_reactionNames[i] >> m_numAmps[i];
788 m_reacIndex[m_reactionNames[i]] = i;
790 m_ampNames[i].resize( m_numAmps[i] );
791 m_ampScaleNames[i].resize( m_numAmps[i] );
792 m_ampScaleValues[i].resize( m_numAmps[i] );
794 for(
int j = 0; j < m_ampNames[i].size(); ++j ) {
796 input >> m_ampNames[i][j]
797 >> m_ampScaleNames[i][j]
798 >> m_ampScaleValues[i][j];
800 m_ampIndex[i][m_ampNames[i][j]] = j;
805 input.getline( line, kMaxLine );
806 input.getline( line, kMaxLine );
808 input >> m_likelihoodTotal;
811 for(
int i = 0; i < m_numReactions; ++i ){
814 m_likelihoodMap[tmp] = val;
817 input.getline( line, kMaxLine );
818 input.getline( line, kMaxLine );
820 input >> tmp >> m_lastCommand;
821 input >> tmp >> m_lastCommandStatus;
822 input >> tmp >> m_eMatrixStatus;
823 input >> tmp >> m_precision;
824 input >> tmp >> m_strategy;
825 input >> tmp >> m_estDistToMin;
826 input >> tmp >> m_bestMin;
828 input.getline( line, kMaxLine );
829 input.getline( line, kMaxLine );
833 m_parNames.resize( nPar );
834 m_parValues.resize( nPar );
835 m_covMatrix.resize( nPar );
837 for(
int i = 0; i < m_parNames.size(); ++i ){
839 input >> m_parNames[i] >> m_parValues[i];
840 m_parIndex[m_parNames[i]] = i;
843 for(
int i = 0; i < m_parNames.size(); ++i ){
845 m_covMatrix[i].resize( nPar );
846 for(
int j = 0; j < m_parNames.size(); ++j ){
848 input >> m_covMatrix[i][j];
855 input.getline( line, kMaxLine );
856 input.getline( line, kMaxLine );
858 for(
int i = 0; i < m_numReactions; ++i ){
863 input >> (*m_normIntMap[reac]);
867 input.getline( line, kMaxLine );
868 input.getline( line, kMaxLine );
869 input.getline( line, kMaxLine );
883 FitResults::recordAmpSetup(){
885 m_numReactions = m_intenManVec.size();
888 m_reactionNames.clear();
890 m_ampScaleNames.clear();
891 m_ampScaleValues.clear();
896 for(
int i = 0; i < m_intenManVec.size(); ++i ){
905 m_ampNames.push_back( ampNames );
906 m_ampIndex.push_back( map< string, int >() );
907 m_numAmps.push_back( ampNames.size() );
909 vector< string > ampScaleNames( 0 );
910 vector< double > ampScaleValues( 0 );
912 for(
int j = 0; j < ampNames.size(); ++j ){
914 ampScaleNames.push_back( intenMan->
getScale( ampNames[j] ).
name() );
915 ampScaleValues.push_back( intenMan->
getScale( ampNames[j] ) );
917 m_ampIndex[i][ampNames[j]] = j;
920 m_ampScaleNames.push_back( ampScaleNames );
921 m_ampScaleValues.push_back( ampScaleValues );
926 FitResults::recordLikelihood(){
928 m_likelihoodTotal = 0;
930 for( map< string, LikelihoodCalculator* >::iterator
931 mapItr = m_likCalcMap.begin();
932 mapItr != m_likCalcMap.end();
935 double thisLikVal = (*(mapItr->second))();
937 m_likelihoodTotal += thisLikVal;
938 m_likelihoodMap[mapItr->first] = thisLikVal;
943 FitResults::recordParameters(){
949 for(
int i = 0; i < m_parNames.size(); ++i ){
951 m_parIndex[m_parNames[i]] = i;
957 FitResults::recordFitStats(){
960 m_lastCommandStatus = m_minManager->
status();
963 m_strategy = m_minManager->
strategy();
975 vector< ReactionInfo* > reactionInfo = m_cfgInfo->
reactionList();
976 for( vector< ReactionInfo* >::const_iterator reactionInfoItr = reactionInfo.begin(); reactionInfoItr != reactionInfo.end(); ++reactionInfoItr ){
978 reactionName = (**reactionInfoItr).reactionName();
981 vector< string > sumNames;
982 vector< CoherentSumInfo* > sumInfo = m_cfgInfo->
coherentSumList( reactionName );
983 for( vector< CoherentSumInfo* >::const_iterator sumInfoItr = sumInfo.begin(); sumInfoItr != sumInfo.end(); ++sumInfoItr ){
984 sumNames.push_back( (**sumInfoItr).sumName() );
988 vector< string > allAmpNames;
989 vector< AmplitudeInfo* > ampInfoEachSum;
990 for(
unsigned int sum = 0; sum < sumNames.size(); sum++ ){
991 ampInfoEachSum = m_cfgInfo->
amplitudeList( reactionName, sumNames[sum] );
992 for( vector< AmplitudeInfo* >::const_iterator ampInfoItr = ampInfoEachSum.begin(); ampInfoItr != ampInfoEachSum.end(); ++ampInfoItr ){
993 allAmpNames.push_back( (**ampInfoItr).fullName() );
998 for(
unsigned int sum = 0; sum < sumNames.size(); sum++ ){
1001 bool rotate =
false;
1002 bool foundRealAmp =
false;
1003 bool reflect =
false;
1004 double totalIm = 0.0;
1007 vector< string > ampNames;
1008 vector< AmplitudeInfo* > ampInfo = m_cfgInfo->
amplitudeList( reactionName, sumNames[sum] );
1009 for( vector< AmplitudeInfo* >::const_iterator ampInfoItr = ampInfo.begin(); ampInfoItr != ampInfo.end(); ++ampInfoItr ){
1011 ampNames.push_back( (**ampInfoItr).fullName() );
1016 int reIndex = m_parIndex.find( reParName )->second;
1017 int imIndex = m_parIndex.find( imParName )->second;
1028 scIndex = m_parIndex.find(
ampScaleName( ampNames[ampNames.size()-1] ))->second;
1029 scale = m_parValues[scIndex];
1033 if( (**ampInfoItr).real() ==
true && foundRealAmp == false ){
1034 foundRealAmp =
true;
1035 if( m_parValues[reIndex] * scale < 0 )
1041 if( foundRealAmp ==
false ){
1042 const vector< AmplitudeInfo* > constraints = (**ampInfoItr).constraints();
1043 for( vector< AmplitudeInfo* >::const_iterator conInfoItr = constraints.begin(); conInfoItr != constraints.end(); ++conInfoItr ){
1044 if( (**conInfoItr).real() ==
true && foundRealAmp == false ){
1045 foundRealAmp =
true;
1046 if( m_parValues[reIndex] * scale < 0 )
1052 totalIm += scale * m_parValues[imIndex];
1056 if( totalIm < 0 ) reflect =
true;
1059 if( rotate ==
false && reflect ==
false )
continue;
1062 for(
unsigned int amp = 0; amp < ampNames.size(); amp++ ){
1067 int reIndex = m_parIndex.find( reParName )->second;
1068 int imIndex = m_parIndex.find( imParName )->second;
1070 if( rotate ==
true )
1071 m_parValues[reIndex] *= -1.0;
1073 if( reflect ==
true && m_parValues[imIndex] != 0.0 )
1074 m_parValues[imIndex] *= -1.0;
1079 vector<string> ampNameParts = stringSplit( ampNames[amp],
"::" );
1080 string sumAmp = ampNameParts[1];
1083 for(
unsigned int conjAmp = 0; conjAmp < allAmpNames.size(); conjAmp++ ){
1086 int imConjIndex = m_parIndex.find( imConjParName )->second;
1088 string scConjParName =
ampScaleName( allAmpNames[conjAmp] );
1089 int scConjIndex = -1;
1090 if(scConjParName !=
"-") scConjIndex = m_parIndex.find( scConjParName )->second;
1092 if( rotate ==
true ){
1093 m_covMatrix[reIndex][imConjIndex] *= -1.0;
1094 m_covMatrix[imConjIndex][reIndex] *= -1.0;
1103 if(scConjIndex!=-1){
1105 vector<string> conjAmpNameParts = stringSplit( allAmpNames[conjAmp],
"::" );
1106 string sumConjAmp = conjAmpNameParts[1];
1107 cout <<
"sum name of conjAmp = " << sumConjAmp << endl;
1108 if(sumAmp == sumConjAmp){
1110 m_covMatrix[reIndex][scConjIndex] *= -1.0;
1111 m_covMatrix[scConjIndex][reIndex] *= -1.0;
1118 int reConjIndex = m_parIndex.find( reConjParName )->second;
1120 if( reflect ==
true ){
1121 m_covMatrix[imIndex][reConjIndex] *= -1.0;
1122 m_covMatrix[reConjIndex][imIndex] *= -1.0;
1131 if(scConjIndex!=-1){
1133 vector<string> conjAmpNameParts = stringSplit( allAmpNames[conjAmp],
"::" );
1134 string sumConjAmp = conjAmpNameParts[1];
1135 if(sumAmp == sumConjAmp){
1136 m_covMatrix[imIndex][scConjIndex] *= -1.0;
1137 m_covMatrix[scConjIndex][imIndex] *= -1.0;
1151 ofstream output( outFile.c_str() );
1153 output << m_numAmps[0]/4. <<
"\t0" << endl;
1155 for(
unsigned int i = 0; i < m_parNames.size()-1; i++ ){
1156 const char* reactName = m_parNames[i].substr( 8, 4 ).c_str();
1157 if( strcmp( reactName,
"amp1" ) != 0 )
continue;
1158 const char* lastChars = m_parNames[i].substr( m_parNames[i].size() - 2, 2 ).c_str();
1159 if( strcmp( lastChars,
"im" ) == 0 ){
1160 output << m_parNames[i].substr( 0, m_parNames[i].size() - 3 );
1161 if( m_parValues[i] == 0 && m_covMatrix[i][i] == 0 ) output <<
"+";
1162 output <<
"\t(" << m_parValues[i-1] <<
"," << m_parValues[i] <<
")" << endl;
1166 for(
unsigned int i = 0; i < m_parNames.size()-1; i++ ){
1167 const char* reactNamei = m_parNames[i].substr( 8, 4 ).c_str();
1168 if( strcmp( reactNamei,
"amp1" ) != 0 )
continue;
1169 const char* lastCharsi = m_parNames[i].substr( m_parNames[i].size() - 2, 2 ).c_str();
1170 if( strcmp( lastCharsi,
"im" ) == 0 && m_parValues[i] == 0 && m_covMatrix[i][i] == 0 )
continue;
1171 for(
unsigned int j = 0; j < m_parNames.size()-1; j++ ){
1172 const char* reactNamej = m_parNames[j].substr( 8, 4 ).c_str();
1173 if( strcmp( reactNamej,
"amp1" ) == 0 ){
1174 const char* lastCharsj = m_parNames[j].substr( m_parNames[j].size() - 2, 2 ).c_str();
1175 if( strcmp( lastCharsj,
"im" ) == 0 && m_parValues[j] == 0 && m_covMatrix[j][j] == 0 )
continue;
1176 output << m_covMatrix[i][j] <<
"\t";
1186 FitResults::stringSplit(
const string& str,
const string& delimiters )
const 1189 vector< string > tokens;
1191 string::size_type lastPos = str.find_first_not_of(delimiters, 0);
1192 string::size_type pos = str.find_first_of(delimiters, lastPos);
1194 while (string::npos != pos || string::npos != lastPos)
1196 tokens.push_back(str.substr(lastPos, pos - lastPos));
1197 lastPos = str.find_first_not_of(delimiters, pos);
1198 pos = str.find_first_of(delimiters, lastPos);
complex< double > productionParameter(const string &Name) const
ConfigurationInfo * getConfigurationInfo()
string reactionName() const
vector< CoherentSumInfo * > coherentSumList(const string &reactionName="", const string &sumName="") const
void exportNormIntCache(const string &fileName, bool renormalize=false) const
void writeSeed(const string &fileName) const
double gaussianError() const
double covariance(const string &par1, const string &par2) const
bool gaussianBounded() const
vector< vector< double > > covarianceMatrix() const
ParameterInfo * parameter(const string &parName) const
complex< double > scaledProductionParameter(const string &Name) const
double ampScale(const string &Name) const
double parValue(const string &parName) const
double estDistToMinimum() const
double upperBound() const
void writeResults(const string &fileName) const
virtual void forceCacheUpdate(bool normIntOnly=false) const
const NormIntInterface * normInt(const string &reactionName) const
vector< double > parameterValues() const
void loadResults(const string &fileName)
pair< double, double > phaseDiff(const string &1, const string &2) const
const vector< string > & getTermNames() const
map< string, complex< double > > ampProdParMap() const
double parError(const string &parName) const
bool hasAccessToMC() const
AmplitudeInfo * amplitude(const string &reactionName, const string &sumName, const string &Name) const
double likelihood() const
pair< double, double > intensity(bool accCorrected=true) const
map< string, double > ampScaleParMap() const
const AmpParameter & getScale(const string &name) const
const vector< vector< double > > & errorMatrix() const
void writeFitResults(const string &fileName)
double lowerBound() const
string realProdParName(const string &litude) const
vector< ParameterInfo * > parameterList(const string &reactionName="", const string &sumName="", const string &Name="", const string &parName="") const
string ampScaleName(const string &litude) const
vector< AmplitudeInfo * > amplitudeList(const string &reactionName="", const string &sumName="", const string &Name="") const
map< string, double > ampParMap() const
vector< string > ampList() const
double centralValue() const
double bestMinimum() const
vector< ReactionInfo * > reactionList(const string &reactionName="") const
vector< string > parameterList() const
int eMatrixStatus() const
string imagProdParName(const string &litude) const