Skip to content
Snippets Groups Projects

Prototype of new alignment configuration

Merged Florian Reiss requested to merge pyconf into master
Compare and Show latest version
7 files
+ 141
89
Compare changes
  • Side-by-side
  • Inline
Files
7
###############################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
from Moore import options
from PyConf.application import configure_input
from RecoConf.hlt1_tracking import default_ft_decoding_version
default_ft_decoding_version.global_bind(value=6)
options.set_input_and_conds_from_testfiledb('upgrade_DC19_01_MinBiasMD')
options.input_files = list(set(options.input_files)) # remove dups
input_files = options.input_files
input_files = [a for a in input_files if 'eoslhcb.cern.ch' in a]
input_files.sort()
options.input_files = input_files[
0:
1] # just use one file for now. Use one at CERN to avoid issues with unavailable files
options.evt_max = 10
# options.use_iosvc = True
options.event_store = 'EvtStoreSvc'
options.ntuple_file = "testmonitoring.root"
options.histo_file = "testmonitoringhist.root"
# set options above this line!
configure_input(options)
# only configure data flow after this line !
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
from PyConf.Algorithms import VeloClusterTrackingSIMDFull
# note that the PVs reconstructed by TrackBeamLineVertexFinderSoA do not store the list of associated tracks. Use PatPV3DFuture instead
from RecoConf.hlt1_tracking import make_reco_pvs, make_PatPV3DFuture_pvs, make_VeloClusterTrackingSIMD_tracks
from RecoConf.hlt2_tracking import make_hlt2_tracks
#, make_reco_pvs.bind( make_pvs_from_velo_tracks=make_PatPV3DFuture_pvs)
#with reconstruction.bind(from_file=False), make_hlt2_tracks.bind(light_reco=True, use_pr_kf=True, fast_reco=False), make_reco_pvs.bind( make_pvs_from_velo_tracks=make_PatPV3DFuture_pvs):
from RecoConf.hlt2_global_reco import make_default_reconstruction
with reconstruction.bind(from_file=False), make_hlt2_tracks.bind(
light_reco=False), make_reco_pvs.bind(
make_pvs_from_velo_tracks=make_PatPV3DFuture_pvs
), make_VeloClusterTrackingSIMD_tracks.bind(
make_tracks=VeloClusterTrackingSIMDFull
), make_default_reconstruction.bind(usePatPVFuture=True):
#make tracks and PVs
# TODO: in principle the PVs should be an optional input for the alignment
reco = reconstruction()
#hlt2_tracks = make_hlt2_tracks(light_reco=False)
#best_tracks = hlt2_tracks["Best"]['v1']
#pvs = make_pvs()
hlt2_tracks = reco["Tracks"]
best_tracks = hlt2_tracks
pvs = reco["PVs"]
from PyConf.application import default_raw_banks, createODIN
odin = createODIN(RawBanks=default_raw_banks(("ODIN"))).ODIN
# create input particles, use dummy particles for now
# TODO: in principle these should be composite particles and be an optional input for the alginment
from Humboldt.ParticleSelections import DummyParticles
particles = DummyParticles()
#select tracks and PVs
from PyConf.Tools import VPTrackSelector
from PyConf.Algorithms import TrackListRefiner, VertexListRefiner, TrackSelectionMerger
myTrackSelector = VPTrackSelector(
TrackTypes=["Long"], MinHits=5, MaxChi2Cut=5)
selected_tracks = TrackListRefiner(
inputLocation=best_tracks, Selector=myTrackSelector).outputLocation
myBackwardTrackSelector = VPTrackSelector(
TrackTypes=["Velo"],
MinHits=5,
MaxChi2Cut=5,
OnlyBackwardTracks=True)
selected_BackwardTracks = TrackListRefiner(
inputLocation=best_tracks,
Selector=myBackwardTrackSelector).outputLocation
alignmentTracks = TrackSelectionMerger(
InputLocations=[selected_tracks, selected_BackwardTracks
]).OutputLocation
selected_pvs = VertexListRefiner(
MaxChi2PerDoF=5,
MinNumTracks=15,
MinNumLongTracks=0,
InputLocation=pvs).OutputLocation
# add track and vertex monitoring
from PyConf.Algorithms import TrackMonitor, TrackFitMatchMonitor, TrackVertexMonitor, VPTrackMonitor
from RecoConf.mc_checking import vphits_resolution_checker
from RecoConf.hlt1_tracking import make_VPClus_hits
# TODO: should only use selected PVs
myTrackMonitor = TrackMonitor(
TracksInContainer=alignmentTracks, PrimaryVertices=pvs)
myTrackFitMatchMonitor = TrackFitMatchMonitor(
TrackContainer=alignmentTracks)
# TODO: check vertices
myTrackVertexMonitor = TrackVertexMonitor(
TrackContainer=alignmentTracks, PVContainer=pvs)
myVPTrackMonitor = VPTrackMonitor(
TrackContainer=best_tracks, ClusterContainer=make_VPClus_hits())
monitorlist = [
myTrackMonitor, myTrackFitMatchMonitor, myTrackVertexMonitor,
myVPTrackMonitor,
vphits_resolution_checker()
]
return alignmentTracks, selected_pvs, particles, odin, monitorlist
alignmentTracks, alignmentPVs, particles, odin, monitors = getAlignmentTracksAndPVs(
)
#define elements and degrees of freedom to be aligned
from TAlignment.Alignables import Alignables
elements = Alignables()
dofs = "TxTyTzRxRyRz"
dofsmodules = "TxTyTzRxRyRz"
elements.VPLeft(dofs)
elements.VPRight(dofs)
elements.VPModules(dofsmodules)
# add survey constraints
from Configurables import SurveyConstraints
from PyConf.Tools import AlignChisqConstraintTool
surveyconstraints = SurveyConstraints()
surveyconstraints.VP()
myAlignChisqConstraintTool = AlignChisqConstraintTool(
Constraints=surveyconstraints.Constraints,
XmlUncertainties=surveyconstraints.XmlUncertainties,
XmlFiles=surveyconstraints.XmlFiles)
# define Lagrange constraints
constraints = []
constraints.append("VPHalfAverage : VP/VP(Left|Right) : Tx Ty Tz Rx Ry Rz")
constraints.append(
"VPInternalRight : VP/VPRight/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
constraints.append(
"VPInternalLeft : VP/VPLeft/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
from Humboldt.utils import createAlignUpdateTool, createAlignAlgorithm
with createAlignUpdateTool.bind(
logFile="alignlog_vp_halves_modules.txt"
), createAlignAlgorithm.bind(xmlWriters=[
'humb-vp-halves-modules/xml/Conditions/VP/Alignment/Global.xml:/dd/Structure/LHCb/BeforeMagnetRegion/VP:10:0/1:0:1',
'humb-vp-halves-modules/xml/Conditions/VP/Alignment/Modules.xml:/dd/Structure/LHCb/BeforeMagnetRegion/VP:10:2:0:1'
]):
runAlignment(
options,
chisqConstraintTool=myAlignChisqConstraintTool,
lagrangeConstrains=constraints,
alignmentTracks=alignmentTracks,
alignmentPVs=alignmentPVs,
particles=particles,
odin=odin,
elementsToAlign=elements,
monitorList=monitors)
Loading