def main():

    usage = "usage: %prog [options]"
    parser = optparse.OptionParser(usage)
    parser.add_option("-i", "--in", dest="input", help="Input file", default=None)
    parser.add_option("-o", "--out", dest="output", help="Output file", default="HitIntegrationAnalysis.root")
    parser.add_option(
        "-r", "--dR", dest="dR", help="DeltaR cone used for analysis (0.3 by default)", default=0.3, type=float
    )
    parser.add_option(
        "--useTrack", dest="useTrack", help="If given, use track as reference", default=False, action="store_true"
    )
    (opt, args) = parser.parse_args()

    # check inputs
    if opt.input is None:
        parser.print_help()
        sys.exit(1)

    # run analysis
    urlList = []
    if opt.input.find("/store") >= 0:
        basename = os.path.basename(opt.input)
        basedir = os.path.dirname(opt.input)
        from UserCode.HGCanalysis.storeTools_cff import fillFromStore

        allFiles = fillFromStore(basedir)
        for f in allFiles:
            if f.find(basename) < 0:
                continue
            urlList.append(f)
    else:
        urlList = glob.glob("%s*.root" % opt.input)

    testHitIntegration(urlList=urlList, probeCone=opt.dR, useTrackAsRef=opt.useTrack, outUrl=opt.output)
Exemple #2
0
def main():

    usage = 'usage: %prog [options]'
    parser = optparse.OptionParser(usage)
    parser.add_option('-i',
                      '--in',
                      dest='input',
                      help='Input file',
                      default=None)
    parser.add_option('-o',
                      '--out',
                      dest='output',
                      help='Output file',
                      default='HitIntegrationAnalysis.root')
    parser.add_option('-r',
                      '--dR',
                      dest='dR',
                      help='DeltaR cone used for analysis (0.3 by default)',
                      default=0.3,
                      type=float)
    parser.add_option('--useTrack',
                      dest='useTrack',
                      help='If given, use track as reference',
                      default=False,
                      action="store_true")
    (opt, args) = parser.parse_args()

    #check inputs
    if opt.input is None:
        parser.print_help()
        sys.exit(1)

    #run analysis
    urlList = []
    if opt.input.find('/store') >= 0:
        basename = os.path.basename(opt.input)
        basedir = os.path.dirname(opt.input)
        from UserCode.HGCanalysis.storeTools_cff import fillFromStore
        allFiles = fillFromStore(basedir)
        for f in allFiles:
            if f.find(basename) < 0: continue
            urlList.append(f)
    else:
        urlList = glob.glob('%s*.root' % opt.input)

    testHitIntegration(urlList=urlList,
                       probeCone=opt.dR,
                       useTrackAsRef=opt.useTrack,
                       outUrl=opt.output)
    print '\tstep - number of files to process\n'
    sys.exit()

preFix = sys.argv[2]
if (len(sys.argv) > 3):
    if (sys.argv[3].isdigit()): ffile = int(sys.argv[3])
if (len(sys.argv) > 4):
    if (sys.argv[4].isdigit()): step = int(sys.argv[4])
print '[runHGCHitsAnalyzer] processing %d files of %s, starting from %d' % (
    step, preFix, ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring())
if preFix.find('/store') >= 0:
    process.source.fileNames = fillFromStore(preFix, ffile, step)
else:
    process.source.fileNames = fillFromStore(
        '/store/cmst3/group/hgcal/CMSSW/%s' % preFix, ffile, step)
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))

#load the analyzer
import getpass
whoami = getpass.getuser()
outputTag = preFix.replace('/', '_')
process.TFileService = cms.Service(
    "TFileService",
    fileName=cms.string('/tmp/%s/%s_Hits_%d.root' %
                        (whoami, outputTag, ffile)))
process.load('UserCode.HGCanalysis.hgcHitsAnalyzer_cfi')
Exemple #4
0
    origInput = "*" + input2process  #|Adding the initial * allows for relative file locations.
    useWildCards = True
    input2process = input2process.rsplit("/",
                                         1)[0]  #|Gets folder above directory
else:
    useWildCards = False

print '[EDMProcessor] processing from %s and output name is %s' % (
    input2process, outputName)

from UserCode.HGCanalysis.storeTools_cff import fillFromStore  #|Configure the source (list all files in directory within range [ffile,ffile+step]
process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring())
if input2process.find('file') >= 0:
    process.source.fileNames = cms.untracked.vstring(input2process)
else:
    process.source.fileNames = fillFromStore(input2process)

#print process.source.fileNames

# Postprocessing - use wildcards
fileList = []
if useWildCards:
    for filename in process.source.fileNames:
        #print "Filename: %s \norigInput: %s" % (filename, origInput)
        if fnmatch(filename, origInput):  #|Only use files matching wildcard
            fileList.append(filename)
    process.source.fileNames = cms.untracked.vstring(fileList)

# Postprocessing - remove ignore files
if (len(sys.argv) > 4):
    fileList = [filename for filename in process.source.fileNames]
process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(-1)
)

# Input source
process.source = cms.Source("PoolSource",
    secondaryFileNames = cms.untracked.vstring(),
    fileNames = cms.untracked.vstring()
)
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource",
    secondaryFileNames = cms.untracked.vstring(),
    fileNames = cms.untracked.vstring()
)
if preFix.find('/store')>=0:
    process.source.fileNames=fillFromStore(preFix,ffile,step)
else:
    process.source.fileNames=fillFromStore('/store/cmst3/group/hgcal/CMSSW/%s'%preFix,ffile,step)

process.source.skipEvents = cms.untracked.uint32(skipThese)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(processThese) )

print 'Will process %d events from '%processThese
print process.source.fileNames
print ' ....starting at %d'%skipThese

process.options = cms.untracked.PSet(

)

# Production Info
preFix=sys.argv[2]
if(len(sys.argv)>3):
    if(sys.argv[3].isdigit()) : ffile=int(sys.argv[3])
if(len(sys.argv)>4):
    if(sys.argv[4].isdigit()) : step=int(sys.argv[4])
print '[runHGCSimHitsAnalyzer] processing %d files of %s, starting from %d'%(step,preFix,ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource",                            
                            fileNames=cms.untracked.vstring()
                            )
if preFix.find('RelVal')>=0 :
    cmsswVersion=os.environ['CMSSW_VERSION']
    process.source.fileNames=fillFromStore('/store/relval/%s/%s/GEN-SIM-RECO/DES23_62_V1_UPG2023Muon-v1/00000/'%(cmsswVersion,preFix),ffile,step)
elif preFix.find('file')>=0:
    process.source.fileNames=cms.untracked.vstring(preFix)
elif preFix.find('lpc:')>=0:
    preFix=preFix.split(':')[1]
    process.source.fileNames=fillFromStore('srm://cmseos.fnal.gov:8443/srm/v2/server?SFN=/eos/uscms/store/user/lpchgcal/HGCAL_Samples/%s'%preFix,ffile,step)
else :
    process.source.fileNames=fillFromStore('/store/cmst3/group/hgcal/CMSSW/%s'%preFix,ffile,step)
print process.source.fileNames
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

#load the analyzer
import getpass
whoami=getpass.getuser()
outputTag=preFix.replace('/','_')
    outputName=sys.argv[3]
filtertag=''
if(len(sys.argv)>4):
    filtertag=sys.argv[4]

print '[runHGCROIAnalyzer] processing from %s and output name is %s'%(input2process,outputName)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource",                            
                            fileNames=cms.untracked.vstring()
                            )
if input2process.find('file')>=0:
    process.source.fileNames=cms.untracked.vstring(input2process)
else :
    allFiles=fillFromStore(input2process)
    for f in allFiles:
        if len(filtertag)>0:
            if not filtertag in f:
                continue
        process.source.fileNames.append(f)
print process.source.fileNames
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

