Accessing Event Data - PowerPoint PPT Presentation

About This Presentation
Title:

Accessing Event Data

Description:

can retrieve all collections or the default one. compiler checks type of retrieved objects ... StoreGate is responsible for that. ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 13
Provided by: markus56
Category:

less

Transcript and Presenter's Notes

Title: Accessing Event Data


1
Accessing Event Data
2
Objectives
  • After completing this lesson, you should be able
    to
  • Understand how objects are delivered to user
    algorithms.
  • Retrieve objects from the event data store within
    an algorithm.
  • Operate on objects collections.

3
Loading from Data Store
Unsuccessful ifrequested object is not present
Algorithm
(1) Retrieve object
4
StoreGatethe Athena Transient Store
  • Objects of arbitrary type can be added to SG
  • no more need to inherit from DataObject or
    ContainedObject (it does not hurt either)
  • works with STL and STL-like containers (including
    ObjectVector). Can support custom ones (HepMC)
  • Type-based hierarchy, type-safe access
  • no need to specify (and propagate!) object
    "paths"
  • object type is primary key, can retrieve all
    collections or the default one
  • compiler checks type of retrieved objects
  • optional "secondary key" (not only strings)
    allows to identify a specific data object

5
ObjectVectorltTgt
Atlfast uses typedefined ObjectVectorltTgt
collection objects ReconstructedParticleCollecti
on, CellCollection, ClusterCollection.
ObjectVectorltReconstructedParticlegt
ObjectVectorltCellgt
ObjectVectorltClustergt
  • What you fill in are pointers to T
  • Iteration like STL vector
  • ObjectVectorltMCParticlegt pobjColl...Object
    VectorltMCParticlegtiterator iMCPfor(
    iMCPpobjColl-gtbegin()
  • iMCP ! pobjColl-gtend() iMCP ) log
    ltlt MSGINFO
  • ltlt (iMCP)-gtparticleID().id()

iMCP" is an iterator to a pointer to a
MCParticle Athena stores pointers to things in
its collections, therefore (iMCP) is a pointer
to a MCParticle
6
TDS Caveats
  • The TDS expects full ownership.
  • Do not destroy existing objects! Theyre not
    yours!
  • Deleting recorded objects typically results in an
    access violation!
  • StoreGate is responsible for that.
  • The delete operator is invoked automatically at
    the end of each event.
  • Almost const access
  • You can't modify an object you retrieve
  • compiler error!
  • you can, when recording an object, allow
    downstream algorithms to modify it
  • use sparingly!

7
StoreGate TDS access
  • include StoreGate/StoreGateSvc.h
  • Declare StoreGateSvc pointer
  • private data member in your header file
  • private
  • StoreGateSvc m_sgSvc
  • Get the StoreGate service
  • StatusCode sc service(StoreGateSvc, m_sgSvc)
  • if (sc.isFailure( )) print error message
  • return StatusCodeFAILURE

8
Record RetrieveTo key or not to key
  • To record an object/container
  • StatusCode sc m_sgSvc?record(ptr_obj/cont
  • , m_Obj/ContKey)
  • if ( sc ! StatusCodeSUCCESS) print some
    error message

ptr_obj/cont is pointer to the object/containerm_
Obj/ContKey is the optional key given to your
object/container for keyed access
  • To retrieve this object
  • const DataHandleltObject/Containergt obj/cont
  • StatusCode sc m_sgSvc?retrieve(obj/cont
  • , m_Obj/ContKey)

Use the DataHandleltTgt as a pointer/iterator to
Tm_Obj/ContKey is the given ltoptionalgt key while
recording this object/container
9
Hands On Access Object Collections
  • In AnalysisSkeleton.h
  • Forward declare StoreGate service
  • class StoreGateSvc
  • Inside Atlfast namespace declare
  • class ReconstructedParticle
  • class Cell
  • class Cluster
  • Declare pointer to StoreGate service
  • StoreGateSvc m_sgSvc
  • declare additional locations
  • stdstring m_cellLocation
  • stdstring m_clusterLocation
  • In the jobOptions, specify the key of objects to
    be retrieved
  • AnalysisSkeleton.CellLocation
    /Event/AtlfastCells
  • AnalysisSkeleton.ClusterLocation/Event/AtlfastCl
    usters

10
Hands On Access Object Collections
  • In AnalysisSkeleton.cxx
  • include StoreGate/StoreGateSvc.h
  • Declare additional properties to the framework
  • declareProperty(CellLocation, m_cellLocation)
  • declareProperty(ClusterLocation,
    m_clusterLocation)
  • Inside initialize( )
  • If (service(StoreGateSvc, m_sgSvc).isFailure(
    ))
  • log ltlt MSGALWAYS ltlt No StoreGate!!!!!!! ltlt
    endreq
  • Access Atlfast collections inside execute( )
  • const DataHandleltReconstructedParticleCollectiongt
    particles
  • const DataHandleltCellCollectiongt cells
  • const DataHandleltClusterCollectiongt clusters
  • m_sgSvc-gtretrieve(particles, m_particleLocation)
  • m_sgSvc-gtretrieve(cells, m_cellLocation)
  • m_sgSvc-gtretrieve(clusters, m_clusterLocation)

11
Hands On Access Object Collections
  • Algorithms can declare additional member
    functions
  • Add typedef definition of the collection
  • include AtlfastCode/ReconstructedParticleCollect
    ion.h
  • Declare and define private member function
  • void dumpParticles(MsgStream log,
    ReconstructedParticleCollection particles)
  • Inside execute( )
  • // Work on collections
  • MsgStream log (msgSvc(), name())
  • if (particles-gtsize( )) dumpParticles(log,
    particles)
  • Inside dumpParticles( ), iterate in the
    collection
  • ReconstructedParticleCollectionconst_iterator
    theParticle
  • for (theParticle particles-gtbegin()
  • theParticle lt particles-gtend()
  • theParticle)

12
Hands On Access Object Collections
  • For each selected particle, printout values
  • // dump out particles
  • log ltlt MSGINFO ltlt theParticle ltlt endreq
  • // print pT
  • double pT (theParticle)-gtpT( )
  • log ltlt MSGINFO ltlt Particle pT ltlt pT ltlt
    endreq
  • Additional access methods for particles
  • eta( )
  • phi( )
  • eT( )
  • mT( )
  • momentum( ) // HepLorentzVector

Set ApplicationMgr.EvtMax 100
Write a Comment
User Comments (0)
About PowerShow.com