psi_background = Component('psi_background', (bkg_m.pdf(), psi_m), Yield= (200000,500,500000) ) from P2VV.Utilities.DataHandling import readData tree_name = 'DecayTree' prefix = '/stuff/PhD' if os.path.exists('/stuff') else '/bfys/raaij' if dataSample == '2011': input_file = os.path.join(prefix, 'p2vv/data/Bs2JpsiPhi_ntupleB_for_fitting_20121012_MagDownMagUp.root') elif dataSample == '2012': input_file = os.path.join(prefix, '/stuff/PhD/p2vv/data/Bs2JpsiPhi_2012_ntupleB_20121212.root') else: raise RuntimeError cut = 'runNumber > 0 && sel == 1 && sel_cleantail == 1 && (hlt1_biased == 1 || hlt1_unbiased_dec == 1) && hlt2_biased == 1 && ' ## cut = 'runNumber > 0 && sel == 1 && sel_cleantail == 1 && hlt1_unbiased_dec == 1 && hlt2_unbiased == 1 && ' cut += ' && '.join(['%s < 4' % e for e in ['muplus_track_chi2ndof', 'muminus_track_chi2ndof', 'Kplus_track_chi2ndof', 'Kminus_track_chi2ndof']]) data = readData(input_file, tree_name, ntupleCuts = cut, NTuple = True, observables = observables) # Create signal component signal = Component('signal', (sig_m.pdf(), psi_m), Yield = (27437,10000,50000)) ## Build PDF mass_pdf = buildPdf(Components = (signal, background), Observables = (m, ), Name = 'mass_pdf') mass_pdf.Print("t") ## Fit options fitOpts = dict(NumCPU = 4, Timer = 1, Save = True, Verbose = False, Optimize = 2, Minimizer = 'Minuit2') # make sweighted dataset. TODO: use mumu mass as well... from P2VV.Utilities.SWeights import SData, splot
if trigger == 'ExclBiased' : #cuts = 'sel == 1 && sel_cleantail==1 && hlt1_excl_biased_dec == 1 && hlt2_biased == 1 && ' + cuts cuts = 'sel == 1 && sel_cleantail==1 && hlt1_excl_biased == 1 && hlt2_biased == 1 && ' + cuts elif trigger == 'Unbiased' : #cuts = 'sel == 1 && sel_cleantail==1 && hlt1_unbiased_dec == 1 && hlt2_biased == 1 && ' + cuts cuts = 'sel == 1 && sel_cleantail==1 && hlt1_unbiased == 1 && hlt2_biased == 1 && ' + cuts else : #cuts = 'sel == 1 && sel_cleantail==1 && (hlt1_unbiased_dec == 1 || hlt1_biased == 1) && hlt2_biased == 1 && ' + cuts cuts = 'sel == 1 && sel_cleantail==1 && (hlt1_unbiased == 1 || hlt1_biased == 1) && hlt2_biased == 1 && ' + cuts readDataOpts = { } if cuts : readDataOpts['ntupleCuts'] = cuts if weightVar : readDataOpts['WeightVar'] = ( weightVar, True ) from P2VV.Utilities.DataHandling import readData data = readData( nTupleFile, dataSetName = nTupleName, NTuple = True, observables = obsSet, **readDataOpts ) ########################################################################################################################################### ## build the B_s -> J/psi phi signal time, angular and tagging PDF ## ##################################################################### if normPdf : # transversity amplitudes from P2VV.Parameterizations.DecayAmplitudes import JpsiVPolarSWaveFrac_AmplitudeSet as Amplitudes amplitudes = Amplitudes( A0Mag2 = A0Mag2Val, AperpMag2 = AperpMag2Val , AparPhase = AparPhVal - A0PhVal, AperpPhase = AperpPhVal - A0PhVal , f_S = 0., ASOddPhase = 0., C_SP = 1. ) # B lifetime
st = RealVar('sigmat',Title = '#sigma(t)', Unit = 'ps', Observable = True, MinMax = (0.01, 0.07)) t_true = RealVar('truetime', Title = 'true decay time', Unit='ps', Observable = True, MinMax=(-1100, 14)) m = RealVar('mass', Title = 'B mass', Unit = 'MeV', Observable = True, MinMax = (5200, 5550)) observables = [m, t, st, t_true] cut = 'sel == 1 && triggerDecisionUnbiasedPrescaled == 1 && ' cut += ' && '.join(['%s < 4' % e for e in ['muplus_track_chi2ndof', 'muminus_track_chi2ndof', 'Kplus_track_chi2ndof', 'Kminus_track_chi2ndof']]) cut += ' && sel_cleantail == 1' cut += ' && abs(trueid) == 531' if not generate: prefix = '/stuff/PhD' if os.path.exists('/stuff') else '/bfys/raaij' filename = os.path.join(prefix, 'p2vv/data/Bs2JpsiPhiPrescaled_MC11a_ntupleB_for_fitting_20130222.root') from P2VV.Utilities.DataHandling import readData data = readData(filename, "DecayTree", NTuple = True, observables = observables, ntupleCuts = cut) t_diff = FormulaVar(Name = 'time_diff', Formula = '@1 > -900 ? @0 - @1 : @0', Arguments = [t, t_true], data = data) t_diff.setMin(-10) t_diff.setMax(10) else: t_diff = RealVar('time_diff', Unit = 'ps', Observable = True, MinMax = (-5, 5)) observables.append(t_diff) # Create combinatorical background component mean = RealVar(Name = 'mean', Value = 5368, MinMax = (5300, 5400)) sigma = RealVar(Name = 'sigma', Value = 50, MinMax = (1, 500)) from ROOT import RooGaussian as Gaussian bkg_m = Pdf(Name = 'gauss', Type = Gaussian, Parameters = (m, mean, sigma)) background = Component('background', (bkg_m,), Yield = (19620,100,500000) )
# PV bins from array import array PV_bounds = array('d', [-0.5 + i for i in range(12)]) from ROOT import gStyle gStyle.SetPalette(53) corr_canvas = None ## List of all plots we make from collections import defaultdict plots = defaultdict(list) ## Build simple mass pdf if fit_mass: from P2VV.Utilities.DataHandling import readData data = readData(input_data[args[0]]['data'], tree_name, NTuple = True, observables = observables, ntupleCuts = cut, ImportIntoWS = False) data.SetName(tree_name) if signal_MC and data.numEntries() > 3e5: data = data.reduce(EventRange = (int(2e5), int(5e5))) elif data.numEntries() > 6e5: data = data.reduce(EventRange = (0, int(6e5))) if options.reduce: data = data.reduce(EventRange = (0, int(options.reduce))) # In case of reweighing sig_mass_pdf = buildPdf(Components = (signal, background), Observables = (m,), Name = 'sig_mass_pdf') psi_mass_pdf = buildPdf(Components = (psi_ll, background), Observables = (mpsi,), Name='psi_mass_pdf') if signal_MC: sig_mass_pdf.Print('t') signal_name = signal.GetName() mass_pdf = sig_mass_pdf
# ntuple selection string dataSetArgs = {} if applySelection: from P2VV.Imports import cutSelStringsJpsiKst as selection selection.pop('noSelection') if runPeriod == 2011: selection.pop('bdtg_2012') if runPeriod == 2012: selection.pop('bdtg_2011') dataSetArgs['ntupleCuts'] = ' && '.join( selection.itervalues() ) # read tree into RooDataSet from P2VV.Utilities.DataHandling import readData outDataSet = readData( intermediateFileName, inputTreeName, NTuple = True, observables = [ obs for obs in observables.itervalues()], WeightVar = ( weightVarName,True ), ImportIntoWS = False, **dataSetArgs ) outDataSet.Print() # create final output file outFileName = outDataSetPaths[dataSetKey] + '_fitNtuple_%s_%s.root'%(prodDate,weightName + '_weighted') #if createFitNtuple: outFileName += '_fitNtuple' #if createAngAccNtuple or calculateHelAngles: outFileName += '_angEff' outFile = TFile.Open(outFileName, 'recreate') outDataSet.Write() outFile.Close() del outFile
## Fit options fitOpts = dict(NumCPU = 4, Timer = 1, Save = True, Optimize = 2, Strategy = 2, Offset = True, Minimizer = 'Minuit2') valid_definition = [[(hlt1_excl_biased_dec, 'exclB'), (hlt1_excl_biased_dec, 'notExclB')], [(hlt2_biased, 'B'), (hlt2_unbiased, 'UB')]] valid = valid_combinations(valid_definition) data = None if ntuple_file: from ROOT import TFile input_file = TFile(ntuple_file) tree_name = 'DecayTree' if input_file.FindKey(tree_name): input_file.Close() from P2VV.Utilities.DataHandling import readData data = readData(ntuple_file, tree_name, cuts = 'sel == 1 && (hlt1_biased == 1 || hlt1_unbiased_dec == 1) && (hlt2_biased == 1 || hlt2_unbiased == 1)', NTuple = True, observables = observables) for i in range(3): mass_result = mass_pdf.fitTo(data, **fitOpts) if mass_result.status() == 0: break assert(mass_result.status() == 0) # Plot mass pdf from ROOT import kDashed, kRed, kGreen, kBlue, kBlack from ROOT import TCanvas canvas = TCanvas('mass_canvas', 'mass_canvas', 600, 530) obs = [m] for (p,o) in zip(canvas.pads(len(obs)), obs): from P2VV.Utilities.Plotting import plot pdfOpts = dict()
pdfConfig['timeEffHistFiles'].getSettings( [ ( 'runPeriod', 'p2012' ) ] )['file'] = 'timeAcceptanceFit_2012.root' pdfConfig['anglesEffType'] = 'basisSig6' pdfConfig['angEffMomsFiles'] = 'angEffNominalRew_5thOrder.par' ########################################################################################################################################### ## read data and build PDF ## ############################# # workspace from P2VV.RooFitWrappers import RooObject ws = RooObject( workspace = 'JpsiphiWorkspace' ).ws() # read data set from file from P2VV.Utilities.DataHandling import readData inputData = readData( filePath = args.inputData, dataSetName = args.dataName, NTuple = False ) pdfConfig['signalData'] = inputData pdfConfig['readFromWS'] = True # build the PDF from P2VV.Parameterizations.FullPDFs import Bs2Jpsiphi_PdfBuilder as PdfBuilder pdfBuild = PdfBuilder( **pdfConfig ) pdf = pdfBuild.pdf() if parFileIn : # read parameters from file pdfConfig.readParametersFromFile( filePath = parFileIn ) pdfConfig.setParametersInPdf(pdf) if args.model == 'phi' : # set |lambda| = 1
, ctl = 'Candidates / %.2g' , phi = 'Candidates / (%.2g#kern[0.3]{#pi} rad)' ) asymRange = ( -0.3, +0.3 ) numBins = 15 # workspace from P2VV.RooFitWrappers import RooObject worksp = RooObject( workspace = 'JpsiKK' ).ws() # read data sets from file dataSets = { } from itertools import product from P2VV.Utilities.DataHandling import readData for cat in dataSetCats : dataSets[cat[0]] = readData( filePath = dataSetFilePath, dataSetName = dataSetName + '_' + cat[1], NTuple = False ) # create histograms from math import exp, log from array import array timeRange = ( 0.3, 12., numBins ) timeBinLog = log( timeRange[1] / timeRange[0] ) / float( timeRange[2] ) timeBins = array( 'd', [ timeRange[0] * exp( float(it) * timeBinLog ) for it in range( timeRange[2] + 1 ) ] ) from P2VV.Load import LHCbStyle from ROOT import TH1D from math import pi TH1D.SetDefaultSumw2(True) timeHists = dict( [ ( cat[0], TH1D( '%sHistTime' % cat[0], '%sHistTime' % cat[0], timeRange[2], timeBins ) ) for cat in dataSetCats ] ) ctkHists = dict( [ ( cat[0], TH1D( '%sHistCtk' % cat[0], '%sHistCtk' % cat[0], numBins, -1., +1. ) ) for cat in dataSetCats ] ) ctlHists = dict( [ ( cat[0], TH1D( '%sHistCtl' % cat[0], '%sHistCtl' % cat[0], numBins, -1., +1. ) ) for cat in dataSetCats ] )
, ReAperp = sqrt( AperpMag2Val / A0Mag2Val ) * cos( AperpPhVal - A0PhVal ) , ImAperp = sqrt( AperpMag2Val / A0Mag2Val ) * sin( AperpPhVal - A0PhVal ) , ReAS = sqrt( ASMag2Val / A0Mag2Val ) * cos( ASPhVal - A0PhVal ) , ImAS = sqrt( ASMag2Val / A0Mag2Val ) * sin( ASPhVal - A0PhVal ) ) from P2VV.Parameterizations.AngularPDFs import Amplitudes_AngularPdfTerms pdfTerms = Amplitudes_AngularPdfTerms( AmpNames = ampsToUse, Amplitudes = transAmps, AngFunctions = angleFuncs.functions ) # build angular PDF pdf = pdfTerms.buildSumPdf('AngularPDF') if readData : # read data from P2VV.Utilities.DataHandling import readData data = readData( dataSetFile, dataSetName = dataSetName ) print 'amplitudeMoments: read %d events' % data.sumEntries() else : # generate data with PDF print 'amplitudeMoments: generating %d events' % nEvents data = pdf.generate( observables, nEvents ) from P2VV.Utilities.DataHandling import writeData writeData( dataSetFile, dataSetName, data ) if fitDataOriginal : # fit amplitudes PDF to data print 'amplitudeMoments: fitting %d events' % data.numEntries() pdf.fitTo( data, **fitOpts )
########################################################################################################################################### ## Read data and get observables ## ################################### from P2VV.Load import P2VVLibrary, LHCbStyle from ROOT import gStyle gStyle.SetColorModelPS(1) # workspace from P2VV.RooFitWrappers import RooObject ws = RooObject( workspace = 'JpsiphiWorkspace' ).ws() # read data set from file from P2VV.Utilities.DataHandling import readData if drawTotalDists: data = readData( filePath = dataSetFile, dataSetName = 'JpsiKK', NTuple = False ) data = data.reduce('hlt2_biased==1 && mass>5338. && mass<5398.') data.Print() sigData = readData( filePath = dataSetFile, dataSetName = 'JpsiKK_sigSWeight', NTuple = False ) sigData = sigData.reduce('hlt2_biased==1') sigData.Print() # get observables from P2VV.RooFitWrappers import RealVar mumuMass = RealVar('mdau1') KKMass = RealVar('mdau2') # LHCb label labelText = '' # 'LHCb' if labelText : from ROOT import TLatex
angles = [ angleFuncs.angles['cpsi'], angleFuncs.angles['ctheta'], angleFuncs.angles['phi'] ] obsSet = [ time if tResModel in [ 'Gauss', '3Gauss' ] else trueTime ] + angles # read ntuple bkgcatCut = '(bkgcat == 0 || bkgcat == 50)' trackChiSqCuts = 'muplus_track_chi2ndof < 4. && muminus_track_chi2ndof < 4. && Kplus_track_chi2ndof < 4. && Kminus_track_chi2ndof < 4.' massCuts = 'mass > 5200. && mass < 5550. && mdau1 > 3030. && mdau1 < 3150. && mdau2 > 990. && mdau2 < 1050.' timeCuts = 'time > 0.3 && time < 14. && sigmat < 0.12' tagCuts = '(tagdecision == 0 || tagdecision == -1 || tagdecision == +1)' from P2VV.Utilities.DataHandling import readData cuts = bkgcatCut + ' && ' + trackChiSqCuts + ' && ' + massCuts + ' && ' + timeCuts + ' && ' + tagCuts if trigger == 'ExclBiased' : cuts = 'sel == 1 && sel_cleantail==1 && hlt1_excl_biased_dec == 1 && hlt2_biased == 1 && ' + cuts data = readData( nTupleFile, dataSetName = nTupleName, NTuple = True, observables = obsSet, ntupleCuts = cuts ) elif trigger == 'Unbiased' : cuts = 'sel == 1 && sel_cleantail==1 && hlt1_unbiased_dec == 1 && hlt2_biased == 1 && ' + cuts data = readData( nTupleFile, dataSetName = nTupleName, NTuple = True, observables = obsSet, ntupleCuts = cuts ) else : cuts = 'sel == 1 && sel_cleantail==1 && (hlt1_unbiased_dec == 1 || hlt1_biased == 1) && hlt2_biased == 1 && ' + cuts data = readData( nTupleFile, dataSetName = nTupleName, NTuple = True, observables = obsSet, ntupleCuts = cuts ) ########################################################################################################################################### ## build the B_s -> J/psi phi signal time, angular and tagging PDF ## ##################################################################### if physPdf :
########################################################################################################################################### ## generate/read data and fit ## ################################ # generate data from P2VV.Load import RooFitOutput if generateData : print 'timeAnglesSignal: generating %d events' % nEvents data = pdf.generate( observables, nEvents ) from P2VV.Utilities.DataHandling import writeData writeData( dataSetFile, dataSetName, data, NTuple ) else : from P2VV.Utilities.DataHandling import readData data = readData( dataSetFile, dataSetName = dataSetName, NTuple = NTuple, observables = observables ) # TODO: a trick to change the observables in a data set ( iTag( +1, -1 ) <--> iTag( +1, -1, 0 ) ) data = RooDataSet( dataSetName + '1', '', data, ( obs._var for obs in observables ) ) if fitData : # fix values of some parameters #ANuissance.setConstant('avgCOdd') #lambdaCP.setConstant('phiCP') #taggingParams.setConstant('AWTag') # fit data print 'timeAnglesSignal: fitting %d events' % data.numEntries() pdf.fitTo( data, NumCPU = 2, Timer = 1 )#, ConditionalObservables = [iTag] )
, etaTag = ( 'tagomega_os_cb', 'tagomega_ss_nn' ) , OSSSTagEq = ( 'iTagOS', 'iTagSS' ) ) ########################################################################################################################################### ## build J/psiKK mass PDF ## ############################ # create workspace from P2VV.RooFitWrappers import RooObject ws = RooObject( workspace = 'JpsiKKWS' ).ws() # read data set from P2VV.Utilities.DataHandling import readData dataSet = readData( filePath = args.dataPathIn, dataSetName = args.datasetName, NTuple = False ) # get observables from P2VV.RooFitWrappers import RealVar, Category observables = dict( mass = RealVar('mass'), runPeriod = Category('runPeriod'), KKMassCat = Category('KKMassCat') ) # initialize PDF components from P2VV.RooFitWrappers import Component nSig = dataSet.sumEntries() nTot = float( dataSet.numEntries() ) sigMassComps = Component( 'sigMass', [ ], Yield = ( nSig, 0., nTot ) ) cbkgMassComps = Component( 'cbkgMass', [ ], Yield = ( nTot - nSig, 0., nTot ) ) massComps = [ sigMassComps, cbkgMassComps ] # build the signal mass PDF sigMassArgs = dict( Name = 'sig_m', mass = observables['mass'] )
# angular acceptance input pdfConfig['anglesEffType'] = 'weights' pdfConfig['angEffMomsFiles'] = options.AngAccFile if options.AngAccFile \ else path + 'angEffMoments/correctedEffMoms/DEC/Sim08_20112012_hel_UB_UT_trueTime_BkgCat050_KK30_Phys_moms_norm_fromAna' # Iter. proc. corrected acc. of DEC dataset ##################################################################################################################### ## read data and build pdf ## ############################ # workspace from P2VV.RooFitWrappers import RooObject ws = RooObject( workspace = 'JpsiKstWorkspace' ).ws() # read data set from file from P2VV.Utilities.DataHandling import readData dataSet = readData( filePath = dataSetFile, dataSetName = dataSetName, NTuple = False, ImportIntoWS = False ) pdfConfig['signalData'] = dataSet pdfConfig['readFromWS'] = False # build PDF from P2VV.Parameterizations.FullPDFs import Bs2JpsiKst_PdfBuilder as PdfBuilder pdfBuild = PdfBuilder( **pdfConfig ) pdf = pdfBuild.pdf() assert False if parFileIn: # read parameters from file pdfConfig.readParametersFromFile( filePath = parFileIn ) pdfConfig.setParametersInPdf(pdf) print '-' * 80 + '\n\n'
# script paramters plotsFilePath = 'plots/Reco14/20112012Reco14_tagging.pdf' dataSetFilePath = '/project/bfys/jleerdam/data/Bs2Jpsiphi/Reco14/P2VVDataSets20112012Reco14_I2Mass_6KKMassBins_2TagCats_HLT2B_20140619.root' fullDataSetName = 'JpsiKK' sigDataSetName = 'JpsiKK_sigSWeight' cbkgDataSetName = 'JpsiKK_cbkgSWeight' numEstWTagBins = 50 # workspace from P2VV.RooFitWrappers import RooObject ws = RooObject(workspace = 'JpsiphiWorkspace').ws() # read data sets from P2VV.Utilities.DataHandling import readData fullData = readData( filePath = dataSetFilePath, dataSetName = fullDataSetName, NTuple = False ) sigData = readData( filePath = dataSetFilePath, dataSetName = sigDataSetName, NTuple = False ) cbkgData = readData( filePath = dataSetFilePath, dataSetName = cbkgDataSetName, NTuple = False ) # get observables from P2VV.RooFitWrappers import RealVar, Category estWTagOS = RealVar('tagomega_os_cb') estWTagSS = RealVar('tagomega_ss_nn') tagCatOS = Category('tagCatP2VVOS') tagCatSS = Category('tagCatP2VVSS') # build PDFs for estimated wrong-tag probabilities taggedDataOS = sigData.reduce( '%s > 0' % tagCatOS.GetName() ) taggedDataSS = sigData.reduce( '%s > 0' % tagCatSS.GetName() ) from P2VV.RooFitWrappers import HistPdf tagPdfOS = HistPdf( Name = 'sig_bkg_estWTagOS'
[ "%s < 4" % e for e in ["muplus_TRACK_CHI2NDOF", "muminus_TRACK_CHI2NDOF", "Kplus_TRACK_CHI2NDOF", "Kminus_TRACK_CHI2NDOF"] ] ) cut += " && sel_cleantail == 1" for o in [mass, t, st]: cut += " && {0} > {1} && {0} < {2}".format(o.GetName(), o.getMin(), o.getMax()) from P2VV.Utilities.DataHandling import readData data = readData( filePath=input_file, dataSetName="DecayTree", NTuple=True, observables=[mass, t, st, excl_biased], Rename="JpsiphiData", ntupleCuts=cut, ) sigFrac = 0.504 nEvents = data.sumEntries() nSignal = nEvents * sigFrac nBackground = nEvents * (1.0 - sigFrac) ## from P2VV.Parameterizations.MassPDFs import Ipatia2_Signal_Mass as SignalBMass ## sig_m = SignalBMass(Name = 'sig_m', mass = mass, m_sig_lambda = -2.5, m_sig_zeta = 0.01, ## m_sig_alpha_1 = 3.0, m_sig_alpha_2 = 2.5, m_sig_n_1 = 1.5, m_sig_n_2 = 2.0) from P2VV.Parameterizations.MassPDFs import LP2011_Signal_Mass as SignalBMass sig_m = SignalBMass(Name="sig_m", mass=mass)
# angular acceptance input pdfConfig['anglesEffType'] = 'weights' pdfConfig['angEffMomsFiles'] = options.AngAccFile if options.AngAccFile \ else path + 'angEffMoments/correctedEffMoms/DEC/Sim08_20112012_hel_UB_UT_trueTime_BkgCat050_KK30_Phys_moms_norm_fromAna' # Iter. proc. corrected acc. of DEC dataset ##################################################################################################################### ## read data and build pdf ## ############################ # workspace from P2VV.RooFitWrappers import RooObject ws = RooObject( workspace = 'JpsiKstWorkspace' ).ws() # read data set from file from P2VV.Utilities.DataHandling import readData dataSet = readData( filePath = dataSetFile, dataSetName = dataSetName, NTuple = False ) pdfConfig['signalData'] = dataSet pdfConfig['readFromWS'] = True ## TODO:: make correct sWeights for jpsiKst. # data set with weights corrected for background dilution # from P2VV.Utilities.DataHandling import correctWeights # fitData = correctWeights( dataSet, [ 'runPeriod', 'KKMassCat' ] ) # build PDF from P2VV.Parameterizations.FullPDFs import Bs2JpsiKst_PdfBuilder as PdfBuilder pdfBuild = PdfBuilder( **pdfConfig ) pdf = pdfBuild.pdf() assert False if parFileIn:
background = Component('background', (bkg_m,), Yield= (200000,500,5000000) ) signal = Component('signal', (sig_m, sig_t.pdf()), Yield= (200000,500,500000) ) from P2VV.Utilities.DataHandling import readData tree_name = 'DecayTree' ## cut = 'runNumber > 0 && sel == 1 && (hlt1_biased == 1 || hlt1_unbiased_dec == 1) && hlt2_biased == 1 && ' cut = 'runNumber > 0 && sel == 1 && hlt1_unbiased_dec == 1 && hlt2_unbiased == 1 && ' cut += ' && '.join(['%s < 4' % e for e in ['muplus_track_chi2ndof', 'muminus_track_chi2ndof', 'Kplus_track_chi2ndof', 'Kminus_track_chi2ndof']]) from ROOT import RooAbsData storage = RooAbsData.getDefaultStorageType() RooAbsData.setDefaultStorageType(RooAbsData.Tree) data = readData(input_data[args[0]]['data'], tree_name, ntupleCuts = cut, NTuple = True, observables = observables) from ROOT import TFile tmp_file = TFile.Open(os.path.join(prefix, 'p2vv/data/tmp.root'), 'recreate') data.store().tree().SetDirectory(tmp_file) data_cut = data.reduce("time > 0.3") data_cut.store().tree().SetDirectory(tmp_file) ## Build PDF mass_pdf = buildPdf(Components = (background, signal), Observables = (m, ), Name = 'mass_pdf') mass_pdf.Print("t") ## Fit options fitOpts = dict(NumCPU = 4, Timer = 1, Save = True, Verbose = False, Optimize = 1, Minimizer = 'Minuit2')