Example #1
0
if args.mcSig:
    sampleToFit = tnpConf.samplesDef['mcNom']

if args.doFit:
    sampleToFit.dump()
    for ib in range(len(tnpBins['bins'])):
        if (args.binNumber >= 0
                and ib == args.binNumber) or args.binNumber < 0:
            if args.altSig:
                tnpRoot.histFitterAltSig(sampleToFit, tnpBins['bins'][ib],
                                         tnpConf.tnpParAltSigFit)
            elif args.altBkg:
                tnpRoot.histFitterAltBkg(sampleToFit, tnpBins['bins'][ib],
                                         tnpConf.tnpParAltBkgFit)
            else:
                tnpRoot.histFitterNominal(sampleToFit, tnpBins['bins'][ib],
                                          tnpConf.tnpParNomFit)

    args.doPlot = True

####################################################################
##### dumping plots
####################################################################
if args.doPlot:
    fileName = sampleToFit.nominalFit
    fitType = 'nominalFit'
    if args.altSig:
        fileName = sampleToFit.altSigFit
        fitType = 'altSigFit'
    if args.altBkg:
        fileName = sampleToFit.altBkgFit
        fitType = 'altBkgFit'

### change the sample to fit is mc fit
if args.mcSig :
    sampleToFit = tnpConf.samplesDef['mcNom']

if  args.doFit:
    sampleToFit.dump()
    for ib in range(len(tnpBins['bins'])):
        if (args.binNumber >= 0 and ib == args.binNumber) or args.binNumber < 0:
            if args.altSig:                 
                tnpRoot.histFitterAltSig(  sampleToFit, tnpBins['bins'][ib], tnpConf.tnpParAltSigFit )
            elif args.altBkg:
                tnpRoot.histFitterAltBkg(  sampleToFit, tnpBins['bins'][ib], tnpConf.tnpParAltBkgFit )
            else:
                tnpRoot.histFitterNominal( sampleToFit, tnpBins['bins'][ib], tnpConf.tnpParNomFit )

    args.doPlot = True
     
####################################################################
##### dumping plots
####################################################################
if  args.doPlot:
    fileName = sampleToFit.nominalFit
    fitType  = 'nominalFit'
    if args.altSig : 
        fileName = sampleToFit.altSigFit
        fitType  = 'altSigFit'
    if args.altBkg : 
        fileName = sampleToFit.altBkgFit
        fitType  = 'altBkgFit'
Example #3
0
     '.py', '_' + args.flag + '_fitPars.py')
 if not os.path.isfile('etc/config/fitPars/' + (
         tail).replace('.py', '_' + args.flag + '_fitPars.py')):
     print "\n===> Using default fit parameters as given in ", args.settings, "file."
     if args.altSig and not args.addGaus:
         tnpRoot.histFitterAltSig(sampleToFit, tnpBins['bins'][ib],
                                  tnpConf.tnpParAltSigFit)
     elif args.altSig and args.addGaus:
         tnpRoot.histFitterAltSig(sampleToFit, tnpBins['bins'][ib],
                                  tnpConf.tnpParAltSigFit_addGaus,
                                  1)
     elif args.altBkg:
         tnpRoot.histFitterAltBkg(sampleToFit, tnpBins['bins'][ib],
                                  tnpConf.tnpParAltBkgFit)
     else:
         tnpRoot.histFitterNominal(sampleToFit, tnpBins['bins'][ib],
                                   tnpConf.tnpParNomFit)
 else:
     # Add fitPars directory to the path, so that we can import the dictionary
     sys.path.append(os.path.abspath("etc/config/fitPars"))
     # Below line import fit parameter dictionary
     # fit parameters file format should be like: <setting-conf-file>_<flag>_fitPars.py
     importSetting4Fit = 'import %s_%s_fitPars as dynamic_fit_pars' % (
         tail.replace('/', '.').split('.py')[0], args.flag)
     print importSetting4Fit
     exec(importSetting4Fit)
     #import settings_pho_UL2017_fitPars as dynamic_fit_pars
     print "=" * 20, "\t bin number = ", args.binNumber
     if not args.binNumber in dynamic_fit_pars.fitpars_perbin.keys(
     ):
         print "Parameters for bin number ", args.binNumber, " does not exists."
         print "Please check if the file name ", tail + "_fitPars.py exists in directory etc/config/fitPars"