def func_altEffi(args): """ Typically less than 1% """ setupFinalAltEffiFitter = deepcopy(fitCollection.setupFinalFitter) setupFinalAltEffiFitter.update({ 'argAliasInDB': {'afb': 'afb_altEffi', 'fl': 'fl_altEffi', 'fs': 'fs_altEffi', 'as': 'as_altEffi'}, 'saveToDB': False, }) finalAltEffiFitter = StdFitter(setupFinalAltEffiFitter) def _preFitSteps_altEffi(self): StdFitter._preFitSteps(self) hasXTerm = self.args.find("hasXTerm") hasXTerm.setVal(0) finalAltEffiFitter._preFitSteps = types.MethodType(_preFitSteps_altEffi, finalAltEffiFitter) p.setSequence([ pdfCollection.stdWspaceReader, dataCollection.dataReader, finalAltEffiFitter, ]) try: p.beginSeq() p.runSeq() updateToDB_altShape(args, "altEffi") finally: p.endSeq()
def func_altSP(args): """ Set fs to 5% instead of 0% """ setupFinalAltSPFitter = deepcopy(fitCollection.setupFinalFitter) setupFinalAltSPFitter.update({ 'argAliasInDB': {'afb': 'afb_altSP', 'fl': 'fl_altSP', 'fs': 'fs_altSP', 'as': 'as_altSP'}, 'saveToDB': False, }) finalAltSPFitter = StdFitter(setupFinalAltSPFitter) def _preFitSteps_vetoSmallFs_altSP(self): """ fs is usually negligible, set the alternative fraction to 0.05 """ if "fs" in self.cfg.get('argPattern'): fs = self.args.find("fs") transAs = self.args.find("transAs") fs.setVal(0.05) fs.setConstant(True) transAs.setVal(0) transAs.setConstant(False) finalAltSPFitter._preFitSteps_vetoSmallFs = types.MethodType(_preFitSteps_vetoSmallFs_altSP, finalAltSPFitter) p.setSequence([ pdfCollection.stdWspaceReader, dataCollection.dataReader, finalAltSPFitter, ]) try: p.beginSeq() p.runSeq() updateToDB_altShape(args, "altSP") finally: p.endSeq()
def func_altSigM(args): """ Not used """ setupFinalAltSigMFitter = deepcopy(fitCollection.setupFinalFitter) setupFinalAltSigMFitter.update({ 'argAliasInDB': {'afb': 'afb_altSigM', 'fl': 'fl_altSigM', 'fs': 'fs_altSigM', 'as': 'as_altSigM'}, 'saveToDB': False, }) finalAltSigMFitter = StdFitter(setupFinalAltSigMFitter) def _preFitSteps_altSigM(self): StdFitter._preFitSteps(self) sigM_frac = self.args.find("sigM_frac") sigM_frac.setVal(0) finalAltSigMFitter._preFitSteps = types.MethodType(_preFitSteps_altSigM, finalAltSigMFitter) p.setSequence([ pdfCollection.stdWspaceReader, dataCollection.dataReader, finalAltSigMFitter, ]) try: p.beginSeq() p.runSeq() updateToDB_altShape(args, "altSigM") finally: p.endSeq()
def func_vetoJpsiX(args): """ Remvoe LSB from Fit region """ dataReaderCfg = deepcopy(dataCollection.dataReaderCfg) dataReaderCfg.update({ 'preloadFile': None }) dataReader = DataReader(dataReaderCfg) dataReader.customize = types.MethodType( functools.partial(dataCollection.customizeOne, targetBMassRegion=['altFit_vetoJpsiX'], extraCuts=cut_kshortWindow), dataReader ) fitterCfg = deepcopy(fitCollection.setupFinalFitter) fitterCfg.update({ 'data': "dataReader.altFit_vetoJpsiX", 'saveToDB': False }) fitter = StdFitter(fitterCfg) p.setSequence([ pdfCollection.stdWspaceReader, dataReader, fitter, ]) try: p.beginSeq() p.runSeq() updateToDB_altShape(args, "vetoJpsiX") finally: p.endSeq()
def func_altBkgCombM(args): """ Not used """ setupFinalAltBkgCombMFitter = deepcopy(fitCollection.setupFinalFitter) setupFinalAltBkgCombMFitter.update({ 'pdf': "f_finalAltBkgCombM", 'argAliasInDB': {'afb': 'afb_altBkgCombM', 'fl': 'fl_altBkgCombM', 'fs': 'fs_altBkgCombM', 'as': 'as_altBkgCombM'}, 'saveToDB': False, }) finalAltBkgCombMFitter = StdFitter(setupFinalAltBkgCombMFitter) p.setSequence([ pdfCollection.stdWspaceReader, dataCollection.dataReader, finalAltBkgCombMFitter, ]) try: p.beginSeq() p.runSeq() updateToDB_altShape(args, "altBkgCombM") finally: p.endSeq()
def func_randEffi(args): """ Typically less than 5% """ setupFinalRandEffiFitter = deepcopy(fitCollection.setupFinalFitter) setupFinalRandEffiFitter.update({ 'FitMinos': [False, ()], 'argAliasInDB': {'afb': 'afb_randEffi', 'fl': 'fl_randEffi', 'fs': 'fs_randEffi', 'as': 'as_randEffi'}, 'saveToDB': False, }) finalRandEffiFitter = StdFitter(setupFinalRandEffiFitter) def preFitSteps_randEffi(self): self.args = self.pdf.getParameters(self.data) self._preFitSteps_initFromDB() # Fluctuate cross-term correction effiArgs = ROOT.RooArgSet() FitterCore.ArgLooper(self.args, lambda iArg: effiArgs.add(iArg), targetArgs=[r"x\d{1,2}"]) FitDBPlayer.fluctuateFromDB(self.process.dbplayer.odbfile, effiArgs, self.cfg['argAliasInDB']) self._preFitSteps_vetoSmallFs() self._preFitSteps_preFit() finalRandEffiFitter._preFitSteps = types.MethodType(preFitSteps_randEffi, finalRandEffiFitter) foutName = "syst_randEffi_{0}.root".format(q2bins[args.binKey]['label']) class effiStudier(AbsToyStudier): def _preSetsLoop(self): self.hist_afb = ROOT.TH1F("hist_afb", "", 300, -0.75, 0.75) self.hist_afb.GetXaxis().SetTitle("A_{{FB}}") self.hist_fl = ROOT.TH1F("hist_fl", "", 200, 0., 1.) self.hist_fl.GetXaxis().SetTitle("F_{{L}}") def _preRunFitSteps(self, setIndex): pass def _postRunFitSteps(self, setIndex): if self.fitter.fitResult["{0}.migrad".format(self.fitter.name)]['status'] == 0: afb = self.process.sourcemanager.get('afb') fl = self.process.sourcemanager.get('fl') self.hist_afb.Fill(afb.getVal()) self.hist_fl.Fill(fl.getVal()) def _postSetsLoop(self): fout = ROOT.TFile(foutName, "RECREATE") fout.cd() self.hist_afb.Write() self.hist_fl.Write() fout.Close() def getSubDataEntries(self, setIndex): return 1 def getSubData(self): while True: yield self.data setupStudier = deepcopy(effiStudier.templateConfig()) setupStudier.update({ 'name': "effiStudier", 'data': "dataReader.Fit", 'fitter': finalRandEffiFitter, 'nSetOfToys': 200, }) studier = effiStudier(setupStudier) p.setSequence([ pdfCollection.stdWspaceReader, dataCollection.dataReader, studier, ]) try: p.beginSeq() if os.path.exists("{0}".format(foutName)): print("{0} exists, skip fitting procedure".format(foutName)) else: p.runSeq() fin = ROOT.TFile("{0}".format(foutName)) hist_fl = fin.Get("hist_fl") gaus_fl = ROOT.TF1("gaus_fl", "gaus(0)", 0, 1) hist_fl.Fit(gaus_fl, "WI") hist_afb = fin.Get("hist_afb") gaus_afb = ROOT.TF1("gaus_afb", "gaus(0)", -0.75, 0.75) hist_afb.Fit(gaus_afb, "WI") syst_randEffi = { 'syst_randEffi_fl': { 'getError': gaus_fl.GetParameter(2), 'getErrorHi': gaus_fl.GetParameter(2), 'getErrorLo': -gaus_fl.GetParameter(2), }, 'syst_randEffi_afb': { 'getError': gaus_afb.GetParameter(2), 'getErrorHi': gaus_afb.GetParameter(2), 'getErrorLo': -gaus_afb.GetParameter(2), } } print(syst_randEffi) if args.updatePlot: canvas = Plotter.canvas.cd() hist_afb.Draw("HIST") Plotter.latexCMSMark() Plotter.latexCMSExtra() Plotter.latexCMSSim() canvas.Print("syst_randEffi_afb_{0}.pdf".format(q2bins[args.binKey]['label'])) hist_fl.GetXaxis().SetTitle("F_{{L}}") hist_fl.Draw("HIST") Plotter.latexCMSMark() Plotter.latexCMSExtra() Plotter.latexCMSSim() canvas.Print("syst_randEffi_fl_{0}.pdf".format(q2bins[args.binKey]['label'])) if args.updateDB: FitDBPlayer.UpdateToDB(p.dbplayer.odbfile, syst_randEffi) finally: p.endSeq()
def _preFitSteps_altSigM(self): StdFitter._preFitSteps(self) sigM_frac = self.args.find("sigM_frac") sigM_frac.setVal(0)
def _preFitSteps_altEffi(self): StdFitter._preFitSteps(self) hasXTerm = self.args.find("hasXTerm") hasXTerm.setVal(0)
def GetFitterObjects(self, seq): Year = self.cfg['args'].Year AltRange = self.cfg['args'].AltRange binKey = self.cfg['binKey'] TwoStep = self.cfg['args'].TwoStep if seq == 'effiFitter': setupEffiFitter = deepcopy(EfficiencyFitter.templateConfig()) setupEffiFitter.update({ 'name': "effiFitter.{0}".format(Year), 'label': '_ts' if TwoStep else '', 'datahist': "effiHistReader.h2_accXrec.{0}".format(Year), # 2D Histogram 'data': "effiHistReader.accXrec.{0}".format(Year), # 2D RooDataHist 'dataX': "effiHistReader.h_accXrec_fine_ProjectionX.{0}".format( Year), # TH1D CosThetaL 'dataY': "effiHistReader.h_accXrec_fine_ProjectionY.{0}".format( Year), # TH1D CosThetaK 'pdf': "effi_sigA{}.{}".format('_ts' if TwoStep else '', Year), 'pdfX': "effi_cosl{}.{}".format('_ts' if TwoStep else '', Year), 'pdfY': "effi_cosK{}.{}".format('_ts' if TwoStep else '', Year), }) effiFitter = EfficiencyFitter(setupEffiFitter) return effiFitter if seq is 'accEffiFitter': setupEffiFitter = deepcopy(EfficiencyFitter.templateConfig()) setupEffiFitter.update({ 'name': "accEffiFitter.{0}".format(Year), 'label': "_acc", 'datahist': "effiHistReader.hist2_acc.{0}".format(Year) if (binKey == "belowJpsiA" or (binKey == "belowJpsiB" and Year == 2018)) else "effiHistReader.hist2_acc_fine.{0}".format(Year), # 2D Histogram 'data': "effiHistReader.acc.{0}".format(Year) if (binKey == "belowJpsiA" or (binKey == "belowJpsiB" and Year == 2018)) else "effiHistReader.acc_fine.{0}".format(Year), # 2D RooDataHist 'dataX': "effiHistReader.h_acc_fine_ProjectionX.{0}".format( Year), # TH1D CosThetaL 'dataY': "effiHistReader.h_acc_fine_ProjectionY.{0}".format( Year), # TH1D CosThetaK 'pdf': "effi_sigA_acc.{0}".format(Year), 'pdfX': "effi_cosl_acc.{0}".format(Year), 'pdfY': "effi_cosK_acc.{0}".format(Year), }) return EfficiencyFitter(setupEffiFitter) if seq is 'recEffiFitter': setupEffiFitter = deepcopy(EfficiencyFitter.templateConfig()) setupEffiFitter.update({ 'name': "recEffiFitter.{0}".format(Year), 'label': "_rec", 'datahist': "effiHistReader.hist2_rec.{0}".format(Year) if binKey == "belowJpsiA" else "effiHistReader.hist2_rec_fine.{0}".format(Year), # 2D Histogram 'data': "effiHistReader.rec.{0}".format(Year) if binKey == "belowJpsiA" else "effiHistReader.rec_fine.{0}".format(Year), # 2D RooDataHist 'dataX': "effiHistReader.h_rec_fine_ProjectionX.{0}".format( Year), # TH1D CosThetaL 'dataY': "effiHistReader.h_rec_fine_ProjectionY.{0}".format( Year), # TH1D CosThetaK 'pdf': "effi_sigA_rec.{0}".format(Year), 'pdfX': "effi_cosl_rec.{0}".format(Year), 'pdfY': "effi_cosK_rec.{0}".format(Year), }) return EfficiencyFitter(setupEffiFitter) if seq == 'sig2DFitter': setupSig2DFitter = deepcopy(setupTemplateFitter) setupSig2DFitter.update({ 'name': "sig2DFitter.{0}".format(Year), 'data': "sigMCReader.{0}.{1}".format(Year, "altFit" if AltRange else "Fit"), 'pdf': "f_sig2D{}.{}".format('_ts' if TwoStep else '', Year), 'FitHesse': True, 'FitMinos': [True, ()], 'argPattern': ['unboundAfb', 'unboundFl'], 'createNLLOpt': [], 'argAliasInDB': ArgAliasRECO_Alt if AltRange else ArgAliasRECO, }) return StdFitter(setupSig2DFitter) if seq == 'sig3DFitter': setupSig3DFitter = deepcopy(setupTemplateFitter) setupSig3DFitter.update({ 'name': "sig3DFitter.{0}".format(Year), 'data': "sigMCReader.{0}.{1}".format(Year, "altFit" if AltRange else "Fit"), 'pdf': "f_sig3D{}.{}".format('_ts' if TwoStep else '', Year), 'FitHesse': True, 'FitMinos': [ True if self.cfg['args'].seqKey == 'sigMCValidation' else False, () ], 'argPattern': ['unboundAfb', 'unboundFl'] if self.cfg['args'].seqKey == 'sigMCValidation' else ['unboundAfb', 'unboundFl', '^sigM.*'], 'createNLLOpt': [], 'argAliasInDB': ArgAliasRECO_Alt if AltRange else ArgAliasRECO, }) return StdFitter(setupSig3DFitter) if seq == 'sigAFitter': setupSigAFitter = deepcopy(setupTemplateFitter) setupSigAFitter.update({ 'name': "sigAFitter.{0}".format(Year), 'data': "sigMCGENReader.{0}.Fit".format(Year), 'pdf': "f_sigA.{0}".format(Year), 'FitHesse': True, 'FitMinos': [True, ()], 'argPattern': ['unboundAfb', 'unboundFl'], 'createNLLOpt': [], 'argAliasInDB': ArgAliasGEN, }) sigAFitter = StdFitter(setupSigAFitter) sigAFitter._bookPdfData = types.MethodType(sigAFitter_bookPdfData, sigAFitter) return sigAFitter if seq == 'sigAFitterCorrected': setupSigAFitter = deepcopy(setupTemplateFitter) setupSigAFitter.update({ 'name': "sigAFitterCorrected.{0}".format(Year), 'data': "sigMCGENReader.{0}.Fit".format(Year), 'pdf': "f_sigA_corrected.{0}".format(Year), 'FitHesse': True, 'FitMinos': [True, ()], 'argPattern': ['unboundAfb', 'unboundFl'], 'createNLLOpt': [], 'argAliasInDB': ArgAliasGEN, }) sigAFitter = StdFitter(setupSigAFitter) sigAFitter._bookPdfData = types.MethodType(sigAFitter_bookPdfData, sigAFitter) return sigAFitter if seq == 'bkgCombAFitter': setupBkgCombAFitter = deepcopy(setupTemplateFitter) setupBkgCombAFitter.update({ 'name': "bkgCombAFitter{}.{}".format('_Alt' if AltRange else '', Year), 'data': "dataReader.{}.{}SB".format(Year, 'alt' if AltRange else ''), 'pdf': "f_bkgCombA{}.{}".format("_Alt" if AltRange else "", Year), 'argPattern': [r'bkgComb[KL]_c[\d]+', r'bkgComb[KL]_c[\d]_Alt+'], 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupBkgCombAFitter) if seq == 'SimulFitter_bkgCombA': setupSimulFitter_bkgCombA = deepcopy(setupTemplateSimFitter) setupSimulFitter_bkgCombA.update({ 'category': [ 'LSB{}'.format(str(Year).strip('20')), 'USB{}'.format(str(Year).strip('20')) ], 'data': [ "dataReader.{}.LSB".format(Year), "dataReader.{}.USB".format(Year) ], 'pdf': ["f_bkgCombA.{}".format(Year), "f_bkgCombA.{}".format(Year)], 'Years': [Year, Year], #'argPattern': [r'bkgComb[KL]_c[\d]+', ], 'argAliasInDB': None, 'LegName': 'Simulation', 'fitToCmds': [ [ ROOT.RooFit.Strategy(2), ROOT.RooFit.InitialHesse(1), ROOT.RooFit.Minimizer('Minuit', 'minimize'), ROOT.RooFit.Minos(0) ], ], }) return SimultaneousFitter(setupSimulFitter_bkgCombA) if seq is 'finalFitter': setupFinalFitter = deepcopy( setupTemplateFitter) # 3D = nSig(Sig2D*SigM) + nBkg(fBkgM*fBkgA) setupFinalFitter.update({ 'name': "finalFitter.{}".format(Year), 'data': "dataReader.{}.Fit".format(Year), 'pdf': "f_final.{}".format(Year), 'argPattern': [ 'nSig', 'unboundAfb', 'unboundFl', 'nBkgComb', r'bkgCombM_c[\d]+' ], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitHesse': True, 'FitMinos': [False, ('nSig', 'unboundAfb', 'unboundFl', 'nBkgComb')], 'argAliasInDB': { **ArgAliasGEN }, 'argAliasSaveToDB': False, }) return StdFitter(setupFinalFitter) if seq is 'sigMDCBFitter': setupSigMDCBFitter = deepcopy(setupTemplateFitter) setupSigMDCBFitter.update({ 'name': "sigMDCBFitter.{0}".format(Year), 'data': "sigMCReader.{0}.Fit".format(Year), 'pdf': "f_sigMDCB.{0}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], #'argPattern': ['cbs[12]_sigma', 'cbs[12]_alpha', 'cbs[12]_n', 'cbs_mean', 'sigMDCB_frac'], 'createNLLOpt': [], #'argAliasInDB': ArgAliasDCB, 'argAliasSaveToDB': True, }) return StdFitter(setupSigMDCBFitter) #'_DCBG_Alt' if AltRange and binKey not in ['summary', 'summaryLowQ2'] and Year==2017 else ('_Alt' if AltRange else '') if seq is 'sigMFitter': setupSigMDCBFitter = deepcopy(setupTemplateFitter) setupSigMDCBFitter.update({ 'name': "sigMFitter{}.{}".format('_Alt' if AltRange else '', Year), 'data': "sigMCReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_sigM{}.{}".format('_Alt' if AltRange else '', Year), 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupSigMDCBFitter) if seq is 'finalFitter_AltM': setupFinalFitter_AltM = deepcopy( setupTemplateFitter ) # 3D = nSig(Sig2D*SigMDCB) + nBkg(fBkgM*fBkgA) setupFinalFitter_AltM.update({ 'name': "finalFitter_AltM.{}".format(Year), 'data': "dataReader.{}.Fit".format(Year), 'pdf': "f_final_AltM.{}".format(Year), 'argPattern': [ 'nSig', 'unboundAfb', 'unboundFl', 'nBkgComb', r'bkgCombM_c[\d]+' ], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitHesse': True, 'FitMinos': [False, ('nSig', 'unboundAfb', 'unboundFl', 'nBkgComb')], 'argAliasInDB': { **ArgAliasDCB, **ArgAliasGEN }, 'argAliasSaveToDB': False, }) return StdFitter(setupFinalFitter_AltM) if seq is 'bkgM_KStarFitter': setupBkgMFitter_KStar = deepcopy(setupTemplateFitter) setupBkgMFitter_KStar.update({ 'name': "bkgM_KStarFitter{}.{}".format('_Alt' if AltRange else '', Year), 'data': "KsigMCReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_bkgM_KStar{}.{}".format('_Alt' if AltRange else '', Year), 'FitHesse': True, 'FitMinos': [False, ()], #'argPattern': ['cbs[12]_sigma_KStar', 'cbs[12]_alpha_KStar', 'cbs[12]_n_KStar', 'cbs_mean_KStar', 'bkgM_frac_KStar', 'bkgM_frac[\d]_KStar', r'bkgMKStar_c[\d]+'], 'createNLLOpt': [], }) return StdFitter(setupBkgMFitter_KStar) if seq is 'bkgA_KStarFitter': setupBkgA_KStarFitter = deepcopy(setupTemplateFitter) setupBkgA_KStarFitter.update({ 'name': "bkgA_KStarFitter{}.{}".format('_Alt' if AltRange else '', Year), 'data': "KsigMCReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_bkgA_KStar{}.{}".format('_Alt' if AltRange else '', Year), #'argPattern': [r'bkgKStar[KL]_c[\d]+', r'bkgA_frac[\d]_KStar',], 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupBkgA_KStarFitter) if seq == 'bkgPeak3DFitter': setupBkgPeak3DFitter = deepcopy(setupTemplateFitter) setupBkgPeak3DFitter.update({ 'name': "bkgPeak3DFitter{}.{}".format('_Alt' if AltRange else '', Year), 'data': "KsigMCReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_bkg_KStar{}.{}".format('_Alt' if AltRange else '', Year), 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupBkgPeak3DFitter) if seq == 'finalFitter_WithKStar': setupFinalFitter_WithKStar = deepcopy( setupTemplateFitter ) # 3D = nSig(Sig3D) + nBkg(fBkgM*fBkgA) + nBkgPeak(fBkgPeak) setupFinalFitter_WithKStar.update({ 'name': "finalFitter_WithKStar{}.{}".format( '_Alt' if AltRange else '_ts' if TwoStep else '', Year), 'data': "dataReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_final_WithKStar{}.{}".format( '_Alt' if AltRange else '_ts' if TwoStep else '', Year), 'argPattern': [ 'nSig', 'unboundAfb', 'unboundFl', 'nBkgComb', r'bkgCombM_c[\d]+', r'bkgCombM_c[\d]_Alt+' ], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitHesse': True, 'FitMinos': [False, ('nSig', 'unboundAfb', 'unboundFl', 'nBkgComb')], 'argAliasInDB': { **ArgAliasGEN }, 'argAliasSaveToDB': False, }) return StdFitter(setupFinalFitter_WithKStar) if seq is 'finalFitter_AltM_WithKStar': setupFinalFitter_AltM_WithKStar = deepcopy( setupTemplateFitter) #3D = nSig(Sig2D*SigMDCB) + nBkg(fBkgM*fBkgA) setupFinalFitter_AltM_WithKStar.update({ 'name': "finalFitter_AltM_WithKStar{}.{}".format( '_Alt' if AltRange else '', Year), 'data': "dataReader.{}.{}Fit".format(Year, 'alt' if AltRange else ''), 'pdf': "f_final_AltM_WithKStar{}.{}".format('_Alt' if AltRange else '', Year), 'argPattern': [ 'nSig', 'unboundAfb', 'unboundFl', 'nBkgComb', r'bkgCombM_c[\d]+', r'bkgCombM_c[\d]_Alt+' ], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitHesse': True, 'FitMinos': [False, ('nSig', 'unboundAfb', 'unboundFl', 'nBkgComb')], 'argAliasInDB': { **ArgAliasGEN }, 'argAliasSaveToDB': False, }) return StdFitter(setupFinalFitter_AltM_WithKStar) #For Validation if seq is 'sigPhiMFitter_JP': #Phi mass for comparison setupSigMFitter_JP = deepcopy(setupTemplateFitter) setupSigMFitter_JP.update({ 'name': "sigPhiMFitter_JP.{}".format(Year), 'data': "sigMCReader_JP.{}.Fit_antiResVeto".format(Year), 'pdf': "f_sigPhiM3.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'argAliasInDB': { **ArgAlias_PhiM_JP }, 'createNLLOpt': [ ROOT.RooFit.Range(1.016, 1.024), ], }) return StdFitter(setupSigMFitter_JP) if seq is 'finalPhiMFitter_JP': #Phi mass from data for comparison with MC setupfinalPhiMFitter_JP = deepcopy(setupTemplateFitter) setupfinalPhiMFitter_JP.update({ 'name': "finalPhiMFitter_JP.{}".format(Year), 'data': "dataReader.{}.Fit_antiResVeto".format(Year), 'pdf': "f_finalPhiM.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'argAliasInDB': { **ArgAlias_PhiM_JP }, 'createNLLOpt': [ ROOT.RooFit.Range(1.016, 1.024), ], 'argAliasSaveToDB': False, }) return StdFitter(setupfinalPhiMFitter_JP) if seq is 'sigMFitter_JP': #Singal fit for JpsiPhi peak fit setupSigMFitter_JP = deepcopy(setupTemplateFitter) setupSigMFitter_JP.update({ 'name': "sigMFitter_JP.{}".format(Year), 'data': "sigMCReader_JP.{}.Fit_antiResVeto".format(Year), 'pdf': "f_sigM_DCBG_JP.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupSigMFitter_JP) if seq is 'bkgMFitter_JK': #Peaking bkg fit for JpsiPhi peak fit: JK = JpsiK* setupBkgMFitter_JK = deepcopy(setupTemplateFitter) setupBkgMFitter_JK.update({ 'name': "bkgMFitter_JK.{}".format(Year), 'data': "bkgMCReader_JK.{}.Fit_antiResVeto".format(Year), 'pdf': "f_sigMDCB_JK.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'argPattern': [ r'^.*$' ], #['cbs[12]_sigma', 'cbs[12]_alpha', 'cbs[12]_n', 'cbs_mean', 'sigM_frac[12]', 'sigMGauss_mean', 'sigMGauss1_sigma'], 'createNLLOpt': [], }) return StdFitter(setupBkgMFitter_JK) if seq is 'sigMFitter_PP': #Singal fit for PsiPhi peak fit setupSigMFitter_JP = deepcopy(setupTemplateFitter) setupSigMFitter_JP.update({ 'name': "sigMFitter_PP.{}".format(Year), 'data': "sigMCReader_PP.{}.Fit_antiResVeto".format(Year), 'pdf': "f_sigM_DCBG_PP.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupSigMFitter_JP) if seq is 'bkgMFitter_PK': #Peaking bkg fit for PsiPhi peak fit: PK = PsiK* setupBkgMFitter_PK = deepcopy(setupTemplateFitter) setupBkgMFitter_PK.update({ 'name': "bkgMFitter_PK.{}".format(Year), 'data': "bkgMCReader_PK.{}.Fit_antiResVeto".format(Year), 'pdf': "f_sigM_DCBG_PK.{}".format(Year), 'FitHesse': True, 'FitMinos': [False, ()], 'createNLLOpt': [], }) return StdFitter(setupBkgMFitter_PK) if seq is 'finalMFitter': setupFinalMFitter = deepcopy( setupTemplateFitter ) # Final Mass PDF = nSig(SigM)+nBkg(fBkgM)+nBkgP(fBkgP) setupFinalMFitter.update({ 'name': "finalMFitter.{}".format(Year), 'data': "dataReader.{}.Fit".format(Year), 'pdf': "f_finalM.{}".format(Year), 'argPattern': ['nSig', 'nBkgComb', 'nBkgPeak', r'bkgCombM_c[\d]+'], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitMinos': [True, ('nSig', 'nBkgComb', 'nBkgPeak')], }) return StdFitter(setupFinalMFitter) if seq is 'finalMFitter_JP': setupFinalMFitter_JP = deepcopy( setupTemplateFitter) # Final Mass PDF = nSig(SigM)+nBkg(fBkgM) setupFinalMFitter_JP.update({ 'name': "finalMFitter_JP.{}".format(Year), 'data': "dataReader.{}.Fit_antiResVeto".format(Year), 'pdf': "f_finalM_JP.{}".format(Year), 'argPattern': ['nSig', 'nBkgComb', 'nBkgPeak', r'bkgCombM_c[\d]_JP+'], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitMinos': [True, ('nSig', 'nBkgComb', 'nBkgPeak')], 'argAliasInDB': { 'nSig': 'nSig_JP', 'nBkgComb': 'nBkgComb_JP', 'nBkgPeak': 'nBkgPeak_JP' }, 'argAliasSaveToDB': True, }) return StdFitter(setupFinalMFitter_JP) if seq is 'finalMFitter_PP': setupFinalMFitter_PP = deepcopy( setupTemplateFitter) # Final Mass PDF = nSig(SigM)+nBkg(fBkgM) setupFinalMFitter_PP.update({ 'name': "finalMFitter_PP.{}".format(Year), 'data': "dataReader.{}.Fit_antiResVeto".format(Year), 'pdf': "f_finalM_PP.{}".format(Year), 'argPattern': ['nSig', 'nBkgComb', 'nBkgPeak', r'bkgCombM_c[\d]_PP+'], 'createNLLOpt': [ ROOT.RooFit.Extended(True), ], 'FitMinos': [True, ('nSig', 'nBkgComb', 'nBkgPeak')], 'argAliasInDB': { 'nSig': 'nSig_PP', 'nBkgComb': 'nBkgComb_PP', 'nBkgPeak': 'nBkgPeak_PP' }, 'argAliasSaveToDB': True, }) return StdFitter(setupFinalMFitter_PP)
def sigAFitter_bookPdfData(self): self.process.dbplayer.saveSMPrediction() StdFitter._bookPdfData(self) self.data.changeObservableName("genCosThetaK", "CosThetaK") self.data.changeObservableName("genCosThetaL", "CosThetaL")
import types from copy import deepcopy import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True import BsToPhiMuMuFitter.cpp from v2Fitter.Fitter.FitterCore import FitterCore from BsToPhiMuMuFitter.StdFitter import StdFitter, flToUnboundFl, afbToUnboundAfb from BsToPhiMuMuFitter.EfficiencyFitter import EfficiencyFitter from BsToPhiMuMuFitter.StdProcess import p import BsToPhiMuMuFitter.dataCollection as dataCollection import BsToPhiMuMuFitter.pdfCollection as pdfCollection from BsToPhiMuMuFitter.anaSetup import bMassRegions setupTemplateFitter = StdFitter.templateConfig() def sigAFitter_bookPdfData(self): self.process.dbplayer.saveSMPrediction() StdFitter._bookPdfData(self) self.data.changeObservableName("genCosThetaK", "CosThetaK") self.data.changeObservableName("genCosThetaL", "CosThetaL") ArgAliasRECO = {'unboundAfb': 'unboundAfb_RECO', 'unboundFl': 'unboundFl_RECO'} ArgAliasRECO_Alt = { 'unboundAfb': 'unboundAfb_RECO_Alt', 'unboundFl': 'unboundFl_RECO_Alt' } ArgAliasGEN = {'unboundAfb': 'unboundAfb_GEN', 'unboundFl': 'unboundFl_GEN'}
import types from copy import deepcopy import ROOT import BsToPhiMuMuFitter.cpp from v2Fitter.Fitter.FitterCore import FitterCore from BsToPhiMuMuFitter.StdFitter import StdFitter, flToUnboundFl, afbToUnboundAfb from BsToPhiMuMuFitter.EfficiencyFitter import EfficiencyFitter from BsToPhiMuMuFitter.StdProcess import p import BsToPhiMuMuFitter.dataCollection as dataCollection import BsToPhiMuMuFitter.pdfCollection as pdfCollection setupTemplateFitter = StdFitter.templateConfig() setupEffiFitter = deepcopy(EfficiencyFitter.templateConfig()) setupEffiFitter.update({ 'name': "effiFitter", 'data': "effiHistReader.accXrec", 'dataX': "effiHistReader.h_accXrec_fine_ProjectionX", 'dataY': "effiHistReader.h_accXrec_fine_ProjectionY", 'pdf': "effi_sigA", 'pdfX': "effi_cosl", 'pdfY': "effi_cosK", }) effiFitter = EfficiencyFitter(setupEffiFitter) setupSigMFitter = deepcopy(setupTemplateFitter) setupSigMFitter.update({