Difference: DaVinciTutorial6 (1 vs. 52)

Revision 522013-11-20 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 6 to 6
 

Slides

Changed:
<
<
This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). There is also a talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
>
>
This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). Also see the talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
 
Changed:
<
<

Tuple Tools

>
>

Why am I looking at this?

We normally use ROOT nTuple structures to store just the information about data or simulation we really need to do our analyses. When done properly the ntuple will be much smaller than the corresponding full data DST.

This tutorial describes the tools which exist already in DaVinci to get event data or particle data into a ROOT nTuple structure.

Event or Particle? Simulation or Real Data?

The DecayTreeTuple framework comes in three basic flavours. Three basic algorithms which fill different kinds of nTuple.

  • DecayTreeTuple: Fill information about particles, vertices, daughters, of a specific decay chain from a specific location. One entry per "head" particle (the mother decaying particle).
  • MCDecayTreeTuple: Fill information about Monte Carlo truth particles, again of a specific decay chain, again one entry per "head" particle (the mother decaying particle).
  • EventTuple: Fill information about the general properties of the event, how many tracks, run number/event number. One entry per event.

For each of these basic types there is a corresponding type of tool which fills certain information. There are many different copies of these tools to fill different information, and eventually get just the information you actually want in your ROOT file.

  • ParticleTupleTool: Gets passed a particle and a tuple, fills information about the particle and returns. Only used in DecayTreeTuple.
  • MCParticleTupleTool: Gets passed a Monte Carlo particle and a tuple, fills information about the Monte Carlo particle and returns. Basic ToolType for MCDecayTreeTuple, but can also be used in DecayTreeTuple, if carefully configured for the corresponding MC True particle (covered in tutorial 7).
  • EventTupleTool: Doesn't get passed anything, because it fills general information about the event you are sitting in. Can be added to any of the three tuple types. If added to a DecayTreeTuple it fills identical information for each particle in the same event.

Common Tuple Tools

  When you create a decay tree tuple, there are several variables that are automatically written into it:
  • nCandidate
  • totCandidates
  • EventInSequence
Changed:
<
<
The tuple tools are configurables that write particle, track, vertex, and event information into a ROOT tuple. Two tuple tools are automatically included in the tuple's tool list:
>
>
Extra tuple tools can write particle, track, vertex, and event information into your ROOT tuple.

Let's concentrate on DecayTreeTuple for a bit, which fills information about particles, or the event those particles are in. Two tuple tools are automatically included in the tuple's tool list:

 
Line: 33 to 56
 

Data or MC

Changed:
<
<
To avoid filling stuff in the Tuple that is not available, put a switch in your options:
>
>
To avoid filling stuff in the Tuple that is not available, it's a good idea to put a switch in your options, or write smart configurables/classes to configure things for you.
  %SYNTAX{ syntax="python"}% simulation = False # or True, as you wish

Revision 512013-10-21 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 29 to 29
 
  • TupleToolEventInfo, which writes event information such as run number, magnet polarity, GPS time, bunch ID, etc.

Additionally, there are some tuple tools that provide MC information. Many of these are completely analogous to the above data TupleTools, but simply provide MC truth values for truth matched candidates (and appropriate null values for non-truth matched candidates). Others give other sorts of MC information. These include:

Changed:
<
<
  • TupleToolMCBackgroundInfo, which use some boolean variables to sort reconstructed candidates into some generic signal and background categories
>
>
 

Data or MC

Revision 502013-10-14 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 47 to 47
 seq = SeqBs2JpsiPhi.sequence() tuple = DecayTreeTuple() tuple.Inputs = [ SeqBs2JpsiPhi.outputLocation() ]
Deleted:
<
<
tuple.Inputs = [ SeqBs2JpsiPhi.outputLocation() ]
 # tuple.addTupleTool( "TupleToolGeometry") // already default # tuple.addTupleTool( "TupleToolKinematic")// already default tuple.addTupleTool( "TupleToolPropertime")

Revision 492013-09-30 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 67 to 67
 %SYNTAX{ syntax="python"}%etuple = EventTuple() # etuple.addTupleTool("TupleToolEventInfo")// already default if (simulation): etuple.addTupleTool("TupleToolGeneration")
Changed:
<
<
etuple.addTupleTool("TupleToolTrigger") %ENDSYNTAX%
>
>
etuple.addTupleTool("TupleToolTrigger")%ENDSYNTAX%
  An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.

Revision 482013-09-30 - NicolaChiapolini

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 68 to 68
 # etuple.addTupleTool("TupleToolEventInfo")// already default if (simulation): etuple.addTupleTool("TupleToolGeneration") etuple.addTupleTool("TupleToolTrigger")
Added:
>
>
%ENDSYNTAX%
 
Changed:
<
<
An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.
>
>
An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.
  EventTupleTools and ParticleTupleTools are tools that implement the IEventTupleTool and IParticleTupleTool tool interfaces, respectively. Look at the description of these interfaces in doxygen, starting from this page to get a full up to date list of all tools implementing these interfaces. For more information on the different tools and what they are for, you really should see the slides last shown here.

Revision 472013-09-30 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 13 to 13
 When you create a decay tree tuple, there are several variables that are automatically written into it:
  • nCandidate
  • totCandidates
Changed:
<
<
>
>
  • EventInSequence
  The tuple tools are configurables that write particle, track, vertex, and event information into a ROOT tuple. Two tuple tools are automatically included in the tuple's tool list:
  • TupleToolGeometry, which writes information related to the geometry of the vertex locations
Line: 36 to 36
 To avoid filling stuff in the Tuple that is not available, put a switch in your options:

%SYNTAX{ syntax="python"}%

Changed:
<
<
simulation = False
>
>
simulation = False # or True, as you wish
 %ENDSYNTAX%

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from DecayTreeTuple.Configuration import *
Added:
>
>
from DaVinci4.solutions.Bs2JpsiPhi import SeqBs2JpsiPhi # get the GaudiSequencer with everything we need seq = SeqBs2JpsiPhi.sequence()
 tuple = DecayTreeTuple()
Changed:
<
<
tuple.Inputs = [ "Phys/SelBs2JpsiPhi/Particles" ] tuple.ToolList += [ "TupleToolGeometry" , "TupleToolKinematic" , "TupleToolPropertime" , "TupleToolPrimaries" , "TupleToolEventInfo" , "TupleToolTrackInfo" , "TupleToolTagging" ] if (simulation): tuple.ToolList += [ "TupleToolMCTruth", "TupleToolMCBackgroundInfo" ]
>
>
tuple.Inputs = [ SeqBs2JpsiPhi.outputLocation() ] tuple.Inputs = [ SeqBs2JpsiPhi.outputLocation() ] # tuple.addTupleTool( "TupleToolGeometry") // already default # tuple.addTupleTool( "TupleToolKinematic")// already default tuple.addTupleTool( "TupleToolPropertime") tuple.addTupleTool( "TupleToolPrimaries") # tuple.addTupleTool( "TupleToolEventInfo")// already default tuple.addTupleTool( "TupleToolTrackInfo") tuple.addTupleTool( "TupleToolTagging") if (simulation): tuple.addTupleTool( "TupleToolMCTruth") tuple.addTupleTool( "TupleToolMCBackgroundInfo")
 
Changed:
<
<
tuple.Decay = "[B_s0 -> (^J/psi(1S) => ^mu+ ^mu-) (^phi(1020) -> ^K+ ^K-)]cc"
>
>
tuple.Decay = "[B_s0 -> ^(J/psi(1S) -> ^mu+ ^mu-) ^(phi(1020) -> ^K+ ^K-)]CC"
 %ENDSYNTAX%
Changed:
<
<
DecayTreeTuple makes one entry per candidate and takes both EventTupleTools and ParticleTupleTools.
>
>
DecayTreeTuple makes one entry per candidate and takes both EventTupleTools and ParticleTupleTools. The most difficult part of the exercise is to get the decay descriptor right. See the syntax here.
  You can also add a Tuple with one entry per event. This is done using EventTuple. %SYNTAX{ syntax="python"}%etuple = EventTuple()
Changed:
<
<
etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger" ]%ENDSYNTAX%
>
>
# etuple.addTupleTool("TupleToolEventInfo")// already default if (simulation): etuple.addTupleTool("TupleToolGeneration") etuple.addTupleTool("TupleToolTrigger")
  An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.
Line: 84 to 91
 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009 -- PatrickSKoppenburg - 16-Oct-2012
Added:
>
>
-- PatrickSKoppenburg - 30-Sep-2013
  |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 462013-03-26 - JackWimberley

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 28 to 28
 
  • TupleToolTrackInfo, which writes track type and reconstruction information
  • TupleToolEventInfo, which writes event information such as run number, magnet polarity, GPS time, bunch ID, etc.
Added:
>
>
Additionally, there are some tuple tools that provide MC information. Many of these are completely analogous to the above data TupleTools, but simply provide MC truth values for truth matched candidates (and appropriate null values for non-truth matched candidates). Others give other sorts of MC information. These include:
  • TupleToolMCBackgroundInfo, which use some boolean variables to sort reconstructed candidates into some generic signal and background categories
 

Data or MC

To avoid filling stuff in the Tuple that is not available, put a switch in your options:

Revision 452013-01-18 - JackWimberley

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 10 to 10
 

Tuple Tools

Changed:
<
<
The tuple tools are configurables that write particle, track, vertex, and event information into a ROOT tuple. Some of the most common include:
>
>
When you create a decay tree tuple, there are several variables that are automatically written into it:
 
Added:
>
>
The tuple tools are configurables that write particle, track, vertex, and event information into a ROOT tuple. Two tuple tools are automatically included in the tuple's tool list:
 
Added:
>
>
Some other common and useful tuple tools include:
 
  • TupleToolPropertime, which simply writes the proper lifetime of reconstructed particles
  • TupleToolAngles, which writes the decay angles of (charged) tracks
  • TupleToolPid, which writes PID (particle identification) information for (charge) particles

Revision 442013-01-09 - JackWimberley

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 17 to 17
 
  • TupleToolPropertime, which simply writes the proper lifetime of reconstructed particles
  • TupleToolAngles, which writes the decay angles of (charged) tracks
  • TupleToolPid, which writes PID (particle identification) information for (charge) particles
Changed:
<
<
>
>
  • TupleToolTISTOS (TISTOS stands for "Trigger Independent of Signal or Trigger On Signal)
 
  • TupleToolPrimaries, which writes the number and coordinates of primary vertices in the candidate events
  • TupleToolTrackInfo, which writes track type and reconstruction information
  • TupleToolEventInfo, which writes event information such as run number, magnet polarity, GPS time, bunch ID, etc.

Revision 432013-01-09 - JackWimberley

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 55 to 55
  An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.
Changed:
<
<
EventTupleTools and PatricleTupleTools are tools that implement the IEventTupleTool and IParticleTupleTool tool interfaces, respectively. Look at the description of these interfaces in doxygen, starting from this page to get a full up to date list of all tools implementing these interfaces. For more information on the different tools and what they are for, you really should see the slides last shown here.
>
>
EventTupleTools and ParticleTupleTools are tools that implement the IEventTupleTool and IParticleTupleTool tool interfaces, respectively. Look at the description of these interfaces in doxygen, starting from this page to get a full up to date list of all tools implementing these interfaces. For more information on the different tools and what they are for, you really should see the slides last shown here.
 

Job configuration

Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file):

Revision 422013-01-08 - JackWimberley

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 8 to 8
 

Slides

This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). There is also a talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
Added:
>
>

Tuple Tools

The tuple tools are configurables that write particle, track, vertex, and event information into a ROOT tuple. Some of the most common include:

 

Data or MC

Added:
>
>
 To avoid filling stuff in the Tuple that is not available, put a switch in your options:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
simulation = False 
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
simulation = False
<!-- end SyntaxHighlightingPlugin -->
 

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from DecayTreeTuple.Configuration import *

Revision 412012-10-16 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.

Deleted:
<
<

Prerequisites

This tutorial requires

Tutorial/Analysis >= v8r9, Phys/DaVinci >= v26r3p2, Phys/DecayTreeTuple >= v3r11p1

You should start by doing cmt show uses to check this. You may need to getpack the new tutorial and DecayTreeTuple.

 

Slides

Changed:
<
<
This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). There is also a talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
>
>
This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). There is also a talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
 
Added:
>
>

Data or MC

To avoid filling stuff in the Tuple that is not available, put a switch in your options:
<!-- SyntaxHighlightingPlugin -->
simulation = False 
<!-- end SyntaxHighlightingPlugin -->
 

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from DecayTreeTuple.Configuration import * tuple = DecayTreeTuple() tuple.Inputs = [ "Phys/SelBs2JpsiPhi/Particles" ] tuple.ToolList += [
Changed:
<
<
"TupleToolTrigger" , "TupleToolMCTruth" , "TupleToolMCBackgroundInfo" , "TupleToolGeometry"
>
>
"TupleToolGeometry"
  , "TupleToolKinematic" , "TupleToolPropertime" , "TupleToolPrimaries"
Deleted:
<
<
, "TupleToolPid"
  , "TupleToolEventInfo" , "TupleToolTrackInfo"
Deleted:
<
<
, "TupleToolTISTOS"
  , "TupleToolTagging" ]
Added:
>
>
if (simulation): tuple.ToolList += [ "TupleToolMCTruth", "TupleToolMCBackgroundInfo" ]
 tuple.Decay = "[B_s0 -> (^J/psi(1S) => ^mu+ ^mu-) (^phi(1020) -> ^K+ ^K-)]cc" %ENDSYNTAX% DecayTreeTuple makes one entry per candidate and takes both EventTupleTools and ParticleTupleTools.
Line: 47 to 41
 

Job configuration

Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file): %SYNTAX{ syntax="python"}%DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
Changed:
<
<
DaVinci().TupleFile = "DVNtuples.root"%ENDSYNTAX%
>
>
DaVinci().TupleFile = "DVNtuples.root" DaVinci().Simulation = simulation %ENDSYNTAX%
 

Next:

Changed:
<
<
>
>
 
Line: 59 to 55
 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009
Added:
>
>
-- PatrickSKoppenburg - 16-Oct-2012
  |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 402011-12-22 - RoseKoopman

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 12 to 12
 You should start by doing cmt show uses to check this. You may need to getpack the new tutorial and DecayTreeTuple.

Slides

Changed:
<
<
This tutorial corresponds to the slides last shown here.
>
>
This tutorial corresponds to the slides last shown here. (i.e. that is an entire conference around the tutorials, you can read all of the slides, and they will take you though the tutorials step-by-step). There is also a talk on DecayTreeTuple here which is a nice introduction, but strays a little into DaVinciTutorial7 also.
 

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools:

Revision 392011-12-02 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 48 to 48
 Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file):
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
DaVinci().TupleFile = "DVNtuples.root"
<!-- end SyntaxHighlightingPlugin -->
Deleted:
<
<

Trigger

To fill the TupleToolTrigger, you will also need to run the trigger
<!-- SyntaxHighlightingPlugin -->
DaVinci().Hlt = True
DaVinci().HltThresholdSettings = 'Physics_320Vis_300L0_10Hlt1_Aug09'  # just an example
<!-- end SyntaxHighlightingPlugin -->
There are more Hlt settings. Do ls -1 $HLTSETTINGSROOT/python/HltSettings/Physics* Depending on the data you run on, you might need to emulate the L0 as well as the L0 banks included in the MC data might not be compatible with what Hlt expects (remember Hlt1 confirms the L0 decision). L0 and Hlt need to be synchronized. Do
<!-- SyntaxHighlightingPlugin -->
DaVinci().Hlt = True
DaVinci().ReplaceL0BanksWithEmulated = True
<!-- end SyntaxHighlightingPlugin -->
 
Deleted:
<
<

Warning!

You should not run the L0 and the Hlt when running on real data. This only makes sense for MC. The trigger has already been run on real data. If you re-run you overwrite the information which is on the DST.
 

Next:

Revision 382011-03-23 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 18 to 18
 Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from DecayTreeTuple.Configuration import * tuple = DecayTreeTuple()
Changed:
<
<
tuple.InputLocations = [ "SelBs2JpsiPhi" ]
>
>
tuple.Inputs = [ "Phys/SelBs2JpsiPhi/Particles" ]
 tuple.ToolList += [ "TupleToolTrigger" , "TupleToolMCTruth"

Revision 372011-01-24 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 7 to 7
 

Prerequisites

Changed:
<
<
This tutorial requires
Tutorial/Analysis >= v8r2, Phys/DaVinci >= v23r1, Phys/DecayTreeTuple >= v3r11p1
>
>
This tutorial requires
Tutorial/Analysis >= v8r9, Phys/DaVinci >= v26r3p2, Phys/DecayTreeTuple >= v3r11p1
  You should start by doing cmt show uses to check this. You may need to getpack the new tutorial and DecayTreeTuple.

Revision 362011-01-24 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.

Added:
>
>

Prerequisites

This tutorial requires

Tutorial/Analysis >= v8r2, Phys/DaVinci >= v23r1, Phys/DecayTreeTuple >= v3r11p1

You should start by doing cmt show uses to check this. You may need to getpack the new tutorial and DecayTreeTuple.

 

Slides

This tutorial corresponds to the slides last shown here.
Added:
>
>
 

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools:
Changed:
<
<
%SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple
>
>
%SYNTAX{ syntax="python"}%from DecayTreeTuple.Configuration import *
 tuple = DecayTreeTuple() tuple.InputLocations = [ "SelBs2JpsiPhi" ] tuple.ToolList += [

Revision 352010-11-25 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.

Revision 342010-10-28 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 33 to 33
 
<!-- SyntaxHighlightingPlugin -->
etuple = EventTuple()
etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger"  ]
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
An EventTuple can only take EventTupleTools.
>
>
An EventTuple can only take EventTupleTools. Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.
 
Changed:
<
<
For more information on the diferrent tools and what they are for, you really should see the slides last shown here.

Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.

>
>
EventTupleTools and PatricleTupleTools are tools that implement the IEventTupleTool and IParticleTupleTool tool interfaces, respectively. Look at the description of these interfaces in doxygen, starting from this page to get a full up to date list of all tools implementing these interfaces. For more information on the different tools and what they are for, you really should see the slides last shown here.
 

Job configuration

Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file):

Revision 332010-10-28 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 27 to 27
  , "TupleToolTagging" ] tuple.Decay = "[B_s0 -> (^J/psi(1S) => ^mu+ ^mu-) (^phi(1020) -> ^K+ ^K-)]cc" %ENDSYNTAX%
Changed:
<
<
DecayTreeTuple makes one entry per candidate.
>
>
DecayTreeTuple makes one entry per candidate and takes both EventTupleTools and ParticleTupleTools.
  You can also add a Tuple with one entry per event. This is done using EventTuple.
