Difference: DaVinciTutorial4 (1 vs. 43)

Revision 432014-07-29 - NathanaelFarley

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 17 to 17
  At this stage you will need to know quite a bit more about python, including what a python module is, how you create and import them, and the nature of the PYTHONPATH.
Changed:
<
<

Do this before

This tutorial requires you to build your own version of DaVinci. You can do this by the following commands %SYNTAX{ syntax="bash"}%SetupProject DaVinci --build-env # Create the directory structure to build DaVinci getpack Phys/DaVinci # fetch the latest DaVinci code cd Phys/DaVinci/cmt # go into the cmt directory cmt make # make the application
>
>
This tutorial assumes that you have run %SYNTAX{"bash"}% SetupProject DaVinci --build-env getpack Tutorial/Analysis
 %ENDSYNTAX%
Changed:
<
<
You need to do this only once per version of DaVinci. This will give you the required files for this tutorial. You can also make the files from directly within ganga (discussed later in this tutorial). After this is set up run
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci
<!-- end SyntaxHighlightingPlugin -->
to activate your newly compiled code.
>
>
for your personal Davinci installation. Any reference to the folder solutions can be found in the Tutorial/Analysis folder
 

1 LoKi

Line: 63 to 58
 

2 Particle Selection framework

We have a powerful python module-based selection framework. This is the recommended way of constructing particles.

Changed:
<
<
See, for example, the options files in $DAVINCIROOT/options for more examples.
>
>
See, for example, the options files in $DAVINCIROOT/options for more examples.
  Firstly we will use the GaudiAlgorithm CombineParticles to create our resonances, then we will use the framework to combine all these into a sequence. From Following DaVinciTutorial0 you will have a job which runs inside Ganga. You should copy that options file
Changed:
<
<
We will be coding the φ, J/ψ and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in $DAVINCIROOT/python/DaVinci/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
>
>
We will be coding the φ, J/ψ and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
 %SYNTAX{syntax="python"}%
Changed:
<
<
from DaVinci import Bs2JpsiPhi
>
>
from DaVinci4 import Bs2JpsiPhi
 help(Bs2JpsiPhi) dir(Bs2JpsiPhi) %ENDSYNTAX%

2.1 Make a Bs2PsiPhi python module

Changed:
<
<
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in $DAVINCIROOT/python/DaVinci gets put in an area that is on that path once the package is built.
  • Open empty file $DAVINCIROOT/python/DaVinci/Bs2JpsiPhi.py
>
>
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in python/DaVinci4 gets put in an area that is on that path once the package is built.
  • Open empty file python/DaVinci4/Bs2JpsiPhi.py
 
  • Add some necessary modules
    <!-- SyntaxHighlightingPlugin -->
import GaudiKernel.SystemOfUnits as Units
from Gaudi.Configuration import *
<!-- end SyntaxHighlightingPlugin -->
Line: 127 to 122
  Algorithm = _jpsi2mumu, RequiredSelections = [StdLooseMuons])%ENDSYNTAX% Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/ψ! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
Changed:
<
<
from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%
>
>
from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%
 

3 Creating the full sequence

Line: 197 to 192
  Add into your options file: %SYNTAX{ syntax="python"}%
Changed:
<
<
from Bs2JpsiPhiEx4 import SeqBs2JpsiPhi as theSequence
>
>
from Bs2JpsiPhiEx4 import SeqBs2JpsiPhi as theSequence
 MySelection = theSequence.sequence() DaVinci().UserAlgorithms = [MySelection] %ENDSYNTAX%
Line: 206 to 201
 

Help!

Changed:
<
<
The solution is given in python/DaVinci/solutions for the module. and solutions/DaVinci for the script to run the selection.
>
>
The solution is given in python/DaVinci4/solutions for the module. and solutions/DaVinci4 for the script to run the selection.
 

What next?

Line: 219 to 214
 -- JuanPalacios - 2009-10-02 -- PatrickSKoppenburg - 16-Oct-2012 -- PatrickSKoppenburg - 30-Sep-2013
Deleted:
<
<
-- NathanaelFarley - 16 Jun 2014
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"

Revision 422014-07-14 - NathanaelFarley

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 76 to 76
 %ENDSYNTAX%

2.1 Make a Bs2PsiPhi python module

Changed:
<
<
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in =$DAVINCIROOT/python/DaVinci% gets put in an area that is on that path once the package is built.
>
>
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in $DAVINCIROOT/python/DaVinci gets put in an area that is on that path once the package is built.
 
  • Open empty file $DAVINCIROOT/python/DaVinci/Bs2JpsiPhi.py
  • Add some necessary modules %SYNTAX{syntax="python"}%
import SystemOfUnits as Units

Revision 412014-06-16 - NathanaelFarley

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 17 to 17
  At this stage you will need to know quite a bit more about python, including what a python module is, how you create and import them, and the nature of the PYTHONPATH.
Added:
>
>

Do this before

This tutorial requires you to build your own version of DaVinci. You can do this by the following commands
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --build-env # Create the directory structure to build DaVinci
getpack Phys/DaVinci # fetch the latest DaVinci code
cd Phys/DaVinci/cmt # go into the cmt directory
cmt make # make the application
<!-- end SyntaxHighlightingPlugin -->
You need to do this only once per version of DaVinci. This will give you the required files for this tutorial. You can also make the files from directly within ganga (discussed later in this tutorial). After this is set up run
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci
<!-- end SyntaxHighlightingPlugin -->
to activate your newly compiled code.
 

1 LoKi

Our CombineParticles framework uses the amazing flexibility of LoKi.

Line: 51 to 63
 

2 Particle Selection framework

We have a powerful python module-based selection framework. This is the recommended way of constructing particles.

Changed:
<
<
See, for example, the options files in $DAVINCIROOT/options for more examples.
>
>
See, for example, the options files in $DAVINCIROOT/options for more examples.
  Firstly we will use the GaudiAlgorithm CombineParticles to create our resonances, then we will use the framework to combine all these into a sequence. From Following DaVinciTutorial0 you will have a job which runs inside Ganga. You should copy that options file
Changed:
<
<
We will be coding the φ, J/ψ and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
>
>
We will be coding the φ, J/ψ and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in $DAVINCIROOT/python/DaVinci/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
 %SYNTAX{syntax="python"}%
Changed:
<
<
from DaVinci4 import Bs2JpsiPhi
>
>
from DaVinci import Bs2JpsiPhi
 help(Bs2JpsiPhi) dir(Bs2JpsiPhi) %ENDSYNTAX%

2.1 Make a Bs2PsiPhi python module

Changed:
<
<
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in python/DaVinci4 gets put in an area that is on that path once the package is built.
  • Open empty file python/DaVinci4/Bs2JpsiPhi.py
>
>
We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in =$DAVINCIROOT/python/DaVinci% gets put in an area that is on that path once the package is built.
  • Open empty file $DAVINCIROOT/python/DaVinci/Bs2JpsiPhi.py
 
  • Add some necessary modules
    <!-- SyntaxHighlightingPlugin -->
import GaudiKernel.SystemOfUnits as Units
from Gaudi.Configuration import *
<!-- end SyntaxHighlightingPlugin -->
Line: 115 to 127
  Algorithm = _jpsi2mumu, RequiredSelections = [StdLooseMuons])%ENDSYNTAX% Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/ψ! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
Changed:
<
<
from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%
>
>
from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%
 

3 Creating the full sequence

Line: 185 to 197
  Add into your options file: %SYNTAX{ syntax="python"}%
Changed:
<
<
from Bs2JpsiPhiEx4 import SeqBs2JpsiPhi as theSequence
>
>
from Bs2JpsiPhiEx4 import SeqBs2JpsiPhi as theSequence
 MySelection = theSequence.sequence() DaVinci().UserAlgorithms = [MySelection] %ENDSYNTAX%
Line: 194 to 206
 

Help!

Changed:
<
<
The solution is given in python/DaVinci4/solutions for the module. and solutions/DaVinci4 for the script to run the selection.
>
>
The solution is given in python/DaVinci/solutions for the module. and solutions/DaVinci for the script to run the selection.
 

What next?

Line: 207 to 219
 -- JuanPalacios - 2009-10-02 -- PatrickSKoppenburg - 16-Oct-2012 -- PatrickSKoppenburg - 30-Sep-2013
Added:
>
>
-- NathanaelFarley - 16 Jun 2014
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"

Revision 402013-09-30 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Introduction

Changed:
<
<
The purpose of this exercise is to allow you to write a set of complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
>
>
The purpose of this exercise is to allow you to write a set of complete though simple selection algorithms for a typical decay: Bs→J/ψφ. We will use Configurables and the Particle Selection Framework to write re-usable J/ψ, φ and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
 

Slides

Line: 56 to 56
 Firstly we will use the GaudiAlgorithm CombineParticles to create our resonances, then we will use the framework to combine all these into a sequence. From Following DaVinciTutorial0 you will have a job which runs inside Ganga. You should copy that options file
Changed:
<
<
We will be coding the Phi, Jpsi and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
>
>
We will be coding the φ, J/ψ and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
 %SYNTAX{syntax="python"}% from DaVinci4 import Bs2JpsiPhi help(Bs2JpsiPhi)
Line: 78 to 78
 env['PYTHONPATH'] %ENDSYNTAX%
Changed:
<
<

2.2 Make a loose J/psi Selection

>
>

2.2 Make a loose J/ψ Selection

  Add this into your python file %SYNTAX{ syntax="python"}%
Line: 102 to 102
 All the cuts that require the position of the vertex must be applied in MotherCut, while the others, like mass, can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in CombinationCut and a harder in MotherCut. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in CombinationCut it's just the sum of the momenta of the daughters at their first measurement.
  • The cuts that can be applied in the filters are the LoKiHybridFilters.
  • Let's ignore cuts on daughters for the time being.
Changed:
<
<
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
>
>
  • We want a mass cut on the J/ψ candidates.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
 
  • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
Line: 114 to 114
 LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu", Algorithm = _jpsi2mumu, RequiredSelections = [StdLooseMuons])%ENDSYNTAX%
Changed:
<
<
Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
>
>
Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/ψ! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
 from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%

3 Creating the full sequence

Changed:
<
<

3.1 Filter further to make a tighter J/Psi Selection

>
>

3.1 Filter further to make a tighter J/ψ Selection

 We can apply harder cuts using a FilterDesktop. %SYNTAX{ syntax="python"}% # make a FilterDesktop
Line: 131 to 131
  Algorithm = _jpsifilter, RequiredSelections = [LooseJpsi2MuMu]) %ENDSYNTAX%
Changed:
<
<
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its Inputs. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
>
>
This applies a momentum and transverse momentum cut on the J/ψ. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its Inputs. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
 
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
Changed:
<
<

3.2 Make the Phi Selection

>
>

3.2 Make the φ(1020) Selection

 Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons which you need to pass to Phi2KK as RequiredSelections.

3.3 Make the Bs Selection

Changed:
<
<
The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV.
>
>
The last step is the Bs using the filtered J/ψ and the φ as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV.
 %SYNTAX{ syntax="python"}% _bs2jpsiphi = CombineParticles("Bs2JpsiPhi", DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)",
Line: 166 to 166
  Make sure the Selection definition comes after the complete definition of all algorithms that go inside.
Changed:
<
<

3.4 Make a Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection.
>
>

3.4 Make a Bs → J/ψ(μμ)φ(KK) SelectionSequence

Now that we have the J/ψ, φ and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs → J/ψ(μμ)φ(KK)selection. It is remarkable simple, since all the necessary information is contained in each Selection.
 %SYNTAX{syntax="python"}% from PhysSelPython.Wrappers import SelectionSequence SeqBs2JpsiPhi = SelectionSequence('SeqB2jJpsiPhi', TopSelection = Bs2JpsiPhi)
Line: 206 to 206
 -- PatrickKoppenburg - 05 Jan 2009 -- JuanPalacios - 2009-10-02 -- PatrickSKoppenburg - 16-Oct-2012
Added:
>
>
-- PatrickSKoppenburg - 30-Sep-2013
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"

Revision 382012-03-20 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 206 to 206
 -- PatrickKoppenburg - 05 Jan 2009 -- JuanPalacios - 2009-10-02
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r0p1"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r2"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v507r9"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 372012-03-09 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 206 to 206
 -- PatrickKoppenburg - 05 Jan 2009 -- JuanPalacios - 2009-10-02
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v504r5"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r0p1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v507r9"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 362011-12-02 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 83 to 83
 Add this into your python file %SYNTAX{ syntax="python"}% # make a Selection out of a data-on-demand location
Deleted:
<
<
from PhysSelPython.Wrappers import DataOnDemand _muons = DataOnDemand(Location = 'Phys/StdLooseMuons')
 from Configurables import CombineParticles _jpsi2mumu = CombineParticles("Jpsi2MuMu") # Define the Decay Descriptor
Line: 112 to 110
 
  • Now we make a Selection object for the Jpsi. It only needs the standard loose muons, so we pass it a list with _muons as only entry for RequiredSelections.%SYNTAX{ syntax="python"}%
from PhysSelPython.Wrappers import Selection
Added:
>
>
from StandardParticles import StdLooseMuons
 LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu", Algorithm = _jpsi2mumu,
Changed:
<
<
RequiredSelections = [_muons])%ENDSYNTAX%
>
>
RequiredSelections = [StdLooseMuons])%ENDSYNTAX%
  Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python:
<!-- SyntaxHighlightingPlugin -->
from DaVinci4.Bs2JpsiPhiEx4 import LooseJpsi2MuMu 
<!-- end SyntaxHighlightingPlugin -->
Line: 136 to 135
 
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.

3.2 Make the Phi Selection

Changed:
<
<
Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons, so make a DataOnDemand instance to pass to Phi2KK as RequiredSelections.
>
>
Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons which you need to pass to Phi2KK as RequiredSelections.
 

3.3 Make the Bs Selection

The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV.

Revision 352011-03-23 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 115 to 115
 LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu", Algorithm = _jpsi2mumu, RequiredSelections = [_muons])%ENDSYNTAX%
Changed:
<
<
Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
>
>
Note that we do not need to specify any Inputs for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
 from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%

3 Creating the full sequence

Line: 132 to 132
  Algorithm = _jpsifilter, RequiredSelections = [LooseJpsi2MuMu]) %ENDSYNTAX%
Changed:
<
<
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its InputLocations. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
>
>
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its Inputs. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
 
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.

3.2 Make the Phi Selection

Revision 332011-01-04 - ChristopherRJones

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Introduction

Changed:
<
<
The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
>
>
The purpose of this exercise is to allow you to write a set of complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
 

Slides

Changed:
<
<
This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.
>
>
This tutorial corresponds to the slides shown at the 2009 January LHCb-UK tutorial here and the 2011 Course here.
  Warning: This tutorial refers to DaVinci version v30r2 or later.
Line: 194 to 195
 

Help!

Changed:
<
<
The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.
>
>
The solution is given in python/DaVinci4/solutions for the module. and solutions/DaVinci4 for the script to run the selection.
 

What next?

Revision 322010-05-27 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 83 to 83
 %SYNTAX{ syntax="python"}% # make a Selection out of a data-on-demand location from PhysSelPython.Wrappers import DataOnDemand
Changed:
<
<
_muons = DataOnDemand('_stdLooseMuons', Location = 'Phys/StdLooseMuons')
>
>
_muons = DataOnDemand(Location = 'Phys/StdLooseMuons')
 from Configurables import CombineParticles _jpsi2mumu = CombineParticles("Jpsi2MuMu") # Define the Decay Descriptor

Revision 312010-01-29 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 206 to 206
 -- PatrickKoppenburg - 05 Jan 2009 -- JuanPalacios - 2009-10-02
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p2"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p3"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v504r5"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 302010-01-28 - RobLambert

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Changed:
<
<

Introduction

>
>

Introduction

 The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
Changed:
<
<

Slides

>
>

Slides

 This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.

Warning: This tutorial refers to DaVinci version v30r2 or later.

Changed:
<
<

LoKi cuts

We will use LoKiHybridFilters to apply cuts. They are python objects hiding some C++ code behind them. You can play with them in options as in python. Try for instance the following in a python shell:
>
>

Prerequisites

This tutorial requires you to have done DaVinciTutorial0, DaVinciTutorial0p5 and all steps leading up to that. At this stage you should have an options file and Ganga job working with DaVinci.

At this stage you will need to know quite a bit more about python, including what a python module is, how you create and import them, and the nature of the PYTHONPATH.

1 LoKi

Our CombineParticles framework uses the amazing flexibility of LoKi. If you want to know more you should follow the LoKiTutorial .

However, this is not a prerequisite.

1.1 LoKi cuts

We will use LoKiHybridFilters to apply cuts. They are python objects hiding some C++ code behind them. You can play with them in options as in python. Try for instance the following, outside ganga for the moment:
SetupProject DaVinci
python -i
 %SYNTAX{ syntax="python"}%from math import sqrt from LoKiPhys.decorators import * from LoKiCore.functions import monitor
Line: 32 to 47
 from LoKiCore.doxygenurl import browse browse(PT)%ENDSYNTAX%
Changed:
<
<

Particle Selection framework

>
>

2 Particle Selection framework

We have a powerful python module-based selection framework. This is the recommended way of constructing particles. See, for example, the options files in $DAVINCIROOT/options for more examples.

Firstly we will use the GaudiAlgorithm CombineParticles to create our resonances, then we will use the framework to combine all these into a sequence. From Following DaVinciTutorial0 you will have a job which runs inside Ganga. You should copy that options file

 We will be coding the Phi, Jpsi and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this: %SYNTAX{syntax="python"}% from DaVinci4 import Bs2JpsiPhi
Line: 40 to 62
 dir(Bs2JpsiPhi) %ENDSYNTAX%
Changed:
<
<

Make a Bs2PsiPhi python module

>
>

2.1 Make a Bs2PsiPhi python module

 We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in python/DaVinci4 gets put in an area that is on that path once the package is built.
Changed:
<
<
  • Remove you own TutorialAlgorithm and open empty file python/DaVinci4/Bs2JpsiPhi.py
>
>
  • Open empty file python/DaVinci4/Bs2JpsiPhi.py
 
  • Add some necessary modules
    <!-- SyntaxHighlightingPlugin -->
import GaudiKernel.SystemOfUnits as Units
from Gaudi.Configuration import *
<!-- end SyntaxHighlightingPlugin -->
  • Build the package and check the module is in the InstallArea (which is in the $PYTHONPATH)
Deleted:
<
<
cd cmt
cmt make
ls ../../../InstallArea/python/DaVinci4/
echo $PYTHONPATH

Make a loose J/psi Selection

 
Added:
>
>
In your ganga session
<!-- SyntaxHighlightingPlugin -->
t.application.make()
env=t.application.getenv()
env['PYTHONPATH']
<!-- end SyntaxHighlightingPlugin -->

2.2 Make a loose J/psi Selection

Add this into your pyton file

 %SYNTAX{ syntax="python"}% # make a Selection out of a data-on-demand location from PhysSelPython.Wrappers import DataOnDemand
Line: 64 to 89
 # Define the Decay Descriptor _jpsi2mumu.DecayDescriptor = "J/psi(1S) -> mu+ mu-" # mandatory %ENDSYNTAX%
Added:
>
>

2.3 CombineParticles

CombineParticles is a GaudiAlgorithm seemlessly integrating into LoKi, this algorithm creates a mother particle with the correct four-vector and endvertex to have decayed into the particles we saw in the detector.

Unfortunately we have a lot of 'background' events, particles from the primary vertex or from decays of other particles, or perhaps particles that are not really muons at all. Hence we 'cut' away at the background to see the signal.

 
  • There are three cuts applied in CombineParticles
    1. DaughtersCuts : On the incoming daughter particles. Note the double plural.
    2. CombinationCut : Once a combination has been made according to the decay descriptor but before the vertex fit. This cut is applied to the array of particles to be used in the vertex fit.
Line: 74 to 106
 
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
  • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>

2.4 Add into your selection

 
  • Now we make a Selection object for the Jpsi. It only needs the standard loose muons, so we pass it a list with _muons as only entry for RequiredSelections.%SYNTAX{ syntax="python"}%
from PhysSelPython.Wrappers import Selection LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu",
Line: 82 to 117
  Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python:
<!-- SyntaxHighlightingPlugin -->
from DaVinci4.Bs2JpsiPhiEx4 import LooseJpsi2MuMu 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<

Filter further to make a tighter J/Psi Selection

>
>

3 Creating the full sequence

3.1 Filter further to make a tighter J/Psi Selection

 We can apply harder cuts using a FilterDesktop. %SYNTAX{ syntax="python"}% # make a FilterDesktop
Line: 97 to 134
 This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its InputLocations. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
Changed:
<
<

Make the Phi Selection

>
>

3.2 Make the Phi Selection

 Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons, so make a DataOnDemand instance to pass to Phi2KK as RequiredSelections.
Changed:
<
<

Make the Bs Selection

>
>

3.3 Make the Bs Selection

 The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV. %SYNTAX{ syntax="python"}% _bs2jpsiphi = CombineParticles("Bs2JpsiPhi",
Line: 129 to 166
  Make sure the Selection definition comes after the complete definition of all algorithms that go inside.
Changed:
<
<

Make a Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

>
>

3.4 Make a Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

 Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection.
<!-- SyntaxHighlightingPlugin -->
from PhysSelPython.Wrappers import SelectionSequence
SeqBs2JpsiPhi = SelectionSequence('SeqB2jJpsiPhi', TopSelection = Bs2JpsiPhi)
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>

4 Run!

 
Changed:
<
<
That's all!
>
>

4.1 Build!

In your ganga session
<!-- SyntaxHighlightingPlugin -->
t.application.make()
<!-- end SyntaxHighlightingPlugin -->

4.2 Run

Add into your options file:

<!-- SyntaxHighlightingPlugin -->
from DaVinci4.Bs2JpsiPhiEx4 import SeqBs2JpsiPhi as theSequence
MySelection = theSequence.sequence()
DaVinci().UserAlgorithms = [MySelection]
<!-- end SyntaxHighlightingPlugin -->
 
Changed:
<
<

Run

Look at the examples in the Particle Selections examples to add the sequence to DaVinci() in order to run the selection
  • Run it!
>
>
Then submit a new job in Ganga.
 

Help!

The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.

What next?

Added:
>
>
 

Revision 292010-01-28 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 157 to 157
 -- JuanPalacios - 2009-10-02

META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p2"
Changed:
<
<
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p1"
>
>
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p2"
 
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v504r5"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 282010-01-28 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 8 to 8
 

Slides

This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.
Changed:
<
<
Warning: This tutorial refers to DaVinci version v24r3 or later.
>
>
Warning: This tutorial refers to DaVinci version v30r2 or later.
 

LoKi cuts

We will use LoKiHybridFilters to apply cuts. They are python objects hiding some C++ code behind them. You can play with them in options as in python. Try for instance the following in a python shell:
Line: 47 to 47
 import SystemOfUnits as Units from Gaudi.Configuration import *%ENDSYNTAX%
  • Build the package and check the module is in the InstallArea (which is in the $PYTHONPATH)
Changed:
<
<
>
>
 cd cmt cmt make ls ../../../InstallArea/python/DaVinci4/
Line: 129 to 129
  Make sure the Selection definition comes after the complete definition of all algorithms that go inside.
Changed:
<
<

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

>
>

Make a Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

 Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection. %SYNTAX{syntax="python"}% from PhysSelPython.Wrappers import SelectionSequence
Line: 147 to 147
  The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.
Changed:
<
<

Go to DaVinciTutorial5

>
>

What next?

  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009 -- JuanPalacios - 2009-10-02
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v504r5"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 272010-01-26 - NicolaChiapolini

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 71 to 71
 All the cuts that require the position of the vertex must be applied in MotherCut, while the others, like mass, can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in CombinationCut and a harder in MotherCut. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in CombinationCut it's just the sum of the momenta of the daughters at their first measurement.
  • The cuts that can be applied in the filters are the LoKiHybridFilters.
  • Let's ignore cuts on daughters for the time being.
Changed:
<
<
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
>
>
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
 
  • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
Changed:
<
<
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
_jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
 
  • Now we make a Selection object for the Jpsi. It only needs the standard loose muons, so we pass it a list with _muons as only entry for RequiredSelections.%SYNTAX{ syntax="python"}%
from PhysSelPython.Wrappers import Selection LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu",
Line: 124 to 124
 # now make the Selection Bs2JpsiPhi = Selection("SelBs2JpsiPhi", Algorithm = _bs2jpsiphi,
Changed:
<
<
RequiredSelections = [ JpsiPsi2MuMu, Phi2KK ])
>
>
RequiredSelections = [ Jpsi2MuMu, Phi2KK ])
 %ENDSYNTAX%
Changed:
<
<
Make sure the Selection definition comes after the definition of all algorithms that go inside.
>
>
Make sure the Selection definition comes after the complete definition of all algorithms that go inside.
 

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection.

Revision 262010-01-25 - PatrickSKoppenburg

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 127 to 127
  RequiredSelections = [ JpsiPsi2MuMu, Phi2KK ]) %ENDSYNTAX%
Added:
>
>
Make sure the Selection definition comes after the definition of all algorithms that go inside.
 

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection. %SYNTAX{syntax="python"}%

Revision 252010-01-06 - OlivierLeroy

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 79 to 79
 LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu", Algorithm = _jpsi2mumu, RequiredSelections = [_muons])%ENDSYNTAX%
Changed:
<
<
Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, baccause now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
>
>
Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, because now we can use the Jpsi2MuMu selection from python: %SYNTAX{syntax="python"}%
 from Bs2JpsiPhiEx4 import LooseJpsi2MuMu %ENDSYNTAX%

Filter further to make a tighter J/Psi Selection

Revision 242009-11-24 - AnatolySolomin

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 138 to 138
  That's all!

Run

Changed:
<
<
Look at the examples in the Particle Selections examples to add the sequence to DaVinci() in order to run the selection
>
>
Look at the examples in the Particle Selections examples to add the sequence to DaVinci() in order to run the selection
 
  • Run it!

Help!

Changed:
<
<
The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.
>
>
The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.
 

Go to DaVinciTutorial5

Revision 232009-10-20 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Line: 131 to 131
 Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained in each Selection. %SYNTAX{syntax="python"}% from PhysSelPython.Wrappers import SelectionSequence
Changed:
<
<
SeqBs2JpsiPhi = SelectionSequence(TopSelection = Bs2JpsiPhi)
>
>
SeqBs2JpsiPhi = SelectionSequence('SeqB2jJpsiPhi', TopSelection = Bs2JpsiPhi)
 %ENDSYNTAX%

Revision 212009-10-05 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

Added:
>
>
 

Introduction

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
Deleted:
<
<
 

Slides

This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.
Line: 33 to 32
 from LoKiCore.doxygenurl import browse browse(PT)%ENDSYNTAX%
Changed:
<
<
--++ Particle Selection framework
>
>

Particle Selection framework

 We will be coding the Phi, Jpsi and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this: %SYNTAX{syntax="python"}% from DaVinci4 import Bs2JpsiPhi
Line: 41 to 40
 dir(Bs2JpsiPhi) %ENDSYNTAX%
Added:
>
>

Make a Bs2PsiPhi python module

We need to create a python module that will end up in the $PYTHONPATH. This package is set up such that anything in python/DaVinci4 gets put in an area that is on that path once the package is built.
  • Remove you own TutorialAlgorithm and open empty file python/DaVinci4/Bs2JpsiPhi.py
  • Add some necessary modules
    <!-- SyntaxHighlightingPlugin -->
import GaudiKernel.SystemOfUnits as Units
from Gaudi.Configuration import *
<!-- end SyntaxHighlightingPlugin -->
  • Build the package and check the module is in the InstallArea (which is in the $PYTHONPATH)
cd cmt cmt make ls ../../../InstallArea/python/DaVinci4/ echo $PYTHONPATH

Make a loose J/psi Selection

 
Deleted:
<
<

Make a J/psi Selection

  • Remove you own TutorialAlgorithm and replace it by an instance of CombineParticles
 %SYNTAX{ syntax="python"}% # make a Selection out of a data-on-demand location
Changed:
<
<
from PhysSelPython import DataOnDemand _muons = DataOnDemand('_stdLooseMuons', Location = 'Phys/StdLoosemuons')
>
>
from PhysSelPython.Wrappers import DataOnDemand _muons = DataOnDemand('_stdLooseMuons', Location = 'Phys/StdLooseMuons')
 from Configurables import CombineParticles _jpsi2mumu = CombineParticles("Jpsi2MuMu") # Define the Decay Descriptor
Line: 73 to 82
  Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, baccause now we can use the Jpsi2MuMu selection from python:
<!-- SyntaxHighlightingPlugin -->
from DaVinci4.Bs2JpsiPhiEx4 import LooseJpsi2MuMu 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<

Filter a bit further

>
>

Filter further to make a tighter J/Psi Selection

 We can apply harder cuts using a FilterDesktop. %SYNTAX{ syntax="python"}% # make a FilterDesktop from Configurables import FilterDesktop
Changed:
<
<
_jpsifilter = FilterDesktop("_JsiFilter",
>
>
_jpsifilter = FilterDesktop("_JpsiFilter",
  Code = "(PT>1*GeV) & (P>3*GeV)") #make a Selection out of it Jpsi2MuMu = Selection("SelJpsi2MuMu",
Changed:
<
<
Algorithm = _jspifilter,
>
>
Algorithm = _jpsifilter,
  RequiredSelections = [LooseJpsi2MuMu]) %ENDSYNTAX% This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its InputLocations. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
Changed:
<
<

Make the Phi Selection

>
>

Make the Phi Selection

 Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons, so make a DataOnDemand instance to pass to Phi2KK as RequiredSelections.
Changed:
<
<

Make the Bs Selection

>
>

Make the Bs Selection

 The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV. %SYNTAX{ syntax="python"}% _bs2jpsiphi = CombineParticles("Bs2JpsiPhi",
Line: 118 to 127
  RequiredSelections = [ JpsiPsi2MuMu, Phi2KK ]) %ENDSYNTAX%
Changed:
<
<

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

>
>

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

 Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained ineach Selection. %SYNTAX{syntax="python"}% from PhysSelPython.Wrappers import SelectionSequence

Revision 202009-10-02 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"
Changed:
<
<

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
>
>

DaVinci Tutorial 4

Introduction

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. We will use Configurables and the Particle Selection Framework to write re-usable J/psi, Phi and Bs Selections and obtain a algorithm sequence that can be passed on to DaVinci to run the selection.
 

Slides

This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.
Changed:
<
<
Warning: This tutorial refers to DaVinci version v22r0 or later.
>
>
Warning: This tutorial refers to DaVinci version v24r3 or later.
 

LoKi cuts

We will use LoKiHybridFilters to apply cuts. They are python objects hiding some C++ code behind them. You can play with them in options as in python. Try for instance the following in a python shell:
Line: 32 to 33
 from LoKiCore.doxygenurl import browse browse(PT)%ENDSYNTAX%
Changed:
<
<

Make a J/psi using CombineParticles

>
>
--++ Particle Selection framework We will be coding the Phi, Jpsi and Bs selections as self-contained Selection configurables within python modules. This means that, besides using them for this example, we will be able to use them to build other particles, to make (Misro)DSTs, even to bolt them seamlessly into the stripping. For this we will use the Particle Selection "Framework". We will be writing python modules, so your solution should be put in python/DaVinci4/Bs2JpsiPhi.py. This will define a python module, which you will be able to import like this:
<!-- SyntaxHighlightingPlugin -->
from DaVinci4 import Bs2JpsiPhi
help(Bs2JpsiPhi)
dir(Bs2JpsiPhi)
<!-- end SyntaxHighlightingPlugin -->

Make a J/psi Selection

 
  • Remove you own TutorialAlgorithm and replace it by an instance of CombineParticles
Deleted:
<
<
<!-- SyntaxHighlightingPlugin -->
from Configurables import CombineParticles
jpsi2mumu = CombineParticles("Jpsi2MuMu")
tutorialseq.Members += [ jpsi2mumu ]
jpsi2mumu.InputLocations = [ "StdLooseMuons" ] 
<!-- end SyntaxHighlightingPlugin -->
  • Define the Decay Descriptor
 %SYNTAX{ syntax="python"}%
Changed:
<
<
jpsi2mumu.DecayDescriptor = "J/psi(1S) -> mu+ mu-" # mandatory%ENDSYNTAX%
>
>
# make a Selection out of a data-on-demand location from PhysSelPython import DataOnDemand _muons = DataOnDemand('_stdLooseMuons', Location = 'Phys/StdLoosemuons') from Configurables import CombineParticles _jpsi2mumu = CombineParticles("Jpsi2MuMu") # Define the Decay Descriptor _jpsi2mumu.DecayDescriptor = "J/psi(1S) -> mu+ mu-" # mandatory %ENDSYNTAX%
 
  • There are three cuts applied in CombineParticles
    1. DaughtersCuts : On the incoming daughter particles. Note the double plural.
    2. CombinationCut : Once a combination has been made according to the decay descriptor but before the vertex fit. This cut is applied to the array of particles to be used in the vertex fit.
Line: 52 to 65
 
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
  • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
  • Now we make a Selection object for the Jpsi. It only needs the standard loose muons, so we pass it a list with _muons as only entry for RequiredSelections.
    <!-- SyntaxHighlightingPlugin -->
from PhysSelPython.Wrappers import Selection
LooseJpsi2MuMu = Selection("SelLooseJpsi2MuMu", 
                              Algorithm = _jpsi2mumu, 
                              RequiredSelections = [_muons])
<!-- end SyntaxHighlightingPlugin -->
Note that we do not need to specify any InputLocations for the CombineParticles. The Selection takes care of setting it from the RequiredSelections. With this we are already at the same level as with our C++ code for the J/psi! In fact, we are beyond that level, baccause now we can use the Jpsi2MuMu selection from python:
<!-- SyntaxHighlightingPlugin -->
from DaVinci4.Bs2JpsiPhiEx4 import LooseJpsi2MuMu 
<!-- end SyntaxHighlightingPlugin -->
 
Changed:
<
<
With this we are already at the same level as with our C++ code for the J/psi!

Filter a bit further using FilterDesktop

We can apply harder cuts in FilterDesktop.
<!-- SyntaxHighlightingPlugin -->
from Configurables import FilterDesktop
psifilter = FilterDesktop("PsiFilter")
psifilter.InputLocations = [ "Jpsi2MuMu" ]
psifilter.Code = "(PT>1*GeV) & (P>3*GeV)"
tutorialseq.Members += [ psifilter ]
<!-- end SyntaxHighlightingPlugin -->
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done in CombineParticles above already.
>
>

Filter a bit further

We can apply harder cuts using a FilterDesktop.
<!-- SyntaxHighlightingPlugin -->
# make a FilterDesktop
from Configurables import FilterDesktop
_jpsifilter = FilterDesktop("_JsiFilter",
                         Code = "(PT>1*GeV) & (P>3*GeV)")
#make a Selection out of it
Jpsi2MuMu = Selection("SelJpsi2MuMu",
                        Algorithm = _jspifilter,
                        RequiredSelections = [LooseJpsi2MuMu])
<!-- end SyntaxHighlightingPlugin -->
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done directly in the CombineParticles above. Again, note that Jpsi2MuMu doesn't need to explicitly know its InputLocations. It only needs access to LooseJpsi2MuMu, which could've even been in a different module in a different package.
 
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
Changed:
<
<

Make the Phi

Now make another CombineParticles instance for "phi(1020) -> K+ K-" with a 50 MeV mass cut and a vertex chi2 less than 100. The input should be StdLooseKaons.
>
>

Make the Phi Selection

