umd-lhcb / lhcb-ntuples-gen

ntuples generation with DaVinci and in-house offline components
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Apply TrackCalib corrections to RDX run 2 MC sample #80

Closed yipengsun closed 2 years ago

yipengsun commented 3 years ago

We need to apply TrackCalib corrections to our MC samples.

Concepts

3_track_eff_meas_methods

Useful links

yipengsun commented 2 years ago

Trying to run Urania on lxplus failed:

> lb-run -c best Urania bash
WARNING:LbEnv.ProjectEnv.lookup:could not find Urania/prod in SearchPath([EnvSearchPathEntry('CMAKE_PREFIX_PATH', '/cvmfs/lhcb.cern.ch/lib/lhcb:/cvmfs/lhcb.cern.ch/lib/lcg/releases:/cvmfs/lhcb.cern.ch/lib/lcg/app/releases:/cvmfs/lhcb.cern.ch/lib/lcg/external:/cvmfs/lhcb.cern.ch/lib/contrib:/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbDevTools/data/cmake'), EnvSearchPathEntry('CMTPROJECTPATH', ''), EnvSearchPathEntry('LHCBPROJECTPATH', '')])
ERROR:lb-run:current host does not support any of Urania/prod available platforms

I first tried to run it according to its README:

> lb-run -c best --nightly lhcb-head Urania/HEAD bash
Traceback (most recent call last):
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/script.py", line 1130, in main
    super(LbRun, self).main()
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/xenv/__init__.py", line 289, in main
    self._makeEnv()
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/script.py", line 856, in _makeEnv
    self.opts.platform, self.opts.container = self._findPlatformAndContainer()
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/script.py", line 668, in _findPlatformAndContainer
    platforms = listPlatforms(self.project, self.version)
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/lookup.py", line 419, in listPlatforms
    return sorted(platforms, key=platform_sort_key, reverse=True)
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/lookup.py", line 69, in platform_sort_key
    comp = compilerKey(comp)
  File "/cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/2129/stable/linux-64/lib/python3.8/site-packages/LbEnv/ProjectEnv/lookup.py", line 92, in compilerKey
    family, version, extension = re.match(
AttributeError: 'NoneType' object has no attribute 'groups'
yipengsun commented 2 years ago

I tried the following instruction:

lb-dev --nightly lhcb-head Urania/v9r0
cd UrandiaDev_v9r0
git lb-use Urania
git lb-checkout Urania/master TrackCalib
git checkout Urania/master cmake  # this errors out

and got the following error:

error: pathspec 'cmake' did not match any file(s) known to git
yipengsun commented 2 years ago

I plan to send an email on how to use TrackCalib nowadays. Let's discuss to whom should I send this email.

yipengsun commented 2 years ago

Actually, without -c, the older version of Urania seems to work:

> lb-run Urania/v9r0 bash
WARNING:lb-run:Decided best container to use is None
[Urania v9r0] UraniaDev_v9r0 $ python TrackCalib/scripts/CreateTrackEffTables.py "2016_25ns"

This seems to run fine.

yipengsun commented 2 years ago

No. It's a false hope. The fitting script stuck on some pop-up plots, which according to the TWiki was fixed. I then tried to manually clone the latest master branch of Urania and run the TrackCalib portion within Uranian/v9r0, but I got the following error:

❯ lb-run Urania/v9r0 python TrackCalib/scripts/CreateTrackEffTables.py "2015_25ns" 
WARNING:lb-run:Decided best container to use is None

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

##########################################################
#               Welcome to TrackEffReducer               #
#                    Running on MC                       #
##########################################################
connect localhost port 6011: Connection refused

Don't know what will happen or if the session is already stuck.

Anyway, I still don't see a way of running TrackCalib. The instruction really needs some updates. Luckily Veronica has got back to be (a Run1-2 person) and hopefully I can get some feedback soon.

yipengsun commented 2 years ago

The Urania README is at: https://gitlab.cern.ch/lhcb/Urania The TrackCalib TWiki is at: https://twiki.cern.ch/twiki/bin/view/LHCb/TrackCalib

yipengsun commented 2 years ago

Latest updates on TrackCalib: https://indico.cern.ch/event/1081752/contributions/4549593/attachments/2333612/3977324/Tracking_Reconstruction_Efficiency_studies_for_Run3.pdf

yipengsun commented 2 years ago

This is the new WIP trackcalib tool: https://gitlab.cern.ch/farchill/trackcalib_dev_run3

Indeed the Urania dependency has been removed and they are working on fully removing the ROOT dependency.

We should wait until this tool is release.

yipengsun commented 2 years ago

The following TWiki seems to provide the static efficiency tables: https://twiki.cern.ch/twiki/bin/viewauth/LHCbInternal/LHCbTrackingEfficiencies

yipengsun commented 2 years ago

The 2016 tracking weights (it is not differentiated by polarity!):

η \ p 0 (U) 1 (5000.0) 2 (10000.0) 3 (20000.0) 4 (40000.0) 5 (100000.0) 6 (O)
0 (U) 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00
1 (1.9) 0.00 ± 0.00 0.96 ± 0.00 0.99 ± 0.00 1.00 ± 0.00 0.99 ± 0.00 1.00 ± 0.05 0.00 ± 0.00
2 (3.2) 0.00 ± 0.00 1.00 ± 0.05 1.00 ± 0.00 0.99 ± 0.00 1.00 ± 0.05 1.00 ± 0.00 0.00 ± 0.00
3 (O) 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00
yipengsun commented 2 years ago

Mean tracking weights for D*:

For D0:

Previously I have validated that the weight applying tool is working properly. Here the main concern is if the P and ETA are swapped. Obviously they are not, because in that case we'll get lots of 0s.

A slight concern is the slow Pi.

yipengsun commented 2 years ago

I updated the histo printer and now the full bin boundaries are printed out. For the first bin, the lower bound and upper bound are both printed; for the rest of the bin, only the upper bound is printed.

η \ p 0 (U) 1 (5000.0,10000.0) 2 (20000.0) 3 (40000.0) 4 (100000.0) 5 (200000.0) 6 (O)
0 (U) 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00
1 (1.9,3.2) 0.00 ± 0.00 0.96 ± 0.00 0.99 ± 0.00 1.00 ± 0.00 0.99 ± 0.00 1.00 ± 0.05 0.00 ± 0.00
2 (4.9) 0.00 ± 0.00 1.00 ± 0.05 1.00 ± 0.00 0.99 ± 0.00 1.00 ± 0.05 1.00 ± 0.00 0.00 ± 0.00
3 (O) 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00 0.00 ± 0.00
yipengsun commented 2 years ago

OK, I plotted the P-ETA 2D heat maps for all of our final state particles (K, Pi, Mu, slow Pi):

Note

D0 tree

D0_k_p_eta D0_mu_p_eta D0_pi_p_eta

D* tree

Dst_k_p_eta Dst_mu_p_eta Dst_pi_p_eta Dst_spi_p_eta

yipengsun commented 2 years ago

I've followed Phoebe's suggestion to make sure the under/overflow bins are adjusted to the nearest bins.

I've also updated the plots above, and as you can see, the efficiencies are now close to unity.

yipengsun commented 2 years ago

Need to double check the slow Pi correction as 50% of samples are outside the official range.

yipengsun commented 2 years ago

@manuelfs I've noted in our doc that we should be using +/- 0.05 for uncertainty for the bins that are not covered by the official tracking sample: https://github.com/umd-lhcb/rdx-run2-analysis/blob/master/docs/reweight/pid_tracking_reweight.md#tracking

If you think everything's documented, feel free to close this issue.