DSTWriters

This page explains how to use the DSTWriter configurables, found in the Phys/DSTWriters package. The DSTWriters are used to produce stripped DSTs and MicroDSTs.

MicroDSTWriter

The MicroDSTWriter configurable is a configurable designed for a "typical" physics use-case, but has limited flexibility and hides away many details of what is going on. There is an example script in Ex/MicroDSTExample/options/TestMicroDSTMake.py, where one can clearly see how it is standalone and requires some interplay with another LHCb application configurable, in this case, DaVinci(). The MicroDSTWriter requires that the selections that are to be used to write the MicroDST be in the form of SelectionSequences. For more details on how to write selections like that, see the Particle Selections page and DaVinci Tutorial 4.

SelDSTWriter

The SelDSTWriter is identical to the MicroDSTWriter, except that it also copies the full contents of the input DST for events that pass each selection. It is used by the stripping to store the candidates for each stripping line that passed a selection. The configuration for different scenarios is the same as for the MicroDSTWriter, except that some of the default values of some slots are different. Also, since it copies the full DST, there is no need to set CopyODIN, CopyRecHeader, CopyPVs or CopyProtoParticles.

Examples

The following examples have been written using a MicroDSTWriter, but the use of the SelDSTWriter is the same, so simply replace "MicroDSTWriter" with "SelDSTWriter" where applicable. These are based on the full working examples found in $DSTWRITERTESTSROOT/options.

Create a MicroDST from a simple selection.

from Gaudi.Configuration import *
from Configurables import DaVinci, MicroDSTWriter

# Make a simple selection sequence
from PhysSelPython.Wrappers import AutomaticData, SelectionSequence
selSequence = SelectionSequence('SeqKaons', TopSelection = AutomaticData(Location = 'Phys/StdTightKaons'))

conf = MicroDSTWriter("MicroDST0")
conf.OutputFileSuffix = "Test"
conf.CopyProtoParticles = False
conf.SelectionSequences = [selSequence]
conf.CopyL0DUReport = False
conf.CopyHltDecReports = False
conf.CopyMCTruth = True
conf.CopyBTags = True
microDST0Seq = conf.sequence() # this is a GaudiSequencer with everything that is needed.

The above configures the writer and makes a GaudiSequencer available via the MicroDSTWriter.sequence() method. This is then picked up by the application:

dv = DaVinci()
dv.DataType = 'DC06'
dv.EvtMax = 100
dv.UserAlgorithms = [microDST0Seq]
dv.Input =  [ ....... ]

Data will be written to '/Event/SeqKaons'.

Create a MicroDST with an OR of more than one selection.

from Gaudi.Configuration import *
from Configurables import DaVinci, MicroDSTWriter

from PhysSelPython.Wrappers import AutomaticData, SelectionSequence, MultiSelectionSequence

# create some simple selections based on common particles.
pions = AutomaticData(Location = 'Phys/StdTightPions')
muons = AutomaticData(Location = 'Phys/StdTightMuons')
kaons = AutomaticData(Location = 'Phys/StdTightKaons')
jpsis = AutomaticData(Location = 'Phys/StdLooseJpsi2MuMu')

pionSeq = SelectionSequence('SeqPions', TopSeleciton = pions)
muonSeq = SelectionSequence('SeqMuons', TopSelection = muons )
kaonSeq = SelectionSequence('SeqKaons', TopSelection = kaons)
jpsiSeq = SelectionSequence('SeqJpsi', TopSelection = jpsis )

multiSeq = MultiSelectionSequence('Cocktail', Sequences = [kaonSeq, pionSeq, muonSeq, jpsiSeq])

dstWriter = MicroDSTWriter("MicroDST0", 
                      OutputFileSuffix = "Test",
                      SelectionSequences = [multiSeq],
                      CopyFlavourTags = False,
....
....
                       )

DaVinci().UserAlgorithms = [dstWriter.sequence()]
This writes data to '/Event/Cocktail'

Create a MicroDST with all the stripping selections in a given stripping stream.

from Gaudi.Configuration import *
from Configurables import DaVinci, MicroDSTWriter
from StrippingConf.Configuration import StrippingConf
from PhysSelPython.Wrappers import AutomaticData, SelectionSequence, MultiSelectionSequence

# Get location of all candidates in stream Dimuon
from StrippingSelections.StreamDimuon import stream
streamLocations = [stream.name() + '/' + loc for loc in stream.outputLocations()]

# Create a list of SelectionSequences, one for each location.
# This is done by creating an AutomaticData for each location, then making a SelectionSequence
# with it.
selections = []
for loc in streamLocations :
    sel = AutomaticData(Location = loc)
    selections.append(SelectionSequence('StripSeq'+ sel.name(), TopSelection = sel) )

# Make an OR of all the selections
multiSeq = MultiSelectionSequence('DiMuonSeq', Sequences = selections)

dstWriter = MicroDSTWriter("MyDSTWriter",
                           SelectionSequences = [multiSeq],
                           OutputFileSuffix = 'TestDiMuon',
...
...
                           )

...
DaVinci().UserAlgorithms = [dstWriter.sequence()]

Create a selection DST with some event cuts.

Here we want to select events where there is are at least 2PVs and write the full DST, but no extra data.

from Gaudi.Configuration import *
from Configurables import LoKi__VoidFilter as VoidFilter
from Configurables import DaVinci, SelDSTWriter
from PhysSelPython.Wrappers import AutomaticData, SelectionSequence, EventSelection

moreThan2PVs = VoidFilter('MoreThan2PVFilter',  Code = 'CONTAINS("Rec/Vertex/Primary")>1') 

seq = SelectionSequence('SeqDiMuon', TopSelection = EventSelection(moreThan2PVs) )

dstWriter = SelDSTWriter("MyDSTWriter",
                         SelectionSequences = [seq],
                         OutputFileSuffix = 'Test2PVs'
                         ) 

If we wanted to write a DST or MicroDST with a particle selection and the event selection criteria we can use the EventPreSelector field of SelectionSequence. The following example writes a DST with all events with at least 2 primary vertices and at least one StdLooseJpsi2MuMu.

from Gaudi.Configuration import *
from Configurables import LoKi__VoidFilter as VoidFilter
from Configurables import DaVinci, SelDSTWriter
from PhysSelPython.Wrappers import AutomaticData, SelectionSequence

moreThan2PVs = VoidFilter('MoreThan2PVFilter',  Code = 'CONTAINS("Rec/Vertex/Primary")>1') 
jpsis = AutomaticData(Location = 'Phys/StdLooseJpsi2MuMu')
seq = SelectionSequence('SeqJpsi', TopSelection = jpsis, EventPreSelector = [moreThan2PVs] )

dstWriter = SelDSTWriter("MyDSTWriter",
                         SelectionSequences = [seq],
                         OutputFileSuffix = 'Test2PVs'
                         ) 

-- JuanPalacios - 29-Jul-2010

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2010-07-29 - unknown
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback