Difference: DaVinciTutorial1 (1 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
Added:
>
>
-- 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"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r4"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="6-0-9"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r7"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r6"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v600r17"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 812013-07-04 - 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: 142 to 142
 

Run it interactively (outside ganga):

Alternatively you can run interactively on lxplus. To do so you must use the PFNs. Don't forget to do SetupProject if needed:
Changed:
<
<
SetupProject DaVinci %DAVINCIVERS%
>
>
SetupProject DaVinci v33r7
  then type:
Line: 223 to 223
 -- PatrickSKoppenburg - 16-Oct-2012

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="v33r0p1"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r5"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r4"
Changed:
<
<
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5-8-16"
>
>
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="6-0-9"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 802012-10-24 - 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: 223 to 223
 -- PatrickSKoppenburg - 16-Oct-2012

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="v33r0"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r0p1"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r4"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5-8-16"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 792012-10-16 - 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: 109 to 109
  sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2); if (sc){ plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm);
Changed:
<
<
plot(IP/IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
>
>
plot(IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
  if ( (*im)->pt()>2*Gaudi::Units::GeV) plot(IP, "IP_2", "Muon IP for PT>2GeV", 0., 10.*Gaudi::Units::mm); }
Line: 121 to 121
 
<!-- SyntaxHighlightingPlugin -->
t.application.make() 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
or from outside ganga, SetupProject --build-env DaVinci %DAVINCIVERS% (if not already done), move to the cmt directory of Tutorial/Analysis and type:
>
>
or from outside ganga, SetupProject --build-env DaVinci v33r7 (if not already done), move to the cmt directory of Tutorial/Analysis and type:
 
cmt make
Line: 191 to 191
 H1->SetLineColor(2) H1->SetLineWidth(3) H1->Draw()
Changed:
<
<
gPad->SaveAs("DV1_P.eps");
>
>
gPad->SaveAs("DV1_P.png");
  H2->SetLineColor(2) H2->SetLineWidth(3) H2->Draw()
Changed:
<
<
gPad->SaveAs("DV1_Pt.eps");
>
>
gPad->SaveAs("DV1_Pt.png");
  H3->SetLineColor(2) H3->SetLineWidth(3) H3->Draw()
Changed:
<
<
gPad->SaveAs("DV1_IP.eps");
>
>
gPad->SaveAs("DV1_IP.png");
  H4->SetLineColor(2) H4->SetLineWidth(3) H4->Draw()
Changed:
<
<
gPad->SaveAs("DV1_IPchi2.eps");%ENDSYNTAX%
>
>
gPad->SaveAs("DV1_IPchi2.png");%ENDSYNTAX%
  For sure one could do this shorter...
  • To quit root:
Line: 220 to 220
 -- PatrickKoppenburg - 11 Mar 2008 -- PatrickKoppenburg - 05 Jan 2009 -- JeremyDickens - 04-Jan-2011
Added:
>
>
-- PatrickSKoppenburg - 16-Oct-2012
 
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="v30r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v507r9"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v33r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r4"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5-8-16"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 782012-10-16 - 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: 6 to 6
 

Slides

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

Prerequisites

Revision 772012-03-20 - 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: 222 to 222
 -- JeremyDickens - 04-Jan-2011

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="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 762012-03-09 - 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: 222 to 222
 -- JeremyDickens - 04-Jan-2011

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="v30r1p1"
>
>
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 752012-03-09 - 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: 222 to 222
 -- JeremyDickens - 04-Jan-2011

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="v29r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v507r1"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v30r1p1"
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 742011-12-02 - 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: 121 to 121
 
<!-- SyntaxHighlightingPlugin -->
t.application.make() 
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
or from outside ganga, SetupProject --build-env DaVinci v26r3p2 (if not already done), move to the cmt directory of Tutorial/Analysis and type:
>
>
or from outside ganga, SetupProject --build-env DaVinci %DAVINCIVERS% (if not already done), move to the cmt directory of Tutorial/Analysis and type:
 
cmt make
Line: 142 to 142
 

Run it interactively (outside ganga):

Alternatively you can run interactively on lxplus. To do so you must use the PFNs. Don't forget to do SetupProject if needed:
Changed:
<
<
SetupProject DaVinci v26r3p2
>
>
SetupProject DaVinci %DAVINCIVERS%
  then type:
Changed:
<
<
gaudirun.py options/myOptions.py options/MC09-InclJpsi.py
>
>
gaudirun.py options/myOptions.py options/InclJpsi.py
 

Look at the histograms

Revision 732011-12-02 - 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: 222 to 222
 -- JeremyDickens - 04-Jan-2011

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="v28r1p1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r0"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r26"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v29r2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v507r1"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 722011-12-02 - 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: 64 to 64
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Changed:
<
<
const LHCb::Particle::ConstVector muons = desktop()->particles();
>
>
const LHCb::Particle::ConstVector muons = particles();
  sc = loopOnMuons(muons); if (sc) return sc;

Revision 712011-03-23 - 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.InputLocations = [ "Phys/StdLooseMuons" ]
>
>
tutalg.Inputs = [ "Phys/StdLooseMuons/Particles" ]
 # # 3) Configure the application. We'll come back to this later. #
Line: 222 to 222
 -- JeremyDickens - 04-Jan-2011

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="v26r3p2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r7"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r16"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v28r1p1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v10r0"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r26"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 702011-01-05 - JeremyDickensExCern

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: 54 to 54
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:
Changed:
<
<
StatusCode loopOnMuons(const LHCb::Particle::Range&)const ;
>
>
StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
 %ENDSYNTAX%
  • Now let's add something to the execute method in the cpp:
Line: 64 to 64
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Changed:
<
<
const LHCb::Particle::Range muons = this->particles();
>
>
const LHCb::Particle::ConstVector muons = desktop()->particles();
  sc = loopOnMuons(muons); if (sc) return sc;
Line: 79 to 79
 //==================================================== // loop on muons //====================================================
Changed:
<
<
StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::Range& muons)const {
>
>
StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::ConstVector& muons)const {
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Line: 89 to 89
 %ENDSYNTAX%
  • In the method add:
%SYNTAX{ syntax="cpp"}%
Changed:
<
<
for ( LHCb::Particle::Range::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
>
>
for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
  plot((*im)->p(), "P", "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum plot((*im)->pt(), "Pt", "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt debug() << "Mu Momentum: " << (*im)->momentum() << endmsg ;
Line: 102 to 102
 
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}%
Changed:
<
<
for ( LHCb::RecVertex::Range::const_iterator ipv = pvs.begin() ;
>
>
for ( LHCb::RecVertex::ConstVector::const_iterator ipv = pvs.begin() ;
  ipv = pvs.end() ; ++ipv ){ double IP, IPchi2; if (msgLevel(MSG::DEBUG)) debug() << (*ipv)->position() << endmsg ;

Revision 692011-01-04 - JeremyDickensExCern

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: 18 to 18
 
  • Open the main options file (from ganga type:)
!emacs $t.application.optsfile[0].name &
Added:
>
>
or from outside ganga move to the options directory of the Tutorial/Analysis package and type:

emacs myOptions.py &
 
  • Write in the options file.
%SYNTAX{ syntax="python"}%from Gaudi.Configuration import * #
Line: 45 to 50
 

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):
Changed:
<
<
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/src/TutorialAlgorithm.{cpp,h} &
>
>
emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/src/TutorialAlgorithm.{cpp,h} &
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:
Line: 112 to 117
  %ENDSYNTAX%
Changed:
<
<
  • Now compile
>
>
  • Now compile (from ganga):
 
<!-- SyntaxHighlightingPlugin -->
t.application.make() 
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
or from outside ganga, SetupProject --build-env DaVinci v26r3p2 (if not already done), move to the cmt directory of Tutorial/Analysis and type:

cmt make
 ... and fix all compilation errors...

Run!

Changed:
<
<

Submit

>
>

Submit from within ganga:

 
  • Define a job. If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->
you can also use LSF, Local, Dirac... For small tests, interactive or local is usually best. For larger amounts of data, you'll need to run either on the LSF batch system or on the Grid.
Line: 129 to 139
 
  • Submit the job
<!-- SyntaxHighlightingPlugin -->
j.submit()
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<

Run it interactively

Alternatively you can run interactively on lxplus. To do so you must use the PFNs.
<!-- SyntaxHighlightingPlugin -->
gaudirun.py options/myOptions.py options/MC09-InclJpsi.py
<!-- end SyntaxHighlightingPlugin -->
>
>

Run it interactively (outside ganga):

Alternatively you can run interactively on lxplus. To do so you must use the PFNs. Don't forget to do SetupProject if needed:

SetupProject DaVinci v26r3p2

then type:

gaudirun.py options/myOptions.py options/MC09-InclJpsi.py
 

Look at the histograms

Changed:
<
<
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 interactively, from outside ganga, then the DVHistos.root file should be in the directory where you ran DaVinci. From that directory, start root by typing:

root -l

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: 151 to 170
 
<!-- SyntaxHighlightingPlugin -->
SetupProject Gaudi ROOT
<!-- end SyntaxHighlightingPlugin -->
<!-- SyntaxHighlightingPlugin -->
root.exe
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>

Once in root:

  The simplest way to look at histograms is to use the TBrowser.
<!-- SyntaxHighlightingPlugin -->
TBrowser B
<!-- end SyntaxHighlightingPlugin -->
which has a Windows-like look and feel.
Line: 198 to 219
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008 -- PatrickKoppenburg - 05 Jan 2009
Added:
>
>
-- JeremyDickens - 04-Jan-2011
 
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"
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v26r3p2"

Revision 682010-12-01 - RobLambert

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: 200 to 200
 -- PatrickKoppenburg - 05 Jan 2009

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="v25r3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r4"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r5"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v26r3p2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r7"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r16"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 672010-08-06 - 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: 8 to 8
 

Slides

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

Prerequisites---++ Platform Warning

Ganga is not yet fully operational on slc5. We encourage newcomers to log in to lxplus4.cern.ch to run this tutorial.
>
>

Prerequisites

  DaVinciTutorial0 and DaVinciTutorial0p5
Line: 75 to 74
 //==================================================== // loop on muons //====================================================
Changed:
<
<
StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::ConstVector& muons)const {
>
>
StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::Range& muons)const {
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Revision 662010-05-31 - unknown

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: 32 to 32
 from Configurables import TutorialAlgorithm tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ]
Changed:
<
<
tutalg.InputLocations = [ "StdLooseMuons" ]
>
>
tutalg.InputLocations = [ "Phys/StdLooseMuons" ]
 # # 3) Configure the application. We'll come back to this later. #
Line: 50 to 50
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:
Changed:
<
<
StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
>
>
StatusCode loopOnMuons(const LHCb::Particle::Range&)const ;
 %ENDSYNTAX%
  • Now let's add something to the execute method in the cpp:
Line: 60 to 60
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Changed:
<
<
const LHCb::Particle::ConstVector muons = desktop()->particles();
>
>
const LHCb::Particle::Range muons = this->particles();
  sc = loopOnMuons(muons); if (sc) return sc;
Line: 68 to 68
  return StatusCode::SUCCESS; } %ENDSYNTAX%
Changed:
<
<
Here we get the particles from the PhysDesktop tool and call our new method.
>
>
Here we get the particles from a local container and call our new method.
 
  • Now implement the method in the cpp file. You can get a template method typing insert M in emacs. You then have to replace the type void by StatusCode and declare the arguments:
%SYNTAX{ syntax="cpp"}%
Line: 85 to 85
 %ENDSYNTAX%
  • In the method add:
%SYNTAX{ syntax="cpp"}%
Changed:
<
<
for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
>
>
for ( LHCb::Particle::Range::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
  plot((*im)->p(), "P", "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum plot((*im)->pt(), "Pt", "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt debug() << "Mu Momentum: " << (*im)->momentum() << endmsg ;
Line: 94 to 94
 
  • Now get the primary vertices (before the muons loop):
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::Container* pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::Range pvs = this->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
 
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}%
Changed:
<
<
for ( LHCb::RecVertex::Container::const_iterator ipv = pvs->begin() ; ipv = pvs->end() ; ++ipv ){
>
>
for ( LHCb::RecVertex::Range::const_iterator ipv = pvs.begin() ; ipv = pvs.end() ; ++ipv ){
  double IP, IPchi2; if (msgLevel(MSG::DEBUG)) debug() << (*ipv)->position() << endmsg ; sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2);

Revision 652010-04-26 - 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: 201 to 201
 -- PatrickKoppenburg - 05 Jan 2009

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="v24r7p3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v504r5"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v25r3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r4"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="v505r5"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 642010-04-26 - 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: 8 to 8
 

Slides

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

Platform Warning

>
>

Prerequisites---++ Platform Warning

 Ganga is not yet fully operational on slc5. We encourage newcomers to log in to lxplus4.cern.ch to run this tutorial.
Deleted:
<
<

Prerequisites

 DaVinciTutorial0 and DaVinciTutorial0p5

Start to write the options

Revision 632010-02-01 - 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: 202 to 202
 -- PatrickKoppenburg - 05 Jan 2009

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="v24r7p2"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r7p3"
 
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 622010-02-01 - RobLambert

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!

Revision 612010-01-28 - RobLambert

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: 11 to 11
 

Platform Warning

Ganga is not yet fully operational on slc5. We encourage newcomers to log in to lxplus4.cern.ch to run this tutorial.
Changed:
<
<

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
<!-- SyntaxHighlightingPlugin -->
SetupProject Ganga
<!-- end SyntaxHighlightingPlugin -->
and take the latest version (v600r17 at time of writing).
  • If you have last used ganga before version 5.1 you may need to do
<!-- SyntaxHighlightingPlugin -->
ganga -g
<!-- end SyntaxHighlightingPlugin -->
  • Now start an interactive session:
<!-- SyntaxHighlightingPlugin -->
ganga
<!-- end SyntaxHighlightingPlugin -->
You will be prompted for your grid password.
  • At the ganga prompt type:
<!-- SyntaxHighlightingPlugin -->
t = JobTemplate( application = DaVinci( version = "v33r7" ))
# t.application.setupProjectOptions = '--nightly lhcb1' # uncomment this if DaVinci version is HEAD
t.application.getpack( "Tutorial/Analysis v10r6" )
t.application.masterpackage = "Phys/DaVinci"
t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/options/myOptions.py" )
t.application.make()
<!-- end SyntaxHighlightingPlugin -->
Be very careful not to copy-paste leading spaces; python does not like that at all.
>
>

Prerequisites

DaVinciTutorial0 and DaVinciTutorial0p5
 

Start to write the options

  • First make sure you have the LHCb flavour of emacs. If not do what's described here.
Line: 138 to 119
 t.application.make() %ENDSYNTAX% ... and fix all compilation errors...
Deleted:
<
<

Warning

The above might not work, depending on the version of ganga. If all you get are cmt warnings about undefined versions, then leave ganga (ctrl-D) and do the following:
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci 
cd $ANALYSISROOT/cmt
cmt make
<!-- end SyntaxHighlightingPlugin -->
Once you fixed all compilation errors, go back into ganga and recover your job template:
<!-- SyntaxHighlightingPlugin -->
t=templates[-1]
<!-- end SyntaxHighlightingPlugin -->
 

Run!

Changed:
<
<

Data

First we need some data.
  • Open the feicim browser in ganga.
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events. Double click on it, and "save". Check:
<!-- SyntaxHighlightingPlugin -->
for i in data.files: print i
<!-- end SyntaxHighlightingPlugin -->
  • This will be a set of LFNs that you can pass to the job:
<!-- SyntaxHighlightingPlugin -->
t.inputdata = data
<!-- end SyntaxHighlightingPlugin -->

DaVinci()

We now need to configure the job in the main options file:
<!-- SyntaxHighlightingPlugin -->
DaVinci().HistogramFile = "DVHistos_1.root"    # Histogram file
DaVinci().EvtMax = 1000                        # Number of events
DaVinci().DataType = "MC09"                    # Default anyway
DaVinci().Simulation   = True                  # It's MC
<!-- end SyntaxHighlightingPlugin -->
if you have closed it you can reopen with:
!emacs $t.application.optsfile[0].name &
>
>
 

Submit

  • Define a job. If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->
Line: 179 to 136
 
<!-- SyntaxHighlightingPlugin -->
gaudirun.py options/myOptions.py options/MC09-InclJpsi.py
<!-- end SyntaxHighlightingPlugin -->

Look at the histograms

Changed:
<
<
We'll do that outside of ganga... so exit back to shell.
  • Source the root setup scripts
>
>
The output of the job will be stored in |j.outputdir|. Go to that directory in ganga, and you can start root directly:

<!-- SyntaxHighlightingPlugin -->
cd $j.outputdir
root -l
<!-- end SyntaxHighlightingPlugin -->

Or use ganga's built-in peek command:

<!-- SyntaxHighlightingPlugin -->
j.peek('DVHistos.root', 'root -l')
<!-- end SyntaxHighlightingPlugin -->

Or, if you have screwed up your own root environment wink you may need to exit to the shell

 
<!-- SyntaxHighlightingPlugin -->
SetupProject Gaudi ROOT
<!-- end SyntaxHighlightingPlugin -->
Deleted:
<
<
  • Open root
 
<!-- SyntaxHighlightingPlugin -->
root.exe
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • The simplest way to look at histograms is to use the TBrowser.
>
>
The simplest way to look at histograms is to use the TBrowser.
 
<!-- SyntaxHighlightingPlugin -->
TBrowser B
<!-- end SyntaxHighlightingPlugin -->
which has a Windows-like look and feel.
  • But if you just want to save the histograms, you could as well just paste the following in the root prompt
Line: 225 to 194
 
<!-- SyntaxHighlightingPlugin -->
.q
<!-- end SyntaxHighlightingPlugin -->

Next

Changed:
<
<
  • If you want to learn how to write an algorithm doing J/psi->mumu in C++ go to DaVinciTutorial2.
  • If you want to learn how to configure predefined algorithms doing the same thing go to DaVinciTutorial4 (recommended).
>
>
  • If you want to learn how to write an algorithm doing J/psi->mumu in C++ go to DaVinciTutorial2. (Advanced).
  • If you want to learn how to use existing options files, and existing C++, and our clever CombineParticles framework, move to DaVinciTutorial4.
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008

Revision 602010-01-28 - 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: 233 to 233
 -- PatrickKoppenburg - 05 Jan 2009

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="v24r3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.5"
>
>
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 592010-01-18 - RobLambert

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!

Revision 582010-01-08 - unknown

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: 14 to 14
 

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
GangaEnv
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
SetupProject Ganga
<!-- end SyntaxHighlightingPlugin -->
  and take the latest version (v600r17 at time of writing).
  • If you have last used ganga before version 5.1 you may need to do
<!-- SyntaxHighlightingPlugin -->
ganga -g
<!-- end SyntaxHighlightingPlugin -->

Revision 572009-11-25 - AnatolySolomin

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: 150 to 150
 

Data

First we need some data.
  • Open the feicim browser in ganga.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events. Double click on it, and "save". Check:
>
>
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events. Double click on it, and "save". Check:
 
<!-- SyntaxHighlightingPlugin -->
for i in data.files: print i
<!-- end SyntaxHighlightingPlugin -->
  • This will be a set of LFNs that you can pass to the job:
<!-- SyntaxHighlightingPlugin -->
t.inputdata = data
<!-- end SyntaxHighlightingPlugin -->
Line: 164 to 164
 if you have closed it you can reopen with:
!emacs $t.application.optsfile[0].name &

Submit

Changed:
<
<
  • Define a job, If you want the output to the terminal do:
>
>
  • Define a job. If you want the output to the terminal do:
 
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->
you can also use LSF, Local, Dirac... For small tests, interactive or local is usually best. For larger amounts of data, you'll need to run either on the LSF batch system or on the Grid.
  • Before you submit you can export the file:

Revision 562009-10-26 - 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: 137 to 137
 t.application.make() %ENDSYNTAX% ... and fix all compilation errors...
Added:
>
>

Warning

The above might not work, depending on the version of ganga. If all you get are cmt warnings about undefined versions, then leave ganga (ctrl-D) and do the following:
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci 
cd $ANALYSISROOT/cmt
cmt make
<!-- end SyntaxHighlightingPlugin -->
Once you fixed all compilation errors, go back into ganga and recover your job template:
<!-- SyntaxHighlightingPlugin -->
t=templates[-1]
<!-- end SyntaxHighlightingPlugin -->
 

Run!

Data

First we need some data.
Line: 166 to 175
 

Run it interactively

Alternatively you can run interactively on lxplus. To do so you must use the PFNs.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
gaudirun.py options/myOptions.py options/Bs2JpsiPhi2008.py
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
gaudirun.py options/myOptions.py options/MC09-InclJpsi.py
<!-- end SyntaxHighlightingPlugin -->
 

Look at the histograms

We'll do that outside of ganga... so exit back to shell.

Revision 552009-10-26 - 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: 8 to 8
 

Slides

This tutorial refers to the slides shown here.
Added:
>
>

Platform Warning

Ganga is not yet fully operational on slc5. We encourage newcomers to log in to lxplus4.cern.ch to run this tutorial.
 

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:

Revision 542009-10-05 - 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: 220 to 220
 -- PatrickKoppenburg - 05 Jan 2009

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="v24r2p3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2p1"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r3"
 
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.5"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 532009-10-02 - 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: 147 to 147
 We now need to configure the job in the main options file: %SYNTAX{ syntax="python"}%DaVinci().HistogramFile = "DVHistos_1.root" # Histogram file DaVinci().EvtMax = 1000 # Number of events
Changed:
<
<
DaVinci().DataType = "2009" # Default is "DC06". Should be MC09, but that's not supported yet
>
>
DaVinci().DataType = "MC09" # Default anyway
 DaVinci().Simulation = True # It's MC%ENDSYNTAX%
Changed:
<
<
if you have close it you can reopen with:
>
>
if you have closed it you can reopen with:
 
!emacs $t.application.optsfile[0].name &

Submit

  • Define a job, If you want the output to the terminal do:
Line: 220 to 220
 -- PatrickKoppenburg - 05 Jan 2009

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="v23r2p3"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v24r2p3"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.5"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 522009-10-02 - 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: 222 to 222
 
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"
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v23r2p3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2p1"
Changed:
<
<
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.4"
>
>
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.5"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 512009-10-02 - 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: 6 to 6
 

Slides

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
Line: 220 to 220
 -- PatrickKoppenburg - 05 Jan 2009

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="v23r1p1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.2.4"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v23r2p3"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.3.4"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 502009-06-16 - RuggeroTurra

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: 149 to 149
 DaVinci().EvtMax = 1000 # Number of events DaVinci().DataType = "2009" # Default is "DC06". Should be MC09, but that's not supported yet DaVinci().Simulation = True # It's MC%ENDSYNTAX%
Added:
>
>
if you have close it you can reopen with:
!emacs $t.application.optsfile[0].name &
 

Submit

  • Define a job, If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->

Revision 492009-06-16 - RuggeroTurra

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: 138 to 138
 

Data

First we need some data.
  • Open the feicim browser in ganga.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events.
>
>
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events. Double click on it, and "save". Check:
<!-- SyntaxHighlightingPlugin -->
for i in data.files: print i
<!-- end SyntaxHighlightingPlugin -->
 
  • This will be a set of LFNs that you can pass to the job:
<!-- SyntaxHighlightingPlugin -->
t.inputdata = data
<!-- end SyntaxHighlightingPlugin -->

Revision 482009-06-16 - unknown

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

Slides

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.

Revision 472009-06-15 - unknown

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: 219 to 219
 
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"
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v23r1p1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2"
Changed:
<
<
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.2.3"
>
>
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.2.4"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 462009-06-15 - unknown

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: 217 to 217
 -- PatrickKoppenburg - 05 Jan 2009

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="v23r1"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v23r1p1"
 
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.2.3"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 452009-06-12 - unknown

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: 45 to 45
 # # 2) Create the Tutorial Algorithm #
Changed:
<
<
from Configurables import TutorialAlgorithm, PhysDesktop
>
>
from Configurables import TutorialAlgorithm
 tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ]
Changed:
<
<
tutalg.addTool( PhysDesktop ) tutalg.PhysDesktop.InputLocations = [ "StdLooseMuons" ]
>
>
tutalg.InputLocations = [ "StdLooseMuons" ]
 # # 3) Configure the application. We'll come back to this later. #
Line: 57 to 56
 DaVinci().UserAlgorithms = [ tutorialseq ] %ENDSYNTAX%
Deleted:
<
<
In the past we advertised tutalg.addTool( PhysDesktop() ) and InputLocations = [ "Phys/StdLooseMuons" ]. This is deprecated. Correct it if you spot it.
 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.

Now we need to write the algorithm!

Line: 84 to 81
  if (sc) return sc;

setFilterPassed(true); // Set to true if event is accepted.

Changed:
<
<
return StatusCode::SUCCESS; }
>
>
return StatusCode::SUCCESS; }
 %ENDSYNTAX% Here we get the particles from the PhysDesktop tool and call our new method.