<!-- SyntaxHighlightingPlugin -->
etuple = EventTuple()
etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger"  ]
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
For mote information on the diferrent tools and what they are for, you really should see the slides last shown here.
>
>
An EventTuple can only take EventTupleTools.

For more information on the diferrent tools and what they are for, you really should see the slides last shown here.

Since a candidate always also has an associated event, you can add the information from the event into every candidate. This is why EventTupleTools can equally well go into an EventTuple and/or a DecayTreeTuple.

 

Job configuration

Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file):

Revision 322010-04-26 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 40 to 40
 
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
DaVinci().TupleFile = "DVNtuples.root"
<!-- end SyntaxHighlightingPlugin -->

Trigger

Changed:
<
<
To fill the TupleToolTrigger, you will also need to run the trigger (Warning, already edited for DaVinci v24r4)
>
>
To fill the TupleToolTrigger, you will also need to run the trigger
 
<!-- SyntaxHighlightingPlugin -->
DaVinci().Hlt = True
DaVinci().HltThresholdSettings = 'Physics_320Vis_300L0_10Hlt1_Aug09'  # just an example
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
There are more Hlt settings. Do ls -1 $HLTCONFROOT/python/HltConf/Physics*
>
>
There are more Hlt settings. Do ls -1 $HLTSETTINGSROOT/python/HltSettings/Physics* Depending on the data you run on, you might need to emulate the L0 as well as the L0 banks included in the MC data might not be compatible with what Hlt expects (remember Hlt1 confirms the L0 decision). L0 and Hlt need to be synchronized. Do
<!-- SyntaxHighlightingPlugin -->
DaVinci().Hlt = True
DaVinci().ReplaceL0BanksWithEmulated = True
<!-- end SyntaxHighlightingPlugin -->

Warning!

You should not run the L0 and the Hlt when running on real data. This only makes sense for MC. The trigger has already been run on real data. If you re-run you overwrite the information which is on the DST.
 

Next:

Changed:
<
<
>
>
 

Revision 312010-02-02 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.

Revision 302010-01-28 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 11 to 11
 Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple tuple = DecayTreeTuple()
Changed:
<
<
tuple.InputLocations = [ "Bs2JpsiPhi" ]
>
>
tuple.InputLocations = [ "SelBs2JpsiPhi" ]
 tuple.ToolList += [ "TupleToolTrigger" , "TupleToolMCTruth"
Line: 45 to 45
 DaVinci().HltThresholdSettings = 'Physics_320Vis_300L0_10Hlt1_Aug09' # just an example%ENDSYNTAX% There are more Hlt settings. Do ls -1 $HLTCONFROOT/python/HltConf/Physics*
Added:
>
>

Next:

 -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008 -- PatrickKoppenburg - 05 Jan 2009

Revision 292010-01-25 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 33 to 33
 
<!-- SyntaxHighlightingPlugin -->
etuple = EventTuple()
etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger"  ]
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
For mote information on the diferrent tools and what they are for, you really should see the slides last shown here.
 

Job configuration

Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file): %SYNTAX{ syntax="python"}%DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]

Revision 282010-01-06 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 20 to 20
  , "TupleToolKinematic" , "TupleToolPropertime" , "TupleToolPrimaries"
Added:
>
>
, "TupleToolPid"
  , "TupleToolEventInfo" , "TupleToolTrackInfo" , "TupleToolTISTOS"

Revision 272009-11-14 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 33 to 33
 etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger" ]%ENDSYNTAX%

Job configuration

Changed:
<
<
Run them outside of your sequence
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->
>
>
Run them outside of your sequence, and define an ntuple output file (which is different from the histogram file):
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
DaVinci().TupleFile = "DVNtuples.root"
<!-- end SyntaxHighlightingPlugin -->
 

Trigger

To fill the TupleToolTrigger, you will also need to run the trigger (Warning, already edited for DaVinci v24r4) %SYNTAX{ syntax="python"}%DaVinci().Hlt = True

Revision 262009-10-15 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 36 to 36
 Run them outside of your sequence
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->

Trigger

Changed:
<
<
To fill the TupleToolTrigger, you will also need to run the trigger
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
DaVinci().HltThresholdSettings = 'Effective_Nominal'  # just an example
<!-- end SyntaxHighlightingPlugin -->
>
>
To fill the TupleToolTrigger, you will also need to run the trigger (Warning, already edited for DaVinci v24r4)
<!-- SyntaxHighlightingPlugin -->
DaVinci().Hlt = True
DaVinci().HltThresholdSettings = 'Physics_320Vis_300L0_10Hlt1_Aug09'  # just an example
<!-- end SyntaxHighlightingPlugin -->
There are more Hlt settings. Do ls -1 $HLTCONFROOT/python/HltConf/Physics*
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008

Revision 252009-10-05 - PatrickSKoppenburg

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 37 to 37
 
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->

Trigger

To fill the TupleToolTrigger, you will also need to run the trigger
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
DaVinci().HltThresholdSettings = 'Effective_Nominal'  # just an example
<!-- end SyntaxHighlightingPlugin -->
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008

Revision 242009-06-10 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 9 to 9
 This tutorial corresponds to the slides last shown here.

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools:
Changed:
<
<
%SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple, PhysDesktop
>
>
%SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple
 tuple = DecayTreeTuple()
Changed:
<
<
tuple.addTool( PhysDesktop ) tuple.PhysDesktop.InputLocations = [ "Bs2JpsiPhi" ]
>
>
tuple.InputLocations = [ "Bs2JpsiPhi" ]
 tuple.ToolList += [ "TupleToolTrigger" , "TupleToolMCTruth"

Revision 232009-06-07 - RobLambert

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 37 to 37
 Run them outside of your sequence
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->

Trigger

Changed:
<
<
You also need to run the trigger
>
>
To fill the TupleToolTrigger, you will also need to run the trigger
 
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
<!-- end SyntaxHighlightingPlugin -->

-- PatrickKoppenburg - 01 Oct 2007

Revision 222009-03-11 - unknown

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 11 to 11
 Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple, PhysDesktop tuple = DecayTreeTuple()
Changed:
<
<
tuple.addTool( PhysDesktop() )
>
>
tuple.addTool( PhysDesktop )
 tuple.PhysDesktop.InputLocations = [ "Bs2JpsiPhi" ] tuple.ToolList += [ "TupleToolTrigger"

Revision 212009-01-08 - unknown

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

DaVinci Tutorial 6

This is all about running DecayTreeTuple and some more.
Line: 15 to 15
 tuple.PhysDesktop.InputLocations = [ "Bs2JpsiPhi" ] tuple.ToolList += [ "TupleToolTrigger"
Changed:
<
<
"TupleToolMCTruth"
>
>
, "TupleToolMCTruth"
  , "TupleToolMCBackgroundInfo" , "TupleToolGeometry" , "TupleToolKinematic"
Line: 38 to 38
 
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->

Trigger

You also need to run the trigger
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'                      
DaVinci().HltOldStyle = False                  ## Go for the new thing
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
<!-- end SyntaxHighlightingPlugin -->
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008

Revision 202009-01-05 - unknown

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

DaVinci Tutorial 6

Changed:
<
<
We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
>
>
This is all about running DecayTreeTuple and some more.
 

Slides

Changed:
<
<
This tutorial corresponds to the slides last shown here. But they might be a little out of date. Also have a look here.

New algorithm

Let's call it TutorialChecker. You need to:
  • Create the cpp and header files. The algorithm is a DVAlgorithm again.
  • Add it to your sequence as you want to run it only for events where you found something.

Tuple filling

  • Create a Tuple in the execute() method.
<!-- SyntaxHighlightingPlugin -->
Tuple tuple = nTuple("TutorialTuple");
<!-- end SyntaxHighlightingPlugin -->

Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialize() and keep it for the whole job.

  • Loop over the Bs candidates. You know how to do that.
  • For each Bs call a method
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillReco(Tuple& tuple, const LHCb::Particle* b)
<!-- end SyntaxHighlightingPlugin -->

  • In there fill some variables in the Tuple. For instance the mass:
<!-- SyntaxHighlightingPlugin -->
tuple->column( "Mass", b->measuredMass()); // mass
<!-- end SyntaxHighlightingPlugin -->

  • The momentum can be filled in one go:
<!-- SyntaxHighlightingPlugin -->
tuple->column( "P", b->momentum()); // 4-vector! 
<!-- end SyntaxHighlightingPlugin -->

  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like:
%SYNTAX{ syntax="cpp"}%std::vector ips, ipchi2s; for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv = PVs.end() ; ++ipv ){ double ip, ipchi2; distanceCalculator()->distance(b, (*ipv), ip, ipchi2); ips.push_back(ip); ipchi2s.push_back(ipchi2); } tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20); tuple->farray( "IPchi2", ipchi2s.begin(), ipchi2s.end(), "PVs", 20);
>
>
This tutorial corresponds to the slides last shown here.

Make two Tuples

Add an instance of DecayTreeTuple and add the appropriate tools: %SYNTAX{ syntax="python"}%from Configurables import DecayTreeTuple, PhysDesktop tuple = DecayTreeTuple() tuple.addTool( PhysDesktop() ) tuple.PhysDesktop.InputLocations = [ "Bs2JpsiPhi" ] tuple.ToolList += [ "TupleToolTrigger" "TupleToolMCTruth" , "TupleToolMCBackgroundInfo" , "TupleToolGeometry" , "TupleToolKinematic" , "TupleToolPropertime" , "TupleToolPrimaries" , "TupleToolEventInfo" , "TupleToolTrackInfo" , "TupleToolTISTOS" , "TupleToolTagging" ] tuple.Decay = "[B_s0 -> (^J/psi(1S) => ^mu+ ^mu-) (^phi(1020) -> ^K+ ^K-)]cc"
 %ENDSYNTAX%
Added:
>
>
DecayTreeTuple makes one entry per candidate.
 
Changed:
<
<
It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anything else you like...
  • At the end of your execute() method write out the tuple:
<!-- SyntaxHighlightingPlugin -->
StatusCode sc = tuple->write();
<!-- end SyntaxHighlightingPlugin -->
  • It's probably a good idea to compile and run at this stage. Don't forget to declare the algorithm in your options. You will also have to declare the name of the Tuple you want to save:
<!-- SyntaxHighlightingPlugin -->
NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
<!-- end SyntaxHighlightingPlugin -->
  • You can then view it in root:
<!-- SyntaxHighlightingPlugin -->
TFile* F = new TFile("Tuple.root") 
TTree* T = F->Get("TutorialChecker/1") 
T->Print() T->Draw("Mass")
<!-- end SyntaxHighlightingPlugin -->

MC truth

  • For each Bs call a method
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker& L)
<!-- end SyntaxHighlightingPlugin -->
where you would handle everything related to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).

