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
4 files
+ 182
17
Compare changes
  • Side-by-side
  • Inline
Files
4
###############################################################################
# (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]
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 = 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 long pions as dummy for now
# TODO: in principle these should be composite particles and be an optional input for the alginment
from Humboldt.ParticleSelections import defaultHLTD0Selection
particles = defaultHLTD0Selection()
#select tracks and PVs
from PyConf.Tools import TrackSelector
from PyConf.Algorithms import TrackListRefiner, VertexListRefiner, TrackSelectionMerger
from Humboldt.TrackSelections import GoodLongTracks
selected_tracks = GoodLongTracks(reco)
alignmentTracks = TrackSelectionMerger(
InputLocations=[selected_tracks]).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.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 = []
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 = "TxTzRxRz"
elements.FTStations(dofs)
elements.FTFrameLayers(dofs)
# add survey constraints
from Configurables import SurveyConstraints
from PyConf.Tools import AlignChisqConstraintTool
surveyconstraints = SurveyConstraints()
surveyconstraints.FT()
myAlignChisqConstraintTool = AlignChisqConstraintTool(
Constraints=surveyconstraints.Constraints,
XmlUncertainties=surveyconstraints.XmlUncertainties,
XmlFiles=surveyconstraints.XmlFiles)
# define Lagrange constraints
constraints = []
constraints.append("station3 : FT/T3 : Tx Tz Rx Rz")
constraints.append("backlayer_T3 : FT/T3/Layer(V|X2) : Tx Tz Rx Rz")
# Confine quarters in T3 to Cframes
constraints.append(
"FT/T3X1UCSide : /dd/Structure/LHCb/AfterMagnetRegion/T/FT/T3/Layer(X1|U)/Quarter(0|2) : Tx Tz Rx Rz"
)
constraints.append(
"FT/T3VX2CSide : /dd/Structure/LHCb/AfterMagnetRegion/T/FT/T3/Layer(V|X2)/Quarter(0|2) : Tx Tz Rx Rz"
)
constraints.append(
"FT/T3X1UASide : /dd/Structure/LHCb/AfterMagnetRegion/T/FT/T3/Layer(X1|U)/Quarter(1|3) : Tx Tz Rx Rz"
)
constraints.append(
"FT/T3VX2ASide : /dd/Structure/LHCb/AfterMagnetRegion/T/FT/T3/Layer(V|X2)/Quarter(1|3) : Tx Tz Rx Rz"
)
from Humboldt.utils import createAlignUpdateTool
with createAlignUpdateTool.bind(logFile="alignlog_SciFi.txt"):
runAlignment(
options,
chisqConstraintTool=myAlignChisqConstraintTool,
lagrangeConstrains=constraints,
alignmentTracks=alignmentTracks,
alignmentPVs=alignmentPVs,
particles=particles,
odin=odin,
elementsToAlign=elements,
monitorList=monitors)
Loading