ATLAS Offline Software
runegammaMonitoring.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration.
4 
5 # Cut-and-paste from RunHitAnalysis.py
6 
7 import sys
8 import os
9 
10 from argparse import ArgumentParser
11 
12 # Argument parsing
13 parser = ArgumentParser("egammaMonitoring")
14 parser.add_argument("-m", "--maxEvents", default=60000, type=int,
15  help="The number of events to run. -1 runs all events.")
16 parser.add_argument("-p", "--particleType", default='electron', type=str,
17  help="The particle type. electron or gamma")
18 parser.add_argument("-fwd", "--addFwd", default='False', type=str,
19  help="Also run on fwd electrons")
20 parser.add_argument("-i", "--inputFiles", default='Nightly_AOD.pool.root',
21  help='Comma separated list of input AOD files')
22 parser.add_argument("-o", "--outputFileName", default='Nightly-monitoring.hist', type=str,
23  help="The output file name")
24 
25 args = parser.parse_args()
26 
27 addFwd = True if args.addFwd == 'True' else False
28 if args.particleType == 'gamma' and addFwd:
29  print('Fwd electrons can only be read in an electron run')
30  addFwd = False
31 
32 # Configure
33 from AthenaConfiguration.AllConfigFlags import initConfigFlags
34 from AthenaConfiguration.Enums import ProductionStep
35 flags = initConfigFlags()
36 flags.Common.ProductionStep = ProductionStep.Simulation
37 isDir = os.path.isdir(args.inputFiles)
38 if isDir:
39  flags.Input.Files = [ args.inputFiles + '/' + f for f in os.listdir(args.inputFiles) ]
40 else:
41  flags.Input.Files = [ f for f in args.inputFiles.split(',') ]
42 from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
43 setupDetectorFlags(flags, ['LAr','Tile'], use_metadata=True, toggle_geometry=True)
44 # to be checked. Without this, I got
45 #DataProxy WARNING accessData: conversion failed for data object 254546453//LAR/Align
46 # Returning NULL DataObject pointer
47 #GeoModelSvc.LAr... ERROR Could not retrieve LAr DetCondKeyTrans
48 flags.LAr.doAlign = False
49 flags.GeoModel.Align.LegacyConditionsAccess = False
50 flags.lock()
51 
52 # Construct our accumulator to run
53 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
54 acc = MainServicesCfg(flags)
55 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
56 acc.merge(LArGMCfg(flags))
57 from TileGeoModel.TileGMConfig import TileGMCfg
58 acc.merge(TileGMCfg(flags))
59 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
60 acc.merge(PoolReadCfg(flags))
61 from egammaValidation.egammaMonitoringConfig import egammaMonitoringCfg
62 acc.merge(egammaMonitoringCfg(flags,\
63  particleType = args.particleType, \
64  outputFileName = args.outputFileName, \
65  addFwd = addFwd))
66 
67 # Execute and finish
68 sc = acc.run(maxEvents=args.maxEvents)
69 
70 # Success should be 0
71 sys.exit(not sc.isSuccess())
72 
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.DetectorConfigFlags.setupDetectorFlags
def setupDetectorFlags(flags, custom_list=None, use_metadata=False, toggle_geometry=False, validate_only=False, keep_beampipe=False)
Definition: DetectorConfigFlags.py:289
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
egammaMonitoringConfig.egammaMonitoringCfg
def egammaMonitoringCfg(flags, particleType='electron', outputFileName='Nightly-monitoring.hist', addFwd=False)
Definition: egammaValidation/python/egammaMonitoringConfig.py:6
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7