def test_tfile(self): config = cfg.Service(TFileService, 'myhists', fname = 'histos.root', option = 'recreate') dummy = None dirname = 'test_dir' if os.path.exists(dirname): shutil.rmtree(dirname) os.mkdir(dirname) fileservice = TFileService(config, dummy, dirname) fileservice.start() fileservice.stop() shutil.rmtree(dirname)
for comp in selectedComponents: comp.splitFactor = 600 comp.files = comp.files[:] #comp.files = comp.files[:1] #comp.files = comp.files[57:58] # to process only file [57] #comp.triggers = triggers_HT900 + triggers_HTMET # to apply trigger skimming # ------------------------------------------------------------------------------------------- # from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service( TFileService, 'outputfile', name="outputfile", fname='mt2.root', option='recreate' ) # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events from CMGTools.TTHAnalysis.tools.EOSEventsWithDownload import EOSEventsWithDownload event_class = EOSEventsWithDownload if getHeppyOption("nofetch"): event_class = Events config = cfg.Config( components = selectedComponents, sequence = sequence, services = [output_service], events_class = event_class) # events_class = Events)
monoJetCtrlLepSkim.minLeptons = 2 else: selectedComponents = dataSamples742 for comp in selectedComponents: comp.splitFactor = 1 comp.fineSplitFactor = 1 if getHeppyOption("single") else 6 if not getHeppyOption("all"): comp.files = comp.files[:1] ## output histogram outputService=[] from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service( TFileService, 'outputfile', name="outputfile", fname='treeProducerDarkMatterMonoJet/tree.root', option='recreate' ) outputService.append(output_service) # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events from CMGTools.TTHAnalysis.tools.EOSEventsWithDownload import EOSEventsWithDownload event_class = EOSEventsWithDownload if getHeppyOption("nofetch"): event_class = Events config = cfg.Config( components = selectedComponents, sequence = sequence, services = outputService, events_class = event_class)
243541 ] # for i, row in enumerate(reader): # evtsToPick += [int(j) for j in row] eventSelector.toSelect = evtsToPick sequence.insert(0, eventSelector) # # output histogram outputService = [] if doSUSY: from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service(TFileService, 'outputfile', name="outputfile", fname='H2TauTauTreeProducerTauTau/tree.root', option='recreate') outputService.append(output_service) ################################################### ### SET BATCH OR LOCAL ### ################################################### if not production: comp = data_list[0] if data else sync_list[0] # comp = SMS # comp = samples_susy[1] selectedComponents = [comp] comp.splitFactor = 4 comp.fineSplitFactor = 1 # comp.files = comp.files[13:20]
ttHLepSkim.minLeptons = 0 sequence.remove(jsonAna) # preprocessor cfg to be created with # cmsDriver.py miniAOD-data -s PAT --data --runUnscheduled --eventcontent MINIAOD --conditions GR_P_V56 --no_exec # sed -i 's/process.MINIAODoutput_step/process.endpath/' miniAOD-data_PAT.py from PhysicsTools.Heppy.utils.cmsswPreprocessor import CmsswPreprocessor preprocessor = CmsswPreprocessor("miniAOD-data_PAT.py") ## output histogram outputService=[] from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service( TFileService, 'outputfile', name="outputfile", fname='treeProducerSusyMultilepton/tree.root', option='recreate' ) outputService.append(output_service) # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events from CMGTools.TTHAnalysis.tools.EOSEventsWithDownload import EOSEventsWithDownload event_class = EOSEventsWithDownload if not preprocessor else Events EOSEventsWithDownload.aggressive = 2 # always fetch if running on Wigner if getHeppyOption("nofetch"): event_class = Events if preprocessor: preprocessor.prefetch = False config = cfg.Config( components = selectedComponents, sequence = sequence,
if not isSignal: sequence.remove(susyScanAna) #remove all skims for signal if isSignal: sequence.remove(anyLepSkim) sequence.remove(ttHHTSkimmer) sequence.remove(ttHSTSkimmer) sequence.remove(eventFlagsAna) ## output histogram outputService = [] from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service( TFileService, 'outputfile', name="outputfile", fname='treeProducerSusySingleLepton/tree.root', #fname='susyCounter/counts.root', option='recreate') outputService.append(output_service) from PhysicsTools.Heppy.utils.cmsswPreprocessor import CmsswPreprocessor preprocessor = None if cmssw: fname = "$CMSSW_BASE/src/CMGTools/SUSYAnalysis/cfg/runBTaggingSlimPreprocessor_cfg.py" jetAna.jetCol = 'selectedUpdatedPatJets' # fname = "$CMSSW_BASE/src/CMGTools/SUSYAnalysis/cfg/MetType1_jec_Spring16_25nsV6_MC.py" preprocessor = CmsswPreprocessor(fname) #, addOrigAsSecondary=False) print "running" from PhysicsTools.HeppyCore.framework.eventsfwlite import Events
if runOnSignal and not signalZ: if ttHLepSkim in sequence: sequence.remove(ttHLepSkim) if triggerAna in sequence: sequence.remove(triggerAna) if genAna in sequence: genAna.saveAllInterestingGenParticles = True ## Auto-AAA if not getHeppyOption("isCrab"): autoAAA(selectedComponents) ## output histogram outputService = [] from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service(TFileService, 'outputfile', name="outputfile", fname='treeProducerWMass/tree.root', option='recreate') outputService.append(output_service) # print summary of components to process printSummary(selectedComponents) # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events from CMGTools.TTHAnalysis.tools.EOSEventsWithDownload import EOSEventsWithDownload event_class = EOSEventsWithDownload if not preprocessor else Events EOSEventsWithDownload.aggressive = 2 # always fetch if running on Wigner if getHeppyOption("nofetch") or getHeppyOption("isCrab"): event_class = Events if preprocessor: preprocessor.prefetch = False
#replace some parameters LepAna.loose_muon_pt = 10 sequence = [ LHEAna, FlagsAna, GenAna, PUAna, TrigAna, VertexAna, LepAna, TauAna, PhoAna, JetAna, METAna, treeProducer, treeProducer2, treeProducer3 ] #use tfile service to provide a single TFile to all modules where they #can write any root object. If the name is 'outputfile' or the one specified in treeProducer #also the treeProducer uses this file from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service(TFileService, 'outputfile', name="outputfile", fname='tree.root', option='recreate') output_service2 = cfg.Service(TFileService, 'genonlyfile', name="genonlyfile", fname='treegen.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() print "Running on test file %s" % testfiles sample = cfg.MCComponent(
from PhysicsTools.HeppyCore.analyzers.Printer import Printer printer = cfg.Analyzer(Printer) from PhysicsTools.HeppyCore.analyzers.SimpleTreeProducer import SimpleTreeProducer tree = cfg.Analyzer(SimpleTreeProducer, tree_name='tree', tree_title='A test tree') from PhysicsTools.HeppyCore.analyzers.Histogrammer import Histogrammer histos = cfg.Analyzer(Histogrammer, file_label='myhists') # definition of a sequence of analyzers, # the analyzers will process each event in this order sequence = cfg.Sequence([printer, tree, histos]) from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_rootfile = cfg.Service(TFileService, 'myhists', fname='histograms.root', option='recreate') services = [output_rootfile] # finalization of the configuration object. config = cfg.Config(components=selectedComponents, sequence=sequence, services=services, events_class=Events) # print config
if len(good_samp) != 1: raise Exception( "Need to specify at least one sample: dataset={0}, subfiles={1}, good_samp={2}" .format(dataset, fns, good_samp)) assert (len(good_samp) == 1) print 'Running over sample: {0}'.format(good_samp) 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.
NTupleCollection("gen_jet", genParticleType, 20, help="generated jets after selection"), # "matched_b_jets" : NTupleCollection("gen_jets_b", genJetType, 8, help="gen-jets matched to b-quarks"), # "matched_q_jets" : NTupleCollection("gen_jets_q", genJetType, 8, help="gen-jets matched to light quarks"), # "unmatched_jets" : NTupleCollection("gen_jets_unmatched", genJetType, 8, help="gen-jets not matched to quarks"), }, ) sequence = cfg.Sequence( [event_ana, genquark_ana, genjet_ana, mem_ana, outs_ana, treeProducer]) from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service(TFileService, 'outputfile', fname='tree.root', option='recreate') if os.environ.has_key("FILE_NAMES"): fns = os.environ["FILE_NAMES"].split() fns = map(getSitePrefix, fns) dataset = os.environ["DATASETPATH"] firstEvent = int(os.environ["SKIP_EVENTS"]) nEvents = int(os.environ["MAX_EVENTS"]) elif os.environ.get("SAMPLE", "tth") == "tth": fns = map(getSitePrefix, [ "/store/user/jpata/tth/Sep29_v1/ttHTobb_M125_TuneCUETP8M2_ttHtranche3_13TeV-powheg-pythia8/Sep29_v1/160930_103104/0000/tree_1.root" ]) dataset = "ttHTobb_M125_TuneCUETP8M2_ttHtranche3_13TeV-powheg-pythia8" firstEvent = 0 nEvents = 100
# test all components (1 thread per component). for comp in selectedComponents: comp.splitFactor = 1 comp.fineSplitFactor = 4 comp.files = comp.files[:5] elif test == '5b': # test all components (1 thread per component). for comp in selectedComponents: comp.splitFactor = 1 comp.fineSplitFactor = 2 comp.files = comp.files[5:20] from PhysicsTools.HeppyCore.framework.services.tfile import TFileService output_service = cfg.Service(TFileService, 'outputfile', name="outputfile", fname='treeProducerSusyGenLevelOnly/tree.root', option='recreate') # the following is declared in case this cfg is used in input to the heppy.py script from PhysicsTools.HeppyCore.framework.eventsfwlite import Events from CMGTools.TTHAnalysis.tools.EOSEventsWithDownload import EOSEventsWithDownload event_class = EOSEventsWithDownload EOSEventsWithDownload.aggressive = 2 # always fetch if getHeppyOption("nofetch"): event_class = Events config = cfg.Config(components=selectedComponents, sequence=sequence, services=[output_service], events_class=event_class)