Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:12:16

0001 #!/usr/bin/env python
0002 import sys
0003 
0004 """
0005 The parameters can be changed by adding commandline arguments of the form
0006 ::
0007 
0008     create_plots.py n=-1 pu=low
0009 
0010 or ::
0011 
0012     create_plots.py n=-1:wfile=foo.root
0013 
0014 The latter can be used to change parameters in crab.
0015 """
0016 
0017 n = 1
0018 legacy = False
0019 data = False
0020 debug = False
0021 
0022 do_digi = False
0023 do_reco = False
0024 
0025 aod = False
0026 raw = True
0027 reco = True
0028 reemul = True
0029 
0030 
0031 # Argument parsing
0032 # vvv
0033 
0034 if len(sys.argv) > 1 and sys.argv[1].endswith('.py'):
0035     sys.argv.pop(0)
0036 if len(sys.argv) == 2 and ':' in sys.argv[1]:
0037     argv = sys.argv[1].split(':')
0038 else:
0039     argv = sys.argv[1:]
0040 
0041 for arg in argv:
0042     (k, v) = map(str.strip, arg.split('='))
0043     if k not in globals():
0044         raise "Unknown argument '%s'!" % (k,)
0045     if isinstance(globals()[k], bool):
0046         globals()[k] = v.lower() in ('y', 'yes', 'true', 't', '1')
0047     elif isinstance(globals()[k], int):
0048         globals()[k] = int(v)
0049     else:
0050         globals()[k] = v
0051 
0052 
0053 mc = not data
0054 reemul = reemul or (mc and raw)
0055 
0056 import FWCore.ParameterSet.Config as cms
0057 
0058 process = cms.Process('L1UPGRADE')
0059 process.load('FWCore.MessageLogger.MessageLogger_cfi')
0060 if do_reco:
0061     process.MessageLogger.cerr.FwkReport.reportEvery = 1
0062 else:
0063     process.MessageLogger.cerr.FwkReport.reportEvery = 100
0064 process.MessageLogger.L1GtTrigReport=dict()
0065 
0066 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(n))
0067 
0068 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0069 process.GlobalTag.connect   = 'frontier://FrontierProd/CMS_COND_31X_GLOBALTAG'
0070 process.GlobalTag.pfnPrefix = cms.untracked.string('frontier://FrontierProd/')
0071 if data:
0072     process.GlobalTag.globaltag = cms.string('GR_P_V40::All')
0073 else:
0074     process.GlobalTag.globaltag = cms.string('POSTLS161_V12::All')
0075 
0076 process.load('Configuration.StandardSequences.GeometryExtended_cff')
0077 process.load('Configuration.StandardSequences.Services_cff')
0078 process.load('Configuration.StandardSequences.GeometryDB_cff')
0079 process.load('Configuration.StandardSequences.MagneticField_38T_cff')
0080 if mc:
0081     process.load('Configuration.StandardSequences.Reconstruction_cff')
0082 else:
0083     process.load('Configuration.StandardSequences.Reconstruction_Data_cff')
0084 
0085 if do_digi:
0086     process.load('Configuration.StandardSequences.Digi_cff')
0087     process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0088     process.load('HLTrigger.Configuration.HLT_GRun_cff')
0089     process.load('Configuration.StandardSequences.DigiToRaw_cff')
0090     process.load('Configuration.StandardSequences.L1Reco_cff')
0091     process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0092 
0093     process.digi = cms.Path(process.pdigi)
0094     process.l1sim = cms.Path(process.SimL1Emulator)
0095     process.d2raw = cms.Path(process.DigiToRaw)
0096     process.l1reco = cms.Path(process.L1Reco)
0097 if do_reco:
0098     process.GlobalTag.toGet = cms.VPSet(
0099             cms.PSet(record = cms.string('EcalSampleMaskRcd'),
0100                 tag = cms.string('EcalSampleMask_offline'),
0101                 # connect = cms.untracked.string('oracle://cms_orcoff_prep/CMS_COND_ECAL'),
0102                 connect = cms.untracked.string('frontier://FrontierPrep/CMS_COND_ECAL'),
0103                 )
0104             )
0105     process.GlobalTag.DBParameters.authenticationPath="/afs/cern.ch/cms/DB/conddb"
0106     process.ecalGlobalUncalibRecHit.kPoorRecoFlagEB = cms.bool(False)
0107     process.ecalGlobalUncalibRecHit.kPoorRecoFlagEE = cms.bool(False)
0108 
0109 if data:
0110     process.load('Configuration.StandardSequences.RawToDigi_Data_cff')
0111 else:
0112     process.load('Configuration.StandardSequences.RawToDigi_cff')
0113 
0114 process.raw2digi = cms.Path(process.RawToDigi)
0115 process.reco = cms.Path(process.reconstruction)
0116 
0117 process.load('SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff')
0118 
0119 
0120 # =====================
0121 
0122 
0123 process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
0124 if reemul:
0125     process.l1GtTrigReport.L1GtRecordInputTag = "simGtDigis"
0126 else:
0127     process.l1GtTrigReport.L1GtRecordInputTag = "gtDigis"
0128 process.l1GtTrigReport.PrintVerbosity = 1
0129 process.report = cms.Path(process.l1GtTrigReport)
0130 
0131 import HLTrigger.HLTfilters.triggerResultsFilter_cfi as hlt
0132 process.ZeroBiasAve = hlt.triggerResultsFilter.clone()
0133 process.ZeroBiasAve.triggerConditions = cms.vstring('L1_ZeroBias',)
0134 process.ZeroBiasAve.hltResults = cms.InputTag( "TriggerResults", "", "HLT" )
0135 process.ZeroBiasAve.l1tResults = cms.InputTag("gtDigis")
0136 process.ZeroBiasAve.throw = cms.bool( True )
0137 process.zerobias = cms.Path(process.ZeroBiasAve)
0138 
0139 if reemul:
0140     process.load('HLTrigger.Configuration.HLT_FULL_cff')
0141     process.load('Configuration.StandardSequences.SimL1Emulator_cff')
0142     process.load('EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi')
0143 
0144     import L1Trigger.Configuration.L1Trigger_custom
0145     process = L1Trigger.Configuration.L1Trigger_custom.customiseL1GtEmulatorFromRaw(process)
0146     process = L1Trigger.Configuration.L1Trigger_custom.customiseResetPrescalesAndMasks(process)
0147 
0148     import HLTrigger.Configuration.customizeHLTforL1Emulator
0149     process = HLTrigger.Configuration.customizeHLTforL1Emulator.switchToL1Emulator(
0150             process, False, 'minPt', 'minPt', False, True, False, True)
0151     process = HLTrigger.Configuration.customizeHLTforL1Emulator.switchToSimGtReEmulGctDigis(process)
0152     process.HcalTPGCoderULUT.LUTGenerationMode = cms.bool(True)
0153 
0154     process.unpacker = cms.Path(process.HLTL1UnpackerSequence)
0155     process.l1unpack = cms.Path(process.l1GtUnpack)
0156 
0157 process.load('L1Trigger.L1ExtraFromDigis.l1extraParticles_cff')
0158 # process.l1extraParticles.forwardJetSource = cms.InputTag('gctReEmulDigis', 'forJets')
0159 # process.l1extraParticles.centralJetSource = cms.InputTag('gctReEmulDigis', 'cenJets')
0160 # process.l1extraParticles.tauJetSource = cms.InputTag('gctReEmulDigis', 'tauJets')
0161 process.l1extra = cms.Path(process.l1extraParticles)
0162 
0163 process.dump = cms.EDAnalyzer("EventContentAnalyzer")
0164 process.pdump = cms.Path(process.dump)
0165 
0166 
0167 ### ES Prefer preferences
0168 
0169 #process.es_prefer_calotowerconstituentsmapbuilder = cms.ESPrefer("CaloTowerConstituentsMapBuilder","caloTowerConstituentsMapBuilder")
0170 process.es_prefer_trackerNumberingGeometry = cms.ESPrefer("TrackerGeometricDetESModule","trackerNumberingGeometryDB")
0171 #process.es_prefer_ttrhbwr = cms.ESPrefer("TkTransientTrackingRecHitBuilderESProducer","ttrhbwr")
0172 #process.es_prefer_ttrhbwor = cms.ESPrefer("TkTransientTrackingRecHitBuilderESProducer","ttrhbwor")
0173 
0174 process.schedule = cms.Schedule()
0175 
0176 
0177 ### Override the L1 menu
0178 outputFile = 'l1_nugun.root'
0179 dumpFile   = 'dumpedConfig.py'
0180 
0181 if legacy:
0182     process.load('L1TriggerConfig.L1GtConfigProducers.l1GtTriggerMenuXml_cfi')
0183     process.l1GtTriggerMenuXml.TriggerMenuLuminosity = 'startup'
0184     process.l1GtTriggerMenuXml.DefXmlFile = 'L1Menu_Collisions2012_v3_L1T_Scales_20101224_Imp0_0x102b.xml'
0185 
0186     process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMenuConfig_cff')
0187     process.es_prefer_l1GtParameters = cms.ESPrefer('L1GtTriggerMenuXmlProducer','l1GtTriggerMenuXml')
0188 else:
0189     process.load('L1Trigger.L1TGlobal.TriggerMenuXml_cfi')
0190     process.TriggerMenuXml.TriggerMenuLuminosity = 'startup'
0191     #process.TriggerMenuXml.DefXmlFile = 'L1_Example_Menu_2013.xml'
0192     process.TriggerMenuXml.DefXmlFile = 'L1Menu_Reference_2014.xml'
0193 
0194     process.load('L1Trigger.L1TGlobal.L1uGtTriggerMenuConfig_cff')
0195     process.es_prefer_l1GtParameters = cms.ESPrefer('l1t::TriggerMenuXmlProducer','TriggerMenuXml')
0196 
0197     outputFile = 'l1_nugun_newL1MenuParser.root'
0198     dumpFile   = 'dumpedConfig_newL1MenuParser.py'
0199 
0200 
0201 ### Useful for debugging (sometimes)
0202 #process.Tracer = cms.Service("Tracer")
0203 
0204 if do_digi:
0205     process.schedule.extend([process.digi, process.l1sim, process.d2raw])
0206 if raw or do_reco:
0207     process.schedule.append(process.raw2digi)
0208     process.schedule.append(process.l1extra)
0209 if data:
0210     process.schedule.append(process.zerobias)
0211 if do_digi:
0212     process.schedule.append(process.l1reco)
0213 if reemul:
0214     process.schedule.append(process.unpacker)
0215     process.schedule.append(process.l1unpack)
0216 if debug:
0217     process.schedule.append(process.pdump)
0218 if do_reco:
0219     process.schedule.append(process.reco)
0220 
0221 if raw:
0222     process.schedule.append(process.report)
0223 
0224 
0225 
0226 readFiles = cms.untracked.vstring()
0227 secFiles = cms.untracked.vstring()
0228 process.source = cms.Source ("PoolSource",
0229                              fileNames = readFiles,
0230                              secondaryFileNames = secFiles
0231                              )
0232 
0233 readFiles.extend( [
0234     "/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_3A11157B-ED51-E311-BA75-003048679080.root",
0235     #"/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_1A20137C-E651-E311-A9C6-00304867BFAA.root",
0236     #"/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_2EFD8C7A-E651-E311-8C92-002354EF3BE3.root"
0237     #'/store/user/puigh/Neutrino_Pt2to20_gun_UpgradeL1TDR-PU50_POSTLS161_V12-v1_A4FFBC76-5B39-E211-999D-0030487F1BE5.root',
0238     ##'root://xrootd.unl.edu//store/mc/Summer12/Neutrino_Pt2to20_gun/GEN-SIM-DIGI-RAW/UpgradeL1TDR-PU50_POSTLS161_V12-v1/00000/002EF512-2A39-E211-9B80-0030487F1A47.root',
0239     ##'/store/mc/Summer12/Neutrino_Pt2to20_gun/GEN-SIM-DIGI-RAW/UpgradeL1TDR-PU50_POSTLS161_V12-v1/00000/002EF512-2A39-E211-9B80-0030487F1A47.root',
0240         ] )
0241 
0242 
0243 process.output = cms.OutputModule( "PoolOutputModule"
0244                                 , fileName       = cms.untracked.string( 'delete.root' )
0245                                 , SelectEvents   = cms.untracked.PSet( SelectEvents = cms.vstring([]) )
0246                                 , outputCommands = cms.untracked.vstring( 'keep *'
0247                                         )
0248                                 )
0249 process.output.fileName = outputFile
0250 
0251 process.options = cms.untracked.PSet()
0252 
0253 process.outpath = cms.EndPath(process.output)
0254 
0255 #process.schedule.append(process.outpath)
0256 
0257 # Spit out filter efficiency at the end.
0258 process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True))
0259 
0260 #outfile = open(dumpFile,'w')
0261 #print >> outfile,process.dumpPython()
0262 #outfile.close()