Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look inside a DST #6

Closed
betatim opened this issue May 8, 2015 · 2 comments
Closed

Look inside a DST #6

betatim opened this issue May 8, 2015 · 2 comments

Comments

@betatim
Copy link
Member

betatim commented May 8, 2015

Use an interactive python session to explore around the TES of a DST.

Show what is in these stripping locations/decisions, basically some tools to "debug" when things aren't working.

Some random bits of python that could be interesting/staring point for this. Quite Boole/Brunel centric though.

# Configuration done, run time!
appMgr = GP.AppMgr()
evt = appMgr.evtsvc()
det = appMgr.detsvc()
ft_det = det['/dd/Structure/LHCb/AfterMagnetRegion/T/FT']

for n in xrange(100):
    appMgr.run(1)

    digits = evt['/Event/MC/FT/Digits'].containedObjects()
    for digit in digits:
        digit_adcs.Fill(digit.adcCount())

This is from a dst-explore.py I have which contains various useful things, potentially broken in newer versions of DV

# SetupProject DaVinci v35r1
import sys

import GaudiPython as GP
from GaudiConf import IOHelper
from Configurables import LHCbApp, ApplicationMgr, DataOnDemandSvc
from Configurables import SimConf, DigiConf, DecodeRawEvent
from Configurables import CondDB, DstConf, PhysConf
from Configurables import LoKiSvc

MCParticle = GP.gbl.LHCb.MCParticle
Particle = GP.gbl.LHCb.Particle
Track = GP.gbl.LHCb.Track
MCHit = GP.gbl.LHCb.MCHit


def nodes(evt, node=None):
    nodenames = []

    if node is None:
        root = evt.retrieveObject('')
        node = root.registry()

    if node.object():
        nodenames.append(node.identifier())
        for l in evt.leaves(node):
            # skip a location that takes forever to load
            # XXX How to detect these automatically??
            if "Swum" in l.identifier():
                continue

            temp = evt[l.identifier()]
            nodenames += nodes(evt, l)

    else:
        nodenames.append(node.identifier())

    return nodenames

def advance(decision='B02DKWSD2HHHBeauty2CharmLine'):
    """Advance until stripping decision is true, returns
    number of events by which we advanced"""
    n = 0
    while True:
        appMgr.run(1)
        n += 1
        dec=evt['/Event/Strip/Phys/DecReports']
        if dec.hasDecisionName("Stripping%sDecision"%decision):
            break

    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc+= ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

from Configurables import DaVinci
dv = DaVinci()
dv.DataType = "2012"

lhcbApp = LHCbApp()
lhcbApp.Simulation = False
CondDB().Upgrade = False
# don't really need tags for looking around
#LHCbApp().DDDBtag = t['DDDB']
#LHCbApp().CondDBtag  = t['CondDB']

inputFiles = [sys.argv[-1]]
IOHelper('ROOT').inputFiles(inputFiles)


# Configuration done, run time!
appMgr = GP.AppMgr()
evt = appMgr.evtsvc()

print_decay = appMgr.toolsvc().create('PrintDecayTreeTool', interface="IPrintDecayTreeTool")

# New style decay descriptors, also known as LoKi decays
loki_decay_finder = appMgr.toolsvc().create('LoKi::Decay', interface="Decays::IDecay")
# Old style decay descriptors
old_decay_finder = appMgr.toolsvc().create("DecayFinder", interface="IDecayFinder")

# works
#decay_desc = "[[B0]cc -> (^D- => {^K- ^K+ ^pi-, ^K- ^pi+ ^pi-,^pi+ ^pi- ^pi-, ^K- ^K- ^pi+}) ^K-]cc"
# doesn't work
decay_desc = "[[B0]cc -> (^D- => {^K- ^K+ ^pi-, ^K- ^pi+ ^pi-,^pi+ ^pi- ^pi-}) ^K-]cc"
old_decay_finder.setDecay(decay_desc)

# process first event
appMgr.run(1)

# Get a small print out of what is there in the event
evt.dump()

# print out "all" TES locations
# prints out packed locations, so you need to know
# what the unpacked location is called to actually access it
print "-"*80
for node in nodes(evt):
    print node

# print out the stripping lines which fired for this event
print "-"*80
print evt['/Event/Strip/Phys/DecReports']

# Figure out why your decay descriptor does not work
# type the following into the python terminal
#advance()

#WS_candidates = evt['/Event/Bhadron/Phys/B02DKWSD2HHHBeauty2CharmLine/Particles']
#B = WS_candidates[0]
#print_decay.printTree(B)
# Can we find the decay?
#old_decay_finder.hasDecay(WS_candidates)

# Beware, you can not repeatedly call this. It somehow keeps track
# of how often it has been called/recursion stuff :-s
#head = Particle()
#old_decay_finder.findDecay(WS_candidates, head)
# head will contain the head of the decay tree
#print head
@apuignav
Copy link
Contributor

I have also some Moore-centric snippets which could also be useful, we can add them in here.

################################
# L0
################################
l0_report = TES["/Event/Trig/L0/L0DUReport"]
if not l0_report:
    continue
################################
# HLT1
################################
hlt1_reports = TES["/Event/Hlt1/SelReports"]
if not hlt1_reports:
    continue
################################
# HLT2
################################
hlt2_reports = TES["/Event/Hlt2/SelReports"]
if not hlt2_reports:
    continue
# Get events that pass my lines
two_body_cands = []
if hlt2_reports.selReport('Hlt2RadiativeIncHHGammaDecision'):
    two_body_cands.extend([cand.summarizedObject()
                           for cand in hlt2_reports.selReport('Hlt2RadiativeIncHHGammaDecision').substructure()])
three_body_cands = []
if hlt2_reports.selReport('Hlt2RadiativeIncHHHGammaDecision'):
    three_body_cands.extend([cand.summarizedObject()
                             for cand in hlt2_reports.selReport('Hlt2RadiativeIncHHHGammaDecision').substructure()])

@betatim
Copy link
Member Author

betatim commented May 25, 2015

This is done. @roelaaij might be interested in the trigger snippets

@betatim betatim closed this as completed May 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants