# Difference: DaVinciTutorial2 (26 vs. 27)

#### Revision 272013-09-30 - PatrickSKoppenburg

Line: 1 to 1

 META TOPICPARENT name="DaVinciTutorial"

# DaVinci Tutorial 2

Changed:
<
<
The purpose of these exercises is to allow you to write a complete though simple selection algorithms for a typical decay: Bs->J/psiPhi. Let's do the J/psi first. We start for the algorithm created in DaVinciTutorial1.
>
>
The purpose of these exercises is to allow you to write a complete though simple selection algorithms for a typical decay: Bs → J/ψφ. Let's do the J/ψ→μμ first. We start for the algorithm created in DaVinciTutorial1.

Line: 16 to 16
double m_jPsiMass ; ///< J/psi mass %ENDSYNTAX%
• It is mantatory to initialise everything in the constructor (in the .cpp file).
Changed:
<
<
%SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : DVAlgorithm( name, pSvcLocator )
>
>
%SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : DaVinciTupleAlgorithm( name, pSvcLocator )
, m_jPsiID(0) , m_jPsiMass(0.) {
Line: 40 to 40
%ENDSYNTAX% This will create the ParticleTable.txt file in the subdirectory param of the current directory, which lists all particles and their properties.
Changed:
<
<

>
>

## Make the J/ψ

• First separate positive and negative muons. This is best done using the DaVinci::filter functions. Add a new private method StatusCode makeJpsi(const LHCb::Particle::ConstVector&) ; and implement it:
%SYNTAX{ syntax="cpp"}%
Line: 66 to 66
%ENDSYNTAX% You probably also want to plot the mass before the cut, and maybe to print it out in debug() or verbose() level. imp and imm are the iterator on MuPlus and MuMinus
Changed:
<
<
• Now call the vertex fitter. It will return you a vertex and the J/psi Particle.
>
>
• Now call the vertex fitter. It will return you a vertex and the J/ψ Particle.
%SYNTAX{ syntax="cpp"}% LHCb::Vertex MuMuVertex; LHCb::Particle Jpsi( m_jPsiID ); StatusCode scFit = vertexFitter()->fit( *(*imp), *(*imm), MuMuVertex, Jpsi );
Line: 80 to 80

<!-- SyntaxHighlightingPlugin -->
if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue; // chi2 cut
<!-- end SyntaxHighlightingPlugin -->
But maybe you should fill a histogram with the chi2 first.
Changed:
<
<
• Decare the the J/psi as to be kept.
>
>
• Decare the the J/ψ as to be kept.

<!-- SyntaxHighlightingPlugin -->
this->markTree(&Jpsi);
setFilterPassed( true ); // Mandatory. Set to true if event is accepted
<!-- end SyntaxHighlightingPlugin -->
Warning: It does not save it yet.
Changed:
<
<
Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.
>
>
Since you have a J/ψ you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.
Now you have only to add this function into the execute method: %SYNTAX{ syntax="cpp"}%
Line: 104 to 104
# J/psi->mumu selection # jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");
Changed:
<
<
jpsi2mumu.InputLocations = [ "Phys/StdLooseMuons" ]
>
>
jpsi2mumu.InputLocations = [ "Phys/StdAllLooseMuons" ]
from SystemOfUnits import MeV jpsi2mumu.MassWindow = 30*MeV%ENDSYNTAX%
>
>

## Don't panic!

You'll see some of those:

<!-- SyntaxHighlightingPlugin -->
LHCb::ParticleID m_jPsiID ; ///< J/psi ID
Jpsi2MuMu                                                   WARNING TutorialAlgorithm:: Fit error StatusCode=FAILURE
Jpsi2MuMu                                                   WARNING TutorialAlgorithm:: Fit error StatusCode=FAILURE
Jpsi2MuMu                                                   WARNING TutorialAlgorithm:: Fit error StatusCode=FAILURE
<!-- end SyntaxHighlightingPlugin -->

That just means the vertex fit failed, which can happen.

## Help!

The solution is given in solutions/DaVinci2.
Line: 115 to 126
Try to write the macro that does the plots of the slides.

# Next

Changed:
<
<
• If you'd like to know how the same algorithm can select J/psi->mumu and phi->KK go to DaVinciTutorial3.
>
>
• If you'd like to know how the same algorithm can select J/ψ→μμ and φ(1020)→KK go to DaVinciTutorial3.

• If you'd like to use standard code to do the same thing go to DaVinciTutorial4.

-- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009 -- PatrickSKoppenburg - 16-Oct-2012

>
>
-- PatrickSKoppenburg - 30-Sep-2013

 META FILEATTACHMENT attachment="DiMuM.png" attr="" comment="" date="1350394581" name="DiMuM.png" path="DiMuM.png" size="16430" user="pkoppenb" version="1" attachment="DM.png" attr="" comment="" date="1350394581" name="DM.png" path="DM.png" size="16430" user="pkoppenb" version="1"