Skip to content

Commit 17673c7

Browse files
committed
Updated test of edm::Ref use from a merged ROOT file
- consolidated two cfg files into one with command line options - modernized module configuration syntax - extended test to include case where different branches are in the different files
1 parent b5cf409 commit 17673c7

File tree

6 files changed

+110
-90
lines changed

6 files changed

+110
-90
lines changed
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
import sys
4+
5+
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test ConditionalTasks.')
6+
7+
parser.add_argument("--inFile1", help="first file to read")
8+
parser.add_argument("--inFile2", help="second file to read")
9+
parser.add_argument("--outFile", help="name of output file", default="ref_merge.root")
10+
11+
args = parser.parse_args()
12+
213
process = cms.Process("MERGE")
314

4-
process.source = cms.Source("PoolSource",
5-
fileNames = cms.untracked.vstring("file:ref_merge_prod1.root",
6-
"file:ref_merge_prod2.root")
15+
from IOPool.Input.modules import PoolSource
16+
process.source = PoolSource(fileNames = [f"file:{args.inFile1}",
17+
f"file:{args.inFile2}"]
718
)
819

9-
process.out = cms.OutputModule("PoolOutputModule",
10-
fileName = cms.untracked.string("ref_merge.root")
11-
)
20+
from IOPool.Output.modules import PoolOutputModule
21+
process.out = PoolOutputModule(fileName = args.outFile)
1222

13-
process.tester = cms.EDAnalyzer("OtherThingAnalyzer",
14-
other = cms.untracked.InputTag("d","testUserTag"))
23+
from FWCore.Integration.modules import OtherThingAnalyzer
24+
process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))
1525

1626
process.o = cms.EndPath(process.out+process.tester)
1727

FWCore/Integration/test/ref_merge_prod1_cfg.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

FWCore/Integration/test/ref_merge_prod2_cfg.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
import argparse
4+
import sys
5+
6+
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test ConditionalTasks.')
7+
8+
parser.add_argument("--extraProducers", help="Add extra producers to configuration", action="store_true")
9+
parser.add_argument("--fileName", help="name of output file")
10+
parser.add_argument("--firstLumi", help="LuminosityBlock number for first lumi", type = int, default=1)
11+
parser.add_argument("--keepAllProducts", help="Keep all products made in the job", action="store_true")
12+
parser.add_argument("--dropThings", help="drop the Things collections so the refs will not function", action="store_true")
13+
14+
args = parser.parse_args()
15+
16+
17+
process = cms.Process("PROD")
18+
19+
nEvents = 10
20+
from FWCore.Modules.modules import EmptySource
21+
process.source = EmptySource(
22+
firstLuminosityBlock = args.firstLumi,
23+
firstEvent = nEvents*(args.firstLumi-1)+1
24+
)
25+
26+
process.maxEvents.input = nEvents
27+
28+
if args.extraProducers:
29+
from FWCore.Framework.modules import IntProducer
30+
process.a = IntProducer(ivalue = 1)
31+
32+
process.b = IntProducer(ivalue = 2)
33+
34+
from FWCore.Integration.modules import ThingProducer, OtherThingProducer, OtherThingAnalyzer
35+
process.c = ThingProducer()
36+
37+
process.d = OtherThingProducer(thingTag="c")
38+
39+
outputs = []
40+
if not args.keepAllProducts:
41+
outputs = ["drop *",
42+
"keep edmtestOtherThings_*_*_*"]
43+
if not args.dropThings:
44+
outputs.append("keep edmtestThings_*_*_*")
45+
46+
47+
from IOPool.Output.modules import PoolOutputModule
48+
process.o = PoolOutputModule(outputCommands = outputs,
49+
fileName = args.fileName
50+
)
51+
if args.extraProducers:
52+
process.p = cms.Path(process.a+process.b+process.c*process.d)
53+
else:
54+
process.p = cms.Path(process.c*process.d)
55+
56+
process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))
57+
58+
process.out = cms.EndPath(process.o+process.tester)
59+
60+
61+
62+
63+
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
import sys
4+
5+
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test Refs after merge.')
6+
7+
parser.add_argument("--fileName", help="file to read")
8+
9+
args = parser.parse_args()
10+
211
process = cms.Process("TEST")
312

