## example cfg to dump HCAL conditions from the database
## (can be also used to dump sqlite content or to test fake conditions reading in CMSSW)
## Radek Ofierzynski, 9.11.2008
##
## Gena Kukartsev, July 29, 2009
## Gena Kukartsev, September 21, 2009

import FWCore.ParameterSet.Config as cms

process = cms.Process("DUMP")

process.load("CondCore.DBCommon.CondDBSetup_cfi")

## specify which conditions you would like to dump to a text file in the "dump" vstring
process.prod = cms.EDAnalyzer("HcalDumpConditions",
    dump = cms.untracked.vstring(
#        'Pedestals',
#        'PedestalWidths',
#        'Gains',
#        'GainWidths', 
#        'QIEData',
#        'QIETypes',
#        'ElectronicsMap',
#        'ChannelQuality' ,
#        'RespCorrs', 
#        'TimeCorrs',
#        'LUTCorrs',
#        'PFCorrs',
#        'L1TriggerObjects',
#        'ZSThresholds',
#        'ValidationCorrs',
#        'LutMetadata',
#        'DcsValues',
#        'DcsMap',
#        'TimingParams',
         'SiPMParameters',
#         'SiPMCharacteristics',
#    'RecoParams',
#    'LongRecoParams',
#    'MCParams',
#    'FlagHFDigiTimeParams',
        ),
    outFilePrefix = cms.untracked.string('DumpCond')
)

## specify for which run you would like to get the conditions in the "firstRun"
process.source = cms.Source("EmptySource",
    numberEventsInRun = cms.untracked.uint32(1),
    firstRun = cms.untracked.uint32(1)
)

process.load('Configuration.Geometry.GeometryExtended2017dev_cff')
process.load('Configuration.Geometry.GeometryExtended2017devReco_cff')
#process.load('Configuration.Geometry.GeometrySimDB_cff')
#process.load('Configuration.Geometry.GeometryRecoDB_cff')
#process.load("Geometry.HcalCommonData.testPhase0GeometryXML_cfi")
#process.load("Geometry.HcalCommonData.hcalDDConstants_cff")
#process.load("Geometry.HcalEventSetup.hcalTopologyIdeal_cfi")
process.load('Configuration.StandardSequences.Services_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')
from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
#process.GlobalTag = GlobalTag(process.GlobalTag, '81X_upgrade2017_HCALdev_v3', '')
#process.GlobalTag = GlobalTag(process.GlobalTag, '81X_mcRun2_asymptotic_v9', '')
process.GlobalTag = GlobalTag(process.GlobalTag, '81X_upgrade2017_realistic_v18', '')


## specify which conditions should be taken for input, 
## you can mix different es_sources as long as it's unique for each object
process.es_pool = cms.ESSource(
     "PoolDBESSource",
     process.CondDBSetup,
     timetype = cms.string('runnumber'),
#     connect = cms.string('frontier://FrontierDev/CMS_COND_HCAL'),
     connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS'),
     authenticationMethod = cms.untracked.uint32(0),
     toGet = cms.VPSet(
          cms.PSet(
              record = cms.string('HcalSiPMParametersRcd'),
              tag = cms.string('HcalSiPMParameters_2017_v2.0_mc')
          ),
#         cms.PSet(
#             record = cms.string('HcalPedestalsRcd'),
#             tag = cms.string('hcal_pedestals_fC_v3_mc')
#             ), 
#         cms.PSet(
#             record = cms.string('HcalPedestalWidthsRcd'),
#             tag = cms.string('hcal_widths_fC_v3_mc')
#             ), 
#         cms.PSet(
#             record = cms.string('HcalGainsRcd'),
#             tag = cms.string('hcal_gains_v2_physics_50_mc')
#             ), 
#         cms.PSet(
#             record = cms.string('HcalQIEDataRcd'),
#             tag = cms.string('HcalQIEData_2017_v2.0_mc')
#             ), 
#         cms.PSet(
#             record = cms.string('HcalElectronicsMapRcd'),
#             tag = cms.string('official_emap_v5_080208_mc')
#             ),
#         cms.PSet(
#             record = cms.string('HcalLutMetadataRcd'),
#             tag = cms.string('hcal_lutmetadata_trivial_v1.01_mc')
#         ) 
#         cms.PSet(
#             record = cms.string('HcalDcsMapRcd'),
#             tag = cms.string('HcalDcsMap_v1.00_test')
#         ) 
         )
 )
process.es_prefer_HcalQIEData = cms.ESPrefer("PoolDBESSource", "es_pool")

#process.es_hardcode = cms.ESSource("HcalHardcodeCalibrations",
#     toGet = cms.untracked.vstring(
#        'Pedestals'
#        ,'PedestalWidths' 
#        ,'Gains' 
#        ,'QIEData' 
#        ,'ElectronicsMap'
#        ,'ChannelQuality' 
#        ,'GainWidths' 
#        ,'RespCorrs' 
#        ,'TimeCorrs'
#        ,'LUTCorrs'
#        ,'PFCorrs'
#        ,'L1TriggerObjects'
#        ,'ZSThresholds'
#        ,'ValidationCorrs' 
#        ,'LutMetadata'
#        ,'DcsValues'
#        ,'DcsMap'
#        'TimingParams'
#        ,'RecoParams'
#        ,'LongRecoParams'
#        ,'MCParams'
#        ,'FlagHFDigiTimeParams'        
#        )
# )

process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(1)
)
process.p = cms.Path(process.prod)