Now make another Selection called Phi2KK, using a CombineParticles instance for "phi(1020) -> K+ K-". Apply a 50 MeV mass cut and a vertex chi2 less than 100. The input should come from StdLooseKaons, so make a DataOnDemand instance to pass to Phi2KK as RequiredSelections.
 
Changed:
<
<

Make the Bs

>
>

Make the Bs Selection

 The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
bs2jpsiphi = CombineParticles("Bs2JpsiPhi")
bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"
bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV"
bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
bs2jpsiphi.InputLocations = [ "PsiFilter", "Phi2KK" ]
<!-- end SyntaxHighlightingPlugin -->
  • Feel free to add more cuts as you like.
  • Now let's add some plots
%SYNTAX{ syntax="python"}%from Configurables import LoKi__Hybrid__PlotTool as PlotTool bs2jpsiphi.HistoProduce = True bs2jpsiphi.addTool( PlotTool("DaughtersPlots") ) bs2jpsiphi.DaughtersPlots.Histos = { "P/1000" : ('momentum',0,100) ,
>
>
%SYNTAX{ syntax="python"}% _bs2jpsiphi = CombineParticles("Bs2JpsiPhi", DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)", CombinationCut = "ADAMASS('B_s0')<2*GeV", MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ) # feel free to add more cuts _bs2jpsiPhi. .... # Now let's add some plots from Configurables import LoKi__Hybrid__PlotTool as PlotTool _bs2jpsiphi.HistoProduce = True _bs2jpsiphi.addTool( PlotTool("DaughtersPlots") ) # Note that it's using the same functors as above. Hence the same syntax. _bs2jpsiphi.DaughtersPlots.Histos = { "P/1000" : ('momentum',0,100) ,
  "PT/1000" : ('pt_%1%',0,5,500) , "M" : ('mass in MeV_%1%_%2%_%3%',0.8*Units.GeV,4*Units.GeV) }
Changed:
<
<
bs2jpsiphi.addTool( PlotTool("MotherPlots") ) bs2jpsiphi.MotherPlots.Histos = { "P/1000" : ('momentum',0,100) ,
>
>
_bs2jpsiphi.addTool( PlotTool("MotherPlots") ) _bs2jpsiphi.MotherPlots.Histos = { "P/1000" : ('momentum',0,100) ,
  "PT/1000" : ('pt_%1%',0,5,500) ,
Changed:
<
<
"M" : ('mass in MeV_%1%_%2%_%3%',4*Units.GeV,6*Units.GeV) }%ENDSYNTAX% Note that it's using the same functors as above. Hence the same syntax.
>
>
"M" : ('mass in MeV_%1%_%2%_%3%',4*Units.GeV,6*Units.GeV) } # now make the Selection Bs2JpsiPhi = Selection("SelBs2JpsiPhi", Algorithm = _bs2jpsiphi, RequiredSelections = [ JpsiPsi2MuMu, Phi2KK ]) %ENDSYNTAX%

Make a =Bs -> Jpsi(mumu) Phi (KK) SelectionSequence

Now that we have the Jpsi, Phi and Bs Selections (plus Selections for the data-on-demand particles) we can create a SelectionSequence for the Bs -> Jpsi Phi selection. It is remarkable simple, since all the necessary information is contained ineach Selection.
<!-- SyntaxHighlightingPlugin -->
from PhysSelPython.Wrappers import SelectionSequence
SeqBs2JpsiPhi = SelectionSequence(TopSelection = Bs2JpsiPhi)
<!-- end SyntaxHighlightingPlugin -->
  That's all!

Run

Changed:
<
<
>
>
Look at the examples in the Particle Selections examples to add the sequence to DaVinci() in order to run the selection
 
  • Run it!

Help!

Changed:
<
<
The solution is given in solutions/DaVinci4.
>
>
The solution is given in python/DaVinci4/python for the module. and solutions/DaVinci4 for the script to run the selection.
 

Go to DaVinciTutorial5

-- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009

Added:
>
>
-- JuanPalacios - 2009-10-02
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 192009-06-09 - RobLambert

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 35 to 35
 

Make a J/psi using CombineParticles

  • Remove you own TutorialAlgorithm and replace it by an instance of CombineParticles
Changed:
<
<
%SYNTAX{ syntax="python"}%from Configurables import CombineParticles, PhysDesktop
>
>
%SYNTAX{ syntax="python"}%from Configurables import CombineParticles
 jpsi2mumu = CombineParticles("Jpsi2MuMu") tutorialseq.Members += [ jpsi2mumu ]
Changed:
<
<
jpsi2mumu.addTool( PhysDesktop ) jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ] %ENDSYNTAX%
>
>
jpsi2mumu.InputLocations = [ "StdLooseMuons" ] %ENDSYNTAX%
 
  • Define the Decay Descriptor
<!-- SyntaxHighlightingPlugin -->
jpsi2mumu.DecayDescriptor = "J/psi(1S) -> mu+ mu-" # mandatory
<!-- end SyntaxHighlightingPlugin -->
Line: 60 to 59
 We can apply harder cuts in FilterDesktop. %SYNTAX{ syntax="python"}%from Configurables import FilterDesktop psifilter = FilterDesktop("PsiFilter")
Changed:
<
<
psifilter.addTool( PhysDesktop ) psifilter.PhysDesktop.InputLocations = [ "Jpsi2MuMu" ]
>
>
psifilter.InputLocations = [ "Jpsi2MuMu" ]
 psifilter.Code = "(PT>1*GeV) & (P>3*GeV)" tutorialseq.Members += [ psifilter ]%ENDSYNTAX% This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done in CombineParticles above already.
Line: 76 to 74
 bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)" bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV" bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
Changed:
<
<
bs2jpsiphi.addTool( PhysDesktop ) bs2jpsiphi.PhysDesktop.InputLocations = [ "PsiFilter", "Phi2KK" ]
>
>
bs2jpsiphi.InputLocations = [ "PsiFilter", "Phi2KK" ]
 %ENDSYNTAX%
  • Feel free to add more cuts as you like.
  • Now let's add some plots

Revision 182009-03-11 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 38 to 38
 %SYNTAX{ syntax="python"}%from Configurables import CombineParticles, PhysDesktop jpsi2mumu = CombineParticles("Jpsi2MuMu") tutorialseq.Members += [ jpsi2mumu ]
Changed:
<
<
jpsi2mumu.addTool( PhysDesktop() )
>
>
jpsi2mumu.addTool( PhysDesktop )
 jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ] %ENDSYNTAX%
  • Define the Decay Descriptor
%SYNTAX{ syntax="python"}%
Line: 60 to 60
 We can apply harder cuts in FilterDesktop. %SYNTAX{ syntax="python"}%from Configurables import FilterDesktop psifilter = FilterDesktop("PsiFilter")
Changed:
<
<
psifilter.addTool( PhysDesktop() )
>
>
psifilter.addTool( PhysDesktop )
 psifilter.PhysDesktop.InputLocations = [ "Jpsi2MuMu" ] psifilter.Code = "(PT>1*GeV) & (P>3*GeV)" tutorialseq.Members += [ psifilter ]%ENDSYNTAX%
Line: 76 to 76
 bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)" bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV" bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
Changed:
<
<
bs2jpsiphi.addTool( PhysDesktop() )
>
>
bs2jpsiphi.addTool( PhysDesktop )
 bs2jpsiphi.PhysDesktop.InputLocations = [ "PsiFilter", "Phi2KK" ] %ENDSYNTAX%
  • Feel free to add more cuts as you like.

Revision 172009-01-15 - ThomasLatham

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 81 to 81
 %ENDSYNTAX%
  • Feel free to add more cuts as you like.
  • Now let's add some plots
