Пример #1
0
def flatten(analysis,sample,**kwargs):
    histParams = kwargs.pop('histParams',{})
    histSelections = kwargs.pop('histSelections',{})
    inputFileList = kwargs.pop('inputFileList','')
    outputFile = kwargs.pop('outputFile','')
    shift = kwargs.pop('shift','')
    countOnly = kwargs.pop('countOnly',False)
    njobs = kwargs.pop('njobs',1)
    job = kwargs.pop('job',0)
    multi = kwargs.pop('multi',False)
    useProof = kwargs.pop('useProof',False)
    intLumi = kwargs.pop('intLumi',float(getLumi()))
    if hasProgress and multi:
        pbar = kwargs.pop('progressbar',ProgressBar(widgets=['{0}: '.format(sample),' ',SimpleProgress(),' histograms ',Percentage(),' ',Bar(),' ',ETA()]))
    else:
        pbar = None

    if outputFile:
        flat = outputFile
        proj = outputFile.replace('.root','_projection.root')
        flattener = FlattenTree(analysis,sample,inputFileList=inputFileList,flat=flat,proj=proj,shift=shift,countOnly=countOnly,useProof=useProof,intLumi=intLumi)
    else:
        flattener = FlattenTree(analysis,sample,inputFileList=inputFileList,shift=shift,countOnly=countOnly,useProof=useProof,intLumi=intLumi)

    for histName, params in histParams.iteritems():
        flattener.addHistogram(histName,**params)

    for selName, sel in histSelections.iteritems():
        if sel: flattener.addSelection(selName,**sel['kwargs'])

    flattener.flattenAll(progressbar=pbar,njobs=njobs,job=job,multi=multi)
Пример #2
0
def flatten(directory,**kwargs):
    sample = directory.split('/')[-1]
    if hasProgress:
        pbar = kwargs.pop('progressbar',ProgressBar(widgets=['{0}: '.format(sample),' ',SimpleProgress(),' histograms ',Percentage(),' ',Bar(),' ',ETA()]))
    else:
        pbar = None
    eFlatten = FlattenTree(
        ntupleDirectory=sourceDirectory,
        treeName='ETree',
    )
    eFlatten.initializeSample(sample,'flat/Electron/{0}.root'.format(sample))

    for histName, params in histParams.iteritems():
        eFlatten.addHistogram(histName,**params)
    
    promptCut = 'e_genMatch==1 && e_genIsPrompt==1'
    fakeCut = '(e_genMatch==0 || (e_genMatch==1 && e_genIsFromHadron))'
    barrelCut = 'fabs(e_eta)<1.479'
    endcapCut = 'fabs(e_eta)>1.479'
    lowpt = 'e_pt<50'
    highpt = 'e_pt>100'

    eFlatten.addSelection(promptCut)
    eFlatten.addSelection(fakeCut,postfix='fake')
    eFlatten.addSelection(' && '.join([promptCut,barrelCut]),postfix='barrel')
    eFlatten.addSelection(' && '.join([fakeCut,barrelCut]),postfix='barrel_fake')
    eFlatten.addSelection(' && '.join([promptCut,endcapCut]),postfix='endcap')
    eFlatten.addSelection(' && '.join([fakeCut,endcapCut]),postfix='endcap_fake')
    eFlatten.addSelection(' && '.join([promptCut,lowpt]),postfix='lowpt')
    eFlatten.addSelection(' && '.join([fakeCut,lowpt]),postfix='lowpt_fake')
    eFlatten.addSelection(' && '.join([promptCut,highpt]),postfix='highpt')
    eFlatten.addSelection(' && '.join([fakeCut,highpt]),postfix='highpt_fake')

    eFlatten.flattenAll(progressbar=pbar)
def flatten(directory, **kwargs):
    sample = directory.split('/')[-1]
    if hasProgress:
        pbar = kwargs.pop(
            'progressbar',
            ProgressBar(widgets=[
                '{0}: '.format(sample), ' ',
                SimpleProgress(), ' histograms ',
                Percentage(), ' ',
                Bar(), ' ',
                ETA()
            ]))
    else:
        pbar = None
    eFlatten = FlattenTree(
        ntupleDirectory=sourceDirectory,
        treeName='ETree',
    )
    eFlatten.initializeSample(sample, 'flat/Electron/{0}.root'.format(sample))

    for histName, params in histParams.iteritems():
        eFlatten.addHistogram(histName, **params)

    promptCut = 'e_genMatch==1 && e_genIsPrompt==1'
    fakeCut = '(e_genMatch==0 || (e_genMatch==1 && e_genIsFromHadron))'
    barrelCut = 'fabs(e_eta)<1.479'
    endcapCut = 'fabs(e_eta)>1.479'
    lowpt = 'e_pt<50'
    highpt = 'e_pt>100'

    eFlatten.addSelection(promptCut)
    eFlatten.addSelection(fakeCut, postfix='fake')
    eFlatten.addSelection(' && '.join([promptCut, barrelCut]),
                          postfix='barrel')
    eFlatten.addSelection(' && '.join([fakeCut, barrelCut]),
                          postfix='barrel_fake')
    eFlatten.addSelection(' && '.join([promptCut, endcapCut]),
                          postfix='endcap')
    eFlatten.addSelection(' && '.join([fakeCut, endcapCut]),
                          postfix='endcap_fake')
    eFlatten.addSelection(' && '.join([promptCut, lowpt]), postfix='lowpt')
    eFlatten.addSelection(' && '.join([fakeCut, lowpt]), postfix='lowpt_fake')
    eFlatten.addSelection(' && '.join([promptCut, highpt]), postfix='highpt')
    eFlatten.addSelection(' && '.join([fakeCut, highpt]),
                          postfix='highpt_fake')

    eFlatten.flattenAll(progressbar=pbar)