Skip to content

Instantly share code, notes, and snippets.

@mazurov
Created August 29, 2012 09:07
Show Gist options
  • Save mazurov/3508875 to your computer and use it in GitHub Desktop.
Save mazurov/3508875 to your computer and use it in GitHub Desktop.
Upsilons
#!/usr/bin/env python
# =============================================================================
# $Id: Chib.py 140321 2012-05-20 15:54:20Z ibelyaev $
# =============================================================================
## @file BenderExample/Chib.py
# The simple Bender-based example to look for Chi_b-peak
#
# This file is a part of
# <a href="http://cern.ch/lhcb-comp/Analysis/Bender/index.html">Bender project</a>
# <b>``Python-based Interactive Environment for Smart and Friendly
# Physics Analysis''</b>
#
# The package has been designed with the kind help from
# Pere MATO and Andrey TSAREGORODTSEV.
# And it is based on the
# <a href="http://cern.ch/lhcb-comp/Analysis/LoKi/index.html">LoKi project:</a>
# ``C++ ToolKit for Smart and Friendly Physics Analysis''
#
# By usage of this code one clearly states the disagreement
# with the smear campaign of Dr.O.Callot et al.:
# ``No Vanya's lines are allowed in LHCb/Gaudi software.''
#
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2012-02-15
#
# $Revision: 140321 $
# Last modification $Date: 2012-05-20 17:54:20 +0200 (Sun, 20 May 2012) $
# by $Author: ibelyaev $
# =============================================================================
"""
The simple Bender-based example to look for Chi_b-peak
This file is a part of BENDER project:
``Python-based Interactive Environment for Smart and Friendly Physics Analysis''
The project has been designed with the kind help from
Pere MATO and Andrey TSAREGORODTSEV.
And it is based on the
LoKi project: ``C++ ToolKit for Smart and Friendly Physics Analysis''
By usage of this code one clearly states the disagreement
with the smear campaign of Dr.O.Callot et al.:
``No Vanya's lines are allowed in LHCb/Gaudi software.''
$Revision: 140321 $
Last modification $Date: 2012-05-20 17:54:20 +0200 (Sun, 20 May 2012) $
by $Author: ibelyaev $
"""
# =============================================================================
__author__ = " Alexander Mazurov alexander.mazurov@gmail.com"
__date__ = " 2012-06-18 "
__version__ = " Version $$"
# =============================================================================
## import everything from bender
from Bender.Main import *
from GaudiKernel.SystemOfUnits import MeV , GeV, mm
import BenderTools.TisTos
# =============================================================================
## Simple class to look for Chi_b-peak
# @author Vanya BELYAEV ibelyaev@physics.syr.edu
# @date 2006-10-13
class Chib(Algo) :
"""
Simple class to look for Chi_b-peak
"""
## the standard initialization
def initialize ( self ) :
"""
Initialization
"""
sc = Algo.initialize ( self )
if sc.isFailure() : return sc
triggers = {}
triggers[ 'Ups'] = {}
lines = {}
lines ['Ups'] = {}
lines ['Ups'] ['L0TOS' ] = 'L0(Muon|DiMuon).*Decision'
lines ['Ups'] ['L0TIS' ] = 'L0(Hadron|Muon|DiMuon|Photon|Electron)Decision'
lines ['Ups'] ['Hlt1TOS'] = 'Hlt1(DiMuon|SingleMuonHighPT|MuonTrack).*Decision'
lines ['Ups'] ['Hlt1TIS'] = 'Hlt1TrackAll.*Decision'
lines ['Ups'] ['Hlt2TOS'] = 'Hlt2(DiMuon|SingleMuonHighPT).*Decision'
lines ['Ups'] ['Hlt2TIS'] = 'Hlt2(Charm|Topo|Single|Express|Inc|Tri).*Decision'
sc = self.tisTos_initialize ( triggers , lines )
if sc.isFailure() : return sc
self.count = 0
return SUCCESS
## standard mehtod for analysis
def analyse( self ) :
"""
The standard method for analysis
"""
## select dimuons
dimuons = self.select ( 'dimuon' , 'Meson -> mu+ mu-' )
if dimuons.empty() :
return self.Warning ( "No dimuons are found!" , SUCCESS )
## select heavy dimuons
upsilons = self.select ( 'ups' ,
dimuons ,
( 8 * GeV <= M ) & ( M < 12 * GeV ) )
if upsilons.empty() :
return self.Warning ( "No heavy dimuons are found!" , SUCCESS )
# =====================================================================
chi2_dtf = DTF_CHI2NDOF(True)
deltaM = DTF_FUN(M - M1, True)
mups = DTF_FUN(M, True)
minDLLmu = MINTREE(ISBASIC, PIDmu - PIDpi)
kullback = MINTREE(ISBASIC & HASTRACK, CLONEDIST)
dm_1s = ADMASS('Upsilon(1S)')
dm_2s = ADMASS('Upsilon(2S)')
dm_3s = ADMASS('Upsilon(3S)')
# =====================================================================
tup = self.nTuple('Chib')
## collect TisTos-statistics
# =====================================================================
# Loop:
# =====================================================================
for ups in upsilons :
# =================================================================
self.decisions(ups, self.triggers['Ups'])
# =================================================================
mu1 = ups.child(1)
mu2 = ups.child(2)
# =================================================================
#tup.column ( 'dm' , dm / GeV )
tup.column ( 'm', M(ups) / GeV)
tup.column ( 'c2_dtf', chi2_dtf(ups))
tup.column ( 'm_dtf' , mups(ups) / GeV)
tup.column ( 'pt_ups', PT(ups) / GeV )
tup.column ( 'p_mu1', P(mu1) / GeV )
tup.column ( 'p_mu2', P(mu2) / GeV )
tup.column ( 'pt_mu1', PT(mu1) / GeV )
tup.column ( 'pt_mu2', PT(mu2) / GeV )
tup.column ( 'dm_1s', dm_1s(ups) / GeV )
tup.column ( 'dm_2s', dm_2s(ups) / GeV )
tup.column ( 'dm_3s', dm_3s(ups) / GeV )
tup.column ( 'dll_min', minDLLmu(ups))
tup.column ( 'kl_dist', kullback(ups))
tup.write()
# =================================================================
self.count += 1
# if (self.count % 10) == 0:
# self.Warning ( "Upsilons %d" % self.count, SUCCESS)
# =================================================================
return SUCCESS
## finalization
def finalize ( self ) :
"""
Standard finalization
"""
#
#print "COUNT=%d" % self.count
Algo.tisTos_finalize ( self )
return Algo.finalize ( self )
# =============================================================================
## configure the job
def configure ( datafiles , catalogs = [] , castor = False ) :
"""
Configure the job
"""
from Configurables import DaVinci ## needed for job configuration
from Configurables import EventSelector ## needed for job configuration
from PhysConf.Filters import LoKi_Filters
# "/Event/Dimuon/Phys/FullDSTDiMuonDiMuonHighMassLine"
fltrs = LoKi_Filters (
STRIP_Code = """
HLT_PASS_RE ( 'Stripping.*DiMuonHighMass.*Decision' )
""" ,
VOID_Code = """
0 < CONTAINS ('/Event/Dimuon/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles')
"""
)
filters = fltrs.filters('Filters')
filters.reverse()
script = os.path.basename(__file__).split('.')[0]
davinci = DaVinci (
DataType = '2012' ,
PrintFreq = 1000 ,
#EventPreFilters = filters ,
EvtMax = 10000 ,
##
HistogramFile = 'data/%s_histos.root' % script,
TupleFile = 'data/%s_tuples.root' % script,
##
Lumi = True ,
##
)
# =========================================================================
#RootInTES = '/Event/ChiB'
RootInTES = '/Event/Bottomonia/'
# # =========================================================================
# from BenderTools.MicroDST import uDstConf
# uDstConf(RootInTES)
# =========================================================================
from Configurables import Gaudi__IODataManager as IODataManager
IODataManager().AgeLimit = 2
# =========================================================================
# come back to Bender
setData ( datafiles , catalogs , castor )
gaudi = appMgr()
alg = Chib (
'Chib' , ## Algorithm name ,
# input particles
RootInTES = RootInTES ,
# For DiMuon DST
#
#Inputs = ['Phys/Upsilons/Particles'],
Inputs = ['Phys/Upsilon/Particles'],
ParticleCombiners = { '' : 'LoKi::VertexFitter'}
)
# =========================================================================
mainSeq = gaudi.algorithm ('GaudiSequencer/DaVinciUserSequence', True )
mainSeq.Members += [ alg.name() ]
# =========================================================================
return SUCCESS
# =============================================================================
# The actual job steering
if '__main__' == __name__ :
import shelve
## make printout of the own documentations
print '*'*120
print __doc__
print ' Author : %s ' % __author__
print ' Version : %s ' % __version__
print ' Date : %s ' % __date__
print '*'*120
# db = shelve.open("data/data_db","r")
# configure ( db["chi_down"] , castor = True )
db = shelve.open("data/lfns.db","r")
configure ( db["DiMuon.Y&ChiB.Stripping17;Down"] , castor = True )
run (10000)
# =============================================================================
# The END
# =============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment