SLAC PEP-II
BABAR
SLAC<->RAL
Babar logo
HEPIC E,S & H Databases PDG HEP preprints
Organization Detector Computing Physics Documentation
Personnel Glossary Sitemap Search Hypernews
Unwrap page!
Simulation Home
Sim Codes
Event Generators
Bogus/BgsApp
SimApp
Bear
Moose
Fast Simulation
Geant4 Home
Subsystems
PEP
SVT
DCH
DRC
EMC
IFR
Mixing/Trigger
Backgrounds
Mixing
Trigger Simulation
MC Truth/QA
MC Truth
Micro/Mini
QA Histograms
Sim Error Reports
REMEDY
MC Production
Production Home
Test Production
Tools
Database
CERNLIB
CLHEP
Event display
RandControl
Scripts
Check this page for HTML 4.01 Transitional compliance with the
W3C Validator
(More checks...)

Simu to Reco Data Flow status

30/10/95


Earlier progress notes (from recent Monday meetings) on dbio-based data flow are available on the Phys/Sim page.

Overview

Starting point: a data structure description file for dbio, bbdata.ds. Presently defines data structures for
  • Geant tracks
  • Geant vertices
  • Geant hits for all detector subsystems (SVT, DCH layer hits, DCH wire hits, ATC, DRC, EMC, IFR)
The description file syntax supports structures containing
  • integer, real, double, and char (string) types
  • single or multidimensional arrays for all types
  • nested structures

Sample extract of the data structure description:

mode babardata  ! usage mode = BaBar data structure definition.
database bbdata 0100  ! Name and version number, for version control
!
!  ******************** Geant tracks
!
incprefix G3Data    ! prefix #includes with this
!
incname gTrack      ! include file for Geant tracks
!
template gTrack
  int n    ! track number
  int id   ! particle ID
  real px  ! momentum at origin
  real py
  real pz
  real e   ! energy
  int ivtx ! vertex number
end template

dimension gTrackMax 100    ! dimension parameter
record gTrack(gtrackMax)   ! instantiate the structure array
...
end

The ds file is parsed by the dbio tool -- formerly a lex program, now rewritten as a conventional C program -- to generate several output files which provide the code implementing access to the data in Fortran, C and C++ and implementing I/O of the data via an XDR-based I/O utility, McFio, developed at Fermilab.
  • Sidebar on XDR: XDR is a standard Unix package (developed by Sun, and used (among other places) in NFS) supporting efficient, binary, platform independent I/O of user-defined data structures. It is available free on all platforms as part of the standard Unix library.
  • Sidebar on McFio: After reviewing available options for event I/O including Farfalla, Cheetah, Zebra, etc., and rejecting all of them, Fermilab decided to develop its own I/O toolkit for fast, efficient event I/O optimized for high throughput, large data volumes, portability, and tape as well as disk support (ie. our requirements exactly). They developed it for application in their fast simulation program MCFast, are supporting it for wider use, and welcome its use in BaBar. Documentation on mcfio is available at the Fermilab computer simulation group page.
dbio is a rechristening of the latest version of dbin, renamed to reflect the extension of its functionality to output and (more importantly) because it will coexist with dbin for some time while we gradually migrate the geometry database from dbin to dbio. dbio adds to the database functionality of dbin a usage mode in which data structures are just defined, not filled with data; it is this mode that is being used in this data flow implementation. Documentation is available for this new version of dbin but has not yet been adapted for the further extensions incorporated for the BaBar data model application.

Defining the data structures for simu to reco data movement using dbio provides a number of benefits:

  • All the code required to access the data from Fortran, C or C++ is generated automatically, eliminating a nasty maintenance problem and greatly easing initial implementation, modification and extension
  • All the code required to perform I/O of the data structures -- using, as mentioned, an I/O package well matched to our needs -- is also generated automatically, again easing maintenance and lowering the hurdle on implementing I/O
  • There is a single maintenance point and reference point, the ds file(s), for the data structures
  • The problem of storing geometry information and run conditions on the output file is automatically solved, because these are already defined using dbin and can easily be migrated to dbio
  • The approach provides an easy means of moving other data out of the simulation and into the reconstruction, eg. geometry constants calculated in the course of building the bbsim geometry and needed in the reconstruction. The data can be stored in or moved to a dbio-defined data structure and is then easily moved to an output file and into the reco or other C++, C or Fortran application.
  • I/O of HEPEVT records to the output file (which we will want) is already implemented for McFio in the latest version of stdhep.

Files generated by dbio

xxxGHit.inc
The Fortran definition of the Geant hit data structure for subsystem xxx (svt, dch, atc, drc, emc, ifr; but note that for dch there are two hit types, dchGLayHit and dchGWirHit), and a common block containing the array of this structure
xxxGHit.h
The C definition of the structure. Implemented as a C struct. C access to the structure is via pointers that point to the Fortran common block; ie. C and Fortran reference the same data space.
xxxGHit.dhh
The class data members for the elements of the hit structure, and the declarations for the accessor member functions. eg.
       // atcGHit.dhh: Define C++ class data members
       protected: float _x;
       public: float& getX() const; void setX(const float);
       
