Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:25

0001 import shlex, shutil, getpass
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 
0005 process = cms.Process("ProcessOne")
0006 
0007 options = VarParsing.VarParsing("analysis")
0008 options.register ('firstRun',
0009                   325170,
0010                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0011                   VarParsing.VarParsing.varType.int,            # string, int, or float
0012                   "first run to be processed")
0013 options.register ('nLSToProcessPerRun',
0014                   2000,
0015                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0016                   VarParsing.VarParsing.varType.int,            # string, int, or float
0017                   "number of lumisections to process per run")
0018 options.register ('nRunsToProcess',
0019                   1,
0020                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0021                   VarParsing.VarParsing.varType.int,            # string, int, or float
0022                   "total number of Runs to process")
0023 options.register ('inputLumiFile',
0024                   '/eos/cms/store/group/comm_luminosity/LumiProducerFromBrilcalc/LumiData_2018_20200401.csv',
0025                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0026                   VarParsing.VarParsing.varType.string,         # string, int, or float
0027                   "input luminosity file")
0028 
0029 options.parseArguments()
0030 
0031 ##
0032 ## MessageLogger
0033 ##
0034 process.load('FWCore.MessageService.MessageLogger_cfi')   
0035 process.MessageLogger.cerr.enable = False
0036 process.MessageLogger.SiPixelQualityPlotter =dict()  
0037 process.MessageLogger.cout = cms.untracked.PSet(
0038     enable = cms.untracked.bool(True),
0039     threshold = cms.untracked.string("INFO"),
0040     default   = cms.untracked.PSet(limit = cms.untracked.int32(0)),                       
0041     FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
0042                                    reportEvery = cms.untracked.int32(1000)
0043                                    ),                                                      
0044     SiPixelQualityPlotter           = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0045     enableStatistics = cms.untracked.bool(True)
0046     )
0047 
0048 ##
0049 ## Empty source
0050 ##
0051 process.source = cms.Source("EmptySource",
0052                             firstRun = cms.untracked.uint32(options.firstRun),
0053                             numberEventsInRun    = cms.untracked.uint32(options.nLSToProcessPerRun),
0054                             firstLuminosityBlock = cms.untracked.uint32(84),
0055                             numberEventsInLuminosityBlock = cms.untracked.uint32(1),
0056                             )
0057 
0058 maxEventsToProcess = (options.nRunsToProcess*options.nLSToProcessPerRun) + 1       # the +1 is needed in order to fall on the next run (outside of the range selected and close the last IOV
0059 maxRunsToProcess = (options.firstRun+options.nRunsToProcess)-1
0060 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(maxEventsToProcess))
0061 
0062 ## 
0063 ## Now do some printing
0064 ##
0065 
0066 print("===============================================")
0067 print(" First run to be processed: ",options.firstRun)
0068 print(" Last  run to be processed: ",maxRunsToProcess)
0069 print(" n. LS process per Run: ",options.nLSToProcessPerRun)
0070 print(" Total LS to process: ",maxEventsToProcess)
0071 print(" Using Luminosity file: ",options.inputLumiFile)
0072 print("===============================================")
0073 
0074 ##
0075 ## TrackerTopology
0076 ##
0077 process.load("Configuration.Geometry.GeometryExtended2017_cff")         # loads the Phase-1 topology
0078 process.load("Geometry.TrackerGeometryBuilder.trackerParameters_cfi")
0079 process.TrackerTopologyEP = cms.ESProducer("TrackerTopologyEP")
0080 
0081 ##
0082 ## Database output service
0083 ##
0084 process.load("CondCore.CondDB.CondDB_cfi")
0085 
0086 # DB input service: 
0087 process.CondDB.connect = "frontier://FrontierProd/CMS_CONDITIONS"
0088 process.dbInput = cms.ESSource("PoolDBESSource",
0089                                process.CondDB,
0090                                toGet = cms.VPSet(cms.PSet(record = cms.string("SiPixelQualityFromDbRcd"),
0091                                                           #tag = cms.string("SiPixelQuality_byPCL_stuckTBM_v1") ## FED25
0092                                                           tag = cms.string("SiPixelQuality_byPCL_prompt_v2")  ## Prompt
0093                                                           #tag = cms.string("SiPixelQuality_v07_offline")      ## Re-Reco
0094                                                           )
0095                                                  )
0096                                )
0097 ##
0098 ## Clean old files
0099 ##
0100 chosenTag=process.dbInput.toGet[0].tag.value()
0101 try:
0102     shutil.move("SummaryBarrel_"+chosenTag+".png", "SummaryBarrel_"+chosenTag+"_old.png")
0103     shutil.move("SummaryForward_"+chosenTag+".png", "SummaryForward_"+chosenTag+"_old.png")
0104 except:
0105     print("No old files to be moved")
0106 
0107 ##
0108 ## The analysis module
0109 ##
0110 process.ReadInDB = cms.EDAnalyzer("SiPixelQualityPlotter",
0111                                   analyzedTag = cms.string(chosenTag),
0112                                   maxRun = cms.untracked.uint32(maxRunsToProcess),
0113                                   lumiInputTag = cms.untracked.InputTag("LumiInfo", "brilcalc")
0114                                   )
0115 
0116 ##
0117 ## The lumi information
0118 ##
0119 process.LumiInfo = cms.EDProducer('LumiProducerFromBrilcalc',
0120                                   lumiFile = cms.string(options.inputLumiFile),
0121                                   throwIfNotFound = cms.bool(False),
0122                                   doBunchByBunch = cms.bool(False))
0123 
0124 ##
0125 ## The path
0126 ##
0127 process.p = cms.Path(process.LumiInfo*process.ReadInDB)