Changed:
<
<
%SYNTAX{ syntax="python"}%bs2jpsiphi.HistoProduce = True
>
>
%SYNTAX{ syntax="python"}%from Configurables import LoKi__Hybrid__PlotTool as PlotTool bs2jpsiphi.HistoProduce = True
 bs2jpsiphi.addTool( PlotTool("DaughtersPlots") ) bs2jpsiphi.DaughtersPlots.Histos = { "P/1000" : ('momentum',0,100) , "PT/1000" : ('pt_%1%',0,5,500) ,

Revision 162009-01-08 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 10 to 10
  Warning: This tutorial refers to DaVinci version v22r0 or later.
Added:
>
>

LoKi cuts

We will use LoKiHybridFilters to apply cuts. They are python objects hiding some C++ code behind them. You can play with them in options as in python. Try for instance the following in a python shell:
<!-- SyntaxHighlightingPlugin -->
from math import sqrt 
from LoKiPhys.decorators import *
from LoKiCore.functions import monitor
p = LHCb.Particle()
p.setParticleID( LHCb.ParticleID(11) )
m = p.momentum()
m.SetPx (   1000 )
m.SetPy (  -1000 )
m.SetPz (  10000 )
m.SetE  ( sqrt( m.P2() + 5000*5000 ) )
p.setMomentum ( m )
fun = PX+PY
print PX(p), PY(p) , fun(p)
fun2 = PX>750
print fun2(p)
fun3 = monitor(fun2)
print fun3(p)
from LoKiCore.doxygenurl import browse 
browse(PT)
<!-- end SyntaxHighlightingPlugin -->
 

Make a J/psi using CombineParticles

  • Remove you own TutorialAlgorithm and replace it by an instance of CombineParticles

Revision 152009-01-05 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial corresponds to the slides to be shown at the June 2008 Software week here.
>
>
This tutorial corresponds to the slides to be shown at the January LHCb-UK tutorial here.
 
Changed:
<
<
Warning: This tutorial refers to DaVinci version v20r2 or later.
>
>
Warning: This tutorial refers to DaVinci version v22r0 or later.
 
Changed:
<
<

Add a Bs maker

>
>

Make a J/psi using CombineParticles

 
Changed:
<
<
  • Add a CombineParticles instance to your sequence. Let's call it Bs2psiPhi.
  • Feed the PhysDesktop with your J/psi and Phi candidates.
  • Define the Decay Descriptor
    <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi = CombineParticles("Bs2JpsiPhi")
bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)" # mandatory
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Remove you own TutorialAlgorithm and replace it by an instance of CombineParticles
<!-- SyntaxHighlightingPlugin -->
from Configurables import CombineParticles, PhysDesktop
jpsi2mumu = CombineParticles("Jpsi2MuMu")
tutorialseq.Members += [ jpsi2mumu ]
jpsi2mumu.addTool( PhysDesktop() )
jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ] 
<!-- end SyntaxHighlightingPlugin -->
  • Define the Decay Descriptor
<!-- SyntaxHighlightingPlugin -->
jpsi2mumu.DecayDescriptor = "J/psi(1S) -> mu+ mu-" # mandatory
<!-- end SyntaxHighlightingPlugin -->
 
  • There are three cuts applied in CombineParticles
    1. DaughtersCuts : On the incoming daughter particles. Note the double plural.
    2. CombinationCut : Once a combination has been made according to the decay descriptor but before the vertex fit. This cut is applied to the array of particles to be used in the vertex fit.
Line: 23 to 28
 All the cuts that require the position of the vertex must be applied in MotherCut, while the others, like mass, can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in CombinationCut and a harder in MotherCut. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in CombinationCut it's just the sum of the momenta of the daughters at their first measurement.
  • The cuts that can be applied in the filters are the LoKiHybridFilters.
    • Let's ignore cuts on daughters for the time being.
Changed:
<
<
    • We want a mass cut on the J/psi Phi candidates. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV"
<!-- end SyntaxHighlightingPlugin -->
>
>
  • We want a mass cut on the J/psi candidates.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.CombinationCut = "ADAMASS('J/psi(1S)')<30*MeV"
<!-- end SyntaxHighlightingPlugin -->
 
      • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
Changed:
<
<
      • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2.
        <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
<!-- end SyntaxHighlightingPlugin -->
      • Note that we are not soing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
>
>
  • Let's also cut on the vertex chi2. This happens after the vertex fit and is therefore a Mother cut.
    <!-- SyntaxHighlightingPlugin -->
jpsi2mumu.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
<!-- end SyntaxHighlightingPlugin -->
  With this we are already at the same level as with our C++ code for the J/psi!
Changed:
<
<
  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. You'll need to use MINTREE.
  • Now let's add some plots%SYNTAX{ syntax="python"}%bs2jpsiphi.HistoProduce = True
>
>

Filter a bit further using FilterDesktop

We can apply harder cuts in FilterDesktop.
<!-- SyntaxHighlightingPlugin -->
from Configurables import FilterDesktop
psifilter = FilterDesktop("PsiFilter")
psifilter.addTool( PhysDesktop() )
psifilter.PhysDesktop.InputLocations = [ "Jpsi2MuMu" ]
psifilter.Code = "(PT>1*GeV) & (P>3*GeV)"
tutorialseq.Members += [ psifilter ]
<!-- end SyntaxHighlightingPlugin -->
This applies a momentum and transverse momentum cut on the J/psi. Of course that could have been done in CombineParticles above already.
  • Note that we are not doing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.

Make the Phi

Now make another CombineParticles instance for "phi(1020) -> K+ K-" with a 50 MeV mass cut and a vertex chi2 less than 100. The input should be StdLooseKaons.

Make the Bs

The last step is the Bs using the filtered J/psi and the Phi as input. A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2. We also want a mass cut, but let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV.
<!-- SyntaxHighlightingPlugin -->
bs2jpsiphi = CombineParticles("Bs2JpsiPhi")
bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"
bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV"
bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
bs2jpsiphi.addTool( PhysDesktop() )
bs2jpsiphi.PhysDesktop.InputLocations = [ "PsiFilter", "Phi2KK" ]
<!-- end SyntaxHighlightingPlugin -->
  • Feel free to add more cuts as you like.
  • Now let's add some plots
%SYNTAX{ syntax="python"}%bs2jpsiphi.HistoProduce = True
 bs2jpsiphi.addTool( PlotTool("DaughtersPlots") ) bs2jpsiphi.DaughtersPlots.Histos = { "P/1000" : ('momentum',0,100) , "PT/1000" : ('pt_%1%',0,5,500) ,
Line: 50 to 77
 

Help!

Changed:
<
<
The solution is given in solutions/DaVinci4. There are two versions:
  • DVTutorial_4.py starts from what you had previously.
  • DVTutorial_4b.py rewrites everything with instances of CombineParticles.
>
>
The solution is given in solutions/DaVinci4.
 

Go to DaVinciTutorial5

-- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008

Added:
>
>
-- PatrickKoppenburg - 05 Jan 2009
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 142008-12-23 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 60 to 60
 -- PatrickKoppenburg - 13 Jun 2008

META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
Added:
>
>
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 132008-11-26 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 8 to 8
 

Slides

This tutorial corresponds to the slides to be shown at the June 2008 Software week here.
Changed:
<
<
Warning: This tutorial refers to DaVinci version v19r12 or later.
>
>
Warning: This tutorial refers to DaVinci version v20r2 or later.
 

Add a Bs maker

Revision 122008-06-13 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 54 to 54
 
  • DVTutorial_4.py starts from what you had previously.
  • DVTutorial_4b.py rewrites everything with instances of CombineParticles.
Added:
>
>

Go to DaVinciTutorial5

 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008

Revision 112008-06-13 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial corresponds to the slides to be shown at March 2008 Software week here and the April 2008 LHCb-UK tutorial here.
>
>
This tutorial corresponds to the slides to be shown at the June 2008 Software week here.
 
Changed:
<
<
Warning: This tutorial refers to DaVinci version v19r12 or later. The syntax has changed as compared to v19r11 which was used for the slides above.
>
>
Warning: This tutorial refers to DaVinci version v19r12 or later.
 

Add a Bs maker

  • Add a CombineParticles instance to your sequence. Let's call it Bs2psiPhi.
  • Feed the PhysDesktop with your J/psi and Phi candidates.
Changed:
<
<
  • Define the Decay Descriptor
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Define the Decay Descriptor
    <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi = CombineParticles("Bs2JpsiPhi")
bs2jpsiphi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)" # mandatory
<!-- end SyntaxHighlightingPlugin -->
 
  • There are three cuts applied in CombineParticles
    1. DaughtersCuts : On the incoming daughter particles. Note the double plural.
    2. CombinationCut : Once a combination has been made according to the decay descriptor but before the vertex fit. This cut is applied to the array of particles to be used in the vertex fit.
    3. MotherCut : On the outcoming Mother, after the vertex fit.
All the cuts that require the position of the vertex must be applied in MotherCut, while the others, like mass, can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in CombinationCut and a harder in MotherCut. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in CombinationCut it's just the sum of the momenta of the daughters at their first measurement.
Changed:
<
<
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DaughtersCuts = { "K+" : "(MIPCHI2DV(PRIMARY)>9)",
                             "mu-" : "(PT>1*GeV)" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note that 'K+' refers to both K+ and K- by default.
      • Also note that this is not C++. Thus the & instead of the &&.
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.CombinationCut= "(ADAMASS('B_s0')<2*GeV) & (APT>1*GeV)" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note the difference between PT used above and APT used here. The leading A refers to the array of particles. The same applies to ADAMASS, which is the array version of ADMASS. See LoKiHybridFilters for a complete list.
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
>
>
    • Let's ignore cuts on daughters for the time being.
    • We want a mass cut on the J/psi Phi candidates. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi.CombinationCut = "ADAMASS('B_s0')<2*GeV"
<!-- end SyntaxHighlightingPlugin -->
      • Note that here we use functors for an array of particles. Usually there's an "A" in the name to remind you about this. ADAMASS is the array version of ADMASS. See LoKiHybridFilters for a complete list.
      • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2.
        <!-- SyntaxHighlightingPlugin -->
bs2jpsiphi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)"
<!-- end SyntaxHighlightingPlugin -->
      • Note that we are not soing logical operations but binary additions. Hence use & and |, not &&, ||, and, or.
  With this we are already at the same level as with our C++ code for the J/psi!

  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
Changed:
<
<
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. Remember how to do that?
  • Now let's add some plots%SYNTAX{ syntax="cpp"}%Bs2JpsiPhi.HistoProduce=true;
