Skip to content
Snippets Groups Projects
Commit 8f99e50b authored by Eduardo Rodrigues's avatar Eduardo Rodrigues Committed by Abhijit Mathad
Browse files

Remove legacy package Phys/DaVinciTrackScaling

parent e4a8579a
No related branches found
No related tags found
1 merge request!1021Remove legacy package Phys/DaVinciTrackScaling
Showing
with 3 additions and 634 deletions
......@@ -3,7 +3,6 @@ extend-ignore = E501
exclude =
*.opts.py
Phys/AnalysisPython/*
Phys/DaVinciTrackScaling/*
select = F, # all PyFlakes warning/error codes
E71, # pycodestyle: check comparison to None/True
E9, # runtime errors
......
......@@ -22,7 +22,7 @@ repos:
hooks:
- id: mypy
files: Phys
exclude: "(tests|Phys/JetAccessoriesMC|Phys/DaVinciTrackScaling|Phys/AnalysisPython)"
exclude: "(tests|Phys/JetAccessoriesMC|Phys/AnalysisPython)"
additional_dependencies: [types-requests]
args: [--show-error-codes]
- repo: https://github.com/codespell-project/codespell
......@@ -32,7 +32,7 @@ repos:
exclude: ^(.*\.ref|.*\.detdesc|.*\.notes|.*\.md)$
args: [
"--skip",
"Phys/AnalysisPython/*,Phys/DaVinciTrackScaling/*"
"Phys/AnalysisPython/*"
]
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
......
###############################################################################
# (c) Copyright 2000-2022 CERN for the benefit of the LHCb Collaboration #
# (c) Copyright 2000-2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
......@@ -36,7 +36,6 @@ endif()
lhcb_add_subdirectories(
Phys/AnalysisPython
Phys/DaVinciMCTools
Phys/DaVinciTrackScaling
Phys/FunTuple
Phys/JetAccessoriesMC
)
......
###############################################################################
# (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
#[=======================================================================[.rst:
Phys/DaVinciTrackScaling
------------------------
#]=======================================================================]
gaudi_install(PYTHON)
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
!-----------------------------------------------------------------------------
! Package : Phys/DaVinciTrackScaling
! Responsible : Vanya Belyaev
! Purpose : Track scaling and smearing
!-----------------------------------------------------------------------------
! 2017-01-11 - Vanya Belyaev
- prepare scripts for momenentum scaling for -2015&2016
!=================== DaVinciTrackScaling v1r6 2016-02-04 =====================
! 2015-12-05 - Gerhard Raven
- replace outputLevel with msgLevel
!=================== DaVinciTrackScaling v1r5 2015-12-04 =====================
! 2015-12-03 - Vanya Belyaev
- update for scripts
! 2015-11-01 - Gerhard Raven
- replace endreq with endmsg
!=================== DaVinciTrackScaling v1r4 2015-01-16 =====================
! 2015-01-16 - Eduardo Rodrigues
- Added python/DaVinciTrackScaling/__init__.py to please CMake.
!========================= DaVinciTrackScaling v1r3p1 2014-10-30 =========================
! 2014-09-19 - Marco Clemencic
- Fixed compilation problem with head version of ROOT.
(same problem as yesterday, but in a slightly different place).
! 2014-09-18 - Marco Clemencic
- Fixed compilation problem with head version of ROOT.
!========================= DaVinciTrackScaling v1r3 2013-10-07 =========================
! 2013-10-05 - Vanya Belyaev
- TrackScaleState: reduce printout
! 2013-10-05 - Vanya Belyaev
- TrackScaleState
remove some bad-intereference with ROOT memory management
(actually it needs to be fixed in XmlBaseConditionCnv.cpp)
!========================= DaVinciTrackScaling v1r2 2013-08-01 =========================
! 2013-07-12 M Needham
- Fix some warnings
! 2013-07-11 - Vanya Belyaev
- TrackSmearState : Add property RootFile to read TGraph-"res;1"
from a file.
! 2013-07-10 M Needham
- Add the old momentum smearing code that allows simple access to rootfile
containing histogram. This code is well tested and works.
I hope in the future this functionality will be provided by the official
code, allowing this hack to be depreciated.
! 2013-06-01 - M Needham
- Allow momentum calibration to applied also to downstream tracks.
!========================= DaVinciTrackScaling v1r1 2013-06-13 =========================
! 2013-05-26 - Vanya Belyaev
- Helper scripts to fill CONDDB: Remove "comment" attribute for Condition object
!========================= DaVinciTrackScaling v1r0 2013-05-07 =========================
! 2013-04-27 - Chris Jones
- First import. Components moved from Phys/DaVinciTools
#!/usr/bin/env python
###############################################################################
# (c) Copyright 2000-2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# =============================================================================
# @file DaVinciTools/covariance_scale.py
#
# Helper script to convert input data histogram to XML-format
#
# Input data are specified close to the start of the script
#
# - input ROOT file with histogram 'CovScale'
#
# As the output xml-file CovarianceScale.xml is generated in cwd
#
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2013-04-20
#
# ============================================================================
"""
Input data are specified close to the start of the script
- input ROOT file with histogram 'CovScale'
As the output xml-file CovarianceScale.xml is generated in cwd
"""
# ============================================================================
__author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
__date__ = "2013-04-20"
# ============================================================================
print(100 * "*")
print(__doc__)
print(100 * "*")
# ============================================================================
import ROOT
from Ostap.PyRoUts import hID, h1_axis
# =============================================================================
## get the data
# =============================================================================
#
year = "2k+12"
reco = "????"
sim = "????"
#
directory = "/afs/cern.ch/user/i/ibelyaev/public/"
filename = "covscale.root"
the_file = ROOT.TFile(directory + filename)
print(100 * "*")
print("HISTOS are read from ", directory + filename)
print(the_file.ls())
print(100 * "*")
#
histo = the_file.Get("CovScale")
#
# =============================================================================
# Build XML-document
# =============================================================================
##
line1 = '<?xml version="1.0" encoding="ISO-8859-1"?>'
line2 = '<!DOCTYPE DDDB SYSTEM "../../../DTD/structure.dtd">'
##
## import lxml.etree
import lxml.builder
E = lxml.builder.ElementMaker()
DDDB = E.DDDB
CONDITION = E.condition
PARAM = E.param
smear = PARAM(
histo.toString(),
name="Scale",
type="Histo1D",
comment=f"Covariance scale {sim} {reco} {year} ",
)
document = DDDB(
CONDITION(
smear,
## comment = 'Covariance scale %s %s %s ' % ( sim , reco , year ) ,
name="CovarianceScale",
),
)
xml_name = "CovarianceScale.xml"
xml_file = open(xml_name, "w")
print(
line1 + "\n" + line2 + "\n\n\n" + lxml.etree.tostring(document, pretty_print=True),
file=xml_file,
)
xml_file.close()
print(100 * "*")
print('XML file "%s" is generated in CWD ' % xml_name)
print(100 * "*")
# =============================================================================
# The END
# =============================================================================
#!/usr/bin/env python
###############################################################################
# (c) Copyright 2000-2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# =============================================================================
# @file momentum_scale.py
#
# Helper script to convert input data (histograms + offsets) to XML-format
#
# Input data are specified close to the start of the script:
#
# - input ROOT file with historams
# the file should have two 2D-histograms, named as 'idp-plus' and 'idp-minus'
#
# - global delta
# - list of run-dependent offsets as list of triplets: [ (start,stop,offset) ],
# where (start,stop) represent the run range (both edges are inclusive)
#
# As the output xml-file MomentumScale.xml is generated in cwd
#
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2013-04-20
# @see TrackScaleState
#
# ============================================================================
"""
Helper script to convert input data (histograms + offsets) to XML-format
Input data are specified close to the start of the script
- input ROOT file with historams
the file should have two 2D-histograms, named as 'idp-plus' and 'idp-minus'
- global delta
- list of run-dependent offsets as list of triplets: [ (start,stop,offset) ],
where (start,stop) represent the run range (both edges are inclusive)
As the output xml-file MomentumScale.xml is generated in cwd
"""
# ============================================================================
__author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
__date__ = "2013-04-20"
__all__ = ("logger", "buildXML", "offsets_to_histo")
# ============================================================================
import ROOT
from Ostap.PyRoUts import h1_axis, VE
# ============================================================================
from Ostap.Logger import getLogger
logger = getLogger("MomentumScale")
# ============================================================================
# ============================================================================
## convert run offsets into the histogram
# @param offset the list of run-dependes offsets: [ (start,stop,offset) ]
# @param title (optional) the histogram title
# @code
# offsets_2011 = [
# ## start stop offset
# ( 89333 , 90256 , 9.97629e-05 ) ,
# ( 90257 , 90763 , 6.01683e-06 ) ,
# ( 91556 , 93282 , 5.33486e-05 ) ,
# ( 93398 , 94386 , 0.000183575 ) ,
# ]
# histo = offsets_to_histo ( offets_2011 )
# @endcode
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2013-04-20
#
def offsets_to_histo(offsets, title=""):
"""Helper function to convert the offset list into histogram
offsets_2011 = [
## start stop offset
( 89333 , 90256 , 9.97629e-05 ) ,
( 90257 , 90763 , 6.01683e-06 ) ,
( 91556 , 93282 , 5.33486e-05 ) ,
( 93398 , 94386 , 0.000183575 ) ,
]
histo = offsets_to_histo ( offets_2011 )
"""
#
# make the axis ticks
ticks = set()
for i in offsets:
ticks.add(i[0])
ticks.add(i[1] + 1) ## take care about equality
## create the histogram with appropriate binnings
h = h1_axis(list(ticks), double=True, title=title)
for i in offsets:
mid = 0.5 * (i[0] + i[1])
bin = h.findBin(mid)
h[bin] = VE(i[2], 0)
return h
line1 = '<?xml version="1.0" encoding="ISO-8859-1"?>'
line2 = '<!DOCTYPE DDDB SYSTEM "../../../DTD/structure.dtd">'
# =============================================================================
# Build XML-document
# =============================================================================
def buildXML(reco, year, idp_plus, idp_minus, offsets, delta):
import lxml.builder
E = lxml.builder.ElementMaker()
DDDB = E.DDDB
CONDITION = E.condition
PARAM = E.param
xml_delta = PARAM(
str(delta),
name="Delta",
type="double",
comment=f"Global delta scale {reco} {year}",
)
xml_idplus = PARAM(
idp_plus.toString(),
name="IdpPlus",
type="Histo2D",
comment=f"Calibration for IdpPlus {reco} {year}",
)
xml_idpminus = PARAM(
idp_minus.toString(),
name="IdpMinus",
type="Histo2D",
comment=f"Calibration for IdpMinus {reco} {year}",
)
xml_offsets = PARAM(
offsets_to_histo(offsets, "Run-dependent offsets").toString(),
name="Offsets",
type="Histo1D",
comment=f"Run-dependent offsets {reco} {year}",
)
document = DDDB(
CONDITION(
xml_delta,
xml_idplus,
xml_idpminus,
xml_offsets,
## comment = "Momentum scale %s %s" % ( reco , year ) ,
name="MomentumScale",
),
)
xml_name = "MomentumScale.xml"
xml_file = open(xml_name, "w")
print(
line1
+ "\n"
+ line2
+ "\n\n\n"
+ lxml.etree.tostring(document, pretty_print=True),
file=xml_file,
)
xml_file.close()
logger.info('XML file "%s" is generated in CWD ' % xml_name)
# =============================================================================
# The END
# =============================================================================
#!/usr/bin/env python
###############################################################################
# (c) Copyright 2000-2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# =============================================================================
# @file DaVinciTools/momentum_smear.py
#
# Helper script to convert input data (TGraphi) to XML-format
#
# Input data are specified close to the start of the script
#
# - input ROOT file with graph 'res'
#
# As the output xml-file MomentumSmear.xml is generated in cwd
#
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2013-04-20
#
# ============================================================================
"""
Input data are specified close to the start of the script
- input ROOT file with graph 'res'
As the output xml-file MomentumSmear.xml is generated in cwd
"""
# ============================================================================
__author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
__date__ = "2013-04-20"
# ============================================================================
print(100 * "*")
print(__doc__)
print(100 * "*")
# ============================================================================
import ROOT
from Ostap.PyRoUts import hID, h1_axis
# =============================================================================
## get the data
# =============================================================================
#
year = "2k+12"
reco = "????"
sim = "????"
#
directory = "/afs/cern.ch/user/i/ibelyaev/public/"
filename = "smear12.root"
the_file = ROOT.TFile(directory + filename)
print(100 * "*")
print("HISTOS are read from ", directory + filename)
print(the_file.ls())
print(100 * "*")
#
# get the grah
#
graph = the_file.Get("res")
#
## convert graph to histo:
histo = graph.GetHistogram() ## histogram layout
histo = h1_axis(histo.GetXaxis(), "Momentum smear", double=True)
histo += graph ## histogram content
# =============================================================================
# Build XML-document
# =============================================================================
##
line1 = '<?xml version="1.0" encoding="ISO-8859-1"?>'
line2 = '<!DOCTYPE DDDB SYSTEM "../../../DTD/structure.dtd">'
##
## import lxml.etree
import lxml.builder
E = lxml.builder.ElementMaker()
DDDB = E.DDDB
CONDITION = E.condition
PARAM = E.param
smear = PARAM(
histo.toString(),
name="Smear",
type="Histo1D",
comment=f"Momentum Smearing {sim} {reco} {year} ",
)
document = DDDB(
CONDITION(
smear,
## comment = 'Momentum Smearing %s %s %s ' % ( sim , reco , year ),
name="MomentumSmear",
),
)
xml_name = "MomentumSmear.xml"
xml_file = open(xml_name, "w")
print(
line1 + "\n" + line2 + "\n\n\n" + lxml.etree.tostring(document, pretty_print=True),
file=xml_file,
)
xml_file.close()
print(100 * "*")
print('XML file "%s" is generated in CWD ' % xml_name)
print(100 * "*")
# =============================================================================
# The END
# =============================================================================
#!/usr/bin/env python
###############################################################################
# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# =============================================================================
# @file scaling_2011.py
#
# Momentum scaling for 2011
#
# Input data are specified close to the start of the script:
#
# - input ROOT file with historams
# the file should have two 2D-histograms, named as 'idp-plus' and 'idp-minus'
#
# - global delta
# - list of run-dependent offsets as list of triplets: [ (start,stop,offset) ],
# where (start,stop) represent the run range (both edges are inclusive)
#
# As the output xml-file MomentumScale.xml is generated in cwd
#
# @author Matt NEEDHAM
# @author Vanya BELYAEV Ivan.Belyaev@itep.ru
# @date 2013-04-20
# @see TrackScaleState
# ============================================================================
"""Momentum sclaing for 2011
- input ROOT file with historams
the file should have two 2D-histograms, named as 'idp-plus' and 'idp-minus'
- global delta
- list of run-dependent offsets as list of triplets: [ (start,stop,offset) ],
where (start,stop) represent the run range (both edges are inclusive)
As the output xml-file MomentumScale.xml is generated in cwd
"""
# ============================================================================
__author__ = "Vanya BELYAEV Ivan.Belyaev@itep.ru"
__date__ = "2013-04-20"
# ============================================================================
import ROOT, Ostap.PyRoUts
# ============================================================================
from DaVinciTrackScaling.momentum_scale import buildXML, logger
# ============================================================================
logger.info(100 * "*")
logger.info(__doc__)
logger.info(100 * "*")
# ============================================================================
# ============================================================================
## the histograms
with ROOT.TFile("BFitResults-2011repro.root", "READ") as the_file:
idp_plus = the_file.Get("idp-plus").clone()
idp_minus = the_file.Get("idp-minus").clone()
logger.info("HISTOS are read from %s" % the_file)
# =============================================================================
## global delta
delta = 1.0e-4
logger.info("Global delta: %s" % delta)
# =============================================================================
## CalScale.h:
## if (run >= 87219 && run <= 89777 ) alpha =0.0;
## else if (run >= 89333 && run <= 90256 ) alpha = 6.36699e-05 ;
## else if (run >= 90257 && run <= 90763 ) alpha = 7.11719e-05 ;
## else if (run >= 91556 && run <= 93282) alpha = 1.53674e-05 ;
## else if (run >= 93398 && run <= 94386 ) alpha = 0.000144135 ;
## else if (run >= 95948 && run <= 97028 ) alpha = 0.000214408 ;
## else if (run >= 97114 && run <= 98882 ) alpha = 3.41493e-05 ;
## else if (run >= 98900 && run <= 101862 ) alpha = 0.000137622;
## else if (run >= 101891 && run <= 102452 ) alpha = 3.73981e-05 ;
## else if (run >= 102499 && run <= 102907 ) alpha = 0.000169023 ;
## else if (run >= 103049 && run <= 103687 ) alpha = 3.20303e-05 ;
## else if (run >= 103954 && run <= 104414 ) alpha = 0.00017584 ;
offsets = [
## start stop offset
(87219, 89777, 0.0),
(89333, 90256, 6.36699e-05),
(90257, 90763, 7.11719e-05),
(91556, 93282, 1.53674e-05),
(93398, 94386, 0.000144135),
(95948, 97028, 0.000214408),
(97114, 98882, 3.41493e-05),
(98900, 101862, 0.000137622),
(101891, 102452, 3.73981e-05),
(102499, 102907, 0.000169023),
(103049, 103687, 3.20303e-05),
(103954, 104414, 0.00017584),
]
# =============================================================================
# Build XML-document
# =============================================================================
buildXML(
year="2k+11",
reco="Reco14",
idp_plus=idp_plus,
idp_minus=idp_minus,
offsets=offsets,
delta=delta,
)
# =============================================================================
# The END
# =============================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment