Exercises linked to DaVinci session 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
1. 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.
- Let's also add some statistics, and store a few things we will need in the execute()
- It is mandatory to initialise everything in the constructor
- Of course, we want to get some real numbers in there. This happens in initialize()
private:
double m_jPsiMassWin ; ///< Mass window
double m_jPsiChi2 ; ///< Max J/psi chi^2
int m_jPsiID ; ///< J/psi ID
double m_jPsiMass ; ///< J/psi mass
int m_nJPsis ; ///< number of J/psis
int m_nEvents ; ///< number of Events
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.);
}
debug() << "==> Initialize" << endmsg;
ParticleProperty* psi = ppSvc()->find( "J/psi(1S)" );
Now get the mass and the PID of the J/psi from the ParticleProperty.
2. Make the J/psi
- First separate positive and negative muons. This is best done using the ParticleFilter tool.
- 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.
- Now cut on the chi2.
if ( MuMuVertex.chi2() > m_jPsiChi2 ) continue ; // chi2 cut
But maybe you should fill a histogram with the chi2 first.
- Save the J/psi.
desktop()->save(&Jpsi); setFilterPassed(true); // Mandatory. Set to true if event is accepted.
This declares the J/psi to the PhysDesktop. 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() ;
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
.
3. Don't forget the counters
- Increment the counters where suitable.
- Print out their value in the finalisation.
4. Run it
- Set the appropriate options.
- Get data from the bookkeeping
TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" };
Jpsi2MuMu.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" } ;
Jpsi2MuMu.MassWindow = 50*MeV ;
Jpsi2MuMu.MaxChi2 = 100 ;
Jpsi2MuMu.OutputLevel = 3 ;
There is J/psi Ks data available in the bookkeeping. You'll get more J/psi's from this data than from the BB inclusive!
Pay attention to restrict yourself to the latest Gauss version available.
5. Help!
-
The solution is given in
solutions/DaVinci2
More exercises linked to DaVinci session 2
You could actually use this algorithm to make the Phi too. The procedure for selecting the Phi is the same, it's just the properties of the mother and the type of the daughters that change.
- Adapt
TutorialAlgorithm
in order to be able to select J/psi and Phi depending on the configuration. The options should look like:
//
// J/psi->mumu selection
//
TutorialSeq.Members += { "TutorialAlgorithm/Jpsi2MuMu" };
Jpsi2MuMu.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" } ;
Jpsi2MuMu.Particle = "J/psi(1S)" ;
Jpsi2MuMu.MassWindow = 50*MeV ;
Jpsi2MuMu.MaxChi2 = 100 ;
Jpsi2MuMu.OutputLevel = 3 ;
//
// Phi->KK selection
//
TutorialSeq.Members += { "TutorialAlgorithm/Phi2KK" };
Phi2KK.PhysDesktop.InputLocations = { "Phys/StdLooseKaons" } ;
Phi2KK.Particle = "phi(1020)" ;
Phi2KK.MassWindow = 50*MeV ;
Phi2KK.MaxChi2 = 100 ;
Phi2KK.OutputLevel = 3 ;
The solution is given in solutions/DaVinci3
Last modified by P. Koppenburg, June 1 2006