DaughtersPlots.Histos ={ "P/1000" : ('momentum',0,100) ,
>
>
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. You'll need to use MINTREE.
  • Now let's add some plots%SYNTAX{ syntax="python"}%bs2jpsiphi.HistoProduce = True
bs2jpsiphi.addTool( PlotTool("DaughtersPlots") ) bs2jpsiphi.DaughtersPlots.Histos = { "P/1000" : ('momentum',0,100) ,
  "PT/1000" : ('pt_%1%',0,5,500) ,
Changed:
<
<
"M" : ('mass in MeV_%1%_%2%_%3%',0.8*GeV,4*GeV) } ; MotherPlots.Histos = { "P/1000" : ('momentum',0,100) ,
>
>
"M" : ('mass in MeV_%1%_%2%_%3%',0.8*Units.GeV,4*Units.GeV) } bs2jpsiphi.addTool( PlotTool("MotherPlots") ) bs2jpsiphi.MotherPlots.Histos = { "P/1000" : ('momentum',0,100) ,
  "PT/1000" : ('pt_%1%',0,5,500) ,
Changed:
<
<
"M" : ('mass in MeV_%1%_%2%_%3%',4*GeV,6*GeV) } ; %ENDSYNTAX% Note that it's using the same functors as above. Hence the same syntax.
>
>
"M" : ('mass in MeV_%1%_%2%_%3%',4*Units.GeV,6*Units.GeV) }%ENDSYNTAX% Note that it's using the same functors as above. Hence the same syntax.
  That's all!
Line: 51 to 51
 

Help!

The solution is given in solutions/DaVinci4. There are two versions:

Changed:
<
<
  • DVTutorial_4.opts starts from what you had previously.
  • DVTutorial_4b.opts rewrites everything with instances of CombineParticles.
>
>
  • DVTutorial_4.py starts from what you had previously.
  • DVTutorial_4b.py rewrites everything with instances of CombineParticles.
  -- PatrickKoppenburg - 01 Oct 2007
Added:
>
>
-- PatrickKoppenburg - 13 Jun 2008

META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"

Revision 102008-04-29 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 8 to 8
 

Slides

This tutorial corresponds to the slides to be shown at March 2008 Software week here and the April 2008 LHCb-UK tutorial here.
Added:
>
>
Warning: This tutorial refers to DaVinci version v19r12 or later. The syntax has changed as compared to v19r11 which was used for the slides above.
 

Add a Bs maker

  • Add a CombineParticles instance to your sequence. Let's call it Bs2psiPhi.
  • Feed the PhysDesktop with your J/psi and Phi candidates.
  • Define the Decay Descriptor
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
<!-- end SyntaxHighlightingPlugin -->
  • There are three cuts applied in CombineParticles
Changed:
<
<
    1. FILTER0 : On the incoming daughter particles.
    2. FILTER1 : Once a combination has been made according to the decay descriptor but before the vertex fit.
    3. FILTER2 : After the vertex fit.
All the cuts that require the position of the vertex must be applied in FILTER2, while the others can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in FILTER1 and a harder in FILTER2. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in FILTER1 it's just the sum of the momenta of the daughters at their first measurement.
>
>
    1. DaughtersCuts : On the incoming daughter particles. Note the double plural.
    2. CombinationCut : Once a combination has been made according to the decay descriptor but before the vertex fit. This cut is applied to the array of particles to be used in the vertex fit.
    3. MotherCut : On the outcoming Mother, after the vertex fit.
All the cuts that require the position of the vertex must be applied in MotherCut, while the others, like mass, can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in CombinationCut and a harder in MotherCut. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in CombinationCut it's just the sum of the momenta of the daughters at their first measurement.
 
