lcio a persistency framework for lc detector simulation studies frank gaede, desy, it linear...

34
LCIO LCIO A persistency framework for LC A persistency framework for LC detector simulation studies detector simulation studies Frank Gaede, DESY, IT Frank Gaede, DESY, IT Linear Collider Linear Collider Simulation Workshop SLAC Simulation Workshop SLAC May 19-22 2003 May 19-22 2003

Post on 22-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

LCIO LCIO A persistency framework for LC A persistency framework for LC

detector simulation studiesdetector simulation studies Frank Gaede, DESY, ITFrank Gaede, DESY, IT

Linear Collider Simulation Linear Collider Simulation Workshop SLAC May 19-22 Workshop SLAC May 19-22

20032003

2Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

PeoplePeople

Ties Behnke - DESY/SLACTies Behnke - DESY/SLAC Frank Gaede - DESYFrank Gaede - DESY Norman Graf - SLACNorman Graf - SLAC Tony Johnson - SLACTony Johnson - SLAC Paulo Mora de Freitas - IN2P3Paulo Mora de Freitas - IN2P3

3Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

OutlineOutline

IntroductionIntroduction Software designSoftware design APIAPI Data modelData model StatusStatus SummarySummary

4Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

MotivationMotivation

Generator

geometry

AnalysisRecon-

structionSimulation

LCIO Persistency Framework

Java, C++, FortranGeant3, Geant4

Java, C++, FortranJava, C++, Fortran

5Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

data model

The Persistency Framework

LCIO

contents

data format persistency

data access API implementation

6Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

LCIO requirementsLCIO requirements need Java, C++ and f77 (!) implementationneed Java, C++ and f77 (!) implementation extendable data model for current and future extendable data model for current and future

simulation studiessimulation studies user code separated from concrete data user code separated from concrete data

formatformat -> need to be flexible for future decisions on -> need to be flexible for future decisions on

persistencypersistency three general use casesthree general use cases

writing data (simulation)writing data (simulation) reading and updating data (reconstruction)reading and updating data (reconstruction) read only access to data (analysis)read only access to data (analysis)

needed a.s.a.p. -> keep it simple !needed a.s.a.p. -> keep it simple !

7Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

API design – simulation API design – simulation datadata

untyped collections

tagging interface

data entities

Interface fora) writing data (simulation)

b) read only access (analysis)

user extensions

8Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

API & implementationAPI & implementationabstract event abstract io

concrete classes

persistency implementation

10Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

API definition for Java and API definition for Java and C++C++

use AID Abstract Interface Definitionuse AID Abstract Interface Definition tool from tool from freehep.org freehep.org (M. Dönzelsmann)(M. Dönzelsmann) used successfully in the AIDA projectused successfully in the AIDA project

define interfaces in Java-like language define interfaces in Java-like language with C++ extensionswith C++ extensions -> generates files with Java interfaces -> generates files with Java interfaces -> generates C++ header files with pure -> generates C++ header files with pure

abstract base classesabstract base classes use use javadocjavadoc for documentation for documentation

independent implementations in Java and independent implementations in Java and C++C++ -> keep Java “pure” i.e. machine independent-> keep Java “pure” i.e. machine independent

11Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

AIDAID example: example:

12Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

API documentationAPI documentation

API documentationcreated from java implementation

with javadoc

13Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

C++ developer C++ developer documentationdocumentation

documentationcreated from C++

implementationwith doxygen

14Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Example: reading dataExample: reading data LCReader* lcReader =LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;LCFactory::getInstance()->createLCReader() ; lcReader->open( "myFile" ) ;lcReader->open( "myFile" ) ; LCEvent *myEvt ;LCEvent *myEvt ; while( ( myEvt = while( ( myEvt = lcReader->readNextEvent()lcReader->readNextEvent() ) != 0 ){ ) != 0 ){ cout << " Evt : " << cout << " Evt : " << myEvt->getEventNumber()myEvt->getEventNumber() << " - " << << " - " << myEvt->getRunNumber()myEvt->getRunNumber()

<< ": " << << ": " << myEvt->getDetectorName()myEvt->getDetectorName() << endl ;<< endl ;

}} cout << endl ;cout << endl ; lcReader->close() ;lcReader->close() ; independent of persistency

