Skip to content

Commit

Permalink
improve unit test SubmitPVsplit and allow for different track collect…
Browse files Browse the repository at this point in the history
…ions to be used. Also refresh the input data
  • Loading branch information
mmusich committed Mar 19, 2024
1 parent d5a9f53 commit a9842ff
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
26 changes: 17 additions & 9 deletions Alignment/OfflineValidation/scripts/submitPVResolutionJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def as_dict(config):
return dictionary

#######################################################
def batchScriptCERN(theCMSSW_BASE,runindex, eosdir,lumiToRun,key,config):
def batchScriptCERN(theCMSSW_BASE, cfgdir, runindex, eosdir, lumiToRun, key, config, tkCollection, isUnitTest=False):
#######################################################
'''prepare the batch script, to run on HTCondor'''
script = """#!/bin/bash
Expand All @@ -201,22 +201,26 @@ def batchScriptCERN(theCMSSW_BASE,runindex, eosdir,lumiToRun,key,config):
cd $CMSSW_DIR
eval `scram runtime -sh`
cd $LXBATCH_DIR
cp -pr $CMSSW_DIR/cfg/PrimaryVertexResolution_{KEY}_{runindex}_cfg.py .
cmsRun PrimaryVertexResolution_{KEY}_{runindex}_cfg.py GlobalTag={GT} lumi={LUMITORUN} {REC} {EXT} >& log_{KEY}_run{runindex}.out
cp -pr {CFGDIR}/PrimaryVertexResolution_{KEY}_{runindex}_cfg.py .
cmsRun PrimaryVertexResolution_{KEY}_{runindex}_cfg.py TrackCollection={TRKS} GlobalTag={GT} lumi={LUMITORUN} {REC} {EXT} >& log_{KEY}_run{runindex}.out
ls -lh .
#for payloadOutput in $(ls *root ); do cp $payloadOutput $OUT_DIR/pvresolution_{KEY}_{runindex}.root ; done
for payloadOutput in $(ls *root ); do xrdcp -f $payloadOutput root://eoscms/$OUT_DIR/pvresolution_{KEY}_{runindex}.root ; done
tar czf log_{KEY}_run{runindex}.tgz log_{KEY}_run{runindex}.out
for logOutput in $(ls *tgz ); do cp $logOutput $LOG_DIR/ ; done
""".format(CMSSW_BASE_DIR=theCMSSW_BASE,
CFGDIR=cfgdir,
runindex=runindex,
MYDIR=eosdir,
KEY=key,
LUMITORUN=lumiToRun,
TRKS=tkCollection,
GT=config['globaltag'],
EXT="external="+config['external'] if 'external' in config.keys() else "",
REC="records="+config['records'] if 'records' in config.keys() else "")


if not isUnitTest:
script += """for payloadOutput in $(ls *root ); do xrdcp -f $payloadOutput root://eoscms/$OUT_DIR/pvresolution_{KEY}_{runindex}.root ; done
tar czf log_{KEY}_run{runindex}.tgz log_{KEY}_run{runindex}.out
for logOutput in $(ls *tgz ); do cp $logOutput $LOG_DIR/ ; done
""".format(KEY=key, runindex=runindex)

return script

#######################################################
Expand Down Expand Up @@ -306,6 +310,7 @@ def main():

cwd = os.getcwd()
bashdir = os.path.join(cwd,"BASH")
cfgdir = os.path.join(cwd,"cfg")

runs.sort()

Expand All @@ -330,6 +335,9 @@ def main():
lumimask = inputDict["Input"]["lumimask"]
print("\n\n Using JSON file:",lumimask)

tkCollection = inputDict["Input"]["trackcollection"]
print("\n\n Using trackCollection:", tkCollection)

mytuple=[]
print("\n\n First run:",opts.start,"last run:",opts.end)

Expand Down Expand Up @@ -411,7 +419,7 @@ def main():

scriptFileName = os.path.join(bashdir,"batchHarvester_"+key+"_"+str(count-1)+".sh")
scriptFile = open(scriptFileName,'w')
scriptFile.write(batchScriptCERN(input_CMSSW_BASE,run,eosdir,theLumi,key,value))
scriptFile.write(batchScriptCERN(input_CMSSW_BASE,cfgdir,run,eosdir,theLumi,key,value,tkCollection,opts.isUnitTest))
scriptFile.close()
#os.system('chmod +x %s' % scriptFileName)

