Difference: DaVinciTutorial2 (1 vs. 29)

Revision 292017-12-19 - EduardoRodrigues

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

DaVinci Tutorial 2

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: 35 to 35
  The list of official particle names and their properties is stored in a database. To dump the current list you can run in a new window: %SYNTAX{ syntax="sh"}%
Changed:
<
<
lb-run LHCb bash --norc dump_db_to_files.py -c sqlite_file:$SQLITEDBPATH/DDDB.db/DDDB -s /param/ParticleTable.txt -d ./ -v
>
>
lb-run DaVinci/latest dump_particle_properties | tee ParticleTable.txt
 %ENDSYNTAX%
Changed:
<
<
This will create the ParticleTable.txt file in the subdirectory param of the current directory, which lists all particles and their properties.
>
>
This will create the ParticleTable.txt file in the current directory, which lists all particles and their properties.
 

Make the J/ψ

Revision 282017-06-12 - JoelClosier

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

DaVinci Tutorial 2

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: 35 to 35
  The list of official particle names and their properties is stored in a database. To dump the current list you can run in a new window: %SYNTAX{ syntax="sh"}%
Changed:
<
<
SetupProject LHCb
>
>
lb-run LHCb bash --norc
 dump_db_to_files.py -c sqlite_file:$SQLITEDBPATH/DDDB.db/DDDB -s /param/ParticleTable.txt -d ./ -v %ENDSYNTAX% This will create the ParticleTable.txt file in the subdirectory param of the current directory, which lists all particles and their properties.

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/psi

>
>

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%
Added:
>
>
dont-panic.jpg

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

Added:
>
>
-- 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"
META FILEATTACHMENT attachment="DM.png" attr="" comment="" date="1350394581" name="DM.png" path="DM.png" size="16430" user="pkoppenb" version="1"
Added:
>
>
META FILEATTACHMENT attachment="dont-panic.jpg" attr="h" comment="" date="1380534553" name="dont-panic.jpg" path="dont-panic.jpg" size="57540" user="pkoppenb" version="1"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 262012-10-16 - PatrickSKoppenburg

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

DaVinci Tutorial 2

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.
Line: 121 to 121
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009
Added:
>
>
-- PatrickSKoppenburg - 16-Oct-2012
 
Added:
>
>
META FILEATTACHMENT attachment="DiMuM.png" attr="" comment="" date="1350394581" name="DiMuM.png" path="DiMuM.png" size="16430" user="pkoppenb" version="1"
META FILEATTACHMENT attachment="DM.png" attr="" comment="" date="1350394581" name="DM.png" path="DM.png" size="16430" user="pkoppenb" version="1"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 252011-07-04 - PatrickSKoppenburg

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

DaVinci Tutorial 2

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.
Line: 56 to 56
 size_t nMuons = DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)<0, MuMinus); if (nMuons>0) nMuons += DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)>0, MuPlus); %ENDSYNTAX%
Changed:
<
<
Assuming that the muons you got from the desktop are in a vector called muons.
>
>
Assuming that the muons you got from the TES are in a vector called muons.
 
  • Loop over the muons, you already know how. You need two nested for loop, one for positive muons, one for negative muons.

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 to the PhysDesktop.
%SYNTAX{ syntax="cpp"}% desktop()->keep( &Jpsi );
>
>
  • Decare the the J/psi as to be kept.
%SYNTAX{ syntax="cpp"}% this->markTree(&Jpsi);
 setFilterPassed( true ); // Mandatory. Set to true if event is accepted%ENDSYNTAX% Warning: It does not save it yet.

Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.

Deleted:
<
<
  • Save all J/psis. At the end of the method (outside the loop) you should ask the desktop to save it all.
<!-- SyntaxHighlightingPlugin -->
return desktop()->saveDesktop(); 
<!-- end SyntaxHighlightingPlugin -->
 Now you have only to add this function into the execute method: %SYNTAX{ syntax="cpp"}% sc = makeJpsi(muons);

Revision 242010-06-03 - unknown

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

DaVinci Tutorial 2

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.
Line: 54 to 54
 StatusCode sc = StatusCode::SUCCESS;

size_t nMuons = DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)<0, MuMinus);

Changed:
<
<
if (nMuons>0) nMuons += DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)>0,, MuPlus);
>
>
if (nMuons>0) nMuons += DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)>0, MuPlus);
 %ENDSYNTAX% Assuming that the muons you got from the desktop are in a vector called muons.

Revision 232010-05-27 - unknown

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

DaVinci Tutorial 2

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.
Line: 44 to 44
 
  • 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"}%
Added:
>
>
#include "Kernel/ParticleFilters.h" #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> ...

using namespace boost::lambda;

 LHCb::Particle::ConstVector MuPlus, MuMinus; StatusCode sc = StatusCode::SUCCESS;
Changed:
<
<
size_t nMu = DaVinci::filterNegative(muons, boost::lambda::bind(&LHCb::Particle::charge,_1)<0, MuMinus); if (nMu) nMu = DaVinci::filter(muons, boost::lambda::bind(&LHCb::Particle::charge,_1)<0,, MuPlus);
>
>
size_t nMuons = DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)<0, MuMinus); if (nMuons>0) nMuons += DaVinci::filter(muons, bind(&LHCb::Particle::charge,_1)>0,, MuPlus);
 %ENDSYNTAX% Assuming that the muons you got from the desktop are in a vector called muons.
Line: 101 to 107
 # J/psi->mumu selection # jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");
Changed:
<
<
jpsi2mumu.InputLocations = [ "StdLooseMuons" ]
>
>
jpsi2mumu.InputLocations = [ "Phys/StdLooseMuons" ]
 from SystemOfUnits import MeV jpsi2mumu.MassWindow = 30*MeV%ENDSYNTAX%

Revision 222010-05-27 - unknown

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

DaVinci Tutorial 2

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.
Line: 42 to 42
 

Make the J/psi

Changed:
<
<
  • First separate positive and negative muons. This is best done using the ParticleFilter tool. Add a new private method StatusCode makeJpsi(const LHCb::Particle::ConstVector&) ; and implement it:
%SYNTAX{ syntax="cpp"}% LHCb::Particle::ConstVector MuPlus, MuMinus;
>
>
  • 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"}% LHCb::Particle::ConstVector MuPlus, MuMinus;
 StatusCode sc = StatusCode::SUCCESS;
Changed:
<
<
sc = particleFilter()->filterNegative(muons, MuMinus); if (sc) sc = particleFilter()->filterPositive(muons, MuPlus);%ENDSYNTAX%
>
>
size_t nMu = DaVinci::filterNegative(muons, boost::lambda::bind(&LHCb::Particle::charge,_1)<0, MuMinus); if (nMu) nMu = DaVinci::filter(muons, boost::lambda::bind(&LHCb::Particle::charge,_1)<0,, MuPlus); %ENDSYNTAX%
 Assuming that the muons you got from the desktop are in a vector called muons.

  • Loop over the muons, you already know how. You need two nested for loop, one for positive muons, one for negative muons.

Revision 212010-04-15 - MoritzKarbach

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

DaVinci Tutorial 2

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.
Line: 31 to 31
 const LHCb::ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX% Now get the mass and the PID of the J/psi from the ParticleProperty and store these values in the private data members, for example:
<!-- SyntaxHighlightingPlugin -->
m_jPsiID = LHCb::ParticleID(Jpsi->pdgID()); 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
To find out the method you need to get the mass look at the doxygen documentation.
>
>
To find out the method you need to get the mass look at the doxygen documentation.
  The list of official particle names and their properties is stored in a database. To dump the current list you can run in a new window: %SYNTAX{ syntax="sh"}%

Revision 202009-11-16 - AdamWebber1

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

DaVinci Tutorial 2

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.
Line: 61 to 61
 
  • Now call the vertex fitter. It will return you a vertex and the J/psi Particle.
%SYNTAX{ syntax="cpp"}% LHCb::Vertex MuMuVertex; LHCb::Particle Jpsi( m_jPsiID );
Changed:
<
<
StatusCode scFit = vertexFitter()->fit( *(*imp), *(*imm), Jpsi, MuMuVertex );
>
>
StatusCode scFit = vertexFitter()->fit( *(*imp), *(*imm), MuMuVertex, Jpsi );
 if ( scFit ) { Warning("Fit error").ignore(); continue;

Revision 192009-11-10 - FlorianKruse

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

DaVinci Tutorial 2

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.
Line: 28 to 28
 
  • Of course, we want to get some real numbers in there. This happens in initialize()
%SYNTAX{ syntax="cpp"}% debug() << "==> Initialize" << endmsg;
Changed:
<
<
const LHCB::ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX%
>
>
const LHCb::ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX%
 Now get the mass and the PID of the J/psi from the ParticleProperty and store these values in the private data members, for example:
<!-- SyntaxHighlightingPlugin -->
m_jPsiID = LHCb::ParticleID(Jpsi->pdgID()); 
<!-- end SyntaxHighlightingPlugin -->
To find out the method you need to get the mass look at the doxygen documentation.

Revision 182009-06-18 - RuggeroTurra

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

DaVinci Tutorial 2

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.
Line: 44 to 44
 
  • First separate positive and negative muons. This is best done using the ParticleFilter tool. Add a new private method StatusCode makeJpsi(const LHCb::Particle::ConstVector&) ; and implement it:
%SYNTAX{ syntax="cpp"}% LHCb::Particle::ConstVector MuPlus, MuMinus;
Added:
>
>
StatusCode sc = StatusCode::SUCCESS;
 sc = particleFilter()->filterNegative(muons, MuMinus); if (sc) sc = particleFilter()->filterPositive(muons, MuPlus);%ENDSYNTAX% Assuming that the muons you got from the desktop are in a vector called muons.
Changed:
<
<
  • Loop over the muons, you already know how. You need two nested for loop, one for positive muons, one for negatiive muons.
>
>
  • Loop over the muons, you already know how. You need two nested for loop, one for positive muons, one for negative muons.
 
  • Cut on the dimuon mass before you make the vertex, as the latter takes much more CPU. Inside the loop:
<!-- SyntaxHighlightingPlugin -->
Gaudi::LorentzVector twoMu = (*imp)->momentum() + (*imm)->momentum();
if ( fabs(twoMu.M() - m_jPsiMass) > m_jPsiMassWin ) continue; // mass cuts
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
You probably also want to plot the mass before the cut, and maybe to print it out in debug() or verbose() level.
>
>
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
 
  • Now call the vertex fitter. It will return you a vertex and the J/psi Particle.
%SYNTAX{ syntax="cpp"}% LHCb::Vertex MuMuVertex;
Line: 71 to 73
 But maybe you should fill a histogram with the chi2 first.

  • Decare the the J/psi to the PhysDesktop.
Changed:
<
<
%SYNTAX{ syntax="cpp"}% desktop()->save( &Jpsi );
>
>
%SYNTAX{ syntax="cpp"}% desktop()->keep( &Jpsi );
 setFilterPassed( true ); // Mandatory. Set to true if event is accepted%ENDSYNTAX% Warning: It does not save it yet.

Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.

Changed:
<
<
  • Save all J/psis. At the end of the method you should ask the desktop to save it all.
>
>
  • Save all J/psis. At the end of the method (outside the loop) you should ask the desktop to save it all.
 
<!-- SyntaxHighlightingPlugin -->
return desktop()->saveDesktop(); 
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
Now you have only to add this function into the execute method:
<!-- SyntaxHighlightingPlugin -->
sc = makeJpsi(muons);
  if (!sc) return sc;
<!-- end SyntaxHighlightingPlugin -->
remember to delete the setFilterPassed(true) statement, because it is evaluate in the makeJpsi function.
 

Need some counters?

Counters are booked on-demand like plots. Just add at an appropriate place
<!-- SyntaxHighlightingPlugin -->
counter("J/psi's")++; 
<!-- end SyntaxHighlightingPlugin -->

Revision 172009-06-18 - RuggeroTurra

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

DaVinci Tutorial 2

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.
Line: 19 to 19
 %SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : DVAlgorithm( name, pSvcLocator ) , m_jPsiID(0) , m_jPsiMass(0.)
Changed:
<
<
declareProperty("MassWindow", m_jPsiMassWin = 10.*GeV);
>
>
{ declareProperty("MassWindow", m_jPsiMassWin = 10.*Gaudi::Units::GeV);
  declareProperty("MaxChi2", m_jPsiChi2 = 1000.); }%ENDSYNTAX%
Added:
>
>
 Note that while the compiler issues a warning when you use an uninitialized local variable in a method, it doesn't for uninitialized class members. People have run into horrible troubles impossible to debug because of such mistakes.

  • Of course, we want to get some real numbers in there. This happens in initialize()
Line: 26 to 28
 
  • Of course, we want to get some real numbers in there. This happens in initialize()
%SYNTAX{ syntax="cpp"}% debug() << "==> Initialize" << endmsg;
Changed:
<
<
ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX% Now get the mass and the PID of the J/psi from the ParticleProperty.
>
>
const LHCB::ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX% Now get the mass and the PID of the J/psi from the ParticleProperty and store these values in the private data members, for example:
<!-- SyntaxHighlightingPlugin -->
m_jPsiID = LHCb::ParticleID(Jpsi->pdgID()); 
<!-- end SyntaxHighlightingPlugin -->
To find out the method you need to get the mass look at the doxygen documentation.
  The list of official particle names and their properties is stored in a database. To dump the current list you can run in a new window: %SYNTAX{ syntax="sh"}%
Line: 38 to 42
 

Make the J/psi

Changed:
<
<
  • First separate positive and negative muons. This is best done using the ParticleFilter tool.
>
>
  • First separate positive and negative muons. This is best done using the ParticleFilter tool. Add a new private method StatusCode makeJpsi(const LHCb::Particle::ConstVector&) ; and implement it:
 
<!-- SyntaxHighlightingPlugin -->
LHCb::Particle::ConstVector MuPlus, MuMinus;
sc = particleFilter()->filterNegative(muons, MuMinus);
if (sc) sc = particleFilter()->filterPositive(muons, MuPlus);
<!-- end SyntaxHighlightingPlugin -->
Assuming that the muons you got from the desktop are in a vector called muons.
Changed:
<
<
  • Loop over the muons, you already know how.
>
>
  • Loop over the muons, you already know how. You need two nested for loop, one for positive muons, one for negatiive muons.
 
Changed:
<
<
  • Cut on the dimuon mass before you make the vertex, as the latter takes much more CPU.
>
>
  • Cut on the dimuon mass before you make the vertex, as the latter takes much more CPU. Inside the loop:
 
<!-- SyntaxHighlightingPlugin -->
Gaudi::LorentzVector twoMu = (*imp)->momentum() + (*imm)->momentum();
if ( fabs(twoMu.M() - m_jPsiMass) > m_jPsiMassWin ) continue; // mass cuts
<!-- end SyntaxHighlightingPlugin -->

Revision 162009-06-09 - RobLambert

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

DaVinci Tutorial 2

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.
Line: 87 to 87
 # J/psi->mumu selection # jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");
Changed:
<
<
jpsi2mumu.addTool( PhysDesktop ) jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ]
>
>
jpsi2mumu.InputLocations = [ "StdLooseMuons" ]
 from SystemOfUnits import MeV jpsi2mumu.MassWindow = 30*MeV%ENDSYNTAX%

Revision 152009-03-11 - unknown

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

DaVinci Tutorial 2

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.
Line: 88 to 88
 # jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");
Changed:
<
<
jpsi2mumu.addTool( PhysDesktop() )
>
>
jpsi2mumu.addTool( PhysDesktop )
 jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ] from SystemOfUnits import MeV jpsi2mumu.MassWindow = 30*MeV%ENDSYNTAX%

Revision 142009-02-16 - DavidHutchcroft

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

DaVinci Tutorial 2

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.
Line: 29 to 29
 ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX% Now get the mass and the PID of the J/psi from the ParticleProperty.
Added:
>
>
The list of official particle names and their properties is stored in a database. To dump the current list you can run in a new window:
<!-- SyntaxHighlightingPlugin -->
SetupProject LHCb
dump_db_to_files.py  -c sqlite_file:$SQLITEDBPATH/DDDB.db/DDDB  -s /param/ParticleTable.txt -d ./ -v
<!-- end SyntaxHighlightingPlugin -->
This will create the ParticleTable.txt file in the subdirectory param of the current directory, which lists all particles and their properties.
 

Make the J/psi

  • First separate positive and negative muons. This is best done using the ParticleFilter tool.

Revision 132009-01-05 - unknown

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

DaVinci Tutorial 2

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.

Deleted:
<
<

Slides

This tutorial refers to the slides shown here.
 

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.
%SYNTAX{ syntax="cpp"}%private:
Line: 85 to 82
 jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");

jpsi2mumu.addTool( PhysDesktop() )

Changed:
<
<
jpsi2mumu.PhysDesktop.InputLocations = [ "Phys/StdLooseMuons" ] jpsi2mumu.MassWindow = 30*Units.MeV jpsi2mumu.OutputLevel = 3 ;

GaudiSequencer("TutorialSeq").Members.append(jpsi2mumu)%ENDSYNTAX%

>
>
jpsi2mumu.PhysDesktop.InputLocations = [ "StdLooseMuons" ] from SystemOfUnits import MeV jpsi2mumu.MassWindow = 30*MeV%ENDSYNTAX%
 

Help!

The solution is given in solutions/DaVinci2.
Line: 97 to 92
 

Some plots

Try to write the macro that does the plots of the slides.
Changed:
<
<

Go to DaVinciTutorial3

>
>

Next

  • 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 use standard code to do the same thing go to DaVinciTutorial4.
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008
Added:
>
>
-- PatrickKoppenburg - 05 Jan 2009
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 122008-12-23 - unknown

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

DaVinci Tutorial 2

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.
Line: 101 to 101
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 \ No newline at end of file
Added:
>
>
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 112008-11-26 - unknown

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

DaVinci Tutorial 2

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.
Line: 17 to 17
 
  • Let's also store a few things we will need in the execute()
%SYNTAX{ syntax="cpp"}%LHCb::ParticleID m_jPsiID ; ///< J/psi ID double m_jPsiMass ; ///< J/psi mass
Changed:
<
<
>
>
%ENDSYNTAX%
 
  • It is mantatory to initialise everything in the constructor (in the .cpp file).
%SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : DVAlgorithm( name, pSvcLocator ) , m_jPsiID(0)

Revision 102008-10-15 - AngelaBuechler

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

DaVinci Tutorial 2

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.
Line: 29 to 29
 
  • Of course, we want to get some real numbers in there. This happens in initialize()
%SYNTAX{ syntax="cpp"}% debug() << "==> Initialize" << endmsg;
Changed:
<
<
ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX%
>
>
ParticleProperty* Jpsi = ppSvc()->find( "J/psi(1S)" );%ENDSYNTAX%
 Now get the mass and the PID of the J/psi from the ParticleProperty.

Make the J/psi

Revision 92008-06-13 - unknown

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

DaVinci Tutorial 2

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.
Line: 97 to 97
 

Some plots

Try to write the macro that does the plots of the slides.
Added:
>
>

Go to DaVinciTutorial3

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

Revision 82008-06-13 - unknown

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

DaVinci Tutorial 2

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.
Line: 79 to 79
 

Run it

  • You need to set the appropriate options
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" }; 
Jpsi2MuMu.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" }; 
Jpsi2MuMu.MassWindow = 30*MeV; 
Jpsi2MuMu.MaxChi2 = 20; 
Jpsi2MuMu.OutputLevel = 3;
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
#
# J/psi->mumu selection
#
jpsi2mumu = TutorialAlgorithm("Jpsi2MuMu");

jpsi2mumu.addTool( PhysDesktop() )
jpsi2mumu.PhysDesktop.InputLocations = [ "Phys/StdLooseMuons" ]
jpsi2mumu.MassWindow = 30*Units.MeV
jpsi2mumu.OutputLevel = 3 ;

GaudiSequencer("TutorialSeq").Members.append(jpsi2mumu)
<!-- end SyntaxHighlightingPlugin -->
 

Help!

The solution is given in solutions/DaVinci2.
Line: 93 to 99
 

-- PatrickKoppenburg - 01 Oct 2007 \ No newline at end of file

Added:
>
>
-- PatrickKoppenburg - 13 Jun 2008

Revision 72008-06-03 - unknown

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

DaVinci Tutorial 2

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.
Line: 14 to 14
  double m_jPsiMassWin ; ///< Mass window double m_jPsiChi2 ; ///< Max J/psi chi^2%ENDSYNTAX%
Changed:
<
<
  • Let's also add some counters, and store a few things we will need in the execute()
>
>
  • Let's also store a few things we will need in the execute()
 %SYNTAX{ syntax="cpp"}%LHCb::ParticleID m_jPsiID ; ///< J/psi ID double m_jPsiMass ; ///< J/psi mass
Deleted:
<
<
int m_nJPsis ; ///< number of J/psis int m_nEvents ; ///< number of Events%ENDSYNTAX%
 
  • It is mantatory to initialise everything in the constructor (in the .cpp file).
%SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) : DVAlgorithm( name, pSvcLocator ) , m_jPsiID(0) , m_jPsiMass(0.)
Deleted:
<
<
, m_nJPsis(0) , m_nEvents(0) {
  declareProperty("MassWindow", m_jPsiMassWin = 10.*GeV); declareProperty("MaxChi2", m_jPsiChi2 = 1000.); }%ENDSYNTAX%
Line: 57 to 53
 LHCb::Particle Jpsi( m_jPsiID ); StatusCode scFit = vertexFitter()->fit( *(*imp), *(*imm), Jpsi, MuMuVertex ); if ( scFit ) {
Changed:
<
<
Warning("Fit error");
>
>
Warning("Fit error").ignore();
  continue; }%ENDSYNTAX%
Changed:
<
<
Presently the fitter returns a failure if the fit failed. This is not a good reason to stop the execution. So catch this error and handle it properly.
>
>
Presently the fitter returns a failure if the fit failed. This is not a good reason to stop the execution. So catch this error and handle it properly. The ignore() is just there because Warning() returns a StatusCode and all StatusCodes should be checked or explicitly ignored. Else you'll get a list of unchecked StatusCodes at the end of the logfile.
 
  • Cut on the chi2.
<!-- SyntaxHighlightingPlugin -->
if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue; // chi2 cut
<!-- end SyntaxHighlightingPlugin -->
Line: 76 to 72
 
  • Save all J/psis. At the end of the method you should ask the desktop to save it all.
<!-- SyntaxHighlightingPlugin -->
return desktop()->saveDesktop(); 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<

Don't forget the counters

  • Increment the counters where suitable.
  • Print out their value in the finalize().
>
>

Need some counters?

Counters are booked on-demand like plots. Just add at an appropriate place
<!-- SyntaxHighlightingPlugin -->
counter("J/psi's")++; 
<!-- end SyntaxHighlightingPlugin -->
and you'll get a count of the number of candidates.
 

Run it

  • You need to set the appropriate options

Revision 62008-04-10 - unknown

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

DaVinci Tutorial 2

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.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial refers to the slides shown here.
>
>
This tutorial refers to the slides shown here.
 

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.

Revision 52008-03-05 - AnatolySolomin

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

DaVinci Tutorial 2

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.
Line: 29 to 29
  declareProperty("MassWindow", m_jPsiMassWin = 10.*GeV); declareProperty("MaxChi2", m_jPsiChi2 = 1000.); }%ENDSYNTAX%
