Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-12 23:03:57

0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.Utilities.FileUtils as FileUtils
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 
0005 # PART 1 : PARSE ARGUMENTS
0006 
0007 options = VarParsing.VarParsing ('analysis')
0008 options.register('debug',
0009                  0,
0010                  VarParsing.VarParsing.multiplicity.singleton,
0011                  VarParsing.VarParsing.varType.int,
0012                  "Print out additional debugging information")
0013 options.register ('format',
0014                   'EMP', # default value
0015                   VarParsing.VarParsing.multiplicity.singleton,
0016                   VarParsing.VarParsing.varType.string,
0017                   "File format (APx, EMP or X2O)")
0018 options.register('threads',
0019                  1, # default value
0020                  VarParsing.VarParsing.multiplicity.singleton,
0021                  VarParsing.VarParsing.varType.int,
0022                  "Number of threads to run")
0023 options.register('streams',
0024                  0, # default value
0025                  VarParsing.VarParsing.multiplicity.singleton,
0026                  VarParsing.VarParsing.varType.int,
0027                  "Number of streams to run")
0028 options.register ('tracks',
0029                   'donotload', # default value
0030                   VarParsing.VarParsing.multiplicity.singleton,
0031                   VarParsing.VarParsing.varType.string,
0032                   "Whether to load tracks from buffers and how to treat them in the processing chain ('donotload', 'load', 'overwrite')")
0033 options.register ('vertices',
0034                   'donotload', # default value
0035                   VarParsing.VarParsing.multiplicity.singleton,
0036                   VarParsing.VarParsing.varType.string,
0037                   "Whether to load vertices from buffers and how to treat them in the processing chain ('donotload', 'load', 'overwrite')")
0038 options.register ('readerformat',
0039                   'EMPv2', # default value
0040                   VarParsing.VarParsing.multiplicity.singleton,
0041                   VarParsing.VarParsing.varType.string,
0042                   "File format of loaded tracks and vertices (APx, EMPv2)")
0043 options.parseArguments()
0044 
0045 inputFiles = []
0046 inputBuffers = []
0047 inputTrackBuffers = []
0048 for filePath in options.inputFiles:
0049     if filePath.endswith(".root"):
0050         inputFiles.append(filePath)
0051     elif filePath.endswith("_cff.py"):
0052         filePath = filePath.replace("/python/","/")
0053         filePath = filePath.replace("/", ".")
0054         inputFilesImport = getattr(__import__(filePath.strip(".py"),fromlist=["readFiles"]),"readFiles")
0055         inputFiles.extend( inputFilesImport )
0056         if options.vertices in ['load', 'overwrite']:
0057             inputBuffersImport = getattr(__import__(filePath.strip(".py"),fromlist=["correlator_source"]),"correlator_source").fileNames
0058             inputBuffers.extend( inputBuffersImport )
0059         if options.tracks in ['load', 'overwrite']:
0060             inputTrackBuffersImport = getattr(__import__(filePath.strip(".py"),fromlist=["track_source"]),"track_source").fileNames
0061             inputTrackBuffers.extend( inputTrackBuffersImport )
0062     else:
0063         inputFiles += FileUtils.loadListFromFile(filePath)
0064 
0065 # PART 2: SETUP MAIN CMSSW PROCESS 
0066 
0067 
0068 process = cms.Process("GTTFileWriter")
0069 
0070 process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff')
0071 process.load('Configuration.Geometry.GeometryExtended2026D88_cff')
0072 process.load('Configuration.StandardSequences.MagneticField_cff')
0073 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0074 from Configuration.AlCa.GlobalTag import GlobalTag
0075 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')
0076 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0077 
0078 process.source = cms.Source("PoolSource",
0079     fileNames = cms.untracked.vstring(inputFiles),
0080     inputCommands = cms.untracked.vstring("keep *", "drop l1tTkPrimaryVertexs_L1TkPrimaryVertex__*")
0081 )
0082 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) )
0083 process.options = cms.untracked.PSet(
0084     numberOfThreads = cms.untracked.uint32(options.threads),
0085     numberOfStreams = cms.untracked.uint32(options.streams if options.streams>0 else 0)
0086 )
0087 
0088 process.load('L1Trigger.L1TTrackMatch.l1tGTTInputProducer_cfi')
0089 process.load('L1Trigger.L1TTrackMatch.l1tTrackSelectionProducer_cfi')
0090 process.load('L1Trigger.VertexFinder.l1tVertexProducer_cfi')
0091 process.load('L1Trigger.L1TTrackMatch.l1tTrackVertexAssociationProducer_cfi')
0092 process.load('L1Trigger.L1TTrackMatch.l1tTrackJetsEmulation_cfi')
0093 process.load('L1Trigger.L1TTrackMatch.l1tTrackerEmuHTMiss_cfi')
0094 process.load('L1Trigger.L1TTrackMatch.l1tTrackerEmuEtMiss_cfi')
0095 process.load('L1Trigger.DemonstratorTools.l1tGTTFileWriter_cfi')
0096 process.load('L1Trigger.DemonstratorTools.l1tGTTFileReader_cfi')
0097 
0098 process.l1tGTTFileReader.processOutputToCorrelator = cms.bool((options.vertices in ['load', 'overwrite']))
0099 process.l1tGTTFileReader.processInputTracks = cms.bool((options.tracks in ['load', 'overwrite']))
0100 process.l1tGTTFileReader.processOutputToGlobalTrigger = cms.bool(False) #NotImplemented
0101 process.l1tGTTFileReader.filesOutputToCorrelator = inputBuffers if (options.vertices in ['load', 'overwrite']) else cms.vstring("L1GTTOutputToCorrelatorFile_0.txt")
0102 process.l1tGTTFileReader.filesInputTracks = inputTrackBuffers if (options.tracks in ['load', 'overwrite']) else cms.vstring("L1GTTInputFile_0.txt")
0103 process.l1tGTTFileReader.filesOutputToGlobalTrigger = cms.vstring("L1GTTOutputToGlobalTriggerFile_0.txt")
0104 process.l1tGTTFileReader.format = cms.untracked.string(options.readerformat)
0105 
0106 process.l1tGTTInputProducer.debug = cms.int32(options.debug)
0107 if (options.tracks in ['overwrite']):
0108     process.l1tGTTInputProducer.l1TracksInputTag = cms.InputTag("l1tGTTFileReader", "Level1TTTracks")
0109     process.l1tGTTInputProducer.setTrackWordBits = cms.bool(False)
0110 
0111 process.l1tTrackSelectionProducer.processSimulatedTracks = cms.bool(False)
0112 process.l1tVertexFinderEmulator.VertexReconstruction.VxMinTrackPt = cms.double(0.0)
0113 process.l1tVertexFinderEmulator.debug = options.debug
0114 process.l1tTrackVertexAssociationProducer.processSimulatedTracks = cms.bool(False)
0115 
0116 process.l1tTrackSelectionProducerForEtMiss.processSimulatedTracks = cms.bool(False)
0117 process.l1tTrackVertexAssociationProducerForEtMiss.processSimulatedTracks = cms.bool(False)
0118 process.l1tTrackerEmuEtMiss.debug = options.debug
0119 
0120 process.l1tTrackSelectionProducerForJets.processSimulatedTracks = cms.bool(False)
0121 process.l1tTrackSelectionProducerForJets.cutSet = cms.PSet(
0122     ptMin = cms.double(2.0), # pt must be greater than this value, [GeV]
0123     absEtaMax = cms.double(2.4), # absolute value of eta must be less than this value
0124     absZ0Max = cms.double(15.0), # z0 must be less than this value, [cm]
0125     nStubsMin = cms.int32(4), # number of stubs must be greater than or equal to this value
0126     nPSStubsMin = cms.int32(0), # the number of stubs in the PS Modules must be greater than or equal to this value
0127     
0128     promptMVAMin = cms.double(-1.0), # MVA must be greater than this value
0129     reducedBendChi2Max = cms.double(2.25), # bend chi2 must be less than this value
0130     reducedChi2RZMax = cms.double(5.0), # chi2rz/dof must be less than this value
0131     reducedChi2RPhiMax = cms.double(20.0), # chi2rphi/dof must be less than this value
0132 )
0133 process.l1tTrackVertexAssociationProducerForJets.processSimulatedTracks = cms.bool(False)
0134 process.l1tTrackVertexAssociationProducerForJets.cutSet = cms.PSet(
0135     #deltaZMaxEtaBounds = cms.vdouble(0.0, absEtaMax.value), # these values define the bin boundaries in |eta|
0136     #deltaZMax = cms.vdouble(0.5), # delta z must be less than these values, there will be one less value here than in deltaZMaxEtaBounds, [cm]
0137     deltaZMaxEtaBounds = cms.vdouble(0.0, 0.7, 1.0, 1.2, 1.6, 2.0, 2.4), # these values define the bin boundaries in |eta|
0138     deltaZMax = cms.vdouble(0.37, 0.50, 0.60, 0.75, 1.00, 1.60), # delta z must be less than these values, there will be one less value here than in deltaZMaxEtaBounds, [cm]
0139 )
0140 process.l1tTrackerEmuHTMiss.debug = (options.debug > 0)
0141 
0142 #Disable internal track selection
0143 process.l1tTrackJetsEmulation.trk_zMax = cms.double(20.46912512)    # maximum track z from TrackWord
0144 
0145 if options.debug:
0146     process.MessageLogger.cerr.INFO.limit = cms.untracked.int32(1000000000)
0147     process.MessageLogger.suppressInfo = cms.untracked.vstring('CondDBESSource', 'PoolDBESSource')
0148     process.MessageLogger.cerr.CondDBESSource = cms.untracked.PSet(
0149         limit = cms.untracked.int32(0)
0150     )
0151 
0152 process.l1tGTTFileWriter.format = cms.untracked.string(options.format) #FIXME Put all this into the default GTTFileWriter
0153 if options.tracks == 'overwrite':
0154     process.l1tGTTFileWriter.tracks = cms.untracked.InputTag("l1tGTTFileReader", "Level1TTTracks")
0155 else:
0156     process.l1tGTTFileWriter.tracks = cms.untracked.InputTag("l1tTTTracksFromTrackletEmulation", "Level1TTTracks")
0157 process.l1tGTTFileWriter.convertedTracks = cms.untracked.InputTag("l1tGTTInputProducer", "Level1TTTracksConverted")
0158 process.l1tGTTFileWriter.selectedTracks = cms.untracked.InputTag("l1tTrackSelectionProducer", "Level1TTTracksSelectedEmulation")
0159 if options.vertices == 'overwrite':
0160     process.l1tGTTFileWriter.vertices = cms.untracked.InputTag("l1tGTTFileReader", "L1VerticesFirmware")
0161 else:
0162     process.l1tGTTFileWriter.vertices = cms.untracked.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation")
0163 process.l1tGTTFileWriter.vertexAssociatedTracks = cms.untracked.InputTag("l1tTrackVertexAssociationProducer", "Level1TTTracksSelectedAssociatedEmulation")
0164 process.l1tGTTFileWriter.jets = cms.untracked.InputTag("l1tTrackJetsEmulation","L1TrackJets")
0165 process.l1tGTTFileWriter.htmiss = cms.untracked.InputTag("l1tTrackerEmuHTMiss", "L1TrackerEmuHTMiss")
0166 process.l1tGTTFileWriter.etmiss = cms.untracked.InputTag("l1tTrackerEmuEtMiss", "L1TrackerEmuEtMiss")
0167 process.l1tGTTFileWriter.outputCorrelatorFilename = cms.untracked.string("L1GTTOutputToCorrelatorFile")
0168 process.l1tGTTFileWriter.outputGlobalTriggerFilename = cms.untracked.string("L1GTTOutputToGlobalTriggerFile")
0169 process.l1tGTTFileWriter.selectedTracksFilename = cms.untracked.string("L1GTTSelectedTracksFile")
0170 process.l1tGTTFileWriter.vertexAssociatedTracksFilename = cms.untracked.string("L1GTTVertexAssociatedTracksFile")
0171 
0172 process.MessageLogger.cerr.FwkReport.reportEvery = 1
0173 process.Timing = cms.Service("Timing", summaryOnly = cms.untracked.bool(True))
0174 
0175 if options.tracks in ['load', 'overwrite'] or options.vertices in ['load', 'overwrite']:
0176     process.p = cms.Path(process.l1tGTTFileReader * process.l1tGTTFileWriter)
0177 else:
0178     process.p = cms.Path(process.l1tGTTFileWriter)
0179 process.p.associate(cms.Task(process.l1tGTTInputProducer, 
0180                              process.l1tTrackSelectionProducer,
0181                              process.l1tVertexFinderEmulator, 
0182                              process.l1tTrackVertexAssociationProducer,
0183                              process.l1tTrackSelectionProducerForJets,
0184                              process.l1tTrackVertexAssociationProducerForJets,
0185                              process.l1tTrackJetsEmulation, 
0186                              process.l1tTrackerEmuHTMiss, 
0187                              process.l1tTrackSelectionProducerForEtMiss,
0188                              process.l1tTrackVertexAssociationProducerForEtMiss,
0189                              process.l1tTrackerEmuEtMiss,
0190                          )
0191                 )