cms-jet / JetToolbox

Python framework for configuration of jet tools via the jet toolbox.
https://twiki.cern.ch/twiki/bin/viewauth/CMS/JetToolbox
7 stars 36 forks source link

update ECFs, use postfix consistently #57

Closed kpedro88 closed 6 years ago

kpedro88 commented 6 years ago
  1. ECFs now generated in line with https://github.com/cms-sw/cmssw/blob/CMSSW_9_4_X/PhysicsTools/PatAlgos/python/slimming/applySubstructure_cff.py. Subjet ECFs are included and can be turned on separately. Limitations:
    • Restricted to Puppi and Softdrop based on advice from @rappoccio. This limitation could be removed if there is demand (but has a bit of complexity in terms of picking the associated grooming algo name).
    • Restricted to the sets of parameters used in miniAOD production. It is non-trivial to allow users to specify sets of four parameters (Njets, type, alpha, beta). Possible to implement if there is demand (maybe using dicts or named tuples), but there probably won't be.
  2. The postfix was not applied to the first step (FastjetJetProducer instances) or to the miniAOD constituents selector, meaning the toolbox could not be reused with different sets of candidates in the same job. The problem should be remedied now, as far as I could see.

Problems like 2. would be significantly less likely if every construction was assigned to a clearly named variable the first time used or created (instead of repeating e.g. jetalgo+'PFJets'+PUMethod+postFix dozens of times).

alefisico commented 6 years ago

Hi @kpedro88, I merged your changes, but I am trying to test it in a simple config and I am getting errors about postFix names. Can you send me the snap of the toolbox that you test for the EnergyCorrFunc? After I test this, I will create a first preliminary tag and put it in the twiki. cheers,

kpedro88 commented 6 years ago

@alefisico, my setup is the following: https://github.com/kpedro88/TreeMaker/blob/090674d2bc1dea5a2ec5d196b3488830d0ca5430/TreeMaker/python/doZinvBkg.py#L7-L39

(cleanedCandidates is a subset of the full miniAOD PF collection with leptons or photons removed, but you could just use the standard set of candidates for testing.)

I'm running on this file: /store/relval/CMSSW_9_4_5_cand1/RelValTTbar_13/MINIAODSIM/94X_mc2017_realistic_v14_RelVal_rmaod-v1/10000/A8356B71-6E2E-E811-8A63-0CC47A7C3424.root

If you send me your config, I can also take a look at the error.

alefisico commented 6 years ago

@kpedro88 Based on your setup, I tried to run this:

listBTagInfos = ['pfInclusiveSecondaryVertexFinderTagInfos','pfImpactParameterTagInfos'] listBtagDiscriminatorsAK8 = [ 'pfBoostedDoubleSecondaryVertexAK8BJetTags', ] jecLevels = ['L1FastJet', 'L2Relative', 'L3Absolute'] jetToolbox(process, 'ak8', 'jetSequence', 'out', PUMethod = 'Puppi', miniAOD = True, runOnMC = True, postFix='Clean',

newPFCollection = True,

    #nameNewPFCollection = cleanedCandidates.value(),
    Cut = 'pt>170.',
    addPruning = True,
    addSoftDropSubjets = True,
    addNsub = True,
    maxTau = 3,
    bTagInfos = listBTagInfos, 
    bTagDiscriminators = listBtagDiscriminatorsAK8,
    JETCorrLevels = jecLevels,
    subJETCorrLevels = jecLevels,
    addEnergyCorrFunc = True,

)

and I am getting this error:

----- Begin Fatal Exception 26-Apr-2018 16:18:13 CEST----------------------- An exception of category 'ConfigFileReadError' occurred while [0] Processing the python configuration file named jettoolbox_cfg.py Exception Message: python encountered the error: <type 'exceptions.AttributeError'> 'Process' object has no attribute 'nb1AK8PuppiCleanSoftDrop' ----- End Fatal Exception -------------------------------------------------

kpedro88 commented 6 years ago

when I dump my config, I see this:

process.nb1AK8PuppiCleanSoftDrop = cms.EDProducer("ECFAdder",
    Njets = cms.vuint32(1, 2, 3),
    alpha = cms.double(1),
    beta = cms.double(1),
    cuts = cms.vstring('', 
        '', 
        'pt > 250'),
    ecftype = cms.string('N'),
    src = cms.InputTag("ak8PFJetsPuppiCleanSoftDrop")
)

Can you send me the your entire config and any other pertinent info (CMSSW version, etc.)?

alefisico commented 6 years ago

CMSSW_9_4_4, without any additional packages besides the jetToolbox. the configuration is here (although it only has what I wrote before): jettoolbox_test_cfg.txt

kpedro88 commented 6 years ago

I can't reproduce your error after the following steps:

setenv SCRAM_ARCH slc6_amd64_gcc630
cmsrel CMSSW_9_4_4
cd CMSSW_9_4_4/src
cmsenv
git clone git@github.com:cms-jet/JetToolbox JMEAnalysis/JetToolbox -b jetToolbox_94X
scram b -j 8
cmsRun jettoolbox_test_cfg.py

Here I am using your config exactly, but with the file I specified instead of the PAT relval (https://www.dropbox.com/s/j43483ucac11ub7/jettoolbox_test_cfg.py?dl=0). The PAT relval file was produced in 9_2_X, which is significantly out of date with respect to 9_4_X. (In fact I couldn't even open the PAT relval file over xrootd...)

alefisico commented 6 years ago

I change it to the file that you mentioned (/store/relval/CMSSW_9_4_5_cand1/RelValTTbar_13/MINIAODSIM/94X_mc2017_realistic_v14_RelVal_rmaod-v1/10000/A8356B71-6E2E-E811-8A63-0CC47A7C3424.root) and I get the same error:

----- Begin Fatal Exception 26-Apr-2018 18:14:30 CEST----------------------- An exception of category 'ConfigFileReadError' occurred while [0] Processing the python configuration file named jettoolbox_test_cfg.py Exception Message: python encountered the error: <type 'exceptions.AttributeError'> 'Process' object has no attribute 'nb1AK8PuppiCleanSoftDrop' ----- End Fatal Exception -------------------------------------------------

kpedro88 commented 6 years ago

Can you point me to your full work area (if it's on lxplus or something)? It's hard to say more if I can't reproduce the error...

alefisico commented 6 years ago

@kpedro88 sorry my mistake, I forgot to compile it (but since we are not changing anything c++ related I thought that I dont need it). sorry for the mess. I'll update the README and the twiki now.