Background category tool

The first thing we want to do is to get the background category. This tells you if the reconstructed Bs is correctly reconstructed or if it is background, and which type of background. See the details here.
  • The tool is not pre-declared to DVAlgorithm, so you'll have to declare it. First in the header file:
<!-- SyntaxHighlightingPlugin -->
#include "Kernel/IBackgroundCategory.h"
<!-- end SyntaxHighlightingPlugin -->
and
<!-- SyntaxHighlightingPlugin -->
private: IBackgroundCategory* m_background ;
<!-- end SyntaxHighlightingPlugin -->
Please note that "Kernel/IBackgroundCategory.h" is only found because in the package requirements we have a line that says
<!-- SyntaxHighlightingPlugin -->
use DaVinciMCKernel v* Phys
<!-- end SyntaxHighlightingPlugin -->

  • Initialize it as a private tool in initialize():
<!-- SyntaxHighlightingPlugin -->
m_background = tool("BackgroundCategory", this);
<!-- end SyntaxHighlightingPlugin -->

  • Before you can use it in fillTruth:
<!-- SyntaxHighlightingPlugin -->
IBackgroundCategory::categories cat = m_background->category(b); 
tuple->fill("category", cat);
<!-- end SyntaxHighlightingPlugin -->

  • It's probably a good idea to compile and run at this stage.

MC association

Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this.
  • Here again one needs to include:
<!-- SyntaxHighlightingPlugin -->
#include "Kernel/Particle2MCLinker.h"
<!-- end SyntaxHighlightingPlugin -->
which is found at compilation because we have declared DaVinciAssociators in the requirements file.
  • Create it in execute():
<!-- SyntaxHighlightingPlugin -->
Particle2MCLinker Linker(this, Particle2MCMethod::Composite, std::vector<std::string>(1,""));
<!-- end SyntaxHighlightingPlugin -->

  • Pass it to the fillTruth method which is declared as:
<!-- SyntaxHighlightingPlugin -->
StatusCode fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker& Link);
<!-- end SyntaxHighlightingPlugin -->
with the code
<!-- SyntaxHighlightingPlugin -->
sc = fillTruth(tuple, *b, Linker);
<!-- end SyntaxHighlightingPlugin -->

  • You can now use it in fillTruth:
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = Link.firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->

You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!

  • It's probably a good idea to compile and run at this stage.

Tagging

Bs->J/psiPhi is only interesting if we are able to tag the initial flavor of the Bs.
  • The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
  • Its method decision() tells you the initial flavour of the b quark.
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Add:
<!-- SyntaxHighlightingPlugin -->
# B tagging options 
importOptions( "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts" )
<!-- end SyntaxHighlightingPlugin -->
WARNING There is something wrong in these options in DaVinci up to v19r13. You will get an error if you do that. It will be fixed in the next release.

  • In root compare the tag decision with the true PID.
<!-- SyntaxHighlightingPlugin -->
T->Draw("TPID/Tag", "Tag!=0") 
<!-- end SyntaxHighlightingPlugin -->
>
>
You can also add a Tuple with one entry per event. This is done using EventTuple.
<!-- SyntaxHighlightingPlugin -->
etuple = EventTuple()
etuple.ToolList = [ "TupleToolEventInfo", "TupleToolGeneration", "TupleToolTrigger"  ]
<!-- end SyntaxHighlightingPlugin -->

Job configuration

Run them outside of your sequence
<!-- SyntaxHighlightingPlugin -->
DaVinci().UserAlgorithms = [ tutorialseq, tuple, etuple ]
<!-- end SyntaxHighlightingPlugin -->
 

Trigger

Changed:
<
<
  • The first step is already done for you, but if you want to use the trigger in some piece of code, you need to add the following in the relevant package requirements:
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event
<!-- end SyntaxHighlightingPlugin -->
  • Then in your cpp file add the relevant headers:
<!-- SyntaxHighlightingPlugin -->
#include "Event/L0DUReport.h" 
#include "Event/HltDecReports.h"
<!-- end SyntaxHighlightingPlugin -->
  • In your execute, or any other method, get the L0 object:
<!-- SyntaxHighlightingPlugin -->
const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default); 
  const LHCb::HltDecReports* decReports = get<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default );
  debug() << "L0 decision is " << l0->decision() <<  endmsg ; 
  debug() << "Hlt1: " <<  (decReports->decReport("Hlt1Global"))? 
                        (decReports->decReport("Hlt1Global")->decision()):0 )) return StatusCode::FAILURE;
  debug() << "Hlt2: " <<  (decReports->decReport("Hlt1Global"))? 
                        (decReports->decReport("Hlt1Global")->decision()):0 )) return StatusCode::FAILURE;
<!-- end SyntaxHighlightingPlugin -->
  • And then fill it in your tuple.
<!-- SyntaxHighlightingPlugin -->
tuple->column("L0", l0->decision()); 
<!-- end SyntaxHighlightingPlugin -->

  • You can also get the result for each trigger line. For L0 do as in DecayTreeTuple :
<!-- SyntaxHighlightingPlugin -->
StatusCode TupleToolTrigger::fillL0( Tuples::Tuple& tuple ) {
  if( exist<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default) ){
    LHCb::L0DUReport* report = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default);
    if ( ! tuple->column( "L0Decision", report->decision() ) ) return StatusCode::FAILURE;
    if (msgLevel(MSG::DEBUG)) debug() << "L0 decision:  " << report->decision() << endreq;
    if ( m_verboseL0 ){
      LHCb::L0DUChannel::Map channels = report->configuration()->channels();
      for(LHCb::L0DUChannel::Map::const_iterator it = channels.begin();
          it!=channels.end();it++){
        if ( ! tuple->column( "L0_"+(*it).first , 
                              report->channelDecision( ((*it).second)->id() )))
          return StatusCode::FAILURE;
        if (msgLevel(MSG::VERBOSE)) verbose() << (*it).first << " : " 
                    << report->channelDecision( ((*it).second)->id() ) << endreq;
      } 
    }
  } else {
    Warning("Can't get LHCb::L0DUReportLocation::Default (" +
            LHCb::L0DUReportLocation::Default + ")" );
    if ( ! tuple->column( "L0Decision", -1 ) ) return StatusCode::FAILURE;
  }
  return StatusCode::SUCCESS;
}
<!-- end SyntaxHighlightingPlugin -->
  • And for Hlt with level="Hlt1" and "Hlt2.
<!-- SyntaxHighlightingPlugin -->
StatusCode TupleToolTrigger::fillHlt( Tuples::Tuple& tuple, const std::string & level, bool individual ) {
  if( exist<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default ) ){ 
    const LHCb::HltDecReports* decReports = 
      get<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default );
    if( !tuple->column( level+"Global", (decReports->decReport(level+"Global"))? 
                        (decReports->decReport(level+"Global")->decision()):0 )) return StatusCode::FAILURE;
    if ( individual) {
      // individual Hlt trigger lines
      for(LHCb::HltDecReports::Container::const_iterator it=decReports->begin();
          it!=decReports->end();++it){
        if( ( it->first.find(level) == 0 ) && 
            ( it->first.find("Decision") != std::string::npos ) ) 
          if (msgLevel(MSG::DEBUG))  debug() << " Hlt2 trigger name= " << it->first  
                                             << " decision= " << it->second.decision() << endmsg;
        if ( ! tuple->column(it->first  , it->second.decision() ) ) 
          return StatusCode::FAILURE;
      } 
    }
  }
  return StatusCode::SUCCESS ;
}
<!-- end SyntaxHighlightingPlugin -->
  • To run the trigger you need to configure it using HltConf(). Try commenting and uncommenting some of these:
<!-- SyntaxHighlightingPlugin -->
#
# Standard Trigger configuration (not deafult)
#
from HltConf.Configuration import *
HltConf().replaceL0BanksWithEmulated = True         ## enable if you want to rerun L0  
HltConf().Hlt2IgnoreHlt1Decision = True             ## enable if you want Hlt2 irrespective of Hlt1
HltConf().hltType = 'Hlt1+Hlt2'                     ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
<!-- end SyntaxHighlightingPlugin -->