#prepare alternative jet collections 
#from RecoJets.Configuration.RecoPFJets_cff import *
#process.ak3PFJetsPandora = ak4PFJets.clone( src=cms.InputTag('pandorapfanew'), rParam = 0.3 )
#process.load('RecoJets.Configuration.GenJetParticles_cff')
#from RecoJets.JetProducers.ak5GenJets_cfi import ak5GenJets
#process.ak3GenJets = ak5GenJets.clone(rParam = 0.3)
Exemple #8
0
    eventAutoFlushCompressedSize=cms.untracked.int32(5242880),
    outputCommands=process.FEVTDEBUGHLTEventContent.outputCommands,
    fileName=cms.untracked.string('file:%s/Events_PU%d.root' %
                                  (outputDir, avgPU)),
    dataset=cms.untracked.PSet(
        filterName=cms.untracked.string(''),
        dataTier=cms.untracked.string('GEN-SIM-DIGI-RAW')))

# Additional output definition

# Other statements
process.mix.input.nbPileupEvents.averageNumber = cms.double(avgPU)
process.mix.bunchspace = cms.int32(25)
process.mix.minBunch = cms.int32(-12)
process.mix.maxBunch = cms.int32(3)
mixFileNames = fillFromStore(
    '/store/cmst3/group/hgcal/CMSSW/%s' % minBiasPreFix, 0, -1)
import random
random.shuffle(mixFileNames)
process.mix.input.fileNames = cms.untracked.vstring(mixFileNames)
process.mix.digitizers = cms.PSet(process.theDigitizersValid)
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')

# Path and EndPath definitions
process.digitisation_step = cms.Path(process.pdigi_valid)
process.L1simulation_step = cms.Path(process.SimL1Emulator)
process.digi2raw_step = cms.Path(process.DigiToRaw)
process.endjob_step = cms.EndPath(process.endOfProcess)
process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput)

# Schedule definition
if "*" in input2process:
    origInput = "*"+input2process                                                                   #|Adding the initial * allows for relative file locations.
    useWildCards = True
    input2process = input2process.rsplit("/",1)[0]                                                  #|Gets folder above directory
else: 
    useWildCards = False

print '[EDMProcessor] processing from %s and output name is %s'%(input2process,outputName)

from UserCode.HGCanalysis.storeTools_cff import fillFromStore                                       #|Configure the source (list all files in directory within range [ffile,ffile+step]
process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring())
if input2process.find('file') >= 0:
    process.source.fileNames = cms.untracked.vstring(input2process)
else :                       
    process.source.fileNames = fillFromStore(input2process)

#print process.source.fileNames

# Postprocessing - use wildcards
fileList = []
if useWildCards:
    for filename in process.source.fileNames:
        #print "Filename: %s \norigInput: %s" % (filename, origInput)
        if fnmatch(filename, origInput):                                                            #|Only use files matching wildcard
            fileList.append(filename)
    process.source.fileNames = cms.untracked.vstring(fileList)


# Postprocessing - remove ignore files
if(len(sys.argv)>4):
    sys.exit()
preFix=sys.argv[2]
if(len(sys.argv)>3):
    if(sys.argv[3].isdigit()) : ffile=int(sys.argv[3])
if(len(sys.argv)>4):
    if(sys.argv[4].isdigit()) : step=int(sys.argv[4])
print '[runHGCOccupancyAnalyzer] processing %d files of %s, starting from %d'%(step,preFix,ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource",                            
                            fileNames=cms.untracked.vstring()
                            )
if preFix.find('RelVal')>=0 :
    cmsswVersion=os.environ['CMSSW_VERSION']
    process.source.fileNames=fillFromStore('/store/relval/%s/%s/GEN-SIM-RECO/DES23_62_V1_UPG2023Muon-v1/00000/'%(cmsswVersion,preFix),ffile,step)
elif preFix.find('.root')>=0 :
    process.source.fileNames=cms.untracked.vstring('file://%s'%preFix)
