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 commands
0007 import re
0008 from os import listdir
0009 from os.path import isfile, join
0010 
0011 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0012 
0013 verbose = True
0014 
0015 filesNameLike = sys.argv[2]
0016 
0017 #version = "ExtraplMB1nadMB2DTQualAndEtaFloatP_atan_ValueP1Scale_t18"
0018 version = "noExtrapl_deltaPhiVsPhiRef"
0019 
0020 if verbose: 
0021     process.MessageLogger = cms.Service("MessageLogger",
0022        #suppressInfo       = cms.untracked.vstring('AfterSource', 'PostModule'),
0023        destinations   = cms.untracked.vstring(
0024                                                #'detailedInfo',
0025                                                #'critical',
0026                                                #'cout',
0027                                                #'cerr',
0028                                                'omtfEventPrint'
0029                     ),
0030        categories        = cms.untracked.vstring('l1tOmtfEventPrint', 'OMTFReconstruction'),
0031        omtfEventPrint = cms.untracked.PSet(    
0032                          filename  = cms.untracked.string("Patterns_dispalced_test_" + version + "_" + filesNameLike),
0033                          extension = cms.untracked.string('.txt'),                
0034                          threshold = cms.untracked.string('INFO'),
0035                          default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), 
0036                          #INFO   =  cms.untracked.int32(0),
0037                          #DEBUG   = cms.untracked.int32(0),
0038                          l1tOmtfEventPrint = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0039                          OMTFReconstruction = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) )
0040                        ),
0041        debugModules = cms.untracked.vstring('simOmtfDigis') 
0042        #debugModules = cms.untracked.vstring('*')
0043     )
0044 
0045     #process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(100)
0046 if not verbose:
0047     process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(-1)
0048     process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(False), 
0049                                          #SkipEvent = cms.untracked.vstring('ProductNotFound') 
0050                                      )
0051     
0052 # PostLS1 geometry used
0053 process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff')
0054 process.load('Configuration.Geometry.GeometryExtended2026D86_cff')  
0055     
0056 # import of standard configurations
0057 process.load('Configuration.StandardSequences.Services_cff')
0058 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0059 process.load('Configuration.EventContent.EventContent_cff')
0060 process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0061 #process.load('Configuration.Geometry.GeometryExtended2026D41Reco_cff')
0062 #process.load('Configuration.Geometry.GeometryExtended2026D41_cff')
0063 process.load('Configuration.StandardSequences.MagneticField_cff')
0064 #process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0065 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0066 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0067 
0068 from Configuration.AlCa.GlobalTag import GlobalTag
0069 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')
0070 process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') 
0071 
0072 #path = '/eos/user/c/cericeci/forOMTF/OMTF_Run3_FixedTiming/'
0073 #path = '/eos/user/c/cericeci/forOMTF/OMTF_Run3_FixedTiming_FullOutput/'
0074 
0075 
0076 #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v2/' #new sample, but small and more noisy
0077 #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v1/'
0078 
0079 #path = '/afs/cern.ch/work/a/akalinow/public/MuCorrelator/Data/SingleMu/9_3_14_FullEta_v1/'
0080 #path = '/afs/cern.ch/work/k/kbunkow/public/data/SingleMuFullEta/721_FullEta_v4/'
0081 
0082 #print(onlyfiles)
0083 
0084 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_p_10_' in f) or ('_m_10_' in f))]
0085 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_10_p_10_' in f))]
0086 #chosenFiles = ['file://' + path + f for f in onlyfiles if (re.match('.*_._p_10.*', f))]
0087 #chosenFiles = ['file://' + path + f for f in onlyfiles if ((filesNameLike in f))]
0088 
0089 #print(onlyfiles)
0090 
0091 chosenFiles = []
0092 
0093 cscBx = 8
0094 
0095 if filesNameLike == 'displHighPt' : # displaced muon sample
0096     cscBx = 8
0097     #path = '/eos/user/c/cericeci/forOMTF/OMTF_PhaseII_FixedTiming/'
0098     path =  '/eos/user/a/asotorod/Samples/OMTF-L1/OMTF_fixedTiming/'
0099     
0100     fileCnt = 200 
0101     firstFile = 1 #1001            
0102     for i in range(firstFile, firstFile + fileCnt, 1):
0103         filePathName = path + "custom_Displaced_" + str(i) + "_numEvent5000.root"
0104         if isfile(filePathName) :
0105             #chosenFiles.append('file://' + path + "custom_Displaced_Run3_" + str(i) + "_numEvent1000.root") 
0106             #chosenFiles.append('file://' + path + "custom_Displaced_Run3_" + str(i) + "_numEvent2000.root") 
0107             chosenFiles.append('file://' + filePathName)
0108     
0109     print("chosenFiles")
0110     for chFile in chosenFiles:
0111         print(chFile)
0112     
0113     if len(chosenFiles) == 0 :
0114         print("no files selected!!!!!!!!!!!!!!! (argumetn should be e.g. 20_p")
0115         exit
0116 
0117 elif filesNameLike == 'allPt' : # promt muon sample
0118     cscBx = 6
0119     path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big
0120     onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
0121     
0122     filesPerPtBin = 10 #TODO max is 200 for the 721_FullEta_v4 and 100 for 9_3_14_FullEta_v2
0123     
0124     for ptCode in range(31, 4, -1) : #the rigt bound of range is not included 
0125         if ptCode == 5 : #5 is 3-4 GeV (maybe 3-3.5 GeV). 4 is 2-3GeV (maybe 2.5-3 GeV), very small fraction makes candidates, and even less reaches the second station
0126             filesPerPtBin = 30
0127         elif ptCode == 6 : #5 is 3-4 GeV (maybe 3-3.5 GeV). 4 is 2-3GeV (maybe 2.5-3 GeV), very small fraction makes candidates, and even less reaches the second station
0128             filesPerPtBin = 20    
0129         elif ptCode <= 7 : 
0130             filesPerPtBin = 10
0131         elif ptCode <= 12 :
0132             filesPerPtBin = 5
0133         else :    
0134             filesPerPtBin = 3
0135             
0136         filesPerPtBin = 1 # TODO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    
0137             
0138         for sign in ['_m', '_p'] : #, m
0139             selFilesPerPtBin = 0
0140             for i in range(1, 50, 1): #TODO
0141                 for f in onlyfiles:
0142                    if (( '_' + str(ptCode) + sign + '_' + str(i) + '_') in f): #TODO for 721_FullEta_v4/
0143                    #if (( '_' + str(ptCode) + sign + '_' + str(i) + ".") in f):  #TODO for 9_3_14_FullEta_v2
0144                         #print(f)
0145                         chosenFiles.append('file://' + path + f) 
0146                         selFilesPerPtBin += 1
0147                 if(selFilesPerPtBin >= filesPerPtBin):
0148                     break
0149 
0150 elif filesNameLike == 'mcWaw2022' :
0151     cscBx = 8
0152     path = '/eos/user/k/kbunkow/cms_data/mc/mcWaw2022/'
0153     chosenFiles.append('file://' + path + "DoubleMuPt1to100Eta24_1kevents.root") 
0154                             
0155 else :
0156     cscBx = 6
0157     path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big
0158     onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
0159     
0160     for i in range(1, 10, 1):
0161         for f in onlyfiles:
0162             if (( filesNameLike + '_' + str(i) + '_') in f):  #TODO for 721_FullEta_v4/
0163             #if (( filesNameLike + '_' + str(i) + '.') in f): #TODO for 9_3_14_FullEta_v2
0164                 print(f)
0165                 chosenFiles.append('file://' + path + f) 
0166 
0167 
0168 # input files (up to 255 files accepted)
0169 process.source = cms.Source('PoolSource',
0170 fileNames = cms.untracked.vstring( 
0171     #'file:/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/SingleMu_16_p_1_1_xTE.root',
0172     #'file:/afs/cern.ch/user/k/kpijanow/Neutrino_Pt-2to20_gun_50.root',
0173     list(chosenFiles), ),
0174     skipEvents =  cms.untracked.uint32(0),
0175     inputCommands=cms.untracked.vstring(
0176         'keep *',
0177         'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT',
0178         'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT',
0179         'drop l1tEMTFHit2016s_simEmtfDigis__HLT',
0180         'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT',
0181         'drop l1tEMTFTrack2016s_simEmtfDigis__HLT')
0182 )
0183 
0184                         
0185 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1))
0186 
0187 
0188 
0189 #Calibrate Digis
0190 process.load("L1Trigger.DTTriggerPhase2.CalibratedDigis_cfi")
0191 process.CalibratedDigis.dtDigiTag = "simMuonDTDigis" 
0192 process.CalibratedDigis.scenario = 0
0193 
0194 #DTTriggerPhase2
0195 process.load("L1Trigger.DTTriggerPhase2.dtTriggerPhase2PrimitiveDigis_cfi")
0196 process.dtTriggerPhase2PrimitiveDigis.debug = False
0197 process.dtTriggerPhase2PrimitiveDigis.dump = False
0198 process.dtTriggerPhase2PrimitiveDigis.scenario = 0
0199 
0200 ####Event Setup Producer
0201 process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff')
0202 process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0009_patGen.xml")
0203 
0204 process.omtfParams.patternsXMLFiles = cms.VPSet(
0205         #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0003.xml")),
0206         #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb1.xml") ),
0207         cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")),
0208         #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2.xml")),
0209         #cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_layerStat_ExtraplMB1nadMB2_t10_classProb17_recalib2.xml")),
0210     )
0211 
0212 
0213 
0214 process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter",
0215    toGet = cms.VPSet(
0216       cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'),
0217                data = cms.vstring('L1TMuonOverlapParams'))
0218                    ),
0219    verbose = cms.untracked.bool(False)
0220 )
0221 
0222 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) )
0223                                    
0224 ####OMTF Emulator
0225 process.load('L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi')
0226 
0227 #needed by candidateSimMuonMatcher
0228 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi")
0229 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi")
0230 #process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi")
0231 
0232 process.simOmtfDigis.candidateSimMuonMatcher = cms.bool(True)
0233 process.simOmtfDigis.simTracksTag = cms.InputTag('g4SimHits')
0234 process.simOmtfDigis.simVertexesTag = cms.InputTag('g4SimHits')
0235 process.simOmtfDigis.muonMatcherFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/muonMatcherHists_100files_smoothStdDev_withOvf.root")
0236 
0237 
0238 process.simOmtfDigis.bxMin = cms.int32(0)
0239 process.simOmtfDigis.bxMax = cms.int32(0)
0240 
0241 process.simOmtfDigis.dumpResultToXML = cms.bool(False)
0242 process.simOmtfDigis.eventCaptureDebug = cms.bool(False)
0243 
0244 process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")
0245 #process.simOmtfDigis.patternsXMLFiles = cms.VPSet(cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_plus_v1.xml")),
0246 #                                                       cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_minus_v1.xml"))
0247 #)
0248 
0249 #process.simOmtfDigis.patternGenerator = cms.string("patternGen")
0250 #process.simOmtfDigis.patternGenerator = cms.string("2DHists")
0251 process.simOmtfDigis.patternGenerator = cms.string("deltaPhiVsPhiRef")
0252 
0253 
0254 process.simOmtfDigis.patternType = cms.string("GoldenPatternWithStat")
0255 process.simOmtfDigis.generatePatterns = cms.bool(True)
0256 process.simOmtfDigis.optimisedPatsXmlFile = cms.string("Patterns_dispalced_test_" + version + "_" + filesNameLike + ".xml")
0257 
0258 process.simOmtfDigis.rpcMaxClusterSize = cms.int32(3)
0259 process.simOmtfDigis.rpcMaxClusterCnt = cms.int32(2)
0260 process.simOmtfDigis.rpcDropAllClustersIfMoreThanMax = cms.bool(True)
0261 
0262 process.simOmtfDigis.minCSCStubRME12 = cms.int32(410) #[cm]
0263 process.simOmtfDigis.minCSCStubR = cms.int32(490) #[cm]
0264 
0265 process.simOmtfDigis.minDtPhiQuality = cms.int32(2)
0266 process.simOmtfDigis.minDtPhiBQuality = cms.int32(4)
0267 
0268 process.simOmtfDigis.dtRefHitMinQuality =  cms.int32(4)
0269 
0270 #process.simOmtfDigis.usePhiBExtrapolationFromMB1 = cms.bool(True)
0271 #process.simOmtfDigis.usePhiBExtrapolationFromMB2 = cms.bool(True)
0272 process.simOmtfDigis.usePhiBExtrapolationFromMB1 = cms.bool(False)
0273 process.simOmtfDigis.usePhiBExtrapolationFromMB2 = cms.bool(False)
0274 
0275 process.simOmtfDigis.useStubQualInExtr  = cms.bool(True)
0276 process.simOmtfDigis.useEndcapStubsRInExtr  = cms.bool(True)
0277 process.simOmtfDigis.useFloatingPointExtrapolation  = cms.bool(True)
0278 #process.simOmtfDigis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_DTQualAndEtaValueP1Scale.xml")
0279 #process.simOmtfDigis.extrapolFactorsFilename = cms.FileInPath("ExtrapolationFactors_simple.xml")
0280 process.simOmtfDigis.extrapolFactorsFilename = cms.FileInPath("")
0281 
0282 process.simOmtfDigis.stubEtaEncoding = cms.string("valueP1Scale")  
0283 #process.simOmtfDigis.stubEtaEncoding = cms.string("bits")   
0284 
0285 process.simOmtfDigis.goldenPatternResultFinalizeFunction = cms.int32(3) ## is needed here , becasue it just counts the number of layers with a stub
0286 process.simOmtfDigis.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
0287 
0288 
0289 
0290 #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0291 #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0292 
0293 process.L1TMuonSeq = cms.Sequence( process.esProd          
0294                                    + process.simOmtfDigis 
0295                                    #+ process.dumpED
0296                                    #+ process.dumpES
0297 )
0298 
0299 process.L1TMuonPath = cms.Path(process.L1TMuonSeq)
0300 
0301 #process.out = cms.OutputModule("PoolOutputModule", 
0302 #   fileName = cms.untracked.string("l1tomtf_superprimitives1.root")
0303 #)
0304 
0305 #process.output_step = cms.EndPath(process.out)
0306 #process.schedule = cms.Schedule(process.L1TMuonPath)
0307 #process.schedule.extend([process.output_step])