Line: 115 to 113
 
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::Container* pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->

  • And loop over them (inside the muons loop!):
Changed:
<
<
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::Container::const_iterator ipv = pvs->begin() ;
>
>
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::Container::const_iterator ipv = pvs->begin() ;
  ipv = pvs->end() ; ++ipv ){ double IP, IPchi2; if (msgLevel(MSG::DEBUG)) debug() << (*ipv)->position() << endmsg ;
Line: 139 to 138
 

Data

First we need some data.
  • Open the feicim browser in ganga.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events with J/psi->mumu.
>
>
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of MC09 MC with 5 TeV collisions, nu=1, closed velo, magnet on, with truth, simulation version 03, and inclusive J/psi events.
 
  • This will be a set of LFNs that you can pass to the job:
<!-- SyntaxHighlightingPlugin -->
t.inputdata = data
<!-- end SyntaxHighlightingPlugin -->
Line: 147 to 146
 We now need to configure the job in the main options file: %SYNTAX{ syntax="python"}%DaVinci().HistogramFile = "DVHistos_1.root" # Histogram file DaVinci().EvtMax = 1000 # Number of events
Changed:
<
<
DaVinci().DataType = "2008" # Default is "DC06"
>
>
DaVinci().DataType = "2009" # Default is "DC06". Should be MC09, but that's not supported yet
 DaVinci().Simulation = True # It's MC%ENDSYNTAX%

Submit

  • Define a job, If you want the output to the terminal do:
Line: 183 to 182
 TH1D* H1 = F->Get("TutorialAlgorithm/P") TH1D* H2 = F->Get("TutorialAlgorithm/Pt") TH1D* H3 = F->Get("TutorialAlgorithm/IP")
Changed:
<
<
TH1D* H4 = F->Get("TutorialAlgorithm/IPS")
>
>
TH1D* H4 = F->Get("TutorialAlgorithm/IPchi2")
  H1->SetLineColor(2) H1->SetLineWidth(3)
Line: 203 to 202
 H4->SetLineColor(2) H4->SetLineWidth(3) H4->Draw()
Changed:
<
<
gPad->SaveAs("DV1_IPS.eps");%ENDSYNTAX%
>
>
gPad->SaveAs("DV1_IPchi2.eps");%ENDSYNTAX%
  For sure one could do this shorter...
  • To quit root:
Line: 218 to 217
 -- PatrickKoppenburg - 05 Jan 2009

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="v22r1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r1p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.8"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v23r1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r2"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.2.3"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 442009-03-12 - unknown

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: 138 to 138
 

Run!

Data

First we need some data.
Changed:
<
<
  • Open the feicim browser.
<!-- SyntaxHighlightingPlugin -->
!~joel/public/lhcb_bkk
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events. Save the data sample as a python file.
  • This will be a set of LFNs. You can do two things with it:
    1. Create an LHCbDataset and declare it to your job. See the Ganga user guide. This is the only option if you want to run on the grid.
    2. Translate the LFNs to the appropriate PFNs. We have done that for you. See file options/Bs2JpsiPhi2008.py. You can then declare it as second option file for your job
<!-- SyntaxHighlightingPlugin -->
j.application.optsfile.append(File('~/cmtuser/DaVinci_HEAD/Tutorial/Analysis/options/Bs2JpsiPhi2008.py'))
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Open the feicim browser in ganga.
<!-- SyntaxHighlightingPlugin -->
data = browseBK()
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events with J/psi->mumu.
  • This will be a set of LFNs that you can pass to the job:
<!-- SyntaxHighlightingPlugin -->
t.inputdata = data
<!-- end SyntaxHighlightingPlugin -->
 

DaVinci()

We now need to configure the job in the main options file: %SYNTAX{ syntax="python"}%DaVinci().HistogramFile = "DVHistos_1.root" # Histogram file
Line: 220 to 219
 
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"
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v22r1"
Changed:
<
<
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.7"
>
>
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r1p1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.8"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 432009-03-11 - unknown

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: 48 to 48
 from Configurables import TutorialAlgorithm, PhysDesktop tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ]
