Gaudi Framework Tutorial, April 2006 4 Accessing Event Data.

Slides:



Advertisements
Similar presentations
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
Advertisements

IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Review for Midterm Chapter 1-9 CSc 212 Data Structures.
Gaudi Framework Tutorial, April Introduction.
1 Stacks Chapter 4 2 Introduction Consider a program to model a switching yard –Has main line and siding –Cars may be shunted, removed at any time.
Data Structures Using C++ 2E
M.Frank LHCb/CERN - In behalf of the LHCb GAUDI team Data Persistency Solution for LHCb ã Motivation ã Data access ã Generic model ã Experience & Conclusions.
1 Today’s Objectives  Announcements Turn in Homework #1 Homework #2 is posted and it is due on 21-Jun  Review Quiz #1  Pointers and C-style strings.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
COP3530 Data Structures600 Stack Stack is one the most useful ADTs. Like list, it is a collection of data items. Supports “LIFO” (Last In First Out) discipline.
CERN Tutorial, September Job Options and Printing.
Job Options and Printing 1 LHCb software tutorial - September 2011.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Standard Template Library (STL)
Event Data History David Adams BNL Atlas Software Week December 2001.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
GLAST Gaudi Code Review, 10 Sept. 2002, H. Kelly, 2-1 GLAST Event Data Model and Persistency.
Level 2 ID-tracking truth association Trigger AOD discussion 13 December 2006 Ricardo Gonçalo - RHUL.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
LHCb Simulation Tutorial CERN, 21 st -22 nd February B 00 l e Event Model, XML, GaudiObjDesc Original.
Particle to MC truth association Juan Palacios (Nikhef) LHCb software week June
C ++ Basics by Bindra Shrestha sce.uhcl.edu/shresthab CSCI 3333 Data Structures.
Use of Gaudi in Reconstruction Weidong Li 23/06/2004.
Gaudi Framework Tutorial, April Algorithm Tools: what they are, how to write them, how to use them.
CHEP /21/03 Detector Description Framework in LHCb Sébastien Ponce CERN.
Gaudi Framework Tutorial, April Job Options and Printing.
Jose A. Hernando Trigger Gaudies Reconstruction Tools & Algorithms Inspectors MC & Data Algorithms Template preserved container Jose A. Hernando.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Apr. 8, 2002Calibration Database Browser Workshop1 Database Access Using D0OM H. Greenlee Calibration Database Browser Workshop Apr. 8, 2002.
Ticket Booth Base Level 3 1. In the completed program, the ticket seller will: Select a venue from a menu of all venues. Select a show from a menu of.
Chapter 5 Files and Exceptions I. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. What is a file? A.
Files Tutor: You will need ….
CHEP /21/03 Detector Description Framework in LHCb Sébastien Ponce CERN.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Bologna Tutorial, April Job Options and Printing.
April 6, 2000 LHCb Event Data Model Pavel Binko, Gloria Corti LHCb / CERN 1 LHCb Software week LHCb Event Data Model Pavel Binko Gloria Corti LHCb / CERN.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
CSC Java Programming, Fall, 2008 Week 3: Objects, Classes, Strings, Text I/O, September 11.
Dynamic Programming & Memoization. When to use? Problem has a recursive formulation Solutions are “ordered” –Earlier vs. later recursions.
Level 2 ID-tracking truth association How it works Information in POOL How to use it.
Gaudi Framework Tutorial, April Creating Objects and Writing Data.
DaVinciAssociators How to relate physics objects to MC truth.
25th Nov, 1999 LHCb Event Data Model Pavel Binko, LHCb / CERN 1 LHCb Software Week LHCb Event Data Model Pavel Binko LHCb / CERN.
ROOT Based CMS Framework Bill Tanenbaum US-CMS/Fermilab 14/October/2002.
Athena Tutorial: Liquid Argon Example ATHENA The ATLAS Control Framework Tutorial: Liquid Argon Example Based on original by S. Rajagopalan BNL.
Proposal for extension of GaudiAlgorithm and GaudiTool classes Vanya Belyaev CERN & ITEP/Moscow.
Gaudi Framework Tutorial, Algorithm Tools: what they are and how to use them.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Athena StoreGate Tutorial: May 30, Objectives Learn how to access data objects using StoreGate How to record/retrieve by TYPE Optionally using keys.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Gaudi Framework Tutorial, April Histograms And N-tuples.
Root I/O and the Gaudi Framework
Fundamentals of Python: First Programs
C++ Standard Library.
Writing Physics Tools Schedule: Timing Topic 20 minutes Lecture
Practical example of C programming
LHCb Software Tutorial
Stacks Chapter 4.
Topics Introduction to File Input and Output
Data Persistency Solution for LHCb
Recitation Outline C++ STL associative containers Examples
Raw Event Conversion Service in BOSS framework
Bryan Burlingame 17 April 2019
Topics Introduction to File Input and Output
Use Of GAUDI framework in Online Environment
Accessing Event Data Schedule: Timing Topic 20 minutes Lecture
Presentation transcript:

