Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:30

0001 import os
0002 import PhysicsTools.HeppyCore.framework.config as cfg
0003 from PhysicsTools.HeppyCore.framework.chain import Chain as Events
0004 import logging
0005 logging.basicConfig(level=logging.INFO)
0006 
0007 # input component 
0008 # several input components can be declared,
0009 # and added to the list of selected components
0010 inputSample = cfg.Component(
0011     'test_component',
0012     # create the test file by running
0013     # python create_tree.py
0014     files = [os.path.abspath('test_tree.root')],
0015     )
0016 
0017 selectedComponents  = [inputSample]
0018 
0019 from PhysicsTools.HeppyCore.analyzers.Printer import Printer
0020 printer = cfg.Analyzer(
0021     Printer
0022     )
0023 
0024 from PhysicsTools.HeppyCore.analyzers.SimpleTreeProducer import SimpleTreeProducer
0025 tree = cfg.Analyzer(
0026     SimpleTreeProducer,
0027     tree_name = 'tree',
0028     tree_title = 'A test tree'
0029     )
0030 
0031 from PhysicsTools.HeppyCore.analyzers.Histogrammer import Histogrammer
0032 histos = cfg.Analyzer(
0033     Histogrammer,
0034     file_label = 'myhists'
0035 )
0036 
0037 # definition of a sequence of analyzers,
0038 # the analyzers will process each event in this order
0039 sequence = cfg.Sequence( [
0040     printer,
0041     tree,
0042     histos
0043     ] )
0044 
0045 from PhysicsTools.HeppyCore.framework.services.tfile import TFileService
0046 output_rootfile = cfg.Service(
0047     TFileService,
0048     'myhists',
0049     fname='histograms.root',
0050     option='recreate'
0051 )
0052 
0053 services = [output_rootfile]
0054 
0055 # finalization of the configuration object. 
0056 config = cfg.Config( components = selectedComponents,
0057                      sequence = sequence,
0058                      services = services, 
0059                      events_class = Events )
0060 
0061 # print config