Changed:
<
<
tutalg.addTool( PhysDesktop() )
>
>
tutalg.addTool( PhysDesktop )
 tutalg.PhysDesktop.InputLocations = [ "StdLooseMuons" ] # # 3) Configure the application. We'll come back to this later.
Line: 57 to 57
 DaVinci().UserAlgorithms = [ tutorialseq ] %ENDSYNTAX%
Added:
>
>
In the past we advertised tutalg.addTool( PhysDesktop() ) and InputLocations = [ "Phys/StdLooseMuons" ]. This is deprecated. Correct it if you spot it.
 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.

Now we need to write the algorithm!

Line: 217 to 219
 -- PatrickKoppenburg - 05 Jan 2009

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="v22r0p2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r0"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.5"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v22r1"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r1"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.7"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 422009-02-05 - unknown

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!

Deleted:
<
<

Warning

These pages are being rewritten for DaVinci v22r0 which was just released. To do the tutorial do
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci v22r0 --build-env
SetupProject DaVinci v22r0
<!-- end SyntaxHighlightingPlugin -->

Don't do this in the same shell as ganga, as DaVinci and ganga use incompatible python versions.

 

Slides

This tutorial refers to the slides shown here.
Line: 224 to 217
 -- PatrickKoppenburg - 05 Jan 2009

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="HEAD"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="head"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.3"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v22r0p2"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r0"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.5"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 412009-02-02 - JohanBlouw

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: 145 to 145
 First we need some data.
  • Open the feicim browser.
<!-- SyntaxHighlightingPlugin -->
!~joel/public/lhcb_bkk
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events. Save the data sample as a python file.
Changed:
<
<
  • This will be a set of LFNs. You can do tow things with it:
>
>
  • This will be a set of LFNs. You can do two things with it:
 
    1. Create an LHCbDataset and declare it to your job. See the Ganga user guide. This is the only option if you want to run on the grid.
    2. Translate the LFNs to the appropriate PFNs. We have done that for you. See file options/Bs2JpsiPhi2008.py. You can then declare it as second option file for your job
<!-- SyntaxHighlightingPlugin -->
j.application.optsfile.append(File('~/cmtuser/DaVinci_HEAD/Tutorial/Analysis/options/Bs2JpsiPhi2008.py'))
<!-- end SyntaxHighlightingPlugin -->

Revision 402009-01-20 - DavidHutchcroft

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

Warning

