Skip to content
Snippets Groups Projects

Prototype of new alignment configuration

Merged Florian Reiss requested to merge pyconf into master
Compare and
4 files
+ 139
3
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 136
0
###############################################################################
# (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 PyConf.application import configure_input, configure
from PyConf.control_flow import CompositeNode, NodeLogic
from RecoConf.hlt2_tracking import make_hlt2_tracks
from RecoConf.hlt1_tracking import make_pvs, all_velo_track_types
from Moore import options
options.set_input_and_conds_from_testfiledb('MiniBrunel_2018_MinBias_FTv4_MDF')
options.input_files = list(set(options.input_files)) # remove dups
options.evt_max = 10
# options.use_iosvc = True
options.event_store = 'EvtStoreSvc'
options.ntuple_file = "testmonitoring.root"
# set options above this line!
configure_input(options)
# only configure data flow after this line !
from RecoConf.reconstruction_objects import reconstruction
with reconstruction.bind(from_file=False):
#make tracks and PVs
# TODO: in principle the PVs should be an optional input for the alignment
hlt2_tracks = make_hlt2_tracks(light_reco=False)
best_tracks = hlt2_tracks["Best"]['v1']
pvs = make_pvs()
#select tracks and PVs
from PyConf.Tools import VPTrackSelector
from PyConf.Algorithms import TrackListRefiner, VertexListRefiner, TrackSelectionMerger
from PyConf.Algorithms import LHCb__Converters__RecVertex__v2__fromVectorLHCbRecVertices as fromLHCbRecVertices
myTrackSelector = VPTrackSelector(
TrackTypes=["Long"], MinHits=5, MaxChi2Cut=5)
selected_tracks = TrackListRefiner(
inputLocation=best_tracks, Selector=myTrackSelector).outputLocation
myBackwardTrackSelector = VPTrackSelector(
TrackTypes=["Backward"], MinHits=5, MaxChi2Cut=5)
selected_BackwardTracks = TrackListRefiner(
inputLocation=best_tracks,
Selector=myBackwardTrackSelector).outputLocation
alignmentTracks = TrackSelectionMerger(
InputLocations=[selected_tracks, selected_BackwardTracks
]).OutputLocation
#need to convert PVs first
converted_pvs = fromLHCbRecVertices(
InputVerticesName=pvs,
InputTracksName=all_velo_track_types()["v1"]).OutputVerticesName
selected_pvs = VertexListRefiner(
InputLocation=converted_pvs).OutputLocation
#create ODIN
from PyConf.application import default_raw_event, createODIN
odin = createODIN(RawEvent=default_raw_event(["ODIN"])).ODIN
# create input particles, use long pions as dummy for now
# TODO: in principle these should be composite particles and be an optional input for the alginment
from Hlt2Conf.standard_particles import make_long_pions
pions = make_long_pions()
#put everything together into AlignAlgorithm and run it
from PyConf.Algorithms import AlignAlgorithm
from PyConf.Tools import AlignUpdateTool, EigenDiagSolvTool, AlignChisqConstraintTool
# add arguments to configure AlignAlgorithm and AlignUpdateTool
#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
myAlignChisqConstraintTool = AlignChisqConstraintTool(
Constraints=[
"VP : 0 0 0 0 0 0 : 0.5 0.5 0.5 0.0001 0.0001 0.0001",
"VP/VP(Right|Left) : 0. 0. 0. 0. 0. 0. : 0.200 0.200 0.2 0.0001 0.0001 0.0001"
],
XmlUncertainties=[
".*Module(00|).. : 0.02 0.02 0.02 0.0002 0.0002 0.0002"
],
XmlFiles=["Alignment/Alignment/TAlignment/surveyxml/VP/Modules.xml"])
# define Lagrange constraints
constraints = []
constraints.append("VPHalfAverage : VP/VP(Left|Right) : Tx Ty Tz Rx Ry Rz")
constraints.append(
"VPInternal : VP/VPRight/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
constraints.append(
"VPInternal : VP/VPLeft/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
myAlignUpdateTool = AlignUpdateTool(
MatrixSolverTool=EigenDiagSolvTool(public=True),
SurveyConstraintTool=myAlignChisqConstraintTool,
Constraints=constraints)
alignment = AlignAlgorithm(
VertexLocation=selected_pvs,
ODINLocation=odin,
TracksLocation=alignmentTracks,
ParticleLocation=pions,
UpdateTool=myAlignUpdateTool,
Elements=list(elements),
UpdateInFinalize=True)
# add track and vertex monitoring
from PyConf.Algorithms import TrackMonitor, TrackFitMatchMonitor, TrackVertexMonitor
# TODO: should only use selected PVs
myTrackMonitor = TrackMonitor(
TracksInContainer=alignmentTracks, PrimaryVertices=converted_pvs)
myTrackFitMatchMonitor = TrackFitMatchMonitor(
TrackContainer=alignmentTracks)
# TODO: check vertices
myTrackVertexMonitor = TrackVertexMonitor(
TrackContainer=alignmentTracks, PVContainer=converted_pvs)
top_node = CompositeNode(
"alignment", [
alignment, myTrackMonitor, myTrackFitMatchMonitor,
myTrackVertexMonitor
],
combine_logic=NodeLogic.NONLAZY_OR,
force_order=True)
configure(options, top_node, public_tools=[])
Loading