umd-lhcb / lhcb-ntuples-gen

ntuples generation with DaVinci and in-house offline components
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Documenting `BARE` cuts and checking DaVinci script #74

Closed manuelfs closed 3 years ago

manuelfs commented 3 years ago

I went through the reco_Dst.py and reco_Dst_D0.py scripts used in tags 0.9.0 and an update to 0.9.4 comparing the cuts used to produce the old and new BARE ntuples. The following table (.tex, .pdf) is my first attempt

image

I imagine there's no difference between using AALL and ATRUE in the CombinationCut, though this link seems to indicate that ALL (missing an A) is for particles and ATRUE is for combination cuts.

One subtle thing I was puzzled with initially is that cuts are some times overwritten and some times added, like in this example for the D0.DaughtersCuts

algo_D0.DaughtersCuts = {
    'K+': '(MIPCHI2DV(PRIMARY) > 9.0) &'
          '(P > 2.0*GeV) & (PT > 300.0*MeV) &'
          '(TRGHOSTPROB < 0.5)',
    'pi-': '(P > 2.0*GeV) & (PT > 300.0*MeV) &'
           '(MIPCHI2DV(PRIMARY) > 9.0) &'
           '(TRGHOSTPROB < 0.5)'
}

if has_flag('BARE'):
    algo_D0.DaughtersCuts = {
        'K+': '(MIPCHI2DV(PRIMARY) > 4.5) & (TRGHOSTPROB < 1.0)',
        'pi-': '(MIPCHI2DV(PRIMARY) > 4.5) & (TRGHOSTPROB < 1.0)'
    }

# PID for real data only
if not DaVinci().Simulation and not has_flag('BARE'):
    algo_D0.DaughtersCuts['K+'] = \
        '(PIDK > 4.0) &' + algo_D0.DaughtersCuts['K+']

    algo_D0.DaughtersCuts['pi-'] = \
        '(PIDK < 2.0) &' + algo_D0.DaughtersCuts['pi-']

if DaVinci().Simulation:
    algo_D0.DaughtersCuts['K+'] = \
        "(mcMatch('[^K+]CC')) &" \
        '(MCSELMATCH(MCNINANCESTORS(BEAUTY) > 0)) &' + \
        algo_D0.DaughtersCuts['K+']
    algo_D0.DaughtersCuts['pi-'] = \
        '(MCSELMATCH(MCNINANCESTORS(BEAUTY) > 0)) &' + \
        algo_D0.DaughtersCuts['pi-']

# NOTE: These cuts are from Hlt2XcMuXForTauB2XcMu lines. They are tigher than
#       stripping cuts
if DaVinci().Simulation and not has_flag('BARE'):
    algo_D0.DaughtersCuts['K+'] = \
        '(P > 5.0*GeV) &' + algo_D0.DaughtersCuts['K+']
    algo_D0.DaughtersCuts['pi-'] = \
        '(P > 5.0*GeV) &' + algo_D0.DaughtersCuts['pi-']

I'll need to check more carefully the non-BARE parts, but so far, the new script seems fine.

manuelfs commented 3 years ago

I summarized the cuts applied for the standard data and MC DaVinci reconstruction Run 1 and Run 2 in data and MC (.tex, .pdf)

image

As far as I can tell, these look ok, except perhaps for the Run 2 trigger filtering which I simply do not understand. This is applied to data with the function

def trigger_filter(sel, B_meson='B0', suffix=''):
    if DaVinci().Simulation or has_flag('CUTFLOW'):
        return sel  # Don't do anything about trigger for these modes!

    sel_name = 'SelMy{}{}TriggerFiltered'.format(B_meson, suffix)

    algo = FilterDesktop(
        'MyTriggerFiltered{}{}'.format(B_meson, suffix),
        Code='''
INTREE((ABSID == 'D0') & TOS('Hlt1.*TrackMVADecision', 'Hlt1TriggerTisTos')) & (
    INTREE((ABSID == '{b}') &
        TIS('L0Global', 'L0TriggerTisTos')
    ) |
    INTREE((ABSID == 'D0') &
        TOS('L0HadronDecision', 'L0TriggerTisTos'))
) & INTREE((ABSID == '{b}') &
        TOS('{hlt2}', 'Hlt2TriggerTisTos')
)'''.format(b=B_meson, hlt2=hlt2_trigger)
    )

    return Selection(sel_name, Algorithm=algo, RequiredSelections=[sel])

sel_B0_stub = trigger_filter(sel_B0)
seq_B0 = SelectionSequence('SeqMyB0', TopSelection=sel_B0_stub)

I think it may be trying to apply our full Run 2 trigger

(b0_L0Global_TIS || d0_L0HadronDecision_TOS) 
  && (d0_Hlt1TrackMVADecision_TOS  || k_Hlt1TrackMVADecision_TOS || pi_Hlt1TrackMVADecision_TOS) 
  && b0_Hlt2XcMuXForTauB2XcMuDecision_TOS

but I can't follow the code.

The MC is not filtered with this function, and instead, it looks like all the cuts except for PID are correctly applied independently.

manuelfs commented 3 years ago

The code above applies the trigger for data fine.

Checked that k_Hlt1TrackMVADecision_TOS || pi_Hlt1TrackMVADecision_TOS is very similar to d0_Hlt1TrackMVADecision_TOS

(base) |16:12:44|~/code/lhcb-ntuples-gen$ rut ntuples/0.9.4-trigger_emulation/Dst_D0-cutflow_mc/Dst_D0--21_05_29--cutflow_mc--bare--MC_2016_Beam6500GeV-2016-MagDown-Nu1.6-25ns-Pythia8_Sim09b_Trig0x6138160F_Reco16_Turbo03_Stripping26NoPrescalingFlagged_11874091_ALLSTREAMS.DST.root 
root [0] 
Attaching file ntuples/0.9.4-trigger_emulation/Dst_D0-cutflow_mc/Dst_D0--21_05_29--cutflow_mc--bare--MC_2016_Beam6500GeV-2016-MagDown-Nu1.6-25ns-Pythia8_Sim09b_Trig0x6138160F_Reco16_Turbo03_Stripping26NoPrescalingFlagged_11874091_ALLSTREAMS.DST.root as _file0...
(TFile *) 0x7ff278c90b90
root [1] _file0->cd("TupleB0")
(bool) true
root [2] DecayTree->GetEntries()
(long long) 199668
root [4] DecayTree->GetEntries("d0_Hlt1TwoTrackMVADecision_TOS  || k_Hlt1TrackMVADecision_TOS || pi_Hlt1TrackMVADecision_TOS")
(long long) 77883
root [5] DecayTree->GetEntries("d0_Hlt1TwoTrackMVADecision_TOS  || d0_Hlt1TrackMVADecision_TOS")
(long long) 77883