Changed:
<
<
These pages are being rewritten for DaVinci v22r0 which is not yet released. To do the tutorial do
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 --build-env
SetupProject DaVinci --nightly lhcb1
<!-- end SyntaxHighlightingPlugin -->
but first check here that the build succeeded if not, use the last day that compiled. For instance
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Tue
<!-- end SyntaxHighlightingPlugin -->
>
>
These pages are being rewritten for DaVinci v22r0 which was just released. To do the tutorial do
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci v22r0 --build-env
SetupProject DaVinci v22r0
<!-- end SyntaxHighlightingPlugin -->
  Don't do this in the same shell as ganga, as DaVinci and ganga use incompatible python versions.

Revision 392009-01-14 - unknown

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: 12 to 12
 but first check here that the build succeeded if not, use the last day that compiled. For instance
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Tue
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
Don't do this in the same shell as ganga, as DaVinci and ganga use incompatible python versions.
 

Slides

This tutorial refers to the slides shown here.

Revision 382009-01-14 - unknown

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

Warning

These pages are being rewritten for DaVinci v22r0 which is not yet released. To do the tutorial do
Changed:
<
<
%SYNTAX{ syntax="sh"}%setenvDaVinci HEAD
>
>
%SYNTAX{ syntax="sh"}%SetupProject DaVinci --nightly lhcb1 --build-env
 SetupProject DaVinci --nightly lhcb1%ENDSYNTAX% but first check here that the build succeeded if not, use the last day that compiled. For instance
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Tue
<!-- end SyntaxHighlightingPlugin -->
Line: 28 to 28
 
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}% t = JobTemplate( application = DaVinci( version = "v33r7" ))
Changed:
<
<
# t.application.setupProjectOptions = '--nightly lhcb' # add this if DaVinci version is HEAD
>
>
# t.application.setupProjectOptions = '--nightly lhcb1' # uncomment this if DaVinci version is HEAD
 t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.masterpackage = "Phys/DaVinci" t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/options/myOptions.py" )
Line: 37 to 37
 Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

Added:
>
>
  • First make sure you have the LHCb flavour of emacs. If not do what's described here.
 
  • Open the main options file (from ganga type:)
!emacs $t.application.optsfile[0].name &
  • Write in the options file.
Line: 67 to 70
 

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):
Changed:
<
<
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/src/TutorialAlgorithm.{cpp,h} &
>
>
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/src/TutorialAlgorithm.{cpp,h} &
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:

Revision 372009-01-14 - unknown

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: 10 to 10
 
<!-- SyntaxHighlightingPlugin -->
setenvDaVinci HEAD
SetupProject DaVinci --nightly lhcb1
<!-- end SyntaxHighlightingPlugin -->
but first check here that the build succeeded if not, use the last day that compiled. For instance
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Mon
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Tue
<!-- end SyntaxHighlightingPlugin -->
 

Slides

This tutorial refers to the slides shown here.
Line: 28 to 28
 
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}% t = JobTemplate( application = DaVinci( version = "v33r7" ))
Changed:
<
<
# t.application.setupProjectOptions = '--nightly lhcb1' # add this if DaVinci version is HEAD
>
>
# t.application.setupProjectOptions = '--nightly lhcb' # add this if DaVinci version is HEAD
 t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.masterpackage = "Phys/DaVinci" t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/options/myOptions.py" )

Revision 362009-01-08 - unknown

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: 49 to 49
 # # 2) Create the Tutorial Algorithm #
Changed:
<
<
rom Configurables import TutorialAlgorithm, PhysDesktop
>
>
from Configurables import TutorialAlgorithm, PhysDesktop
 tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ] tutalg.addTool( PhysDesktop() )
Line: 77 to 77
  %SYNTAX{ syntax="cpp"}% StatusCode TutorialAlgorithm::execute() {
Changed:
<
<
debug() << "==> Execute" << endmsg;
>
>
if (msgLevel(MSG::DEBUG)) debug() << "==> Execute" << endmsg;
  StatusCode sc = StatusCode::SUCCESS ;

// code goes here

Changed:
<
<
const LHCb::Particle::ConstVector & muons = desktop()->particles();
>
>
const LHCb::Particle::ConstVector muons = desktop()->particles();
  sc = loopOnMuons(muons); if (sc) return sc;
Line: 120 to 120
 %SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::Container::const_iterator ipv = pvs->begin() ; ipv = pvs->end() ; ++ipv ){ double IP, IPchi2;
Changed:
<
<
debug() << (*ipv)->position() << endmsg ;
>
>
if (msgLevel(MSG::DEBUG)) debug() << (*ipv)->position() << endmsg ;
  sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2); if (sc){ plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm); plot(IP/IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
Added:
>
>
if ( (*im)->pt()>2*Gaudi::Units::GeV) plot(IP, "IP_2", "Muon IP for PT>2GeV", 0., 10.*Gaudi::Units::mm);
  } }
Added:
>
>
 %ENDSYNTAX%

  • Now compile
Line: 217 to 220
 -- PatrickKoppenburg - 11 Mar 2008 -- PatrickKoppenburg - 05 Jan 2009
Added:
>
>
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"
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="HEAD"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="head"
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.3"

Revision 352009-01-07 - unknown

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: 9 to 9
 These pages are being rewritten for DaVinci v22r0 which is not yet released. To do the tutorial do
<!-- SyntaxHighlightingPlugin -->
setenvDaVinci HEAD
SetupProject DaVinci --nightly lhcb1
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
but first check here that the build succeeded if not, use the last day that compiled. For instance
<!-- SyntaxHighlightingPlugin -->
SetupProject DaVinci --nightly lhcb1 Mon
<!-- end SyntaxHighlightingPlugin -->
 

Slides

This tutorial refers to the slides shown here.

Revision 342009-01-05 - unknown

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: 133 to 133
 ... and fix all compilation errors...

Run!

Added:
>
>

Data

 First we need some data.
  • Open the feicim browser.
<!-- SyntaxHighlightingPlugin -->
!~joel/public/lhcb_bkk
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events. Save the data sample as a python file.
  • This will be a set of LFNs. You can do tow things with it:
    1. Create an LHCbDataset and declare it to your job. See the Ganga user guide. This is the only option if you want to run on the grid.
    2. Translate the LFNs to the appropriate PFNs. We have done that for you. See file options/Bs2JpsiPhi2008.py. You can then declare it as second option file for your job
Changed:
<
<

<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->

  • We don't want to run forever, so define the number of events:
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->

  • We want to save the histograms, so add the following line to your options:
<!-- SyntaxHighlightingPlugin -->
HistogramPersistencySvc().OutputFile = "DVHistos_1.root"
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
j.application.optsfile.append(File('~/cmtuser/DaVinci_HEAD/Tutorial/Analysis/options/Bs2JpsiPhi2008.py'))
<!-- end SyntaxHighlightingPlugin -->

DaVinci()

We now need to configure the job in the main options file:
<!-- SyntaxHighlightingPlugin -->
DaVinci().HistogramFile = "DVHistos_1.root"    # Histogram file
DaVinci().EvtMax = 1000                        # Number of events
DaVinci().DataType = "2008"                    # Default is "DC06"
DaVinci().Simulation   = True                  # It's MC
<!-- end SyntaxHighlightingPlugin -->

Submit

 
  • Define a job, If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->
you can also use LSF, Local, Dirac... For small tests, interactive or local is usually best. For larger amounts of data, you'll need to run either on the LSF batch system or on the Grid.
Line: 164 to 158
 
<!-- SyntaxHighlightingPlugin -->
j.submit()
<!-- end SyntaxHighlightingPlugin -->

Run it interactively

Changed:
<
<
Alternatively you can run interactively on lxplus. To do so you must
  • get the PFN from the bookkeeping, not the LFN
  • run
gaudirun.py options/myOptions.py
>
>
Alternatively you can run interactively on lxplus. To do so you must use the PFNs.
<!-- SyntaxHighlightingPlugin -->
gaudirun.py options/myOptions.py options/Bs2JpsiPhi2008.py
<!-- end SyntaxHighlightingPlugin -->
 

Look at the histograms

We'll do that outside of ganga... so exit back to shell.
  • Source the root setup scripts
Changed:
<
<
SetupProject Gaudi ROOT
>
>
<!-- SyntaxHighlightingPlugin -->
SetupProject Gaudi ROOT
<!-- end SyntaxHighlightingPlugin -->
 
  • Open root
Changed:
<
<
root.exe
>
>
<!-- SyntaxHighlightingPlugin -->
root.exe
<!-- end SyntaxHighlightingPlugin -->
 
  • The simplest way to look at histograms is to use the TBrowser.
<!-- SyntaxHighlightingPlugin -->
TBrowser B
<!-- end SyntaxHighlightingPlugin -->
which has a Windows-like look and feel.
Line: 217 to 207
 
  • To quit root:
<!-- SyntaxHighlightingPlugin -->
.q
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<

Go to DaVinciTutorial2

>
>

Next

  • If you want to learn how to write an algorithm doing J/psi->mumu in C++ go to DaVinciTutorial2.
  • If you want to learn how to configure predefined algorithms doing the same thing go to DaVinciTutorial4 (recommended).
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Added:
>
>
-- PatrickKoppenburg - 05 Jan 2009
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="HEAD"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="head"

Revision 332009-01-05 - unknown

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: 26 to 26
 
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}% t = JobTemplate( application = DaVinci( version = "v33r7" ))
Added:
>
>
# t.application.setupProjectOptions = '--nightly lhcb1' # add this if DaVinci version is HEAD
 t.application.getpack( "Tutorial/Analysis v10r6" )
Deleted:
<
<
t.application.getpack( "Phys/DaVinci v33r7" )
 t.application.masterpackage = "Phys/DaVinci" t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/options/myOptions.py" ) t.application.make()
Line: 38 to 38
 
  • Open the main options file (from ganga type:)
!emacs $t.application.optsfile[0].name &
  • Write in the options file.
Changed:
<
<
%SYNTAX{ syntax="python"}%from os import environ from Gaudi.Configuration import *
>
>
%SYNTAX{ syntax="python"}%from Gaudi.Configuration import *
 #
Changed:
<
<
# we'll need this later
>
>
# 1) Let's define a sequence
 #
Changed:
<
<
from Configurables import TutorialAlgorithm, PhysDesktop
>
>
from Configurables import GaudiSequencer tutorialseq = GaudiSequencer("TutorialSeq")
 #
Changed:
<
<
# standard options
>
>
# 2) Create the Tutorial Algorithm
 #
Changed:
<
<
importOptions( "$DAVINCIROOT/options/DaVinciCommon.opts" )
>
>
rom Configurables import TutorialAlgorithm, PhysDesktop tutalg = TutorialAlgorithm() tutorialseq.Members += [ tutalg ] tutalg.addTool( PhysDesktop() ) tutalg.PhysDesktop.InputLocations = [ "StdLooseMuons" ]
 #