Gaudi Framework Tutorial, April Accessing Event Data

4-2 Gaudi Framework Tutorial, April 2006 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. Use relationships between objects. Specify event data input. 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. Use relationships between objects. Specify event data input.

4-3 Gaudi Framework Tutorial, April 2006 Event Data Reside In Data Store Tree - similar to file system Identification by path ”/Event/MC/Particles” LHCb::MCParticleLocation::Default Objects or Containers of objects KeyedContainer Containers of objects KeyedContainer

4-4 Gaudi Framework Tutorial, April 2006 Containers: e.g. KeyedContainer LHCb::MCParticles* parts; //note LHCb:: namespace... LHCb::MCParticles::const_iterator i; for( i=parts->begin(); i != parts->end(); i++ ) { info() particleID().pid() begin(); i != parts->end(); i++ ) { info() particleID().pid() << endmsg; } Templated classTemplated class –Usually hidden to end-user code by typedefs in header file Templated classTemplated class –Usually hidden to end-user code by typedefs in header file Iteration like any STL vector typedef KeyedContainer MCParticles;

4-5 Gaudi Framework Tutorial, April 2006 Understanding Data Stores: Loading (5) Register Data Service Algorithm (1) get (location) Try to access an object data (2) Search in Store Data Store Unsuccessful if requested object is not present Converter (4) Request creation (3) Request load Persistency Service Conversion Service Request dispatcher SICB, ROOT,..

4-6 Gaudi Framework Tutorial, April 2006 Caveats Consider Objects on the store as READ-ONLY Do not modify existing objects! Do not destroy existing objects! Never, never delete an object which is registered to the store It’s not yours! It will only screw up others! Consider Objects on the store as READ-ONLY Do not modify existing objects! Do not destroy existing objects! Never, never delete an object which is registered to the store It’s not yours! It will only screw up others!

4-7 Gaudi Framework Tutorial, April 2006 Data Access In GaudiAlgorithm const LHCb::MCHeader* evt = get ( LHCb::MCHeaderLocation::Default ); // No need to test a return code, this method throws // an exception if data is not found const LHCb::MCHeader* evt = get ( LHCb::MCHeaderLocation::Default ); // No need to test a return code, this method throws // an exception if data is not found

4-8 Gaudi Framework Tutorial, April 2006 Relationships Between Objects Objects have relationships between each other MCParticle MCVertex 0..1m_originVertex 0..nm_endVertices MCVertices are also connected to MCParticles, but this we neglect here...

4-9 Gaudi Framework Tutorial, April 2006 Implementing Relationships 0..1 Relationships can be implemented using a SmartRef Usage similar to a normal pointer 0..n Relationships are implemented using a SmartRefVector …an array of SmartRef Allows for late data loading –Only loaded when SmartRef is dereferenced 0..1 Relationships can be implemented using a SmartRef Usage similar to a normal pointer 0..n Relationships are implemented using a SmartRefVector …an array of SmartRef Allows for late data loading –Only loaded when SmartRef is dereferenced

4-10 Gaudi Framework Tutorial, April 2006 Using These Relationships class MCParticle { SmartRef m_originVertex; SmartRef m_originVertex; LHCb::MCVertex* originVertex() { LHCb::MCVertex* originVertex() { return m_originVertex; return m_originVertex; }}; class MCParticle { SmartRef m_originVertex; SmartRef m_originVertex; LHCb::MCVertex* originVertex() { LHCb::MCVertex* originVertex() { return m_originVertex; return m_originVertex; }}; …load data and trigger conversion …load data and trigger conversion See Doxygen code documentation

4-11 Gaudi Framework Tutorial, April 2006 SmartRef, pointers, references LHCb::MCParticle* p = new LHCb::MCParticle(); SmartRef ref; LHCb::MCParticle* p = new LHCb::MCParticle(); SmartRef ref; Assignment from raw pointer Assignment to raw pointer Gaudi::LorentzVector& m_A = p->momentum(); Gaudi::LorentzVector& m_B = ref->momentum(); Gaudi::LorentzVector m_slow = ref->momentum(); Gaudi::LorentzVector& m_A = p->momentum(); Gaudi::LorentzVector& m_B = ref->momentum(); Gaudi::LorentzVector m_slow = ref->momentum(); ref = p; p = ref;

4-12 Gaudi Framework Tutorial, April 2006 Specify Event Data Input EventSelector.Input = { “DATAFILE=‘a_filename’ [Spec]” [,“DATAFILE=‘another_filename’ [Spec]”] }; EventSelector.Input = { “DATAFILE=‘a_filename’ [Spec]” [,“DATAFILE=‘another_filename’ [Spec]”] }; Event data input is specified in the job options [Spec] is an array of qualified strings: KEY1=‘VALUE1’ … KEYn=‘VALUEn’ Several files can be specified, separated by a comma Event data input is specified in the job options [Spec] is an array of qualified strings: KEY1=‘VALUE1’ … KEYn=‘VALUEn’ Several files can be specified, separated by a comma

4-13 Gaudi Framework Tutorial, April 2006 Specify POOL Event Input EventSelector.Input = {"DATAFILE='PFN:castor: /castor/cern.ch/grid/lhcb/production/DC06/v1-lumi2/ /SIM/ _ _1.sim ' TYP='POOL_ROOTTREE' OPT='READ'" } PFN: keyword tells POOL this is a physical file name castor: keyword selects data transfer protocol (rootd in this case) omit for a disk file OPT=‘READ’ is read only file PFN: keyword tells POOL this is a physical file name castor: keyword selects data transfer protocol (rootd in this case) omit for a disk file OPT=‘READ’ is read only file

4-14 Gaudi Framework Tutorial, April 2006 Hands On: Print B 0 Decays Use particle property service m_ppSvc = svc ( "ParticlePropertySvc", true );Use particle property service m_ppSvc = svc ( "ParticlePropertySvc", true ); –See “User Guide” chapter 11.5 for usage Retrieve MCParticles from event storeRetrieve MCParticles from event store –LHCb::MCParticleLocation::Default Filter out the B 0 particlesFilter out the B 0 particles –MCParticle::particleID().pid() is PDG particle code For each B 0 Loop over all decay vertices and print the decay particlesFor each B 0 Loop over all decay vertices and print the decay particles –recursion ? Use particle property service m_ppSvc = svc ( "ParticlePropertySvc", true );Use particle property service m_ppSvc = svc ( "ParticlePropertySvc", true ); –See “User Guide” chapter 11.5 for usage Retrieve MCParticles from event storeRetrieve MCParticles from event store –LHCb::MCParticleLocation::Default Filter out the B 0 particlesFilter out the B 0 particles –MCParticle::particleID().pid() is PDG particle code For each B 0 Loop over all decay vertices and print the decay particlesFor each B 0 Loop over all decay vertices and print the decay particles –recursion ?

4-15 Gaudi Framework Tutorial, April 2006 DecayTreeAlgorithm.cpp: Add Headers // Using Particle properties #include "GaudiKernel/IParticlePropertySvc.h" #include "GaudiKernel/ParticleProperty.h" // Accessing data: #include "Event/MCParticle.h" #include "Event/MCVertex.h" // Using Particle properties #include "GaudiKernel/IParticlePropertySvc.h" #include "GaudiKernel/ParticleProperty.h" // Accessing data: #include "Event/MCParticle.h" #include "Event/MCVertex.h"

4-16 Gaudi Framework Tutorial, April 2006 Using IParticlePropertySvc...DecayTreeAlgorithm.h... IParticlePropertySvc* m_ppSvc; std::string m_partName; int m_partID; IParticlePropertySvc* m_ppSvc; std::string m_partName; int m_partID;...DecayTreeAlgorithm::initialize()... m_ppSvc = svc ( "ParticlePropertySvc", true ); m_ppSvc = svc ( "ParticlePropertySvc", true ); ParticleProperty* partProp = m_ppSvc->find( m_partName ); if ( 0 == partProp ) {// You have to handle the error! } m_partID = partProp->pdgID(); ParticleProperty* partProp = m_ppSvc->find( m_partName ); if ( 0 == partProp ) {// You have to handle the error! } m_partID = partProp->pdgID();...DecayTreeAlgorithm.h... IParticlePropertySvc* m_ppSvc; std::string m_partName; int m_partID; IParticlePropertySvc* m_ppSvc; std::string m_partName; int m_partID;...DecayTreeAlgorithm::initialize()... m_ppSvc = svc ( "ParticlePropertySvc", true ); m_ppSvc = svc ( "ParticlePropertySvc", true ); ParticleProperty* partProp = m_ppSvc->find( m_partName ); if ( 0 == partProp ) {// You have to handle the error! } m_partID = partProp->pdgID(); ParticleProperty* partProp = m_ppSvc->find( m_partName ); if ( 0 == partProp ) {// You have to handle the error! } m_partID = partProp->pdgID();

4-17 Gaudi Framework Tutorial, April 2006 Hands On: Retrieve and loop over MCParticles LHCb::MCParticles* parts = get ( LHCb::MCParticleLocation::Default ); LHCb::MCParticles::const_iterator i; for(i=parts->begin();i != parts->end(); i++ ) { if ( (*i)->particleID().pid() == m_partID ){ if ( (*i)->particleID().pid() == m_partID ){ printDecayTree( *i ); printDecayTree( *i ); }} LHCb::MCParticles* parts = get ( LHCb::MCParticleLocation::Default ); LHCb::MCParticles::const_iterator i; for(i=parts->begin();i != parts->end(); i++ ) { if ( (*i)->particleID().pid() == m_partID ){ if ( (*i)->particleID().pid() == m_partID ){ printDecayTree( *i ); printDecayTree( *i ); }}

4-18 Gaudi Framework Tutorial, April 2006 Hands On: Print Decays For each selected particle: Loop over decay vertices Print all daughters – If daughters have decay vertices – recurse If you run out of time, just print some particle property For each selected particle: Loop over decay vertices Print all daughters – If daughters have decay vertices – recurse If you run out of time, just print some particle property

4-19 Gaudi Framework Tutorial, April 2006 Loop Over Decay Vertices const SmartRefVector & decays = mother->endVertices(); const SmartRefVector & decays = mother->endVertices(); SmartRefVector ::const_iterator ivtx; SmartRefVector ::const_iterator ivtx; for ( ivtx = decays.begin(); ivtx != decays.end(); ivtx++ ) { for ( ivtx = decays.begin(); ivtx != decays.end(); ivtx++ ) { const SmartRefVector daughters=(*ivtx)->products(); const SmartRefVector daughters=(*ivtx)->products(); SmartRefVector ::const_iterator idau; SmartRefVector ::const_iterator idau; for( idau = daughters.begin(); idau != daughters.end(); idau++ ) { for( idau = daughters.begin(); idau != daughters.end(); idau++ ) { printDecayTree( depth+1, prefix+" |", *idau ); printDecayTree( depth+1, prefix+" |", *idau ); } } const SmartRefVector & decays = mother->endVertices(); const SmartRefVector & decays = mother->endVertices(); SmartRefVector ::const_iterator ivtx; SmartRefVector ::const_iterator ivtx; for ( ivtx = decays.begin(); ivtx != decays.end(); ivtx++ ) { for ( ivtx = decays.begin(); ivtx != decays.end(); ivtx++ ) { const SmartRefVector daughters=(*ivtx)->products(); const SmartRefVector daughters=(*ivtx)->products(); SmartRefVector ::const_iterator idau; SmartRefVector ::const_iterator idau; for( idau = daughters.begin(); idau != daughters.end(); idau++ ) { for( idau = daughters.begin(); idau != daughters.end(); idau++ ) { printDecayTree( depth+1, prefix+" |", *idau ); printDecayTree( depth+1, prefix+" |", *idau ); } }

4-20 Gaudi Framework Tutorial, April 2006 Solution In src.decaytree directory of Tutorial/Components packageIn src.decaytree directory of Tutorial/Components package To try this solution and start next exercise from it:To try this solution and start next exercise from it: In src.decaytree directory of Tutorial/Components packageIn src.decaytree directory of Tutorial/Components package To try this solution and start next exercise from it:To try this solution and start next exercise from it: Uncomment Tutorial 1 options in $MAINROOT/options/jobOptions.opts cd ~/cmtuser/Tutorial/Component/v7r0/src Move your modified files if you want to keep them cp../src.decaytree/*.*. cd../cmt gmake $MAINROOT/$CMTCONFIG/Main.exe $MAINROOT/options/jobOptions.opts