for name2 in funcNames : covs[name1][name2] += ( momCoefs[name1][0] - funcMeans[name1] ) * ( momCoefs[name2][0] - funcMeans[name2] ) covsW[name1][name2] += ( momCoefsW[name1][0] - funcMeans[name1] ) * ( momCoefsW[name2][0] - funcMeans[name2] ) # divide covariance sums by number of entries to get covariances for name1 in funcNames : for name2 in funcNames : covs[name1][name2] /= float(nIters) covsW[name1][name2] /= float(nIters) # print data sets from last iteration noWeightData.Print() weightData.Print() for evIt in range(10) : print 'not weighted: %+.2f (%.2f) weighted: %+.2f (%.2f)'\ % ( noWeightData.get(evIt).getRealValue('x'), noWeightData.weight(), weightData.get(evIt).getRealValue('x'), weightData.weight() ) print # print moments from last iteration and computed covariances maxLenName = max( [ len(name) for name in funcNames ] ) from math import sqrt def printCovs(covMat) : print ' errors:' for name in funcNames : print ( ' {0:>%ds}: {1:>7.5f}' % maxLenName ).format( name, sqrt( covMat[name][name] ) ) print print ' correlations:' print ' ' * ( maxLenName + 5 ) + ' '.join( '{0:>6s}'.format(name) for name in funcNames ) for name1 in funcNames : corrs = [ ( covMat[name1][name2] / sqrt( covMat[name1][name1] * covMat[name2][name2] ) )\
weightVar = dataSetAsym.addColumn(weightVar) obsSet.add(weightVar) dataSetAsymW = RooDataSet( 'asymDataW', 'asymDataW', obsSet, Import = dataSetAsym, WeightVar = ( 'weightVar', True ) ) del dataSetAsym ws.put(dataSetAsymW) del dataSetAsymW dataSetAsymW = ws['asymDataW'] obsSet = RooArgSet( dataSetAsymW.get() ) dataSetAsymW.Print() # get sums of weights sumW = dict( plus = 0., minus = 0. ) for evSet in dataSetAsymW : if evSet.getCatIndex('asymCat') == 1 : sumW['plus'] += dataSetAsymW.weight() else : sumW['minus'] += dataSetAsymW.weight() assert abs( dataSetAsymW.sumEntries() - sumW['plus'] - sumW['minus'] ) < 1.e-5 if applyAngWeights : ASumW = 2. * sumW['plus'] - ( sumW['plus'] + sumW['minus'] ) else : ASumW = 2. * sumW['plus'] / ( sumW['plus'] + sumW['minus'] ) - 1. # create arrays of time bins from array import array timeArr = array( 'd', [ ( periodShift + ( float(it) + binOffset + 0.5 ) / float(numTimeBins) ) * oscPeriod\ for it in range( numTimeBins + 1 ) ] ) timeErrArr = array( 'd', [ 0.5 / float(numTimeBins) * oscPeriod ] * ( numTimeBins + 1 ) ) timeArrPdf = array( 'd', [ ( periodShift + ( float(it) + binOffset + float(frac) ) / float(numTimeBins) ) * oscPeriod\ for it in range( numTimeBins + 1 ) for frac in timeFracs ]\