ATLAS Offline Software
Loading...
Searching...
No Matches
test_AnalysisBaseEventLoopJob.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2#
3# This script is an example of how to run jet algorithms in AnalysisBase.
4# Jet algs are configured wth the r22 new -style configuration.
5#
6# simply invoke it with
7# python test_AnalysisBaseEventLoopJob.py
8#
9# WARNING : this is experimental. Pay attention to the TEMPORARY comments : these are still needed to run the job.
10import ROOT
11
12ROOT.JetSorter # TEMPORARY : ask ROOT/cppyy to load simple jet tool first. Otherwise loading other tools might result in crash.
13
14
15
16inputFilePath = "/eos/atlas/atlascerngroupdisk/trig-jet/AOD_AthenaMTvalidations/11thRound/ttbar_withPileup/valid1/"
17filePattern = 'AOD.24230077._000510.pool.root.1'
18
19# if the above input file from trigger community disapear, we can use the one below from the tutorials :
20#inputFilePath = '/cvmfs/atlas.cern.ch/repo/tutorials/asg/cern-nov2020/mc16_13TeV.410470.PhPy8EG_A14_ttbar_hdamp258p75_nonallhad.deriv.DAOD_PHYS.e6337_s3126_r10201_p4172/'
21#filePattern = 'DAOD_PHYS.21569875._001323.pool.root.1'
22
23
24#****************************************************
25# the athena-like configuration
26
27# This makes all the Athena config module available :
28import JetRecConfig.JetAnalysisCommon
29
30from JetRecConfig.JetRecConfig import JetRecCfg
31from JetRecConfig.StandardSmallRJets import AntiKt4LCTopo, AntiKt4Truth
32
33
34# TEMPORARY : we need to run a simplistic AnaAlgorithm (and NOT a AnaReentrantAlgorithm like jet algs) as the
35# 1st alg and this alg has to access a ReadHandle. Otherwise AnaReentrantAlgorithm will crash when accessing ReadHandle with "no active event".
36from AthenaConfiguration.ComponentFactory import CompFactory
37aa = CompFactory.TCAlg('AA')
38
39
40# We need to setup the flags according to our input file :
41flags = JetRecConfig.JetAnalysisCommon.setupFlags(inputFiles=[inputFilePath+filePattern])
42
43#*******************************************************************
44# Some flags are not available in AnalysisBase.
45# Add them manually :
46flags.addFlag('Reco.EnableTracking',True)
47flags.addFlag('Reco.EnableCombinedMuon',True)
48
49# Schedule 2 jet containers
50# truth jets :
51acc=JetRecCfg(flags, AntiKt4Truth )
52
53# we re-define AntiKt4LCTopo adding a suffix to the output and the modifiers :
54myAk4LCtopo = AntiKt4LCTopo.clone(suffix="ReDone",
55 modifiers = ('ConstitFourMom', 'CaloEnergies', 'Calib:T0:mc', 'Sort', 'Filter:10000', 'LArHVCorr', 'Width', 'CaloQuality', 'PartonTruthLabel', 'TruthPartonDR', 'JetDeltaRLabel:5000', 'ECPSFrac', 'ClusterMoments')
56 # tracks moments not working yet
57 # 'TrackMoments', 'TrackSumMoments', 'JVF', 'JVT', 'OriginSetPV', 'Charge',
58 )
59
60# generate the config and append it to acc :
61acc.merge(JetRecCfg( flags, myAk4LCtopo ))
62
63# acc contains all the algs (inputs + jet finding) needed. Just set debug mode for the last one :
64acc.algs[-1].OutputLevel = 2
65
66
67
68
69#****************************************************
70# EL::Job configuration
71
72sh = ROOT.SH.SampleHandler()
73sh.setMetaString( 'nc_tree', 'CollectionTree' )
74ROOT.SH.ScanDir().filePattern( filePattern ).scan( sh, inputFilePath )
75
76sh.printContent()
77
78
79job = ROOT.EL.Job()
80job.options().setString( ROOT.EL.Job.optSubmitDirMode, 'unique-link')
81job.sampleHandler( sh )
82job.options().setDouble( ROOT.EL.Job.optMaxEvents, 5 )
83
84
85
86job.addManyAlgs( [aa] ) # TEMPORARY : schedule the simplistic alg first
87# schedule our jet algs to the EL job.
88job.addManyAlgs( acc )
89
90
91# Run the job using the direct driver.
92driver = ROOT.EL.DirectDriver()
93driver.submit( job, "out")
void scan(TDirectory *td=0, int depth=0)
Definition listroot.cxx:440