![]() |
|
|||
File indexing completed on 2024-04-06 12:19:08
0001 # This configuration is used to test ROOT schema evolution. 0002 0003 import FWCore.ParameterSet.Config as cms 0004 import sys 0005 import argparse 0006 0007 parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test ROOT Schema Evolution') 0008 0009 parser.add_argument("--inputFile", type=str, help="Input file name (default: SchemaEvolutionTest.root)", default="SchemaEvolutionTest.root") 0010 parser.add_argument("--outputFileName", type=str, help="Output file name (default: SchemaEvolutionTest2.root)", default="SchemaEvolutionTest2.root") 0011 parser.add_argument("--enableStreamerInfosFix", action="store_true", help="Enable service that fixes missing streamer infos") 0012 args = parser.parse_args() 0013 0014 process = cms.Process("READ") 0015 0016 # The service named FixMissingStreamerInfos is 0017 # tested when enabled. 0018 # 0019 # The version of ROOT associated with CMSSW_13_0_0 0020 # had a bug that caused some products to be written 0021 # to an output file with no StreamerInfo in the file. 0022 # At some future point, if the format of one of those 0023 # types changes then ROOT schema evolution fails. 0024 # 0025 # There is a workaround fix for this problem that 0026 # involves creating a standalone ROOT file that 0027 # contains the StreamerInfo's. Opening and closing 0028 # that file before reading the data files will 0029 # bring the StreamerInfos into memory and makes 0030 # the problem files readable even if the data formats 0031 # change. 0032 # 0033 # Create the "fixit" file as follows: 0034 # 0035 # Create a working area with release CMSSW_13_2_6 0036 # There is nothing special about that release. We could 0037 # have used another release for this. It was just the latest 0038 # at the time this was done (11/1/2023). I didn't want to use 0039 # an IB or pre-release. 0040 # Then add the package with the relevant class definitions and dictionaries: 0041 # git cms-addpkg DataFormats/TestObjects 0042 # 0043 # Add the relevant files from the master branch: 0044 # git checkout official-cmssw/master DataFormats/TestObjects/interface/SchemaEvolutionTestObjects.h 0045 # git checkout official-cmssw/master DataFormats/TestObjects/interface/VectorVectorTop.h 0046 # git checkout official-cmssw/master DataFormats/TestObjects/src/VectorVectorTop.cc 0047 # git checkout official-cmssw/master DataFormats/TestObjects/src/SchemaEvolutionTestObjects.cc 0048 # git checkout official-cmssw/master DataFormats/TestObjects/src/classes_def.xml 0049 # git checkout official-cmssw/master DataFormats/TestObjects/src/classes.h 0050 # 0051 # Edit the files to use the older versions as described above and build. 0052 # 0053 # Note that if a release is available with the desired versions 0054 # (class definitions and classes_def.xml), then you don't need 0055 # to checkout the code and/or edit the code. You probably want 0056 # to use a release at or earlier than the release you will use 0057 # to read the file (this might not be necessary, depends on what 0058 # has changed in ROOT...). 0059 # 0060 # Start root, then give the following commands at the root prompt: 0061 # 0062 # root [0] auto f = TFile::Open("fixitfile.root", "NEW"); 0063 # root [1] TClass::GetClass("edmtest::VectorVectorElementNonSplit")->GetStreamerInfo()->ForceWriteInfo(f); 0064 # root [2] delete f 0065 # 0066 # rename the output file to "fixMissingStreamerInfosUnitTest.root" and add 0067 # to the cms-data repository for IOPool/Input. 0068 # 0069 # Note the test only needs the one class definition, but in real use 0070 # cases many different types of StreamerInfos might be needed. 0071 0072 if args.enableStreamerInfosFix: 0073 process.FixMissingStreamerInfos = cms.Service("FixMissingStreamerInfos", 0074 fileInPath = cms.untracked.FileInPath("IOPool/Input/data/fixMissingStreamerInfosUnitTest.root") 0075 ) 0076 0077 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:"+args.inputFile)) 0078 0079 process.schemaEvolutionTestRead = cms.EDAnalyzer("SchemaEvolutionTestRead", 0080 # I stick to values exactly convertable to float 0081 # to avoid potential rounding issues in the test. 0082 expectedVectorVectorIntegralValues = cms.vint32( 0083 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151 0084 ), 0085 vectorVectorTag = cms.InputTag("writeSchemaEvolutionTest", "", "PROD") 0086 ) 0087 0088 process.out = cms.OutputModule("PoolOutputModule", 0089 fileName = cms.untracked.string(args.outputFileName) 0090 ) 0091 0092 process.path = cms.Path(process.schemaEvolutionTestRead) 0093 0094 process.endPath = cms.EndPath(process.out)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |