Isolation Tools in the LHCb Stripping framework

Contents

Introduction

Isolating your signal decay from other tracks in LHCb has been shown to help reject partially reconstructed background decays. Most isolation algorithms require the other tracks in the event, and moving to MicroDST means that the tracks are not retained as part of the event. Once your isolation algorithms are mature, then you can be confident to implement the algorithm in the stripping. This allows the algorithms to be run and for you candidates, with the additional isolation parameters, to be saved on muDST.

Requirements:

  • Testing the configuration of the tools: DaVinci v36r0 onwards
  • Testing the reading/writing : DaVinci HEAD (as of 13-08-14) :
SetupProject DaVinci --nightly lhcb-head and SetupProject DaVinci --nightly lhcb-head --build-env

Adding isolation variables to your stripping line

These are configured in the constructor of the StrippingLine, through the RelatedInfoTools parameter:

StrippingLine( ...
       RelatedInfoTools = [
        { 'Type' : 'RelInfoConeVariables', 'ConeAngle' : 0.5, 'Variables' : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
          'RecursionLevel' : 1,
          'Locations' : {
            selPromptDstar : 'P2CVDstar2',
            selD02hhmumu   : 'P2CVD2',
            'Phys/StdAllNoPIDsPions'   : 'P2CVpi2',
          }
        },
        {
          'Type' : 'RelInfoConeVariables', 'ConeAngle' : 0.5, 'Variables' : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
          'TopSelection' : selD02hhmumu,
          'Location' : 'P2CVD'
        },
      ]

Here, the code configures the isolation variables as follows:

  • Uses the RelInfoConeVariables tool
  • Calculates the parameters 'CONEANGLE', 'CONEMULT', 'CONEPTASYM'
  • Recursion level of 1 implies that the Tool calculates the variables for the head of the decay chain and the first direct daughters.
  • There are two options for running the RelatedInfo tools
    • TopSelection is the stripping line selection and the Location parameter stores the info on the B
    • Locations parameter stores the info for the daughter particles and takes selections or locations as input
  • The Location(s) strings are the places on the DST (in the TES) where the information will be stored. These are unique to the Stripping line and are only needed for when you and to read the information out. The information is stored at '/Event/MyStream/Phys/MyLine/MyLocation'
  • At the moment, the Locations string must point to a Container created by a CombineParticleMaker instance (where the particles sit) rather than to a FilterDesktop - check which type of CommonParticles you use!!!

Reading the isolation variables

The additional information stored by the RelatedInfo tools can be read out using the RELINFO loki functor.

RELINFO('full TES location', 'variable', default_value)
e.g.
from Configurables import LoKi__Hybrid__TupleTool
LoKi_Cone =  LoKi__Hybrid__TupleTool( 'LoKi_Cone')
LoKi_Cone.Variables = {
    "Dstar_CONEANGLE" : "RELINFO('/Event/MyStream/Phys/MyLine/MyLocation', 'CONEANGLE', -1.)"
}

Shortened Paths like "Phys/...." can be passed to RELINFO aswell.

Developing new isolation variables

The isolation tools are stored in the package, Phys/IsolationTools.

Requirements

The requirements you need to write an Isolation tool are the following

  • Variables you want to calculate.
  • Code to calculate the variables (should be able to run in a TupleTool beforehand)

Packages for development in DaVinci v36r0:

Phys/IsolationTools head   #package to add the tools
Phys/RelatedInfoTools head   #package with examples
Phys/DaVinciTypes head     #package containing the enums
TMVAWeights head             #package for the BDT weights files
*

Example testing script

  • /afs/cern.ch/work/a/ashires/public/Isolation/DVBu2LLKstripping.py

Implementation

At the moment, there are two implementations in Phys/IsolationTools for you to look at.

  • RelInfoVertexIsolationBDT
  • RelInfoTrackIsolationBDT

in Phys/DaVinciTools, there are the tools

  • RelInfoConeVariables
  • RelInfoVertexIsolation

The relevant bits of code that you need to port across are

m_map.clear();

    std::vector<short int>::const_iterator ikey;
    for (ikey = m_keys.begin(); ikey != m_keys.end(); ikey++) {

        float value = 0;
        switch (*ikey) {
            case RelatedInfoNamed::VTXISOBDTHARDFIRSTVALUE : value = m_bdt1; break;
            case RelatedInfoNamed::VTXISOBDTHARDSECONDVALUE  : value = m_bdt2; break;
            case RelatedInfoNamed::VTXISOBDTHARDTHIRDVALUE   : value = m_bdt3; break;
            case RelatedInfoNamed::VTXISOBDTSOFTFIRSTVALUE : value = m_bdt1; break;
            case RelatedInfoNamed::VTXISOBDTSOFTSECONDVALUE  : value = m_bdt2; break;
            case RelatedInfoNamed::VTXISOBDTSOFTTHIRDVALUE   : value = m_bdt3; break;

        }

        if (msgLevel(MSG::DEBUG)) debug() << "  Inserting key = " << *ikey << ", value = " << value << " into map" << endreq;
        m_map.insert( std::make_pair( *ikey, value) );
    }

and

LHCb::RelatedInfoMap* RelInfoVertexIsolationBDT::getInfo(void) {
    return &m_map;
}

The enumerated types where the information are stored must be added to Phys/DaVinciTypes/Kernel/RelatedInfoNamed.h. These names must be clear, explanatory and simple. You should check with Anton and Chris before comitting to this package.

To be able to test the new variables after adding them to Phys/DaVinciTypes/Kernel/RelatedInfoNamed.h, you need to getpack and build Phys/LoKiPhys package (or wait for DaVinci nightlies to be ready if running from nightlies). This is the package that provides LoKi functor RELINFO and it takes the variable names from Phys/DaVinciTypes/Kernel/RelatedInfoNamed.h.

Testing your isolation tool

You must test your isolation tool before it is used in the stripping. There must not be any memory leaks, excessively long performance and it must compile cleanly without any errors or warnings. This is production code and must be treated with respect.

Script

# Now build the stream
from StrippingConf.StrippingStream import StrippingStream
stream = StrippingStream("Test")
stream.OutputLevel = 1

# Append your line
from StrippingSelections.StrippingBu2LLK import Bu2LLKConf
from StrippingSelections.StrippingBu2LLK import default_config

import copy
default_config_noiso    = copy.deepcopy(default_config['CONFIG'])
default_config_basiciso = copy.deepcopy(default_config['CONFIG'])
default_config_vtxiso   = copy.deepcopy(default_config['CONFIG'])
default_config_trkiso   = copy.deepcopy(default_config['CONFIG'])

default_config_noiso["RelatedInfoTools"]    = []
default_config_basiciso["RelatedInfoTools"] = [
                                        {'Type': 'RelInfoVertexIsolation'
                                            , 'Location':'VtxIsoInfo' }
                                       , {'Type': 'RelInfoConeVariables'
                                            , 'Location':'ConeIsoInfo' }
                                        ]
default_config_vtxiso["RelatedInfoTools"]   = [
                                        {'Type': 'RelInfoVertexIsolationBDT'
                                            , 'Location':'VtxIsoBDTInfo' }
                                        #{'Type': 'RelInfoConeVariables'
                                        #    , 'Location':'ConeIsoInfo' }
                                        ]
default_config_trkiso["RelatedInfoTools"]   = [
                                            { 'Type': 'RelInfoTrackIsolationBDT'
                                            , 'Locations': { 'StdLooseMuons'
                                                : "MuonTrackIsoBDTInfo" }
                                        #    {'Type': 'RelInfoConeVariables'
                                        #    , 'Location':'ConeIsoInfo' }
                                            }
                                            ]

print default_config_noiso

Bu2LLKBuilder = Bu2LLKConf( name="Bu2LLK", config=default_config_noiso )
Bu2LLKBuilder1 = Bu2LLKConf( name="Bu2LLK_noiso", config=default_config_noiso )
Bu2LLKBuilder2 = Bu2LLKConf( name="Bu2LLK_basicso", config=default_config_basiciso )
Bu2LLKBuilder3 = Bu2LLKConf( name="Bu2LLK_vtxbdtiso", config=default_config_vtxiso )
Bu2LLKBuilder4 = Bu2LLKConf( name="Bu2LLK_trkbdtiso", config=default_config_trkiso )

lines = Bu2LLKBuilder.lines()
lines1 = Bu2LLKBuilder1.lines()
lines2 = Bu2LLKBuilder2.lines()
lines3 = Bu2LLKBuilder3.lines()
lines4 = Bu2LLKBuilder4.lines()

print lines[2].name(), lines2[2].name()
#sublines = [ line for line in Bu2LLKBuilder.lines() if "mm" in line ]
stream.appendLines( ( [lines[2]
        , lines1[2]
        , lines2[2]
        , lines3[2]
        , lines4[2]
        ])  )

sc = StrippingConf( Streams = [ stream ],
                    MaxCandidates = 2000,
                    AcceptBadEvents = False,
                    BadEventSelection = filterBadEvents,
                    TESPrefix = 'Strip'
                    )

DaVinci().appendToMainSequence( [ sc.sequence() ] )
-- AlexShires - 22 Jul 2014
Edit | Attach | Watch | Print version | History: r16 < r15 < r14 < r13 < r12 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r16 - 2017-10-13 - JulienCogan
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback