ATLAS Offline Software
Loading...
Searching...
No Matches
python.BeamSpotUpdate Namespace Reference

Classes

class  BeamSpotWriteAlg
class  Config

Functions

 setBeamSpot (run, lb, x, y, z, status=7, dbname='sqlite://;schema=beampos.db;dbname=CONDBR2', tag='IndetBeamposOnl-HLT-UPD1-001-00')
 addFolderUpdate (event)
 modify (event)
 setup ()
 run (flags)

Variables

list folderList = []
 log = logging.getLogger(__name__)
 parser = argparse.ArgumentParser(description=__doc__)
 metavar
 nargs
 help
 type
 int
 default
 str
 args = parser.parse_args()
 dr = EventStorage.pickDataReader(args.file[0])
 output
int i = 0
 newevt = modify(event)

Detailed Description

Module to test beamspot updates using a local sqlite file. Two steps are necessary:

1) Create a modified bytestream file that contains the correct COOL update information
   in the CTP fragment. To do this simply run this script with a RAW file and it will
   write a modified file into the current directory with beamspot updates on LBs as
   specified in Config.lb_updateBeamspot.

2) Configure a job with the BeamSpotWriteAlg in the topSequence. This algorithm will
   write a new beamspot into the sqlite file one LB before the actual update is
   triggered via the CTP fragment. See TrigP1Test/python/BeamSpotReader.py
   for an example.

Function Documentation

◆ addFolderUpdate()

python.BeamSpotUpdate.addFolderUpdate ( event)
Add COOL folder update to event

Definition at line 78 of file BeamSpotUpdate.py.

78def addFolderUpdate(event):
79 """Add COOL folder update to event"""
80
81 ctp_robs = [rob for rob in event if rob.source_id().subdetector_id()==eformat.helper.SubDetector.TDAQ_CTP]
82
83 if len(ctp_robs)==0:
84 log.error("Cannot find CTP ROB in event")
85 return event
86
87 # Copy event except CTP ROBs
88 new_event = eformat.write.FullEventFragment()
89 new_event.copy_header(event)
90 for r in event:
91 if r.source_id().subdetector_id() != eformat.helper.SubDetector.TDAQ_CTP:
92 new_event.append(eformat.write.ROBFragment(r))
93
94 # Set the CTP extra payload
95 for rob in ctp_robs:
96 x = CTPfragment.ExtraPayload() # start from empty payload object
97 for f in folderList: x.updateFolder(f)
98 new_ctp_rob = CTPfragment.setHltExtraPayloadWords(rob, [d for d in x.serialize()])
99 new_event.append(eformat.write.ROBFragment(new_ctp_rob))
100
101 return new_event
102
103

◆ modify()

python.BeamSpotUpdate.modify ( event)

Definition at line 104 of file BeamSpotUpdate.py.

104def modify(event):
105 event = eformat.write.FullEventFragment(event)
106
107 # Modify LB and HLT counter in CTP fragment
108 newevt = trigbs_modifyEvent.modify(event)
109 lb = newevt.lumi_block()
110
111 # Write conditions update into CTP fragment
112 if lb in Config.lb_updateBeamspot:
113 lb_for_update,status = Config.lb_updateBeamspot.pop(lb)
114
115 fe = CTPfragment.FolderEntry()
116 fe.folderIndex = 0 # /Indet/Onl/Beampos
117 fe.lumiBlock = lb_for_update
118 folderList.append(fe)
119 log.info('Added COOL folder update to event: folderIndex=%d, LB=%d', fe.folderIndex,fe.lumiBlock)
120
121 return addFolderUpdate(newevt).readonly()
122
123

◆ run()

python.BeamSpotUpdate.run ( flags)
CA cfg function to be used from athenaHLT

Definition at line 139 of file BeamSpotUpdate.py.

139def run(flags):
140 """CA cfg function to be used from athenaHLT"""
141
142 from AthenaCommon.Constants import DEBUG
143 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
144 from AthenaConfiguration.ComponentFactory import CompFactory
145 from IOVDbSvc.IOVDbSvcConfig import addFolders
146
147 from pathlib import Path
148
149 flags.lock()
150 cfg = ComponentAccumulator()
151
152 # addFolders requires at least an empty sqlite file
153 Path('beampos.db').touch()
154
155 # These folders are filled in Testing/condStopStart.trans
156 cfg.merge( addFolders(flags, '/Indet/Onl/Beampos <key>/Indet/Beampos</key>',
157 detDb='beampos.db',
158 tag='IndetBeamposOnl-HLT-UPD1-001-00',
159 className='AthenaAttributeList',
160 extensible=True) )
161
162 cfg.addEventAlgo( BeamSpotWriteAlg() )
163 cfg.addEventAlgo( CompFactory.InDet.InDetBeamSpotReader(VxContainer = "") )
164 cfg.addCondAlgo( CompFactory.BeamSpotCondAlg(OutputLevel = DEBUG) )
165
166 return cfg
167
168
169# For standalone running and writing a new output file
Definition run.py:1

◆ setBeamSpot()

python.BeamSpotUpdate.setBeamSpot ( run,
lb,
x,
y,
z,
status = 7,
dbname = 'sqlite://;schema=beampos.db;dbname=CONDBR2',
tag = 'IndetBeamposOnl-HLT-UPD1-001-00' )

Definition at line 62 of file BeamSpotUpdate.py.

65 tag='IndetBeamposOnl-HLT-UPD1-001-00'):
66
67 log.info('============================= Creating new beamspot in COOL ===================================')
68 log.info('run=%d, lb=%d, x=%f, y=%f, z=%f', run, lb, x, y, z)
69 sys.stdout.flush()
70 os.system("beamSpotOnl_set.py --output=sqlite:beampos.db --run=%d --lbn=%d %d %f %f %f" % (run,lb,status,x,y,z))
71 if log.level<=logging.DEBUG:
72 log.info('Current content of beampos.db sqlite file:')
73 os.system("AtlCoolConsole.py 'sqlite://;schema=beampos.db;dbname=CONDBR2' <<< 'more Indet/Onl/Beampos'")
74 log.info('===============================================================================================')
75 sys.stdout.flush()
76
77

◆ setup()

python.BeamSpotUpdate.setup ( )
Initial setup

Definition at line 124 of file BeamSpotUpdate.py.

124def setup():
125 """Initial setup"""
126
127 log.info('Will perform beamspot udpate on these LBs (LB,status): %s', sorted(Config.lb_updateBeamspot.values()))
128
129 # Delete any previous sqlite file
130 try:
131 os.remove('beampos.db')
132 except OSError:
133 pass
134
135 # Create an open-ended IOV with a default beamspot
136 setBeamSpot(1,0,0.06,1.06,-4.6,4)
137
138
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile="")
mostly useful for athena, which will otherwise re-use the previous tool

Variable Documentation

◆ args

python.BeamSpotUpdate.args = parser.parse_args()

Definition at line 179 of file BeamSpotUpdate.py.

◆ default

python.BeamSpotUpdate.default

Definition at line 176 of file BeamSpotUpdate.py.

◆ dr

python.BeamSpotUpdate.dr = EventStorage.pickDataReader(args.file[0])

Definition at line 180 of file BeamSpotUpdate.py.

◆ folderList

list python.BeamSpotUpdate.folderList = []

Definition at line 35 of file BeamSpotUpdate.py.

◆ help

python.BeamSpotUpdate.help

Definition at line 175 of file BeamSpotUpdate.py.

◆ i

int python.BeamSpotUpdate.i = 0

Definition at line 190 of file BeamSpotUpdate.py.

◆ int

python.BeamSpotUpdate.int

Definition at line 176 of file BeamSpotUpdate.py.

◆ log

python.BeamSpotUpdate.log = logging.getLogger(__name__)

Definition at line 36 of file BeamSpotUpdate.py.

◆ metavar

python.BeamSpotUpdate.metavar

Definition at line 175 of file BeamSpotUpdate.py.

◆ nargs

python.BeamSpotUpdate.nargs

Definition at line 175 of file BeamSpotUpdate.py.

◆ newevt

python.BeamSpotUpdate.newevt = modify(event)

Definition at line 195 of file BeamSpotUpdate.py.

◆ output

python.BeamSpotUpdate.output
Initial value:
1= eformat.ostream(core_name = args.output or dr.fileNameCore(),
2 run_number = dr.runNumber(),
3 trigger_type = dr.triggerType(),
4 detector_mask = dr.detectorMask(),
5 beam_type = dr.beamType(),
6 beam_energy = dr.beamEnergy(),
7 meta_data_strings=dr.freeMetaDataStrings(),
8 compression=dr.compression())

Definition at line 181 of file BeamSpotUpdate.py.

◆ parser

python.BeamSpotUpdate.parser = argparse.ArgumentParser(description=__doc__)

Definition at line 174 of file BeamSpotUpdate.py.

◆ str

python.BeamSpotUpdate.str

Definition at line 177 of file BeamSpotUpdate.py.

◆ type

python.BeamSpotUpdate.type

Definition at line 176 of file BeamSpotUpdate.py.