Changed:
<
<
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') & (MIPCHI2DV(PRIMARY)>9)) | ((ABSID=='mu-') & (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note that (ABSID=='K+') applies an absolute value on both sides. (ABSID=='K+'), (ABSID=='K-'), (ABSID==321) and (ABSID==-321) are equivalent, although the last may seem quite strange.
>
>
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DaughtersCuts = { "K+" : "(MIPCHI2DV(PRIMARY)>9)",
                             "mu-" : "(PT>1*GeV)" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note that 'K+' refers to both K+ and K- by default.
 
      • Also note that this is not C++. Thus the & instead of the &&.
Changed:
<
<
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER1.Code = "ADMASS('B_s0')<2000" ;
<!-- end SyntaxHighlightingPlugin -->
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
  • Note that if you do not want to apply any cut at some level you must still configure it. Simply do
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "ALL" ;
<!-- end SyntaxHighlightingPlugin -->
>
>
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.CombinationCut= "(ADAMASS('B_s0')<2*GeV) & (APT>1*GeV)" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note the difference between PT used above and APT used here. The leading A refers to the array of particles. The same applies to ADAMASS, which is the array version of ADMASS. See LoKiHybridFilters for a complete list.
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a MotherCut cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherCut = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
  With this we are already at the same level as with our C++ code for the J/psi!

  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. Remember how to do that?
  • Now let's add some plots%SYNTAX{ syntax="cpp"}%Bs2JpsiPhi.HistoProduce=true;
Changed:
<
<
DaughterPlots.Variables={"M","P","Pt","IP"}; MotherPlots.Variables={"M", "P","Pt", "IP"}; %ENDSYNTAX% Unfortunately this is not yet the same syntax as the FILTER?, but we'll get there.
>
>
DaughtersPlots.Histos ={ "P/1000" : ('momentum',0,100) , "PT/1000" : ('pt_%1%',0,5,500) , "M" : ('mass in MeV_%1%_%2%_%3%',0.8*GeV,4*GeV) } ; MotherPlots.Histos = { "P/1000" : ('momentum',0,100) , "PT/1000" : ('pt_%1%',0,5,500) , "M" : ('mass in MeV_%1%_%2%_%3%',4*GeV,6*GeV) } ; %ENDSYNTAX% Note that it's using the same functors as above. Hence the same syntax.
  That's all!

Run

Revision 92008-04-10 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial corresponds to the slides to be shown at March 2008 Software week here.
>
>
This tutorial corresponds to the slides to be shown at March 2008 Software week here and the April 2008 LHCb-UK tutorial here.
 

Add a Bs maker

Revision 82008-04-08 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 18 to 18
 
    1. FILTER1 : Once a combination has been made according to the decay descriptor but before the vertex fit.
    2. FILTER2 : After the vertex fit.
All the cuts that require the position of the vertex must be applied in FILTER2, while the others can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in FILTER1 and a harder in FILTER2. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in FILTER1 it's just the sum of the momenta of the daughters at their first measurement.
Changed:
<
<
>
>
 
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') & (MIPCHI2DV(PRIMARY)>9)) | ((ABSID=='mu-') & (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
      • Note that (ABSID=='K+') applies an absolute value on both sides. (ABSID=='K+'), (ABSID=='K-'), (ABSID==321) and (ABSID==-321) are equivalent, although the last may seem quite strange.
      • Also note that this is not C++. Thus the & instead of the &&.

Revision 72008-03-17 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 24 to 24
 
      • Also note that this is not C++. Thus the & instead of the &&.
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER1.Code = "ADMASS('B_s0')<2000" ;
<!-- end SyntaxHighlightingPlugin -->
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • Note that if you do not want to apply any cut at some level you must still configure it. Simply do
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "TRUE" ;
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Note that if you do not want to apply any cut at some level you must still configure it. Simply do
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "ALL" ;
<!-- end SyntaxHighlightingPlugin -->
 

With this we are already at the same level as with our C++ code for the J/psi!

Revision 62008-03-13 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 20 to 20
 All the cuts that require the position of the vertex must be applied in FILTER2, while the others can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in FILTER1 and a harder in FILTER2. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in FILTER1 it's just the sum of the momenta of the daughters at their first measurement.
  • The cuts that can be applied in the filters are the LoKiParticleFunctions, plus some more to be added.
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') & (MIPCHI2DV(PRIMARY)>9)) | ((ABSID=='mu-') & (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
      • Be careful that ABSID requires you to know which is the kaon with the positive PID. You can also use the PDG code 321 if you like.
>
>
      • Note that (ABSID=='K+') applies an absolute value on both sides. (ABSID=='K+'), (ABSID=='K-'), (ABSID==321) and (ABSID==-321) are equivalent, although the last may seem quite strange.
 
      • Also note that this is not C++. Thus the & instead of the &&.
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER1.Code = "ADMASS('B_s0')<2000" ;
<!-- end SyntaxHighlightingPlugin -->
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->

Revision 52008-03-06 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 19 to 19
 
    1. FILTER2 : After the vertex fit.
All the cuts that require the position of the vertex must be applied in FILTER2, while the others can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in FILTER1 and a harder in FILTER2. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in FILTER1 it's just the sum of the momenta of the daughters at their first measurement.
Changed:
<
<
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') and (MIPCHI2DV(PRIMARY)>9)) or ((ABSID=='mu-') and (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
>
>
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') & (MIPCHI2DV(PRIMARY)>9)) | ((ABSID=='mu-') & (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
 
      • Be careful that ABSID requires you to know which is the kaon with the positive PID. You can also use the PDG code 321 if you like.
Changed:
<
<
      • Also note that this is python, not C++. Thus the and instead of the &&.
>
>
      • Also note that this is not C++. Thus the & instead of the &&.
 
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER1.Code = "ADMASS('B_s0')<2000" ;
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) and (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
>
>
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) & (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
 
  • Note that if you do not want to apply any cut at some level you must still configure it. Simply do
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "TRUE" ;
<!-- end SyntaxHighlightingPlugin -->

Revision 42008-03-04 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial corresponds to the slides last shown here. But they might be a little out of date.
>
>
This tutorial corresponds to the slides to be shown at March 2008 Software week here.
 

Add a Bs maker

Changed:
<
<
  • Add a MakeResonances instance to your sequence. Let's call it Bs2psiPhi.
>
>
  • Add a CombineParticles instance to your sequence. Let's call it Bs2psiPhi.
 
  • Feed the PhysDesktop with your J/psi and Phi candidates.
Changed:
<
<
  • Define the Decay Descriptor
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
<!-- end SyntaxHighlightingPlugin -->
  • Define the mass window.
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.Window = 100 * MeV;
<!-- end SyntaxHighlightingPlugin -->
  • Add a vertex cut for the Bs
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherFilter.Selections = { "B_s0 : VtxFilterCriterion"}; 
<!-- end SyntaxHighlightingPlugin -->
  • And configure it
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherFilter.VtxFilterCriterion.MaxChi2 = 30 ;
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Define the Decay Descriptor
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
<!-- end SyntaxHighlightingPlugin -->
  • There are three cuts applied in CombineParticles
    1. FILTER0 : On the incoming daughter particles.
    2. FILTER1 : Once a combination has been made according to the decay descriptor but before the vertex fit.
    3. FILTER2 : After the vertex fit.
All the cuts that require the position of the vertex must be applied in FILTER2, while the others can be applied earlier (saving CPU). Note that for long lived particles like Ks it pays off to apply a loose mass cut in FILTER1 and a harder in FILTER2. The reason is that the vertex fit does a propagation of the momenta through the detector. You thus get the momentum at the Ks vertex, while in FILTER1 it's just the sum of the momenta of the daughters at their first measurement.
  • The cuts that can be applied in the filters are the LoKiParticleFunctions, plus some more to be added.
    • Let's add a cut at IP/error>3 for kaons and Pt>1 GeV for muons:
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "((ABSID=='K+') and (MIPCHI2DV(PRIMARY)>9)) or ((ABSID=='mu-') and (PT>1000))" ;
<!-- end SyntaxHighlightingPlugin -->
      • Be careful that ABSID requires you to know which is the kaon with the positive PID. You can also use the PDG code 321 if you like.
      • Also note that this is python, not C++. Thus the and instead of the &&.
    • Now we want a mass cut. But let's make it wide so we get an idea of our background level. ± 500 MeV is typical in the HLT and stripping, but here let's make it 2 GeV
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER1.Code = "ADMASS('B_s0')<2000" ;
<!-- end SyntaxHighlightingPlugin -->
    • A good cut for a B is to require pointing to the PV. This needs the vertex and thus is a FILTER2 cut. Let's also cut on the vertex chi2.
      <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER2.Code = "(VFASPF(VCHI2/VDOF)<10) and (BPVIPCHI2()<100)" ;
<!-- end SyntaxHighlightingPlugin -->
  • Note that if you do not want to apply any cut at some level you must still configure it. Simply do
    <!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.FILTER0.Code = "TRUE" ;
<!-- end SyntaxHighlightingPlugin -->
  With this we are already at the same level as with our C++ code for the J/psi!

  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. Remember how to do that?
Changed:
<
<
  • Now let's add some plots
%SYNTAX{ syntax="cpp"}%Bs2JpsiPhi.HistoProduce=true;
>
>
  • Now let's add some plots%SYNTAX{ syntax="cpp"}%Bs2JpsiPhi.HistoProduce=true;
 DaughterPlots.Variables={"M","P","Pt","IP"};
Changed:
<
<
MotherPlots.Variables={"M", "P","Pt", "IP"}; DaughterPlotsPath= "Bin" ; MotherPlotsPath= "Bout" ; %ENDSYNTAX%
>
>
MotherPlots.Variables={"M", "P","Pt", "IP"}; %ENDSYNTAX% Unfortunately this is not yet the same syntax as the FILTER?, but we'll get there.
  That's all!

Run

Line: 42 to 45
  The solution is given in solutions/DaVinci4. There are two versions:
  • DVTutorial_4.opts starts from what you had previously.
Changed:
<
<
  • DVTutorial_4b.opts rewrites everything with instances of MakeResonances.
>
>
  • DVTutorial_4b.opts rewrites everything with instances of CombineParticles.
  -- PatrickKoppenburg - 01 Oct 2007 \ No newline at end of file

Revision 32007-11-19 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.

Added:
>
>

Slides

This tutorial corresponds to the slides last shown here. But they might be a little out of date.
 

Add a Bs maker

  • Add a MakeResonances instance to your sequence. Let's call it Bs2psiPhi.

Revision 22007-10-02 - unknown

Line: 1 to 1
 
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.
Line: 10 to 10
 
  • Add a MakeResonances instance to your sequence. Let's call it Bs2psiPhi.
  • Feed the PhysDesktop with your J/psi and Phi candidates.
  • Define the Decay Descriptor
Changed:
<
<
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
>
>
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
<!-- end SyntaxHighlightingPlugin -->
 
  • Define the mass window.
Changed:
<
<
Bs2JpsiPhi.Window = 100 * MeV;
>
>
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.Window = 100 * MeV;
<!-- end SyntaxHighlightingPlugin -->
 
  • Add a vertex cut for the Bs
Changed:
<
<
Bs2JpsiPhi.MotherFilter.Selections = { "B_s0 : VtxFilterCriterion"}; 
>
>
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherFilter.Selections = { "B_s0 : VtxFilterCriterion"}; 
<!-- end SyntaxHighlightingPlugin -->
 
  • And configure it
Changed:
<
<
Bs2JpsiPhi.MotherFilter.VtxFilterCriterion.MaxChi2 = 30 ;
>
>
<!-- SyntaxHighlightingPlugin -->
Bs2JpsiPhi.MotherFilter.VtxFilterCriterion.MaxChi2 = 30 ;
<!-- end SyntaxHighlightingPlugin -->
  With this we are already at the same level as with our C++ code for the J/psi!

  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. Remember how to do that?
  • Now let's add some plots
Changed:
<
<
|
Bs2JpsiPhi.HistoProduce=true; 

>
>
%SYNTAX{ syntax="cpp"}%Bs2JpsiPhi.HistoProduce=true;
 DaughterPlots.Variables={"M","P","Pt","IP"}; MotherPlots.Variables={"M", "P","Pt", "IP"}; DaughterPlotsPath= "Bin" ;
Changed:
<
<
MotherPlotsPath= "Bout" ; |
>
>
MotherPlotsPath= "Bout" ; %ENDSYNTAX%
  That's all!

Revision 12007-10-01 - unknown

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="DaVinciTutorial"

DaVinci Tutorial 4

The purpose of this exercise is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Now that we have the J/psi and the Phi, let's do the Bs using options.

Add a Bs maker

  • Add a MakeResonances instance to your sequence. Let's call it Bs2psiPhi.
  • Feed the PhysDesktop with your J/psi and Phi candidates.
  • Define the Decay Descriptor
Bs2JpsiPhi.DecayDescriptor = "B_s0 -> phi(1020) J/psi(1S)"; 
  • Define the mass window.
Bs2JpsiPhi.Window = 100 * MeV;
  • Add a vertex cut for the Bs
Bs2JpsiPhi.MotherFilter.Selections = { "B_s0 : VtxFilterCriterion"}; 
  • And configure it
Bs2JpsiPhi.MotherFilter.VtxFilterCriterion.MaxChi2 = 30 ;

With this we are already at the same level as with our C++ code for the J/psi!

  • Now you can add an impact parameter cut (the Bs should be pointing to the PV!) and a flight distance cut.
  • You could also cut on the daughters. For instance: Cut on the IP of the kaons in the Phi. Remember how to do that?
  • Now let's add some plots
Bs2JpsiPhi.HistoProduce=true; 
Bs2JpsiPhi.DaughterPlots.Variables={"M","P","Pt","IP"}; 
Bs2JpsiPhi.MotherPlots.Variables={"M", "P","Pt", "IP"}; 
Bs2JpsiPhi.DaughterPlotsPath= "Bin" ; 
Bs2JpsiPhi.MotherPlotsPath= "Bout" ; 

That's all!

Run

  • Run it!

Help!

The solution is given in solutions/DaVinci4. There are two versions:

  • DVTutorial_4.opts starts from what you had previously.
  • DVTutorial_4b.opts rewrites everything with instances of MakeResonances.

-- PatrickKoppenburg - 01 Oct 2007

 
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