Expand Down
13 changes: 6 additions & 7 deletions Alignment/OfflineValidation/test/PVResolutionExample.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# submitPVResolutionJobs.py -j UNIT_TEST -i PVResolutionExample.ini -D /JetHT/Run2018C-TkAlMinBias-12Nov2019_UL2018-v2/ALCARECO -v
# submitPVResolutionJobs.py -j UNIT_TEST -i PVResolutionExample.ini -D /JetHT/Run2022B-TkAlJetHT-PromptReco-v1/ALCARECO -v
[Input]
# also on afs:
#lumimask=/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions18/13TeV/DCSOnly/json_DCSONLY.txt
lumimask=/eos/cms/store/group/comm_dqm/certification/Collisions18/13TeV/DCSOnly/json_DCSONLY.txt
lumimask=/eos/user/c/cmsdqm/www/CAF/certification/Collisions22/DCSOnly_JSONS/Cert_Collisions2022_355100_362760_eraBCDEFG_13p6TeV_DCSOnly_TkPx_New.json
trackcollection=ALCARECOTkAlJetHT
[Validation:Prompt]
globaltag=111X_dataRun2_v3
globaltag=140X_dataRun3_Prompt_v2
records=TrackerAlignmentRcd:TrackerAlignment_PCL_byRun_v2_express,TrackerAlignmentErrorExtendedRcd:TrackerAlignmentExtendedErr_2009_v2_express_IOVs,TrackerSurfaceDeformationRcd:TrackerSurafceDeformations_v1_express
[Validation:Ultra-Legacy]
globaltag=111X_dataRun2_v3
[Validation:ReReco]
globaltag=140X_dataRun3_ForTkAlReReco_v1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def best_match(rcd):
VarParsing.VarParsing.varType.string, # string, int, or float
"record:fle.db picks the following record from this external file")

options.register ('TrackCollection',
'ALCARECOTkAlMinBias',
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
VarParsing.VarParsing.varType.string, # string, int, or float
"track collection to use")

options.register ('GlobalTag',
'110X_dataRun3_Prompt_v3',
VarParsing.VarParsing.multiplicity.singleton, # singleton or list
Expand All @@ -63,13 +69,14 @@ def best_match(rcd):

options.parseArguments()

print("TrackCollection : ", options.TrackCollection)
print("conditionGT : ", options.GlobalTag)
print("conditionOverwrite: ", options.records)
print("external conditions:", options.external)
print("outputFile : ", options.outputRootFile)

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(False))
process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(True)) #False to silence errors
process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
reportEvery = cms.untracked.int32(1000) # every 100th only
# limit = cms.untracked.int32(10) # or limit to 10 printouts...
Expand Down Expand Up @@ -126,7 +133,7 @@ def best_match(rcd):

process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
# remove the following lines if you run on RECO files
process.TrackRefitter.src = 'ALCARECOTkAlMinBias'
process.TrackRefitter.src = options.TrackCollection
process.TrackRefitter.NavigationSchool = ''

####################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,23 @@
function die { echo $1: status $2 ; exit $2; }

echo " TESTING Split Vertex Validation submission ..."
submitPVResolutionJobs.py -j UNIT_TEST -D /JetHT/Run2018C-TkAlMinBias-12Nov2019_UL2018-v2/ALCARECO \
submitPVResolutionJobs.py -j UNIT_TEST -D /JetHT/Run2022B-TkAlJetHT-PromptReco-v1/ALCARECO \
-i ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/PVResolutionExample.ini --unitTest || die "Failure running Split Vertex Validation submission" $?

echo -e "\n\n TESTING Primary Vertex Split script execution ..."
# Define script name
scriptName="batchHarvester_Prompt_0.sh"

# Create directory if it doesn't exist
mkdir -p "./testExecution"

# Copy script to the test execution directory
cp -pr "./BASH/${scriptName}" "./testExecution/"

# Change directory to the test execution directory
cd "./testExecution" || exit 1

# Execute the script and handle errors
./"${scriptName}" || die "Failure running PVSplit script" $?

cat log_Prompt_run355100.out

0 comments on commit a9842ff

Please sign in to comment.