Primary vertex re-fitting


PV re-fitting in analysis

Primary vertex re-fitting can be achieved either automatically from a DVAlgorithm, or with PVRefitterAlg, an algorithm designed specifically for that purpose. In both cases, the re-fitted primary vertices and relations tables linking the particles to re-fitted vertices are stored on the TES. It is very important that re-fitted vertices are accessed via the relations tables. Re-fitted vertices have no meaning without the particles that were used to make them, and a container of re-fitted vertices will have as many versions of the same vertex as there are candidates in the event. This is why the TES location of the vertices is not advertised, but that of the relations tables is. The relations tables can be passed on to any DVAlgorithm via it's PhysDesktop's P2PVInputLocations property (see examples below).

Automatic re-fitting in DVAlgorithm

The DVAlgorithm base class has a property ReFitPVs which can be used to automatically re-fit primary vertices each time the relatedVertex method is called (see Particle2PV). In practice, this method is called each time a PV-related cut is applied in the creation or selection of an LHCb::Particle. It is set to false by default. When set to true, primary vertices for a particle are re-fitted each time the best vertex for a given Particle is asked for. The results are cached, such that the re-fitting isn't performed for a particle that already has a "best" re-fitted primary vertex. At the end of each event, the DVAlgorithm writes the particles out to TES location "Phys/AlgoName/Particles" and the relations tables to ="Phys/AlgoName/Particle2VertexRelations". When re-fitting has been performed, these relations link particles to re-fitted vertices.

myPMaker = CombineParticles("PMaker")
myPMaker.Code = ....
myPMaker.ReFitPVs = True
MySequence.Members +=[myPMaker]

The relations tables can be used by following DVAlgorithms such that the same vertices are used in the selection and in following analysis stages:

from Configurables import FilterDesktop # FilterDesktop is a DVAlgorithm
myFilter = FilterDesktop("ParticleFilter")
myFilter.Code = .....
myFilter.PhysDesktop.P2PVInputLocations = "Phys/" + +"/Particle2VertexRelations"
MySequence.Members +=[myFilter]


DecayTreeTuple is just a DVAlgorithm that is used to write out quantities to a ROOT ntuple at some stage of your analysis. Therefore, everything that is said above about using the refitted vertices in a later stage of the analysis must also be applied to your DecayTreeTuple instance. If you do not use the refitted PVs with DecayTreeTuple, the BPV* quantities in your ntuple will be incorrect (i.e., you will see distributions extending past the value of the cut that you applied in your selection).

PVReFitterAlg: re-fit independently from particle selection and/or creation

The PVReFitterAlg is a GaudiAlgorithm which holds a pointer to an IPVReFitter. It produces re-fitted primary vertices and a relations table associating each particle to the vertices that were re-fitted using it. The table has artificial weights to maintain the order of the original primary vertices. The PVReFitterAlg's configuration properties allow the user to set the TES location of primary vertices and LHCb::Particles, and the output TES location of the resulting relations table. It is also possible to provide an input relations table location. In the example below, we re-fit primary vertices and create a Particle2Vertex::Table relating LHCb::Particles from "Phys/PMaker/Particles" to the re-fitted primary vertices and put it in "Phys/PMaker/Particle2ReFittedVertexRelations".

myPMaker = CombineParticles("PMaker")
myPMaker.Code = ....
mainLocation = "Phys/" +
MySequence.Members +=[myPMaker]
from Configurables import PVReFitterAlg
PVReFitter = PVReFitterAlg("PVReFitterAlg")
PVReFitter.ParticleInputLocation = mainLocation+"/Particles"
PVReFitter.VertexOutputLocation = mainLocation+"/RefittedVertices"
PVReFitter.P2VRelationsOutputLocation = mainLocation+"/Particle2ReFittedVertexRelations"
MySequence.Members += [PVReFitter]

The relations table can be used as input to additional DVAlgorithms. However, the relations have to be sorted according to some "bestness" criteria, since the DVAlgorithm assumes sorted relations (maybe this should be done automatically??) For more details of the sorting, see Particle2PV.

from Configurables import PVRelatorAlg
p2RefitPV = PVRelatorAlg("P2ReFitVertices")
p2RefitPV.P2PVRelationsInputLocation = mainLocation + "/Particle2ReFittedVertexRelations"
p2RefitPV.P2PVRelationsOutputLocation = mainLocation + "/P2ReFitPVSortedRelations"

from Configurables import FilterDesktop # FilterDesktop is a DVAlgorithm
myFilter = FilterDesktop("ParticleFilter")
myFilter.Code = .....
myFilter.PhysDesktop.P2PVInputLocations = mainLocation+"/P2ReFitPVSortedRelations"
MySequence.Members +=[p2RefitPV, myFilter]

-- JuanPalacios - 17 Jul 2009

This topic: LHCb > WebHome > LHCbComputing > DaVinci > RefitPV
Topic revision: r2 - 2009-07-17 - GreigCowan
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback