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('Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2'),
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 = 1 #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, 3, -1) :
0085         if ptCode <= 7 :
0086             filesPerPtBin = 10
0087         elif ptCode <= 12 :
0088             filesPerPtBin = 5
0089         else :    
0090             filesPerPtBin = 3
0091             
0092         for sign in ['_m', '_p'] : #, m
0093             selFilesPerPtBin = 0
0094             for i in range(1, 201, 1): #TODO
0095                 for f in onlyfiles:
0096                    if (( '_' + str(ptCode) + sign + '_' + str(i) + '_') in f): #TODO for 721_FullEta_v4/
0097                    #if (( '_' + str(ptCode) + sign + '_' + str(i) + ".") in f):  #TODO for 9_3_14_FullEta_v2
0098                         #print f
0099                         chosenFiles.append('file://' + path + f) 
0100                         selFilesPerPtBin += 1
0101                 if(selFilesPerPtBin >= filesPerPtBin):
0102                     break
0103                         
0104 else :
0105     for i in range(1, 2, 1):
0106         for f in onlyfiles:
0107             if (( filesNameLike + '_' + str(i) + '_') in f):  #TODO for 721_FullEta_v4/
0108             #if (( filesNameLike + '_' + str(i) + '.') in f): #TODO for 9_3_14_FullEta_v2
0109                 print f
0110                 chosenFiles.append('file://' + path + f) 
0111          
0112 
0113 print "chosenFiles"
0114 for chFile in chosenFiles:
0115     print chFile
0116 
0117 if len(chosenFiles) == 0 :
0118     print "no files selected!!!!!!!!!!!!!!!"
0119     exit
0120 
0121 firstEv = 0#40000
0122 #nEvents = 1000
0123 
0124 # input files (up to 255 files accepted)
0125 process.source = cms.Source('PoolSource',
0126 fileNames = cms.untracked.vstring( 
0127     #'file:/eos/user/k/kbunkow/cms_data/SingleMuFullEta/721_FullEta_v4/SingleMu_16_p_1_1_xTE.root',
0128     #'file:/afs/cern.ch/user/k/kpijanow/Neutrino_Pt-2to20_gun_50.root',
0129     list(chosenFiles), ),
0130     skipEvents =  cms.untracked.uint32(0),
0131     inputCommands=cms.untracked.vstring(
0132         'keep *',
0133         'drop l1tEMTFHit2016Extras_simEmtfDigis_CSC_HLT',
0134         'drop l1tEMTFHit2016Extras_simEmtfDigis_RPC_HLT',
0135         'drop l1tEMTFHit2016s_simEmtfDigis__HLT',
0136         'drop l1tEMTFTrack2016Extras_simEmtfDigis__HLT',
0137         'drop l1tEMTFTrack2016s_simEmtfDigis__HLT')
0138 )
0139                         
0140 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1))
0141 
0142 
0143 ####Event Setup Producer
0144 process.load('L1Trigger.L1TMuonOverlapPhase1.fakeOmtfParams_cff')
0145 #process.omtfParams.configXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/hwToLogicLayer_0x0008_patGen.xml"),
0146 
0147 process.esProd = cms.EDAnalyzer("EventSetupRecordDataGetter",
0148    toGet = cms.VPSet(
0149       cms.PSet(record = cms.string('L1TMuonOverlapParamsRcd'),
0150                data = cms.vstring('L1TMuonOverlapParams'))
0151                    ),
0152    verbose = cms.untracked.bool(False)
0153 )
0154 
0155 #process.TFileService = cms.Service("TFileService", fileName = cms.string('omtfAnalysis1_1.root'), closeFileFast = cms.untracked.bool(True) )
0156                                    
0157 ####OMTF Emulator
0158 process.load('L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi')
0159 
0160 process.simOmtfDigis.bxMin = cms.int32(0)
0161 process.simOmtfDigis.bxMax = cms.int32(0)
0162 
0163 process.simOmtfDigis.dumpResultToXML = cms.bool(False)
0164 process.simOmtfDigis.dumpResultToROOT = cms.bool(False)
0165 process.simOmtfDigis.eventCaptureDebug = cms.bool(False)
0166 
0167 process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_template.xml")
0168 #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb1_recalib.xml")
0169 #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00012_oldSample_3_30Files_grouped1_classProb11_recalib2.xml")
0170 #process.simOmtfDigis.patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/Patterns_0x0009_oldSample_3_10Files_classProb2.xml")
0171 #process.simOmtfDigis.patternsXMLFiles = cms.VPSet(cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_plus_v1.xml")),
0172 #                                                       cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuon/data/omtf_config/GPs_parametrised_minus_v1.xml"))  )
0173 
0174 #process.simOmtfDigis.patternsXMLFiles = cms.VPSet(#cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/PatternsDisplaced_0x0007_minus.xml")),
0175 #                                                        cms.PSet(patternsXMLFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/PatternsDisplaced_0x0007_plus.xml"))  
0176 #                                                        )
0177 
0178 
0179 #process.simOmtfDigis.patternGenerator = cms.string("modifyClassProb")
0180 #process.simOmtfDigis.patternGenerator = cms.string("groupPatterns")
0181 process.simOmtfDigis.patternGenerator = cms.string("patternGenFromStat")
0182 #process.simOmtfDigis.patternGenerator = cms.string("") #does nothing except storing the patterns in the root file
0183 process.simOmtfDigis.patternsROOTFile = cms.FileInPath("L1Trigger/L1TMuonOverlapPhase1/test/expert/omtf/Patterns_0x00011_oldSample_3_30Files_layerStat.root")
0184 
0185 process.simOmtfDigis.patternType = cms.string("GoldenPatternWithStat")
0186 process.simOmtfDigis.generatePatterns = cms.bool(True)
0187 #process.simOmtfDigis.optimisedPatsXmlFile = cms.string("Patterns_0x0009_oldSample_3_10Files_classProb3.xml")
0188 process.simOmtfDigis.optimisedPatsXmlFile = cms.string("Patterns_0x00012_oldSample_3_30Files_grouped1_classProb17_recalib2.xml")
0189 #process.simOmtfDigis.optimisedPatsXmlFile = cms.string("PatternsDisplaced_0x0007_p.xml")
0190 
0191 process.simOmtfDigis.rpcMaxClusterSize = cms.int32(3)
0192 process.simOmtfDigis.rpcMaxClusterCnt = cms.int32(2)
0193 process.simOmtfDigis.rpcDropAllClustersIfMoreThanMax = cms.bool(True)
0194 
0195 process.simOmtfDigis.goldenPatternResultFinalizeFunction = cms.int32(3) #valid values are 0, 1, 2, 3, 5
0196 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
0197 
0198 
0199 #process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0200 #process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0201 
0202 process.L1TMuonSeq = cms.Sequence( process.esProd          
0203                                    + process.simOmtfDigis 
0204                                    #+ process.dumpED
0205                                    #+ process.dumpES
0206 )
0207 
0208 process.L1TMuonPath = cms.Path(process.L1TMuonSeq)
0209 
0210 #process.out = cms.OutputModule("PoolOutputModule", 
0211 #   fileName = cms.untracked.string("l1tomtf_superprimitives1.root")
0212 #)
0213 
0214 #process.output_step = cms.EndPath(process.out)
0215 #process.schedule = cms.Schedule(process.L1TMuonPath)
0216 #process.schedule.extend([process.output_step])