Exemplo n.º 1
0
 def prepareInputSamples(sampleFile=conf.general["sampleFile"]):
     print "loading samples from", sampleFile
     samplefile = imp.load_source("samplefile", sampleFile)
     from samplefile import samples_dict
     inputSamples = []
     for sn in sorted(samples_dict.keys()):
         s = samples_dict[sn]
         inputSample = cfg.Component(
             s.name.value(),
             files=map(getSitePrefix, s.subFiles.value()),
             tree_name=s.treeName.value(),
         )
         inputSample.isMC = s.isMC.value()
         inputSamples.append(inputSample)
     return inputSamples, samples_dict
Exemplo n.º 2
0
import os
import PhysicsTools.HeppyCore.framework.config as cfg

# input component
# several input components can be declared,
# and added to the list of selected components
inputSample = cfg.Component(
    'some_aodsim',
    # files = ['ee_qq_py_GEN_SIM_RECO.root'],
    files=['gun_22_0.0to50.0_ME0_GEN_SIM_RECO.root']
    # files = ['pp_qqbar_30_GEN_SIM_RECO.root'],
)

selectedComponents = [inputSample]

from Colin.PFSim.analyzers.CMSReader import CMSReader

reader = cfg.Analyzer(CMSReader,
                      gen_particles='genParticles',
                      pf_particles='particleFlow')

from Colin.PFSim.analyzers.PFSim import PFSim

pfsim = cfg.Analyzer(PFSim, display=True, verbose=False)

from Colin.PFSim.analyzers.JetClusterizer import JetClusterizer

jets = cfg.Analyzer(JetClusterizer,
                    instance_label='rec',
                    particles='particles')
from PhysicsTools.HeppyCore.framework.services.tfile import TFileService
output_service = cfg.Service(TFileService,
                             'outputfile',
                             name="outputfile",
                             fname='tree.root',
                             option='recreate')

# the following two lines are just for automatic testing
# they are not needed for running on your own samples
from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles
testfiles = miniAodFiles()

sample = cfg.Component(
    #specify the file you want to run on
    #    files = ["/scratch/arizzi/Hbb/CMSSW_7_2_2_patch2/src/VHbbAnalysis/Heppy/test/ZLL-8A345C56-6665-E411-9C25-1CC1DE04DF20.root"],
    files=testfiles,
    name="SingleSample",
    isMC=False,
    isEmbed=False)

from PhysicsTools.Heppy.utils.cmsswPreprocessor import CmsswPreprocessor
preprocessor = CmsswPreprocessor("makeAK5Jets.py")

# the following is declared in case this cfg is used in input to the heppy.py script
from PhysicsTools.HeppyCore.framework.eventsfwlite import Events
selectedComponents = [sample]
config = cfg.Config(
    components=selectedComponents,
    sequence=sequence,
    services=[output_service],
    preprocessor=
Exemplo n.º 4
0
                             'outputfile',
                             name="outputfile",
                             fname='tree.root',
                             option='recreate')

##############################
### INPUT                  ###
##############################
from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles
from DMPD.Heppy.samples.Phys14.fileLists import samples

sampleTest = cfg.Component(
    files=[
        "file:/lustre/cmswork/zucchett/CMSSW_7_2_0_patch1/src/ZZhToLLM1000/MINIAODSIM.root"
    ],
    #files = ["dcap://t2-srm-02.lnl.infn.it/pnfs/lnl.infn.it/data/cms//store/mc/Phys14DR/DYJetsToLL_M-50_HT-100to200_Tune4C_13TeV-madgraph-tauola/MINIAODSIM/PU20bx25_PHYS14_25_V1-v1/00000/021C8316-1E71-E411-8CBD-0025901D484C.root"],
    name="Test",
    isMC=True,
    isEmbed=False,
    splitFactor=1)

sampleQCD_HT100To250 = cfg.Component(
    ### QCD
    files=samples['QCD_HT100To250']['files'],
    name="QCD_HT100To250",
    isMC=True,
    isEmbed=False,
    splitFactor=16)

sampleQCD_HT250To500 = cfg.Component(
    ### QCD
Exemplo n.º 5
0
import os
import PhysicsTools.HeppyCore.framework.config as cfg
from PhysicsTools.HeppyCore.framework.chain import Chain as Events
from PhysicsTools.HeppyCore.analyzers.Printer import Printer
from PhysicsTools.HeppyCore.analyzers.SimpleTreeProducer import SimpleTreeProducer

# input component
# several input components can be declared,
# and added to the list of selected components
inputSample = cfg.Component(
    'test_component',
    # create the test file by running
    # python create_tree.py
    files=[os.path.abspath('test_tree.root')],
)

selectedComponents = [inputSample]

printer = cfg.Analyzer(Printer)

tree = cfg.Analyzer(SimpleTreeProducer,
                    tree_name='tree',
                    tree_title='A test tree')

# definition of a sequence of analyzers,
# the analyzers will process each event in this order
sequence = cfg.Sequence([printer, tree])

# finalization of the configuration object.
config = cfg.Config(components=selectedComponents,
                    sequence=sequence,
Exemplo n.º 6
0
from PhysicsTools.Heppy.analyzers.objects.TauAnalyzer import TauAnalyzer

TauAna = TauAnalyzer.defaultConfig

from PhysicsTools.Heppy.analyzers.objects.JetAnalyzer import JetAnalyzer

JetAna = JetAnalyzer.defaultConfig

sequence = [VertexAna, LepAna, TauAna, PhoAna, JetAna, treeProducer]

from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles

sample = cfg.Component(
    # files = "/scratch/arizzi/heppy/CMSSW_7_2_0_pre8/src/PhysicsTools/Heppy/test/E21AD523-E548-E411-8DF6-00261894388F.root",
    files=miniAodFiles(),
    name="ATEST",
    isMC=False,
    isEmbed=False)

# the following is declared in case this cfg is used in input to the heppy.py script
selectedComponents = [sample]
from PhysicsTools.HeppyCore.framework.eventsfwlite import Events

config = cfg.Config(components=selectedComponents,
                    sequence=sequence,
                    events_class=Events)

# and the following runs the process directly
if __name__ == '__main__':
    from PhysicsTools.HeppyCore.framework.looper import Looper
    looper = Looper('Loop', sample, sequence, Events, nPrint=5)
Exemplo n.º 7
0
import PhysicsTools.HeppyCore.framework.config as cfg
from DMPD.Heppy.samples.Data.fileLists import datasamples

sampleSingleMuon_Run2015B_17Jul2015_v1 = cfg.Component(
    files=datasamples["SingleMuon_Run2015B_17Jul2015_v1"]["files"],
    name="SingleMuon_Run2015B_17Jul2015_v1",
    splitFactor=20,
)

sampleSingleMuon_Run2015B_PromptReco_v1 = cfg.Component(
    files=datasamples["SingleMuon_Run2015B_PromptReco_v1"]["files"],
    name="SingleMuon_Run2015B_PromptReco_v1",
    splitFactor=20,
)

sampleSingleElectron_Run2015B_17Jul2015_v1 = cfg.Component(
    files=datasamples["SingleElectron_Run2015B_17Jul2015_v1"]["files"],
    name="SingleElectron_Run2015B_17Jul2015_v1",
    splitFactor=20,
)

sampleSingleElectron_Run2015B_PromptReco_v1 = cfg.Component(
    files=datasamples["SingleElectron_Run2015B_PromptReco_v1"]["files"],
    name="SingleElectron_Run2015B_PromptReco_v1",
    splitFactor=20,
)

sampleDoubleMuon_Run2015B_17Jul2015_v1 = cfg.Component(
    files=datasamples["DoubleMuon_Run2015B_17Jul2015_v1"]["files"],
    name="DoubleMuon_Run2015B_17Jul2015_v1",
    splitFactor=20,
Exemplo n.º 8
0
import os
import PhysicsTools.HeppyCore.framework.config as cfg
from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles

# input component
# several input components can be declared,
# and added to the list of selected components
inputSample = cfg.Component(
    'test_component',
    files=miniAodFiles(),
)
inputSample.isMC = True
inputSample.splitFactor = 2

selectedComponents = [inputSample]

from PhysicsTools.Heppy.analyzers.examples.SimpleJetAnalyzer import SimpleJetAnalyzer
jets = cfg.Analyzer(SimpleJetAnalyzer, 'jets', ptmin=30.)

from PhysicsTools.Heppy.analyzers.examples.SimpleTreeAnalyzer import SimpleTreeAnalyzer
tree = cfg.Analyzer(SimpleTreeAnalyzer)

# definition of a sequence of analyzers,
# the analyzers will process each event in this order
sequence = cfg.Sequence([jets, tree])

# finalization of the configuration object.
from PhysicsTools.HeppyCore.framework.eventsfwlite import Events
config = cfg.Config(components=selectedComponents,
                    sequence=sequence,
                    services=[],
Exemplo n.º 9
0
    print "Running tth code"
    import cPickle as pickle
    import TTH.MEAnalysis.TFClasses as TFClasses
    sys.modules["TFClasses"] = TFClasses
    os.environ["ME_CONF"] = os.environ[
        "CMSSW_BASE"] + "/python/TTH/MEAnalysis/" + me_conf_name
    handle = open("MEAnalysis_heppy.py", 'r')
    cfo2 = imp.load_source("heppy_config", "MEAnalysis_heppy.py", handle)
    config = cfo2.config
    from TTH.MEAnalysis.MEAnalysis_cfg_heppy import conf_to_str
    print "MEM config", conf_to_str(cfo2.conf)
    config.components = [
        cfg.Component(
            "dummy",
            files=["Output/tree.root"],
            tree_name="tree",
            n_gen=1,
            xs=1,
        )
    ]
    config.components[0].isMC = cfo.sample.isMC

    if not cfo.sample.isMC:
        from TTH.MEAnalysis.VHbbTree_data import EventAnalyzer
        evs = cfg.Analyzer(
            EventAnalyzer,
            'events',
        )
        config.sequence[2] = evs
    looper = Looper('Output_tth', config, nPrint=0)
    looper.loop()
Exemplo n.º 10
0
outFileName = os.environ["GC_SCRATCH"] + "/output.root"

import PhysicsTools.HeppyCore.framework.config as cfg
from PhysicsTools.HeppyCore.framework.services.tfile import TFileService
output_service = cfg.Service(TFileService,
                             'outputfile',
                             name="outputfile",
                             fname="tree.root",
                             option='recreate')

inputSamples = []
for sn, s in samples_dict.items():
    inputSample = cfg.Component('tth',
                                files=s.subFiles.value(),
                                tree_name=s.treeName.value(),
                                n_gen=1.0,
                                xs=1.0)
    inputSample.isMC = s.isMC.value()
    if s.skip.value() == False:
        inputSamples.append(inputSample)

#finalization of the configuration object.
from PhysicsTools.HeppyCore.framework.chain import Chain as Events
config = cfg.Config(
    #Run across these inputs
    components=inputSamples,

    #Using this sequence
    sequence=sequence,
Exemplo n.º 11
0
##############################
from PhysicsTools.Heppy.utils.miniAodFiles import miniAodFiles
from DMPD.Heppy.samples.Spring15.fileLists import mcsamples
from DMPD.Heppy.samples.Data.fileLists import datasamples

maxlsftime = 5  # in hours
eventspersec = 5  # in ev/s

sample = {}
for i in datasamples:
    if int(datasamples[i]['nevents']) < 1: continue
    sample[i] = cfg.Component(
        files=datasamples[i]['files'],
        name=i,
        json=
        '%s/src/DMPD/Heppy/python/tools/JSON/Cert_246908-260627_13TeV_PromptReco_Collisions15_25ns_JSON.txt'
        % os.environ['CMSSW_BASE'],
        splitFactor=int(datasamples[i]['nevents'] /
                        (maxlsftime * 3600 * eventspersec)),
    )

for i in mcsamples:
    if int(mcsamples[i]['nevents']) < 1: continue
    #print i, " - ", int(mcsamples[i]['nevents']/(maxlsftime*3600*eventspersec))
    sample[i] = cfg.MCComponent(
        files=mcsamples[i]['files'],
        name=i,
        isMC=True,
        isEmbed=False,
        splitFactor=int(mcsamples[i]['nevents'] /
                        (maxlsftime * 3600 * eventspersec)),
Exemplo n.º 12
0
    from TTH.MEAnalysis.MEAnalysis_cfg_heppy import conf_to_str
    print "MEM config", conf_to_str(cfo.conf)

    #replace files with crab ones
    #Also get the correct sample (xsec) based on the file name
    #config.components[0].files=[rootfilename]
    sampleName = findSampleName(rootfilename)
    sample = cfo.samples_dict[sampleName]
    sample.subFiles = [rootfilename]
    print "Running over sample", sample
    config.components = [
        cfg.Component(
            sample.name.value(),
            files=[rootfilename],
            tree_name="tree",
            n_gen=sample.nGen.value(),
            xs=sample.xSec.value(),
        )
    ]
    #need to set isMC like this for heppy to find it
    config.components[0].isMC = sample.isMC.value()

    from PhysicsTools.HeppyCore.framework.looper import Looper
    print "processing", rootfilename, firstEvent, nEvents
    #Run over all events in file
    if nEvents < 0:
        nEvents = None
    looper = Looper('Output',
                    config,
                    nPrint=0,
Exemplo n.º 13
0
import os
#import heppy.framework.config as cfg
import PhysicsTools.HeppyCore.framework.config as cfg
import logging

logging.basicConfig(level=logging.INFO)

# input component
# several input components can be declared,
# and added to the list of selected components

inputSample = cfg.Component(
    'test_component',
    # create the test file by running
    # python create_tree.py
    files=[],
)

selectedComponents = [inputSample]

# use a simple event reader based on the ROOT TChain class
#from heppy.framework.chain import Chain as Events
from PhysicsTools.HeppyCore.framework.chain import Chain as Events

# add a random variable to the event
#from heppy.analyzers.examples.simple.RandomAnalyzer import RandomAnalyzer
from PhysicsTools.Heppy.analyzers.examples.SimpleTreeAnalyzer import ZJetsTreeAnalyzer as RandomAnalyzer

random = cfg.Analyzer(RandomAnalyzer)

# just print a variable in the input test tree