Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13_1_X] APE measurement tool: Resolved python3 compatibility issues, added unit test functionality, removed dependency on other package: Backport of #42012 #42086

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Alignment/APEEstimation/python/ApeEstimator_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
minGoodHitsPerTrack = cms.uint32(0),

#File containing TrackerTree with ideal Geometry
TrackerTreeFile = cms.string(os.environ['CMSSW_BASE'] + '/src/Alignment/TrackerAlignment/hists/TrackerTree.root'),
TrackerTreeFile = cms.string(os.environ['CMSSW_BASE'] + '/src/Alignment/APEEstimation/hists/TrackerTree.root'),

#Sectors defining set of modules for common overview plots resp. APE values
Sectors = cms.VPSet(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import FWCore.ParameterSet.Config as cms

maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
readFiles = cms.untracked.vstring()
secFiles = cms.untracked.vstring()
source = cms.Source ("PoolSource",fileNames = readFiles, secondaryFileNames = secFiles)


readFiles.extend( [
"/store/mc/Run3Winter22DRPremix/WJetsToLNu_TuneCP5_13p6TeV-madgraphMLM-pythia8/ALCARECO/TkAlMuonIsolated-TRKALCADesign_design_geometry_122X_mcRun3_2021_design_v9-v2/2520000/0027e6ed-2626-4ede-97a5-f0a44164b81b.root",
"/store/mc/Run3Winter22DRPremix/WJetsToLNu_TuneCP5_13p6TeV-madgraphMLM-pythia8/ALCARECO/TkAlMuonIsolated-TRKALCADesign_design_geometry_122X_mcRun3_2021_design_v9-v2/2520000/00899b9d-32ab-46f2-b77b-0b0a8d666027.root",
"/store/mc/Run3Winter22DRPremix/WJetsToLNu_TuneCP5_13p6TeV-madgraphMLM-pythia8/ALCARECO/TkAlMuonIsolated-TRKALCADesign_design_geometry_122X_mcRun3_2021_design_v9-v2/2520000/07851676-0c65-4630-bbab-7406defeb670.root",
"/store/mc/Run3Winter22DRPremix/WJetsToLNu_TuneCP5_13p6TeV-madgraphMLM-pythia8/ALCARECO/TkAlMuonIsolated-TRKALCADesign_design_geometry_122X_mcRun3_2021_design_v9-v2/2520000/0a54c512-0f69-44e1-90bc-16da035cbe02.root",
] );



secFiles.extend( [
] )

2 changes: 0 additions & 2 deletions Alignment/APEEstimation/scripts/initialise.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

DIRBASE="$CMSSW_BASE/src/Alignment/APEEstimation"

mkdir $CMSSW_BASE/src/Alignment/TrackerAlignment/hists/

mkdir $DIRBASE/hists/
mkdir $DIRBASE/hists/workingArea/
mkdir $DIRBASE/hists/workingArea/apeObjects/
Expand Down
3 changes: 3 additions & 0 deletions Alignment/APEEstimation/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<environment>
<test name="ApeTest" command="bash unitTest.sh"/>
</environment>
45 changes: 8 additions & 37 deletions Alignment/APEEstimation/test/SkimProducer/skimProducer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
import sys
options = VarParsing.VarParsing ('standard')
options.register('sample', 'data1', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Input sample")
options.register('useTrackList', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Use list of preselected tracks")
options.register('isTest', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Test run")

# get and parse the command line arguments
options.parseArguments()

print("Input sample: ", options.sample)
print("Use list of preselected tracks: ", options.useTrackList)
print("Test run: ", options.isTest)


##
Expand Down Expand Up @@ -79,11 +75,6 @@
outputName = 'MinBias.root'
#outputPath = "workingArea"
trackSelection = "MinBias"
if options.sample == 'data2':
process.load("Alignment.APEEstimation.samples.Data_TkAlMinBias_Run2018C_PromptReco_v3_cff")
outputName = 'MinBias1.root'
#outputPath = "workingArea"
trackSelection = "MinBias"
if options.sample == 'data3':
process.load("Alignment.APEEstimation.samples.Data_TkAlMuonIsolated_22Jan2013C_v1_cff")
outputName = 'Data_TkAlMuonIsolated_22Jan2013C.root'
Expand All @@ -104,22 +95,14 @@
outputPath = '/eos/cms/store/caf/user/jschulz/Skims/MC/UL2016ReRecoRealistic'
outputName = 'Mc_TkAlMuonIsolated_WJetsToLNu_2016.root'
trackSelection = "SingleMu"
if options.sample == 'zmumu':
process.load("")
outputName = ''
trackSelection = "DoubleMu"
if options.sample == 'zmumu10':
process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer12_zmumu10_cff")
outputName = 'Mc_TkAlMuonIsolated_Summer12_zmumu10.root'
trackSelection = "DoubleMu"
if options.sample == 'zmumu20':
process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer12_zmumu20_cff")
outputName = 'Mc_TkAlMuonIsolated_Summer12_zmumu20.root'
trackSelection = "DoubleMu"
if options.sample == 'zmumu50':
process.load("Alignment.APEEstimation.samples.DYToMuMu_M-50_Tune4C_13TeV-pythia8_Spring14dr-TkAlMuonIsolated-castor_PU_S14_POSTLS170_V6-v1_ALCARECO_cff")
outputName = 'Mc_DYToMuMu_M-50_Tune4C_13TeV-pythia8_Spring14dr-TkAlMuonIsolated-castor_PU_S14_POSTLS170_V6-v1.root'
trackSelection = "DoubleMu"

# For unit tests
if options.sample == 'UnitTest':
process.load("Alignment.APEEstimation.samples.MC_UnitTest_TkAlMuonIsolated_cff")
outputName = 'MC_UnitTest_TkAlMuonIsolated.root'
maxEvents = 1000
globalTag = "auto:phase1_2022_design"
trackSelection = "SingleMu"


print("Using output name %s"%(outputName))
Expand Down Expand Up @@ -148,7 +131,6 @@
## Number of Events (should be after input file)
##
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(maxEvents) )
if options.isTest: process.maxEvents.input = 1001


##
Expand Down Expand Up @@ -177,13 +159,6 @@

process.MuSkim = trackSelector

##
## If preselected track list is used
##
if options.useTrackList:
process.MuSkim.src = 'TrackList'
process.TriggerSelectionSequence *= process.TrackList

import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
process.seqTrackselRefit = trackselRefit.getSequence(process, trackSelector.src.getModuleLabel())

Expand Down Expand Up @@ -226,10 +201,6 @@
process.out.outputCommands.extend(process.ApeSkimEventContent.outputCommands)


if options.isTest:
process.out.fileName = os.environ['CMSSW_BASE'] + '/src/Alignment/APEEstimation/hists/test_apeSkim.root'


##
## Outpath
##
Expand Down
6 changes: 3 additions & 3 deletions Alignment/APEEstimation/test/SkimProducer/startSkim.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def condorSubmitSkim(sample, caf=False):
def localStartSkim(sample):
base = os.environ['CMSSW_BASE']

execString = "cmsRun {base}/src/Alignment/APEEstimation/test/SkimProducer/skimProducer_cfg.py isTest=False useTrackList=False sample={sample}".format(sample=sample, base=base)
execString = "cmsRun {base}/src/Alignment/APEEstimation/test/SkimProducer/skimProducer_cfg.py sample={sample}".format(sample=sample, base=base)
print(execString)
toExec = execString.split(" ")

Expand All @@ -73,7 +73,7 @@ def localStartSkim(sample):

def get_output(proc):
while True:
line = proc.stdout.readline().rstrip()
line = proc.stdout.readline().rstrip().decode()
if not line:
break
yield line
Expand Down Expand Up @@ -153,7 +153,7 @@ def main(argv):

if len(args.samples) == 0:
print("Usage: python startSkim.py -s <sample>")
sys.exit()
sys.exit(1)

finalSamples = []
for sample in args.samples:
Expand Down
Loading