Exemple #1
0
names0 = 'p2vvab_00..'
names1 = names0 + '|p2vvab_10..'
names2 = names1 + '|p2vvab_20..'

from P2VV.Utilities.DataMoments import RealMomentsBuilder
moments = RealMomentsBuilder()
moments.appendPYList( angleFuncs.angles, indices )

if computeMoments :
    # compute moments from data set
    moments.compute(data)
    moments.write(momentsFile, Scale = scale)

else :
    # read moments from file
    moments.read(momentsFile)

# print moments to screen
moments.Print( Scale = scale, MinSignificance = 3., Names = names0 )
moments.Print( Scale = scale, MinSignificance = 3., Names = names1 )
moments.Print( Scale = scale, MinSignificance = 3., Names = names2 )
moments.Print( Scale = scale, MinSignificance = 0.                 )

# build new PDFs with angular moments
momPDFTerms0 = moments.buildPDFTerms(MinSignificance = 3., Names = names0, Scale = scale, CoefNamePrefix = 'C0_')
momPDFTerms1 = moments.buildPDFTerms(MinSignificance = 3., Names = names1, Scale = scale, CoefNamePrefix = 'C1_')
momPDFTerms2 = moments.buildPDFTerms(MinSignificance = 3., Names = names2, Scale = scale, CoefNamePrefix = 'C2_')
momPDFTerms  = moments.buildPDFTerms(MinSignificance = 0.                , Scale = scale                        , RangeNumStdDevs = 5.)

momPDF0 = momPDFTerms0.buildSumPdf('angMomentsPDF0')
momPDF1 = momPDFTerms1.buildSumPdf('angMomentsPDF1')
indices += [ ( 0, 4, 0 ), ( 0, 4, 2 ), ( 0, 4, 4 ) ]
#indices  = [ ( PIndex, YIndex0, YIndex1 ) for PIndex in range(4) for YIndex0 in range(4) for YIndex1 in range( -YIndex0, YIndex0 + 1 )\
#             if PIndex == 3 or YIndex0 == 3 ]
#indices  = [ ( 0, YIndex0, YIndex1 ) for YIndex0 in range(6) for YIndex1 in range( -YIndex0, YIndex0 + 1 ) ]
#indices = [ ( PIndex, 2, YIndex1 ) for PIndex in range(40) for YIndex1 in [ +1, -1 ] ]

basisMoments = RealMomentsBuilder()
if normPdf :
    basisMoments.appendPYList( angleFuncs.angles, indices, PDF = pdf, IntSet = intSet, NormSet = normSet )
else :
    basisMoments.appendPYList( angleFuncs.angles, indices )

PDFInt = 1. if normPdf else 8. * pi
if readMoments :
    # read moments from file
    physMoments.read(  momentsFile + '_Phys'  )
    basisMoments.read( momentsFile + '_Basis' )
else :
    # compute moments from data set
    physMoments.compute(data)
    basisMoments.compute(data)

    physMoments.write(  momentsFile + '_Phys',  Scale = PDFInt / 16. / sqrt(pi) )
    basisMoments.write( momentsFile + '_Basis', Scale = PDFInt                  )

# print moments to screen
physMoments.Print(  Scale = PDFInt / 16. / sqrt(pi)                       )
physMoments.convertEffWeightsToMoments( OutputFilePath = momentsFile + '_Basis_weights', Scale = PDFInt / 16. / sqrt(pi) )
basisMoments.Print( Scale = PDFInt /  2. / sqrt(pi)                       )
basisMoments.Print( Scale = PDFInt /  2. / sqrt(pi), MinSignificance = 5. )
    angleFuncs = AngleFuncs( cpsi = 'helcosthetaK', ctheta = 'helcosthetaL', phi = 'helphi' )

angles = [ angleFuncs.angles[ang] for ang in [ 'cpsi', 'ctheta', 'phi' ] ]

from P2VV.Utilities.DataMoments import RealMomentsBuilder
from math import sqrt, pi
indices  = [ ( PIndex, YIndex0, YIndex1 ) for PIndex in range(6) for YIndex0 in range(6)\
                                          for YIndex1 in range( -YIndex0, YIndex0 + 1 ) ]
#indices  = [ ( PIndex, YIndex0, 0 ) for PIndex in range(5) for YIndex0 in range(5) ]
#indices  = [ ( PIndex, YIndex0, YIndex1 ) for PIndex in range(3) for YIndex0 in range(3)\
#                                          for YIndex1 in range( -YIndex0, YIndex0 + 1 ) ]
#indices += [ ( 0, 4, 0 ), ( 0, 4, 2 ), ( 0, 4, 4 ) ]
moments = RealMomentsBuilder()
moments.appendPYList( angleFuncs.angles, indices )
for file, fac in zip( momentsFiles, addFactors ) :
    moments.read( file, AddMoments = fac )
moments.Print(  Scale = 1. / 2. / sqrt(pi)
              , Names = '|'.join( 'p2vvab_%d0%d%s%d' % ( moms[0], moms[1], 'm' if moms[2] < 0 else '', moms[2] ) for moms in signMoms )
             )
moments.Print( Scale = 1. / 2. / sqrt(pi), MinSignificance = 2.5 )

momFuncTerms = moments.buildPDFTerms( CoefNamePrefix = 'transC_' if transAngles else 'helC_'
                                     , Names = '|'.join( 'p2vvab_%d0%d%s%d' % ( moms[0], moms[1], 'm' if moms[2] < 0 else '', moms[2] )\
                                                        for moms in signMoms )
                                    )
momFunc = momFuncTerms.buildAddition( 'efficiency' + ( 'Trans' if transAngles else 'Hel' ) )

# create efficiency functions with alternative angular values for slices
from ROOT import RooRealVar, RooCustomizer
angles1 = [ RooRealVar(ang._var) for ang in angles ]
angles2 = [ RooRealVar(ang._var) for ang in angles ]