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
1 file
+ 6
5
Compare changes
  • Side-by-side
  • Inline
###############################################################################
# (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')
#use only a cetain file from testfileDB as some files seem to be corrupt in that sample
options.input_files = list(
set([
"root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/MC/Upgrade/XDIGI/00092857/0000/00092857_00000030_1.xdigi"
]))
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, PrKalmanFilter
# 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
from RecoConf.hlt2_global_reco import make_fastest_reconstruction
from RecoConf.hlt2_global_reco import reconstruction as reconstruction_hook
with reconstruction.bind(from_file=False), PrKalmanFilter.bind(
FillFitResult=True,
ClassicSmoothing=True), reconstruction_hook.bind(
make_reconstruction=make_fastest_reconstruction
), make_reco_pvs.bind(
make_pvs_from_velo_tracks=make_PatPV3DFuture_pvs
), make_fastest_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 = 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 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(
"VPInternal : VP/VPRight/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
constraints.append(
"VPInternal : VP/VPLeft/Module..WithSupport: Tx Ty Tz Rx Ry Rz")
runAlignment(
options,
chisqConstraintTool=myAlignChisqConstraintTool,
lagrangeConstrains=constraints,
alignmentTracks=alignmentTracks,
alignmentPVs=alignmentPVs,
particles=particles,
odin=odin,
elementsToAlign=elements,
monitorList=monitors)
Loading