Skip to content
Snippets Groups Projects

proof-of-concept for a new tupling algorithm

Merged Abhijit Mathad requested to merge newtuplealgo into master
All threads resolved!
4 files
+ 56
41
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -9,9 +9,28 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
"""
Example of tupling with the FunTuple algorithm
"""
from Configurables import LHCbApp
from Gaudi.Configuration import ApplicationMgr, NTupleSvc
from GaudiKernel.Configurable import ConfigurableGeneric as RFileCnv
from Configurables import CondDB
from Configurables import MakeData
from Configurables import FunTuple
######### Define helpful classes and functions
""" Define helpful class and function
class ParticleTupleProp:
A class that one can configure with branch_name, decay descriptor and functors.
Function convert_to_parsable_objs:
Since ParticleTupleProp cannot currently be passed as Gaudi::Property, define
this function to turn member variables into parsable_objs for FunTuple
"""
class ParticleTupleProp:
def __init__(self, branch_name, decay_descriptor, particle_code):
"""
@@ -48,17 +67,7 @@ def convert_to_parsable_objs(particle_tuple_props):
return branch_list, discrp_list, func_list, func_bnamelist, func_rtypelist
#########
from Gaudi.Configuration import *
from Configurables import LHCbApp
from Configurables import LHCb__ParticlePropertySvc
LHCb__ParticlePropertySvc(
) #To turn on verbose set LHCb__ParticlePropertySvc(OutputLevel=1)
from Configurables import CondDB
CondDB(Upgrade=True)
#Configure LHCb application
app = LHCbApp()
app.DataType = "Upgrade"
app.DDDBtag = "dddb-20171126"
@@ -66,17 +75,16 @@ app.CondDBtag = "sim-20171127-vc-md100"
app.Simulation = True
ApplicationMgr().EvtMax = 5
ApplicationMgr().EvtSel = "NONE"
CondDB(Upgrade=True)
#Make MCParticles (just one Bs): Turns out TES is not clever enough to take ownership 'recursively' (set makeCustomData = True if running this algorithm)
from Configurables import MakeData
algMakeData = MakeData(
name="Alg_MakeData",
decay_descriptor=
"[B_s0 => (J/psi(1S) => mu+ mu- ) ( phi(1020) => K+ K-)]CC",
output_location="MCParticle")
#Do we need a custom gaudi property like ParticleTupleProp?
#Configure Particles Bs
#Configure Particles Bs and phi
ParticleBs = ParticleTupleProp(
branch_name="Bs",
decay_descriptor=
@@ -84,18 +92,18 @@ ParticleBs = ParticleTupleProp(
#List of tuple, each tuple (functor, branch name, precision (TODO), description).
particle_code=[('MCP', 'TRUEP', 'double', 'True Moment'),
('MCPT', 'TRUEPT', 'double', 'True Transverse moment')])
#Configure Particles Phi
ParticlePhi = ParticleTupleProp(
branch_name="Phi",
decay_descriptor=
"[B_s0 => (J/psi(1S) => mu+ mu- ) ^( phi(1020) => K+ K-)]CC",
particle_code=[('MCP', 'TRUEP', 'double', 'True Moment'),
('MCPT', 'TRUEPT', 'double', 'True Transverse moment')])
#Do not need to do this if a custom gaudi property is implemented
branchlist, decaydiscrpList, funcList, funcBranchNameList, funcRetunTypeList = convert_to_parsable_objs(
[ParticleBs, ParticlePhi])
from Configurables import FunTuple
#Configure FunTuple algorithm
algtupledata = FunTuple(
name="FunTuple",
tree_name="DecayTree",
@@ -110,9 +118,10 @@ algtupledata = FunTuple(
input_location="MCParticle",
NTupleLUN='tuple')
#add the algorithms to the sequence
ApplicationMgr().TopAlg = [algMakeData, algtupledata]
#Tuple props
#set Tuple properties
outputname = "FunTuple.root"
NTupleSvc().Output = [
"{} DATAFILE='{}' TYP='ROOT' OPT='NEW'".format(algtupledata.NTupleLUN,
@@ -121,5 +130,4 @@ NTupleSvc().Output = [
ApplicationMgr().ExtSvc.append(NTupleSvc())
ApplicationMgr().HistogramPersistency = "ROOT"
# Set the compression level for the ROOT tuple file
from GaudiKernel.Configurable import ConfigurableGeneric as RFileCnv
RFileCnv('RFileCnv').GlobalCompression = "LZMA:6"
Loading