implementation !

15Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Example: reading event Example: reading event collectionscollections

…… LCEvent *evt ;LCEvent *evt ;while( ( while( ( evt =evt = lcReader->readNextEvent()lcReader->readNextEvent() ) != 0 ){ ) != 0 ){ const LCCollection* const LCCollection* col =col = evt-evt-

>getCollection( “EcalHits”);>getCollection( “EcalHits”); int nHits = int nHits = col->getNumberOfElements() ;col->getNumberOfElements() ; for( int i=0 ; i< nHits ; i++ ){for( int i=0 ; i< nHits ; i++ ){ const CalorimeterHit* hit = const CalorimeterHit* hit =

dynamic_cast<const CalorimeterHit*>dynamic_cast<const CalorimeterHit*> ( col-( col-

>getElementAt( i ) ) ;>getElementAt( i ) ) ; const float* const float* x = hit->getPosition() ;x = hit->getPosition() ; cout << “x: " << x[0] << ", " << x[1] << ", " << x[2] cout << “x: " << x[0] << ", " << x[1] << ", " << x[2] << " energy: " << << " energy: " << hit->getEnergy() hit->getEnergy() << endl ;<< endl ; }…}…

untyped collections addressed via name

16Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

LCReader APILCReader API

• “direct access” via fast skip• read next event/run• callbacks for modules

17Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Example: writing data Example: writing data (events)(events)

LCWriter* lcWrt = LCFactory::getInstance()-LCWriter* lcWrt = LCFactory::getInstance()->createLCWriter() ;>createLCWriter() ;

lcWriter->open( "myFile" ) ;lcWriter->open( "myFile" ) ; for( int i=0; i<NEVENT; i++ ){for( int i=0; i<NEVENT; i++ ){ LCEventImpl* evt = new LCEventImpl() ;LCEventImpl* evt = new LCEventImpl() ; evt->setRunNumber( rn ) ;evt->setRunNumber( rn ) ; evt->setEventNumber( i ) ;evt->setEventNumber( i ) ;// add collections ...// add collections ... lcWrt->writeEvent( evt ) ;lcWrt->writeEvent( evt ) ; delete evt ;delete evt ; // C++ only :) // C++ only :) }} lcWriter->close() ;lcWriter->close() ;

use LCIO implementation classes or own classes for writing !

18Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Example: writing Example: writing collectionscollections

LCCollectionVec* trkVec = LCCollectionVec* trkVec = new new

LCCollectionVec( LCIO::TRACKERHIT ) ;LCCollectionVec( LCIO::TRACKERHIT ) ; for(int j=0;j<NHITS;j++){for(int j=0;j<NHITS;j++){ TrackerHitImpl* hit = new TrackerHitImpl ;TrackerHitImpl* hit = new TrackerHitImpl ; hit->setdEdx( 30e-9 ) ;hit->setdEdx( 30e-9 ) ; double pos[3] = { 1., 2., 3. } ;double pos[3] = { 1., 2., 3. } ; hit->setPosition( pos ) ;hit->setPosition( pos ) ; trkVec->push_back( hit ) ;trkVec->push_back( hit ) ; }} evt->addCollection( (LCCollection*) trkVec , evt->addCollection( (LCCollection*) trkVec ,

“TPCHits” ) ;“TPCHits” ) ;… … // write event// write event

19Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

LCWriter APILCWriter API

20Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

LCIO Fortran interfaceLCIO Fortran interface Fortran support forFortran support for

legacy software (e.g. BRAHMS legacy software (e.g. BRAHMS reconstruction)reconstruction)

non OO-analyses code (“old guys”)non OO-analyses code (“old guys”) not a third implementation of the library not a third implementation of the library

– use C++-wrapper functions and – use C++-wrapper functions and cfortran.hcfortran.h instead: instead: one function for every class member functionone function for every class member function use integers to store pointers ! use integers to store pointers ! have factory and delete functionshave factory and delete functions -> OO-like code in fortran-> OO-like code in fortran

21Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

LCIO f77 example: LCIO f77 example:

22Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Persistency Persistency ImplementationImplementation

use SIO: Simple Input Outputuse SIO: Simple Input Output developed at SLAC for NLC developed at SLAC for NLC

simulationsimulation already used in hep.lcd frameworkalready used in hep.lcd framework features:features:

on the fly data compressionon the fly data compression some OO capabilities, e.g. pointerssome OO capabilities, e.g. pointers C++ and Java implementation availableC++ and Java implementation available

23Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

The Data Model - The Data Model - OverviewOverview

SimHeader

Event

TrackerHit

CalorimeterHit

RunHeader

RecoHeader

ReconstructedObject

ReconstructedParticleMCParticle

Track

Cluster

SIMReco

for details see transperencies after summary

24Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Status of LCIOStatus of LCIO

first Java and C++ implementation first Java and C++ implementation (simulation data!)(simulation data!) integrated into Mokka simulation framework integrated into Mokka simulation framework

latest release mokka-01-05 writes Hits in LCIOlatest release mokka-01-05 writes Hits in LCIO ff77 prototype 77 prototype

demonstrating the designdemonstrating the design complete integration into simulation software complete integration into simulation software

chains in the next months:chains in the next months: US: hep.lcd (Java) ? -> US: hep.lcd (Java) ? -> to be discussed at this to be discussed at this

workshopworkshop Europe: Mokka (C++)/BRAHMS-reco(f77)Europe: Mokka (C++)/BRAHMS-reco(f77)

25Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

SummarySummary LCIO is a persistency framework for LCIO is a persistency framework for

linear collider simulation softwarelinear collider simulation software Java, C++ and f77 user interfaceJava, C++ and f77 user interface LCIO is currently implemented in LCIO is currently implemented in

simulation frameworks: simulation frameworks: hep.lcd hep.lcd Mokka/BRAHMS-recoMokka/BRAHMS-reco

-> other groups are invited to join-> other groups are invited to join see LCIO homepage for more details: see LCIO homepage for more details:

http://www-it.desy.de/physics/projects/simsoft/lcio/http://www-it.desy.de/physics/projects/simsoft/lcio/index.htmlindex.html

26Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - Data model - LCRunHeader LCRunHeader

block: RunHeaderblock: RunHeader int: runNumberint: runNumber string: detectorNamestring: detectorName string: descriptionstring: description string[]: activeSubdetectorsstring[]: activeSubdetectors

=> describes the run setup=> describes the run setup

27Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - Data model - LCEventHeaderLCEventHeader

EventHeaderEventHeader int: runNumberint: runNumber int: evtNumberint: evtNumber string: detectorNamestring: detectorName String[]: subdetectorNameString[]: subdetectorName blockNames:blockNames:

string: blockNamestring: blockName string: blockTypestring: blockType

28Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model – LCEvent Data model – LCEvent (sim)(sim)

MCParticleMCParticle pntr: parentpntr: parent pntr: secondparentpntr: secondparent pntr[]: daughterspntr[]: daughters int : pdgid:int : pdgid: int : hepevtStatusint : hepevtStatus

(0,1,2,3 HepEvt)(0,1,2,3 HepEvt)

(201, 202 sim. decay)(201, 202 sim. decay)

MCParticle cont.MCParticle cont. double[3]: start double[3]: start

(production vertex)(production vertex) float[3] : float[3] :

momentummomentum(at vertex)(at vertex)

float: energyfloat: energy float: chargefloat: charge

29Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (sim)(sim)

TrackerHitTrackerHit string: subdetectorstring: subdetector

int: hitFlags (detector specific: Id, key, int: hitFlags (detector specific: Id, key, etc.)etc.)

double[3]: positiondouble[3]: position float: dEdxfloat: dEdx float: timefloat: time pntr: MCParticle pntr: MCParticle

30Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (sim)(sim)

CalorimeterHitCalorimeterHit string: subdetectorstring: subdetector

int: cellId0int: cellId0 int: cellId1int: cellId1 float: energyfloat: energy float[3]: position – optional (file size!)float[3]: position – optional (file size!) particle contributions:particle contributions:

pntr: MCParticlepntr: MCParticle float: energyContribution float: energyContribution float: timefloat: time int: PDG (of secondary) - optionalint: PDG (of secondary) - optional

31Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (reco)(reco)

OutputHeaderOutputHeader int: isrFlagint: isrFlag float: colliderEnergyfloat: colliderEnergy int: flag0 int: flag0 (to be defined)(to be defined) int: flag1 int: flag1 (to be defined)(to be defined) int: reconstructionProgramTagint: reconstructionProgramTag float: Bfieldfloat: Bfield

-> could be combined with global header…-> could be combined with global header…

32Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (reco)(reco)

TrackTrack int: tracktype int: tracktype (full reconstr, TPC only, Muon (full reconstr, TPC only, Muon only, etc.)only, etc.) float: momentumfloat: momentum float: thetafloat: theta float: phifloat: phi float: chargefloat: charge float: d0 float: d0 (Impact Parameter in r-phi)(Impact Parameter in r-phi) float: z0 float: z0 (Impact Parameter in r-z)(Impact Parameter in r-z) float[15]: cov.matrixfloat[15]: cov.matrix float: reference point float: reference point (x, y, z)(x, y, z) float: chi**2 of fitfloat: chi**2 of fit float[10]: dEdx float[10]: dEdx (weights and probabilities)(weights and probabilities) TrackerHits: - optional TrackerHits: - optional

pntr: TrackerHitpntr: TrackerHit

33Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (reco)(reco)

ClusterCluster int: detector int: detector ((type of cluster: ECAL, HCAL, combined…type of cluster: ECAL, HCAL, combined…)) int: clustertype int: clustertype (neutral, charged, undefined cluster)(neutral, charged, undefined cluster) float: energyfloat: energy float[3]: position float[3]: position (center of cluster x, y, z)(center of cluster x, y, z) float[6]: errpos float[6]: errpos (cov. matrix of position)(cov. matrix of position) float: theta float: theta (intrinsic direction: theta at position)(intrinsic direction: theta at position) float: phi float: phi (intrinsic direction: phi at position)(intrinsic direction: phi at position) float[3]: errdir float[3]: errdir (cov. matrix of direction)(cov. matrix of direction) float[6]: shapeParameters (definition needed)float[6]: shapeParameters (definition needed) float[3]: weights float[3]: weights ((compatible with em., had., muon)compatible with em., had., muon) CalorimeterHits: - optionalCalorimeterHits: - optional

pntr: CalorimeterHit pntr: CalorimeterHit float: contributionfloat: contribution

34Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (reco)(reco)

ReconstructedParticleReconstructedParticle int: primaryFlag (int: primaryFlag (0: 0:

secondary, 1: primary)secondary, 1: primary) int: ObjectType int: ObjectType (charged/ (charged/

neutral particle)neutral particle) float[3]: 3-Vec float[3]: 3-Vec (px, py, pz)(px, py, pz) float: energyfloat: energy float[10]: covariance float[10]: covariance

matrixmatrix float: chargefloat: charge float[3]: reference float[3]: reference

position for 4-vectorposition for 4-vector float[5]: PID_type float[5]: PID_type

(hypotheses for e, g, pi, K, (hypotheses for e, g, pi, K, p, ...)p, ...)

ReconstructedParticle ReconstructedParticle cont.cont. Tracks:Tracks:

pntr: pntr: TrackTrack float:weightfloat:weight

Clusters:Clusters: pntr: pntr: ClusterCluster float:weightfloat:weight

MCParticles:MCParticles: pntr: pntr: MCParticleMCParticle float:weightfloat:weight

have separate MC-link object ?

35Frank Gaede, DESY ITLC Simulation Workshop,SLAC, May 2003

Data model - LCEvent Data model - LCEvent (reco)(reco)

ReconstructedObjectReconstructedObject int: ObjectType int: ObjectType (jet, vertex, ... )(jet, vertex, ... ) float[5]: 4vec float[5]: 4vec ((4-vector of object (px, py, pz, E, M)4-vector of object (px, py, pz, E, M) float[3]: reference float[3]: reference (position)(position) float[15]: covariance matrixfloat[15]: covariance matrix reconstructedParticle:reconstructedParticle:

pntr: ReconstructedParticlepntr: ReconstructedParticle float: weightfloat: weight

=> generic reconstructed objects, linked to => generic reconstructed objects, linked to reconstructed particlesreconstructed particles