Commit be00fe43 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Merge branch 'rm-fix-formatting' into 'master'

Apply formatting and fix CI job

See merge request !330
parents 3cbdb376 6731425d
Pipeline #4805257 passed with stage
in 29 seconds
......@@ -18,8 +18,11 @@ check-copyright:
- python lb-check-copyright origin/${TARGET_BRANCH} --exclude lhcbproject.yml
check-formatting:
image: gitlab-registry.cern.ch/lhcb-docker/style-checker
tags:
- cvmfs
image: gitlab-registry.cern.ch/ci-tools/ci-worker:cc7
script:
- . /cvmfs/lhcb.cern.ch/lib/LbEnv.sh
- if [ ! -e .clang-format ] ; then
- curl -o .clang-format "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/data/default.clang-format?inline=false"
- echo '.clang-format' >> .gitignore
......
......@@ -293,9 +293,10 @@ if __name__ == '__main__':
outFile_name = os.path.join(
Moni_dir, '{0}/{1}.pdf'.format(activity, run))
#outFile_name='test{0}.pdf'.format(activity)
print(printTime(), 'Analising run {0}'.format(run) +
(', alignment version v{0}'.format(version)
if version else ''))
print(
printTime(), 'Analising run {0}'.format(run) +
(', alignment version v{0}'.format(version)
if version else ''))
sys.stdout.flush()
logger.info('Analising run {0}'.format(run) +
(', alignment version v{0}'.
......
......@@ -158,7 +158,7 @@ if __name__ == '__main__':
if args.freeY: args.labelAU = True
args.labels = dict([i.split(':')
for i in args.labels]) if args.labels else {}
exec ('args.stickers = {0}'.format(args.stickers))
exec('args.stickers = {0}'.format(args.stickers))
##########################
......
......@@ -80,10 +80,10 @@ from Gaudi.Configuration import logging
if options:
g = {}
l = {}
exec ("from Gaudi.Configuration import *", g, l)
exec("from Gaudi.Configuration import *", g, l)
for o in options:
logging.debug(o)
exec (o, g, l)
exec(o, g, l)
## Instantiate application manager
from GaudiPython.Bindings import AppMgr
......
......@@ -92,8 +92,9 @@ def main():
for d in dirs:
shutil.rmtree(d)
else:
print(str("Keeping XML files for difference DB in " + dirs[0] +
" and for DB " + inputfiles[1] + " in " + dirs[1]))
print(
str("Keeping XML files for difference DB in " + dirs[0] +
" and for DB " + inputfiles[1] + " in " + dirs[1]))
def doCalculations(ETs):
......
......@@ -49,10 +49,10 @@ from Gaudi.Configuration import logging
if options:
g = {}
l = {}
exec ("from Gaudi.Configuration import *", g, l)
exec("from Gaudi.Configuration import *", g, l)
for o in options:
logging.debug(o)
exec (o, g, l)
exec(o, g, l)
# let the algorithm update in finalize and set the input file
from Configurables import TAlignment, AlignAlgorithm
......
......@@ -105,10 +105,10 @@ from GaudiPython.Bindings import gbl
timebegin = intTime(opts.since, cool.ValidityKeyMin) // nsPerSecond
timeend = intTime(opts.until, cool.ValidityKeyMax) // nsPerSecond
print("From: ", opts.since, " --> ", gbl.Gaudi.Time(timebegin, 0).format(
True, "%c"))
print("Until: ", opts.until, " --> ", gbl.Gaudi.Time(timeend, 0).format(
True, "%c"))
print("From: ", opts.since, " --> ",
gbl.Gaudi.Time(timebegin, 0).format(True, "%c"))
print("Until: ", opts.until, " --> ",
gbl.Gaudi.Time(timeend, 0).format(True, "%c"))
if opts.dtime > 0:
timeinterval = opts.dtime
......
......@@ -185,8 +185,8 @@ def CallDumpToFile(outputfilename, opts, callback=lambda a, c, b, d: 0):
LHCbApp().CondDBtag = "HEAD"
if opts.time > 0:
from Configurables import EventClockSvc
print("Time: ", opts.time, " --> ", gbl.Gaudi.Time(opts.time).format(
True, "%c"))
print("Time: ", opts.time, " --> ",
gbl.Gaudi.Time(opts.time).format(True, "%c"))
EventClockSvc().InitialTime = opt.time
if opts.aligndb:
......
......@@ -112,10 +112,10 @@ from Gaudi.Configuration import logging
if options:
g = {}
l = {}
exec ("from Gaudi.Configuration import *", g, l)
exec("from Gaudi.Configuration import *", g, l)
for o in options:
logging.debug(o)
exec (o, g, l)
exec(o, g, l)
#options = [ "importOptions(%r)" % f for f in args ]
......
......@@ -62,10 +62,10 @@ from Gaudi.Configuration import logging
if options:
g = {}
l = {}
exec ("from Gaudi.Configuration import *", g, l)
exec("from Gaudi.Configuration import *", g, l)
for o in options:
logging.debug(o)
exec (o, g, l)
exec(o, g, l)
# make sure that the algorithms know how many iterations are coming
from Configurables import TAlignment
......
......@@ -94,8 +94,7 @@ def getAlignmentTracksAndPVs():
Bins=50)
monitorlist = [
myFTTrackMonitor,
myTrackVertexMonitor, myParticleMonitor
myFTTrackMonitor, myTrackVertexMonitor, myParticleMonitor
]
return alignmentTracks, selected_pvs, particles, odin, monitorlist
......
......@@ -14,7 +14,8 @@ from PyConf.application import configure_input
from PRConfig.FilesFromDirac import get_access_urls
# set DDDB and CondDB info
options.set_input_and_conds_from_testfiledb('upgrade-magdown-minbias-alignHLT1filtered')
options.set_input_and_conds_from_testfiledb(
'upgrade-magdown-minbias-alignHLT1filtered')
options.evt_max = 100
# options.use_iosvc = True
......@@ -30,6 +31,7 @@ configure_input(options)
from Humboldt.utils import runAlignment
# at the moment, define tracks and PVs by hand. Could be changed to centrally defined selection in the future
def getAlignmentTracksAndPVs():
from RecoConf.reconstruction_objects import reconstruction
......@@ -74,18 +76,15 @@ def getAlignmentTracksAndPVs():
from GaudiKernel.SystemOfUnits import MeV
# TODO: should only use selected PVs in monitors
myTrackMonitor = TrackMonitor(
TracksInContainer=alignmentTracks)
myTrackMonitor = TrackMonitor(TracksInContainer=alignmentTracks)
myTrackFitMatchMonitor = TrackFitMatchMonitor(
TrackContainer=alignmentTracks)
myFTTrackMonitor = FTTrackMonitor(
TracksInContainer=alignmentTracks)
myFTTrackMonitor = FTTrackMonitor(TracksInContainer=alignmentTracks)
# TODO: check vertices
myTrackVertexMonitor = TrackVertexMonitor(
TrackContainer=alignmentTracks,
PVContainer=pvs)
TrackContainer=alignmentTracks, PVContainer=pvs)
monitorlist = [
myTrackMonitor, myTrackFitMatchMonitor, myFTTrackMonitor,
......@@ -93,8 +92,8 @@ def getAlignmentTracksAndPVs():
]
return alignmentTracks, selected_pvs, odin, monitorlist
alignmentTracks, alignmentPVs, odin, monitors = getAlignmentTracksAndPVs(
)
alignmentTracks, alignmentPVs, odin, monitors = getAlignmentTracksAndPVs()
#define elements and degrees of freedom to be aligned
from TAlignment.Alignables import Alignables
......@@ -113,13 +112,17 @@ myAlignChisqConstraintTool = AlignChisqConstraintTool(
XmlFiles=surveyconstraints.XmlFiles)
# define Lagrange constraints
constraints=[]
constraints = []
#Confine module motion to CFrames
for station in ["T1","T2","T3"]:
for layerlabel, layercode in zip(["X1U","VX2"],["Layer(X1|U)","Layer(V|X2)"]):
for sidelabel, sidecode in zip(["CSide","ASide"],["Quarter(0|2)","Quarter(1|3)"]):
constraints.append(f"Modules{station}{layerlabel}{sidelabel} : FT/{station}{layercode}{sidecode}Module. : Tx Tz Rx Rz")
for station in ["T1", "T2", "T3"]:
for layerlabel, layercode in zip(["X1U", "VX2"],
["Layer(X1|U)", "Layer(V|X2)"]):
for sidelabel, sidecode in zip(["CSide", "ASide"],
["Quarter(0|2)", "Quarter(1|3)"]):
constraints.append(
f"Modules{station}{layerlabel}{sidelabel} : FT/{station}{layercode}{sidecode}Module. : Tx Tz Rx Rz"
)
from Humboldt.utils import createAlignUpdateTool, createAlignAlgorithm, getXMLWriterList
with createAlignUpdateTool.bind(
......
......@@ -17,26 +17,27 @@ import OnlineEnvBase as OnlineEnv
# Setup online
# TODO: get inputs from Online
runNumber= 9999
runNumber = 9999
workerNumber = 0
runType="SCIFI"
if OnlineEnv.PartitionName =="TEST":
runType = "SCIFI"
if OnlineEnv.PartitionName == "TEST":
derivfile = "humb-ft-modules-derivs"
histofile = "testmonitoringhist.root"
else:
from pathlib import Path
onlineprefix = '/group/online/dataflow/cmtuser/alignonlinetest'
Path(f"{onlineprefix}/{runType}/{runNumber}/analyzerOutput/").mkdir(parents=True, exist_ok=True)
Path(f"{onlineprefix}/{runType}/{runNumber}/analyzerOutput/").mkdir(
parents=True, exist_ok=True)
derivfile = f"{onlineprefix}/{runType}/{runNumber}/analyzerOutput/{workerNumber}_humb-vp-halves-modules-derivs"
histofile = f"{onlineprefix}/{runType}/{runNumber}/analyzerOutput/{workerNumber}_testmonitoringhist.root"
# set options above this line!
options.histo_file=histofile
options.histo_file = histofile
configure_input(options)
# only configure data flow after this line !
# at the moment, define tracks and PVs by hand. Could be changed to centrally defined selection in the future
def getAlignmentTracksAndPVs():
......@@ -80,18 +81,15 @@ def getAlignmentTracksAndPVs():
from GaudiKernel.SystemOfUnits import MeV
# TODO: should only use selected PVs in monitors
myTrackMonitor = TrackMonitor(
TracksInContainer=alignmentTracks)
myTrackMonitor = TrackMonitor(TracksInContainer=alignmentTracks)
myTrackFitMatchMonitor = TrackFitMatchMonitor(
TrackContainer=alignmentTracks)
myFTTrackMonitor = FTTrackMonitor(
TracksInContainer=alignmentTracks)
myFTTrackMonitor = FTTrackMonitor(TracksInContainer=alignmentTracks)
# TODO: check vertices
myTrackVertexMonitor = TrackVertexMonitor(
TrackContainer=alignmentTracks,
PVContainer=pvs)
TrackContainer=alignmentTracks, PVContainer=pvs)
monitorlist = [
myTrackMonitor, myTrackFitMatchMonitor, myFTTrackMonitor,
......@@ -99,8 +97,8 @@ def getAlignmentTracksAndPVs():
]
return alignmentTracks, selected_pvs, odin, monitorlist
alignmentTracks, alignmentPVs, odin, monitors = getAlignmentTracksAndPVs(
)
alignmentTracks, alignmentPVs, odin, monitors = getAlignmentTracksAndPVs()
#define elements and degrees of freedom to be aligned
from TAlignment.Alignables import Alignables
......@@ -119,19 +117,21 @@ myAlignChisqConstraintTool = AlignChisqConstraintTool(
XmlFiles=surveyconstraints.XmlFiles)
# define Lagrange constraints
constraints=[]
constraints = []
#Confine module motion to CFrames
for station in ["T1","T2","T3"]:
for layerlabel, layercode in zip(["X1U","VX2"],["Layer(X1|U)","Layer(V|X2)"]):
for sidelabel, sidecode in zip(["CSide","ASide"],["Quarter(0|2)","Quarter(1|3)"]):
constraints.append(f"Modules{station}{layerlabel}{sidelabel} : FT/{station}{layercode}{sidecode}Module. : Tx Tz Rx Rz")
for station in ["T1", "T2", "T3"]:
for layerlabel, layercode in zip(["X1U", "VX2"],
["Layer(X1|U)", "Layer(V|X2)"]):
for sidelabel, sidecode in zip(["CSide", "ASide"],
["Quarter(0|2)", "Quarter(1|3)"]):
constraints.append(
f"Modules{station}{layerlabel}{sidelabel} : FT/{station}{layercode}{sidecode}Module. : Tx Tz Rx Rz"
)
from Humboldt.utils import createAlignAlgorithm
with createAlignAlgorithm.bind(
onlineMode=True,
histoPrint=True,
outputDataFile=derivfile):
onlineMode=True, histoPrint=True, outputDataFile=derivfile):
runAlignment(
options,
chisqConstraintTool=myAlignChisqConstraintTool,
......
......@@ -51,9 +51,6 @@ constraints.append(
from Humboldt.utils import createAlignUpdateTool, getXMLWriterList
#TODO: get these from Online
runNumber = 9999
workerNumber = 0
......@@ -65,13 +62,13 @@ if OnlineEnv.PartitionName == "TEST":
else:
from pathlib import Path
onlineprefix = '/group/online/dataflow/cmtuser/alignonlinetest'
Path(f"{onlineprefix}/{runType}/{runNumber}/iteratorOutput/").mkdir(parents=True, exist_ok=True)
Path(f"{onlineprefix}/{runType}/{runNumber}/iteratorOutput/").mkdir(
parents=True, exist_ok=True)
derivfile = f"{onlineprefix}/{runType}/{runNumber}/analyzerOutput/{workerNumber}_humb-vp-halves-modules-derivs"
alignlogFile = f"{onlineprefix}/{runType}/{runNumber}/iteratorOutput/alignlog_iterator.txt"
xmlprefix = f"{onlineprefix}/{runType}/{runNumber}/iteratorOutput/humb-iterator-vp-halves-modules/"
myUpdateTool = AlignUpdateTool(
SurveyConstraintTool=myAlignChisqConstraintTool,
Constraints=constraints,
......
......@@ -16,6 +16,7 @@ from PyConf.Tools import AlignUpdateTool, EigenDiagSolvTool, AlignChisqConstrain
from PyConf.application import configure
from RecoConf.event_filters import require_gec
@configurable
def createAlignAlgorithm(tracks,
elements,
......@@ -42,8 +43,8 @@ def createAlignAlgorithm(tracks,
alignment = AlignAlgorithm
if particles is None:
from .ParticleSelections import DummyParticles
particles=DummyParticles()
from .ParticleSelections import DummyParticles
particles = DummyParticles()
if pvs is None:
from .VertexSelections import DummyPVs
pvs = DummyPVs()
......@@ -93,6 +94,7 @@ def createAlignUpdateTool(name='updateTool',
public=isPublic)
return updatetool
def runAlignment(options,
chisqConstraintTool,
lagrangeConstrains,
......@@ -103,17 +105,18 @@ def runAlignment(options,
particles=None,
monitorList=[],
filters=[],
updateInFinalize = False,
usePrKalman = False):
updateInFinalize=False,
usePrKalman=False):
# make sure to mereg track lists, if multiple lists are provided
alignTrackLists = alignmentTracks
if not isinstance(alignTrackLists, list):
alignTrackLists = [ alignmentTracks ]
alignTrackLists = [alignmentTracks]
else:
# make sure to merge them
from PyConf.Algorithms import TrackSelectionMerger
alignmentTracks = TrackSelectionMerger(InputLocations = alignTrackLists).OutputLocation
alignmentTracks = TrackSelectionMerger(
InputLocations=alignTrackLists).OutputLocation
# automatically create monitoring algorithms for each input track list
from PyConf.Algorithms import TrackFitMatchMonitor
......@@ -124,13 +127,23 @@ def runAlignment(options,
for trklist in alignTrackLists:
#from PyConf.Algorithms import TrackMonitor, TrackFitMatchMonitor
monitorList.append( TrackMonitor(name = trklist.producer.name + "TrackMonitor", TracksInContainer = trklist ) )
monitorList.append( TrackFitMatchMonitor(name = trklist.producer.name + "TrackFitMatchMonitor", TrackContainer = trklist ) )
monitorList.append(
TrackMonitor(
name=trklist.producer.name + "TrackMonitor",
TracksInContainer=trklist))
monitorList.append(
TrackFitMatchMonitor(
name=trklist.producer.name + "TrackFitMatchMonitor",
TrackContainer=trklist))
# create monitor for PVs
if alignmentPVs:
from PyConf.Algorithms import TrackVertexMonitor
monitorList.append( TrackVertexMonitor(name = alignmentPVs.producer.name + "VertexMonitor", PVContainer=alignmentPVs, TrackContainer=alignmentTracks) )
monitorList.append(
TrackVertexMonitor(
name=alignmentPVs.producer.name + "VertexMonitor",
PVContainer=alignmentPVs,
TrackContainer=alignmentTracks))
updatetool = createAlignUpdateTool(
surveyconstraintTool=chisqConstraintTool,
......@@ -159,38 +172,46 @@ def runAlignment(options,
configure(options, top_node, public_tools=[])
def getXMLWriterList(detectors, prefix='xml', precision=10, online=False, removePivot=True):
def getXMLWriterList(detectors,
prefix='xml',
precision=10,
online=False,
removePivot=True):
from DDDB.CheckDD4Hep import UseDD4Hep
topLevelElements = {
'VP' : "/dd/Structure/LHCb/BeforeMagnetRegion/VP"
if not UseDD4Hep else "/world/BeforeMagnetRegion/VP",
'UT' : "",
'FT' : "/dd/Structure/LHCb/AfterMagnetRegion/T/FT",
'Muon' : "/dd/Structure/LHCb/DownstreamRegion/Muon",
'Ecal' : "/dd/Structure/LHCb/DownstreamRegion/Ecal"
'VP':
"/dd/Structure/LHCb/BeforeMagnetRegion/VP"
if not UseDD4Hep else "/world/BeforeMagnetRegion/VP",
'UT':
"",
'FT':
"/dd/Structure/LHCb/AfterMagnetRegion/T/FT",
'Muon':
"/dd/Structure/LHCb/DownstreamRegion/Muon",
'Ecal':
"/dd/Structure/LHCb/DownstreamRegion/Ecal"
}
subElements = {
'VP' : {
'Global' : [0, 1],
'VP': {
'Global': [0, 1],
'Modules': [2, 4]
},
'UT' : {}, #TODO: UT
'FT' : {
'FTSystem' : [0, 1, 2, 3],
'Modules' : [4],
'Mats' : [5]
'UT': {}, #TODO: UT
'FT': {
'FTSystem': [0, 1, 2, 3],
'Modules': [4],
'Mats': [5]
},
'Muon' : {
'Global' : [0, 1, 2],
'Modules' : [2]
'Muon': {
'Global': [0, 1, 2],
'Modules': [2]
},
'Ecal' : {
'alignment' : []
'Ecal': {
'alignment': []
}
}
xmlWriterList = []
if not isinstance(detectors, list): detectors = [ detectors ]
if not isinstance(detectors, list): detectors = [detectors]
for detector in detectors:
topLevelElement = topLevelElements[detector]
for element, depths in subElements[detector].items():
......@@ -198,5 +219,3 @@ def getXMLWriterList(detectors, prefix='xml', precision=10, online=False, remove
curString = f'{prefix}/Conditions/{detector}/Alignment/{element}.xml:{topLevelElement}:{precision}:{depth}:{int(online)}:{int(removePivot)}'
xmlWriterList.append(curString)
return xmlWriterList
......@@ -427,11 +427,12 @@ def defaultHLTJPsiSelection(lines=[]):
# revive only particles used for trigger
print('Hlt lines to be used: ')
print(ReviveHltTracks(
lines if len(lines) else [
'Hlt2ExpressJPsiDecision', 'Hlt2DiMuonDetachedJPsiDecision',
'Hlt2DiMuonJPsiDecision', 'Hlt2DiMuonJPsiHighPTDecision'
]))
print(
ReviveHltTracks(
lines if len(lines) else [
'Hlt2ExpressJPsiDecision', 'Hlt2DiMuonDetachedJPsiDecision',
'Hlt2DiMuonJPsiDecision', 'Hlt2DiMuonJPsiHighPTDecision'
]))
# Now create the J/psi candidates
from Configurables import CombineParticles, FilterDesktop
......
......@@ -107,8 +107,9 @@ def PrintLatestAlignment(xmlDir='/group/online/alignment'):
}
for det in DetDirs:
for i in range(2):
print(FindLastVersion(xmlDir + '/' + det + '/' + det +
DetDirs[det][i]))
print(
FindLastVersion(xmlDir + '/' + det + '/' + det +
DetDirs[det][i]))
return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment