Exemple #1
0
 def pdf(self, **kwargs ) :
     from P2VV.Utilities.DataMoments import RealMomentsBuilder
     mb = RealMomentsBuilder()
     mb.appendPYList( self._angles, kwargs.pop('Indices') )
     mb.compute( self._splot.data( kwargs.pop('Component') ) )
     if kwargs.pop('Verbose',False) : 
         mb.Print()
         print 'computed moments, creating PDF with name %s' % kwargs['Name']
     return mb.createPDF( **kwargs )
                                                )
                                    )

physMoments.initCovariances()

# moments builder with angular basis functions
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 ) ]
#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                  )

###########################################################################################################################################
## compute angular moments and build moments PDFs ##
####################################################

# build angular moment basis functions
indices  = [ ( PIndex, YIndex0, YIndex1 ) for PIndex in range(4) for YIndex0 in range(3) for YIndex1 in range( -YIndex0, YIndex0 + 1 ) ]

# construct moment names strings
names0 = 'p2vvab_0000'
names1 = names0 + '|p2vvab_001.|p2vvab_100.|p2vvab_101.'

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

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

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

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