Useful Tips in analysis

Python tips

  • When you want to input huge files into your cfg file, if you know the directory, you don't need to write all of them on the cfg file. Just replace like this
at lxplus :
=========
# Input source
process.source = cms.Source("PoolSource",
   skipEvents = cms.untracked.uint32(0),
    fileNames = cms.untracked.vstring(),
      duplicateCheckMode = cms.untracked.string('noDuplicateCheck'),
   dropDescendantsOfDroppedBranches=cms.untracked.bool(False)
)
import os,commands
# get a list of files from a specified directory
mydir = "/castor/cern.ch/user/d/dmoon/cms390pre5/Hydjet_MinBias_2.76TeV_Z0_Flat_Emb_HLT"
cmd  = 'nsls %s/ ' % (mydir)
mylist = ["rfio:%s/%s" % (mydir,j) for j in commands.getoutput(cmd).split('\n')]

# add a specified number of files from mydir to the list of fileNames
nfiles=300 #number from "ls mydir |wc"
for i in range(0,nfiles):
    process.source.fileNames.append('%s' % (mylist[i]))
    print "process.source.fileNames.append(%s" % (mylist[i])
    print "Number of files to process is %s" % (len(process.source.fileNames))
=========

at mit
============
# Input source
process.source = cms.Source("PoolSource",
   skipEvents = cms.untracked.uint32(0),
    fileNames = cms.untracked.vstring(),
      duplicateCheckMode = cms.untracked.string('noDuplicateCheck'),
   dropDescendantsOfDroppedBranches=cms.untracked.bool(False)
)
import os, commands
# get a list of files from a specified directory
mydir = "/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/davidlw/Hydjet_Quenched_MinBias_2760GeV_START39V0_GEN_SIM_RAW_390pre5/SingleJPsimumu_FlatPt0to20_START39V1_GEN_SIM_RAW_390pre5/90920f11cf28a60a1a989824b938abb3/"
mylist = os.listdir(mydir)

# add a specified number of files from mydir to the list of fileNames
nfiles=5 # number from "ls mydir |wc
for i in range(0,nfiles):
  process.source.fileNames.append('dcache:%s/%s' % (mydir,mylist[i]))

-- DongHoMoon - 11 Oct 2010

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2010-10-11 - DongHoMoon
 
KOREA-CMS
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding KoreaCmsWiki? Send feedback