Пример #1
0
# 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_'                       )

momPDF  = momPDFTerms.buildSumPdf('angMomentsPDF')
momPDF0 = momPDFTerms0.buildSumPdf('angMomentsPDF0')
momPDF1 = momPDFTerms1.buildSumPdf('angMomentsPDF1')
Пример #2
0
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. )


###########################################################################################################################################
## add efficiency weights column to data set ##
###############################################

if addInvPdf and normPdf :
    print 'adding efficiency weights to dataset'
Пример #3
0
    else:               PhysicsReweight.setMonteCarloParameters()

physMoments = RealMomentsBuilder( Moments = ( RealEffMoment( Name = func.GetName(), 
                                                             BasisFunc = func,
                                                             Norm      = 1., 
                                                             PDF       = PhysicsReweight.getPdf(), 
                                                             IntSet    = [],
                                                             NormSet   = angles
                                                             )\
       for complexFunc in PhysicsReweight.getAngleFunctions().functions.itervalues() for func in complexFunc if func )
                                  )
  
scaleFactor = 1 / 16. / sqrt(pi)
physMoments.initCovariances()
physMoments.compute(mcDataMngr.getDataSet()) 
physMoments.write( 'Sim08_{0}_{1}_Phys_{2}'.format(MCProd,outputEffMomentsBaselineName,iterNumb), Scale=scaleFactor )

# normalize effciency moments
normalizeMoments( 'Sim08_{0}_{1}_Phys_{2}'.format(MCProd,outputEffMomentsBaselineName,iterNumb),
                  'Sim08_{0}_{1}_Phys_norm_{2}'.format(MCProd,outputEffMomentsBaselineName,iterNumb),
                  normMoment = PhysicsReweight.getParNamePrefix() + '_Re_ang_A0_A0',
                  printMoms  = delIntermediateMoms
                  )
if delIntermediateMoms: os.remove('Sim08_{0}_{1}_Phys_{2}'.format(MCProd,outputEffMomentsBaselineName,iterNumb) )

# combine 2011, 2012 acceptances
if combineEffMoments:
    angAcc2011  = 'Sim08_2011_%s_Phys_norm_%s'%(outputEffMomentsBaselineName,iterNumb) 
    angAcc2012  = 'Sim08_2012_%s_Phys_norm_%s'%(outputEffMomentsBaselineName,iterNumb) 
    combAccName = 'Sim08_20112012_{0}_Phys_norm_{1}'.format(outputEffMomentsBaselineName,iterNumb)
    combineMoments( angAcc2011, angAcc2012, combAccName, Prefix = 'mc', delete=False )