LoKi’s Cook-book : Writing analysis algorithms in C++ Tutorial v4r2 Vanya Belyaev Vanya Belyaev (Syracuse) Vanya Belyaev.

Slides:



Advertisements
Similar presentations
Measuring the bb cross- section using B  D o X   decays Liming Zhang & Sheldon Stone Syracuse University.
Advertisements

Gaudi Framework Tutorial, April Accessing Event Data.
Measuring the bb cross- section using B  D o X   decays Liming Zhang & Sheldon Stone Syracuse University.
B-Tagging Common Interface Y.D. Mutaf, S. Towers 20 March 2003 H b _b.
A Method to measure  + /   detection efficiency asymmetry at LHCb Liming Zhang 08/15/07.
Measuring the bb cross- section using B  D o X   decays Liming Zhang & Sheldon Stone Syracuse University.
DaVinci status Juan Palacios LHCb Software Week March, 2009.
LoKi & Bender User Friendly Physics Analysis Tools Vanya BELYAEV Vanya BELYAEV NIKHEF, Amsterdam, Vanya BELYAEV on leave from ITEP/Moscow.
Event View G. Watts (UW) O. Harris (UW). Philosophy EventView Goals Object Identification & Interpretation Is that a jet or an electron? Is that jet a.
CERN Tutorial, September Job Options and Printing.
Job Options and Printing 1 LHCb software tutorial - September 2011.
David N. Brown Lawrence Berkeley National Lab Representing the BaBar Collaboration The BaBar Mini  BaBar  BaBar’s Data Formats  Design of the Mini 
Introduction Advantages/ disadvantages Code examples Speed Summary Running on the AOD Analysis Platforms 1/11/2007 Andrew Mehta.
19/07/20061 Nectarios Ch. Benekos 1, Rosy Nicolaidou 2, Stathes Paganis 3, Kirill Prokofiev 3 for the collaboration among: 1 Max-Planck-Institut für Physik,
B group status and plans Brad Abbott Sept 11, 2002.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Particle to MC truth association Juan Palacios (Nikhef) LHCb software week June
Kali Calo progress report Dasha Savrina (ITEP/Moscow), Vanya Belyaev.
Gaudi Framework Tutorial, April Algorithm Tools: what they are, how to write them, how to use them.
Gaudi Framework Tutorial, April Job Options and Printing.
Reconstruction Configuration with Python Chris Jones University of Cambridge.
9-13/9/03 Atlas Overview WeekPeter Sherwood 1 Atlfast, Artemis and Atlantis What, Where and How.
AMB HW LOW LEVEL SIMULATION VS HW OUTPUT G. Volpi, INFN Pisa.
Standalone FLES Package for Event Reconstruction and Selection in CBM DPG Mainz, 21 March 2012 I. Kisel 1,2, I. Kulakov 1, M. Zyzak 1 (for the CBM.
Vanya BELYAEV Vanya BELYAEV (Syracuse) Vanya BELYAEV Tutorial Gaudi/DaVinci/LoKi/Bender.
Argonne Jamboree January 2010 Esteban Fullana AOD example analysis.
Refitting Tracks from DST E. Rodrigues, NIKHEF LHCb Tracking and Alignment Workshop, Lausanne, 8-9th November 2006  Motivations  Step-by-step …  Current.
Bologna Tutorial, April Job Options and Printing.
LHCb Software Week, 26th April /23 Tracking in LHCb E. Rodrigues, NIKHEF LHCb Software Week A Status Report.
DaVinciAssociators How to relate physics objects to MC truth.
1 Selection of non-triggering muons in J/ψ  μμ events for the calibration of the Muon System 1)Offline Selection:  use of Mass Constrained Global Fit.
Hadronic Jet Energy Scale Hadronic t-t bar selection and Jet Energy Scale calibration Part I : Accessing the trigger information 09/02 - Menelaos Tsiakiris.
Status of Analysis Software Kanglin He For Analysis Software Group.
Current Status of MDC Track Reconstruction MdcPatRec Zhang Yao, Zhang Xueyao
Muon Persistency Persistent Analysis Objects Muon Persistency Norbert Neumeister µ-PRS meeting February 10, 2004.
LoKi & Bender Smart & transparent physics analysis Vanya Belyaev CERN & ITEP/Moscow.
Bender Tutorial Vanya Belyaev LAPP/Annecy-le-Vieux & ITEP/Moscow.
Processing large data sets Brad Abbott. Now J/Psi Starting with root-tuples Add 4-momentum to look for candidates Pick events (raw) -> reconstruct event.
Study of B s         Supreet Pal Singh Prof. Kajari Mazumdar Prof. J.B.Singh 1India-CMS Meeting 27th-28th.
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.
Python -based Physics Analysis Environment for LHCb G. Barrand, M. Frank, P. Mato, E. de Oliveira, A.Tsaregorodtsev, I. Belyaev CHEP 2004, Interlaken,
Tau31 Tracking Efficiency at BaBar Ian Nugent UNIVERSITY OF VICTORIA Sept 2005 Outline Introduction  Decays Efficiency Charge Asymmetry Pt Dependence.
9 Associators How to relate objects to each other Create relations Save relations Use relations: Associators.
Status of Analysis Tools in PandaROOT K. Götzen, GSI 1.
Introduction to FCC Software FCC Istanbul 11 March, 2016 Alice Robson (CERN/UNIGE) on behalf of / with thanks to the FCC software group.
1 D *+ production Alexandr Kozlinskiy Thomas Bauer Vanya Belyaev
Nikhef Bfys Workshop Day One: Exploring a (m)DST Juan Palacios
News on Rho PANDA Collaboration Meeting, Bochum K. Götzen, GSI 1.
Gaudi Framework Tutorial, April Histograms And N-tuples.
H->WW->lνlν Analysis - Improvements and results - - Data and MC - Higgs Working group meeting, 6 January 2011 Magda Chełstowska & Rosemarie Aben.
An AOD analysis example Esteban Fullana Torregrosa High Energy Physics Division Argonne National Laboratory.
LoKi’s Cook-book : Writing analysis algorithms in C++ Tutorial v8r0 Vanya Belyaev Vanya Belyaev NIKHEF/Amsterdam & ITEP/Moscow Vanya Belyaev.
Bender v7r0 as your analysis environment
AOD example analysis Argonne Jamboree January 2010
The Generator Phase in Gauss
DecayTreeTuple – an update (v2r3p1)
Writing Physics Tools Schedule: Timing Topic 20 minutes Lecture
Status of the Track Event Model Classes and Tools E. Rodrigues, NIKHEF
LHCb Software Tutorial
LoKi’s Cook-book: Writing analysis algorithms in C++
Individual Particle Reconstruction
Update on LHCb Level-1 trigger
2 Getting Started.
Missing B-tracks in L1 trigger
Summary of validation studies of the simplified geometry
Contents First section: pion and proton misidentification probabilities as Loose or Tight Muons. Measurements using Jet-triggered data (from run).
2 Getting Started.
2 Getting Started.
Vanya BELYAEV (Syracuse)
Presentation transcript:

LoKi’s Cook-book : Writing analysis algorithms in C++ Tutorial v4r2 Vanya Belyaev Vanya Belyaev (Syracuse) Vanya Belyaev

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 2 Outline LoKi LoKi V4r2 released V4r2 released DaVinci v17r5 DaVinci v17r5

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 3 LoKi C++ Toolkit for user friendly Physics Analysis Available for users from begin of 2003 Available for users from begin of 2003 The first analysis has been reported March 2003 The first analysis has been reported March 2003 Benoit Viaud: B 0 →  S Benoit Viaud: B 0 →  S Benoit Viaud Benoit Viaud Used for few TDR studies in 2003 Used for few TDR studies in 2003 In use for some DC04 selections/stripping (~¼?) In use for some DC04 selections/stripping (~¼?) In use for private studies, In use for private studies, failure to count all users..  failure to count all users..  Mailing list: Mailing list: LoKi pages by Elena Mayatskaya LoKi pages by Elena MayatskayaLoKi pages Elena MayatskayaLoKi pages Elena Mayatskaya “Tool for senior physicists” ?

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 4 LoKi The major design criteria Locality Locality Introduce and use objects in local scope Introduce and use objects in local scope One file One file One method One method One screen One screen Compact code Compact code Safety Safety No need in new, delete No need in new, delete “Standard” “Standard” Use STL idioms & semantics Use STL idioms & semantics“META-LANGUAGE” The details can be found in “ LoKi User Guide & Reference Manual ” The details can be found in “ LoKi User Guide & Reference Manual ” LHCb DoxyGen documentation: DoxyGen documentation: Now available (partly) throught Phys Doxygen

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 5 LoKi To be discusses today: To be discusses today: LoKi & DaVinci LoKi & DaVinci LoKi basic LoKi basic MC matching MC matching Loops & Charge-blind loops Loops & Charge-blind loops Recipies on every day Recipies on every day Customization of LoKi Customization of LoKi

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 6 LoKi & DaVinci LoKi is a toolkit for DaVinci LoKi is a toolkit for DaVinci Code : LoKi Code : LoKi Job Configuration & steering: DaVinci Job Configuration & steering: DaVinci All user code is placed in the body of algorithm, which inherits from LoKi::Algo ( or LoKi::AlgoMC ), which inherits from DVAlgortithm/GaudiTupleAlg/GaudiHistoAlg/GaudiAlgorithm chain All user code is placed in the body of algorithm, which inherits from LoKi::Algo ( or LoKi::AlgoMC ), which inherits from DVAlgortithm/GaudiTupleAlg/GaudiHistoAlg/GaudiAlgorithm chain The actual chain is much more complicated The actual chain is much more complicated Only one mandatory method analyse() needs to be redefined Only one mandatory method analyse() needs to be redefined majority of mandatory and tedious stuff is hidden by preprocessor MACRO s majority of mandatory and tedious stuff is hidden by preprocessor MACRO s

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 7 Layers of LoKi Multilayered structure Multilayered structure Low level generic utilities Low level generic utilities Range_, Selected_, Combiner_, … Range_, Selected_, Combiner_, … STL -like algorithmic + functional layer STL -like algorithmic + functional layer Templated, very generic, very efficient Templated, very generic, very efficient (I am very proud of them!) (I am very proud of them!) Applicable to different and unrelated problems Applicable to different and unrelated problems Almost invisible for end-users Almost invisible for end-users Few hierarchical levels of “specific” utilities Few hierarchical levels of “specific” utilities Usually only the last layer is visible for end-users Usually only the last layer is visible for end-users Relations → MCMatchObj → MCMatch → MCTRUTH Relations → MCMatchObj → MCMatch → MCTRUTH Combiner_ → LoopObj → Loop Combiner_ → LoopObj → Loop (XXX → INTuple → NTuple::Tuple) → Tuples::TupleObj → Tuples::Tuple (XXX → INTuple → NTuple::Tuple) → Tuples::TupleObj → Tuples::Tuple

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 8 Few differences DC04 ↔DC06 All event classes in namesapce LHCb:: All event classes in namesapce LHCb:: Particle → LHCb::Particle All units in namespace Gaudi::Units All units in namespace Gaudi::Units GeV → Gaudi::Units::GeV Useful (self-explanatory) typedefs: Useful (self-explanatory) typedefs:LHCb::<Object>::VectorLHCb::<Object>::ConstVectorLHCb::<Object>::Container LoKi::Algo inherits from DVAlgorithm LoKi::Algo inherits from DVAlgorithm *ALL* DaVinci lines could be just moved into LoKi scope *ALL* DaVinci lines could be just moved into LoKi scope Many LoKi lines works just in DaVinci Many LoKi lines works just in DaVinci

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 9 “Hello,World” #include “LoKi/LoKi.h” LOKI_ALGORIHTM( MyAlg ) { info() << “Hello, World” << endreq ; info() << “Hello, World” << endreq ; return StatusCode::SUCCESS ; return StatusCode::SUCCESS ;}; Algorithm body, Algorithm body, implementation of constructor & destructor, implementation of constructor & destructor, factories factories MyAlg::analyse() MyAlg::analyse() 6 lines, 1 functional line

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 10 Excersize 0 Compile & run HelloWorld example Compile & run HelloWorld exampleHints: Template is …/templates/TEMPLATE.cpp Template is …/templates/TEMPLATE.cpp Emacs will not help you  Emacs will not help you  It is DaVinci algorithm: *.opts file is required It is DaVinci algorithm: *.opts file is required It is Gaudi component: *_load.cpp, *_dll.cpp It is Gaudi component: *_load.cpp, *_dll.cppSolution../solutions/HelloWorld

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 11 From (to?) base classes: Generic access to data, tools and services Generic access to data, tools and services get (…) get (…) tools (…) tools (…) svc (…) svc (…) Printout & error counts: Printout & error counts: info(), debug(), error(), fatal(), … Error(…), Warning(…) Histograms, NTuples and Event Collections Histograms, NTuples and Event Collectionsplot(…)nTuple()evtCol()

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 12 DaVinci tools All DaVinci tools are available through DVAlgorithm base class: All DaVinci tools are available through DVAlgorithm base class: IVertexFitter* vertexFitter ( const std::string& name = “” ) const; IGeomDispCalculator* geomDispCalculator ( … ) const ; IParticleFilter* particleFilter ( … ) const ; IFilterCriterion* filterCriterion ( … ) const ; IParticleCombiner* particleCombiner ( … ) const ; IParticleReFitter* particleReFitter ( … ) const ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 13 Basic types 4 types of basic “objects”: 4 types of basic “objects”: Particle, Vertex, MCParticle, MCVertex “Function” : functor which gets as argument the pointer to the “object” and returns double “Function” : functor which gets as argument the pointer to the “object” and returns double Func, VFunc, MCFunc, MCVFunc (interface) Fun, VFun, MCFun, MCVFun (assignable) “Cut/Predicate”: functor, which gets as an argument the pointer to the “objects” and returns bool “Cut/Predicate”: functor, which gets as an argument the pointer to the “objects” and returns bool Cuts, VCuts, MCCuts, MCVCuts (interface) Cut, VCut, MCCut, MCVCut (assignable) “Range”: a lightweight representation ( STL compliant) of container/sequence of “objects” “Range”: a lightweight representation ( STL compliant) of container/sequence of “objects” Range, VRange, MCRange, MCVRange +HepMC::GenParticle, tags, …

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 14 “Functions” LoKi offers about >100 “Functions”: LoKi offers about >100 “Functions”: “ Particle Functions”, e.g. “ Particle Functions”, e.g. LoKi::Particles::Momentum P LoKi::Particles::Momentum P LoKi::Particles::Identifier ID LoKi::Particles::Identifier ID LoKi::Vertices::ImpactParameter IP LoKi::Vertices::ImpactParameter IP “ Vertex Functions” “ Vertex Functions” LoKi::Vertices::VertexChi2 VCHI2 LoKi::Vertices::VertexChi2 VCHI2 “ MCParticle Functions” “ MCParticle Functions” LoKi::MCParticles::ProperLifeTime MCTIME “ MCVertex Functions” “ MCVertex Functions” LoKi::McVertices::MCVertexDistance MCVDIST C++ type alias

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 15 “Metafunctions” (~20) Transverse momentum of the first daughter Transverse momentum of the first daughter CHILD( PT, 1 )  LL (K-  ) for the first daughter of the first doughter  LL (K-  ) for the first daughter of the first doughter CHILD( CHILD( PIDK, 1 ), 1 ) CHILD( CHILD( PIDK, 1 ), 1 ) Minimal  LL (K-  ) for all daughter kaons in the decay tree: Minimal  LL (K-  ) for all daughter kaons in the decay tree: MINTREE( PIDK, “K-” == ABSID ) And a lot of “adapters”: And a lot of “adapters”: VXFUN, MCMOTH, FILTER, …

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 16 Functions & Cuts Operations with functions: Operations with functions: Fun fun = P + PT / GeV * sin( 1/ M ) ; Fun fun = pow(P,Q) + atan2(PX,PY); Comparisons: Comparisons: Cut cut = PT > 1.5 * Gaudi::Units::GeV ; Boolean operations Boolean operations Cut cut = ( PT > 1.5 * Gaudi::Units::GeV )&&( Q 1.5 * Gaudi::Units::GeV )&&( Q < 0 ) ; Special cases Special cases ID,ABSID,MCID,MCABSID,GID,GABSID : ID,ABSID,MCID,MCABSID,GID,GABSID : Cut cut = “pi+” == ID ; Cut cut = “mu-” == ABSID ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 17 “Own” functions/cuts I Class which implements LoKi::Function or LoKi::Predicate interface : Class which implements LoKi::Function or LoKi::Predicate interface : TYPE TYPE const (LHCb::,LHCb::MC,HepMC::Gen)Particle* const (LHCb::,LHCb::MC,HepMC::Gen)Vertex* 2 mandatory methods 2 mandatory methods MyType* clone() const ; MyType* clone() const ; result_type operator() ( argument a ) const ; result_type operator() ( argument a ) const ; Optional: Optional: std::ostream& fillStream( std::ostream& s ) const { return s << “XXX” ; } std::ostream& fillStream( std::ostream& s ) const { return s << “XXX” ; }

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 18 Every day idioms: simple selections #include “LoKi/LoKi.h” LOKI_ALGORITHM( MyAlg) { using namespace LoKi ; using namespace LoKi ; using namespace LoKi::Cuts ; using namespace LoKi::Cuts ; using namespace LoKi::Types ; using namespace LoKi::Types ; Range pions = select( “pi”, Range pions = select( “pi”, “pi+” == ABSID && PT > 0.5 * GeV ) ; “pi+” == ABSID && PT > 0.5 * GeV ) ; info() << “ found pions:” << pions.size() info() << “ found pions:” << pions.size() << endreq ; << endreq ; return StatusCode::SUCCESS ; return StatusCode::SUCCESS ;}; TAG Cuts:  + and  - with p T >500 MeV/c Select from all loaded/created particles

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 19 Simple selections (II) Select from other selected range : Select from other selected range : Range pions = select( “pi”, “pi-” == ABSID ) ; Range pos = select( “pi+”, pions, Q > 0 ) ; Select from KeyedContainer : Select from KeyedContainer : const LHCb::Particle::Container* p = get (“Phys/MyChannel/Particles”); get (“Phys/MyChannel/Particles”); Range bs = select( “myBs0”, p, “B_s0” == ID ); “B_s0” == ID ); Select from arbitrary sequence seq : Select from arbitrary sequence seq : Range k0s = select( “myK0S”, Range k0s = select( “myK0S”, seq.begin(), seq.end(), “KS0” == ID ); seq.begin(), seq.end(), “KS0” == ID );

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 20 Easy way to get cuts from *.opts *.opts : *.opts : MyLoKiAlg.Cuts = { “ptMin” : 1 * GeV, MyLoKiAlg.Cuts = { “ptMin” : 1 * GeV, “alpha” : } ; “alpha” : } ; *.cpp: *.cpp: Cut ptCutMin = PT > cutValue(“ptMin”) ; Cut ptCutMin = PT > cutValue(“ptMin”) ; Cut ptCutMax = PT < cutValue(“ptMax”, 5 * GeV ) ; Cut ptCutMax = PT < cutValue(“ptMax”, 5 * GeV ) ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 21 Select tracks with min(  2 ) IP >25 Very efficient operation if done BEFORE looping, the combinatorics is reduced significantly (and huge gain in CPU!) Very efficient operation if done BEFORE looping, the combinatorics is reduced significantly (and huge gain in CPU!) const LHCb::RecVertex::ConstVector& pvs = desktop()->primaryVertices() ; Fun mipc2 = MIPCHI2( geo(), pvs ) ; Range pions = select( “pi”, “pi+” = ABSID && mips > 25) ; “pi+” = ABSID && mips > 25) ; Vertices are selected in a similar way The function objects itself Select pions not from primary verstices

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 22 Trivial 1-particle loops Nothing special: Range behaves like STL -container Nothing special: Range behaves like STL -container Range pions = select( … ) ; for( Range::iterator ipi = pions.begin() ; pions.end() != ipi ; ++ipi ) pions.end() != ipi ; ++ipi ){ const LHCb::Particle* p = *ipi ; const LHCb::Particle* p = *ipi ; info() << “ pion momentum:” info() << “ pion momentum:” << P( p ) / Gaudi::Units::GeV << endreq << P( p ) / Gaudi::Units::GeV << endreq};

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 23 Exercise 1 Select stable particles according to simple criteria Select stable particles according to simple criteria ABSID, Q, PIDK, PIDmu, P, PT,… Sub-select from selected containers using refined criteria from *.opts file Sub-select from selected containers using refined criteria from *.opts file Count them Count themHints: select( … ), cutValue( … ) select( … ), cutValue( … ) (Almost) solution: …/solutions/GetData

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 24 Exercise 2 Select stable particles according to some simple criteria Select stable particles according to some simple criteria Make simple loop over Range of particles, fill n-tuple using simple functions Make simple loop over Range of particles, fill n-tuple using simple functions ABSID, Q, PIDK, PIDmu, P, PT,… Hints: More configurations for N-tuples is required in *.opts More configurations for N-tuples is required in *.opts nTuple( … ), column( name, value ) nTuple( … ), column( name, value ) Solutions:../solutions/SimpleLoop../solutions/SimpleLoop2

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 25 Multiparticle loops: Loop over selected particle tags: Loop over selected particle tags: Range mypi = select( “myPi+”, … ); Range myK = select( “myK-”, … ); for ( Loop D0 = loop( “myK- myPi+”, “D0” ) ; D0 ; ++D0 ) D0 ; ++D0 ){ plot( M( D0 )/GeV,“K pi m”,1.5,2.0 ); plot( M( D0 )/GeV,“K pi m”,1.5,2.0 ); if ( VCHI2( D0 ) > 100 ) { continue ; } if ( VCHI2( D0 ) > 100 ) { continue ; } plot( M( D0 )/GeV,“K pi m,chi2”,1.5,2.0); plot( M( D0 )/GeV,“K pi m,chi2”,1.5,2.0);} Loop objects behaves as Particle Loop objects behaves as Vertex

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 26 Access to daughters: using namespace LoKi::Child for ( Loop D0 = loop ( “K- pi+”, “D0” ) ; D0 ; ++D0 ) { const LHCb::Particle* kaon = D0(1) ; const LHCb::Particle* kaon = D0(1) ; const LHCb::Particle* pion = D0(2) ; const LHCb::Particle* pion = D0(2) ; const LHCb::Particle* k1 = child ( D0, 1 ); const LHCb::Particle* k1 = child ( D0, 1 ); const LHCb::Particle* p1 = child ( D0, 2 ) ; const LHCb::Particle* p1 = child ( D0, 2 ) ;} const LHCb::Particle* B = … ; const LHcb::Particle* psi = child ( B, 1 ) ; const LHCb::Particle* mu = child ( psi, 1 ) ; const LHCb::Particle* mu1 = child ( B, 1, 1 ) ; const LHCb::Particle* mu2 = child ( B, 1, 2 ) ; 0 is “self”

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 27 Creation Different creation strategies: [optional] Different creation strategies: [optional] In the loop declaration: In the loop declaration: Loop D0 = loop( “myK- myPi+”, “D0”, CREATOR ) nothing – default creation nothing – default creation pointer to IParticleCombiner tool pointer to IParticleCombiner tool nickname or typename of IParticleCombiner tool nickname or typename of IParticleCombiner tool “”, “OffLine” : OfflineVertexFitter “”, “OffLine” : OfflineVertexFitter “Trigger” : TrgVertexFitter “Trigger” : TrgVertexFitter “Kalman”,”Blind” : BlindVertexFitter “Kalman”,”Blind” : BlindVertexFitter ? : MomentumCombiner ? : MomentumCombiner In the loop body: In the loop body: for ( Loop D0 = … ; D0 ; ++D0 ) { // optional: Re-create: // optional: Re-create: StatusCode sc1 = D0->make( CREATOR ) StatusCode sc1 = D0->make( CREATOR )}

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 28 (Re)Fits Related to the creation strategies: [optional] Related to the creation strategies: [optional] In the loop body: In the loop body: for ( Loop D0 = … ; D0 ; ++D0 ) { // optional: Re-Fit // optional: Re-Fit StatusCode sc2 = D0->reFit( REFIT ) ; StatusCode sc2 = D0->reFit( REFIT ) ;} nothing – default refitter nothing – default refitter pointer to IParticleReFitter tool pointer to IParticleReFitter tool nickname or typename of IParticleReFitter tool nickname or typename of IParticleReFitter tool “”, “OffLine” : OfflineVertexFitter “”, “OffLine” : OfflineVertexFitter “Kalman”,”Blind” : BlindVertexFitte “Kalman”,”Blind” : BlindVertexFitte

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 29 Save something interesting Cut cut = … ; for ( Loop D0 = … ; D0 ; ++D0 ) { if ( !cut( D0 ) ) { continue ;} if ( !cut( D0 ) ) { continue ;} D0->save( “myD0” ) ; D0->save( “myD0” ) ;} Extract saved particles: Extract saved particles: Range d0 = selected( “myD0” ) info() << “ D0 saved: ” << d0.size() << endreq; << d0.size() << endreq; TAG

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 30 Exercise 3 Select charged kaons Select charged kaons Sub-select positive and negatoive Sub-select positive and negatoive Make loop over all K + K - combination, plot invariant mass under some simple criteria, fill simple N-Tuple Make loop over all K + K - combination, plot invariant mass under some simple criteria, fill simple N-Tuple Save “good”  -candidates Save “good”  -candidates Count them Count themHints: Default configurations of creators and refitters are OK Default configurations of creators and refitters are OK  name is phi(1020)  name is phi(1020) Solutions:../solutions/LoKiLoop

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 31 Using Patterns Shortcut for “loop + cuts + save + selected” Shortcut for “loop + cuts + save + selected” Range phi = pattern( “phi”, “K+ K-”,“phi(1020)”, pattern( “phi”, “K+ K-”,“phi(1020)”, ADMASS(“phi(1020)”) < 10 * MeV, ADMASS(“phi(1020)”) < 10 * MeV, VCHI2 < 25 ) ; VCHI2 < 25 ) ; Compact Compact Efficient Efficient

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 32 Get something “working” (1) //Select muons (  + and  - ) according to B s →J/  selection cuts Range mu = select( “mu”, /* unique tag */ “mu+” == ABSID && /*  + and  - */ “mu+” == ABSID && /*  + and  - */ PIDmu > -8 && /*  LL (  -  )>-8 */ PIDmu > -8 && /*  LL (  -  )>-8 */ mipc2 > 25 && /*  2 IP > 25 */ mipc2 > 25 && /*  2 IP > 25 */ PT > 300 * MeV ) ;/* p T >300 MeV/c */ PT > 300 * MeV ) ;/* p T >300 MeV/c */ //Select J/  →  +  - Cut dm = ADMASS(“J/psi(1S)”) < 50 * MeV ;//  M<50MeV/c 2 for( Loop Jpsi = loop( “mu mu”,“J/psi(1S)” ); Jpsi ; ++Jpsi ) Jpsi ; ++Jpsi ){ if ( 0 != SUMQ(Jpsi) ) { continue ;}/*  + &  - */ if ( 0 != SUMQ(Jpsi) ) { continue ;}/*  + &  - */ if ( VCHI2(Jpsi) > 100 ) { continue ;}/*  2 VX 100 ) { continue ;}/*  2 VX <100 */ if ( dm( Jpsi) ) { Jpsi->save(“psi”);}/*  M save(“psi”);}/*  M<50MeV/c 2 */};  q = 0 and  2 <100

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 33 Get something “working” (II) //Select kaons (K + and K - ) according to B s →J/  selection cuts Range k = select( “K”, /* unique tag */ “K+” == ABSID && /* K + and K - */ “K+” == ABSID && /* K + and K - */ PIDK > -2 && /*  LL ( K -  )>-2 */ PIDK > -2 && /*  LL ( K -  )>-2 */ mipc2 > 4 && /*  2 IP > 4 */ mipc2 > 4 && /*  2 IP > 4 */ PT > 500 * MeV ) ; /* p T >500 MeV/c */ PT > 500 * MeV ) ; /* p T >500 MeV/c */ //Select  → K + K - Cut dm = ADMASS(“phi(1020)”) < 20 * MeV ;//  M<20MeV/c 2 for( Loop phi = loop( “K K”,“phi(1020)” ); phi ; ++phi ) { if ( 0 != SUMQ(phi) ) { continue ;}/* K + & K - */ if ( 0 != SUMQ(phi) ) { continue ;}/* K + & K - */ if ( VCHI2(phi) > 100 ) { continue ;}/*  2 VX 100 ) { continue ;}/*  2 VX <100 */ if ( dm( phi ) ) { phi->save(“phi”);}/*  M save(“phi”);}/*  M<20MeV/c 2 */};

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 34 Get something “working” (III) Select Bs according to B s →J/  selection cuts Cut dm = ADMASS(“B_s0”) < 50 * MeV;/*  M<50MeV/c 2 */ // Loop over selected J/  and  // Loop over selected J/  and  for( Loop Bs = loop( “psi phi”,“B_s0” ); Bs; ++Bs ) { if ( !dm( Bs ) ) { continue ; } ;/*  M<50MeV/c 2 */ if ( !dm( Bs ) ) { continue ; } ;/*  M<50MeV/c 2 */ if ( VCHI2(Bs) > 100 ) { continue ;} /*  2 VX 100 ) { continue ;} /*  2 VX <100 */ if ( mips( Bs ) > 25 ) { continue ;} /*  2 IP 25 ) { continue ;} /*  2 IP <25 */ Bs->save(“Bs”); Bs->save(“Bs”);}; // Retrieve all saved “Bs” // Retrieve all saved “Bs” Range Bs = selected(“Bs”) ; if( !Bs.empty() ) { setFilterPassed(true);}

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 35 Or everything together: 1 st page VRange primaries = vselect( “PVs”, Vertex::Primary == VTYPE ) ; /* all primary vertices */ Vertex::Primary == VTYPE ) ; /* all primary vertices */ Fun mipc2 = MIPCHI2( geo(), primaries ); /* min(  2 IP ) */ // muons: Range mu = select( “mu”, /* unique tag */ “mu+” == ABSID && /*  + and  - */ “mu+” == ABSID && /*  + and  - */ PIDmu > -8 && /*  LL (  -  )>-8 */ PIDmu > -8 && /*  LL (  -  )>-8 */ mipc2 > 25 && /*  2 IP > 25 */ mipc2 > 25 && /*  2 IP > 25 */ PT > 300 * MeV ) ;/* p T >300 MeV/c */ PT > 300 * MeV ) ;/* p T >300 MeV/c */ // kaons: Range k = select( “K”, /* unique tag */ “K+” == ABSID && /* K + and K - */ “K+” == ABSID && /* K + and K - */ PIDK > -2 && /*  LL ( K -  )>-8 */ PIDK > -2 && /*  LL ( K -  )>-8 */ mipc2 > 4 && /*  2 IP > 4 */ mipc2 > 4 && /*  2 IP > 4 */ PT > 500 * MeV ) ; /* p T >500 MeV/c */ PT > 500 * MeV ) ; /* p T >500 MeV/c */

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 36 Or everything together: 2 nd page: // Cuts: Cut dmPsi = ADMASS(“J/psi(1S)”) < 50*MeV; /*  M<50 MeV/c 2 */ Cut dmPhi = ADMASS(“phi(1020)”) < 20*MeV; /*  M<20 MeV/c 2 */ Cut dmBs = ADMASS(“B_s0”) < 50*MeV; /*  M<50 MeV/c 2 */ Cut q = 0 == SUMQ ; /*  q = 0 */ VCut chi2 = VCHI2 < 100 ; /*   VX <50 MeV/c 2 */ // Loops: pattern(“psi”, “mu mu”,“J/psi(1S)”, dmPsi && q, chi2 ); pattern(“phi”, “K K”,“phi(1020”, dmPhi && q, chi2 ); Range Bs = pattern(“Bs”, “psi phi”, “B_s0”, pattern(“Bs”, “psi phi”, “B_s0”, dmBs && mipc2 < 5, chi2 ); dmBs && mipc2 < 5, chi2 ); if( !Bs.empty() ) { setFilterPassed(true);} 1+1 page !!!

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 37 Exercise 4 “Reconstruct” J/  candidates “Reconstruct” J/  candidates “Reconstruct”  -candidates “Reconstruct”  -candidates Fill simple N-Tuple(s) Fill simple N-Tuple(s) Save “good” B s -candidates Save “good” B s -candidates Count them Count themHints: Default configurations of creators and refitters are OK Default configurations of creators and refitters are OK  name is J/psi(1S)  name is J/psi(1S) Solutions:../solutions/PsiPhi

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 38 MC match LoKi uses own concept of MC -truth matching, described in details in LUG LoKi uses own concept of MC -truth matching, described in details in LUG “Loose” matching: none relations can be lost “Loose” matching: none relations can be lost Some “extra” relations could be a bit confusing  Some “extra” relations could be a bit confusing  Technically based on Relation Table s from Kernel/Relations package Technically based on Relation Table s from Kernel/Relations package Requires: Requires: IRelation IRelation No way for transitions to Linker s Natural coupling with MCDecayFinder tool and MCParticle selections Natural coupling with MCDecayFinder tool and MCParticle selections Few helper adapter functions Few helper adapter functions

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 39 MCMatch MCFinder mc = mcFinder(“some name”) ; MCRange mcPsi = mc-> findDecay( “B_s0 -> ^J/psi(1S) phi(1020) ”); “B_s0 -> ^J/psi(1S) phi(1020) ”); MCMatch match = mcTruth(“some name”) ; Cut truePsi = MCTRUTH( match, mcPsi ) ; For ( Loop Jpsi = loop(“mu mu”, … ) ; Jpsi ; ++Jpsi) { if( !truePsi( Jpsi) ) { continue ; } if( !truePsi( Jpsi) ) { continue ; }} Evaluates to true, if both muons come from true MC J/psi from this decay chain

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 40 MC truth Match Cut truePsi = MCTRUTH( match, mcPsi ) ; Cut truePhi = MCTRUTH( match, mcPhi ) ; Cut trueBs = MCTRUTH( match, mcBs ) ; Cut trueMu = MCTRUTH( match, mcMu ) ; Cut trueK = MCTRUTH( match, mcK ) ; for( Loop Bs = loop(“psi phi”, … ); Bs ; ++Bs) { tuple -> column(“mcbs”,trueBs (Bs ) ); tuple -> column(“mcpsi”,truePsi (Bs(1)) ); tuple -> column(“mcphi”,truePhi (Bs(2)) ); tuple -> … }

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 41 Useful utility DecayChain Prints (MC) decay chains in different formats Templated Templated applicable to Particles, MCParticles, lists, trees, … applicable to Particles, MCParticles, lists, trees, … std::ostream, MsgStream, ‘\n’, endreq, … std::ostream, MsgStream, ‘\n’, endreq, … (MC)Cut, … (MC)Cut, … Different “formats” are supported Different “formats” are supported Default setting is “reasonable” Default setting is “reasonable” “Intuitive” and recursive “Intuitive” and recursive DecayChain print ; dc.print ( WHAT, /* what to print */ STREAM, “\n”, /* stream and terminator */ STREAM, “\n”, /* stream and terminator */ ACCEPT, /* predicate “to be print” */ ACCEPT, /* predicate “to be print” */ MARK ) ; /* predicate “to be colorized” */ MARK ) ; /* predicate “to be colorized” */ // dc.print( Bs, info(), endreq, ALL, MCTRUTH( mc, mcBs ) ) ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 42 Exercise 5 “Reconstruct” J/  candidates “Reconstruct” J/  candidates Fill simple N-Tuple(s) with MC-flags for muons and for J/  candidates Fill simple N-Tuple(s) with MC-flags for muons and for J/  candidatesHints: The actual base is LoKi::AlgoMC The actual base is LoKi::AlgoMC LOKI_MCALGORITHM( … ) ; Default configurations of creators and refitters are OK Default configurations of creators and refitters are OK  name is J/psi(1S)  name is J/psi(1S) To be efficient: To be efficient: MyAlg.PP2MCs = {“Relations/Rec/ProtoP/charged”} ; Solutions:../solutions/PsiMC

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 43 Exercise 6 (Homework) “almost realistic analysis algorithms” “almost realistic analysis algorithms” “Reconstruct” full B s →J/  chain “Reconstruct” full B s →J/  chain Fill simple N-Tuple(s) with all MC-flags Fill simple N-Tuple(s) with all MC-flagsHints: Default configurations of creators and refitters are OK Default configurations of creators and refitters are OK  name is J/psi(1S)  name is J/psi(1S) B s name is B_s0 B s name is B_s0 To be efficient: To be efficient: MyAlg.PP2MCs = {“Relations/Rec/ProtoP/Charged”} ; Solutions:../solutions/Bs2PsiPhi

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 44 Exercise 7 (Advanced Homework) “almost realistic analysis algorithms” “almost realistic analysis algorithms” “Reconstruct” full B s →D s K  chain “Reconstruct” full B s →D s K  chain Fill simple N-Tuple(s) with all MC-flags Fill simple N-Tuple(s) with all MC-flagsHints: Both B s and anti -B s could decays into this state Both B s and anti -B s could decays into this state decay descriptor decay descriptor D s + name is Ds+ D s + name is Ds+ B s name is B_s0 B s name is B_s0 To be efficient: To be efficient: MyAlg.PP2MCs = {“Relations/Rec/ProtoP/Charged”} ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 45 Exercise 8 (Homework) Run algorithm from Exersises 6&7 on bb-inclusive data, Run algorithm from Exersises 6&7 on bb-inclusive data, Compare the basic distributions for signal and “background” Compare the basic distributions for signal and “background” P,PT, MIPCHI2 for final-state particles, intermediate particles and selected B-candidates P,PT, MIPCHI2 for final-state particles, intermediate particles and selected B-candidates Hints: The nessessary data is available The nessessary data is available /software/lhcb/BenderData directory /software/lhcb/BenderData directory The proper *.opts files need to be prepared The proper *.opts files need to be prepared

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 46 Select Primary vertex Select primary vertex according to some criteria, e.g. the vertex with minimal  2 IP : Select primary vertex according to some criteria, e.g. the vertex with minimal  2 IP : VRange pvs = vselected(“PVs”, Vertex::Primary == VTYPE ) ; Vertex::Primary == VTYPE ) ; for ( Loop Bs = loop(“psi phi”,…); Bs ; ++Bs ) { const Vertex* pv = const Vertex* pv = SelectPrimaryVertexMin( SelectPrimaryVertexMin( pvs.begin(), pvs.end(), pvs.begin(), pvs.end(), VIPCHI2( Bs, geo() ), VIPCHI2( Bs, geo() ), VPSD( Bs, geo() ) > -0.2 * mm) ; VPSD( Bs, geo() ) > -0.2 * mm) ;} Sequence of vertices Selection criterion Cut: B s should not be “too” upstream with respect to selected primary vertex MY FAULT WITH v4r2

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 47 Select Primary vertex: Select primary vertex according to some criteria, e.g. the vertex with minimal  2 IP : Select primary vertex according to some criteria, e.g. the vertex with minimal  2 IP : VRange pvs = vselected(“PVs”, Vertex::Primary == VTYPE ) ; Vertex::Primary == VTYPE ) ; for ( Loop Bs = loop(“psi phi”,…) ; Bs ; ++Bs ) { VRange::iterator ipv = VRange::iterator ipv = select_min ( pvs.begin(), select_min ( pvs.begin(), pvs.end(), pvs.end(), VIPCHI2( Bs, geo() ), VIPCHI2( Bs, geo() ), VPSD ( Bs, geo() ) > -0.2 * mm ) ; VPSD ( Bs, geo() ) > -0.2 * mm ) ; if ( pvs.end() == ipv ) { continue ; } if ( pvs.end() == ipv ) { continue ; } const Vertex* pv = *ipv ; const Vertex* pv = *ipv ;}; More generic & More efficient

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 48 Other features: LoKi is able to build jets (using popular KtJet algorithm) LoKi is able to build jets (using popular KtJet algorithm) KtJet algorithm KtJet algorithm LoKi is able to create Particles from generator infomration: usful to check different decay models with the same code as analysis LoKi is able to create Particles from generator infomration: usful to check different decay models with the same code as analysis LoKi supports many links inbetween LoKi supports many links inbetween RC↔ MC↔ HepMC RC↔ MC↔ HepMC LoKi suppors MC-truth access for reconstructed primary vertices LoKi suppors MC-truth access for reconstructed primary vertices And many-many more And many-many more

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 49 Important missing component: Need for resurrection of “easy” tagging Need for resurrection of “easy” tagging // create tagger object Tagger tag = tagger(“My B-Tagger”); // tag and associate B-candidate tagger->tag( B ) ; // extract all tags for given B TRange tags = tagger->tags( B ) ;

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 50 LoKi I Loki is a god of wit and mischief in Norse mythology Loki is a god of wit and mischief in Norse mythology Lo ops & Ki nematics Lo ops & Ki nematics

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 51 LoKi II

Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 52 LoKi III