Changed:
<
<
Note that while the compiler issues a warning when you use an uninitialised local variable in a method, it doesn't for uninitialised class members. People have run into horrible troubles impossible to debug because of such mistakes.
>
>
Note that while the compiler issues a warning when you use an uninitialized local variable in a method, it doesn't for uninitialized class members. People have run into horrible troubles impossible to debug because of such mistakes.
 
  • Of course, we want to get some real numbers in there. This happens in initialize()
<!-- SyntaxHighlightingPlugin -->
debug() << "==> Initialize" << endmsg; 
  ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
Now get the mass and the PID of the J/psi from the ParticleProperty.
>
>
Now get the mass and the PID of the J/psi from the ParticleProperty.
 

Make the J/psi

Line: 68 to 68
 
  • Decare the the J/psi to the PhysDesktop.
%SYNTAX{ syntax="cpp"}% desktop()->save(&Jpsi);
Changed:
<
<
setFilterPassed(true); // Mandatory. Set to true if event is accepte%ENDSYNTAX%
>
>
setFilterPassed( true ); // Mandatory. Set to true if event is accepted%ENDSYNTAX%
 Warning: It does not save it yet.

Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.

Line: 78 to 78
 

Don't forget the counters

  • Increment the counters where suitable.
Changed:
<
<
  • Print out their value in the finalisation.
>
>
  • Print out their value in the finalize().
 

Run it

  • You need to set the appropriate options

Revision 42008-03-04 - unknown

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

DaVinci Tutorial 2

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.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial refers to the slides shown here.
>
>
This tutorial refers to the slides shown here.
 

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.
Line: 92 to 92
 The solution is given in solutions/DaVinci2.

Some plots

Changed:
<
<
Here's what I did to get the plots from the slides:
<!-- SyntaxHighlightingPlugin -->
TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); 
c1->SetLogy(); 
TFile* F = new TFile("DVHistos.root") 
F->ls() F->cd("Jpsi2MuMu") 
F->ls() 
TH1D* H2 = F->Get("Jpsi2MuMu/2") 
TH1D* H4 = F->Get("Jpsi2MuMu/4") 
TH1D* H9 = F->Get("Jpsi2MuMu/9") 
TH1D* H11 = F->Get("Jpsi2MuMu/11") 
H2->SetLineColor(2) 
H2->SetLineWidth(3) 
H2->Draw() H9->SetLineColor(3) 
H9->SetLineWidth(3) 
H9->Draw("same") 
gPad->SaveAs("Pt.eps") 
H4->SetLineColor(2) 
H4->SetLineWidth(3) 
H4->Draw() 
H11->SetLineColor(3) 
H11->SetLineWidth(3) 
H11->Draw("same") 
gPad->SaveAs("IPs.eps")
<!-- end SyntaxHighlightingPlugin -->
>
>
Try to write the macro that does the plots of the slides.
 

-- 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 2

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.

Added:
>
>

Slides

This tutorial refers to the slides shown here.
 

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.
%SYNTAX{ syntax="cpp"}%private:

Revision 22007-10-02 - unknown

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

DaVinci Tutorial 2

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.
Line: 7 to 7
 

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.
Changed:
<
<
|
private: 

>
>
%SYNTAX{ syntax="cpp"}%private:
  double m_jPsiMassWin ; ///< Mass window
Changed:
<
<
double m_jPsiChi2 ; ///< Max J/psi chi^2|
>
>
double m_jPsiChi2 ; ///< Max J/psi chi^2%ENDSYNTAX%
 
  • Let's also add some counters, and store a few things we will need in the execute()
Changed:
<
<
|
  LHCb::ParticleID m_jPsiID ; ///< J/psi ID 

>
>
%SYNTAX{ syntax="cpp"}% LHCb::ParticleID m_jPsiID ; ///< J/psi ID
  double m_jPsiMass ; ///< J/psi mass int m_nJPsis ; ///< number of J/psis
Changed:
<
<
int m_nEvents ; ///< number of Events|
>
>
int m_nEvents ; ///< number of Events%ENDSYNTAX%
 
  • It is mantatory to initialise everything in the constructor (in the .cpp file).
Changed:
<
<
|
TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator) : DVAlgorithm ( name , pSvcLocator ) 

>
>
%SYNTAX{ syntax="cpp"}%TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator) : DVAlgorithm ( name , pSvcLocator )
  , m_jPsiID(0) , m_jPsiMass(0.) , m_nJPsis(0) , m_nEvents(0) { declareProperty("MassWindow", m_jPsiMassWin = 10.*GeV); declareProperty("MaxChi2", m_jPsiChi2 = 1000.);
Changed:
<
<
}|
>
>
}%ENDSYNTAX%
 Note that while the compiler issues a warning when you use an uninitialised local variable in a method, it doesn't for uninitialised class members. People have run into horrible troubles impossible to debug because of such mistakes.

  • Of course, we want to get some real numbers in there. This happens in initialize()
Changed:
<
<
  debug() << "==> Initialize" << endmsg; 
  ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );
>
>
<!-- SyntaxHighlightingPlugin -->
debug() << "==> Initialize" << endmsg; 
  ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );
<!-- end SyntaxHighlightingPlugin -->
 Now get the mass and the PID of the J/psi from the ParticleProperty.

Make the J/psi

  • First separate positive and negative muons. This is best done using the ParticleFilter tool.
Changed:
<
<
|
  LHCb::Particle::ConstVector MuPlus, MuMinus;

>
>
%SYNTAX{ syntax="cpp"}% LHCb::Particle::ConstVector MuPlus, MuMinus;
  sc = particleFilter()->filterNegative(muons,MuMinus);
Changed:
<
<
if (sc) sc = particleFilter()->filterPositive(muons,MuPlus);|
>
>
if (sc) sc = particleFilter()->filterPositive(muons,MuPlus);%ENDSYNTAX%
 Assuming that the muons you got from the desktop are in a vector called muons.

  • Loop over the muons, you already know how.

  • Cut on the dimuon mass before you make the vertex, as the latter takes much more CPU.
Changed:
<
<
|
  Gaudi::LorentzVector twoMu = (*imp)->momentum() + (*imm)->momentum() ;

>
>
%SYNTAX{ syntax="cpp"}% Gaudi::LorentzVector twoMu = (*imp)->momentum() + (*imm)->momentum() ;
  if ( fabs ( twoMu.M() - m_jPsiMass ) > m_jPsiMassWin ) continue ; // mass cuts
Changed:
<
<
|
>
>
%ENDSYNTAX%
 You probably also want to plot the mass before the cut, and maybe to print it out in debug() or verbose() level.

  • Now call the vertex fitter. It will return you a vertex and the J/psi Particle.
Changed:
<
<
|
  LHCb::Vertex MuMuVertex; 

>
>
%SYNTAX{ syntax="cpp"}% LHCb::Vertex MuMuVertex;
  LHCb::Particle Jpsi(m_jPsiID); StatusCode scFit = vertexFitter()->fit(*(*imp),*(*imm),Jpsi,MuMuVertex); if (scFit) { Warning("Fit error"); continue;
Changed:
<
<
}|
>
>
}%ENDSYNTAX%
 Presently the fitter returns a failure if the fit failed. This is not a good reason to stop the execution. So catch this error and handle it properly.

  • Cut on the chi2.
Changed:
<
<
  if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue ; // chi2 cut
>
>
<!-- SyntaxHighlightingPlugin -->
if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue ; // chi2 cut
<!-- end SyntaxHighlightingPlugin -->
 But maybe you should fill a histogram with the chi2 first.

  • Decare the the J/psi to the PhysDesktop.
Changed:
<
<
 desktop()->save(&Jpsi);
  setFilterPassed(true); // Mandatory. Set to true if event is accepte
>
>
<!-- SyntaxHighlightingPlugin -->
desktop()->save(&Jpsi);
  setFilterPassed(true); // Mandatory. Set to true if event is accepte
<!-- end SyntaxHighlightingPlugin -->
 Warning: It does not save it yet.

Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.

  • Save all J/psis. At the end of the method you should ask the desktop to save it all.
Changed:
<
<
  return desktop()->saveDesktop() ; 
>
>
<!-- SyntaxHighlightingPlugin -->
return desktop()->saveDesktop() ; 
<!-- end SyntaxHighlightingPlugin -->
 

Don't forget the counters

  • Increment the counters where suitable.
Line: 79 to 79
 

Run it

  • You need to set the appropriate options
Changed:
<
<
|
TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" }; 

>
>
%SYNTAX{ syntax="cpp"}%TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" };
 InputLocations = { "Phys/StdLooseMuons" } ; MassWindow = 30*MeV ; MaxChi2 = 20 ;
Changed:
<
<
OutputLevel = 3 ;|
>
>
OutputLevel = 3 ;%ENDSYNTAX%
 

Help!

The solution is given in solutions/DaVinci2.

Some plots

Here's what I did to get the plots from the slides:
Changed:
<
<
|
TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); 

>
>
%SYNTAX{ syntax="cpp"}%TCanvas* c1 = new TCanvas("c1","Tutorial",800,800);
 c1->SetLogy(); TFile* F = new TFile("DVHistos.root") F->ls() F->cd("Jpsi2MuMu")
Line: 111 to 111
 H11->SetLineColor(3) H11->SetLineWidth(3) H11->Draw("same")
Changed:
<
<
gPad->SaveAs("IPs.eps")|
>
>
gPad->SaveAs("IPs.eps")%ENDSYNTAX%
 

Revision 12007-10-01 - unknown

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

DaVinci Tutorial 2

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.

Add some global variables

  • We want to be able to cut on the J/psi mass and the vertex chi2 at least. And change the cut values by options.
private: 
  double m_jPsiMassWin ; ///< Mass window 
  double m_jPsiChi2 ; ///< Max J/psi chi^2

  • Let's also add some counters, and store a few things we will need in the execute()
  LHCb::ParticleID m_jPsiID ; ///< J/psi ID 
  double m_jPsiMass ; ///< J/psi mass 
  int m_nJPsis ; ///< number of J/psis 
  int m_nEvents ; ///< number of Events

  • It is mantatory to initialise everything in the constructor (in the .cpp file).
TutorialAlgorithm::TutorialAlgorithm( const std::string& name, ISvcLocator* pSvcLocator) : DVAlgorithm ( name , pSvcLocator ) 
  , m_jPsiID(0) 
  , m_jPsiMass(0.) 
  , m_nJPsis(0) 
  , m_nEvents(0) { 
  declareProperty("MassWindow", m_jPsiMassWin = 10.*GeV);   
  declareProperty("MaxChi2", m_jPsiChi2 = 1000.); 
}
Note that while the compiler issues a warning when you use an uninitialised local variable in a method, it doesn't for uninitialised class members. People have run into horrible troubles impossible to debug because of such mistakes.

  • Of course, we want to get some real numbers in there. This happens in initialize()
  debug() << "==> Initialize" << endmsg; 
  ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );
Now get the mass and the PID of the J/psi from the ParticleProperty.

Make the J/psi

  • First separate positive and negative muons. This is best done using the ParticleFilter tool.
  LHCb::Particle::ConstVector MuPlus, MuMinus;
  sc = particleFilter()->filterNegative(muons,MuMinus);
  if (sc) sc = particleFilter()->filterPositive(muons,MuPlus);
Assuming that the muons you got from the desktop are in a vector called muons.

  • Loop over the muons, you already know how.

  • Cut on the dimuon mass before you make the vertex, as the latter takes much more CPU.
  Gaudi::LorentzVector twoMu = (*imp)->momentum() + (*imm)->momentum() ;
  if ( fabs ( twoMu.M() - m_jPsiMass ) > m_jPsiMassWin ) continue ; // mass cuts
You probably also want to plot the mass before the cut, and maybe to print it out in debug() or verbose() level.

  • Now call the vertex fitter. It will return you a vertex and the J/psi Particle.
  LHCb::Vertex MuMuVertex; 
  LHCb::Particle Jpsi(m_jPsiID);
  StatusCode scFit = vertexFitter()->fit(*(*imp),*(*imm),Jpsi,MuMuVertex);
  if (!scFit) {
    Warning("Fit error"); 
    continue; 
  }
Presently the fitter returns a failure if the fit failed. This is not a good reason to stop the execution. So catch this error and handle it properly.

  • Cut on the chi2.
  if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue ; // chi2 cut
But maybe you should fill a histogram with the chi2 first.

  • Decare the the J/psi to the PhysDesktop.
 desktop()->save(&Jpsi);
  setFilterPassed(true); // Mandatory. Set to true if event is accepte
Warning: It does not save it yet.

Since you have a J/psi you can set FilterPassed to true, which tells the sequencer the algorithm found what it was looking for.

  • Save all J/psis. At the end of the method you should ask the desktop to save it all.
  return desktop()->saveDesktop() ; 

Don't forget the counters

  • Increment the counters where suitable.
  • Print out their value in the finalisation.

Run it

  • You need to set the appropriate options
TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" }; 
Jpsi2MuMu.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" } ; 
Jpsi2MuMu.MassWindow = 30*MeV ; 
Jpsi2MuMu.MaxChi2 = 20 ; 
Jpsi2MuMu.OutputLevel = 3 ;

Help!

The solution is given in solutions/DaVinci2.

Some plots

Here's what I did to get the plots from the slides:
TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); 
c1->SetLogy(); 
TFile* F = new TFile("DVHistos.root") 
F->ls() F->cd("Jpsi2MuMu") 
F->ls() 
TH1D* H2 = F->Get("Jpsi2MuMu/2") 
TH1D* H4 = F->Get("Jpsi2MuMu/4") 
TH1D* H9 = F->Get("Jpsi2MuMu/9") 
TH1D* H11 = F->Get("Jpsi2MuMu/11") 
H2->SetLineColor(2) 
H2->SetLineWidth(3) 
H2->Draw() H9->SetLineColor(3) 
H9->SetLineWidth(3) 
H9->Draw("same") 
gPad->SaveAs("Pt.eps") 
H4->SetLineColor(2) 
H4->SetLineWidth(3) 
H4->Draw() 
H11->SetLineColor(3) 
H11->SetLineWidth(3) 
H11->Draw("same") 
gPad->SaveAs("IPs.eps")

-- 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