Changed:
<
<
# Let's make it a sequence
>
>
# 3) Configure the application. We'll come back to this later.
 #
Changed:
<
<
ApplicationMgr().TopAlg += [ "GaudiSequencer/TutorialSeq" ] # # J/psi->mumu selection # GaudiSequencer("TutorialSeq").Members += [ "TutorialAlgorithm" ] TutorialAlgorithm().addTool( PhysDesktop() ) TutorialAlgorithm().PhysDesktop.InputLocations = [ "Phys/StdLooseMuons" ]%ENDSYNTAX%
>
>
from Configurables import DaVinci DaVinci().UserAlgorithms = [ tutorialseq ] %ENDSYNTAX%
  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.
Line: 134 to 134
 

Run!

First we need some data.
Changed:
<
<
  1. Click Dataset search
  2. Select Configuration : DC06 - phys-v2-lumi2
  3. Select Event type : 13144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
  4. Datatype : DST1
  5. Step 3 : Brunel - v30r17 (or more recent)
  6. Datasets replicated at : CERN (if you're not yet running on the grid, else anywhere)
  7. Logical File Names
  8. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
  9. Paste the data into your options and slightly edit the syntax. It should look like this
<!-- SyntaxHighlightingPlugin -->
EventSelector( PrintFreq    = 50,
               FirstEvent   = 1,
               Input        = [
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000001_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000002_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000003_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000004_5.dst' TYP='POOL_ROOTTREE' OPT='READ'" ]
              )
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Open the feicim browser.
<!-- SyntaxHighlightingPlugin -->
!~joel/public/lhcb_bkk
<!-- end SyntaxHighlightingPlugin -->
and navigate to a data sample of 2008 MC with 7 TeV collisions, closed velo, field on, and Bs->J/psi Phi events. Save the data sample as a python file.
  • This will be a set of LFNs. You can do tow things with it:
    1. Create an LHCbDataset and declare it to your job. See the Ganga user guide. This is the only option if you want to run on the grid.
    2. Translate the LFNs to the appropriate PFNs. We have done that for you. See file options/Bs2JpsiPhi2008.py. You can then declare it as second option file for your job

 
Changed:
<
<
Note that if you want to run on the grid you will need to create an LHCbDataset using logical file names. See the Ganga user guide.
>
>

<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->
 
  • We don't want to run forever, so define the number of events:
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->
Line: 192 to 185
 c1->SetLogy(); TFile* F = new TFile("DVHistos_1.root")%ENDSYNTAX% and make sure you give the correct path for your file! And then
Changed:
<
<
%SYNTAX{ syntax="cpp"}F->ls()
>
>
%SYNTAX{ syntax="cpp"}%F->ls()
 F->cd("TutorialAlgorithm") F->ls() TH1D* H1 = F->Get("TutorialAlgorithm/P")
Line: 218 to 211
 H4->SetLineColor(2) H4->SetLineWidth(3) H4->Draw()
Changed:
<
<
gPad->SaveAs("DV1_IPS.eps"); %ENDSYNTAX%
>
>
gPad->SaveAs("DV1_IPS.eps");%ENDSYNTAX%
  For sure one could do this shorter...
  • To quit root:
Line: 231 to 223
 -- PatrickKoppenburg - 11 Mar 2008

META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="HEAD"
Changed:
<
<
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="HEAD"
>
>
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="head"
 
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.3"
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 322009-01-05 - unknown

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

DaVinci Tutorial 1

Changed:
<
<
We start with a very simple algorithm that looks at muons and fills some histograms.
>
>
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: 18 to 18
 
  • Set environment for Ganga:
<!-- SyntaxHighlightingPlugin -->
GangaEnv
<!-- end SyntaxHighlightingPlugin -->
and take the latest version (v600r17 at time of writing).
Changed:
<
<
  • Create a fresh configuration file
ganga -g
>
>
  • If you have last used ganga before version 5.1 you may need to do
<!-- SyntaxHighlightingPlugin -->
ganga -g
<!-- end SyntaxHighlightingPlugin -->
 
  • Now start an interactive session:
Changed:
<
<
ganga
>
>
<!-- SyntaxHighlightingPlugin -->
ganga
<!-- end SyntaxHighlightingPlugin -->
 You will be prompted for your grid password.
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}%
Line: 232 to 232
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="HEAD"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="HEAD"
Added:
>
>
META PREFERENCE name="GANGAVERSION" title="GANGAVERSION" type="Set" value="5.1.3"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 312009-01-05 - unknown

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.
Line: 11 to 11
 SetupProject DaVinci --nightly lhcb1%ENDSYNTAX%

Slides

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
Changed:
<
<
GangaEnv 5.0.8
Usually you can just select the default value from GangaEnv but for today please use the specific version above.
>
>
<!-- SyntaxHighlightingPlugin -->
GangaEnv
<!-- end SyntaxHighlightingPlugin -->
and take the latest version (v600r17 at time of writing).
 
  • Create a fresh configuration file
ganga -g
  • Now start an interactive session:
Line: 230 to 230
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v22r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r0"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="HEAD"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="HEAD"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 302009-01-05 - unknown

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.

Added:
>
>

Warning

These pages are being rewritten for DaVinci v22r0 which is not yet released. To do the tutorial do
<!-- SyntaxHighlightingPlugin -->
setenvDaVinci HEAD
SetupProject DaVinci --nightly lhcb1
<!-- end SyntaxHighlightingPlugin -->
 

Slides

This tutorial refers to the slides shown here.
Line: 225 to 230
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v21r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r7"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v22r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v8r0"
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 292008-12-23 - unknown

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.
Line: 227 to 227
 
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v21r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r7"
Added:
>
>
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 282008-12-18 - unknown

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.
Line: 23 to 23
 t = JobTemplate( application = DaVinci( version = "v33r7" )) t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.getpack( "Phys/DaVinci v33r7" )
Changed:
<
<
t.application.masterpackage = "Phys/DaVinci/v33r7" t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.py" )
>
>
t.application.masterpackage = "Phys/DaVinci" t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/options/myOptions.py" )
 t.application.make() %ENDSYNTAX% Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

Changed:
<
<
  • Open the main options file
<!-- SyntaxHighlightingPlugin -->
!emacs $t.application.optsfile[0].name & 
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Open the main options file (from ganga type:)
!emacs $t.application.optsfile[0].name &
 
  • Write in the options file.
%SYNTAX{ syntax="python"}%from os import environ from Gaudi.Configuration import *
Line: 59 to 59
 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.
Changed:
<
<
  • Open the files for your algorithm:
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Open the files for your algorithm (from the shell type):
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/src/TutorialAlgorithm.{cpp,h} &
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:

Revision 272008-11-26 - unknown

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.
Line: 24 to 24
 t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.getpack( "Phys/DaVinci v33r7" ) t.application.masterpackage = "Phys/DaVinci/v33r7"
Changed:
<
<
t.application.optsfile = [ "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.py" ]
>
>
t.application.optsfile = File( "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.py" )
 t.application.make() %ENDSYNTAX% Be very careful not to copy-paste leading spaces; python does not like that at all.
Line: 105 to 105
 } %ENDSYNTAX%
Changed:
<
<
  • Now get the primary vertices (outside the muons loop):
>
>
  • Now get the primary vertices (before the muons loop):
 
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::ConstVector & pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::Container* pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
 
Changed:
<
<
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv = pvs.begin() ; ipv = pvs.end() ; ++ipv ){
>
>
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::Container::const_iterator ipv = pvs->begin() ; ipv = pvs->end() ; ++ipv ){
  double IP, IPchi2; debug() << (*ipv)->position() << endmsg ; sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2);
Line: 225 to 225
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v20r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r5"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v21r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r7"

Revision 262008-10-10 - AngelaBuechler

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
Changed:
<
<
GangaEnv 5.0.0 -pre
>
>
GangaEnv 5.0.8
  Usually you can just select the default value from GangaEnv but for today please use the specific version above.
  • Create a fresh configuration file
ganga -g

Revision 252008-09-17 - MarcoCattaneo

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.

Revision 242008-08-12 - unknown

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.
Line: 117 to 117
  sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2); if (sc){ plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm);
Changed:
<
<
if (IPE>0.) plot(IP/IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
>
>
plot(IP/IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
  } } %ENDSYNTAX%
Line: 225 to 225
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r2"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v20r0"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r5"

Revision 232008-08-12 - unknown

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.
Line: 109 to 109
 
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::ConstVector & pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv = pvs.begin() ; ipv = pvs.end() ; ++ipv ){ double IP, IPE;
>
>
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv = pvs.begin() ; ipv = pvs.end() ; ++ipv ){ double IP, IPchi2;
  debug() << (*ipv)->position() << endmsg ;
Changed:
<
<
sc = geomDispCalculator()->calcImpactPar(*(*im), *(*ipv), IP, IPE);
>
>
sc = distanceCalculator()->distance((*im), (*ipv), IP, IPchi2);
  if (sc){ plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm);
Changed:
<
<
if (IPE>0.) plot(IP/IPE, "IPS", "Muon IP/error", 0., 10.);
>
>
if (IPE>0.) plot(IP/IPchi2, "IPchi2", "Muon chi2 IP", 0., 10.);
  }
Changed:
<
<
}%ENDSYNTAX%
>
>
} %ENDSYNTAX%
 
  • Now compile
%SYNTAX{ syntax="python"}%

Revision 222008-08-11 - AngelaBuechler

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.

Revision 212008-06-17 - unknown

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.
Line: 107 to 107
 
  • Now get the primary vertices (outside the muons loop):
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
LHCb::RecVertex::ConstVector & pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
const LHCb::RecVertex::ConstVector & pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
 
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv =

Revision 202008-06-16 - unknown

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

// code goes here

Changed:
<
<
LHCb::Particle::ConstVector & muons = desktop()->particles();
>
>
const LHCb::Particle::ConstVector & muons = desktop()->particles();
  sc = loopOnMuons(muons); if (sc) return sc;
Line: 153 to 153
 
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->

  • We want to save the histograms, so add the following line to your options:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
HistogramPersistencySvc().OutputFile = "DVHistos_1.root"
<!-- end SyntaxHighlightingPlugin -->
 
  • Define a job, If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->

Revision 192008-06-16 - UlrikEgede

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
Changed:
<
<
GangaEnv
  • Start an interactive session:
>
>
GangaEnv 5.0.0-pre
Usually you can just select the default value from GangaEnv but for today please use the specific version above.
  • Create a fresh configuration file
