11 import modularAnalysis 
as ma
 
   12 from stdPhotons 
import stdPhotons
 
   13 from vertex 
import kFit
 
   14 from basf2 
import B2WARNING
 
   17 def stdPi0s(listtype="eff60_May2020", path=None, loadPhotonBeamBackgroundMVA=False):
 
   19     Function to prepare one of several standardized types of pi0 lists: 
   21     - 'all' using gamma:all 
   22     - 'eff10_May2020' gamma:pi0eff10_May2020, mass range selection, 10% pi0 efficiency list, optimized in May 2020 
   23     - 'eff20_May2020' gamma:pi0eff20_May2020, mass range selection, 20% pi0 efficiency list, optimized in May 2020 
   24     - 'eff30_May2020' gamma:pi0eff30_May2020, mass range selection, 30% pi0 efficiency list, optimized in May 2020 
   25     - 'eff40_May2020' gamma:pi0eff40_May2020, mass range selection, 40% pi0 efficiency list, optimized in May 2020 
   26     - 'eff50_May2020' gamma:pi0eff50_May2020, mass range selection, 50% pi0 efficiency list, optimized in May 2020 
   27     - 'eff60_May2020' gamma:pi0eff60_May2020, mass range selection, 60% pi0 efficiency list, optimized in May 2020 
   29     You can also append "Fit" to the listtype which will run a mass fit and 
   30     require that the fit did not fail. For example: "pi0:eff50_May2020Fit" is the 50% 
   31     efficiency list plus a not-failing mass fit. 
   34         listtype (str): name of standard list 
   35         path (basf2.Path): modules are added to this path 
   36         loadPhotonBeamBackgroundMVA (bool): If true, photon candidates will be assigned a beam background probability. 
   40         B2WARNING(
"stdPi0s is loading \"May2020\" pi0 recommendations. Please check Neutrals Performance Confluence" 
   41                   " page for most up-to-date pi0 recommendations.")
 
   44         stdPhotons(
'all', path, loadPhotonBeamBackgroundMVA)
 
   45         ma.reconstructDecay(
'pi0:all -> gamma:all gamma:all', 
'', 1, 
True, path)
 
   46         ma.matchMCTruth(
'pi0:all', path)
 
   47     elif 'eff10_May2020' == listtype:
 
   48         stdPhotons(
'pi0eff10_May2020', path, loadPhotonBeamBackgroundMVA)
 
   49         ma.reconstructDecay(
'pi0:eff10_May2020 -> gamma:pi0eff10_May2020 gamma:pi0eff10_May2020',
 
   50                             '0.127<InvM<0.139 and -0.9<daughterDiffOf(0,1,phi)<0.9 and daughterAngle(0,1)<0.8',
 
   54         ma.matchMCTruth(
'pi0:eff10_May2020', path)
 
   55     elif 'eff20_May2020' == listtype:
 
   56         stdPhotons(
'pi0eff20_May2020', path, loadPhotonBeamBackgroundMVA)
 
   57         ma.reconstructDecay(
'pi0:eff20_May2020 -> gamma:pi0eff20_May2020 gamma:pi0eff20_May2020',
 
   58                             '0.121<InvM<0.142 and -1.0<daughterDiffOf(0,1,phi)<1.0 and daughterAngle(0,1)<0.9',
 
   62         ma.matchMCTruth(
'pi0:eff20_May2020', path)
 
   63     elif 'eff30_May2020' == listtype:
 
   64         stdPhotons(
'pi0eff30_May2020', path, loadPhotonBeamBackgroundMVA)
 
   65         ma.reconstructDecay(
'pi0:eff30_May2020 -> gamma:pi0eff30_May2020 gamma:pi0eff30_May2020',
 
   66                             '0.120<InvM<0.145 and -1.5<daughterDiffOf(0,1,phi)<1.5 and daughterAngle(0,1)<1.4',
 
   70         ma.matchMCTruth(
'pi0:eff30_May2020', path)
 
   71     elif 'eff40_May2020' == listtype:
 
   72         stdPhotons(
'pi0eff40_May2020', path, loadPhotonBeamBackgroundMVA)
 
   73         ma.reconstructDecay(
'pi0:eff40_May2020 -> gamma:pi0eff40_May2020 gamma:pi0eff40_May2020', 
'0.120<InvM<0.145', 1, 
True, path)
 
   74         ma.matchMCTruth(
'pi0:eff40_May2020', path)
 
   75     elif 'eff50_May2020_nomcmatch' == listtype:
 
   76         stdPhotons(
'pi0eff50_May2020', path, loadPhotonBeamBackgroundMVA)
 
   78             'pi0:eff50_May2020_nomcmatch -> gamma:pi0eff50_May2020 gamma:pi0eff50_May2020',
 
   83     elif 'eff50_May2020' == listtype:
 
   84         stdPi0s(
'eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
 
   85         ma.cutAndCopyList(
'pi0:eff50_May2020', 
'pi0:eff50_May2020_nomcmatch', 
'', 
True, path)
 
   86         ma.matchMCTruth(
'pi0:eff50_May2020', path)
 
   87     elif 'eff60_May2020_nomcmatch' == listtype:
 
   88         stdPhotons(
'pi0eff60_May2020', path, loadPhotonBeamBackgroundMVA)
 
   90             'pi0:eff60_May2020_nomcmatch -> gamma:pi0eff60_May2020 gamma:pi0eff60_May2020',
 
   95     elif 'eff60_May2020' == listtype:
 
   96         stdPi0s(
'eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
 
   97         ma.cutAndCopyList(
'pi0:eff60_May2020', 
'pi0:eff60_May2020_nomcmatch', 
'', 
True, path)
 
   98         ma.matchMCTruth(
'pi0:eff60_May2020', path)
 
  101     elif listtype == 
'skim':
 
  102         stdPi0s(
'eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
 
  103         ma.cutAndCopyList(
'pi0:skim', 
'pi0:eff50_May2020_nomcmatch', 
'', 
True, path)
 
  104         kFit(
'pi0:skim', 0.0, 
'mass', path=path)
 
  105     elif listtype == 
'SkimHighEff':
 
  106         stdPi0s(
'eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
 
  107         ma.cutAndCopyList(
'pi0:SkimHighEff', 
'pi0:eff60_May2020_nomcmatch', 
'', 
True, path)
 
  108         kFit(
'pi0:SkimHighEff', 0.0, 
'mass', path=path)
 
  111     elif listtype == 
'allFit':
 
  112         stdPi0s(
'all', path, loadPhotonBeamBackgroundMVA)
 
  113         ma.cutAndCopyList(
'pi0:allFit', 
'pi0:all', 
'', 
True, path)
 
  114         kFit(
'pi0:allFit', 0.0, 
'mass', path=path)
 
  115     elif listtype == 
'eff10_May2020Fit':
 
  116         stdPi0s(
'eff10_May2020', path, loadPhotonBeamBackgroundMVA)
 
  117         ma.cutAndCopyList(
'pi0:eff10_May2020Fit', 
'pi0:eff10_May2020', 
'', 
True, path)
 
  118         kFit(
'pi0:eff10_May2020Fit', 0.0, 
'mass', path=path)
 
  119     elif listtype == 
'eff20_May2020Fit':
 
  120         stdPi0s(
'eff20_May2020', path, loadPhotonBeamBackgroundMVA)
 
  121         ma.cutAndCopyList(
'pi0:eff20_May2020Fit', 
'pi0:eff20_May2020', 
'', 
True, path)
 
  122         kFit(
'pi0:eff20_May2020Fit', 0.0, 
'mass', path=path)
 
  123     elif listtype == 
'eff30_May2020Fit':
 
  124         stdPi0s(
'eff30_May2020', path, loadPhotonBeamBackgroundMVA)
 
  125         ma.cutAndCopyList(
'pi0:eff30_May2020Fit', 
'pi0:eff30_May2020', 
'', 
True, path)
 
  126         kFit(
'pi0:eff30_May2020Fit', 0.0, 
'mass', path=path)
 
  127     elif listtype == 
'eff40_May2020Fit':
 
  128         stdPi0s(
'eff40_May2020', path, loadPhotonBeamBackgroundMVA)
 
  129         ma.cutAndCopyList(
'pi0:eff40_May2020Fit', 
'pi0:eff40_May2020', 
'', 
True, path)
 
  130         kFit(
'pi0:eff40_May2020Fit', 0.0, 
'mass', path=path)
 
  131     elif listtype == 
'eff50_May2020Fit':
 
  132         stdPi0s(
'eff50_May2020', path, loadPhotonBeamBackgroundMVA)
 
  133         ma.cutAndCopyList(
'pi0:eff50_May2020Fit', 
'pi0:eff50_May2020', 
'', 
True, path)
 
  134         kFit(
'pi0:eff50_May2020Fit', 0.0, 
'mass', path=path)
 
  135     elif listtype == 
'eff60_May2020Fit':
 
  136         stdPi0s(
'eff60_May2020', path, loadPhotonBeamBackgroundMVA)
 
  137         ma.cutAndCopyList(
'pi0:eff60_May2020Fit', 
'pi0:eff60_May2020', 
'', 
True, path)
 
  138         kFit(
'pi0:eff60_May2020Fit', 0.0, 
'mass', path=path)
 
  140         raise ValueError(f
"\"{listtype}\" is none of the allowed standardized types of pi0 lists!")
 
  145 def loadStdSkimPi0(path):
 
  147     Function to prepare the skim pi0 lists. 
  150         Should only be used by skims. 
  153         path (basf2.Path) modules are added to this path 
  156     stdPi0s(
'skim', path, loadPhotonBeamBackgroundMVA=
False)
 
  159 def loadStdSkimHighEffPi0(path):
 
  161     Function to prepare the high-efficiency skim pi0 lists based on eff60_May2020 list. 
  164         Should only be used by skims. 
  167         path (basf2.Path) modules are added to this path 
  170     stdPi0s(
'SkimHighEff', path, loadPhotonBeamBackgroundMVA=
False)