ATLAS Offline Software
testAFPDB.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 
5 # file testAFPDB.py
6 # author Petr Balek <petr.balek@cern.ch> (with a lot of inspiration from Tomasz Bold)
7 # date 2021-03-22
8 
9 # brief A script that will test reading from the local DB file. In order to test it:
10 # 0. setup athena enviroment
11 # 1. have the local database; either get it from somewhere else (will be done in future), or create a new one with AFPLocalAlignDBCreate.py:
12 # $ python AFPLocalAlignDBCreate.py
13 # 2. run this script as (feel free to change the input file):
14 # $ python testAFPDB.py --filesInput=/afs/cern.ch/user/p/pbalek/workspace/public/data17_13TeV.00338480.physics_Main.daq.RAW/data17_13TeV.00338480.physics_Main.daq.RAW._lb0275._SFO-7._0007.data
15 # 2a. for another alignment constants, try this input file (n.b.: local constants are the same, only global are different):
16 # $ python testAFPDB.py --filesInput=/afs/cern.ch/user/p/pbalek/workspace/public/data17_13TeV.00333380.physics_Main.daq.RAW/data17_13TeV.00333380.physics_Main.daq.RAW._lb0163._SFO-7._0001.data
17 # 3. the script will read the files and print out alignment variables for the events in the input file (based on run number and LB)
18 
19 # footnote: for the python setup with TopLocRecSeq, see AFP_LocReco/AFP_LocReco.py
20 
21 from AthenaConfiguration.ComponentAccumulator import CompFactory, ComponentAccumulator
22 
23 def testAFPDBCfg(flags):
24  acc = ComponentAccumulator()
25 
26  from IOVDbSvc.IOVDbSvcConfig import addFoldersSplitOnline
27  from IOVDbSvc.IOVDbSvcConfig import addFolders
28 
29  # these are two randomly picked conditions, checked for comparison
30  acc.merge(addFolders(flags, '/CALO/HadCalibration2/CaloEMFrac', 'CALO_ONL', className='CaloLocalHadCoeff', db='CONDBR2'))
31  acc.merge(addFoldersSplitOnline(flags, "INDET", "/Indet/Onl/Beampos", "/Indet/Beampos", className="AthenaAttributeList"))
32 
33 
34  # set from where to read the local information - from DB
35 # acc.merge(addFolders(flags, "/FWD/Onl/AFP/Align/Local", 'FWD_ONL', className='CondAttrListCollection', tag='AFPAlignLoc-02', db="CONDBR2"))
36 # acc.merge(addFolders(flags, "/FWD/Onl/AFP/Align/Global", 'FWD_ONL', className='CondAttrListCollection', tag='AFPAlignGlob-01', db="CONDBR2"))
37 
38  # set from where to read the local information - from local file
39 # schema = "<db>sqlite://;schema=Example.db;dbname=CONDBR2</db>"
40 # locFolder = "/FWD/Onl/AFP/ToFParameters/Local"
41 # locTag = "<tag>AFPToFLoc-01</tag>"
42 # vtxFolder = "/FWD/Onl/AFP/ToFParameters/Vertex"
43 # vtxTag = "<tag>AFPToFVtx-01</tag>"
44 # acc.merge(addFolders(flags, schema+locFolder+locTag, className='CondAttrListCollection', db='CONDBR2' ))
45 # acc.merge(addFolders(flags, schema+vtxFolder+vtxTag, className='CondAttrListCollection', db='CONDBR2' ))
46 #
47 # acc.addCondAlgo(CompFactory.AFPDBTester())
48 
49 
50  # this will read from DB for MC (note that the source file is still data that provides run and LB, thus this is really for testing only)
51  schema = "<db>sqlite://;schema=ExampleMC_Align.db;dbname=OFLP200</db>"
52  locFolder = "/FWD/AFP/Align/Local"
53  locTag = "<tag>AFPMCAlignLoc-329484-02</tag>"
54  globFolder = "/FWD/AFP/Align/Global"
55  globTag = "<tag>AFPMCAlignGlob-331020-01</tag>"
56  acc.merge(addFolders(flags, schema+locFolder+locTag, className='CondAttrListCollection', db='OFLP200' ))
57  acc.merge(addFolders(flags, schema+globFolder+globTag, className='CondAttrListCollection', db='OFLP200' ))
58 
59  schema2 = "<db>sqlite://;schema=ExampleMC_ToF.db;dbname=OFLP200</db>"
60  acc.merge(addFolders(flags, schema2+"/FWD/AFP/ToFParameters/Local", className='CondAttrListCollection', tag='AFPMCToFLoc-ideal-01', db='OFLP200' ))
61  acc.merge(addFolders(flags, schema2+"/FWD/AFP/ToFParameters/Vertex", className='CondAttrListCollection', tag='AFPMCToFVtx-ideal-01', db='OFLP200' ))
62 
63 
64  acc.addCondAlgo(CompFactory.AFPDBTester("AFPDBTester", locshiftXkey="/FWD/AFP/Align/Local", globshiftXkey="/FWD/AFP/Align/Global", locToFkey="/FWD/AFP/ToFParameters/Local", vtxToFkey="/FWD/AFP/ToFParameters/Vertex"))
65 
66 
67 
68  return acc
69 
70 
71 if __name__ == "__main__":
72  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
73  from AthenaConfiguration.AllConfigFlags import initConfigFlags
74  flags = initConfigFlags()
75 
76  #flags.Input.Files = [] # can hardcode file
77  # if you have issues wiht data dependencies and want to debug it
78  flags.Scheduler.CheckDependencies = True
79  flags.Scheduler.ShowDataDeps = True
80  flags.Scheduler.ShowDataFlow = True
81  flags.Scheduler.ShowControlFlow = True
82  flags.Scheduler.EnableVerboseViews = True
83 
84  # more threads and more concurent events; change both to 1 if something goes wrong
85  flags.Concurrency.NumThreads = 3
86  flags.Concurrency.NumConcurrentEvents = 5
87 
88  flags.Exec.MaxEvents = 500
89 
90  # AFP align constants are not included in these (yet)
91  flags.IOVDb.GlobalTag = "CONDBR2-BLKPA-2017-16"
92  from AthenaConfiguration.TestDefaults import defaultGeometryTags
93  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
94 
95  acc = MainServicesCfg(flags)
96  parser = flags.getArgumentParser()
97  args = flags.fillFromArgs(parser=parser)
98 
99  flags.lock()
100 
101 
102  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
103  acc.merge(ByteStreamReadCfg(flags))
104 
105  acc.merge(testAFPDBCfg(flags))
106  from AthenaCommon.Constants import DEBUG, VERBOSE
107  acc.foreach_component("*AFP*").OutputLevel=VERBOSE
108  acc.foreach_component("AFPDBTester").OutputLevel=DEBUG
109  acc.printConfig(withDetails=True, summariseProps=True)
110  acc.run()
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
testAFPDB.testAFPDBCfg
def testAFPDBCfg(flags)
Definition: testAFPDB.py:23
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
python.IOVDbSvcConfig.addFoldersSplitOnline
def addFoldersSplitOnline(flags, detDb, onlineFolders, offlineFolders, className=None, extensible=False, addMCString='_OFL', splitMC=False, tag=None, forceDb=None, modifiers='')
Definition: IOVDbSvcConfig.py:153
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19