Skip to content

Commit

Permalink
Adjusting stages source example
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Sep 18, 2024
1 parent c142473 commit 93188c1
Showing 1 changed file with 45 additions and 36 deletions.
81 changes: 45 additions & 36 deletions examples/data_source/stages_source.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
# list of processes (mandatory)
processList = {
'p8_ee_WW_ecm240': {'output': 'p8_ee_WW_ecm240_out'}
}

# Production tag when running over EDM4Hep centrally produced events, this
# points to the yaml files for getting sample statistics (mandatory)
prodTag = "FCCee/winter2023/IDEA/"

# Optional: output directory, default is local running directory
outputDir = "."

# Ncpus, default is 4, -1 uses all cores available
# nCPUS = -1

# How to read input files
useDataSource = True

testFile = 'https://fccsw.web.cern.ch/fccsw/testsamples/' \
'edm4hep1/p8_ee_WW_ecm240_edm4hep.root'

# RDFanalysis class where the use defines the operations on the TTree
# (mandatory)
class RDFanalysis():

# analysis function to define the analyzers to process, please make sure
# you return the last dataframe, in this example it is df2
def analysers(df):

df2 = (
df
'''
Analysis example using PODIO ROOT DataSource for reading input files.
'''


class Analysis():
'''
Mandatory class, with three mandatory methods:
* __init__
* analyzers
* output
'''
def __init__(self, _):
# list of processes (mandatory)
self.process_list = {
'p8_ee_WW_ecm240': {'output': 'p8_ee_WW_ecm240_out'}
}

# Production tag when running over EDM4Hep centrally produced events,
# this points to the yaml files for getting sample statistics
# (mandatory)
self.prod_tag = 'FCCee/winter2023/IDEA/'

# Optional: output directory, default is local running directory
self.output_dir = "."

# Ncpus, default is 4, -1 uses all cores available
# self.n_threads = -1

# How to read input files
self.use_data_source = True

self.test_file = 'https://fccsw.web.cern.ch/fccsw/testsamples/' \
'edm4hep1/p8_ee_WW_ecm240_edm4hep.root'

def analyzers(self, dframe):
'''
Analysis function to define the analyzers to process, please make sure
you return the last dataframe, in this example it is dframe2
'''
dframe2 = (
dframe
.Define(
"electron_truth",
"recoParticle::selPDG(11)(MCRecoAssociations)")
Expand All @@ -38,12 +49,10 @@ def analysers(df):
"recoParticle::getPt(electron_truth)")
)

return df2
return dframe2

def output():
branchList = [
def output(self) -> list[str]:
return [
# "electron_truth",
"electron_truth_pt"
]

return branchList

0 comments on commit 93188c1

Please sign in to comment.