cmg-xtracks / cmgtools-lite

CMG X-tracks code
1 stars 0 forks source link

More plotting framework examples #16

Closed gpetruc closed 6 years ago

gpetruc commented 6 years ago

I 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.

gpetruc commented 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