# Difference: DaVinciTutorial1 (81 vs. 82)

#### Revision 822013-09-30 - PatrickSKoppenburg

Line: 1 to 1

 META TOPICPARENT name="DaVinciTutorial"

# DaVinci Tutorial 1

We start with a very simple algorithm that looks at muons and fills some histograms. Follow it step-by-step. Every single line you need to write is given, but be very careful about where to paste what!
Line: 36 to 36
from Configurables import TutorialAlgorithm tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ]
Changed:
<
<
tutalg.Inputs = [ "Phys/StdLooseMuons/Particles" ]
>
>
tutalg.Inputs = [ "Phys/StdAllLooseMuons/Particles" ]
# # 3) Configure the application. We'll come back to this later. #
Line: 44 to 44
DaVinci().UserAlgorithms = [ tutorialseq ] %ENDSYNTAX%
Changed:
<
<
Since we want to make a J/psi->mumu we only need muons as input Particles. The `StdLooseMuons` are all charged tracks compatible with being a muon. They are made on demand when you need them.
>
>
Since we want to make a J/psi->mumu we only need muons as input Particles. The `StdAllLooseMuons` are all charged tracks compatible with being a muon. They are made on demand when you need them.
Now we need to write the algorithm!

## Start to write the algorithm

We will make a small algorithm that loops over muons and plots some variables.
• Open the files for your algorithm (from the shell type):
 `emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/src/TutorialAlgorithm.{cpp,h} &`
Changed:
<
<
Answer "D" for `DVAlgorithm` twice. You can also do that from the shell prompt by opening another window.
>
>
Answer "D" for `DaVinciAlgorithm` twice. You can also do that from the shell prompt by opening another window. This has created a template for a `TutorialAlgorithm` inheriting from `DaVinciAlgorithm`. But as we will want to use a few more features, replace all instances of `DaVinciAlgorithm` by `DaVinciTupleAlgorithm`. This allows to get access to helper methods to make plots. (For what we plan to do, `DaVinciHistoAlgorithm` would work too).

• Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private: StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
Line: 109 to 109
sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2); if (sc){ plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm);
Changed:
<
<
plot(IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
>
>
plot(IPchi2, "IPchi2", "Muon chi2 IP", 0., 25.);
if ( (*im)->pt()>2*Gaudi::Units::GeV) plot(IP, "IP_2", "Muon IP for PT>2GeV", 0., 10.*Gaudi::Units::mm); }
Line: 146 to 146
then type:
Changed:
<
<
 `gaudirun.py options/myOptions.py options/InclJpsi.py`
>
>
 `gaudirun.py options/myOptions.py options/Bs2JpsiPhi_Sim08a.py`

## Look at the histograms

Line: 154 to 154

 `root -l`
Changed:
<
<
If you ran using ganga, the output of the job will be stored in |j.outputdir|. Go to that directory in ganga, and you can start root directly:
>
>
If you ran using ganga, the output of the job will be stored in `j.outputdir`. Go to that directory in ganga, and you can start root directly:
%SYNTAX{ syntax="python"}% cd \$j.outputdir
Line: 221 to 221
-- PatrickKoppenburg - 05 Jan 2009 -- JeremyDickens - 04-Jan-2011 -- PatrickSKoppenburg - 16-Oct-2012
>
>
-- PatrickSKoppenburg - 30-Sep-2013

 META FILEATTACHMENT attachment="Screenshot-Feicim.png" attr="" comment="" date="1231421302" name="Screenshot-Feicim.png" path="Screenshot-Feicim.png" size="117386" stream="Screenshot-Feicim.png" user="Main.PatrickKoppenburg" version="1"
Changed:
<
<
 META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r5" name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r4" name="GANGAVERSION" title="GANGAVERSION" type="Set" value="6-0-9"
>
>
 META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r7" name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r6" name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v600r17"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
 ```"| ```

Copyright &© 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