else :
    process.source.fileNames=fillFromStore('/store/cmst3/group/hgcal/CMSSW/%s'%preFix,ffile,step)
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

#load the analyzer
import getpass
whoami=getpass.getuser()
outputTag=preFix.replace('/','_')
outputTag=outputTag.replace('..','')
process.TFileService = cms.Service("TFileService", fileName = cms.string('/tmp/%s/%s_Occupancy_%d.root'%(whoami,outputTag,ffile)))
process.load('UserCode.HGCanalysis.hgcOccupancyAnalyzer_cfi')
print process.TFileService.fileName
Exemple #11
0
preFix = sys.argv[2]
if (len(sys.argv) > 3):
    if (sys.argv[3].isdigit()): ffile = int(sys.argv[3])
if (len(sys.argv) > 4):
    if (sys.argv[4].isdigit()): step = int(sys.argv[4])
print '[runHGCSimHitsAnalyzer] processing %d files of %s, starting from %d' % (
    step, preFix, ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring())
if preFix.find('RelVal') >= 0:
    cmsswVersion = os.environ['CMSSW_VERSION']
    process.source.fileNames = fillFromStore(
        '/store/relval/%s/%s/GEN-SIM-RECO/DES23_62_V1_UPG2023Muon-v1/00000/' %
        (cmsswVersion, preFix), ffile, step)
elif preFix.find('file') >= 0:
    process.source.fileNames = cms.untracked.vstring(preFix)
elif preFix.find('lpc:') >= 0:
    preFix = preFix.split(':')[1]
    process.source.fileNames = fillFromStore(
        'srm://cmseos.fnal.gov:8443/srm/v2/server?SFN=/eos/uscms/store/user/lpchgcal/HGCAL_Samples/%s'
        % preFix, ffile, step)
else:
    process.source.fileNames = fillFromStore(
        '/store/cmst3/group/hgcal/CMSSW/%s' % preFix, ffile, step)
print process.source.fileNames
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))
Exemple #12
0
process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff')

## MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 10
process.options = cms.untracked.PSet(
    wantSummary=cms.untracked.bool(False),
    SkipEvent=cms.untracked.vstring('ProductNotFound'))

process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))

from UserCode.HGCanalysis.storeTools_cff import fillFromStore

files = [
    f for f in fillFromStore(
        '/afs/cern.ch/work/p/phansen/public/hgcal/CMSSW/hToGammaGamma_SLHC21_p1/'
    )
]

process.source = cms.Source("PoolSource",
                            fileNames=cms.untracked.vstring(files))
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')

process.analysis = cms.EDAnalyzer(
    'HiggsAnalyzer',
    genSource=cms.untracked.string("genParticles"),
    jetSource=cms.untracked.string("ak5PFJets"),
    linCorr=cms.untracked.double(1.0))

process.filter = cms.EDFilter(
    "MCBarrelEndcapFilter",
    inputStr = inputStr[:-1]
    os.system('edmCopyPickMerge inputFiles=%s outputFile=%s'%(inputStr,outputStr))
    os.system('cmsStage %s %s'%(outputStr,opt.dir))
    if opt.deleteOriginal : 
        for f in mergeFiles : 
            os.system('cmsRm %s'%f)


usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage)
parser.add_option('-d', '--dir'      ,    dest='dir'              , help='input directory'                                        , default='')
parser.add_option('-r',                   dest='deleteOriginal'   , help='delete original'                                        , action='store_true')
(opt, args) = parser.parse_args()

from UserCode.HGCanalysis.storeTools_cff import fillFromStore
allFiles=fillFromStore(opt.dir)

totEvts=0
mergeFiles=[]
igroup=0
for f in allFiles :
    try:
        result=commands.getstatusoutput('edmFileUtil -P %s | grep -ir bytes | awk \'{print $6}\''%f)
        iEvts=int(result[1])
        totEvts+=iEvts
        print totEvts
        #mergeFiles.append(f)
    except:
        os.system('cmsRm %s'%f)
        print 'Removed %s as no valid number of events was found'%f
    
