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