Closed gpetruc closed 6 years ago
Updated also with an example module to prepare friend trees with the dE/dx DNN.
The module is defined in python/tools/xtracksDeDxNN.py
(where we could easily have multiple configurations for different trainings etc).
The implementation is not terribly smart since it sends each track individually to keras instead of batching them, but it doesn't look too bad.
Friend tree production can be run with the prepareEventVariablesFriendTree.py
tool (under macros
), e.g. this command will run the dedxNN4h
module locally with 6 threads (-j 6
) and save the output in a subdirectory1_dedxNN4h_v1
within the main directory of the trees ({P}
).
python prepareEventVariablesFriendTree.py --tree treeProducerXtracks -I CMGTools.TTHAnalysis.tools.xtracksDeDxNN -m dedxNN4h /data1/gpetrucc/XTracks_SR_MC {P}/1_dedxNN4h_v1 -j 6
Long input files are split into multiple chunks to process them more efficiently. The chunks can be merged with friendChunkAdd.sh evVarFriend
(the script is under TTHAnalysis/macros/leptons
, and it is to be run in the directory of the friends)
There are options for different running only on some datasets, job splitting, submitting to condor, etc.
Friend trees can be attached to the main trees in the plotting framework from the command line, --Fs {P}/1_dedxNN4h_v1
. Then you can plot the variable as if it were in the original tree.
(if needed, there are commands to attach friends only to MC or only to data, and in principle friends trees for a an individual sample can also be specified in the mca file - but it's rarely useful)
A dumb plot of the normalized NN output after the full SR selection and the requirement of 4 pixel hits is https://gpetrucc.web.cern.ch/gpetrucc/drop/plots/ttH/94X/xtracks/test/NN/IsoTrack_dedxNN4h.png
added a cut file to select Z→μμ events from the SR trees (i.e. triggered by
metNoMu
), following approximately slide 13 of https://indico.cern.ch/event/750030/contributions/3103946/attachments/1700380/2738229/disapp_tracks_14_08_2018.pdf .example of how to do an extrapolation to estimate Z→νν from μμ events changing the selection, the meaning of the variables (use metNoMu instead of met) and applying a weight. An example closure check command is
python mcPlots.py -l 41.37 -P /data1/gpetrucc/XTracks_SR_MC xtracks/mca-ZvvFromZmm.txt xtracks/cuts-SR.txt xtracks/plots-SR.txt --pdir plots/94X/xtracks/test/ZvvFromZmm -p zvv,zvv_fromzmm -f --sP met -L xtracks/functionsXtracks.cc --plotmode nostack --showRatio --sp zvv -e
where:xtracks/mca-ZvvFromZmm.txt
defines thezvv_fromzmm
using theFakeRate=...
option change how the selection applies to this sample-L xtracks/functionsXtracks.cc
is to tell ROOT to load the file were we define our functions-p zvv,zvv_fromzmm
selects just the Zνν from plain MC and from Zμμ--plotmode nostack --showRatio --sp zvv -e
tells to not stack the plots, add a ratio panel with zvv as numerator (by setting it as signal, since in the absence of data the ratio plot puts the signal as numerator), and to show error bars (-e
)-f --sP met
tells to just do the plot called met, and only after all cutsexample on how to compute and k-factors in the MCA file
example function to apply scale factors from the command line: e.g. plot Z→μμ with
-L xtracks/functionsXtracks.cc -W 'muonSF(LepGood_pt[0],LepGood_eta[0],LepGood_tightId[0])*muonSF(LepGood_pt[1],LepGood_eta[1],LepGood_tightId[1])'
to get the muon scale factor appliedI didn't put an example for skimming, but see https://github.com/CERN-PH-CMG/cmgtools-lite/blob/94X_dev/TTHAnalysis/python/plotter/skimTrees.py#L121-L131
I'll later add examples on how to make datacards and plots including systematic uncertainties (both pre-fit and post-fit) but for that we need to first merge in CMGTools the code for it that is currently in Marco's ttH branch.