4-
process.source = cms.Source("PoolSource",
5-
fileNames = cms.untracked.vstring("file:ref_merge.root")
6-
)
13+
from IOPool.Input.modules import PoolSource
14+
process.source = PoolSource(fileNames = [f"file:{args.fileName}"])
715

8-
process.tester = cms.EDAnalyzer("OtherThingAnalyzer",
9-
other = cms.untracked.InputTag("d","testUserTag"))
16+
from FWCore.Integration.modules import OtherThingAnalyzer
17+
process.tester = OtherThingAnalyzer(other = ("d","testUserTag"))
1018

1119
process.e = cms.EndPath(process.tester)
1220

FWCore/Integration/test/run_RefMerge.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,28 @@ function die { echo Failure $1: status $2 ; exit $2 ; }
66

77
LOCAL_TEST_DIR=${SCRAM_TEST_PATH}
88
echo ${test}prod1 ------------------------------------------------------------
9-
cmsRun ${LOCAL_TEST_DIR}/${test}prod1_cfg.py || die "cmsRun ${test}prod1_cfg.py" $?
9+
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --extraProducers --fileName 'ref_merge_prod1.root' || die "cmsRun ${test}prod_cfg.py --extraProducers" $?
1010

1111
echo ${test}prod2 ------------------------------------------------------------
12-
cmsRun ${LOCAL_TEST_DIR}/${test}prod2_cfg.py || die "cmsRun ${test}prod2_cfg.py" $?
12+
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --firstLumi 10 --fileName 'ref_merge_prod2.root'|| die "cmsRun ${test}prod_cfg.py" $?
1313

1414
echo ${test}MERGE------------------------------------------------------------
15-
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py || die "cmsRun ${test}cfg.py" $?
15+
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py --inFile1 'ref_merge_prod1.root' --inFile2 'ref_merge_prod2.root' --outFile 'ref_merge.root' || die "cmsRun ${test}cfg.py" $?
1616

1717
echo ${test}test------------------------------------------------------------
18-
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py || die "cmsRun ${test}test_cfg.py" $?
18+
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py --fileName 'ref_merge.root' || die "cmsRun ${test}test_cfg.py" $?
19+
20+
echo ${test}keepAllProd ------------------------------------------------------------
21+
cmsRun ${LOCAL_TEST_DIR}/${test}prod_cfg.py --extraProducers --keepAllProducts --fileName 'ref_merge_prod_all.root' || die "cmsRun ${test}prod_cfg.py --keepAllProducts" $?
22+
23+
echo ${test}MERGE_keepAll1st ------------------------------------------------------------
24+
cmsRun ${LOCAL_TEST_DIR}/${test}cfg.py --inFile1 'ref_merge_prod_all.root' --inFile2 'ref_merge_prod2.root' --outFile 'ref_merge_all1st.root' || die "cmsRun ${test}cfg.py" $?
25+
26+
echo ${test}test_all1st------------------------------------------------------------
27+
cmsRun ${LOCAL_TEST_DIR}/${test}test_cfg.py --fileName 'ref_merge_all1st.root' || die "cmsRun ${test}test_cfg.py all1st" $?
28+
29+
#note having all be the second file does not work as PoolSource enforces that subsequent files must have a strict subset
30+
# of the branches in the first file read
1931

2032
echo ${test}test------------------------------------------------------------
2133
cmsRun ${LOCAL_TEST_DIR}/${test}subprocess_cfg.py || die "cmsRun ${test}subprocess_cfg.py" $?

0 commit comments

Comments
 (0)