Download presentation
Presentation is loading. Please wait.
Published byAnne Harrell Modified over 9 years ago
1
LoKi’s Cook-book : Writing analysis algorithms in C++ Tutorial v4r2 Vanya Belyaev Vanya Belyaev (Syracuse) Vanya Belyaev
2
Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 2 Outline LoKi LoKi V4r2 released V4r2 released DaVinci v17r5 DaVinci v17r5
3
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: lhcb-loki@cern.ch Mailing list: lhcb-loki@cern.ch lhcb-loki@cern.ch LoKi pages by Elena Mayatskaya LoKi pages by Elena MayatskayaLoKi pages Elena MayatskayaLoKi pages Elena Mayatskaya “Tool for senior physicists” ?
4
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-2004-023 DoxyGen documentation: DoxyGen documentation: Now available (partly) throught Phys Doxygen
5
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
6
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
7
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
8
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
9
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
10
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
11
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()
12
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 ;
13
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, …
14
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
15
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, …
16
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 ;
17
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” ; }
18
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
19
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 );
20
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” : 0.99999 } ; “alpha” : 0.99999 } ; *.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 ) ;
21
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
22
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};
23
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
24
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
25
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
26
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”
27
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 )}
28
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
29
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
30
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
31
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
32
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
33
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 */};
34
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);}
35
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 */
36
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 !!!
37
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
38
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
39
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
40
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 -> … }
41
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 ) ) ;
42
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
43
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
44
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”} ;
45
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
46
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
47
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
48
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
49
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 ) ;
50
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
51
Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 51 LoKi II
52
Nov'2k+6 Tutorial in Uni-Dortmund Vanya BELYAEV/Syracuse 52 LoKi III
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.