process.load('Configuration.Geometry.GeometryExtended2023HGCalMuon_cff')
process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff')

## MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 10
process.options   = cms.untracked.PSet( wantSummary = cms.untracked.bool(False),
        SkipEvent = cms.untracked.vstring('ProductNotFound')
        )


process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

from UserCode.HGCanalysis.storeTools_cff import fillFromStore

files =  [f for f in fillFromStore('/afs/cern.ch/work/p/phansen/public/hgcal/CMSSW/hToGammaGamma_SLHC21_p1/') ]

process.source = cms.Source("PoolSource",
        fileNames = cms.untracked.vstring(files)
        )
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')

process.analysis = cms.EDAnalyzer('HiggsAnalyzer',
        genSource = cms.untracked.string("genParticles"),
        jetSource = cms.untracked.string("ak5PFJets"),
        linCorr = cms.untracked.double(1.0)
)

process.filter = cms.EDFilter("MCBarrelEndcapFilter",
       minInvMass = cms.untracked.double(127.0),
       maxInvMass = cms.untracked.double(133.0),
    sys.exit()

preFix=sys.argv[2]
if(len(sys.argv)>3):
    if(sys.argv[3].isdigit()) : ffile=int(sys.argv[3])
if(len(sys.argv)>4):
    if(sys.argv[4].isdigit()) : step=int(sys.argv[4])
print '[runHGCSimHitsAnalyzer] processing %d files of %s, starting from %d'%(step,preFix,ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore
process.source = cms.Source("PoolSource",                            
                            fileNames=cms.untracked.vstring()
                            )
if preFix.find('/store/')>=0 :
    process.source.fileNames=fillFromStore(preFix,ffile,step)
elif preFix.find('file')>=0:
    process.source.fileNames=cms.untracked.vstring(preFix)
elif preFix.find('lpc:')>=0:
    preFix=preFix.split(':')[1]
    process.source.fileNames=fillFromStore('srm://cmseos.fnal.gov:8443/srm/v2/server?SFN=/eos/uscms/store/user/lpchgcal/HGCAL_Samples/%s'%preFix,ffile,step)
else :
    process.source.fileNames=fillFromStore('/store/cmst3/group/hgcal/CMSSW/%s'%preFix,ffile,step)
print process.source.fileNames
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

#load the analyzer
import getpass
whoami=getpass.getuser()
outputTag=preFix.replace('/','_')
                  default='/store/cmst3/group/hgcal/CMSSW/ntuples/')
parser.add_option('-c',
                  '--cfg',
                  dest='cfg',
                  help='cfg file',
                  default='test/runHGCSimHitsAnalyzer_cfg.py')
(opt, args) = parser.parse_args()

#prepare output
os.system('cmsMkdir %s' % opt.output)
jobsDir = '%s/src/FARM%s' % (cmsswBase, time.time())
os.system('mkdir -p %s' % jobsDir)

from UserCode.HGCanalysis.storeTools_cff import fillFromStore

allFiles = fillFromStore('/store/cmst3/group/hgcal/CMSSW/' + opt.tag)
if opt.step <= 0: opt.step = len(allFiles)
outputTag = opt.tag.replace('/', '_')
print outputTag
for ffile in xrange(0, len(allFiles), opt.step):
    #create a wrapper for standalone cmssw job
    scriptFile = open('%s/runJob_%s_%d.sh' % (jobsDir, outputTag, ffile), 'w')
    scriptFile.write('#!/bin/bash\n')
    scriptFile.write('cd %s/src\n' % cmsswBase)
    scriptFile.write('eval `scram r -sh`\n')
    scriptFile.write('cd %s\n' % jobsDir)
    scriptFile.write('cmsRun %s/src/UserCode/HGCanalysis/%s %s %d %d\n' %
                     (cmsswBase, opt.cfg, opt.tag, ffile, opt.step))
    scriptFile.write('cmsStage -f /tmp/psilva/%s_SimHits_%d.root %s\n' %
                     (outputTag, ffile, opt.output))
    scriptFile.write('rm /tmp/psilva/%s_SimHits_%d.root\n' %
Exemple #17
0
preFix = sys.argv[2]
if (len(sys.argv) > 3):
    if (sys.argv[3].isdigit()): ffile = int(sys.argv[3])
if (len(sys.argv) > 4):
    if (sys.argv[4].isdigit()): step = int(sys.argv[4])
print '[runHGCOccupancyAnalyzer] processing %d files of %s, starting from %d' % (
    step, preFix, ffile)

#configure the source (list all files in directory within range [ffile,ffile+step[
from UserCode.HGCanalysis.storeTools_cff import fillFromStore

process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring())
if preFix.find('RelVal') >= 0:
    cmsswVersion = os.environ['CMSSW_VERSION']
    process.source.fileNames = fillFromStore(
        '/store/relval/%s/%s/GEN-SIM-RECO/DES23_62_V1_UPG2023Muon-v1/00000/' %
        (cmsswVersion, preFix), ffile, step)
elif preFix.find('.root') >= 0:
    process.source.fileNames = cms.untracked.vstring('file://%s' % preFix)
else:
    process.source.fileNames = fillFromStore(
        '/store/cmst3/group/hgcal/CMSSW/%s' % preFix, ffile, step)
process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck')
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))