ganga -g
  • Now start an interactive session:
 
ganga
You will be prompted for your grid password.
  • At the ganga prompt type:

Revision 182008-06-13 - unknown

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.
Line: 216 to 216
 
  • To quit root:
<!-- SyntaxHighlightingPlugin -->
.q
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
>
>

Go to DaVinciTutorial2

  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008

Revision 172008-06-13 - unknown

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.
Line: 21 to 21
 t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.getpack( "Phys/DaVinci v33r7" ) t.application.masterpackage = "Phys/DaVinci/v33r7"
Changed:
<
<
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.opts" )
>
>
t.application.optsfile = [ "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.py" ]
 t.application.make() %ENDSYNTAX% Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

  • Open the main options file
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
!emacs $t.application.optsfile.name & 
<!-- end SyntaxHighlightingPlugin -->
  • Write in the options file:
<!-- SyntaxHighlightingPlugin -->
#include "$DAVINCIROOT/options/DaVinciCommon.opts" 
// 
// Let's make it a sequence 
// 
ApplicationMgr.TopAlg += { "GaudiSequencer/TutorialSeq" }; 
// 
// J/psi->mumu selection 
// 
TutorialSeq.Members += { "TutorialAlgorithm" }; 
// 
// Get the input data : all muons. 
// 
TutorialAlgorithm.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" };
TutorialAlgorithm.UseSequencialNumericAutoIDs = true ; /// to get the root macro to work
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
!emacs $t.application.optsfile[0].name & 
<!-- end SyntaxHighlightingPlugin -->
  • Write in the options file.
<!-- SyntaxHighlightingPlugin -->
from os import environ
from Gaudi.Configuration import *
#
# we'll need this later
#
from Configurables import TutorialAlgorithm, PhysDesktop
#
# standard options
#
importOptions( "$DAVINCIROOT/options/DaVinciCommon.opts" )
#
# Let's make it a sequence
#
ApplicationMgr().TopAlg += [ "GaudiSequencer/TutorialSeq" ]
#
# J/psi->mumu selection
#
GaudiSequencer("TutorialSeq").Members += [ "TutorialAlgorithm" ]
TutorialAlgorithm().addTool( PhysDesktop() )
TutorialAlgorithm().PhysDesktop.InputLocations = [ "Phys/StdLooseMuons" ]
<!-- end SyntaxHighlightingPlugin -->
  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.
Line: 128 to 134
 
  1. Datasets replicated at : CERN (if you're not yet running on the grid, else anywhere)
  2. Logical File Names
  3. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
Changed:
<
<
  1. Paste the data into your options.
>
>
  1. Paste the data into your options and slightly edit the syntax. It should look like this
<!-- SyntaxHighlightingPlugin -->
EventSelector( PrintFreq    = 50,
               FirstEvent   = 1,
               Input        = [
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000001_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000002_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000003_5.dst' TYP='POOL_ROOTTREE' OPT='READ'",
"DATAFILE='LFN:/lhcb/production/DC06/phys-v2-lumi2/00001758/DST/0000/00001758_00000004_5.dst' TYP='POOL_ROOTTREE' OPT='READ'" ]
              )
<!-- end SyntaxHighlightingPlugin -->
  Note that if you want to run on the grid you will need to create an LHCbDataset using logical file names. See the Ganga user guide.

  • We don't want to run forever, so define the number of events:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr.EvtMax = 1000 ;
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->
 
  • We want to save the histograms, so add the following line to your options:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
HistogramPersistencySvc.OutputFile = "DVHistos.root";
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr().EvtMax = 1000
<!-- end SyntaxHighlightingPlugin -->
 
  • Define a job, If you want the output to the terminal do:
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->

Revision 162008-06-12 - unknown

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.
Line: 147 to 147
 
  • Submit the job
<!-- SyntaxHighlightingPlugin -->
j.submit()
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>

Run it interactively

Alternatively you can run interactively on lxplus. To do so you must
  • get the PFN from the bookkeeping, not the LFN
  • run
gaudirun.py options/myOptions.py
 

Look at the histograms

We'll do that outside of ganga... so exit back to shell.
  • Source the root setup scripts
Line: 201 to 207
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 11 Mar 2008
Changed:
<
<
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r11"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r0"
>
>
META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r13"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r2"

Revision 152008-04-10 - unknown

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

Slides

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

Creating Ganga template for DaVinci jobs, and initial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.

Revision 142008-04-10 - ChristopherRJones

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

// code goes here

Changed:
<
<
LHCb::Particle::ConstVector muons = desktop()->particles();
>
>
LHCb::Particle::ConstVector & muons = desktop()->particles();
  sc = loopOnMuons(muons); if (sc) return sc;
Line: 98 to 98
 
  • Now get the primary vertices (outside the muons loop):
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
LHCb::RecVertex::ConstVector pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
LHCb::RecVertex::ConstVector & pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
 
  • And loop over them (inside the muons loop!):
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv =

Revision 132008-04-10 - unknown

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.
Line: 20 to 20
 t = JobTemplate( application = DaVinci( version = "v33r7" )) t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.getpack( "Phys/DaVinci v33r7" )
Changed:
<
<
t.application.masterpackage = "DaVinci v33r7 Phys"
>
>
t.application.masterpackage = "Phys/DaVinci/v33r7"
 t.application.optsfile = File( name = "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.opts" ) t.application.make() %ENDSYNTAX%
Line: 130 to 130
 
  1. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
  2. Paste the data into your options.
Changed:
<
<
Note that if you want to run on the grid you will need to create an LHCbDataSet using logical file names. See the Ganga user guide.
>
>
Note that if you want to run on the grid you will need to create an LHCbDataset using logical file names. See the Ganga user guide.
 
  • We don't want to run forever, so define the number of events:
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr.EvtMax = 1000 ;
<!-- end SyntaxHighlightingPlugin -->

Revision 122008-03-11 - unknown

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.
Line: 18 to 18
 
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}% t = JobTemplate( application = DaVinci( version = "v33r7" ))
Changed:
<
<
t.application.getpack( "Tutorial/Analysis v7r0" ) t.application.getpack( "Phys/DaVinci v19r11" ) t.application.masterpackage = "DaVinci v19r11 Phys" t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r11/Tutorial/Analysis/v7r0/options/myOptions.opts" )
>
>
t.application.getpack( "Tutorial/Analysis v10r6" ) t.application.getpack( "Phys/DaVinci v33r7" ) t.application.masterpackage = "DaVinci v33r7 Phys" t.application.optsfile = File( name = "~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/options/myOptions.opts" )
 t.application.make() %ENDSYNTAX% Be very careful not to copy-paste leading spaces; python does not like that at all.
Line: 51 to 51
 

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:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v19r11/Tutorial/Analysis/v7r0/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v33r7/Tutorial/Analysis/v10r6/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:
Line: 199 to 199
 

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

Added:
>
>
-- PatrickKoppenburg - 11 Mar 2008

META PREFERENCE name="DAVINCIVERSION" title="DAVINCIVERSION" type="Set" value="v19r11"
META PREFERENCE name="TUTORIALVERSION" title="TUTORIALVERSION" type="Set" value="v7r0"

Revision 112008-03-11 - unknown

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.
Line: 17 to 17
 You will be prompted for your grid password.
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}%
Changed:
<
<
t = JobTemplate( application = DaVinci( version = "v19r11" ))
>
>
t = JobTemplate( application = DaVinci( version = "v33r7" ))
 t.application.getpack( "Tutorial/Analysis v7r0" ) t.application.getpack( "Phys/DaVinci v19r11" ) t.application.masterpackage = "DaVinci v19r11 Phys"

Revision 102008-03-11 - unknown

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.
Line: 17 to 17
 You will be prompted for your grid password.
  • At the ganga prompt type:
%SYNTAX{ syntax="python"}%
Changed:
<
<
t = JobTemplate( application = DaVinci( version = "v19r5" )) t.application.getpack( "Tutorial/Analysis v6r4" ) t.application.getpack( "Phys/DaVinci v19r5" ) t.application.masterpackage = "DaVinci v19r5 Phys" t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/options/myOptions.opts" )
>
>
t = JobTemplate( application = DaVinci( version = "v19r11" )) t.application.getpack( "Tutorial/Analysis v7r0" ) t.application.getpack( "Phys/DaVinci v19r11" ) t.application.masterpackage = "DaVinci v19r11 Phys" t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r11/Tutorial/Analysis/v7r0/options/myOptions.opts" )
 t.application.make() %ENDSYNTAX% Be very careful not to copy-paste leading spaces; python does not like that at all.
Line: 51 to 51
 

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:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v19r11/Tutorial/Analysis/v7r0/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:

Revision 92008-03-04 - unknown

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.
Line: 31 to 31
 
<!-- SyntaxHighlightingPlugin -->
!emacs $t.application.optsfile.name & 
<!-- end SyntaxHighlightingPlugin -->
  • Write in the options file:
%SYNTAX{ syntax="cpp"}%#include "$DAVINCIROOT/options/DaVinciCommon.opts"
Deleted:
<
<
// load options for creation of "standard muons": #include "$COMMONPARTICLESROOT/options/StandardMuons.opts"
 // // Let's make it a sequence //
Line: 44 to 42
 // // Get the input data : all muons. //
Changed:
<
<
InputLocations = { "Phys/StdLooseMuons" };%ENDSYNTAX%
>
>
InputLocations = { "Phys/StdLooseMuons" }; UseSequencialNumericAutoIDs = true ; /// to get the root macro to work%ENDSYNTAX%
  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.
Line: 91 to 90
 
  • In the method add:
%SYNTAX{ syntax="cpp"}% for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
Changed:
<
<
plot((*im)->p(), "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum plot((*im)->pt(), "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt
>
>
plot((*im)->p(), "P", "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum plot((*im)->pt(), "Pt", "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt
  debug() << "Mu Momentum: " << (*im)->momentum() << endmsg ; } %ENDSYNTAX%
Line: 108 to 107
  debug() << (*ipv)->position() << endmsg ; sc = geomDispCalculator()->calcImpactPar(*(*im), *(*ipv), IP, IPE); if (sc){
Changed:
<
<
plot(IP, "Muon IP", 0., 10.*Gaudi::Units::mm); if (IPE>0.) plot(IP/IPE, "Muon IP/error", 0., 10.);
>
>
plot(IP, "IP", "Muon IP", 0., 10.*Gaudi::Units::mm); if (IPE>0.) plot(IP/IPE, "IPS", "Muon IP/error", 0., 10.);
  } }%ENDSYNTAX%
Line: 162 to 161
 
  • But if you just want to save the histograms, you could as well just paste the following in the root prompt