The solution to this part is to be found in solutions/DaVinci6/.

>
>
You also need to run the trigger
<!-- SyntaxHighlightingPlugin -->
DaVinci().HltType = 'Hlt1+Hlt2'                ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'                      
DaVinci().HltOldStyle = False                  ## Go for the new thing
<!-- end SyntaxHighlightingPlugin -->
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008
Added:
>
>
-- PatrickKoppenburg - 05 Jan 2009
 |*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 192008-12-23 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 182 to 182
  -- PatrickKoppenburg - 01 Oct 2007 -- PatrickKoppenburg - 13 Jun 2008
Added:
>
>
|*META PREFERENCE*|name="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" title="SYNTAXHIGHLIGHTINGPLUGIN_FORMAT_PREPEND" type="Set" value="
"|

Revision 182008-11-26 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 111 to 111
 
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event
<!-- end SyntaxHighlightingPlugin -->
  • Then in your cpp file add the relevant headers:
%SYNTAX{ syntax="cpp"}%#include "Event/L0DUReport.h"
Changed:
<
<
#include ""Event/HltDecReports.h%ENDSYNTAX%
>
>
#include "Event/HltDecReports.h"%ENDSYNTAX%
 
  • In your execute, or any other method, get the L0 object:
%SYNTAX{ syntax="cpp"}% const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default); const LHCb::HltDecReports* decReports = get<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default );
Line: 169 to 169
  } return StatusCode::SUCCESS ; }%ENDSYNTAX%
Changed:
<
<
>
>
  • To run the trigger you need to configure it using HltConf(). Try commenting and uncommenting some of these:
<!-- SyntaxHighlightingPlugin -->
#
# Standard Trigger configuration (not deafult)
#
from HltConf.Configuration import *
HltConf().replaceL0BanksWithEmulated = True         ## enable if you want to rerun L0  
HltConf().Hlt2IgnoreHlt1Decision = True             ## enable if you want Hlt2 irrespective of Hlt1
HltConf().hltType = 'Hlt1+Hlt2'                     ## pick one of 'Hlt1', 'Hlt2', or 'Hlt1+Hlt2'
<!-- end SyntaxHighlightingPlugin -->
  The solution to this part is to be found in solutions/DaVinci6/.

Revision 172008-09-16 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 111 to 111
 
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event
<!-- end SyntaxHighlightingPlugin -->
  • Then in your cpp file add the relevant headers:
%SYNTAX{ syntax="cpp"}%#include "Event/L0DUReport.h"
Changed:
<
<
#include "Kernel/IHltSummaryTool.h"%ENDSYNTAX%
  • Get the summary tool in your initialize (declare it first!)
<!-- SyntaxHighlightingPlugin -->
m_summary = tool<IHltSummaryTool>("HltSummaryTool");
<!-- end SyntaxHighlightingPlugin -->
>
>
#include ""Event/HltDecReports.h%ENDSYNTAX%
 
  • In your execute, or any other method, get the L0 object:
%SYNTAX{ syntax="cpp"}%const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default);
Changed:
<
<
debug() << "L0 decision is " << l0->decision() << ", HLT: " << m_summary>decision() << endmsg ; %ENDSYNTAX%
>
>
const LHCb::HltDecReports* decReports = get<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default ); debug() << "L0 decision is " << l0->decision() << endmsg ; debug() << "Hlt1: " << (decReports->decReport("Hlt1Global"))? (decReports->decReport("Hlt1Global")->decision()):0 )) return StatusCode::FAILURE; debug() << "Hlt2: " << (decReports->decReport("Hlt1Global"))? (decReports->decReport("Hlt1Global")->decision()):0 )) return StatusCode::FAILURE;%ENDSYNTAX%
 
  • And then fill it in your tuple.
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
tuple->column("L0", l0->decision()); // total decision 
tuple->column("Hlt", m_summary->decision()); // total decision 
<!-- end SyntaxHighlightingPlugin -->
There will be a simple way soon of getting a finer granularity in the HLT decision. Stay tuned.
>
>
<!-- SyntaxHighlightingPlugin -->
tuple->column("L0", l0->decision()); 
<!-- end SyntaxHighlightingPlugin -->

  • You can also get the result for each trigger line. For L0 do as in DecayTreeTuple :
<!-- SyntaxHighlightingPlugin -->
StatusCode TupleToolTrigger::fillL0( Tuples::Tuple& tuple ) {
  if( exist<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default) ){
    LHCb::L0DUReport* report = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default);
    if ( ! tuple->column( "L0Decision", report->decision() ) ) return StatusCode::FAILURE;
    if (msgLevel(MSG::DEBUG)) debug() << "L0 decision:  " << report->decision() << endreq;
    if ( m_verboseL0 ){
      LHCb::L0DUChannel::Map channels = report->configuration()->channels();
      for(LHCb::L0DUChannel::Map::const_iterator it = channels.begin();
          it!=channels.end();it++){
        if ( ! tuple->column( "L0_"+(*it).first , 
                              report->channelDecision( ((*it).second)->id() )))
          return StatusCode::FAILURE;
        if (msgLevel(MSG::VERBOSE)) verbose() << (*it).first << " : " 
                    << report->channelDecision( ((*it).second)->id() ) << endreq;
      } 
    }
  } else {
    Warning("Can't get LHCb::L0DUReportLocation::Default (" +
            LHCb::L0DUReportLocation::Default + ")" );
    if ( ! tuple->column( "L0Decision", -1 ) ) return StatusCode::FAILURE;
  }
  return StatusCode::SUCCESS;
}
<!-- end SyntaxHighlightingPlugin -->
  • And for Hlt with level="Hlt1" and "Hlt2.
<!-- SyntaxHighlightingPlugin -->
StatusCode TupleToolTrigger::fillHlt( Tuples::Tuple& tuple, const std::string & level, bool individual ) {
  if( exist<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default ) ){ 
    const LHCb::HltDecReports* decReports = 
      get<LHCb::HltDecReports>( LHCb::HltDecReportsLocation::Default );
    if( !tuple->column( level+"Global", (decReports->decReport(level+"Global"))? 
                        (decReports->decReport(level+"Global")->decision()):0 )) return StatusCode::FAILURE;
    if ( individual) {
      // individual Hlt trigger lines
      for(LHCb::HltDecReports::Container::const_iterator it=decReports->begin();
          it!=decReports->end();++it){
        if( ( it->first.find(level) == 0 ) && 
            ( it->first.find("Decision") != std::string::npos ) ) 
          if (msgLevel(MSG::DEBUG))  debug() << " Hlt2 trigger name= " << it->first  
                                             << " decision= " << it->second.decision() << endmsg;
        if ( ! tuple->column(it->first  , it->second.decision() ) ) 
          return StatusCode::FAILURE;
      } 
    }
  }
  return StatusCode::SUCCESS ;
}
<!-- end SyntaxHighlightingPlugin -->
  The solution to this part is to be found in solutions/DaVinci6/.

Revision 162008-08-12 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 29 to 29
 
<!-- SyntaxHighlightingPlugin -->
tuple->column( "P", b->momentum()); // 4-vector! 
<!-- end SyntaxHighlightingPlugin -->

  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like:
Changed:
<
<
%SYNTAX{ syntax="cpp"}%std::vector ips, ipes; for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin(); ipv = PVs.end(); ++ipv ){ double ip, ipe; geomDispCalculator()->calcImpactPar(*b, *(*ipv), ip, ipe);
>
>
%SYNTAX{ syntax="cpp"}%std::vector ips, ipchi2s; for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv = PVs.end() ; ++ipv ){ double ip, ipchi2; distanceCalculator()->distance(b, (*ipv), ip, ipchi2);
  ips.push_back(ip);
Changed:
<
<
ipes.push_back(ipe);
>
>
ipchi2s.push_back(ipchi2);
 } tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20);
Changed:
<
<
tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20);%ENDSYNTAX%
>
>
tuple->farray( "IPchi2", ipchi2s.begin(), ipchi2s.end(), "PVs", 20); %ENDSYNTAX%
  It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anything else you like...

Revision 152008-06-13 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 99 to 97
 
  • The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
  • Its method decision() tells you the initial flavour of the b quark.
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Add:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
/// B tagging options 
#include "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts"
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
# B tagging options 
importOptions( "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts" )
<!-- end SyntaxHighlightingPlugin -->
WARNING There is something wrong in these options in DaVinci up to v19r13. You will get an error if you do that. It will be fixed in the next release.
 
  • In root compare the tag decision with the true PID.
<!-- SyntaxHighlightingPlugin -->
T->Draw("TPID/Tag", "Tag!=0") 
<!-- end SyntaxHighlightingPlugin -->

Trigger

  • The first step is already done for you, but if you want to use the trigger in some piece of code, you need to add the following in the relevant package requirements:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event 
use HltEvent v* Event
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event
<!-- end SyntaxHighlightingPlugin -->
 
  • Then in your cpp file add the relevant headers:
%SYNTAX{ syntax="cpp"}%#include "Event/L0DUReport.h"
Changed:
<
<
#include "Event/HltSummary.h"%ENDSYNTAX%
  • In your execute, or any other method, get the objects:
<!-- SyntaxHighlightingPlugin -->
const LHCb::HltSummary* hlt = get<LHCb::HltSummary>(LHCb::HltSummaryLocation::Default); 
const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default); 
debug() << "L0 decision is " << l0->decision() << ", HLT: " << hlt->decision() << endmsg ; 
<!-- end SyntaxHighlightingPlugin -->
>
>
#include "Kernel/IHltSummaryTool.h"%ENDSYNTAX%
  • Get the summary tool in your initialize (declare it first!)
