From d6259784ac74f888498850c47b4648c56910e678 Mon Sep 17 00:00:00 2001
From: "vitalii.lisovskyi@cern.ch" <vitalii.lisovskyi@cern.ch>
Date: Mon, 21 Jun 2021 13:57:29 +0200
Subject: [PATCH 1/2] expand the electron ID line

---
 .../StrippingCalib/StrippingElectronID.py     | 120 +++++++++++++++++-
 1 file changed, 116 insertions(+), 4 deletions(-)

diff --git a/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py b/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
index b0fb496c3..0354163d6 100644
--- a/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
+++ b/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
@@ -21,8 +21,8 @@ stream.appendLines( [
     ])
 '''
 
-__author__=['Jibo He']
-__date__ = '03/10/2010'
+__author__=['Jibo He','Vitalii Lisovskyi']
+__date__ = '21/06/2021'
 __version__= '$Revision: 1.2 $'
 
 
@@ -64,7 +64,15 @@ config_default =  {
         'Bu2JpsieeKLine_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK >5) & (BPVIPCHI2()>9)", #  & (PIDK >0)
         'Bu2JpsieeKLine_JpsiCut'   : "(BPVDLS>4)",
         'Bu2JpsieeKLine_BuComCut'  : "in_range(4.1*GeV,AM,6.1*GeV)",
-        'Bu2JpsieeKLine_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<9)"
+        'Bu2JpsieeKLine_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<6) & (PT>2700)",
+
+        'Bu2JpsieeKLine_notagID_Prescale'  :  1,
+        'Bu2JpsieeKLine_notagID_HltFilter' : None,
+        'Bu2JpsieeKLine_notagID_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK>3) & (BPVIPCHI2()>9)", #  & (PIDK >0)
+        'Bu2JpsieeKLine_notagID_JpsiCut'   : "(BPVDLS>4)",
+        'Bu2JpsieeKLine_notagID_BuComCut'  : "in_range(3.6*GeV,AM,8.*GeV)",
+        'Bu2JpsieeKLine_notagID_BuMomCut'  : "(PT>3200) & (VFASPF(VCHI2PDOF)<6) & in_range(4.45*GeV,DTF_FUN(M,True,'J/psi(1S)'),6.0*GeV)"
+        #'Bu2JpsieeKLine_notagID_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<6) & (PT>3000)",
         }
 
 default_config = {
@@ -118,9 +126,32 @@ class ElectronIDConf(LineBuilder):
                                     eeMaxMass = config['eeMaxMass']
                                     )
 
+        self.JpsiList= makeEE_notagID( 'ee_notagIDFor'+self.name,
+                                    #
+                                    Both_PT = config['Both_PT'],
+                                    Both_P = config['Both_P'],
+                                    Both_TRCHI2DOF = config['Both_TRCHI2DOF'],
+                                    Both_MIPCHI2 = config['Both_MIPCHI2'],
+                                    #
+                                    Tag_PT = config['Tag_PT'],
+                                    Tag_P = config['Tag_P'],
+                                    #Tag_PIDe = config['Tag_PIDe'],
+                                    Tag_MIPCHI2 = config['Tag_MIPCHI2'],
+                                    #
+                                    Probe_PT = config['Probe_PT'],
+                                    Probe_P = config['Probe_P'],
+                                    Probe_MIPCHI2 = config['Probe_MIPCHI2'],
+                                    #
+                                    eeCombMinMass = config['eeCombMinMass'],
+                                    eeCombMaxMass = config['eeCombMaxMass'],
+                                    eeVCHI2PDOF = config['eeVCHI2PDOF'],
+                                    eeMinMass = config['eeMinMass'],
+                                    eeMaxMass = config['eeMaxMass']
+                                    )
+
         self.makeJpsi2eeLine()
         self.makeBu2JpsieeKLine()
-
+        self.makeBu2JpsieeKLine_notagID()
 
     def createSubSel( self, OutputList, InputList, Cuts ) :
         '''create a selection using a FilterDesktop'''
@@ -184,6 +215,26 @@ class ElectronIDConf(LineBuilder):
                                         )
         self.registerLine( Bu2JpsieeKLine )
 
+    def makeBu2JpsieeKLine_notagID( self ):
+
+        from StandardParticles import StdTightKaons
+
+        Bu2JpsieeK_notagID = self.createCombinationSel(
+            OutputList = "Bu2JpsieeK_notagIDFor" + self.name,
+            DecayDescriptor = "[B+ -> J/psi(1S) K+]cc",
+            DaughterLists = [ self.JpsiList, StdTightKaons ],
+                DaughterCuts = { "J/psi(1S)" :  self.config['Bu2JpsieeKLine_notagID_JpsiCut'],
+                                 "K+"        :  self.config['Bu2JpsieeKLine_notagID_KaonCut']},
+                PreVertexCuts = self.config['Bu2JpsieeKLine_notagID_BuComCut'],
+                PostVertexCuts = self.config['Bu2JpsieeKLine_notagID_BuMomCut'] )
+
+        Bu2JpsieeKLine_notagID = StrippingLine( self.name + "Bu2JpsiK_notagIDLine",
+                                        HLT       = self.config['Bu2JpsieeKLine_notagID_HltFilter'],
+                                        algos = [ Bu2JpsieeK_notagID ] ,
+                                        RequiredRawEvents=["Trigger", "Muon", "Calo", "Rich", "Velo", "Tracker"],
+                                        prescale = self.config["Bu2JpsieeKLine_notagID_Prescale"]
+                                        )
+        self.registerLine( Bu2JpsieeKLine_notagID )
 
 def makeEE( name,
             #
@@ -244,3 +295,64 @@ def makeEE( name,
                       Algorithm = _EE,
                       RequiredSelections = [ NoPIDsElectronsForElectronID ]
                       )
+
+
+def makeEE_notagID( name,
+            #
+            Both_PT,
+            Both_P,
+            Both_TRCHI2DOF,
+            Both_MIPCHI2,
+            #
+            Tag_PT,
+            Tag_P,
+            #Tag_PIDe,
+            Tag_MIPCHI2,
+            #
+            Probe_PT,
+            Probe_P,
+            Probe_MIPCHI2,
+            #
+            eeCombMinMass,
+            eeCombMaxMass,
+            eeVCHI2PDOF,
+            eeMinMass,
+            eeMaxMass
+            ):
+
+    from StandardParticles import StdNoPIDsElectrons as NoPIDsElectronsForElectronID
+
+    InAccCuts = "(0.5<PPINFO(LHCb.ProtoParticle.InAccEcal,-1))"
+
+    BothCuts = "(PT> %(Both_PT)s *MeV)"\
+               " & (TRCHI2DOF < %(Both_TRCHI2DOF)s)"\
+               " & (MINTREE('e+'==ABSID,BPVIPCHI2())> %(Both_MIPCHI2)s )" % locals()
+
+    EEComCut = "(in_range(%(eeCombMinMass)s *MeV, AM, %(eeCombMaxMass)s *MeV))" % locals()
+
+    EEMomCut = "(VFASPF(VCHI2)< %(eeVCHI2PDOF)s)"\
+               " & (in_range(%(eeMinMass)s *MeV, MM, %(eeMaxMass)s *MeV))" % locals()
+
+    Tag1Cuts = "(CHILDCUT((PT>%(Tag_PT)s*MeV),1)) & (CHILDCUT((P>%(Tag_P)s*MeV),1))"\
+               " & (CHILDCUT((BPVIPCHI2()> %(Tag_MIPCHI2)s),1))" % locals()
+    Tag2Cuts = "(CHILDCUT((PT>%(Tag_PT)s*MeV),2)) & (CHILDCUT((P>%(Tag_P)s*MeV),2))"\
+               " & (CHILDCUT((BPVIPCHI2()> %(Tag_MIPCHI2)s),2))" % locals()
+
+    Probe1Cuts = "(CHILDCUT((PT>%(Probe_PT)s*MeV),1)) & (CHILDCUT((P>%(Probe_P)s*MeV),1))"\
+                 " & (CHILDCUT((BPVIPCHI2()> %(Probe_MIPCHI2)s),1))" % locals()
+    Probe2Cuts = "(CHILDCUT((PT>%(Probe_PT)s*MeV),2)) & (CHILDCUT((P>%(Probe_P)s*MeV),2))"\
+                 " & (CHILDCUT((BPVIPCHI2()> %(Probe_MIPCHI2)s),2))" % locals()
+
+    Tag1Probe2Cuts = Tag1Cuts + " & " + Probe2Cuts
+    Tag2Probe1Cuts = Tag2Cuts + " & " + Probe1Cuts
+
+    _EE = CombineParticles( DecayDescriptor = "J/psi(1S) -> e+ e-",
+                            DaughtersCuts = {"e+" : InAccCuts + "&" + BothCuts },
+                            CombinationCut = EEComCut,
+                            MotherCut = EEMomCut + " & ( ( " + Tag1Probe2Cuts + " ) | (" + Tag2Probe1Cuts + " ) ) "
+                            )
+
+    return Selection( name,
+                      Algorithm = _EE,
+                      RequiredSelections = [ NoPIDsElectronsForElectronID ]
+                      )
-- 
GitLab


From 5eb3e9e4064487af61ab258f121438313c7e941b Mon Sep 17 00:00:00 2001
From: Vitalii Lisovskyi <vitalii.lisovskyi@cern.ch>
Date: Tue, 22 Jun 2021 14:48:24 +0000
Subject: [PATCH 2/2] fix the buggy cuts

---
 .../StrippingCalib/StrippingElectronID.py        | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py b/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
index 0354163d6..303a20f8e 100644
--- a/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
+++ b/Phys/StrippingSelections/python/StrippingSelections/StrippingCalib/StrippingElectronID.py
@@ -61,17 +61,17 @@ config_default =  {
 
         'Bu2JpsieeKLine_Prescale'  :  1,
         'Bu2JpsieeKLine_HltFilter' : None,
-        'Bu2JpsieeKLine_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK >5) & (BPVIPCHI2()>9)", #  & (PIDK >0)
+        'Bu2JpsieeKLine_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK>5) & (BPVIPCHI2()>9)", #  & (PIDK >0)
         'Bu2JpsieeKLine_JpsiCut'   : "(BPVDLS>4)",
         'Bu2JpsieeKLine_BuComCut'  : "in_range(4.1*GeV,AM,6.1*GeV)",
-        'Bu2JpsieeKLine_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<6) & (PT>2700)",
+        'Bu2JpsieeKLine_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<9)",
 
         'Bu2JpsieeKLine_notagID_Prescale'  :  1,
         'Bu2JpsieeKLine_notagID_HltFilter' : None,
-        'Bu2JpsieeKLine_notagID_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK>3) & (BPVIPCHI2()>9)", #  & (PIDK >0)
+        'Bu2JpsieeKLine_notagID_KaonCut'   : "(TRCHI2DOF<4) & (PT>1.0*GeV) & (P>3.0*GeV) & (PIDK>5) & (BPVIPCHI2()>9)", #  & (PIDK >0)
         'Bu2JpsieeKLine_notagID_JpsiCut'   : "(BPVDLS>4)",
         'Bu2JpsieeKLine_notagID_BuComCut'  : "in_range(3.6*GeV,AM,8.*GeV)",
-        'Bu2JpsieeKLine_notagID_BuMomCut'  : "(PT>3200) & (VFASPF(VCHI2PDOF)<6) & in_range(4.45*GeV,DTF_FUN(M,True,'J/psi(1S)'),6.0*GeV)"
+        'Bu2JpsieeKLine_notagID_BuMomCut'  : "(PT>3200) & (VFASPF(VCHI2PDOF)<9) & in_range(4.5*GeV,DTF_FUN(M,True,'J/psi(1S)'),6.0*GeV)"
         #'Bu2JpsieeKLine_notagID_BuMomCut'  : "in_range(4.2*GeV,M, 6.0*GeV) & (VFASPF(VCHI2PDOF)<6) & (PT>3000)",
         }
 
@@ -80,7 +80,7 @@ default_config = {
     'WGs'         : ['Calib'],
     'BUILDERTYPE' : 'ElectronIDConf',
     'CONFIG'      : config_default,
-    'STREAMS'     :  [ 'BhadronCompleteEvent' ] #[ 'PID' ]
+    'STREAMS'     : { 'Leptonic' : ['StrippingElectronIDCalibBu2JpsiK_notagIDLine'], 'BhadronCompleteEvent' : ['StrippingElectronIDCalibBu2JpsiKLine'] }
     }
 
 
@@ -126,7 +126,7 @@ class ElectronIDConf(LineBuilder):
                                     eeMaxMass = config['eeMaxMass']
                                     )
 
-        self.JpsiList= makeEE_notagID( 'ee_notagIDFor'+self.name,
+        self.JpsiList_notagID= makeEE_notagID( 'ee_notagIDFor'+self.name,
                                     #
                                     Both_PT = config['Both_PT'],
                                     Both_P = config['Both_P'],
@@ -222,7 +222,7 @@ class ElectronIDConf(LineBuilder):
         Bu2JpsieeK_notagID = self.createCombinationSel(
             OutputList = "Bu2JpsieeK_notagIDFor" + self.name,
             DecayDescriptor = "[B+ -> J/psi(1S) K+]cc",
-            DaughterLists = [ self.JpsiList, StdTightKaons ],
+            DaughterLists = [ self.JpsiList_notagID, StdTightKaons ],
                 DaughterCuts = { "J/psi(1S)" :  self.config['Bu2JpsieeKLine_notagID_JpsiCut'],
                                  "K+"        :  self.config['Bu2JpsieeKLine_notagID_KaonCut']},
                 PreVertexCuts = self.config['Bu2JpsieeKLine_notagID_BuComCut'],
@@ -322,7 +322,7 @@ def makeEE_notagID( name,
 
     from StandardParticles import StdNoPIDsElectrons as NoPIDsElectronsForElectronID
 
-    InAccCuts = "(0.5<PPINFO(LHCb.ProtoParticle.InAccEcal,-1))"
+    InAccCuts = "(ALL)"#"(0.5<PPINFO(LHCb.ProtoParticle.InAccEcal,-1))"
 
     BothCuts = "(PT> %(Both_PT)s *MeV)"\
                " & (TRCHI2DOF < %(Both_TRCHI2DOF)s)"\
-- 
GitLab