%SYNTAX{ syntax="cpp"}%TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); c1->SetLogy();
Changed:
<
<
TFile* F = new TFile("DVHistos.root")%ENDSYNTAX%
>
>
TFile* F = new TFile("DVHistos_1.root")%ENDSYNTAX%
 and make sure you give the correct path for your file! And then
Changed:
<
<
%SYNTAX{ syntax="cpp"}%F->ls()
>
>
%SYNTAX{ syntax="cpp"}F->ls()
 F->cd("TutorialAlgorithm") F->ls()
Changed:
<
<
TH1D* H1 = F->Get("TutorialAlgorithm/1") TH1D* H2 = F->Get("TutorialAlgorithm/2") TH1D* H3 = F->Get("TutorialAlgorithm/3") TH1D* H4 = F->Get("TutorialAlgorithm/4")
>
>
TH1D* H1 = F->Get("TutorialAlgorithm/P") TH1D* H2 = F->Get("TutorialAlgorithm/Pt") TH1D* H3 = F->Get("TutorialAlgorithm/IP") TH1D* H4 = F->Get("TutorialAlgorithm/IPS")
 H1->SetLineColor(2) H1->SetLineWidth(3) H1->Draw()
Changed:
<
<
gPad->SaveAs("H1.eps");
>
>
gPad->SaveAs("DV1_P.eps");
 H2->SetLineColor(2) H2->SetLineWidth(3) H2->Draw()
Changed:
<
<
gPad->SaveAs("H2.eps");
>
>
gPad->SaveAs("DV1_Pt.eps");
 H3->SetLineColor(2) H3->SetLineWidth(3) H3->Draw()
Changed:
<
<
gPad->SaveAs("H3.eps");
>
>
gPad->SaveAs("DV1_IP.eps");
 H4->SetLineColor(2) H4->SetLineWidth(3) H4->Draw()
Changed:
<
<
gPad->SaveAs("H4.eps");
>
>
gPad->SaveAs("DV1_IPS.eps");
 %ENDSYNTAX%

For sure one could do this shorter...

Revision 82008-03-02 - AnatolySolomin

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

Slides

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

Creating Ganga template for DaVinci jobs, and intitial package build.

>
>

Creating Ganga template for DaVinci jobs, and initial package build.

 You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
GangaEnv
Line: 123 to 123
 
  1. Click Dataset search
  2. Select Configuration : DC06 - phys-v2-lumi2
Changed:
<
<
  1. Select Event type : 12144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
>
>
  1. Select Event type : 13144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
 
  1. Datatype : DST1
  2. Step 3 : Brunel - v30r17 (or more recent)
  3. Datasets replicated at : CERN (if you're not yet running on the grid, else anywhere)

Revision 72007-11-19 - unknown

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.

Added:
>
>

Slides

This tutorial refers to the slides shown here.
 

Creating Ganga template for DaVinci jobs, and intitial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:

Revision 62007-10-09 - unknown

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.
Line: 169 to 169
 TH1D* H3 = F->Get("TutorialAlgorithm/3") TH1D* H4 = F->Get("TutorialAlgorithm/4") H1->SetLineColor(2)
Changed:
<
<
H1->SetLineWidth(3) %ENDSYNTAX%
>
>
H1->SetLineWidth(3)
 H1->Draw() gPad->SaveAs("H1.eps"); H2->SetLineColor(2)

Revision 52007-10-05 - unknown

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.
Line: 123 to 123
 
  1. Select Event type : 12144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
  2. Datatype : DST1
  3. Step 3 : Brunel - v30r17 (or more recent)
Changed:
<
<
  1. Datasets replicated at : CERN (that's assuming you're not yet running on the grid)
  2. Physical File Names Protocol: castor
>
>
  1. Datasets replicated at : CERN (if you're not yet running on the grid, else anywhere)
  2. Logical File Names
 
  1. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
  2. Paste the data into your options.

Revision 42007-10-04 - unknown

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

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:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
!emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
%SYNTAX{ syntax="cpp"}%private:
Line: 71 to 71
  return StatusCode::SUCCESS; } %ENDSYNTAX% Here we get the particles from the PhysDesktop tool and call our new method.
Changed:
<
<
  • Now implement the method in the cpp file:
>
>
  • Now implement the method in the cpp file. You can get a template method typing insert M in emacs. You then have to replace the type void by StatusCode and declare the arguments:
 %SYNTAX{ syntax="cpp"}% //==================================================== // loop on muons
Line: 122 to 123
 
  1. Select Event type : 12144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
  2. Datatype : DST1
  3. Step 3 : Brunel - v30r17 (or more recent)
Changed:
<
<
  1. Datasets replicated at : Anywhere
>
>
  1. Datasets replicated at : CERN (that's assuming you're not yet running on the grid)
  2. Physical File Names Protocol: castor
 
  1. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
  2. Paste the data into your options.
Added:
>
>
Note that if you want to run on the grid you will need to create an LHCbDataSet using logical file names. See the Ganga user guide.
 
  • We don't want to run forever, so define the number of events:
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr.EvtMax = 1000 ;
<!-- end SyntaxHighlightingPlugin -->

Revision 32007-10-02 - unknown

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.
Line: 13 to 13
 
ganga
You will be prompted for your grid password.
  • At the ganga prompt type:
Changed:
<
<
t = JobTemplate( application = DaVinci( version = "v19r5" ))
t.application.getpack( "Tutorial/Analysis v6r4" )
t.application.getpack( "Phys/DaVinci v19r5" )
t.application.masterpackage = "DaVinci v19r5 Phys"
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/options/myOptions.opts" )
t.application.make()
>
>
<!-- SyntaxHighlightingPlugin -->
t = JobTemplate( application = DaVinci( version = "v19r5" ))
t.application.getpack( "Tutorial/Analysis v6r4" )
t.application.getpack( "Phys/DaVinci v19r5" )
t.application.masterpackage = "DaVinci v19r5 Phys"
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/options/myOptions.opts" )
t.application.make()
<!-- end SyntaxHighlightingPlugin -->
 Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

  • Open the main options file
Changed:
<
<
!emacs $t.application.optsfile.name &
>
>
<!-- SyntaxHighlightingPlugin -->
!emacs $t.application.optsfile.name & 
<!-- end SyntaxHighlightingPlugin -->
 
  • Write in the options file:
Changed:
<
<
|
#include "$DAVINCIROOT/options/DaVinciCommon.opts" 

>
>
%SYNTAX{ syntax="cpp"}%#include "$DAVINCIROOT/options/DaVinciCommon.opts"
 // load options for creation of "standard muons": #include "$COMMONPARTICLESROOT/options/StandardMuons.opts" //
Line: 34 to 41
 // // Get the input data : all muons. //
Changed:
<
<
InputLocations = { "Phys/StdLooseMuons" };|
>
>
InputLocations = { "Phys/StdLooseMuons" };%ENDSYNTAX%
  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.
Line: 42 to 49
 

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:
Changed:
<
<
!emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} &
>
>
<!-- SyntaxHighlightingPlugin -->
emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} & 
<!-- end SyntaxHighlightingPlugin -->
 Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
Changed:
<
<
private:
StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
>
>
<!-- SyntaxHighlightingPlugin -->
private:
  StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
<!-- end SyntaxHighlightingPlugin -->
 
  • Now let's add something to the execute method in the cpp:
Changed:
<
<
|
StatusCode TutorialAlgorithm::execute() {

>
>
%SYNTAX{ syntax="cpp"}% StatusCode TutorialAlgorithm::execute() {
  debug() << "==> Execute" << endmsg; StatusCode sc = StatusCode::SUCCESS ;
Line: 57 to 68
  if (sc) return sc;

setFilterPassed(true); // Set to true if event is accepted.

Changed:
<
<
return StatusCode::SUCCESS; }|
>
>
return StatusCode::SUCCESS; } %ENDSYNTAX%
 Here we get the particles from the PhysDesktop tool and call our new method.
  • Now implement the method in the cpp file:
Changed:
<
<
|
//==================================================== 

>
>
%SYNTAX{ syntax="cpp"}% //====================================================
 // loop on muons //==================================================== StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::ConstVector& muons)const {
Line: 69 to 82
  // code goes here

return sc ;

Changed:
<
<
}|
>
>
} %ENDSYNTAX%
 
  • In the method add:
Changed:
<
<
|
for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im != muons.end() ; ++im ){

>
>
%SYNTAX{ syntax="cpp"}% for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im = muons.end() ; ++im ){
  plot((*im)->p(), "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum plot((*im)->pt(), "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt debug() << "Mu Momentum: " << (*im)->momentum() << endmsg ;
Changed:
<
<
}|
>
>
} %ENDSYNTAX%
 
  • Now get the primary vertices (outside the muons loop):
Changed:
<
<
LHCb::RecVertex::ConstVector pvs = desktop()->primaryVertices();
>
>
<!-- SyntaxHighlightingPlugin -->
LHCb::RecVertex::ConstVector pvs = desktop()->primaryVertices();
<!-- end SyntaxHighlightingPlugin -->
 
  • And loop over them (inside the muons loop!):
Changed:
<
<
|
 for ( LHCb::RecVertex::ConstVector::const_iterator ipv = 

>
>
%SYNTAX{ syntax="cpp"}% for ( LHCb::RecVertex::ConstVector::const_iterator ipv =
  pvs.begin() ; ipv = pvs.end() ; ++ipv ){ double IP, IPE; debug() << (*ipv)->position() << endmsg ;
Line: 90 to 107
  plot(IP, "Muon IP", 0., 10.*Gaudi::Units::mm); if (IPE>0.) plot(IP/IPE, "Muon IP/error", 0., 10.); }
Changed:
<
<
}|
>
>
}%ENDSYNTAX%
 
  • Now compile
Changed:
<
<
t.application.make()
>
>
<!-- SyntaxHighlightingPlugin -->
t.application.make() 
<!-- end SyntaxHighlightingPlugin -->
 ... and fix all compilation errors...

Run!

Line: 109 to 127
 
  1. Paste the data into your options.

  • We don't want to run forever, so define the number of events:
Changed:
<
<
ApplicationMgr.EvtMax = 1000 ;
>
>
<!-- SyntaxHighlightingPlugin -->
ApplicationMgr.EvtMax = 1000 ;
<!-- end SyntaxHighlightingPlugin -->
 
  • We want to save the histograms, so add the following line to your options:
Changed:
<
<
HistogramPersistencySvc.OutputFile = "DVHistos.root";
>
>
<!-- SyntaxHighlightingPlugin -->
HistogramPersistencySvc.OutputFile = "DVHistos.root";
<!-- end SyntaxHighlightingPlugin -->
 
  • Define a job, If you want the output to the terminal do:
