Skip to content

Latest commit

 

History

History
86 lines (71 loc) · 4.89 KB

18-filter-in-trees.md

File metadata and controls

86 lines (71 loc) · 4.89 KB
layout title subtitle minutes
page
Second steps in LHCb
Reuse particles from a decay tree
10

Learning Objectives {.objectives}

  • Learn how to extract particles from a decay tree
  • Build a new particle from the extracted particles

Sometimes we want to extract a portion of the decay tree in order to build a different decay. To do that, we need to put the particles we're interested in in a new container so they can afterwards be used as inputs to a CombineParticles instance (as we saw in the selection framework lesson). To achieve this we can use the FilterInTrees algorithm, a simple variation of FilterDesktop (doxygen).

Let's start from the example in the selection framework lesson and let's check that the $\pi^-$ child of the $D^0$ does not come from a $\rho\to\pi^+\pi^-$. To do that, we have to extract the $\pi^-$ from ([D0 -> pi+ K-]CC) and combine it with all pions in Phys/StdAllNoPIDsPions/Particles.

Using FilterInTrees is done in the same way we would use FilterDesktop:

from Configurables import FilterInTrees
from PhysSelPython.Wrappers import Selection, DataOnDemand

decay_tree_location = '/Event/AllStreams/Phys/D2hhCompleteEventPromptDst2D2RSLine/Particles'
d0_from_dst = FilterInTrees('d0_from_dst_filter', Code="DECTREE('[Charm -> pi+ K-]CC')")
d0_from_dst_sel = Selection("d0_from_dst_sel",
                            Algorithm=d0_from_dst,
                            RequiredSelections=[AutomaticData(Location=decay_tree_location)])
pions_from_d0 = FilterInTrees('pions_from_d0_filter',Code="('pi+' == ABSID)")
pions_from_d0_sel = Selection("pions_from_d0_sel",
                              Algorithm=pions_from_d0,
                              RequiredSelections=[d0_from_dst_sel])

The output of pions_from_d0_sel is a container with all the pions coming from the $D^0$.

Question {.callout}

Do you see why we couldn't use something simple like

pions_from_d0 = FilterInTrees('pions_from_d0_filter', Code="'pi+' == ABSID")

> ?

Note how we had to do the process in two steps in order to avoid getting the soft pion from the $D^*$.
Sometimes this makes things quite difficult, but almost all problems can be solved with a smart use of the `DECTREE` container in an intermediate step.

> ## Selecting the soft pion {.challenge}
> Can you find of a way of selecting the soft pion?
> Hint: use the `FilterDecays` algorithm, in which you specify a decay descriptor as `Code`, marking the desired particle(s).

The final step is easy, very similar to [building your own decay](https://lhcb.github.io/second-analysis-steps/01-building-decays.html):

```python
from Configurables import CombineParticles
from PhysSelPython.Wrappers import Selection, DataOnDemand

Pions = DataOnDemand('Phys/StdAllNoPIDsPions/Particles')
rho = CombineParticles('rho_particles',
                       DecayDescriptor=['rho(770)0 -> pi+ pi-'],
                       CombinationCut="ADAMASS('rho(770)0') < 300*MeV",
                       MotherCut='(VFASPF(VCHI2/VDOF)< 9)')
rho_sel = Selection('rho_sel',
                    Algorithm=rho,
                    RequiredSelections=[pions_from_d0_sel, Pions])

Unfortunately, the CombineParticles example we just wrote is not exactly what we meant, since it will actually build $\rho$ from all pions it gets as input, not using one from our pions_from_d0 selection and one from 'Phys/StdAllNoPIDsPions/Particles'. How to solve this? We have to get creative and use the tools at hand: for example, we could use SubstitutePID from the previous lesson to change the PID of the pions in the pions_from_d0 selection to kaon and build [rho(770)0 -> K+ pi-]CC and then change again the PID of the kaon to a pion. Of course, if we were reconstructing $K^{*}(892)^{0} \to K^{-}\pi^{+}$ with Phys/StdAllLooseKaons/Particles instead, for example, we would already have everything we need since the ambiguity wouldn't exist.

An interesting detail {.callout}

One can use FilterInTrees and FilterDecays to select several particles at once and obtain a flattened list. For example, if we had a Stripping line that builds [B- -> (^D0 -> ^K- ^pi+) ^pi-]cc and we wanted to combine the $D^0$ and $\pi^-$ with an external $\pi^0$ to build [B- -> D0 pi- pi0]cc, we could do

flatlist = FilterInTrees ("FlatList", Code="('D0' == ABSID) | ('pi-' == ABSID)") from Configurables import CombineParticles add_pi0 = CombineParticles("MakeB", DecayDescriptor = "[B- -> D0 pi- pi0]cc", ... Inputs=[flatlist, resolvedPi0])

> `flatlist` contains both $D^0$ and $\pi^-$, which are then used to build the $B$.