#load the analyzer
import getpass

whoami = getpass.getuser()
outputTag = preFix.replace('/', '_')
outputTag = outputTag.replace('..', '')
    inputStr = inputStr[:-1]
    os.system('edmCopyPickMerge inputFiles=%s outputFile=%s'%(inputStr,outputStr))
    os.system('cmsStage %s %s'%(outputStr,opt.dir))
    if opt.deleteOriginal : 
        for f in mergeFiles : 
            os.system('cmsRm %s'%f)

usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage)
parser.add_option('-d', '--dir',  dest='dir',            help='input directory', default='')
parser.add_option('-r',           dest='deleteOriginal', help='delete original', action='store_true')
parser.add_option('-m',           dest='mergeOriginal',  help='mere original',    action='store_true')
(opt, args) = parser.parse_args()

from UserCode.HGCanalysis.storeTools_cff import fillFromStore
allFiles=fillFromStore(opt.dir)

totEvts=0
mergeFiles=[]
igroup=0
nremoved=0
for f in allFiles :
    try:
        result=commands.getstatusoutput('edmFileUtil -P %s | grep -ir bytes | awk \'{print $6}\''%f)
        iEvts=int(result[1])
        totEvts+=iEvts
        if opt.mergeOriginal : mergeFiles.append(f)
    except:
        pos = f.find('/store')
        result=commands.getstatusoutput('cmsRm %s'%(f[pos:]))
        nremoved+=1
    outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands,
    fileName = cms.untracked.string('file:%s/Events_PU%d.root'%(outputDir,avgPU)),
    dataset = cms.untracked.PSet(
        filterName = cms.untracked.string(''),
        dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW')
    )
)

# Additional output definition

# Other statements
process.mix.input.nbPileupEvents.averageNumber = cms.double(avgPU)
process.mix.bunchspace = cms.int32(25)
process.mix.minBunch = cms.int32(-12)
process.mix.maxBunch = cms.int32(3)
mixFileNames=fillFromStore('/store/cmst3/group/hgcal/CMSSW/%s'%minBiasPreFix,0,-1)
import random
random.shuffle(mixFileNames)
process.mix.input.fileNames = cms.untracked.vstring(mixFileNames)
process.mix.digitizers = cms.PSet(process.theDigitizersValid)
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')

# Path and EndPath definitions
process.digitisation_step = cms.Path(process.pdigi_valid)
process.L1simulation_step = cms.Path(process.SimL1Emulator)
process.digi2raw_step = cms.Path(process.DigiToRaw)
process.endjob_step = cms.EndPath(process.endOfProcess)
process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput)

# Schedule definition