fitResult = pdf.fitTo( fitData, SumW2Error = True if corrSFitErr == 'matrix' else False, Minos = RooMinPars, Save = True
                          , Range = fitRange, **fitOpts )

    # print parameter values
    from P2VV.Imports import parNames, parValues2011 as parValues
    print 'plotProjectionsSixKKbins: parameters:'
    fitResult.PrintSpecial( text = True, LaTeX = True, normal = True, ParNames = parNames, ParValues = parValues )
    fitResult.covarianceMatrix().Print()
    fitResult.correlationMatrix().Print()

    print 120 * '=' + '\n'

if parFileOut :
    # write parameters to file
    pdfConfig.getParametersFromPdf( pdf, fitData )
    pdfConfig.writeParametersToFile( filePath = parFileOut )


###########################################################################################################################################
## make plots ##
################

# import plotting tools
from P2VV.Load import LHCbStyle
from P2VV.Utilities.Plotting import plot, CPcomponentsPlotingToolkit
from ROOT import TCanvas, kRed, kGreen, kMagenta, kBlue, kSolid

#Initialaze the CP components ploting toolkit
CpPlotsKit = CPcomponentsPlotingToolkit(pdf,sigData)
if doFit :
    # fit data
    print 120 * '='
    print 'JvLFit: fitting %d events (%s)' % ( dataSet.numEntries(), 'weighted' if dataSet.isWeighted() else 'not weighted' )

    RooMinPars = [ ]
    if MinosPars :
        print 'JvLFit: running Minos for parameters',
        for parName in MinosPars :
            RooMinPars.append( pdfPars.find(parName) )
            print '"%s"' % RooMinPars[-1],
        print

    fitResult = pdf.fitTo( dataSet, SumW2Error = False
                          , Minos = RooMinPars, Save = True, Range = fitRange
                          , **fitOpts
                         )

    from P2VV.Imports import parNames, parValues
    print 'JvLFit: parameters:'
    fitResult.PrintSpecial( text = True, LaTeX = True, normal = True, ParNames = parNames, ParValues = parValues )
    #fitResult.covarianceMatrix().Print()
    #fitResult.correlationMatrix().Print()

    print 120 * '=' + '\n'

if parFileOut :
    # write parameters to file
    pdfConfig.getParametersFromPdf( pdf, dataSet )
    pdfConfig.writeParametersToFile( filePath = parFileOut )