Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-27 04:18:05

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 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0011 
0012 verbose = True
0013 
0014 dumpHitsFileName = 'OMTFHits_pats0x00031_newerSample_files_1_100' #'OMTFHits_pats0x00031_newerSample_files_1_100' OMTFHits_pats0x0003_oldSample_files_30_40
0015 
0016 if verbose: 
0017     process.MessageLogger = cms.Service("MessageLogger",
0018        #suppressInfo       = cms.untracked.vstring('AfterSource', 'PostModule'),
0019        destinations   = cms.untracked.vstring(
0020                                                #'detailedInfo',
0021                                                #'critical',
0022                                                #'cout',
0023                                                #'cerr',
0024                                                'omtfEventPrint'
0025                     ),
0026        categories        = cms.untracked.vstring('l1tOmtfEventPrint', 'OMTFReconstruction'),
0027        omtfEventPrint = cms.untracked.PSet(    
0028                          filename  = cms.untracked.string('log_' + dumpHitsFileName),
0029                          extension = cms.untracked.string('.txt'),                
0030                          threshold = cms.untracked.string('DEBUG'),
0031                          default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), 
0032                          #INFO   =  cms.untracked.int32(0),
0033                          #DEBUG   = cms.untracked.int32(0),
0034                          l1tOmtfEventPrint = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) ),
0035                          OMTFReconstruction = cms.untracked.PSet( limit = cms.untracked.int32(1000000000) )
0036                        ),
0037        debugModules = cms.untracked.vstring('simOmtfDigis') 
0038        #debugModules = cms.untracked.vstring('*')
0039     )
0040 
0041     #process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(100)
0042 if not verbose:
0043     process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(-1)
0044     process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(False), 
0045                                          #SkipEvent = cms.untracked.vstring('ProductNotFound') 
0046                                      )
0047 # import of standard configurations
0048 process.load('Configuration.StandardSequences.Services_cff')
0049 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0050 process.load('Configuration.EventContent.EventContent_cff')
0051 process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0052 process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff')
0053 process.load('Configuration.Geometry.GeometryExtended2023D41_cff')
0054 process.load('Configuration.StandardSequences.MagneticField_cff')
0055 #process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0056 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0057 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0058 
0059 from Configuration.AlCa.GlobalTag import GlobalTag
0060 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')
0061 process.GlobalTag = GlobalTag(process.GlobalTag, '103X_upgrade2023_realistic_v2', '') 
0062 
0063 #path = '/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/' #old sample, but very big
0064 path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v2/' #new sample, but small and more noisy
0065 #path = '/eos/user/a/akalinow/Data/SingleMu/9_3_14_FullEta_v1/'
0066 
0067 #path = '/afs/cern.ch/work/a/akalinow/public/MuCorrelator/Data/SingleMu/9_3_14_FullEta_v1/'
0068 #path = '/afs/cern.ch/work/k/kbunkow/public/data/SingleMuFullEta/721_FullEta_v4/'
0069 
0070 onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
0071 #print onlyfiles
0072 
0073 filesNameLike = sys.argv[2]
0074 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_p_10_' in f) or ('_m_10_' in f))]
0075 #chosenFiles = ['file://' + path + f for f in onlyfiles if (('_10_p_10_' in f))]
0076 #chosenFiles = ['file://' + path + f for f in onlyfiles if (re.match('.*_._p_10.*', f))]
0077 #chosenFiles = ['file://' + path + f for f in onlyfiles if ((filesNameLike in f))]
0078 
0079 #print onlyfiles
0080 
0081 chosenFiles = []
0082 
0083 filesPerPtBin = 100 #TODO max is 200 for the 721_FullEta_v4 and 100 for 9_3_14_FullEta_v2
0084 
0085 if filesNameLike == 'allPt' :
0086     for ptCode in range(31, 3, -1) :
0087         for sign in ['_m', '_p'] : #, m
0088             selFilesPerPtBin = 0
0089             for i in range(1, 201, 1): #TODO
0090                 for f in onlyfiles:
0091                    #if (( '_' + str(ptCode) + sign + '_' + str(i) + '_') in f): #TODO for 721_FullEta_v4/
0092                    if (( '_' + str(ptCode) + sign + '_' + str(i) + ".") in f):  #TODO for 9_3_14_FullEta_v2
0093                         #print f
0094                         chosenFiles.append('file://' + path + f) 
0095                         selFilesPerPtBin += 1
0096                 if(selFilesPerPtBin >= filesPerPtBin):
0097                     break
0098                         
0099 else :
0100     for i in range(1, filesPerPtBin+1, 1):
0101         for f in onlyfiles:
0102             if (( filesNameLike + '_' + str(i) + '_') in f):  #TODO for 721_FullEta_v4/
0103             #if (( filesNameLike + '_' + str(i) + '.') in f): #TODO for 9_3_14_FullEta_v2
0104                 print f
0105                 chosenFiles.append('file://' + path + f) 
0106          
0107 
0108 print "chosenFiles"
0109 for chFile in chosenFiles:
0110     print chFile
0111 
0112 if len(chosenFiles) == 0 :
0113     print "no files selected!!!!!!!!!!!!!!!"
0114     exit
0115 
0116 firstEv = 0#40000
0117 #nEvents = 1000
0118 
0119 # input files (up to 255 files accepted)
0120 process.source = cms.Source('PoolSource',
0121 fileNames = cms.untracked.vstring( 
0122     #'file:/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/SingleMu_16_p_1_1_xTE.root',
0123     #'file:/afs/cern.ch/user/k/kpijanow/Neutrino_Pt-2to20_gun_50.root',
0124     list(chosenFiles),
0125                                   ),
0126 # eventsToProcess = cms.untracked.VEventRange(
0127 #  '3:' + str(firstEv) + '-3:' +   str(firstEv + nEvents),
0128 #  '4:' + str(firstEv) + '-4:' +   str(firstEv + nEvents),
0129 #  '5:' + str(firstEv) + '-5:' +   str(firstEv + nEvents),
0130 #  '6:' + str(firstEv) + '-6:' +   str(firstEv + nEvents),
0131 #  '7:' + str(firstEv) + '-7:' +   str(firstEv + nEvents),
0132 #  '8:' + str(firstEv) + '-8:' +   str(firstEv + nEvents),
0133 #  '9:' + str(firstEv) + '-9:' +   str(firstEv + nEvents),
0134 # '10:' + str(firstEv) + '-10:' +  str(firstEv + nEvents),
0135 # '11:' + str(firstEv) + '-11:' +  str(firstEv + nEvents),
0136 # '12:' + str(firstEv) + '-12:' +  str(firstEv + nEvents),
0137 # '13:' + str(firstEv) + '-13:' +  str(firstEv + nEvents),
0138 # '14:' + str(firstEv) + '-14:' +  str(firstEv + nEvents),
0139 # '15:' + str(firstEv) + '-15:' +  str(firstEv + nEvents),
0140 # '16:' + str(firstEv) + '-16:' +  str(firstEv + nEvents),
0141 # '17:' + str(firstEv) + '-17:' +  str(firstEv + nEvents),
0142 # '18:' + str(firstEv) + '-18:' +  str(firstEv + nEvents),
0143 # '19:' + str(firstEv) + '-19:' +  str(firstEv + nEvents),
0144 # '20:' + str(firstEv) + '-20:' +  str(firstEv + nEvents),
0145 # '21:' + str(firstEv) + '-21:' +  str(firstEv + nEvents),
0146 # '22:' + str(firstEv) + '-22:' +  str(firstEv + nEvents),
0147 # '23:' + str(firstEv) + '-23:' +  str(firstEv + nEvents),
0148 # '24:' + str(firstEv) + '-24:' +  str(firstEv + nEvents),
0149 # '25:' + str(firstEv) + '-25:' +  str(firstEv + nEvents),
0150 # '26:' + str(firstEv) + '-26:' +  str(firstEv + nEvents),
0151 # '27:' + str(firstEv) + '-27:' +  str(firstEv + nEvents),
0152 # '28:' + str(firstEv) + '-28:' +  str(firstEv + nEvents),
0153 # '29:' + str(firstEv) + '-29:' +  str(firstEv + nEvents),
0154 # '30:' + str(firstEv) + '-30:' +  str(firstEv + nEvents),
0155 # '31:' + str(firstEv) + '-31:' +  str(firstEv + nEvents)),
0156 skipEvents =  cms.untracked.uint32(0),
0157 
0158         inputCommands=cms.untracked.vstring(
0159         'keep *',
0160         'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT',
0161         'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT',
0162         'drop l1tEMTFHit2016s_simEmtfDigis__HLT',
0163         'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT',
0164         'drop l1tEMTFTrack2016s_simEmtfDigis__HLT')
0165 )
0166 
0167                         
0168 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1))
0169 
0170 
0171 ####Event Setup Producer
0172 process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff')
0173 process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter",
0174    toGet = cms.VPSet(
0175       cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'),
0176                data = cms.vstring('L1TMuonOverlapParams'))
0177                    ),
0178    verbose = cms.untracked.bool(False)
0179 )
0180 
0181 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) )
0182                                    
0183 ####OMTF Emulator
0184 process.load('L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi')
0185 
0186 process.simOmtfDigis.bxMin = cms.int32(0)
0187 process.simOmtfDigis.bxMax = cms.int32(0)
0188 
0189 process.simOmtfDigis.dumpResultToXML = cms.bool(False)
0190 process.simOmtfDigis.dumpResultToROOT = cms.bool(False)
0191 process.simOmtfDigis.dumpHitsToROOT = cms.bool(True)
0192 process.simOmtfDigis.dumpHitsFileName = cms.string(dumpHitsFileName + '.root')
0193 process.simOmtfDigis.eventCaptureDebug = cms.bool(False)
0194 
0195 process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0003.xml")
0196 #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x00031_oldSample_10Files.xml")
0197 #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0006_2_oldSample_10Files.xml") #TODO!!!!!!!!!!!!
0198 
0199 #process.simOmtfDigis.gpResultsToPtFile = cms.string("gpResultsToPt_Patterns_0x00031.txt") 
0200 
0201 #process.simOmtfDigis.patternType = cms.string("GoldenPatternWithStat")
0202 process.simOmtfDigis.generatePatterns = cms.bool(False)
0203 #process.simOmtfDigis.optimisedPatsXmlFile = cms.string("Patterns_0x0005_1.xml")
0204 
0205 process.simOmtfDigis.rpcMaxClusterSize = cms.int32(3)
0206 process.simOmtfDigis.rpcMaxClusterCnt = cms.int32(2)
0207 process.simOmtfDigis.rpcDropAllClustersIfMoreThanMax = cms.bool(True)
0208 
0209 process.simOmtfDigis.goldenPatternResultFinalizeFunction = cms.int32(5) #valid values are 0, 1, 2, 3, 5
0210 #process.simOmtfDigis.sorterType = cms.string("byLLH") #TODO
0211 
0212 process.simOmtfDigis.lctCentralBx = cms.int32(6);#<<<<<<<<<<<<<<<<!!!!!!!!!!!!!!!!!!!!TODO this was changed in CMSSW 10(?) to 8. if the data were generated with the previous CMSSW then you have to use 6
0213 
0214 
0215 #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0216 #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0217 
0218 process.L1TMuonSeq = cms.Sequence( process.esProd          
0219                                    + process.simOmtfDigis 
0220                                    #+ process.dumpED
0221                                    #+ process.dumpES
0222 )
0223 
0224 process.L1TMuonPath = cms.Path(process.L1TMuonSeq)
0225 
0226 #process.out = cms.OutputModule("PoolOutputModule", 
0227 #   fileName = cms.untracked.string("l1tomtf_superprimitives1.root")
0228 #)
0229 
0230 #process.output_step = cms.EndPath(process.out)
0231 #process.schedule = cms.Schedule(process.L1TMuonPath)
0232 #process.schedule.extend([process.output_step])