xxxGHit.dcc
The accessor functions for the elements of the structure for the class providing C++ access to the data. The class is called XxxGHit. Sample accessor functions:
         float& AtcGHit::getX() {return _x;};
         void AtcGHit::setX(const float f) {_x = f; return;};
         float& AtcGHit::getY() {return _y;};
         void AtcGHit::setY(const float f) {_y = f; return;};
This file is #include'd in the class implementation source file.
xxxGHitInput.dcc
This file contains the init constructor for the class. It loads the class data members from the C structure (mapped to the Fortran common block) loaded by dbio from the XDR file.
dbiXxxGHitLoad.cc
A function that moves the hits from the C structure to C++ class objects in a linked list (HepAList).
bbdataXDR.c
Contains the XDR filter routines for all dbio-defined structures. These routines implement the movement of the data (in both directions) between memory and the XDR file.
bbdataXDRmgr.c
Routines that manage the I/O of all instances of all defined data structures (they call the routines in bbdataXDR.c)
bbdataXDRall.c
The master routine, called by the higher level I/O code, that by default performs I/O of all defined dbio structures. Management of what data structures are actually written requires a manual edit of or a more sophisticated implementation of this routine. (Or, this routine can be used solely as a template to manually implement the needed I/O routines. This is likely to be the short term approach.)
bbdataXDRinc.h
Declarations, includes needed by the bbdataXDR* code.
bbdata_ds.h, bbdata_ds.inc
Version information for the database and the dbio package, used for version checking.

Other routines in the data path implementation

XxxHitsToDs.F
Routines called within bbsim to move hits from the Geant hit bank to the dbio-defined data structures where they are ready for output.
HitsToDs.F
The master steering routine for the XxxHitsToDs.F
TrksToDs.F
Moves Geant tracks and vertices to dbio-defined track and vertex structures, ready for output.
dswrite.F
Routine called from guout.F in bbsim to write the dbio-defined data structures to the McFio XDR file.
event_to_xdr.c
The routine passed to McFio (in dswrite.F) that manages output of dbio-defined data structures. It in turn calls the autogenerated I/O code.

And code for the C++ side...

get_commons.F
Pulls in the data structure common blocks. Must be linked by C and C++ code that uses dbio structures, because the structures are implemented as Fortran common blocks pointed at in the C code.
xdrrd.c, containing xdrrdInit, xdrrdEvent, xdrrdEventCheck, xdrrdClose
A standalone C program with C functions for initializing McFio and opening the input file, reading events into the C structures, and closing the file (or going to the next file).
XxxData/ packages: XxxGHit.cc, XxxGHit.hh etc.
Define the C++ classes. They #include autogenerated code.

Present Status

The simulation side, bbsim generating a dbio output file containing the Geant track and vertex info and the hits for the subsystems, is complete -- except the two varieties of DCH hit for which the dbio structure filling code still has to be put in.

On the reconstruction side, auto generation of the C++ class definition code is complete, its implementation is complete and tested, and test applications are running.

All code is committed to the archive (not tagged as a release yet).

We have very nearly arrived at a point where all hit-level bbsim information is available in a standard way in the emerging reconstruction framework. We will shortly be at a point where we can generate a first round of standard simulation files readable with code provided by the computing group, for use in trigger studies, reconstruction development, etc.

Location of the code

The code resides in the following SRT modules:
dbio
The dbio package. Will peacefully coexist with the dbin package until we migrate fully to dbio (timescale: months).
DbiEvent
The hitio.ds definition file, the code automatically generated when dbio processes it, and the other data flow routines (dswrite, event_to_xdr, XxxHitsToDc.F, etc.)
XxxData (Xxx = Atc, Dch, Drc, Emc, Ifr, Svt, G3)
The subsystem (and Geant) class definitions for data classes.
Framework/src/APPFileInputModule.cc and FrameExample
Framework code implementing a test application to read the dbio file

Summary of the data flow

  • bbsim's GUOUT calls DSWRITE
  • DSWRITE is controlled by a new control block in run.db called dbio (file name, write flags)
  • DSWRITE initializes McFio on first entry
  • Also on first entry, DSWRITE writes the run header, including geometry info and run conditions [not implemented yet]
  • DSWRITE calls McFio with event_to_xdr as a user callback to perform event I/O
  • event_to_xdr calls the autogenerated XDR I/O code to write the dbio-defined data structures to the XDR file
  • DSWRITE (optionally) writes the HEPEVT record(s) for the event to the XDR file, using McFio's built-in HEPEVT I/O (not used yet)
Now the data is on an XDR output file. On the reconstruction side...
  • dbio-generated code reads the data into Fortran common blocks, exactly as written (controlled by xdrrd utility routines)
  • the data is accessible to C/C++ via dbio-defined C structures that map directly onto the Fortran common block
  • more auto-generated code moves the data from the Fortran common blocks to data class objects, created as needed (dbiXxxxLoad routines)
  • the user accesses the data through object accessor methods (getXxx, putXxx)