<!-- SyntaxHighlightingPlugin -->
m_summary = tool<IHltSummaryTool>("HltSummaryTool");
<!-- end SyntaxHighlightingPlugin -->
  • In your execute, or any other method, get the L0 object:
<!-- SyntaxHighlightingPlugin -->
const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default); 
debug() << "L0 decision is " << l0->decision() << ", HLT: " << m_summary>decision() << endmsg ; 
<!-- end SyntaxHighlightingPlugin -->
 
  • And then fill it in your tuple.
%SYNTAX{ syntax="cpp"}%tuple->column("L0", l0->decision()); // total decision
Changed:
<
<
tuple->column("Hlt", hlt->decision()); // total decision tuple->column("HltMuon", hlt->checkDecisionType(LHCb::HltEnums::Muon)); %ENDSYNTAX% If you want to use the HLT enums you also have to include Event/HltEnums.
>
>
tuple->column("Hlt", m_summary->decision()); // total decision %ENDSYNTAX% There will be a simple way soon of getting a finer granularity in the HLT decision. Stay tuned.
  The solution to this part is to be found in solutions/DaVinci6/.

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

Added:
>
>
-- PatrickKoppenburg - 13 Jun 2008

Revision 142008-05-09 - DavidHutchcroft

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 78 to 78
 

MC association

Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this.
  • Here again one needs to include:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
#include "DaVinciAssociators/Particle2MCLinker.h"
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
#include "Kernel/Particle2MCLinker.h"
<!-- end SyntaxHighlightingPlugin -->
 which is found at compilation because we have declared DaVinciAssociators in the requirements file.
  • Create it in execute():
<!-- SyntaxHighlightingPlugin -->
Particle2MCLinker Linker(this, Particle2MCMethod::Composite, std::vector<std::string>(1,""));
<!-- end SyntaxHighlightingPlugin -->

Revision 132008-04-24 - DavidHutchcroft

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 83 to 83
 
  • Create it in execute():
<!-- SyntaxHighlightingPlugin -->
Particle2MCLinker Linker(this, Particle2MCMethod::Composite, std::vector<std::string>(1,""));
<!-- end SyntaxHighlightingPlugin -->
Added:
>
>
  • Pass it to the fillTruth method which is declared as:
<!-- SyntaxHighlightingPlugin -->
StatusCode fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker& Link);
<!-- end SyntaxHighlightingPlugin -->
with the code
<!-- SyntaxHighlightingPlugin -->
sc = fillTruth(tuple, *b, Linker);
<!-- end SyntaxHighlightingPlugin -->
 
  • You can now use it in fillTruth:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = Linker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = Link.firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
  You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!
  • It's probably a good idea to compile and run at this stage.

Revision 122008-04-24 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 54 to 54
 

MC truth

  • For each Bs call a method
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker* L)
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker& L)
<!-- end SyntaxHighlightingPlugin -->
 where you would handle everything related to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).

Background category tool

Revision 112008-04-24 - DavidHutchcroft

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 84 to 84
 
<!-- SyntaxHighlightingPlugin -->
Particle2MCLinker Linker(this, Particle2MCMethod::Composite, std::vector<std::string>(1,""));
<!-- end SyntaxHighlightingPlugin -->

  • You can now use it in fillTruth:
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = m_pLinker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = Linker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
  You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!
  • It's probably a good idea to compile and run at this stage.

Revision 102008-04-24 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 54 to 54
 

MC truth

  • For each Bs call a method
Changed:
<
<
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b)
<!-- end SyntaxHighlightingPlugin -->
>
>
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b, Particle2MCLinker* L)
<!-- end SyntaxHighlightingPlugin -->
 where you would handle everything related to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).

Background category tool

Line: 77 to 77
 

MC association

Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this.
Changed:
<
<
  • Here again one needs to declare everything in the header file:
>
>
  • Here again one needs to include:
 
<!-- SyntaxHighlightingPlugin -->
#include "DaVinciAssociators/Particle2MCLinker.h"
<!-- end SyntaxHighlightingPlugin -->
Deleted:
<
<
and
<!-- SyntaxHighlightingPlugin -->
private: Particle2MCLinker* m_pLinker;
<!-- end SyntaxHighlightingPlugin -->
 which is found at compilation because we have declared DaVinciAssociators in the requirements file.
Changed:
<
<
  • Initialise it in initialize():
<!-- SyntaxHighlightingPlugin -->
m_pLinker = new Particle2MCLinker(this, Particle2MCMethod::Composite, "");
<!-- end SyntaxHighlightingPlugin -->
>
>
  • Create it in execute():
<!-- SyntaxHighlightingPlugin -->
Particle2MCLinker Linker(this, Particle2MCMethod::Composite, std::vector<std::string>(1,""));
<!-- end SyntaxHighlightingPlugin -->
 
  • You can now use it in fillTruth:
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = m_pLinker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->

Revision 92008-03-06 - AnatolySolomin

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 17 to 17
 
  • Create a Tuple in the execute() method.
<!-- SyntaxHighlightingPlugin -->
Tuple tuple = nTuple("TutorialTuple");
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialise() and keep it for the whole job.
>
>
Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialize() and keep it for the whole job.
 
  • Loop over the Bs candidates. You know how to do that.
  • For each Bs call a method
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
<!-- end SyntaxHighlightingPlugin -->
Line: 66 to 66
 Please note that "Kernel/IBackgroundCategory.h" is only found because in the package requirements we have a line that says
<!-- SyntaxHighlightingPlugin -->
use DaVinciMCKernel v* Phys
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • Initialise it as a private tool in initialize():
>
>
  • Initialize it as a private tool in initialize():
 
<!-- SyntaxHighlightingPlugin -->
m_background = tool("BackgroundCategory",this);
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • Before you can use it in
%SYNTAX{ syntax="cpp"}%fillTruth: IBackgroundCategory::categories cat = m_background->category(b);
>
>
  • Before you can use it in fillTruth:
%SYNTAX{syntax="cpp"}%IBackgroundCategory::categories cat = m_background->category(b);
 tuple->fill("category",cat);%ENDSYNTAX%

  • It's probably a good idea to compile and run at this stage.
Line: 86 to 86
 
  • Initialise it in initialize():
<!-- SyntaxHighlightingPlugin -->
m_pLinker = new Particle2MCLinker(this,Particle2MCMethod::Composite, "");
<!-- end SyntaxHighlightingPlugin -->
Changed:
<
<
  • You can now use it in
<!-- SyntaxHighlightingPlugin -->
fillTruth: const LHCb::MCParticle* MC = m_pLinker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
>
>
  • You can now use it in fillTruth:
<!-- SyntaxHighlightingPlugin -->
const LHCb::MCParticle* MC = m_pLinker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->
  You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!
  • It's probably a good idea to compile and run at this stage.

Tagging

Changed:
<
<
Bs->J/psiPhi is only interesting if we are able to tag the initial flavour of the Bs.
>
>
Bs->J/psiPhi is only interesting if we are able to tag the initial flavor of the Bs.
 
  • The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
  • Its method decision() tells you the initial flavour of the b quark.
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Add:

Revision 82008-03-04 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.

Revision 72007-11-19 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.

Added:
>
>

Slides

This tutorial corresponds to the slides last shown here. But they might be a little out of date. Also have a look here.
 

New algorithm

Let's call it TutorialChecker. You need to:
  • Create the cpp and header files. The algorithm is a DVAlgorithm again.

Revision 62007-10-29 - StephenWotton

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.

Revision 52007-10-15 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 92 to 92
 

Tagging

Bs->J/psiPhi is only interesting if we are able to tag the initial flavour of the Bs.
  • The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
Changed:
<
<
  • Its method decision() tells you the initial flavour of the b quark.
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Unfortunately there's a typo in the released options, so we have a corrected copy in the tutorial package. Add:
>
>
  • Its method decision() tells you the initial flavour of the b quark.
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Add:
 
<!-- SyntaxHighlightingPlugin -->
/// B tagging options 
#include "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts"
<!-- end SyntaxHighlightingPlugin -->

Revision 42007-10-03 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 108 to 108
 
<!-- SyntaxHighlightingPlugin -->
#include "Event/L0DUReport.h" 
#include "Event/HltSummary.h"
<!-- end SyntaxHighlightingPlugin -->
  • In your execute, or any other method, get the objects:
Changed:
<
<
%SYNTAX{ syntax="cpp"}%const LHCb::HltSummary* hlt = get(LHCb::HltSummaryLocation::Default); const LHCb::L0DUReport* l0 = get(LHCb::L0DUReportLocation::Default);
>
>
%SYNTAX{ syntax="cpp"}%const LHCb::HltSummary* hlt = get<LHCb::HltSummary>(LHCb::HltSummaryLocation::Default); const LHCb::L0DUReport* l0 = get<LHCb::L0DUReport>(LHCb::L0DUReportLocation::Default);
 debug() << "L0 decision is " << l0->decision() << ", HLT: " << hlt->decision() << endmsg ; %ENDSYNTAX%
  • And then fill it in your tuple.
%SYNTAX{ syntax="cpp"}%tuple->column("L0", l0->decision()); // total decision

Revision 32007-10-02 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 12 to 12
 

Tuple filling

  • Create a Tuple in the execute() method.
