Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:11

0001 # -*- coding: utf-8 -*-
0002 import FWCore.ParameterSet.Config as cms
0003 process = cms.Process("L1TMuonEmulation")
0004 import os
0005 import sys
0006 import re
0007 from os import listdir
0008 from os.path import isfile, join
0009 
0010 
0011 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0012 
0013 verbose = True
0014 #version = 't14_extrapolSimpl_displ_allfiles'
0015 #version = 't16_extrapolSimpl_displ_test'
0016 version = 'ExtraplMB1nadMB2FloatQualand_Eta_t17_v12_test_valueP1Scale'
0017 #version = 'ExtraplMB1nadMB2SimplifiedFP_t17_v11_test_bits'
0018 #version = 'Patterns_0x00012_t17_v11_extr_off_test_bits'
0019 
0020 runDebug = "INFO" # or "INFO" DEBUG
0021 useExtraploationAlgo = True
0022 #useExtraploationAlgo = False
0023 
0024 if verbose: 
0025     process.MessageLogger = cms.Service("MessageLogger",
0026        #suppressInfo       = cms.untracked.vstring('AfterSource', 'PostModule'),
0027        destinations   = cms.untracked.vstring(
0028                                                #'detailedInfo',
0029                                                #'critical',
0030                                                #'cout',
0031                                                #'cerr',
0032                                                'omtfEventPrint'
0033                     ),
0034        categories        = cms.untracked.vstring( 'OMTFReconstruction', 'l1tOmtfEventPrint', 'l1MuonAnalyzerOmtf'), #'l1tOmtfEventPrint', 'l1MuonAnalyzerOmtf'
0035        omtfEventPrint = cms.untracked.PSet(    
0036                          filename  = cms.untracked.string('log_MuonOverlap_newPats_t' + version),
0037                          extension = cms.untracked.string('.txt'),                
0038                          threshold = cms.untracked.string(runDebug), #DEBUG
0039                          default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), 
0040                          #INFO   =  cms.untracked.int32(0),
0041                          #DEBUG   = cms.untracked.int32(0),
0042                          l1tOmtfEventPrint = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0043                          OMTFReconstruction = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0044                          l1MuonAnalyzerOmtf = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0045                        ),
0046        debugModules = cms.untracked.vstring('L1MuonAnalyzerOmtf', 'simOmtfDigis') #'L1MuonAnalyzerOmtf',
0047        #debugModules = cms.untracked.vstring('*')
0048     )
0049 
0050     #process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(100)
0051 if not verbose:
0052     process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000)
0053     process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(False), 
0054                                          #SkipEvent = cms.untracked.vstring('ProductNotFound') 
0055                                      )
0056     
0057     
0058 # PostLS1 geometry used
0059 process.load('Configuration.Geometry.GeometryExtended2015Reco_cff')
0060 process.load('Configuration.Geometry.GeometryExtended2015_cff')
0061 ############################
0062 #process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')
0063 #from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
0064 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')    
0065     
0066     
0067 # import of standard configurations
0068 process.load('Configuration.StandardSequences.Services_cff')
0069 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0070 process.load('Configuration.EventContent.EventContent_cff')
0071 process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0072 #process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff')
0073 #process.load('Configuration.Geometry.GeometryExtended2026D41_cff')
0074 process.load('Configuration.StandardSequences.MagneticField_cff')
0075 #process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0076 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0077 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0078 
0079 from Configuration.AlCa.GlobalTag import GlobalTag
0080 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')
0081 process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') 
0082 
0083 
0084 #path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big
0085 #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v2/' #new sample, but small and more noisy
0086 #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v1/'
0087 
0088 
0089 #path = '/afs/cern.ch/work/a/akalinow/public/MuCorrelator/Data/SingleMu/9_3_14_FullEta_v1/'
0090 #path = '/afs/cern.ch/work/k/kbunkow/public/data/SingleMuFullEta/721_FullEta_v4/'
0091 
0092 #onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
0093 #print(onlyfiles)
0094 
0095 #filesNameLike = sys.argv[2]
0096 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_p_10_' in f) or ('_m_10_' in f))]
0097 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_10_p_10_' in f))]
0098 #chosenFiles = ['file://' + path + f for f in onlyfiles if (re.match('.*_._p_10.*', f))]
0099 #chosenFiles = ['file://' + path + f for f in onlyfiles if ((filesNameLike in f))]
0100 
0101 #print(onlyfiles)
0102 
0103 chosenFiles = []
0104 
0105 fileCnt = 1000 #1000 
0106 if(runDebug == "DEBUG") :
0107     fileCnt = 1;
0108     
0109 if True :    #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0110     #path = '/eos/user/c/cericeci/forOMTF/OMTF_PhaseII_FixedTiming/'    
0111     path =  '/eos/user/a/asotorod/Samples/OMTF-L1/OMTF_fixedTiming/'
0112     firstFile = 1 #1001            
0113     for i in range(firstFile, firstFile + fileCnt, 1):
0114         filePathName = path + "custom_Displaced_" + str(i) + "_numEvent5000.root"
0115         if isfile(filePathName) :
0116             chosenFiles.append('file://' + filePathName)
0117         else :
0118             print("file not found!!!!!!!: " + filePathName) 
0119 # low pt
0120 if False :
0121     path = '/eos/user/c/cericeci/forOMTF/OMTF_Run3_FixedTiming_FullOutput/'
0122     firstFile = 1001            
0123     for i in range(firstFile, firstFile + fileCnt, 1):
0124         #filePathName = path + "custom_Displaced_" + str(i) + "_numEvent5000.root"
0125         #chosenFiles.append('file://' + path + "custom_Displaced_Run3_" + str(i) + "_numEvent1000.root") 
0126         filePathName = path + "custom_Displaced_Run3_" + str(i) + "_numEvent2000.root" 
0127         if isfile(filePathName) :
0128             chosenFiles.append('file://' + filePathName)
0129         else :
0130             print("file not found!!!!!!!: " + filePathName)    
0131 
0132 
0133 print("chosenFiles")
0134 for chFile in chosenFiles:
0135     print(chFile)
0136 
0137 if len(chosenFiles) == 0 :
0138     print("no files selected!!!!!!!!!!!!!!!")
0139     exit
0140 
0141 firstEv = 0#40000
0142 #nEvents = 1000
0143 
0144 # input files (up to 255 files accepted)
0145 process.source = cms.Source('PoolSource',
0146 fileNames = cms.untracked.vstring( 
0147     #'file:/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/SingleMu_16_p_1_1_xTE.root',
0148     #'file:/afs/cern.ch/user/k/kpijanow/Neutrino_Pt-2to20_gun_50.root',
0149     list(chosenFiles), ),
0150     skipEvents =  cms.untracked.uint32(0),
0151     inputCommands=cms.untracked.vstring(
0152         'keep *',
0153         'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT',
0154         'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT',
0155         'drop l1tEMTFHit2016s_simEmtfDigis__HLT',
0156         'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT',
0157         'drop l1tEMTFTrack2016s_simEmtfDigis__HLT')
0158 )
0159                         
0160 if(runDebug == "DEBUG") :
0161     process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(5000))
0162 else :
0163     process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1))
0164 
0165 
0166 ####Event Setup Producer
0167 process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff')
0168 process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0008.xml")
0169 
0170 process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter",
0171    toGet = cms.VPSet(
0172       cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'),
0173                data = cms.vstring('L1TMuonOverlapParams'))
0174                    ),
0175    verbose = cms.untracked.bool(False)
0176 )
0177 
0178 analysisType = "efficiency" # or rate
0179   
0180 for a in sys.argv :
0181     if a == "efficiency" or a ==  "rate" or a == "withTrackPart" :
0182         analysisType = a
0183         break;
0184     
0185 print("analysisType=" + analysisType)
0186 
0187 process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis2_eff_SingleMu_t' + version + '.root'), closeFileFast = cms.untracked.bool(True) )
0188                                    
0189 ####OMTF Emulator
0190 if useExtraploationAlgo :
0191     process.load('L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_extrapolSimple_cfi')
0192 else :
0193     process.load('L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi')    
0194 
0195 if(runDebug == "DEBUG") :
0196     process.simOmtfDigis.dumpResultToXML = cms.bool(True)
0197     process.simOmtfDigis.XMLDumpFileName = cms.string("TestEvents_" + version + ".xml")
0198 else :
0199     process.simOmtfDigis.dumpResultToXML = cms.bool(False)
0200 
0201 
0202 if(runDebug == "DEBUG") :
0203     process.simOmtfDigis.eventCaptureDebug = cms.bool(True)
0204 else :
0205     process.simOmtfDigis.eventCaptureDebug = cms.bool(False)    
0206 #process.simOmtfDigis.simTracksTag = cms.InputTag('g4SimHits')
0207 
0208 process.simOmtfDigis.sorterType = cms.string("byLLH")
0209 process.simOmtfDigis.ghostBusterType = cms.string("byRefLayer") # byLLH byRefLayer GhostBusterPreferRefDt
0210 
0211 if useExtraploationAlgo :
0212     #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t10_classProb17_recalib2_test.xml")
0213     #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_ExtraplMB1nadMB2Simplified_t14_classProb17_recalib2.xml")
0214     #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_ExtraplMB1nadMB2FullAlgo_t16_classProb17_recalib2.xml")
0215     process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_ExtraplMB1nadMB2SimplifiedFP_t17_classProb17_recalib2.xml")
0216 else :
0217     process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2.xml")
0218 
0219   
0220 process.simOmtfDigis.rpcMaxClusterSize = cms.int32(3)
0221 process.simOmtfDigis.rpcMaxClusterCnt = cms.int32(2)
0222 process.simOmtfDigis.rpcDropAllClustersIfMoreThanMax = cms.bool(True)
0223 
0224 process.simOmtfDigis.minCSCStubRME12 = cms.int32(410) #[cm]
0225 process.simOmtfDigis.minCSCStubR = cms.int32(490) #[cm]
0226 
0227 process.simOmtfDigis.goldenPatternResultFinalizeFunction = cms.int32(10) #valid values are 0, 1, 2, 3, 5
0228 
0229 process.simOmtfDigis.noHitValueInPdf = cms.bool(True)
0230 
0231 process.simOmtfDigis.minDtPhiQuality = cms.int32(2)
0232 process.simOmtfDigis.minDtPhiBQuality = cms.int32(4)
0233 
0234 process.simOmtfDigis.lctCentralBx = cms.int32(8);#<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!TODO this was changed in CMSSW 10(?) to 8. if the data were generated with the previous CMSSW then you have to use 6
0235 
0236 if useExtraploationAlgo :
0237     process.simOmtfDigis.dtRefHitMinQuality =  cms.int32(4)
0238 
0239     process.simOmtfDigis.usePhiBExtrapolationFromMB1 = cms.bool(True)
0240     process.simOmtfDigis.usePhiBExtrapolationFromMB2 = cms.bool(True)
0241     
0242     process.simOmtfDigis.useStubQualInExtr  = cms.bool(True)
0243     process.simOmtfDigis.useEndcapStubsRInExtr  = cms.bool(True)
0244     process.simOmtfDigis.useFloatingPointExtrapolation  = cms.bool(True)
0245     process.simOmtfDigis.extrapolFactorsFilename = cms.string("")
0246     
0247 process.simOmtfDigis.stubEtaEncoding = cms.string("valueP1Scale")  
0248 #process.simOmtfDigis.stubEtaEncoding = cms.string("bits")   
0249 
0250 #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0251 #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0252 
0253 #process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0254 #process.load("Configuration.StandardSequences.MagneticField_38T_cff")
0255 
0256 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi")
0257 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi")
0258 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi")
0259 
0260 
0261 
0262 
0263 process.L1TMuonSeq = cms.Sequence( process.esProd          
0264                                    + process.simOmtfDigis 
0265                                    #+ process.dumpED
0266                                    #+ process.dumpES
0267 )
0268 
0269 process.L1TMuonPath = cms.Path(process.L1TMuonSeq)
0270 
0271 #process.out = cms.OutputModule("PoolOutputModule", 
0272 #   fileName = cms.untracked.string("l1tomtf_superprimitives1.root")
0273 #)
0274 
0275 #process.output_step = cms.EndPath(process.out)
0276 #process.schedule = cms.Schedule(process.L1TMuonPath)
0277 #process.schedule.extend([process.output_step])