Changed:
<
<
j = Job( t, backend = Interactive() )
>
>
<!-- SyntaxHighlightingPlugin -->
j = Job( t, backend = Interactive() )
<!-- end SyntaxHighlightingPlugin -->
 you can also use LSF, Local, Dirac... For small tests, interactive or local is usually best. For larger amounts of data, you'll need to run either on the LSF batch system or on the Grid.
  • Before you submit you can export the file:
Changed:
<
<
export (j , "Tutorial.py")
>
>
<!-- SyntaxHighlightingPlugin -->
export (j , "Tutorial.py")
<!-- end SyntaxHighlightingPlugin -->
 
  • Submit the job
Changed:
<
<
j.submit()
>
>
<!-- SyntaxHighlightingPlugin -->
j.submit()
<!-- end SyntaxHighlightingPlugin -->
 

Look at the histograms

We'll do that outside of ganga... so exit back to shell.
Line: 132 to 150
 
root.exe

  • The simplest way to look at histograms is to use the TBrowser.
Changed:
<
<
TBrowser B
>
>
<!-- SyntaxHighlightingPlugin -->
TBrowser B
<!-- end SyntaxHighlightingPlugin -->
 which has a Windows-like look and feel.
  • But if you just want to save the histograms, you could as well just paste the following in the root prompt
Changed:
<
<
|
TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); 

>
>
%SYNTAX{ syntax="cpp"}%TCanvas* c1 = new TCanvas("c1","Tutorial",800,800);
 c1->SetLogy();
Changed:
<
<
TFile* F = new TFile("DVHistos.root")|
>
>
TFile* F = new TFile("DVHistos.root")%ENDSYNTAX%
 and make sure you give the correct path for your file! And then
Changed:
<
<
|
F->ls()

>
>
%SYNTAX{ syntax="cpp"}%F->ls()
 F->cd("TutorialAlgorithm") F->ls() TH1D* H1 = F->Get("TutorialAlgorithm/1")
Line: 147 to 165
 TH1D* H3 = F->Get("TutorialAlgorithm/3") TH1D* H4 = F->Get("TutorialAlgorithm/4") H1->SetLineColor(2)
Changed:
<
<
H1->SetLineWidth(3)
>
>
H1->SetLineWidth(3) %ENDSYNTAX%
 H1->Draw() gPad->SaveAs("H1.eps"); H2->SetLineColor(2)
Line: 161 to 179
 H4->SetLineColor(2) H4->SetLineWidth(3) H4->Draw()
Changed:
<
<
gPad->SaveAs("H4.eps");|
>
>
gPad->SaveAs("H4.eps"); %ENDSYNTAX%
  For sure one could do this shorter...
  • To quit root:
Changed:
<
<
.q
>
>
<!-- SyntaxHighlightingPlugin -->
.q
<!-- end SyntaxHighlightingPlugin -->
 

Revision 22007-10-01 - unknown

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.
Line: 13 to 13
 
ganga
You will be prompted for your grid password.
  • At the ganga prompt type:
Changed:
<
<
t = JobTemplate( application = DaVinci( version = "v19r5" ))
t.application.getpack( "Tutorial/Analysis v6r4" )
t.application.getpack( "Phys/DaVinci v19r5" )
t.application.masterpackage = "DaVinci v19r5 Phys"
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r2/options/myOptions.opts" )
t.application.make()
>
>
t = JobTemplate( application = DaVinci( version = "v19r5" ))
t.application.getpack( "Tutorial/Analysis v6r4" )
t.application.getpack( "Phys/DaVinci v19r5" )
t.application.masterpackage = "DaVinci v19r5 Phys"
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/options/myOptions.opts" )
t.application.make()
 Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

Line: 126 to 126
 

Look at the histograms

We'll do that outside of ganga... so exit back to shell.
  • Source the root setup scripts
Changed:
<
<
source $LHCBHOME/scripts/setup_external ROOT
>
>
SetupProject Gaudi ROOT
 
  • Open root
root.exe

Revision 12007-10-01 - unknown

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

DaVinci Tutorial 1

We start with a very simple algorithm that looks at muons and fills some histograms.

Creating Ganga template for DaVinci jobs, and intitial package build.

You might already have done part of this. It doesn't harm to redo it but look for CVS errors when you getpack.
  • Set environment for Ganga:
GangaEnv
  • Start an interactive session:
ganga
You will be prompted for your grid password.
  • At the ganga prompt type:
t = JobTemplate( application = DaVinci( version = "v19r5" ))
t.application.getpack( "Tutorial/Analysis v6r4" )
t.application.getpack( "Phys/DaVinci v19r5" )
t.application.masterpackage = "DaVinci v19r5 Phys"
t.application.optsfile = File( name = "~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r2/options/myOptions.opts" )
t.application.make()
Be very careful not to copy-paste leading spaces; python does not like that at all.

Start to write the options

  • Open the main options file
!emacs $t.application.optsfile.name &
  • Write in the options file:
#include "$DAVINCIROOT/options/DaVinciCommon.opts" 
// load options for creation of "standard muons": 
#include "$COMMONPARTICLESROOT/options/StandardMuons.opts" 
// 
// Let's make it a sequence 
// 
ApplicationMgr.TopAlg += { "GaudiSequencer/TutorialSeq" }; 
// 
// J/psi->mumu selection 
// 
TutorialSeq.Members += { "TutorialAlgorithm" }; 
// 
// Get the input data : all muons. 
// 
TutorialAlgorithm.PhysDesktop.InputLocations = { "Phys/StdLooseMuons" };

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.

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:
!emacs ~/cmtuser/DaVinci_v19r5/Tutorial/Analysis/v6r4/src/TutorialAlgorithm.{cpp,h} &
Answer "D" for DVAlgorithm twice. You can also do that from the shell prompt by opening another window.
  • Create a new private method in the header file:
private:
StatusCode loopOnMuons(const LHCb::Particle::ConstVector&)const ;
  • Now let's add something to the execute method in the cpp:
StatusCode TutorialAlgorithm::execute() {
  debug() << "==> Execute" << endmsg; 
  StatusCode sc = StatusCode::SUCCESS ; 

  // code goes here 
  LHCb::Particle::ConstVector muons = desktop()->particles(); 
  sc = loopOnMuons(muons); 
  if (!sc) return sc; 

  setFilterPassed(true);  // Set to true if event is accepted. 
  return StatusCode::SUCCESS; }
Here we get the particles from the PhysDesktop tool and call our new method.
  • Now implement the method in the cpp file:
//==================================================== 
// loop on muons 
//==================================================== 
StatusCode TutorialAlgorithm::loopOnMuons( const LHCb::Particle::ConstVector& muons)const { 
  StatusCode sc = StatusCode::SUCCESS ; 

  // code goes here 

  return sc ; 
}
  • In the method add:
for ( LHCb::Particle::ConstVector::const_iterator im = muons.begin() ; im != muons.end() ; ++im ){
 plot((*im)->p(), "Muon P", 0., 50.*Gaudi::Units::GeV); // momentum
 plot((*im)->pt(), "Muon Pt", 0., 5.*Gaudi::Units::GeV ); // Pt
 debug() << "Mu Momentum: " << (*im)->momentum() << endmsg ;
}

  • Now get the primary vertices (outside the muons loop):
LHCb::RecVertex::ConstVector pvs = desktop()->primaryVertices();

  • And loop over them (inside the muons loop!):
 for ( LHCb::RecVertex::ConstVector::const_iterator ipv = 
  pvs.begin() ; ipv != pvs.end() ; ++ipv ){
    double IP, IPE;
    debug() << (*ipv)->position() << endmsg ;
    sc = geomDispCalculator()->calcImpactPar(*(*im), *(*ipv), IP, IPE);
    if (sc){
      plot(IP, "Muon IP", 0., 10.*Gaudi::Units::mm);
      if (IPE>0.) plot(IP/IPE, "Muon IP/error", 0., 10.);
    } 
  }

  • Now compile
t.application.make()
... and fix all compilation errors...

Run!

First we need some data.
  1. Click Dataset search
  2. Select Configuration : DC06 - phys-v2-lumi2
  3. Select Event type : 12144002 - Bs_Jpsiphi,mm=CPV,DecProdCut
  4. Datatype : DST1
  5. Step 3 : Brunel - v30r17 (or more recent)
  6. Datasets replicated at : Anywhere
  7. Submit. The bookkeeping can be very slow. Especially when 30 people try to access it at the same time...
  8. Paste the data into your options.

  • We don't want to run forever, so define the number of events:
ApplicationMgr.EvtMax = 1000 ;

  • We want to save the histograms, so add the following line to your options:
HistogramPersistencySvc.OutputFile = "DVHistos.root";

  • Define a job, If you want the output to the terminal do:
j = Job( t, backend = Interactive() )
you can also use LSF, Local, Dirac... For small tests, interactive or local is usually best. For larger amounts of data, you'll need to run either on the LSF batch system or on the Grid.
  • Before you submit you can export the file:
export (j , "Tutorial.py")

  • Submit the job
j.submit()

Look at the histograms

We'll do that outside of ganga... so exit back to shell.
  • Source the root setup scripts
source $LHCBHOME/scripts/setup_external ROOT

  • Open root
root.exe

  • The simplest way to look at histograms is to use the TBrowser.
TBrowser B
which has a Windows-like look and feel.
  • But if you just want to save the histograms, you could as well just paste the following in the root prompt
TCanvas* c1 = new TCanvas("c1","Tutorial",800,800); 
c1->SetLogy(); 
TFile* F = new TFile("DVHistos.root")
and make sure you give the correct path for your file! And then
F->ls()
F->cd("TutorialAlgorithm") 
F->ls()
TH1D* H1 = F->Get("TutorialAlgorithm/1")
TH1D* H2 = F->Get("TutorialAlgorithm/2")
TH1D* H3 = F->Get("TutorialAlgorithm/3")
TH1D* H4 = F->Get("TutorialAlgorithm/4")
H1->SetLineColor(2) 
H1->SetLineWidth(3) 
H1->Draw() 
gPad->SaveAs("H1.eps"); 
H2->SetLineColor(2) 
H2->SetLineWidth(3) 
H2->Draw() 
gPad->SaveAs("H2.eps"); 
H3->SetLineColor(2) 
H3->SetLineWidth(3) 
H3->Draw() 
gPad->SaveAs("H3.eps"); 
H4->SetLineColor(2) 
H4->SetLineWidth(3) 
H4->Draw() 
gPad->SaveAs("H4.eps");

For sure one could do this shorter...

  • To quit root:
.q

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