cms-nanoAOD / nanoAOD-tools

Tools for working with NanoAOD (requiring only python + root, not CMSSW)
42 stars 328 forks source link

Postprocessing crab job with histograms #192

Open alefisico opened 5 years ago

alefisico commented 5 years ago

Hi all I want to run a postprocessing job that adds a variable to the current nanoAOD and creates some histograms. Running locally and in condor works perfectly, but sending them in crab I am getting the following error:

== CMSSW:     getattr( self, 'variable' ).Fill( var )
== CMSSW: AttributeError: 'resolvedAnalyzer' object has no attribute 'variable'

which basically it is not finding the histogram that I am sure I am including it in the beginJob part. Before give you more details, is this behavior expected? Can I create a job in crab that creates histogram and trees? thanks for the help!

NJManganelli commented 5 years ago

You can fill histograms and trees simultaneously in CRAB.

If you were using a fork of the crab submission included in the repository and a PostProcessor module, you would need to add 'hist.root' to the list in the crab configuration, in the variable including 'tree.root', so that they are transferred back to your group/user space. Otherwise, it should work like typical.

You'll probably need to post those details for anyone to say more.

alefisico commented 5 years ago

Hi @NJManganelli thanks for the reply. Here more details:

do you spot something missing? Again, the module that I am running works fine locally and in condor.

Thanks again!

NJManganelli commented 5 years ago

This configuration is sufficient for me to have both outputs: crab_cfg.py

from WMCore.Configuration import Configuration
from CRABClient.UserUtilities import config, getUsernameFromSiteDB

config = Configuration()

config.section_("General")
config.General.requestName = 'ttWH_2017'
config.General.transferLogs = True
config.section_("JobType")
config.JobType.pluginName = 'Analysis'
config.JobType.psetName = 'PSet.py'
config.JobType.scriptExe = 'crab_script_ttWH_2017.sh'
config.JobType.inputFiles = ['crab_script_ttWH_2017.py', 'haddnano.py',]
config.JobType.outputFiles = ['ttWH_2017_hist.root']
config.JobType.sendPythonFolder  = True
config.section_("Data")
config.Data.inputDataset = '/TTWH_TuneCP5_13TeV-madgraph-pythia8/RunIIFall17NanoAODv5-PU2017_12Apr2018_Nano1June2019_new_pmx_102X_mc2017_realistic_v7-v1/NANOAODSIM'
config.Data.inputDBS = 'global'
config.Data.splitting = 'FileBased'
config.Data.unitsPerJob = 6

config.Data.outLFNDirBase = '/store/user/%s/Stage_NANOv5_to_LogicChain/crab_20190917_1844' % (getUsernameFromSiteDB())
config.Data.outputDatasetTag = 'ttWH_2017'
config.section_("Site")
config.Site.storageSite = 'T2_CH_CERN'

PSet.py

import FWCore.ParameterSet.Config as cms
process = cms.Process('NANO')
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring())
process.source.fileNames = [
        '../../test/lzma.root' ##you can change only this line
]
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10))
process.output = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string('tree.root'))
process.out = cms.EndPath(process.output)