Particle to MC truth association Juan Palacios (Nikhef) LHCb software week June 16 2009.

Slides:



Advertisements
Similar presentations
Lists Introduction to Computing Science and Programming I.
Advertisements

Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
Creating Shareable Models By: Eric Hutton CSDMS - Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There Be.
Project Workshops Results and Evaluation. General The Results section presents the results to demonstrate the performance of the proposed solution. It.
The switch Statement, DecimalFormat, and Introduction to Looping
Neural Network Tools. Neural Net Concepts The package provides a “standard” multi-layer perceptron –Composed of layers of neurons –All neurons in a layer.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Struts 2.0 an Overview ( )
Fundamentals of Python: From First Programs Through Data Structures
DaVinci status Juan Palacios LHCb Software Week March, 2009.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
C.ClémentTile commissioning meeting – From susy group talk of last Wednesday  Simulation and digitization is done in version (8) 
CERN Tutorial, September Job Options and Printing.
Job Options and Printing 1 LHCb software tutorial - September 2011.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Defining New Types Lecture 21 Hartmut Kaiser
Introduction Advantages/ disadvantages Code examples Speed Summary Running on the AOD Analysis Platforms 1/11/2007 Andrew Mehta.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Halting Problem Introduction to Computing Science and Programming I.
Looping and Counting Lecture 3 Hartmut Kaiser
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Gaudi Framework Tutorial, April Algorithm Tools: what they are, how to write them, how to use them.
CSCI-383 Object-Oriented Programming & Design Lecture 18.
Gaudi Framework Tutorial, April Job Options and Printing.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Reconstruction Configuration with Python Chris Jones University of Cambridge.
The Software Development Process
“Education is a Treasure that follows you everywhere.” – Chines Proverb Methods and Functions.
Decision Trees Binary output – easily extendible to multiple output classes. Takes a set of attributes for a given situation or object and outputs a yes/no.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
DaVinciAssociators How to relate physics objects to MC truth.
Proposal for extension of GaudiAlgorithm and GaudiTool classes Vanya Belyaev CERN & ITEP/Moscow.
LCFI Physics Studies Meeting, 18 th October 2005Sonja Hillertp. 0 Using event display for improving Q vtx reconstruction  event display might help to.
Gaudi Framework Tutorial, Algorithm Tools: what they are and how to use them.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
20 October 2005 LCG Generator Services monthly meeting, CERN Validation of GENSER & News on GENSER Alexander Toropin LCG Generator Services monthly meeting.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Introduction to Exceptions in Java CS201, SW Development Methods.
Nikhef Bfys Workshop Day One: Exploring a (m)DST Juan Palacios
News on Rho PANDA Collaboration Meeting, Bochum K. Götzen, GSI 1.
Copyright © Jim Fawcett Spring 2017
Introduction to Computing Science and Programming I
Introduction to Programming
DecayTreeTuple – an update (v2r3p1)
JAVA COLLECTIONS LIBRARY
Writing Physics Tools Schedule: Timing Topic 20 minutes Lecture
More Selections BIS1523 – Lecture 9.
Lecture 22 Inheritance Richard Gesick.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Loops CIS 40 – Introduction to Programming in Python
Coding Concepts (Basics)
SE1H421 Procedural Programming LECTURE 4 Operators & Conditionals (1)
Applying Use Cases (Chapters 25,26)
Negative Number Calculations
Presentation transcript:

Particle to MC truth association Juan Palacios (Nikhef) LHCb software week June

June 16, Juan Palacios –1 Outline Introduction New interfaces Implementations Examples of use Further developments See also talk by Vava for more details about implementation and examples

Introduction For a while MC association has been a problem –Legacy code with no expert support –Complicated structure –Issues with composite particles –Requires lots of switching depending on particle type –Not easily scalable or debugable I personally could never answer users questions about how to use it or why it wouldn’t work sometimes –Use of BackgroundCategoryTool or completely different approach in LoKi framework 16 June 2009MC association - Juan Palacios - LHCb SW week June-092

Introduction (2) Decided to start from scratch –What does a simple user need? –What would an expert need? –What would a user-friendly interface be like? No consideration for implementation –Design simple interface(s) –Then worry about implementation –Too much time wasted in the past trying to write code around problems instead of fixing them. Avoid coupling –Very clever pieces of code are hard to extend and debug –Small stupid pieces can be glued together to do clever stuff 16 June 2009MC association - Juan Palacios - LHCb SW week June-093

Towards new interfaces Many discussions with Gerhard, Patrick, Vanya, Vava I opted towards tool interfaces that take a particle and a container of MCParticles and return a set of MCParticles in one format or another –Weighted associations: each related MCParticle comes coupled with a weight I have issues with weights in an interface: the value of the weights will depend on the implementation Some steps taken to minimise this effect (see Vava’s talk) –Un-weighted “Tree” or “Line” structure (explained later) What’s the word for a tree from which someone has cut all the branches but one? Decay line? 16 June 2009MC association - Juan Palacios - LHCb SW week June-094

Towards new interfaces (2) Also simple method that returns a single MCParticle –Users express interest in method const MCParticle* foo(const Particle*) Note: we input a container of MCParticles, trying to avoid behind the scenes assumptions –I have kept the default MCParticle container location as default value for the corresponding argument –The two argument signatures make the interfaces more useful E.g. select MCParticles from a true decay tree and see if our reco particles are associated to them Note: results returned to the user, not put on TES 16 June 2009MC association - Juan Palacios - LHCb SW week June-095

New interfaces: IParticle2MCAssociator Simplest user interface: Interface speaks for itself. –No side-effects should be assumed. –In fact, side-effects should be avoided –Configurability should be avoided (as with all tools) 16 June 2009MC association - Juan Palacios - LHCb SW week June-096 Calculate and return the LHCb::MCParticle associated to an LHCb::Particle. virtual const LHCb::MCParticle* relatedMCP(const LHCb::Particle*) const =0 virtual const LHCb::MCParticle* operator()(const LHCb::Particle*) const =0 virtual const LHCb::MCParticle* relatedMCP(const LHCb::Particle*, const std::string& mcParticleLocation) const =0 virtual const LHCb::MCParticle* relatedMCP(const LHCb::Particle* particles, const LHCb::MCParticle::ConstVector& mcParticles) const =0 virtual const LHCb::MCParticle* relatedMCP(const LHCb::Particle* particles, const LHCb::MCParticle::Container&cmcParticles) const =0

IParticle2MCWeightedAssociator and IP2MCP Both have relatedMCPs methods –IP2MCP’s returns vector of vectors of MCParticle* –IParticle2MCWeightedAssociator returns vector of MCAssociations (essentially MCParticle*, double pair) 16 June 2009MC association - Juan Palacios - LHCb SW week June-097 IParticle2MCAssoicator IP2MCPIParticle2MCWeightedAssociator

Base class Particle2MCAssociatorBase takes care of implementing all the methods in terms of one or two private methods: Either virtual Particle2MCParticle::ToVector relatedMCPsImpl(const LHCb::Particle* particle, const LHCb::MCParticle::ConstVector& mcParticles) const ; Or both virtual double associationWeight(const LHCb::Particle*, const LHCb::MCParticle* ) const; virtual bool isAssociated(const LHCb::Particle*, const LHCb::MCParticle* ) const; Developers only need to implement this, the rest is taken care of 16 June 2009MC association - Juan Palacios - LHCb SW week June-098

IP2MCP Base class P2MCPBase takes care of implementing all the methods in terms of two methods: Public method virtual bool isMatched(const LHCb::Particle* particle, const LHCb::MCParticle* mcParticle) const ; Private method virtual P2MCP::Types::FlatTrees sort(const LHCb::MCParticle::ConstVector& mcParticles) const; The FlatTrees is just a vector of vectors The sort method will be removed and a proper Trees or DecayLines class with self-sorting written in Developers only need to implement these two methods, the rest is taken care of 16 June 2009MC association - Juan Palacios - LHCb SW week June-099

Existing implementations (1) IParticle2MCWeightedAssociator –P2MCPFromProtoP : For stable charged or neutral particles that have a valid ProtoParticl e. Simply gets the weights from the linkers to implement the relatedMCPImpl method. –DaVinciSmartAssociator (Vava): uses the above for charged and neutral particles, and BackGroundCategoryTool for composite particles. Implements the relatedMCPImpl method. Both implementations require that the MCParticles are on the TES –If an input MCParticle container is passed, the base class checks for the overlap with MCParticles from the standard TES location See Vava’s talk for more details on the DaVinciSmartAssociator and other issues 16 June 2009MC association - Juan Palacios - LHCb SW week June-0910

Existing implementations (2) IP2MCP –MCMatchObjP2MCRelator : Performs the association in two steps. 1.Decide if an LHCb::MCParticle is matched to an LHCb::Particle using Vanya’s LoKi::MCMatch. 2.Use other LoKi MC Truth components to split and sort the resulting set of associated MCParticles into decay sets ( FlatTrees ), such that each set contains only MCParticles that come from different hierarchy levels in the same decay. Order is mother to daughter. This implementation might require that stable MCParticles are on the TES to bootstrap itself. However, it can be given as input a relations table matching stable Particles to MCParticles – This is done in the MicroDST 16 June 2009MC association - Juan Palacios - LHCb SW week June-0911

MCMatchObjP2MCRelator More details are given here – The important point is that a true or false matching is performed in an iterative way –No need for decay descriptors –Builds up from stable particles For illustration, FlatTrees for correctly matched reconstructed particles could be –Tree for particle mu+: B_s0, J/psi(1S), mu+ –Tree for particle phi(1020): B_s0, phi(1020) More than one FlatTree is a symptom of more than one MCParticle making a contribution to one reconstructed Particle 16 June 2009MC association - Juan Palacios - LHCb SW week June-0912

Examples of use: C++ // here you can use any of the implementations, DaVinciSmartAssociator, // MCMatchObj2MCRelator or P2MCPFromProtoP if only interested in stable particles, // since they all implement IParticle2MCAssociator m_assoc = tool (MCMatchObjP2MCRelator); const LHCb::Particle part =...; const LHCb::MCParticle* assocMCP = m_assoc->relatedMCP(part, LHCb::MCParticleLocation::Default); // Or use the DaVinciSmartAssociator to get a range of MCAssociations // header file IParticle2MCWeightedAssociator* m_assoc; // implementation m_assoc = tool (DaVinciSmartAssociator); const LHCb::Particle part =...; Particle2MCParticle::ToVector assocMCPs = m_assoc->relatedMCPs(part, LHCb::MCParticleLocation::Default); Particle2MCParticle::ToVector::const_iterator iAssoc = assocMCPs.begin() for ( ; iAssoc != assocMCPs.end() ; ++ iAssoc ) { verbose() to() weight() << endmsg; } 16 June 2009MC association - Juan Palacios - LHCb SW week June-0913

Examples of use: Python # appMgr = AppMgr(outputlevel=4) toolSvc = appMgr.toolsvc() # get an instance of MCMatchObjP2MCRelator and DaVinciSmartAssociator. MCMatchTool = toolSvc.create('MCMatchObjP2MCRelator', interface='IP2MCP') SmartAssoc = toolSvc.create('DaVinciSmartAssociator', interface = 'IParticle2MCWeightedAssociator') # loop over particles evtSvc = appMgr.evtSvc() while (... ) : particles = evtSvc[particlePath] for p in particles : trees = MCMatchTool.relatedMCPs(p) for tree in trees : for mcp in tree : print "found MCParticle ", mcp bestMatchedMCP = MCMatchTool.relatedMCP(p) print "Best match is ", bestMatchedMCP mcAssociations = SmartAssoc.relatedMCPs(p) for mcAssoc in mcAssociations : June 2009MC association - Juan Palacios - LHCb SW week June-0914

Populating the TES DaVinciAssociators would result in population of Particle->MCParticle linkers on the TES –Now this only happens for Particle->ProtoParticle Not by design: this could disappear any time Approach now is to instrument a GaudiAlgorithm with an associator tool, give it some inputs, and get it to write a relations table to the TES –One working example: P2MCRelatorAlg using IP2MCP Now used for MicroDST (example in this morning’s talk) 16 June 2009MC association - Juan Palacios - LHCb SW week June-0915

Future work MCMatchObjP2MCRelator: –Optimise the getting of single, “best” MCParticle out of FlatTrees – Write self-sorted FlatTrees or DecayLines class Remove sort method from P2MCPBase Write chi2 based implementations of all interfaces – Vava’s found where the old chi2 went wrong – Only need to implement Particle2MCAssociatorBase’s virtual double associationWeight(const LHCb::Particle*, const LHCb::MCParticle* ) const; virtual bool isAssociated(const LHCb::Particle*, const LHCb::MCParticle* ) const; DaVinciSmartAssociator: See Vava’s talk 16 June 2009MC association - Juan Palacios - LHCb SW week June-0916

Wiki Visit the wiki: – rticle2MChttps://twiki.cern.ch/twiki/bin/view/LHCb/Pa rticle2MC 16 June 2009MC association - Juan Palacios - LHCb SW week June-0917