Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-13 03:23:53

0001 # -*- coding: utf-8 -*-
0002 import FWCore.ParameterSet.Config as cms
0003 process = cms.Process("L1TMuonEmulation")
0004 import os
0005 import sys
0006 #import commands
0007 import re
0008 from os import listdir
0009 from os.path import isfile, join
0010 import fnmatch
0011 
0012 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0013 
0014 verbose = True
0015 
0016 filesNameLike = sys.argv[2]
0017 
0018 #version = "ExtraplMB1nadMB2DTQualAndEtaFloatP_atan_ValueP1Scale_t20_deltaPhiVsPhiB_SingleMu_iPt_10files"
0019 #version = "noExtrapl_ValueP1Scale_t18_qualConverted_min4_ipT1_deltaPhiVsPhiRef_fixedDTScale"
0020 #version = "ExtraplMB1nadMB2DTQualAndEtaFloatP_atan_ValueP1Scale_t20_deltaPhiVsPhiB_300files"
0021 version = "ExtraplMB1nadMB2DTQualAndEtaFixedP_ValueP1Scale_t20_deltaPhiVsPhiB_500files"
0022 
0023 if verbose: 
0024     process.MessageLogger = cms.Service("MessageLogger",
0025        #suppressInfo       = cms.untracked.vstring('AfterSource', 'PostModule'),
0026        destinations   = cms.untracked.vstring(
0027                                                #'detailedInfo',
0028                                                #'critical',
0029                                                #'cout',
0030                                                #'cerr',
0031                                                'omtfEventPrint'
0032                     ),
0033        categories        = cms.untracked.vstring('l1tOmtfEventPrint', 'OMTFReconstruction'),
0034        omtfEventPrint = cms.untracked.PSet(    
0035                          filename  = cms.untracked.string("Patterns_dispalced_test_" + version + "_" + filesNameLike),
0036                          extension = cms.untracked.string('.txt'),                
0037                          threshold = cms.untracked.string('INFO'),
0038                          default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), 
0039                          #INFO   =  cms.untracked.int32(0),
0040                          #DEBUG   = cms.untracked.int32(0),
0041                          l1tOmtfEventPrint = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0042                          OMTFReconstruction = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) )
0043                        ),
0044        debugModules = cms.untracked.vstring('simOmtfPhase2Digis') 
0045        #debugModules = cms.untracked.vstring('*')
0046     )
0047 
0048     #process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(100)
0049 if not verbose:
0050     process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(-1)
0051     process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(False), 
0052                                          #SkipEvent = cms.untracked.vstring('ProductNotFound') 
0053                                      )
0054     
0055 # import of standard configurations
0056 process.load('Configuration.StandardSequences.Services_cff')
0057 #process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0058 #process.load('FWCore.MessageService.MessageLogger_cfi')
0059 #process.load('Configuration.EventContent.EventContent_cff')
0060 #process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0061 process.load('Configuration.Geometry.GeometryExtended2026D95Reco_cff')
0062 process.load('Configuration.StandardSequences.MagneticField_cff')
0063 #process.load('Configuration.StandardSequences.RawToDigi_cff')
0064 #process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0065 #process.load('Configuration.StandardSequences.SimPhase2L1GlobalTriggerEmulator_cff')
0066 #process.load('L1Trigger.Configuration.Phase2GTMenus.SeedDefinitions.prototypeSeeds')
0067 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0068 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0069 
0070 from Configuration.AlCa.GlobalTag import GlobalTag
0071 process.GlobalTag = GlobalTag(process.GlobalTag, '131X_mcRun4_realistic_v9', '')
0072 
0073 chosenFiles = []
0074 
0075 cscBx = 8
0076 
0077 if filesNameLike == 'displHighPt' : # displaced muon sample
0078     cscBx = 8
0079     #path = '/eos/user/c/cericeci/forOMTF/OMTF_PhaseII_FixedTiming/'
0080     path =  '/eos/user/a/asotorod/Samples/OMTF-L1/OMTF_fixedTiming/'
0081     
0082     fileCnt = 20 
0083     firstFile = 1 #1001            
0084     for i in range(firstFile, firstFile + fileCnt, 1):
0085         filePathName = path + "custom_Displaced_" + str(i) + "_numEvent5000.root"
0086         if isfile(filePathName) :
0087             #chosenFiles.append('file://' + path + "custom_Displaced_Run3_" + str(i) + "_numEvent1000.root") 
0088             #chosenFiles.append('file://' + path + "custom_Displaced_Run3_" + str(i) + "_numEvent2000.root") 
0089             chosenFiles.append('file://' + filePathName)
0090 
0091 ### N.B. for phase1 samples there are no DT hits
0092 elif filesNameLike == 'mcWaw2023' :
0093     cscBx = 8
0094       
0095     for iPt in [0, 1, 2] :
0096         for charge in [0, 2] : 
0097             path = "/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch" + str(charge) + "_iPt" + str(iPt) + "_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/"
0098             #path = '/eos/user/a/akalinow/Data/SingleMu/12_5_2_p1_04_04_2023/SingleMu_ch0_iPt1_12_5_2_p1_04_04_2023/12_5_2_p1_04_04_2023/230404_084317/0000/'
0099               
0100             root_files = []
0101             for root, dirs, files in os.walk(path):
0102                 for file in fnmatch.filter(files, '*.root'):
0103                     root_files.append(os.path.join(root, file))
0104 
0105             file_cnt = 10
0106                    
0107             file_num = 0    
0108             for root_file in root_files :
0109                 if isfile(root_file) :
0110                     chosenFiles.append('file://' + root_file)
0111                     file_num += 1
0112                 else :
0113                     print("file not found!!!!!!!: " + root_file)   
0114                     
0115                 if file_num >= file_cnt :
0116                     break  
0117                 
0118 elif filesNameLike == 'XTo2LLPTo1Mu' :            
0119     path = "/eos/user/a/almuhamm/ZMu_Test/ExoticLLP/XTo2LLPTo1Mu_CTau8000_Phase2Exotic/231119_223651/0000/"
0120     root_files = []
0121     for root, dirs, files in os.walk(path):
0122         for file in fnmatch.filter(files, '*.root'):
0123             root_files.append(os.path.join(root, file))
0124 
0125     file_cnt = 500
0126            
0127     file_num = 0    
0128     for root_file in root_files :
0129         if isfile(root_file) :
0130             chosenFiles.append('file://' + root_file)
0131             file_num += 1
0132         else :
0133             print("file not found!!!!!!!: " + root_file)   
0134             
0135         if file_num >= file_cnt :
0136             break  
0137                 
0138 print("chosenFiles")
0139 for chFile in chosenFiles:
0140     print(chFile)
0141 
0142 if len(chosenFiles) == 0 :
0143     print("no files selected!!!!!!!!!!!!!!! (argumetn should be e.g. 20_p")
0144     exit 
0145                             
0146 # input files (up to 255 files accepted)
0147 process.source = cms.Source('PoolSource',
0148 fileNames = cms.untracked.vstring( 
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 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1))
0161 
0162 
0163 #Calibrate Digis
0164 process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi")
0165 process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" 
0166 process.CalibratedDigis.scenario = 0
0167 
0168 #DTTriggerPhase2
0169 process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi")
0170 process.dtTriggerPhase2PrimitiveDigis.debug = False
0171 process.dtTriggerPhase2PrimitiveDigis.dump = False
0172 process.dtTriggerPhase2PrimitiveDigis.scenario = 0
0173 
0174 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) )
0175                                    
0176 ####OMTF Emulator
0177 process.load('L1Trigger.L1TMuonOverlapPhase2.simOmtfPhase2Digis_cfi')
0178 
0179 #needed by candidateSimMuonMatcher
0180 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi")
0181 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi")
0182 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi")
0183 
0184 process.simOmtfPhase2Digis.candidateSimMuonMatcher = cms.bool(True)
0185 process.simOmtfPhase2Digis.simTracksTag = cms.InputTag('g4SimHits')
0186 process.simOmtfPhase2Digis.simVertexesTag = cms.InputTag('g4SimHits')
0187 process.simOmtfPhase2Digis.muonMatcherFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/muonMatcherHists_100files_smoothStdDev_withOvf.root")
0188 
0189 
0190 process.simOmtfPhase2Digis.bxMin = cms.int32(0)
0191 process.simOmtfPhase2Digis.bxMax = cms.int32(0)
0192 
0193 process.simOmtfPhase2Digis.dumpResultToXML = cms.bool(False)
0194 process.simOmtfPhase2Digis.eventCaptureDebug = cms.bool(False)
0195 
0196 process.simOmtfPhase2Digis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")
0197 #process.simOmtfPhase2Digis.patternsXMLFiles = cms.VPSet(cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_plus_v1.xml")),
0198 #                                                       cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_minus_v1.xml"))
0199 #)
0200 
0201 #process.simOmtfPhase2Digis.patternGenerator = cms.string("patternGen")
0202 process.simOmtfPhase2Digis.patternGenerator = cms.string("2DHists")
0203 #process.simOmtfPhase2Digis.patternGenerator = cms.string("deltaPhiVsPhiRef")
0204 
0205 process.simOmtfPhase2Digis.patternType = cms.string("GoldenPatternWithStat")
0206 process.simOmtfPhase2Digis.generatePatterns = cms.bool(True)
0207 process.simOmtfPhase2Digis.optimisedPatsXmlFile = cms.string("Patterns_dispalced_test_" + version + "_" + filesNameLike + ".xml")
0208 
0209 process.simOmtfPhase2Digis.rpcMaxClusterSize = cms.int32(3)
0210 process.simOmtfPhase2Digis.rpcMaxClusterCnt = cms.int32(2)
0211 process.simOmtfPhase2Digis.rpcDropAllClustersIfMoreThanMax = cms.bool(True)
0212 
0213 process.simOmtfPhase2Digis.minCSCStubRME12 = cms.int32(410) #[cm]
0214 process.simOmtfPhase2Digis.minCSCStubR = cms.int32(500) #[cm]
0215 
0216 process.simOmtfPhase2Digis.minDtPhiQuality = cms.int32(2)
0217 process.simOmtfPhase2Digis.minDtPhiBQuality = cms.int32(4)
0218 
0219 #process.simOmtfPhase2Digis.dtPhiBUnitsRad = cms.int32(2048) #2048 is the orginal phase2 scale, 512 is the phase1 scale
0220 
0221 process.simOmtfPhase2Digis.dtRefHitMinQuality =  cms.int32(4)
0222 
0223 process.simOmtfPhase2Digis.usePhiBExtrapolationFromMB1 = cms.bool(True)
0224 process.simOmtfPhase2Digis.usePhiBExtrapolationFromMB2 = cms.bool(True)
0225 #process.simOmtfPhase2Digis.usePhiBExtrapolationFromMB1 = cms.bool(False)
0226 #process.simOmtfPhase2Digis.usePhiBExtrapolationFromMB2 = cms.bool(False)
0227 
0228 process.simOmtfPhase2Digis.useStubQualInExtr  = cms.bool(True)
0229 process.simOmtfPhase2Digis.useEndcapStubsRInExtr  = cms.bool(True)
0230 process.simOmtfPhase2Digis.useFloatingPointExtrapolation  = cms.bool(False)
0231 #process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_DTQualAndEtaValueP1Scale.xml")
0232 #process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_simple.xml")
0233 process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/ExtrapolationFactors_ExtraplMB1nadMB2DTQual_ValueP1Scale_t20.xml")
0234 #process.simOmtfPhase2Digis.extrapolFactorsFilename = cms.FileInPath("")
0235 
0236 process.simOmtfPhase2Digis.stubEtaEncoding = cms.string("valueP1Scale")  
0237 #process.simOmtfPhase2Digis.stubEtaEncoding = cms.string("bits")   
0238 
0239 process.simOmtfPhase2Digis.goldenPatternResultFinalizeFunction = cms.int32(3) ## is needed here , becasue it just counts the number of layers with a stub
0240 process.simOmtfPhase2Digis.lctCentralBx = cms.int32(cscBx);#<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!TODO this was changed in CMSSW 10(?) to 8. if the data were generated with the previous CMSSW then you have to use 6
0241 
0242 
0243 
0244 #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0245 #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0246 
0247 process.L1TMuonSeq = cms.Sequence( process.simOmtfPhase2Digis 
0248                                    #+ process.dumpED
0249                                    #+ process.dumpES
0250 )
0251 
0252 process.L1TMuonPath = cms.Path(process.L1TMuonSeq)
0253 
0254 #process.out = cms.OutputModule("PoolOutputModule", 
0255 #   fileName = cms.untracked.string("l1tomtf_superprimitives1.root")
0256 #)
0257 
0258 #process.output_step = cms.EndPath(process.out)
0259 #process.schedule = cms.Schedule(process.L1TMuonPath)
0260 #process.schedule.extend([process.output_step])