Changed:
<
<
Tuple tuple = nTuple("TutorialTuple");
>
>
<!-- SyntaxHighlightingPlugin -->
Tuple tuple = nTuple("TutorialTuple");
<!-- end SyntaxHighlightingPlugin -->
 Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialise() and keep it for the whole job.
  • Loop over the Bs candidates. You know how to do that.
  • For each Bs call a method
Changed:
<
<
StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
>
>
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
<!-- end SyntaxHighlightingPlugin -->
 
  • In there fill some variables in the Tuple. For instance the mass:
Changed:
<
<
tuple->column( "Mass", b->measuredMass()); // mass
>
>
<!-- SyntaxHighlightingPlugin -->
tuple->column( "Mass", b->measuredMass()); // mass
<!-- end SyntaxHighlightingPlugin -->
 
  • The momentum can be filled in one go:
Changed:
<
<
tuple->column( "P", b->momentum()); // 4-vector! 
>
>
<!-- SyntaxHighlightingPlugin -->
tuple->column( "P", b->momentum()); // 4-vector! 
<!-- end SyntaxHighlightingPlugin -->
 
  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like:
Changed:
<
<
|
std::vector ips, ipes; 

>
>
%SYNTAX{ syntax="cpp"}%std::vector ips, ipes;
 for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv = PVs.end() ; ++ipv ){ double ip, ipe; geomDispCalculator()->calcImpactPar(*b, *(*ipv), ip, ipe);
Line: 30 to 34
  ipes.push_back(ipe); } tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20);
Changed:
<
<
tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20);|
>
>
tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20);%ENDSYNTAX%
 It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anything else you like...
  • At the end of your execute() method write out the tuple:
Changed:
<
<
StatusCode sc = tuple->write();
>
>
<!-- SyntaxHighlightingPlugin -->
StatusCode sc = tuple->write();
<!-- end SyntaxHighlightingPlugin -->
 
  • It's probably a good idea to compile and run at this stage. Don't forget to declare the algorithm in your options. You will also have to declare the name of the Tuple you want to save:
Changed:
<
<
NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
>
>
<!-- SyntaxHighlightingPlugin -->
NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
<!-- end SyntaxHighlightingPlugin -->
 
  • You can then view it in root:
Changed:
<
<
|
TFile* F = new TFile("Tuple.root") 

>
>
%SYNTAX{ syntax="cpp"}%TFile* F = new TFile("Tuple.root")
 TTree* T = F->Get("TutorialChecker/1")
Changed:
<
<
T->Print() T->Draw("Mass")|
>
>
T->Print() T->Draw("Mass")%ENDSYNTAX%
 

MC truth

  • For each Bs call a method
Changed:
<
<
 StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b)
>
>
<!-- SyntaxHighlightingPlugin -->
StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b)
<!-- end SyntaxHighlightingPlugin -->
 where you would handle everything related to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).

Background category tool

The first thing we want to do is to get the background category. This tells you if the reconstructed Bs is correctly reconstructed or if it is background, and which type of background. See the details here.
  • The tool is not pre-declared to DVAlgorithm, so you'll have to declare it. First in the header file:
Changed:
<
<
|
#include "Kernel/IBackgroundCategory.h"
| and
private: IBackgroundCategory* m_background ;
>
>
<!-- SyntaxHighlightingPlugin -->
#include "Kernel/IBackgroundCategory.h"
<!-- end SyntaxHighlightingPlugin -->
and
<!-- SyntaxHighlightingPlugin -->
private: IBackgroundCategory* m_background ;
<!-- end SyntaxHighlightingPlugin -->
 Please note that "Kernel/IBackgroundCategory.h" is only found because in the package requirements we have a line that says
Changed:
<
<
use DaVinciMCKernel v* Phys
>
>
<!-- SyntaxHighlightingPlugin -->
use DaVinciMCKernel v* Phys
<!-- end SyntaxHighlightingPlugin -->
 
  • Initialise it as a private tool in initialize():
Changed:
<
<
|
m_background = tool("BackgroundCategory",this);<>/pre>|
   * Before you can use it in fillTruth: IBackgroundCategory::categories cat = m_background->category(b); tuple->fill("category",cat);

>
>
<!-- SyntaxHighlightingPlugin -->
m_background = tool("BackgroundCategory",this);
<!-- end SyntaxHighlightingPlugin -->

  • Before you can use it in
<!-- SyntaxHighlightingPlugin -->
fillTruth: IBackgroundCategory::categories cat = m_background->category(b); 
tuple->fill("category",cat);
<!-- end SyntaxHighlightingPlugin -->
 
  • It's probably a good idea to compile and run at this stage.

MC association

Changed:
<
<
Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this. * Here again one needs to declare everything in the header file: #include "DaVinciAssociators/Particle2MCLinker.h" and private: Particle2MCLinker* m_pLinker; which is found at compilation because we have declared DaVinciAssociators in the requirements file. * Initialise it in initialize(): m_pLinker = new Particle2MCLinker(this,Particle2MCMethod::Composite, ""); * You can now use it in fillTruth: const LHCb::MCParticle* MC = m_pLinker->firstMCP( b ); You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!
>
>
Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this.
  • Here again one needs to declare everything in the header file:
<!-- SyntaxHighlightingPlugin -->
#include "DaVinciAssociators/Particle2MCLinker.h"
<!-- end SyntaxHighlightingPlugin -->

and

<!-- SyntaxHighlightingPlugin -->
private: Particle2MCLinker* m_pLinker;
<!-- end SyntaxHighlightingPlugin -->
which is found at compilation because we have declared DaVinciAssociators in the requirements file.
  • Initialise it in initialize():
<!-- SyntaxHighlightingPlugin -->
m_pLinker = new Particle2MCLinker(this,Particle2MCMethod::Composite, "");
<!-- end SyntaxHighlightingPlugin -->

  • You can now use it in
<!-- SyntaxHighlightingPlugin -->
fillTruth: const LHCb::MCParticle* MC = m_pLinker->firstMCP( b );
<!-- end SyntaxHighlightingPlugin -->

You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking!

  * It's probably a good idea to compile and run at this stage.

Tagging

Bs->J/psiPhi is only interesting if we are able to tag the initial flavour of the Bs.
Changed:
<
<
* The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
>
>
  • The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object.
  * Its method decision() tells you the initial flavour of the b quark.
Changed:
<
<
* It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Unfortunately there's a typo in the released options, so we have a corrected copy in the tutorial package. Add: /// B tagging options #include "$ANALYSISROOT/options/BTaggingTool.opts" Later it would be /// B tagging options #include "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts" * In root compare the tag decision with the true PID. T->Draw("TPID/Tag","Tag!=0")
>
>
  • It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Unfortunately there's a typo in the released options, so we have a corrected copy in the tutorial package. Add:
<!-- SyntaxHighlightingPlugin -->
/// B tagging options 
#include "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts"
<!-- end SyntaxHighlightingPlugin -->
 
Changed:
<
<

Trigger

* The first step is already done for you, but if you want to use the trigger in some piece of code, you need to add the following in the relevant package requirements: use L0Event v* Event use HltEvent v* Event * Then in your cpp file add the relevant headers: #include "Event/L0DUReport.h" #include "Event/HltSummary.h" * In your execute, or any other method, get the objects: const LHCb::HltSummary* hlt = get(LHCb::HltSummaryLocation::Default); LHCb::L0DUReport* l0 = get(LHCb::L0DUReportLocation::Default); debug() << "L0 decision is " << l0->decision() << ", HLT: " << hlt->decision() << endmsg ; L0Report presently cannot be declared const as the decision() method is not const. This should be cured someday. * And then fill it in your tuple. tuple->column("L0", l0->decision()); // total decision tuple->column("Hlt", hlt->decision()); // total decision tuple->column("HltMuon", hlt->checkDecisionType(LHCb::HltEnums::Muon)); If you want to use the HLT enums you also have to include Event/HltEnums.
>
>
  • In root compare the tag decision with the true PID.
<!-- SyntaxHighlightingPlugin -->
T->Draw("TPID/Tag","Tag!=0") 
<!-- end SyntaxHighlightingPlugin -->
 
Added:
>
>

Trigger

  • The first step is already done for you, but if you want to use the trigger in some piece of code, you need to add the following in the relevant package requirements:
<!-- SyntaxHighlightingPlugin -->
use L0Event v* Event 
use HltEvent v* Event
<!-- end SyntaxHighlightingPlugin -->
  • Then in your cpp file add the relevant headers:
<!-- SyntaxHighlightingPlugin -->
#include "Event/L0DUReport.h" 
#include "Event/HltSummary.h"
<!-- end SyntaxHighlightingPlugin -->
  • In your execute, or any other method, get the objects:
<!-- SyntaxHighlightingPlugin -->
const LHCb::HltSummary* hlt = get(LHCb::HltSummaryLocation::Default); 
const LHCb::L0DUReport* l0 = get(LHCb::L0DUReportLocation::Default); 
debug() << "L0 decision is " << l0->decision() << ", HLT: " << hlt->decision() << endmsg ; 
<!-- end SyntaxHighlightingPlugin -->
  • And then fill it in your tuple.
<!-- SyntaxHighlightingPlugin -->
tuple->column("L0", l0->decision()); // total decision 
tuple->column("Hlt", hlt->decision()); // total decision 
tuple->column("HltMuon", hlt->checkDecisionType(LHCb::HltEnums::Muon)); 
<!-- end SyntaxHighlightingPlugin -->
If you want to use the HLT enums you also have to include Event/HltEnums.
 
Changed:
<
<
The solution to this part is to be found in solutions/DaVinci6/
>
>
The solution to this part is to be found in solutions/DaVinci6/.
  -- PatrickKoppenburg - 01 Oct 2007

Revision 22007-10-01 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.
Line: 15 to 15
 
Tuple tuple = nTuple("TutorialTuple");
Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialise() and keep it for the whole job.
  • Loop over the Bs candidates. You know how to do that.
Changed:
<
<
  • For each Bs call a method StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
>
>
  • For each Bs call a method
StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
 
  • In there fill some variables in the Tuple. For instance the mass:
tuple->column( "Mass", b->measuredMass()); // mass
  • The momentum can be filled in one go:
tuple->column( "P", b->momentum()); // 4-vector! 
Changed:
<
<
  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like: std::vector ips, ipes; for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv = PVs.end() ; ++ipv ){ double ip, ipe; geomDispCalculator()->calcImpactPar(*b, *(*ipv), ip, ipe); ips.push_back(ip); ipes.push_back(ipe); } tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20); tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20); It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anthing else you like...
  • At the end of your execute() method write out the tuple: StatusCode sc = tuple->write();
  • It's probably a good idea to compile and run at this stage. Don't forget to declare the algorithm in your options. You will also have to declare the name of the Tuple you want to save: NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
  • You can then view it in root: TFile* F = new TFile("Tuple.root") TTree* T = F->Get("TutorialChecker/1") T->Print() T->Draw("Mass")
>
>
  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like:
std::vector ips, ipes; 
for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv != PVs.end() ; ++ipv ){ 
  double ip, ipe; 
  geomDispCalculator()->calcImpactPar(*b, *(*ipv), ip, ipe); 
  ips.push_back(ip); 
  ipes.push_back(ipe); 
} 
tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20); 
tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20);
It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anything else you like...
  • At the end of your execute() method write out the tuple:
StatusCode sc = tuple->write();
  • It's probably a good idea to compile and run at this stage. Don't forget to declare the algorithm in your options. You will also have to declare the name of the Tuple you want to save:
NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
  • You can then view it in root:
TFile* F = new TFile("Tuple.root") 
TTree* T = F->Get("TutorialChecker/1") 
T->Print() T->Draw("Mass")
 

MC truth

Changed:
<
<
  • For each Bs call a method StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b) where you would handle everything realted to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).
>
>
  • For each Bs call a method
 StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b)
where you would handle everything related to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).
 

Background category tool

The first thing we want to do is to get the background category. This tells you if the reconstructed Bs is correctly reconstructed or if it is background, and which type of background. See the details here.
Changed:
<
<
  • The tool is not pre-declared to DVAlgorithm, so you'll have to declare it. First in the header file: #include "Kernel/IBackgroundCategory.h" and private: IBackgroundCategory* m_background ; Please note that "Kernel/IBackgroundCategory.h" is only found beacause in the package requirements we have a line that says use DaVinciMCKernel v* Phys
  • Initialise it as a private tool in initialize(): m_background = tool("BackgroundCategory",this);
>
>
  • The tool is not pre-declared to DVAlgorithm, so you'll have to declare it. First in the header file:
|
#include "Kernel/IBackgroundCategory.h"
| and
private: IBackgroundCategory* m_background ;
Please note that "Kernel/IBackgroundCategory.h" is only found because in the package requirements we have a line that says
use DaVinciMCKernel v* Phys
  • Initialise it as a private tool in initialize():
|
m_background = tool("BackgroundCategory",this);<>/pre>|

 
  • Before you can use it in fillTruth: IBackgroundCategory::categories cat = m_background->category(b); tuple->fill("category",cat);
  • It's probably a good idea to compile and run at this stage.

Revision 12007-10-01 - unknown

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

DaVinci Tutorial 6

We will create a new algorithm that runs on the found Bs and associates it to truth. It will also fill an nTuple and add some more information about tagging and trigger. There is no chance that you will have enough time to do it all during the practical sessions.

New algorithm

Let's call it TutorialChecker. You need to:
  • Create the cpp and header files. The algorithm is a DVAlgorithm again.
  • Add it to your sequence as you want to run it only for events where you found something.

Tuple filling

  • Create a Tuple in the execute() method.
Tuple tuple = nTuple("TutorialTuple");
Although it does look like an object it actually behaves like a pointer. Be warned that it's not a persistent object. There is no way you can define it in initialise() and keep it for the whole job.
  • Loop over the Bs candidates. You know how to do that.
  • For each Bs call a method StatusCode TutorialChecker::fillReco(Tuple& tuple,const LHCb::Particle* b)
  • In there fill some variables in the Tuple. For instance the mass:
tuple->column( "Mass", b->measuredMass()); // mass
  • The momentum can be filled in one go:
tuple->column( "P", b->momentum()); // 4-vector! 
  • You can also fill the impact parameter of each Bs on each primary vertex. This would go like: std::vector ips, ipes; for ( LHCb::RecVertex::ConstVector::const_iterator ipv = PVs.begin() ; ipv = PVs.end() ; ++ipv ){ double ip, ipe; geomDispCalculator()->calcImpactPar(*b, *(*ipv), ip, ipe); ips.push_back(ip); ipes.push_back(ipe); } tuple->farray( "IP", ips.begin(), ips.end(), "PVs", 20); tuple->farray( "IPe", ipes.begin(), ipes.end(), "PVs", 20); It would be actually more interesting to store the flight distance and the lifetime...
  • You could as well store the vertex, the momenta of the daughters, or anthing else you like...
  • At the end of your execute() method write out the tuple: StatusCode sc = tuple->write();
  • It's probably a good idea to compile and run at this stage. Don't forget to declare the algorithm in your options. You will also have to declare the name of the Tuple you want to save: NTupleSvc.Output={"FILE1 DATAFILE='Tuple.root' TYP='ROOT' OPT='NEW'"};
  • You can then view it in root: TFile* F = new TFile("Tuple.root") TTree* T = F->Get("TutorialChecker/1") T->Print() T->Draw("Mass")

MC truth

  • For each Bs call a method StatusCode TutorialChecker::fillTruth(Tuple& tuple,const LHCb::Particle* b) where you would handle everything realted to truth association. It is a good idea to keep the truth as separate from the rest as possible, so that you can easily switch it off when you run on data not containing MC truth information (like real data...).

Background category tool

The first thing we want to do is to get the background category. This tells you if the reconstructed Bs is correctly reconstructed or if it is background, and which type of background. See the details here.
  • The tool is not pre-declared to DVAlgorithm, so you'll have to declare it. First in the header file: #include "Kernel/IBackgroundCategory.h" and private: IBackgroundCategory* m_background ; Please note that "Kernel/IBackgroundCategory.h" is only found beacause in the package requirements we have a line that says use DaVinciMCKernel v* Phys
  • Initialise it as a private tool in initialize(): m_background = tool("BackgroundCategory",this);
  • Before you can use it in fillTruth: IBackgroundCategory::categories cat = m_background->category(b); tuple->fill("category",cat);
  • It's probably a good idea to compile and run at this stage.

MC association

Now we want to associate our Bs to the true one. We will use the Particle2MCLinker class for this. * Here again one needs to declare everything in the header file: #include "DaVinciAssociators/Particle2MCLinker.h" and private: Particle2MCLinker* m_pLinker; which is found at compilation because we have declared DaVinciAssociators in the requirements file. * Initialise it in initialize(): m_pLinker = new Particle2MCLinker(this,Particle2MCMethod::Composite, ""); * You can now use it in fillTruth: const LHCb::MCParticle* MC = m_pLinker->firstMCP( b ); You can the fill some tuple variables with the MC true Bs. But be careful to check that there is one found. Never use a pointer without checking! * It's probably a good idea to compile and run at this stage.

Tagging

Bs->J/psiPhi is only interesting if we are able to tag the initial flavour of the Bs. * The DVAlgorithm method flavourTagging() provides a pointer to IBTaggingTool. Try to use it to get a FlavourTag object. * Its method decision() tells you the initial flavour of the b quark. * It's probably a good idea to compile and run at this stage. You have to configure the tool to get it working. Unfortunately there's a typo in the released options, so we have a corrected copy in the tutorial package. Add: /// B tagging options #include "$ANALYSISROOT/options/BTaggingTool.opts" Later it would be /// B tagging options #include "$FLAVOURTAGGINGROOT/options/BTaggingTool.opts" * In root compare the tag decision with the true PID. T->Draw("TPID/Tag","Tag!=0")

Trigger

* The first step is already done for you, but if you want to use the trigger in some piece of code, you need to add the following in the relevant package requirements: use L0Event v* Event use HltEvent v* Event * Then in your cpp file add the relevant headers: #include "Event/L0DUReport.h" #include "Event/HltSummary.h" * In your execute, or any other method, get the objects: const LHCb::HltSummary* hlt = get(LHCb::HltSummaryLocation::Default); LHCb::L0DUReport* l0 = get(LHCb::L0DUReportLocation::Default); debug() << "L0 decision is " << l0->decision() << ", HLT: " << hlt->decision() << endmsg ; L0Report presently cannot be declared const as the decision() method is not const. This should be cured someday. * And then fill it in your tuple. tuple->column("L0", l0->decision()); // total decision tuple->column("Hlt", hlt->decision()); // total decision tuple->column("HltMuon", hlt->checkDecisionType(LHCb::HltEnums::Muon)); If you want to use the HLT enums you also have to include Event/HltEnums.

The solution to this part is to be found in solutions/DaVinci6/

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