Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:37

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