diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBuildBadChannelDB.sh b/LArCalorimeter/LArBadChannelTool/share/LArBuildBadChannelDB.sh index 180b39b0c6abf717bc35c90e6b8b405bf62d230a..f1dddc4cf7c45fecf9c3401ba9896415f93daaab 100755 --- a/LArCalorimeter/LArBadChannelTool/share/LArBuildBadChannelDB.sh +++ b/LArCalorimeter/LArBadChannelTool/share/LArBuildBadChannelDB.sh @@ -353,7 +353,7 @@ cat $summaryFile echo "Output sqlite files:" echo "$outputSqlite: Containing UPD1 and/or UPD4 and/or Bulk version of bad-channel list for OFFLINE DB. UPD4 valid as of run $runnumber" echo "Upload to OFFLINE oracle server:" -echo "/afs/cern.ch/user/a/atlcond/utilsflask/AtlCoolMerge.py --flask ${outputSqlite} CONDBR2 ATONR_GPN ATLAS_COOLOFL_LAR_W " +echo "/afs/cern.ch/user/a/atlcond/utilsflask/AtlCoolMerge.py --flask ${outputSqlite} CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_LAR_W " if [ -f $outputSqliteOnl ]; then echo "$outputSqliteOnl: Containing UPD1 version of bad-channel list for ONLINE DB." diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBuildMissingFebDB.sh b/LArCalorimeter/LArBadChannelTool/share/LArBuildMissingFebDB.sh index 69152a683fc8f3104a96b8ae1662a2cf1eb817c0..5cd299114ca81808576977acea42a89f8310fa51 100755 --- a/LArCalorimeter/LArBadChannelTool/share/LArBuildMissingFebDB.sh +++ b/LArCalorimeter/LArBadChannelTool/share/LArBuildMissingFebDB.sh @@ -263,7 +263,7 @@ echo "$outputTextFile: Text version of the new bad channel list (read back from echo "" echo "Upload to OFFLINE oracle server using" -echo "/afs/cern.ch/user/a/atlcond/utilsflask/AtlCoolMerge.py --flask ${outputSqlite} CONDBR2 ATONR_GPN ATLAS_COOLOFL_LAR_W " +echo "/afs/cern.ch/user/a/atlcond/utilsflask/AtlCoolMerge.py --flask ${outputSqlite} CONDBR2 ATONR_COOL_GPN ATLAS_COOLOFL_LAR_W " echo "" if [ $online -eq 1 ]; then echo "Upload to ONLINE oracle server using" diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h index 0d1bb9954c4131e03f1fcd6eb4a59df8a962054c..bcfa032e890778efcca7bab2ac5d7c38c633ad20 100644 --- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h +++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h @@ -15,6 +15,11 @@ #define LARAVERAGES2NTUPLE_H #include "LArCalibTools/LArCond2NtupleBase.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "LArIdentifier/LArOnlineID.h" +#include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArCalibLineMapping.h" + #include #include #include @@ -30,9 +35,17 @@ class LArAverages2Ntuple : public LArCond2NtupleBase StatusCode initialize(); StatusCode execute() ; StatusCode finalize(){return StatusCode::SUCCESS;} + private: + const LArEM_Base_ID* m_emId; + const LArOnlineID_Base* m_onlineHelper; + + SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_calibMapKey{this,"CalibMapKey","LArCalibLineMap","SG Key of calib line mapping object"}; + std::string m_ntName; std::string m_contKey; + std::vector m_keepFT; unsigned int m_Nsamples; bool m_keepPulsed; diff --git a/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py index 13f362c4ba603313e0bf01f3413b96b89bce8540..9b62d9f5621e61050494ac12edd6b92b5701294f 100755 --- a/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py +++ b/LArCalorimeter/LArCalibTools/share/LArAverages2Ntuple_jobOptions.py @@ -1,37 +1,237 @@ -# ******************************************************************* -# JobOptions file to produce ramps -# -# 15/08/2005 S. Laplace (laplace@lapp.in2p3.fr) -# ******************************************************************* +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -include( "ByteStreamCnvSvc/TBEventSelector_jobOptions.py" ) -from AthenaCommon.DetFlags import DetFlags -DetFlags.Calo_setOn() -DetFlags.ID_setOff() -DetFlags.Muon_setOff() -DetFlags.Truth_setOff() -DetFlags.LVL1_setOff() -DetFlags.digitize.all_setOff() +import commands +include ("LArCalibProcessing/GetInputFiles.py") -from AthenaCommon.GlobalFlags import GlobalFlags -GlobalFlags.DetGeo.set_atlas() -GlobalFlags.DataSource.set_data() -include( "AthenaCommon/Atlas.UnixStandardJob.py" ) +if not 'SubDet' in dir(): + SubDet = "Barrel" +if not 'RunNumberList' in dir(): + RunNumberList = [ '0018660' ] + +if not 'BaseFileName' in dir(): + BaseFileName = "LArDigits" + + for RunNumber in RunNumberList : + BaseFileName = BaseFileName+"_"+str(RunNumber) +if not 'OutputRootFileName' in dir(): + OutputRootFileName = BaseFileName+".root" + +if not 'OutputDir' in dir(): + OutputDir = commands.getoutput("pwd") -theApp.Dlls += [ "LArByteStream"] +if not 'FilePrefix' in dir(): + if (int(RunNumberList[0]))<99800 : + FilePrefix = "daq.Ramp" + else : + FilePrefix = "data*" + +if not 'NSamples' in dir(): + NSamples=32 -ByteStreamInputSvc = Service( "ByteStreamInputSvc" ) +if not 'InputDir' in dir(): + InputDir = "/castor/cern.ch/grid/atlas/DAQ/lar/ElecCalib/2014/"+RunNumberList[0] -ByteStreamAddressProviderSvc = Service( "ByteStreamAddressProviderSvc" ) -ByteStreamAddressProviderSvc.TypeNames += ["LArCalibDigitContainer/MEDIUM"] -ByteStreamAddressProviderSvc.TypeNames += ["LArCalibDigitContainer/HIGH"] +if not 'FillSCDataBCID' in dir(): + FillSCDataBCID=-1 +if not 'FillLatomeSourceID' in dir(): + FillLatomeSourceID=-1 +if not 'OverwriteEventNumber' in dir(): + OverwriteEventNumber=False + +if not 'FullFileName' in dir(): + if not 'Trigger' in dir(): + if (int(RunNumberList[0]))<99800 : + Trigger = "*"+Partition + else : + if 'Partition' in dir(): + Trigger = "calibration_"+".*"+Partition + else: + Trigger = "calibration_"+"*" + + FullFileName = [] + for RunNumber in RunNumberList : + FullFileName+=GetInputFilesFromTokens(InputDir,int(RunNumber),FilePrefix,Trigger) -# Three input files (for H8): accordion HG, accordion MG, PS (HG only) -#EventSelector.Input += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005134_file01.data"] -EventSelector.Input += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005135_file01.data"] -#EventSelector.Input += ["/castor/cern.ch/atlas/testbeam/lar/2004/daq_ROS-41_LargCalib_0005136_file01.data"] +if not 'Gain' in dir(): + Gain = "HIGH" + +if not 'EvtMax' in dir(): + EvtMax=-1 + +if not 'WriteNtuple' in dir(): + WriteNtuple = LArCalib_Flags.WriteNtuple + +if not 'SuperCells' in dir(): + SuperCells=False + +if not 'WithAccDigits' in dir(): + WithAccDigits=False + +if not SuperCells: include("LArCalibProcessing/LArCalib_Flags.py") +else: include("LArCalibProcessing/LArCalib_FlagsSC.py") + +include("RecExCommission/GetInputFiles.py") + +if SuperCells: + from AthenaCommon.GlobalFlags import globalflags + globalflags.DetGeo.set_Value_and_Lock('atlas') + globalflags.Luminosity.set_Value_and_Lock('zero') + globalflags.DataSource.set_Value_and_Lock('data') + globalflags.InputFormat.set_Value_and_Lock('bytestream') + globalflags.DatabaseInstance.set_Value_and_Lock('CONDBR2') + + from AthenaCommon.JobProperties import jobproperties + jobproperties.Global.DetDescrVersion = "ATLAS-R2-2016-01-00-01" + + from AthenaCommon.DetFlags import DetFlags + DetFlags.Calo_setOn() + DetFlags.ID_setOff() + DetFlags.Muon_setOff() + DetFlags.Truth_setOff() + DetFlags.LVL1_setOff() + DetFlags.digitize.all_setOff() + + #Set up GeoModel (not really needed but crashes without) + from AtlasGeoModel import SetGeometryVersion + from AtlasGeoModel import GeoModelInit + + #Get identifier mapping + include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + include( "LArIdCnv/LArIdCnv_joboptions.py" ) + include( "ByteStreamCnvSvc/BSEventStorageEventSelector_jobOptions.py" ) +else: + include ("LArConditionsCommon/LArMinimalSetup.py") + +from LArCabling.LArCablingAccess import LArOnOffIdMapping,LArFebRodMapping,LArCalibIdMapping +LArOnOffIdMapping() +LArFebRodMapping() +LArCalibIdMapping() +if SuperCells: + from LArCabling.LArCablingAccess import LArOnOffIdMappingSC, LArCalibIdMappingSC + LArOnOffIdMappingSC() + LArCalibIdMappingSC() + + +svcMgr.IOVDbSvc.GlobalTag=LArCalib_Flags.globalFlagDB +svcMgr.IOVDbSvc.DBInstance="" + +if 'BadChannelsFolder' not in dir(): + BadChannelsFolder="/LAR/BadChannels/BadChannels" +if 'MissingFEBsFolder' not in dir(): + MissingFEBsFolder="/LAR/BadChannels/MissingFEBs" + +if not 'ReadBadChannelFromCOOL' in dir(): + ReadBadChannelFromCOOL = True + +if ( ReadBadChannelFromCOOL ): + if 'InputBadChannelSQLiteFile' in dir(): + InputDBConnectionBadChannel = DBConnectionFile(InputBadChannelSQLiteFile) + else: + if 'InputDBConnectionBadChannel' not in dir(): + InputDBConnectionBadChannel = "COOLONL_LAR/" + conddb.dbname + +if 'BadChannelsLArCalibFolderTag' in dir() : + BadChannelsTagSpec = LArCalibFolderTag (BadChannelsFolder,BadChannelsLArCalibFolderTag) + conddb.addFolder("",BadChannelsFolder+""+BadChannelsTagSpec+""+""+InputDBConnectionBadChannel+"", + className="CondAttrListCollection") +else : + conddb.addFolder("",BadChannelsFolder+""+InputDBConnectionBadChannel+"",className="CondAttrListCollection") + + +if 'MissingFEBsLArCalibFolderTag' in dir() : + MissingFEBsTagSpec = LArCalibFolderTag (MissingFEBsFolder,MissingFEBsLArCalibFolderTag) + conddb.addFolder("",MissingFEBsFolder+""+MissingFEBsTagSpec+""+""+InputDBConnectionBadChannel+"",className='AthenaAttributeList') +else : + conddb.addFolder("",MissingFEBsFolder+""+InputDBConnectionBadChannel+"",className='AthenaAttributeList') + + +from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelCondAlg, LArBadFebCondAlg +theLArBadChannelCondAlg=LArBadChannelCondAlg(ReadKey=BadChannelsFolder) +condSeq+=theLArBadChannelCondAlg + +theLArBadFebCondAlg=LArBadFebCondAlg(ReadKey=MissingFEBsFolder) +condSeq+=theLArBadFebCondAlg + +if SuperCells: + conddb.addFolder("","/LAR/IdentifierOfl/OnOffIdMap_SCCOOLOFL_LAR/OFLP200LARIdentifierOflOnOffIdMap_SC-000") + + + + + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +theByteStreamInputSvc=svcMgr.ByteStreamInputSvc +if not 'FullFileName' in dir(): + RampLog.info( "No FullFileName! Please give a FullFileName list." ) + theApp.exit(-1) + +else : + theByteStreamInputSvc.FullFileName=FullFileName + +theByteStreamInputSvc.MaxBadEvents=0 +svcMgr.ByteStreamCnvSvc.InitCnvs += [ "EventInfo"] + +theByteStreamAddressProviderSvc =svcMgr.ByteStreamAddressProviderSvc +theByteStreamAddressProviderSvc.TypeNames += ["LArFebHeaderContainer/LArFebHeader"] + +if not SuperCells: + from LArByteStream.LArByteStreamConf import LArRodDecoder + svcMgr.ToolSvc += LArRodDecoder() + + theByteStreamAddressProviderSvc.TypeNames += [ "LArAccumulatedCalibDigitContainer/HIGH" ] + theByteStreamAddressProviderSvc.TypeNames += [ "LArAccumulatedCalibDigitContainer/MEDIUM"] + theByteStreamAddressProviderSvc.TypeNames += [ "LArAccumulatedCalibDigitContainer/LOW" ] + + # this will go outside SC loop + include ("LArROD/LArFebErrorSummaryMaker_jobOptions.py") + topSequence.LArFebErrorSummaryMaker.CheckAllFEB=False + + from LArCalibDataQuality.LArCalibDataQualityConf import LArBadEventCatcher + theLArBadEventCatcher=LArBadEventCatcher() + theLArBadEventCatcher.CheckAccCalibDigitCont=False + theLArBadEventCatcher.CheckBSErrors=True + theLArBadEventCatcher.KeyList=[Gain] + theLArBadEventCatcher.StopOnError=False + topSequence+=theLArBadEventCatcher +else: + theByteStreamAddressProviderSvc.TypeNames += [ "LArDigitContainer/SC" ] + from LArByteStream.LArByteStreamConf import LArLATOMEDecoder + theLArLATOMEDecoder = LArLATOMEDecoder("LArLATOMEDecoder") + theLArLATOMEDecoder.NSamples = NSamples + theLArLATOMEDecoder.latomeInfoFileName = LatomeInfo + theLArLATOMEDecoder.DumpFile = SC_DumpFile + theLArLATOMEDecoder.RawDataFile = SC_RawDataFile + theLArLATOMEDecoder.SampleShift = SC_SampleShift + svcMgr.ToolSvc += theLArLATOMEDecoder + + + +from LArCalibTools.LArCalibToolsConf import LArAverages2Ntuple + +LArDigits2Ntuple=LArAverages2Ntuple("LArDigits2Ntuple") +LArDigits2Ntuple.ContainerKey = Gain +LArDigits2Ntuple.KeepOnlyPulsed=False +if 'FTlist' in dir(): + LArDigits2Ntuple.KeepFT=FTlist +LArDigits2Ntuple.isSC = SuperCells + +if SuperCells: + LArDigits2Ntuple.RealGeometry = True + LArDigits2Ntuple.OffId = True + LArDigits2Ntuple.FillBCID = True + LArDigits2Ntuple.AddBadChannelInfo = False + LArDigits2Ntuple.FillSCDataBCID = FillSCDataBCID + LArDigits2Ntuple.FillLatomeSourceID = FillLatomeSourceID + LArDigits2Ntuple.OverwriteEventNumber = OverwriteEventNumber + +topSequence+= LArDigits2Ntuple include( "LArDetMgrDetDescrCnv/LArDetMgrDetDescrCnv_H8_joboptions.py" ) @@ -42,13 +242,6 @@ DetDescrCnvSvc.DoIdChecks include ("LArConditionsCommon/LArConditionsCommon_H8_jobOptions.py") IOVDbSvc.Folders += ["/LAR/LArElecCalibH8/LArCalibParamsLArCalibParams-"+LArTB04FolderTag_Calib+""+LArH8DBConnection] -theApp.Dlls += ["LArRawUtils"] -theApp.Dlls += ["LArTools"] -theApp.Dlls += ["LArCalibUtils"] -theApp.Dlls += ["LArCalibTools"] -theApp.Dlls += ["LArRecUtils"] -theApp.Dlls += ["LArROD"] - theApp.topAlg+=["LArCalibDigitsAccumulator"] LArCalibDigitsAccumulator=Algorithm("LArCalibDigitsAccumulator") LArCalibDigitsAccumulator.KeyList+=["HIGH"] @@ -63,20 +256,14 @@ theApp.topAlg+=["LArAverages2Ntuple/averagesmedium"] averagesmedium=Algorithm("averagesmedium") averagesmedium.containerKey="MEDIUM" -theApp.Dlls += [ "RootHistCnv" ] theApp.HistogramPersistency = "ROOT" -NTupleSvc = Service( "NTupleSvc" ) - -NTupleSvc.Output = [ "FILE1 DATAFILE='LArAverages.root' OPT='NEW'" ] - +from GaudiSvc.GaudiSvcConf import NTupleSvc +svcMgr += NTupleSvc() +svcMgr.NTupleSvc.Output = [ "FILE1 DATAFILE='"+OutputDir + "/" +OutputRootFileName+"' OPT='NEW'" ] AthenaEventLoopMgr=Service("AthenaEventLoopMgr") AthenaEventLoopMgr.OutputLevel=ERROR -MessageSvc.OutputLevel=INFO -#MessageSvc.OutputLevel=DEBUG -MessageSvc.defaultLimit=1000000; - -#StoreGateSvc=Service("StoreGateSvc"); -#StoreGateSvc.dump=TRUE +theApp.EvtMax=EvtMax +svcMgr.MessageSvc.OutputLevel=WARNING diff --git a/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py index 9bbe31bc1e8a7ce18842e77bd034a50643385494..1ee7121363dbd1093b2657b91a3d79029c0baf0d 100755 --- a/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py +++ b/LArCalorimeter/LArCalibTools/share/LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py @@ -1,3 +1,5 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + ########################################################################### # # LArCalib_Delay_OFC_2Ntuple_POOL_jobOptions.py dumps the conntet of a @@ -41,12 +43,10 @@ if not 'OFCRootFileName' in dir(): OFCRootFileName = "LArWaves2Ntuple_POOL.root" if not 'RunNumber' in dir(): - RunNumber = 165983 + RunNumber = 393960 ########################################################################### -#include("LArConditionsCommon/LArMinimalSetup.py") - include("LArCalibProcessing/LArCalib_Flags.py") include("LArCalibProcessing/LArCalib_MinimalSetup.py") @@ -65,8 +65,7 @@ include("AthenaPoolCnvSvc/AthenaPool_jobOptions.py") include("LArCondAthenaPool/LArCondAthenaPool_joboptions.py") if not 'DBConnectionCOOL' in dir(): - DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_LAR;dbname=CONDBR2;" - #DBConnectionCOOL = "COOLONL_LAR/COMP200" + DBConnectionCOOL = "COOLONL_LAR/CONDBR2" ## define the DB Global Tag : svcMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB @@ -76,9 +75,6 @@ svcMgr.IOVDbSvc.forceRunNumber=RunNumber from IOVDbSvc.CondDB import conddb PoolFileList = [] -# Temperature folder -#conddb.addFolder("DCS_OFL","/LAR/DCS/FEBTEMP") - if 'InputBadChannelSQLiteFile' in dir(): from string import * InputDBConnectionBadChannel = "sqlite://;schema="+InputBadChannelSQLiteFile+";dbname=CONDBR2" @@ -87,18 +83,22 @@ else: if ( not 'InputBadChannelSQLiteFile' in dir()) and ("ONL" in DBConnectionCOOL): BadChannelsFolder="/LAR/BadChannels/BadChannels" - conddb.addFolder("",BadChannelsFolder+""+InputDBConnectionBadChannel+"",className="CondAttrListCollection") MissingFEBsFolder="/LAR/BadChannels/MissingFEBs" - conddb.addFolder("",MissingFEBsFolder+""+InputDBConnectionBadChannel+"",className='AthenaAttributeList') + conddb.addFolder("",BadChannelsFolder+""+InputDBConnectionBadChannel+"",className="CondAttrListCollection") + conddb.addFolder("",MissingFEBsFolder+""+InputDBConnectionBadChannel+"",className="AthenaAttributeList") else: BadChannelsFolder="/LAR/BadChannelsOfl/BadChannels" - conddb.addFolder("",BadChannelsFolder+""+InputDBConnectionBadChannel+"",className="CondAttrListCollection") MissingFEBsFolder="/LAR/BadChannelsOfl/MissingFEBs" - conddb.addFolder("",MissingFEBsFolder+""+InputDBConnectionBadChannel+"",className='AthenaAttributeList') + conddb.addFolder("",BadChannelsFolder+""+InputDBConnectionBadChannel+"",className="CondAttrListCollection") + conddb.addFolder("",MissingFEBsFolder+""+InputDBConnectionBadChannel+"",className="AthenaAttributeList") + +from AthenaCommon.AlgSequence import AthSequencer +condSeq = AthSequencer("AthCondSeq") from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelCondAlg, LArBadFebCondAlg theLArBadChannelCondAlg=LArBadChannelCondAlg(ReadKey=BadChannelsFolder) condSeq+=theLArBadChannelCondAlg + theLArBadFebCondAlg=LArBadFebCondAlg(ReadKey=MissingFEBsFolder) condSeq+=theLArBadFebCondAlg diff --git a/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py b/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py index ad131132a3837a0947efd6d3295acf5a976198fa..feceb68992e94863aab88726ac150455c724ebe7 100755 --- a/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py +++ b/LArCalorimeter/LArCalibTools/share/LArDigits2Ntuple_jobOptions.py @@ -32,6 +32,9 @@ if not 'FilePrefix' in dir(): else : FilePrefix = "data*" +if not 'NSamples' in dir(): + NSamples=32 + if not 'InputDir' in dir(): InputDir = "/castor/cern.ch/grid/atlas/DAQ/lar/ElecCalib/2014/"+RunNumberList[0] @@ -67,13 +70,15 @@ if not 'WriteNtuple' in dir(): if not 'SuperCells' in dir(): SuperCells=False +if not 'WithAccDigits' in dir(): + WithAccDigits=False + if not 'GainList' in dir(): if SuperCells: GainList = ["SC"] else: GainList = [ "HIGH", "MEDIUM", "LOW" ] - if not SuperCells: include("LArCalibProcessing/LArCalib_Flags.py") else: include("LArCalibProcessing/LArCalib_FlagsSC.py") include("LArCalibProcessing/GetInputFiles.py") diff --git a/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx index ed092bda0d84b7e1d847defc0c9cd7d2b0bf0322..1bfd6e10313fa492c8126c7999b9b530d1ef9216 100644 --- a/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx +++ b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx @@ -5,6 +5,8 @@ #include "LArCalibTools/LArAverages2Ntuple.h" #include "LArRawEvent/LArAccumulatedCalibDigitContainer.h" +#include "CaloIdentifier/CaloCell_ID.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" LArAverages2Ntuple::LArAverages2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): LArCond2NtupleBase(name, pSvcLocator) @@ -12,6 +14,8 @@ LArAverages2Ntuple::LArAverages2Ntuple(const std::string& name, ISvcLocator* pSv declareProperty("ContainerKey",m_contKey); declareProperty("NSamples",m_Nsamples=50); declareProperty("KeepOnlyPulsed",m_keepPulsed=true); + declareProperty("KeepFT",m_keepFT); + declareProperty("isSC",m_isSC=false); m_ipass=0; } @@ -22,6 +26,42 @@ LArAverages2Ntuple::~LArAverages2Ntuple() StatusCode LArAverages2Ntuple::initialize() { ATH_MSG_INFO ( "in initialize" ); + + const CaloCell_ID* idHelper = nullptr; + ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") ); + m_emId = idHelper->em_idHelper(); + if (!m_emId) { + ATH_MSG_ERROR ( "Could not access lar EM ID helper" ); + return StatusCode::FAILURE; + } + + StatusCode sc; + if ( m_isSC ){ + const LArOnline_SuperCellID* ll; + sc = detStore()->retrieve(ll, "LArOnline_SuperCellID"); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Could not get LArOnlineID helper !" ); + return StatusCode::FAILURE; + } + else { + m_onlineHelper = dynamic_cast(ll); + ATH_MSG_DEBUG("Found the LArOnlineID helper"); + } + } else { // m_isSC + const LArOnlineID* ll; + sc = detStore()->retrieve(ll, "LArOnlineID"); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Could not get LArOnlineID helper !" ); + return StatusCode::FAILURE; + } + else { + m_onlineHelper = dynamic_cast(ll); + ATH_MSG_DEBUG(" Found the LArOnlineID helper. "); + } + } + ATH_CHECK(m_cablingKey.initialize()); + ATH_CHECK(m_calibMapKey.initialize()); + m_ntName = "AVERAGES"; m_ntTitle="Averages"; m_ntpath=std::string("/NTUPLES/FILE1/")+m_ntName+m_contKey; @@ -50,6 +90,21 @@ StatusCode LArAverages2Ntuple::execute() { ATH_MSG_DEBUG ( "in execute" ); + const EventContext& ctx = Gaudi::Hive::currentContext(); + + SG::ReadCondHandle cablingHdl{m_cablingKey, ctx}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "DO not have cabling from the key " << m_cablingKey.key() ); + return StatusCode::FAILURE; + } + SG::ReadCondHandle clHdl{m_calibMapKey, ctx}; + const LArCalibLineMapping *clcabling {*clHdl}; + if(!clcabling) { + ATH_MSG_ERROR( "Do not have calib line mapping !!!" ); + return StatusCode::FAILURE; + } + const LArAccumulatedCalibDigitContainer* accuDigitContainer = NULL; StatusCode sc=evtStore()->retrieve(accuDigitContainer,m_contKey); if (sc!=StatusCode::SUCCESS) { @@ -59,60 +114,87 @@ StatusCode LArAverages2Ntuple::execute() ATH_MSG_DEBUG ( "Got LArAccumulatedCalibDigitContainer with key " << m_contKey ); - if (accuDigitContainer) { + if (accuDigitContainer) { - LArAccumulatedCalibDigitContainer::const_iterator it=accuDigitContainer->begin(); - LArAccumulatedCalibDigitContainer::const_iterator it_e=accuDigitContainer->end(); - - if(it == it_e) { - ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " is empty " ); - return StatusCode::SUCCESS; - }else{ - ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " has " <size() << " entries" ); - } - - unsigned cellCounter=0; - for (;it!=it_e;++it) { - // Add protection - Modif from JF. Marchand - if ( !(*it) ) continue; - - HWIdentifier chid=(*it)->channelID(); - m_isPulsed = (long)(*it)->isPulsed(); - if(m_keepPulsed && !(*it)->isPulsed()) continue; - m_DAC = (*it)->DAC(); - m_Nsteps = (*it)->nSteps(); - m_Ntrigger = (*it)->nTriggers(); - m_delay = (*it)->delay(); - m_StepIndex=(*it)->stepIndex(); - unsigned int trueMaxSample = (*it)->nsamples(); - m_ntNsamples = trueMaxSample; - - if(trueMaxSample>m_Nsamples){ - if(!m_ipass){ - ATH_MSG_WARNING ( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); - m_ipass=1; + LArAccumulatedCalibDigitContainer::const_iterator it=accuDigitContainer->begin(); + LArAccumulatedCalibDigitContainer::const_iterator it_e=accuDigitContainer->end(); + + if(it == it_e) { + ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " is empty " ); + return StatusCode::SUCCESS; + }else{ + ATH_MSG_DEBUG ( "LArAccumulatedCalibDigitContainer with key=" << m_contKey << " has " <size() << " entries" ); + } + + unsigned cellCounter=0; + for (;it!=it_e;++it) { + // Add protection - Modif from JF. Marchand + if ( !(*it) ) continue; + + HWIdentifier chid=(*it)->channelID(); + m_isPulsed = (long)(*it)->isPulsed(); + if(m_keepPulsed && !(*it)->isPulsed()) continue; + m_DAC = (*it)->DAC(); + m_Nsteps = (*it)->nSteps(); + m_Ntrigger = (*it)->nTriggers(); + m_delay = (*it)->delay(); + m_StepIndex=(*it)->stepIndex(); + unsigned int trueMaxSample = (*it)->nsamples(); + m_ntNsamples = trueMaxSample; + + if(trueMaxSample>m_Nsamples){ + if(!m_ipass){ + ATH_MSG_WARNING ( "The number of samples in data is larger than the one specified by JO: " << trueMaxSample << " > " << m_Nsamples << " --> only " << m_Nsamples << " will be available in the ntuple " ); + m_ipass=1; + } + trueMaxSample = m_Nsamples; } - trueMaxSample = m_Nsamples; - } - - - const std::vector& sampleSum = (*it)->sampleSum(); - const std::vector& sampleSum2 = (*it)->sample2Sum(); - const std::vector& mean = (*it)->mean(); - const std::vector& RMSv = (*it)->RMS(); - - for(unsigned int j=0;jwriteRecord(m_nt) ); - cellCounter++; - }//end loop over cells - }//end if have accumulatedDigitContainer - ATH_MSG_DEBUG ( "LArAverages2Ntuple has finished." ); - return StatusCode::SUCCESS; -}// end finalize-method. + + const std::vector& sampleSum = (*it)->sampleSum(); + const std::vector& sampleSum2 = (*it)->sample2Sum(); + const std::vector& mean = (*it)->mean(); + const std::vector& RMSv = (*it)->RMS(); + + for(unsigned int j=0;jchannel(chid); + m_slot=m_onlineHelper->slot(chid); + m_FT=m_onlineHelper->feedthrough(chid); + if(m_keepFT.size() > 0) { + if(std::find(std::begin(m_keepFT), std::end(m_keepFT), m_FT) == std::end(m_keepFT)) continue; + } + m_barrel_ec = m_onlineHelper->barrel_ec(chid); + m_pos_neg = m_onlineHelper->pos_neg(chid); + + bool isConnected = cabling->isOnlineConnected(chid); + if(isConnected){ + Identifier id=cabling->cnvToIdentifier(chid); + const std::vector& calibLineV=clcabling->calibSlotLine(chid); + std::vector::const_iterator calibLineIt=calibLineV.begin(); + m_calibLine = m_onlineHelper->channel(*calibLineIt); + m_eta=m_emId->eta(id); + m_phi=m_emId->phi(id); + m_layer=m_emId->sampling(id); + m_region=m_emId->region(id); + } else { + m_calibLine=-999; + m_eta=-999; + m_phi=-999; + m_layer=-999; + m_region=-999; + } + + fillFromIdentifier(chid); + ATH_CHECK( ntupleSvc()->writeRecord(m_nt) ); + cellCounter++; + }//end loop over cells + }//end if have accumulatedDigitContainer + ATH_MSG_DEBUG ( "LArAverages2Ntuple has finished." ); + return StatusCode::SUCCESS; +}// end execute method. diff --git a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCaliWaveBuilder.h b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCaliWaveBuilder.h index 919b0a7480657bf5e9ccc1409a4cccafa0f1dc91..6909aa0ae83c281a49b1ef835decc2edfcd58aa8 100644 --- a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCaliWaveBuilder.h +++ b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArCaliWaveBuilder.h @@ -17,7 +17,9 @@ #include #include "LArRawConditions/LArCaliWaveContainer.h" +#include "LArRawConditions/LArCalibParams.h" #include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArCalibLineMapping.h" #include "StoreGate/ReadCondHandleKey.h" @@ -38,10 +40,12 @@ class LArCaliWaveBuilder : public AthAlgorithm SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; SG::ReadCondHandleKey m_cablingKeySC{this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_calibMapKey{this,"CalibLineKey","LArCalibLineMap","SG Key of calib. line mapping object"}; + SG::ReadCondHandleKey m_pedKey{this,"PedestalKey","Pedestal","SG Key of pedestal object"}; bool m_useAccumulatedDigits; - StatusCode executeWithAccumulatedDigits(); - StatusCode executeWithStandardDigits(); + StatusCode executeWithAccumulatedDigits(const LArCalibParams* calibParams=nullptr, const LArCalibLineMapping* clcabling=nullptr ); + StatusCode executeWithStandardDigits(const LArCalibParams* calibParams=nullptr, const LArCalibLineMapping* clcabling=nullptr); std::vector m_keylist; std::vector m_keylistproperty; @@ -54,9 +58,7 @@ class LArCaliWaveBuilder : public AthAlgorithm WaveContainer m_waves; // Pedestal subtraction - const DataHandle m_larPedestal; bool m_pedSub; - //const ILArPedestal* m_larPedestal; unsigned m_baseline; // Reco also unpulsed and saturated cells ? @@ -84,7 +86,7 @@ class LArCaliWaveBuilder : public AthAlgorithm uint16_t m_fatalFebErrorPattern; int m_usePatt; - unsigned m_numPatt; + bool m_useParams; }; #endif diff --git a/LArCalorimeter/LArCalibUtils/src/LArCaliWaveBuilder.cxx b/LArCalorimeter/LArCalibUtils/src/LArCaliWaveBuilder.cxx index 10e2883c03bf0478e14f32c5b3c59f670596fc93..e91d1ae8a89cbc2dd8c0ba564bd64c1a0ba33723 100644 --- a/LArCalorimeter/LArCalibUtils/src/LArCaliWaveBuilder.cxx +++ b/LArCalorimeter/LArCalibUtils/src/LArCaliWaveBuilder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "LArCalibUtils/LArCaliWaveBuilder.h" @@ -41,7 +41,7 @@ LArCaliWaveBuilder::LArCaliWaveBuilder(const std::string& name, ISvcLocator* pSv declareProperty("CheckEmptyPhases", m_checkEmptyPhases=false); declareProperty("RecAllCells", m_recAll=false); declareProperty("UsePattern", m_usePatt=-1); - declareProperty("NumPattern", m_numPatt=16); // fix me - is it possible to get from outside ? + declareProperty("UseParams", m_useParams=false); // Read LArCalibParams from DetStore ? declareProperty("isSC", m_isSC=false); @@ -84,15 +84,8 @@ StatusCode LArCaliWaveBuilder::initialize() if (m_checkEmptyPhases) ATH_MSG_INFO( "Empty phases check selected." ); - //Get pedestal from DetStore - if (m_pedSub) { - ATH_MSG_INFO( "Pedestal subtraction selected." ); - sc=detStore()->regHandle(m_larPedestal,"Pedestal"); - if (sc.isFailure()) { - ATH_MSG_ERROR( "Cannot register data handle for LArPedestal object!" ); - return sc; - } - } + //Get pedestal from CondStore + ATH_CHECK( m_pedKey.initialize(m_pedSub) ); //Get Online helper from DetStore if ( m_isSC ) { @@ -110,24 +103,49 @@ StatusCode LArCaliWaveBuilder::initialize() ATH_CHECK( m_cablingKey.initialize() ); ATH_CHECK( m_cablingKeySC.initialize(m_isSC) ); + if(m_usePatt >= 0 && !m_useParams) { + ATH_MSG_ERROR("Inconsistent configuration, for UsePattern > 0 the UseParams must be true"); + return StatusCode::FAILURE; + } + ATH_CHECK( m_calibMapKey.initialize(m_useParams) ); + return StatusCode::SUCCESS; } StatusCode LArCaliWaveBuilder::execute() { - if(m_usePatt >= 0) { // we have to check in which event we are, reading only ones corresponding + // using EvtId + const EventContext& ctx = getContext(); + m_event_counter=ctx.eventID().event_number(); + + const LArCalibParams* calibParams = nullptr; + const LArCalibLineMapping *clcabling=nullptr; + if(m_useParams) { // we have to check in which event we are, reading only ones corresponding // to our pattern - if(static_cast(m_event_counter % m_numPatt) != m_usePatt) { - m_event_counter++ ; + ATH_CHECK(detStore()->retrieve(calibParams,"LArCalibParams")); + unsigned numPatt=calibParams->getNumberPatterns(HWIdentifier(0)); + + int counter=m_event_counter; + if(m_useAccumulatedDigits) counter /= calibParams->NTrigger(HWIdentifier(1007091712)); + if(m_usePatt >= 0 && static_cast(counter % numPatt) != m_usePatt) { return StatusCode::SUCCESS; } + ATH_MSG_DEBUG("Good event "<NTrigger(HWIdentifier(1007091712)) <<" triggers "); + + const EventContext& ctx = Gaudi::Hive::currentContext(); + SG::ReadCondHandle clHdl{m_calibMapKey, ctx}; + clcabling =*clHdl; + if(!clcabling) { + ATH_MSG_WARNING( "Do not have calib line mapping from key " << m_calibMapKey.key() ); + return StatusCode::FAILURE; + } + } if ( m_event_counter < 1000 || m_event_counter%100==0 ) ATH_MSG_INFO( "Processing event " << m_event_counter ); - m_event_counter++ ; if (m_keylist.size()==0) { ATH_MSG_ERROR( "Key list is empty! No containers to process!" ); @@ -137,12 +155,12 @@ StatusCode LArCaliWaveBuilder::execute() // execute() method... if (m_useAccumulatedDigits) - return executeWithAccumulatedDigits(); + return executeWithAccumulatedDigits(calibParams, clcabling); else - return executeWithStandardDigits(); + return executeWithStandardDigits(calibParams, clcabling); } -StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() +StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits(const LArCalibParams* calibParams, const LArCalibLineMapping* clcabling) { StatusCode sc; @@ -174,7 +192,7 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() } } else - if (m_event_counter==1) + if (m_event_counter==0) ATH_MSG_WARNING( "No FebErrorSummaryObject found! Feb errors not checked!" ); HWIdentifier lastFailedFEB(0); @@ -182,7 +200,7 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() LArAccumulatedCalibDigitContainer::const_iterator it_end=larAccumulatedCalibDigitContainer->end(); if (it == it_end) { - ATH_MSG_DEBUG("LArAccumulatedCalibDigitContainer with key=" << *key_it << " is empty "); + ATH_MSG_DEBUG("LArAccumulatedCalibDigitContainer with key=" << *key_it << " is empty "); continue; // at this event LArAccumulatedCalibDigitContainer is empty, do not even try to loop on it... } @@ -191,14 +209,21 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() for (;it!=it_end; ++it) { // Loop over all cells - if ( (!m_recAll) && (!(*it)->isPulsed()) ) { - ATH_MSG_DEBUG( "Non pulsed cell " << m_onlineID->channel_name((*it)->hardwareID()) ); + bool ispulsed=false; + if(m_useParams && calibParams) { // got LArCalibParams from DetStore + const std::vector& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID()); + for (const HWIdentifier &calibLineHWID : calibLineLeg) {// loop calib lines + ispulsed |= calibParams->isPulsed(m_event_counter,calibLineHWID); + } + } else { + ispulsed=(*it)->isPulsed(); + } + if ( (!m_recAll) && !ispulsed ) { + ATH_MSG_DEBUG( "Non pulsed cell " << m_onlineID->channel_name((*it)->hardwareID())<<" in evt. "<hardwareID(); HWIdentifier febid=m_onlineID->feb_Id(chid); - ATH_MSG_DEBUG( "Pulsed cell " << m_onlineID->channel_name(chid) ); - ATH_MSG_DEBUG( "with " << (*it)->sampleSum().size() << " samples " << (*it)->DAC() << " DAC " << (*it)->delay() << " delay " << (*it)->isPulsed(1) << " line 1 pulsed " ); if (febErrSum) { const uint16_t febErrs=febErrSum->feb_error(febid); if (febErrs & m_fatalFebErrorPattern) { @@ -233,22 +258,48 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() WaveMap& waveMap = m_waves.get(chid,gain); - //make dac and Pulsed which has dac and four bits of is pulsed info + //make dacPulsed which has dac and four bits of is pulsed info + int dacPulsed; + float delay = (*it)->delay(); int dac=(*it)->DAC(); - int pulsed=0; int index; - for(int iLine=1;iLine<5;iLine++){ - if((*it)->isPulsed(iLine)){ - ATH_MSG_DEBUG("GR: line pulsed true, line="<& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID()); + if(calibLineLeg.size()==0) { + ATH_MSG_WARNING("Why do not have calib lines for "<<(*it)->hardwareID()<<" ?"); + continue; + } + dac=calibParams->DAC(m_event_counter,calibLineLeg[0]); + dacPulsed=dac; + delay = calibParams->Delay(m_event_counter,calibLineLeg[0]); + for (unsigned i=0; iisPulsed(m_event_counter,calibLineLeg[i])){ + ATH_MSG_DEBUG("GR: line pulsed true, line="<DAC(); + for(int iLine=1;iLine<5;iLine++){ + if((*it)->isPulsed(iLine)){ + ATH_MSG_DEBUG("GR: line pulsed true, line="<DAC(); - } + index = dacPulsed; + } else { + index = dac; + } + + ATH_MSG_DEBUG( "Pulsed cell " << m_onlineID->channel_name(chid) << " gain: "<sampleSum().size() << " samples " << index << " DAC " << delay << " delay " << dacPulsed << " dacPulsed " ); WaveMap::iterator itm = waveMap.find(index); @@ -258,7 +309,7 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() itm = (waveMap.insert(WaveMap::value_type(index,wave))).first; ATH_MSG_DEBUG("index: "<delay()/deltaDelay), m_NStep, + (*itm).second.addAccumulatedEvent(int(std::roundf(delay/deltaDelay)), m_NStep, samplesum, sample2sum, (*it)->nTriggers()); } //End loop over all cells @@ -268,7 +319,7 @@ StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits() } -StatusCode LArCaliWaveBuilder::executeWithStandardDigits() +StatusCode LArCaliWaveBuilder::executeWithStandardDigits(const LArCalibParams* calibParams, const LArCalibLineMapping* clcabling) { StatusCode sc; @@ -298,7 +349,20 @@ StatusCode LArCaliWaveBuilder::executeWithStandardDigits() for (;it!=it_end; ++it) { // Loop over all cells - if ((!m_recAll) && !(*it)->isPulsed() ) continue ; // Check if cell is pulsed + bool pulsed=false; + int dac = (*it)->DAC(); + float delay= (*it)->delay(); + if(m_useParams && calibParams && clcabling) { // get LArCalibParams from DetStore + const std::vector& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID()); + dac=calibParams->DAC(m_event_counter,calibLineLeg[0]); // assuming all calib. boards configured equally + delay = calibParams->Delay(m_event_counter,calibLineLeg[0]); + for (const HWIdentifier &calibLineHWID : calibLineLeg) {// loop calib lines + pulsed |= calibParams->isPulsed(m_event_counter,calibLineHWID); + } + } else { + pulsed=(*it)->isPulsed(); + } + if ((!m_recAll) && !pulsed ) continue ; // Check if cell is pulsed HWIdentifier chid=(*it)->hardwareID(); CaloGain::CaloGain gain=(*it)->gain(); @@ -314,15 +378,15 @@ StatusCode LArCaliWaveBuilder::executeWithStandardDigits() samples.push_back((double)(sample)); WaveMap& waveMap = m_waves.get(chid,gain); - WaveMap::iterator itm = waveMap.find((*it)->DAC()); + WaveMap::iterator itm = waveMap.find(dac); if ( itm == waveMap.end() ) { // A new LArCaliWave is booked - LArCaliWave wave(samples.size()*m_NStep, m_dt, (*it)->DAC(),0x1); + LArCaliWave wave(samples.size()*m_NStep, m_dt, dac,0x1); wave.setFlag( LArWave::meas ); - itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(),wave))).first; + itm = (waveMap.insert(WaveMap::value_type(dac,wave))).first; } - (*itm).second.addEvent((int)roundf((*it)->delay()/deltaDelay), m_NStep, samples); + (*itm).second.addEvent((int)roundf(delay/deltaDelay), m_NStep, samples); } //End loop over all cells } //End loop over all containers @@ -350,9 +414,10 @@ StatusCode LArCaliWaveBuilder::stop() return sc; } + const EventContext& ctx = Gaudi::Hive::currentContext(); const LArOnOffIdMapping* cabling(0); if( m_isSC ){ - SG::ReadCondHandle cablingHdl{m_cablingKeySC}; + SG::ReadCondHandle cablingHdl{m_cablingKeySC, ctx}; cabling = {*cablingHdl}; if(!cabling) { ATH_MSG_ERROR("Do not have mapping object " << m_cablingKeySC.key()); @@ -360,15 +425,19 @@ StatusCode LArCaliWaveBuilder::stop() } }else{ - SG::ReadCondHandle cablingHdl{m_cablingKey}; + SG::ReadCondHandle cablingHdl{m_cablingKey, ctx}; cabling = {*cablingHdl}; if(!cabling) { ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key()); return StatusCode::FAILURE; } } - - + SG::ReadCondHandle pedHdl{m_pedKey, ctx}; + const ILArPedestal* larPedestal{*pedHdl}; + if(m_pedSub && !larPedestal) { + ATH_MSG_DEBUG("No pedestal(s) found "); + ATH_MSG_INFO( "Using fake (baseline) pedestal subtraction..." ); + } LArWaveHelper wHelper; int NCaliWave=0; @@ -437,8 +506,8 @@ StatusCode LArCaliWaveBuilder::stop() float pedAve = 0.; if ( m_pedSub ) { - if ( m_larPedestal.isValid() ) { - float pedestal = m_larPedestal->pedestal(chid,gain); + if ( larPedestal ) { + float pedestal = larPedestal->pedestal(chid,gain); if (pedestal <= (1.0+LArElecCalib::ERRORCODE)) { ATH_MSG_DEBUG("No pedestal(s) found for channel 0x" << MSG::hex << chid << MSG::dec); ATH_MSG_INFO( "Using fake (baseline) pedestal subtraction..." ); @@ -447,8 +516,6 @@ StatusCode LArCaliWaveBuilder::stop() pedAve = pedestal; } } else { - ATH_MSG_DEBUG("No pedestal(s) found for channel 0x" << MSG::hex << chid << MSG::dec); - ATH_MSG_INFO( "Using fake (baseline) pedestal subtraction..." ); pedAve = wHelper.getBaseline(thisWave,m_baseline) ; } ATH_MSG_DEBUG("Pedestal for channel 0x" << MSG::hex << chid << MSG::dec << " is = " << pedAve << " ADC"); diff --git a/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx b/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx index f542b00f16b38ddcd3f6f2a6beebd64c36d4db40..5ce35964382324fb820f17cdb882d665b5dd651e 100644 --- a/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx +++ b/LArCalorimeter/LArCalibUtils/src/LArCalibDigitMaker.cxx @@ -166,7 +166,7 @@ StatusCode LArCalibDigitMaker::execute() { } if (!m_pulsedChids.empty()) m_pulsedChids.clear(); //Iterate over LArDigitContainer and build LArCalibDigitContainer - LArCalibDigitContainer* calibDigitContainer=new LArCalibDigitContainer(); + auto calibDigitContainer=std::make_unique(); calibDigitContainer->setDelayScale(m_delayScale); for (const LArDigit* digit : *larDigitCont) { HWIdentifier chid=digit->hardwareID(); @@ -194,6 +194,7 @@ StatusCode LArCalibDigitMaker::execute() { } uint16_t dac=ddac; uint16_t delay=calibParams->Delay(eventNb,*csl_it); + bool ispulsed=false; for(; csl_it != calibChannelIDs.end(); ++csl_it) { if(calibParams->isPulsed(eventNb,*csl_it)){ @@ -203,14 +204,14 @@ StatusCode LArCalibDigitMaker::execute() { } //build LArCalibDigit: if ( ispulsed ){ - ATH_MSG_DEBUG("HERE!! "<push_back(calibDigit); } //End iteration to build calibDigits ATH_MSG_DEBUG("Trying to store with key "<record(calibDigitContainer,key) ); + ATH_CHECK( evtStore()->record(std::move(calibDigitContainer),key) ); ATH_MSG_DEBUG ("LArCalibDigitContainer recorded to StoreGate. key=" << key ); } //End loop key list return StatusCode::SUCCESS; diff --git a/LArCalorimeter/LArCondTools/CMakeLists.txt b/LArCalorimeter/LArCondTools/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1c8cd7acdaff5f96084b69e691aecbc44f6844db --- /dev/null +++ b/LArCalorimeter/LArCondTools/CMakeLists.txt @@ -0,0 +1,22 @@ +################################################################################ +# Package: LArCondTools +################################################################################ + +# Declare the package name: +atlas_subdir( LArCondTools ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_component( LArCondTools + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${CORAL_LIBRARIES} AthenaBaseComps StoreGateLib SGtests AthenaPoolUtilities Identifier GaudiKernel CaloDetDescrLib CaloIdentifier CaloGeoHelpers AthenaKernel LArCablingLib LArHV LArReadoutGeometry LArIdentifier LArRawConditions LArCOOLConditions LArRecConditions ) + +# Install files from the package: +atlas_install_joboptions( share/*.py ) + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_FcalIdFix7_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_FcalIdFix7_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..6dcc6dc7570fac647791802056098997bf95d33f --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_FcalIdFix7_jobOptions.py @@ -0,0 +1,165 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +DetDescrVersion = "ATLAS-DC3-05" + +# Switches: +# items +RunNumber = 1 + +# flags . turn them on when ready to write to COOL +RecreateFolder = False +SchemaPrivilege = False +WriteIOV = False + +# Objects and its tag +ObjectList = [] +TagList = [] + + +# FIX 2 +TagNameForFix = "DC3-B-IdFix7" +ObjectList += ["LArDAC2uAMC#LArDAC2uA#/LAR/ElecCalibMC/DAC2uA"] +TagList += ["LARElecCalibMCDAC2uA-"+TagNameForFix] + +ObjectList += ["LAruA2MeVMC#LAruA2MeV#/LAR/ElecCalibMC/uA2MeV"] +TagList += ["LARElecCalibMCuA2MeV-"+TagNameForFix] + +ObjectList += ["LArAutoCorrMC#LArAutoCorr#/LAR/ElecCalibMC/AutoCorr"] +TagList += ["LARElecCalibMCAutoCorr-"+TagNameForFix] + +ObjectList += ["LArNoiseMC#LArNoise#/LAR/ElecCalibMC/Noise"] +TagList += ["LARElecCalibMCNoise-"+TagNameForFix] + +ObjectList += ["LArRampMC#LArRamp#/LAR/ElecCalibMC/Ramp"] +TagList += ["LARElecCalibMCRamp-"+TagNameForFix] + +ObjectList += ["LArShape32MC#LArShape#/LAR/ElecCalibMC/Shape"] +TagList += ["LARElecCalibMCShape-"+TagNameForFix] + +ObjectList += ["LArMinBiasMC#LArMinBias#/LAR/ElecCalibMC/MinBias"] +TagList += ["LARElecCalibMCMinBias-"+TagNameForFix] + +ObjectList += ["LArfSamplMC#LArfSampl#/LAR/ElecCalibMC/fSampl"] +TagList += ["LARElecCalibMCfSampl-"+TagNameForFix] + +ObjectList += ["LArPedestalMC#LArPedestal#/LAR/ElecCalibMC/Pedestal"] +TagList += ["LARElecCalibMCPedestal-"+TagNameForFix] + +OutputPOOLFileName = "LArConditionData_"+TagNameForFix+"_v1.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") +FixLArElecCalib.FixFlag =2 +# FixLArElecCalib.FixFlag =0 + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +LArIdMapFix=7 + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArRawConditions/LArRawConditions_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py") + +DetDescrCnvSvc.LArIDFileName ="IdDictLArCalorimeter_DC3-05-Comm-01.xml" +DetDescrCnvSvc.IdDictFromRDB=False + +#-------------------------------------------------------------- +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +theApp.Dlls += [ "PoolSvc", "AthenaPoolCnvSvc", "AthenaPoolCnvSvcPoolCnv", "EventAthenaPoolPoolCnv", "EventSelectorAthenaPool" ] + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = DEBUG + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = AuditorSvc() +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + # include regstration alg (default is WriteIOV = False) + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + + ToolSvc = Service("ToolSvc") + ToolSvc.ConditionsAlgStream.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.Event1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = Service( "IOVDbSvc" ) + + if (SchemaPrivilege): + # To recreate folder or add DB, need to use schema account: + IOVDbSvc.dbConnection="impl=cool;techno=oracle;schema=ATLAS_COOL_LAR;ATLAS_COOLPROD:OFLP130:ATLAS_COOL_LAR:" + else: + # For db writing + IOVDbSvc.dbConnection="impl=cool;techno=oracle;schema=ATLAS_COOL_LAR;ATLAS_COOLPROD:OFLP130:ATLAS_COOL_LAR_W:" + + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + if (RecreateFolder): + IOVRegSvc.RecreateFolders = True +########################################################################### + +DetDescrCnvSvc.MuonIDFileName = "IdDictMuonSpectrometer_R.01.xml" +# In case Id checks are needed, uncomment: +# DetDescrCnvSvc.DoIdChecks = True; + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix16_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix16_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..a19f8e009a546b6bc540aba210f7e4ff32b59f1e --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix16_jobOptions.py @@ -0,0 +1,120 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=999999 +EventSelector.EventsPerRun=10; +EventSelector.FirstEvent=1 + + +LArIOVDbTag = "CONDBR2-ES1PA-2016-03" +DetDescrVersion='ATLAS-GEO-20-00-00' + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.ConditionsTag.set_Value_and_Lock(LArIOVDbTag) +globalflags.DetDescrVersion.set_Value_and_Lock(DetDescrVersion) +# Set the connection string +include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) +IOVDbSvc.GlobalTag=LArIOVDbTag + + +#-------------------------------------------------------------- +# Detector Description +#-------------------------------------------------------------- +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion=DetDescrVersion + +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +RunNumber = 999999 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + +from LArConditionsTest.LArConditionsTestConf import FixLArElecCalib +topSequence += FixLArElecCalib() +FixLArElecCalib = topSequence.FixLArElecCalib +# fix16 for EMEC-A FT 7 cable swap +FixLArElecCalib.FixFlag = 16 + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector.RunNumber=RunNumber +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +theApp.EvtMax=1 + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + + + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + ["AthenaAttributeList#/LAR/Identifier/OnOffIdMap", + ], + ["LARIdentifierOnOffIdMap_EMECASwap", + ], + True) + +OutputConditionsAlg.Run1 = 0 + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False +svcMgr.IOVRegistrationSvc.userTags = True + +svcMgr.IOVRegistrationSvc.OverrideNames += ["OnlineHashToOfflineId",] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=LArOnOfIdMap_EMECSwap.db;dbname=CONDBR2" + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix17_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix17_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..3df1c8c96dc8241214ddd44bf521bbc3ae2a4d9b --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix17_jobOptions.py @@ -0,0 +1,145 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +if 'InputFile' not in dir(): + InputFile='shape.txt' + +if 'OutputDb' not in dir(): + OutputDb='LArElecCalib_NewShape_v2.db' + +if 'Version' not in dir(): + Version='3' + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=308000 +EventSelector.EventsPerRun=10; +EventSelector.FirstEvent=1 + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = svcMgr.AuditorSvc +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +DetDescrVersion='ATLAS-GEO-20-00-00' +LArIOVDbTag = "CONDBR2-ES1PA-2016-03" + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.ConditionsTag.set_Value_and_Lock(LArIOVDbTag) +globalflags.DetDescrVersion.set_Value_and_Lock(DetDescrVersion) +include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) +IOVDbSvc.GlobalTag=LArIOVDbTag + + +#-------------------------------------------------------------- +# Detector Description +#-------------------------------------------------------------- +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion=DetDescrVersion + +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + + +RunNumber = 308000 +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + +TagNameForFix = "SpecRun" + +ObjectList += ["LArShape32MC#LArShape#/LAR/ElecCalibOfl/LArPileupShape"] + +TagList += ["LARElecCalibOflLArPileupShape-RUN2-"+TagNameForFix] + +OutputPOOLFileName = "LArElecCalib_"+TagNameForFix+"_v"+Version+".pool.root" + +from LArConditionsTest.LArConditionsTestConf import FixLArElecCalib +topSequence += FixLArElecCalib() +FixLArElecCalib = topSequence.FixLArElecCalib +FixLArElecCalib.FixFlag = 17 +FixLArElecCalib.InputFile = InputFile + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_comm_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +#-------------------------------------------------------------- + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +conddb.addFolder("LAR_OFL","/LAR/ElecCalibOfl/LArPileupShape") + +theApp.EvtMax=1 + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + include("RegistrationServices/IOVRegistrationSvc_jobOptions.py") + + from AthenaCommon.AlgSequence import AlgSequence + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + topSequence += OutputConditionsAlg() + OutputConditionsAlg = topSequence.OutputConditionsAlg + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + svcMgr.ToolSvc.OutputConditionsAlgTool.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + + svcMgr.IOVDbSvc.dbConnection="sqlite://;schema="+OutputDb+";dbname=CONDBR2" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = svcMgr.IOVRegistrationSvc + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + +########################################################################### + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix18_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix18_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..4048c7ce3ce70b11d0a94bcb118b1634742bfa00 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix18_jobOptions.py @@ -0,0 +1,106 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +# This should scale Ped+Ramp for SC + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + +if 'OutputDB' not in dir(): + OutputDB="sqlite://;schema=EMFCalibMap.db;dbname=CONDBR2" + +if 'OutputFolder' not in dir(): + OutputFolder="/LAR/Identifier/CalibIdMap_EMF" + +if 'OutTag' not in dir(): + OutTag="LARIdentifierCalibIdMap-EMF" + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-R2-2015-03-01-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() #Switched off to avoid geometry +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +# for testing +conddb.addMarkup("/LAR/Identifier/CalibIdMap","sqlite://;schema=/afs/cern.ch/user/p/pavol/public/EMF_CalibMap.db;dbname=CONDBR2LARIdentifierCalibIdMap-EMF") + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + + +from LArConditionsTest.LArConditionsTestConf import FixLArElecCalib +fix=FixLArElecCalib(OutputLevel=DEBUG) +fix.FixFlag = 18 +topSequence+=fix + +outObjects=[] +outTags=[] + +outObjects += ["AthenaAttributeList#"+OutputFolder] +outTags+=[OutTag] + +theApp.EvtMax = 1 + +#svcMgr.IOVDbSvc.GlobalTag = "COMCOND-BLKPA-RUN1-07" +svcMgr.IOVDbSvc.GlobalTag = "CONDBR2-BLKPA-2015-18" +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + +theOutputConditionsAlgRec=OutputConditionsAlg("OutputConditionsAlgInline","dummy.root", + outObjects,outTags,True) + + +svcMgr.IOVDbSvc.dbConnection = OutputDB +svcMgr.IOVDbSvc.DBInstance="" + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder=False +svcMgr.IOVRegistrationSvc.OverrideNames += [ "OnlineHashToCalibIds" ] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; + +svcMgr.DetectorStore.Dump=True + +if 'poolcat' in dir(): + svcMgr.PoolSvc.WriteCatalog="xmlcatalog_file:"+poolcat + +svcMgr.MessageSvc.defaultLimit=9999999999 +svcMgr.MessageSvc.OutputLevel=INFO diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix3_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix3_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..f5286d67ab41d7efa1d4bb716fe4d98bfcd25612 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix3_jobOptions.py @@ -0,0 +1,139 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.InputFormat.set_pool() +GlobalFlags.DetGeo.set_atlas() + + +DetDescrVersion = "ATLAS-CSC-02-00-00" +G4Phys ="QGSP_BERT" + +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + + +# FIX +if DetDescrVersion == "ATLAS-CSC-02-00-00" : + TagNameForFix = "CSC02-C-"+G4Phys +elif DetDescrVersion == "ATLAS-DC3-05" : + TagNameForFix = "CSC01-C-"+G4Phys +else : + TagNameForFix = "Wrong" + print " ERROR: wrong DetDescrVersion" + + +ObjectList += ["LArfSamplMC#LArfSampl#/LAR/ElecCalibMC/fSampl"] +TagList += ["LARElecCalibMCfSampl-"+TagNameForFix] + +OutputPOOLFileName = "LArfSampl_1302_v3.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") +FixLArElecCalib.FixFlag =3 +FixLArElecCalib.G4Phys =G4Phys +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = DEBUG + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = AuditorSvc() +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + # include regstration alg (default is WriteIOV = False) + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + + ToolSvc = Service("ToolSvc") + ToolSvc.ConditionsAlgStream.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = Service( "IOVDbSvc" ) + + IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArElecCalib_G4Phys_v3.db;X:OFLP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + + PoolSvc.FileOpen = "update" +########################################################################### + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix4_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix4_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..15ac176ab22763fd23c7c096d7d5050cf86d2b79 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix4_jobOptions.py @@ -0,0 +1,131 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.InputFormat.set_pool() +GlobalFlags.DetGeo.set_atlas() + + +DetDescrVersion = "ATLAS-CSC-02-00-00" + +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + +TagNameForFix = "comm-04-A" + +ObjectList += ["LAruA2MeVMC#LAruA2MeV#/LAR/ElecCalib/uA2MeV/Symmetry"] +ObjectList += ["LArDAC2uAMC#LArDAC2uA#/LAR/ElecCalib/DAC2uA/Symmetry"] + +TagList += ["LARElecCalibuA2MeVSymmetry-"+TagNameForFix] +TagList += ["LARElecCalibDAC2uASymmetry-"+TagNameForFix] + +OutputPOOLFileName = "LArDACuAMeV_"+TagNameForFix+"_v1.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") +FixLArElecCalib.OutputLevel = DEBUG +FixLArElecCalib.FixFlag = 4 +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = INFO + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = AuditorSvc() +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + # include regstration alg (default is WriteIOV = False) + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + + ToolSvc = Service("ToolSvc") + ToolSvc.ConditionsAlgStream.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = Service( "IOVDbSvc" ) + + IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArElecCalib_DACuAMeV.db;X:COMP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + +########################################################################### + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix5_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix5_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..3e91abc83197e50110f67ff46fa5b7487e04d648 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix5_jobOptions.py @@ -0,0 +1,135 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.InputFormat.set_pool() +GlobalFlags.DetGeo.set_atlas() + + +DetDescrVersion = "ATLAS-CSC-02-00-00" + +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + + +# FIX +if DetDescrVersion == "ATLAS-CSC-02-00-00" : + TagNameForFix = "CSC02-E" +else : + TagNameForFix = "Wrong" + print " ERROR: wrong DetDescrVersion" + +ObjectList += ["LArNoiseMC#LArNoise#/LAR/ElecCalibMC/Noise"] +ObjectList += ["LArMinBiasMC#LArMinBias#/LAR/ElecCalibMC/MinBias"] + +TagList += ["LARElecCalibMCNoise-"+TagNameForFix] +TagList += ["LARElecCalibMCMinBias-"+TagNameForFix] + +OutputPOOLFileName = "LArFCalNoise_13.0.30_v2.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") +FixLArElecCalib.FixFlag =5 +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = INFO + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = AuditorSvc() +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + # include regstration alg (default is WriteIOV = False) + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + + ToolSvc = Service("ToolSvc") + ToolSvc.ConditionsAlgStream.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = Service( "IOVDbSvc" ) + + IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArElecCalib_FCalNoise.db;X:OFLP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix6_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix6_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e133c603eea593d7556c73d9240d6395f84ba1bc --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix6_jobOptions.py @@ -0,0 +1,145 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.InputFormat.set_pool() +GlobalFlags.DetGeo.set_atlas() + + +DetDescrVersion = "ATLAS-CSC-02-00-00" + +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + + +# FIX +if DetDescrVersion == "ATLAS-CSC-02-00-00" : + TagNameForFix = "CSC02-F" +else : + TagNameForFix = "Wrong" + import logging + logger = logging.getLogger('fix6_jobOptions') + logger.setLevel(logging.ERROR) + logger.error(" wrong DetDescrVersion") + +ObjectList += ["LArNoiseMC#LArNoise#/LAR/ElecCalibMC/Noise"] +ObjectList += ["LAruA2MeVMC#LAruA2MeV#/LAR/ElecCalibMC/uA2MeV"] +ObjectList += ["LArDAC2uAMC#LArDAC2uA#/LAR/ElecCalibMC/DAC2uA"] +ObjectList += ["LArRampMC#LArRamp#/LAR/ElecCalibMC/Ramp"] + + +TagList += ["LARElecCalibMCNoise-"+TagNameForFix] +TagList += ["LARElecCalibMCuA2MeV-"+TagNameForFix] +TagList += ["LARElecCalibMCDAC2uA-"+TagNameForFix] +TagList += ["LARElecCalibMCRamp-"+TagNameForFix] + +OutputPOOLFileName = "LArFCalADC2MeV_13.0.30_v1.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") +FixLArElecCalib.FixFlag =6 +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector = Service( "EventSelector" ) +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = INFO + +MessageSvc = Service( "MessageSvc" ) +MessageSvc.OutputLevel = INFO +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = AuditorSvc() +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + # include regstration alg (default is WriteIOV = False) + include("RegistrationServices/OutputConditionsAlg_jobOptions.py") + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + + ToolSvc = Service("ToolSvc") + ToolSvc.ConditionsAlgStream.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = Service( "IOVDbSvc" ) + + IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArElecCalib_FCalADC2MeV.db;X:OFLP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + + # PoolSvc.FileOpen = "update" +########################################################################### + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix7_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix7_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..94f9052e7ba1c560e3e38a7ca7e2342d6ef41795 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix7_jobOptions.py @@ -0,0 +1,148 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOn() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.InputFormat.set_pool() +GlobalFlags.DetGeo.set_atlas() + +G4Phys ="QGSP_BERT" +LArfSamplG4Phys = G4Phys + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion="ATLAS-CSC-02-00-00" + +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + + +# FIX +if jobproperties.Global.DetDescrVersion() == "ATLAS-CSC-02-00-00" : + TagNameForFix = "CSC02-D-"+G4Phys +elif jobproperties.Global.DetDescrVersion() == "ATLAS-DC3-05" : + TagNameForFix = "CSC01-D-"+G4Phys +else : + TagNameForFix = "Wrong" + import logging + logger = logging.getLogger('fix7_jobOptions') + logger.setLevel(logging.ERROR) + logger.error(" wrong DetDescrVersion") + + +ObjectList += ["LArfSamplMC#LArfSampl#/LAR/ElecCalibMC/fSampl"] +TagList += ["LARElecCalibMCfSampl-"+TagNameForFix] + +OutputPOOLFileName = "LArfSampl_1303_v1.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- + +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArElecCalib" ] +FixLArElecCalib = Algorithm("FixLArElecCalib") + +# 2=fix for IdMapFix=1 +# 3=new fsample for CSC-02 +# 7 = fsampl from 13.0.30 +topSequence.FixLArElecCalib.FixFlag =7 +topSequence.FixLArElecCalib.G4Phys =G4Phys +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- +theApp.Dlls += [ "LArTools" ] + +include ("AtlasGeoModel/SetGeometryVersion.py") +include ("AtlasGeoModel/GeoModelInit.py") + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +AthenaEventLoopMgr=Service("AthenaEventLoopMgr") +AthenaEventLoopMgr.OutputLevel = DEBUG + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = INFO +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + include( "RegistrationServices/IOVRegistrationSvc_jobOptions.py" ) + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + topSequence += OutputConditionsAlg(outputFile=OutputPOOLFileName) + + # List of objects container type#key#foldername + topSequence.OutputConditionsAlg.ObjectList = ObjectList + topSequence.OutputConditionsAlg.IOVTagList = TagList + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + + topSequence.OutputConditionsAlg.WriteIOV = WriteIOV + topSequence.OutputConditionsAlg.Run1 = 0 + topSequence.OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + IOVDbSvc = svcMgr.IOVDbSvc + + IOVDbSvc.dbConnection="sqlite://X;schema=LArElecCalib_13.0.30_v1.db;dbname=OFLP200" + + # For schema creation - only should be used when creating the folder + # i.e. the first time + IOVRegSvc = svcMgr.IOVRegistrationSvc + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + + PoolSvc.FileOpen = "update" + +AthenaEventLoopMgr.ClearStorePolicy = "BeginEvent" + +########################################################################### + + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix8_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix8_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e082d2f11da0cc533437196fc3ec44bde3746ccb --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix8_jobOptions.py @@ -0,0 +1,149 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=10; +EventSelector.FirstEvent=1 + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = svcMgr.AuditorSvc +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DetGeo.set_atlas() + +#-------------------------------------------------------------- +# Detector Description +#-------------------------------------------------------------- +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion="ATLAS-CSC-02-00-00" + +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + + +LArIOVDbTag = "CSC02-H-QGSP_BERT" +RunNumber = 1 + +# +RecreateFolder = False +WriteIOV = True + +# Objects and its tag +ObjectList = [] +TagList = [] + +TagNameForFix = "CSC02-I" + +ObjectList += ["LArNoiseMC#LArNoise#/LAR/ElecCalibMC/Noise"] +ObjectList += ["LAruA2MeVMC#LAruA2MeV#/LAR/ElecCalibMC/uA2MeV"] +ObjectList += ["LArDAC2uAMC#LArDAC2uA#/LAR/ElecCalibMC/DAC2uA"] +ObjectList += ["LArRampMC#LArRamp#/LAR/ElecCalibMC/Ramp"] +ObjectList += ["LArShape32MC#LArShape#/LAR/ElecCalibMC/Shape"] +ObjectList += ["LArAutoCorrMC#LArAutoCorr#/LAR/ElecCalibMC/AutoCorr"] +ObjectList += ["LArMphysOverMcalMC#LArMphysOverMcal#/LAR/ElecCalibMC/MphysOverMcal"] + +TagList += ["LARElecCalibMCNoise-"+TagNameForFix] +TagList += ["LARElecCalibMCuA2MeV-"+TagNameForFix] +TagList += ["LARElecCalibMCDAC2uA-"+TagNameForFix] +TagList += ["LARElecCalibMCRamp-"+TagNameForFix] +TagList += ["LARElecCalibMCShape-"+TagNameForFix] +TagList += ["LARElecCalibMCAutoCorr-"+TagNameForFix] +TagList += ["LARElecCalibMCMphysOverMcal-"+TagNameForFix] + +OutputPOOLFileName = "LArElecCalib_"+TagNameForFix+"_v1.pool.root" + +from LArConditionsTest.LArConditionsTestConf import FixLArElecCalib +topSequence += FixLArElecCalib() +FixLArElecCalib = topSequence.FixLArElecCalib +# fix8 for updating EM/HEC calib for rel 14. +FixLArElecCalib.FixFlag =8 + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector.RunNumber=1 +#EventSelector.EventsPerRun=10; +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + include("RegistrationServices/IOVRegistrationSvc_jobOptions.py") + + from AthenaCommon.AlgSequence import AlgSequence + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + topSequence += OutputConditionsAlg() + OutputConditionsAlg = topSequence.OutputConditionsAlg + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + svcMgr.ToolSvc.OutputConditionsAlgTool.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + #### + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + + svcMgr.IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArElecCalib_CSC02-I.db;X:OFLP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = svcMgr.IOVRegistrationSvc + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = RecreateFolder + +########################################################################### + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix9_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix9_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..ab3bb3785eae352c62140b800445e25091b06bc8 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecCalib_fix9_jobOptions.py @@ -0,0 +1,121 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=1 +EventSelector.EventsPerRun=10; +EventSelector.FirstEvent=1 + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = svcMgr.AuditorSvc +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + +LArIOVDbTag = "OFLCOND-SDR-BS7T-05-12" +DetDescrVersion='ATLAS-GEO-18-01-03' + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.DataSource.set_Value_and_Lock('geant4') +globalflags.ConditionsTag.set_Value_and_Lock(LArIOVDbTag) +globalflags.DetDescrVersion.set_Value_and_Lock(DetDescrVersion) +# Set the connection string +include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) +IOVDbSvc.GlobalTag=LArIOVDbTag + + +#-------------------------------------------------------------- +# Detector Description +#-------------------------------------------------------------- +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion=DetDescrVersion + +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +RunNumber = 1 + +RecreateFolder = False +WriteIOV = True + +from LArConditionsTest.LArConditionsTestConf import FixLArElecCalib +topSequence += FixLArElecCalib() +FixLArElecCalib = topSequence.FixLArElecCalib +FixLArElecCalib.FixFlag = 13 + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +#-------------------------------------------------------------- +EventSelector.RunNumber=RunNumber +EventSelector.EventsPerRun=2 +EventSelector.FirstEvent=1 + + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) +# AthenaSealSvc.CheckDictAtInit = True + +#include ("LArRawConditions/LArRawConditionsDict_joboptions.py") +#include ("LArTools/LArToolsDict_joboptions.py") + +theApp.EvtMax=1 + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = DEBUG +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + + + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + ["AthenaAttributeList#/LAR/IdentifierOfl/OnOffIdMap_SC", + ], + ["LARIdentifierOflOnOffIdMap_SC-000", + ], + True) + +OutputConditionsAlg.Run1 = 0 + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False +svcMgr.IOVRegistrationSvc.userTags = False + +svcMgr.IOVRegistrationSvc.OverrideNames += ["OnlineHashToOfflineId",] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=LArSCIdentifierMaps.db;dbname=OFLP200" + diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix1_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix1_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..7183ed5df07c5e382d60f4071be0f7744720ba08 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix1_jobOptions.py @@ -0,0 +1,149 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +# This should scale Ped+Ramp for SC + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + +if 'InputDB' not in dir(): + InputDB="COOLOFL_LAR/OFLP200" + +if 'InputFolder' not in dir(): + InputFolder="/LAR/ElecCalibMCSC/Pedestal" + +if 'InputKey' not in dir(): + InputKey="Pedestal_orig" + +if 'InTag' not in dir(): + InTag="LARElecCalibMCSCPedestal-000" + +if 'InputFolderRamp' not in dir(): + InputFolderRamp="/LAR/ElecCalibMCSC/Ramp" + +if 'InputKeyRamp' not in dir(): + InputKeyRamp="Ramp_orig" + +if 'InTagRamp' not in dir(): + InTagRamp="LARElecCalibMCSCRamp-mV-LSB" + +if 'OutputDB' not in dir(): + OutputDB="sqlite://;schema=newConstants.db;dbname=OFLP200" + +if 'OutputFolder' not in dir(): + OutputFolder="/LAR/ElecCalibMCSC/Pedestal" + +if 'OutputKey' not in dir(): + OutputKey="Pedestal" + +if 'OutTag' not in dir(): + OutTag="LARElecCalibMCSCPedestal-000_scaled" + +if 'OutputFolderRamp' not in dir(): + OutputFolderRamp="/LAR/ElecCalibMCSC/Ramp" + +if 'OutputKeyRamp' not in dir(): + OutputKeyRamp="Ramp" + +if 'OutTagRamp' not in dir(): + OutTagRamp="LARElecCalibMCSCRamp-mV-LSB_scaled" + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-R2-2015-03-01-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() #Switched off to avoid geometry +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + +conddb.addFolder("",""+InputDB+""+InputFolder+""+InTag+"Pedestal_in") +conddb.addFolder("",""+InputDB+""+InputFolderRamp+""+InTagRamp+"Ramp_in") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc +if not hasattr(svcMgr,"LArFlatConditionSvc"): + svcMgr+=LArFlatConditionSvc() + svcMgr.ProxyProviderSvc.ProviderNames += [ "LArFlatConditionSvc" ] + svcMgr.LArFlatConditionSvc.DoSuperCells=True + svcMgr.LArFlatConditionSvc.PedestalSCInput="Pedestal_in" + svcMgr.LArFlatConditionSvc.PedestalSCOutput=InputKey + svcMgr.LArFlatConditionSvc.RampSCInput="Ramp_in" + svcMgr.LArFlatConditionSvc.RampSCOutput=InputKeyRamp + +from LArConditionsTest.LArConditionsTestConf import FixLArElecSCCalib +fix=FixLArElecSCCalib(OutputLevel=DEBUG) +fix.FixFlag = 1 +fix.FixFactor = 0.9 +topSequence+=fix + +outObjects=[] +outTags=[] + +outObjects += ["CondAttrListCollection#/LAR/ElecCalibMCSC/Pedestal"] +outTags+=[OutTag] +outObjects += ["CondAttrListCollection#/LAR/ElecCalibMCSC/Ramp"] +outTags+=[OutTagRamp] + +theApp.EvtMax = 1 + +svcMgr.IOVDbSvc.GlobalTag = "CONDBR2-BLKPA-2015-18" +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + +theOutputConditionsAlgRec=OutputConditionsAlg("OutputConditionsAlgInline","dummy.root", + outObjects,outTags,True) + + +svcMgr.IOVDbSvc.dbConnection = OutputDB +svcMgr.IOVDbSvc.DBInstance="" + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder=False +svcMgr.IOVRegistrationSvc.OverrideNames += [ "Pedestal","PedestalRMS","OFCa" ,"OFCb" ,"TimeOffset","RampVec","Shape","ShapeDer","HVScaleCorr","MphysOverMcal","DAC2uA","uA2MeV"] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; + +svcMgr.DetectorStore.Dump=True + +if 'poolcat' in dir(): + svcMgr.PoolSvc.WriteCatalog="xmlcatalog_file:"+poolcat + +svcMgr.MessageSvc.defaultLimit=9999999999 diff --git a/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix2_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix2_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..3ec5407b2bbc8eb682b420b1f218941f8ec91978 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArElecSCCalib_fix2_jobOptions.py @@ -0,0 +1,116 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +# This should scale Ped+Ramp for SC + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + +if 'InputDB' not in dir(): + InputDB="COOLOFL_LAR/OFLP200" + +if 'InputFolder' not in dir(): + InputFolder="/LAR/IdentifierOfl/OnOffIdMap_SC" + +if 'InTag' not in dir(): + InTag="LARIdentifierOflOnOffIdMap_SC-000" + +if 'OutputDB' not in dir(): + OutputDB="sqlite://;schema=SCCalibMap.db;dbname=OFLP200" + +if 'OutputFolder' not in dir(): + OutputFolder="/LAR/IdentifierOfl/CalibIdMap_SC" + +if 'OutTag' not in dir(): + OutTag="LARIdentifierOflCalibIdMap_SC-000" + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-R2-2015-03-01-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() #Switched off to avoid geometry +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + +conddb.addFolder("",""+InputDB+""+InputFolder+""+InTag+"") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArCabling.LArCablingConf import LArSuperCellCablingTool +ToolSvc+=LArSuperCellCablingTool(LArOnOffIdFolder=InputFolder,OutputLevel=DEBUG) + + +from LArConditionsTest.LArConditionsTestConf import FixLArElecSCCalib +fix=FixLArElecSCCalib(OutputLevel=DEBUG) +fix.FixFlag = 2 +topSequence+=fix + +outObjects=[] +outTags=[] + +outObjects += ["AthenaAttributeList#"+OutputFolder] +outTags+=[OutTag] + +theApp.EvtMax = 1 + +svcMgr.IOVDbSvc.GlobalTag = "CONDBR2-BLKPA-2015-18" +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + +theOutputConditionsAlgRec=OutputConditionsAlg("OutputConditionsAlgInline","dummy.root", + outObjects,outTags,True) + + +svcMgr.IOVDbSvc.dbConnection = OutputDB +svcMgr.IOVDbSvc.DBInstance="" + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder=False +svcMgr.IOVRegistrationSvc.OverrideNames += [ "OnlineHashToCalibIds" ] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; + +svcMgr.DetectorStore.Dump=True + +if 'poolcat' in dir(): + svcMgr.PoolSvc.WriteCatalog="xmlcatalog_file:"+poolcat + +svcMgr.MessageSvc.defaultLimit=9999999999 +svcMgr.MessageSvc.OutputLevel=INFO diff --git a/LArCalorimeter/LArCondTools/share/FixLArIdMap_jobOptions.py b/LArCalorimeter/LArCondTools/share/FixLArIdMap_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..fe89773eac37989e49c3ed25f6bf137307f77ae3 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/FixLArIdMap_jobOptions.py @@ -0,0 +1,146 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### +# +#============================================================== +#use McEventSelector +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + +EventSelector = svcMgr.EventSelector +EventSelector.RunNumber=300000 +EventSelector.EventsPerRun=10; +EventSelector.FirstEvent=1 + +theApp.Dlls += [ "GaudiAud" ] +theAuditorSvc = svcMgr.AuditorSvc +theAuditorSvc.Auditors = [ "ChronoAuditor" ] + + +from AthenaCommon.GlobalFlags import GlobalFlags +GlobalFlags.DataSource.set_geant4() +GlobalFlags.DetGeo.set_atlas() + +#-------------------------------------------------------------- +# Detector Description +#-------------------------------------------------------------- +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = 'ATLAS-CommNF-04-00-00' + +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +# svcMgr.IOVDbSvc.GlobalTag = "COMCOND-006-00" + +# These flags should remain false,if you just want to write new objects +RecreateFolder = False +SchemaPrivilege = False + +# Objects and its tag +ObjectList = [] +TagList = [] + +OnOffIdTag = "test" +FebRodTag = "test" + +# Turn on flag for writing to COOL IOV +WriteIOV = True + +if "OnOffIdTag" in dir() : + ObjectList +=["LArOnOffIdMap#LArOnOffIdMapAtlas#/LAR/Identifier/OnOffIdAtlas"] + TagList += ["LARIdentifierOnOffIdAtlas-"+OnOffIdTag] + +elif "FebRodTag" in dir() : + ObjectList += ["LArFebRodMap#LArFebRodMapAtlas#/LAR/Identifier/FebRodAtlas"] + TagList += ["LARIdentifierFebRodAtlas-"+FebRodTag] + +OutputPOOLFileName = "LArIdMapFix_test.pool.root" + +#/-------------------------------------------------------------- +# Algorithm to fix the LAr Id, if needed +#/------------------------------- +theApp.Dlls += [ "LArConditionsTest" ] +theApp.TopAlg += [ "FixLArIdMap" ] +FixLArIdMap = Algorithm("FixLArIdMap") +FixLArIdMap.FixFlag = 0 +FixLArIdMap.OutputLevel = 2 + +FixLArIdMap.DumpIds = True + + +#-------------------------------------------------------------- +# Private Application Configuration options +#-------------------------------------------------------------- + +# Other LAr related +include( "LArIdCnv/LArIdCnv_joboptions.py" ) +include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + +include( "LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py" ) +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +theApp.Dlls += [ "LArTools" ] + + +include( "AthenaPoolCnvSvc/AthenaPool_jobOptions.py" ) + +theApp.Dlls += [ "AthenaPoolCnvSvc" ] +theApp.Dlls += [ "LArCondAthenaPoolPoolCnv" ] +include( "AthenaSealSvc/AthenaSealSvc_joboptions.py" ) + +include ("LArRawConditions/LArRawConditionsDict_joboptions.py") + +theApp.EvtMax=1 + +MessageSvc = svcMgr.MessageSvc +MessageSvc.OutputLevel = INFO +MessageSvc.defaultLimit = 1000000; +MessageSvc.Format = "% F%20W%S%7W%R%T %0W%M" + +############################################## +# Writing POOL and COOL +if len(ObjectList)>0 : + + include("RegistrationServices/IOVRegistrationSvc_jobOptions.py") + + from AthenaCommon.AlgSequence import AlgSequence + from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg + topSequence += OutputConditionsAlg() + OutputConditionsAlg = topSequence.OutputConditionsAlg + + # List of objects container type#key#foldername + OutputConditionsAlg.ObjectList = ObjectList + OutputConditionsAlg.IOVTagList = TagList + svcMgr.ToolSvc.OutputConditionsAlgTool.OutputFile = OutputPOOLFileName + + # Set flag to register and run interval Run1/Event1 to Run2/Event2 + # Usually, only need to set Run1, others go to default + # # + + OutputConditionsAlg.WriteIOV = WriteIOV + OutputConditionsAlg.Run1 = 0 + OutputConditionsAlg.LB1 = 0 + + # OutputConditionsAlg.Run2 = 56411 + + # Set the connection string + include ( "IOVDbSvc/IOVDbSvc_jobOptions.py" ) + + svcMgr.IOVDbSvc.dbConnection="impl=cool;techno=sqlite;schema=LArIdMapFix_test.db;X:OFLP200" + + # For schema creation - only should be used when creating the folder, + # i.e. the first time + IOVRegSvc = Service( "IOVRegistrationSvc" ) + IOVRegSvc.OutputLevel = DEBUG + IOVRegSvc.RecreateFolders = False + diff --git a/LArCalorimeter/LArCondTools/share/LArIdMapConvert.py b/LArCalorimeter/LArCondTools/share/LArIdMapConvert.py new file mode 100644 index 0000000000000000000000000000000000000000..cce0dc0473a78e7f2c52f9f3f3964cd54392d4d5 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/LArIdMapConvert.py @@ -0,0 +1,70 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) +include("LArCalibProcessing/LArCalib_MinimalSetup.py") + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + + + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArConditionsTest.LArConditionsTestConf import LArIdMapConvert +topSequence+=LArIdMapConvert() + +from LArConditionsTest.LArConditionsTestConf import LArFebRodMapConvert +topSequence+=LArFebRodMapConvert() + + +theApp.EvtMax = 1 + +svcMgr.IOVDbSvc.GlobalTag = "COMCOND-BLKPA-006-05" + + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + ["AthenaAttributeList#/LAR/Identifier/OnOffIdMap", + "AthenaAttributeList#/LAR/Identifier/CalibIdMap", + "AthenaAttributeList#/LAR/Identifier/FebRodMap" + ], + ["LARIdentifierOnOffIdMap-000", + "LARIdentifierCalibIdMap-000", + "LARIdentifierFebRodMap-000", + ], + True) + +OutputConditionsAlg.Run1 = beginRun + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False +svcMgr.IOVRegistrationSvc.userTags = False + +svcMgr.IOVRegistrationSvc.OverrideNames += ["OnlineHashToOfflineId","OnlineHashToCalibIds", ] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=LArIdentifierMaps.db;dbname=COMP200" + diff --git a/LArCalorimeter/LArCondTools/share/LArOFCtoOFC.py b/LArCalorimeter/LArCondTools/share/LArOFCtoOFC.py new file mode 100644 index 0000000000000000000000000000000000000000..d5d64790a227a4fd901ecc7de1d902f0f2e79102 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/LArOFCtoOFC.py @@ -0,0 +1,146 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +# This should convert some samples OFC to another samples one, by adding NullsToAdd nulls + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + +if 'HECShift' not in dir(): + HECShift=True + +if 'NullsToAdd' not in dir(): + NullsToAdd=1 + +if 'doShape' not in dir(): + doShape=False + +if 'InputDB' not in dir(): + InputDB="sqlite://;schema=freshConstants_repro_comp200.db;dbname=COMP200" + +if 'InputFolder' not in dir(): + InputFolder="/LAR/ElecCalibOfl/OFC/PhysWave/RTM/4samples1phase" + +if doShape and 'InputShapeFolder' not in dir(): + InputShapeFolder="/LAR/ElecCalibOfl/Shape/RTM/4samples1phase" + +if 'InputKey' not in dir(): + InputKey="LArOFC_4_0_mu_picked" + +if doShape and 'InputShapeKey' not in dir(): + InputShapeKey="LArShape_4_0_picked" + +if 'InTagSuffix' not in dir(): + InTagSuffix="-mu-20-RUN2-UPD3-00" + +if doShape and 'InShapeTagSuffix' not in dir(): + InShapeTagSuffix="-corr-RUN2-UPD3-00" + +if 'OutputDB' not in dir(): + OutputDB="sqlite://;schema=freshConstants_repro.db;dbname=CONDBR2" + +if 'OutputFolder' not in dir(): + OutputFolder="/LAR/ElecCalibOfl/OFC/PhysWave/RTM/5samples1phase" + +if doShape and 'OutputShapeFolder' not in dir(): + OutputShapeFolder="/LAR/ElecCalibOfl/Shape/RTM/5samples1phase" + +if 'OutputKey' not in dir(): + OutputKey="LArOFC" + +if doShape and 'OutputShapeKey' not in dir(): + OutputShapeKey="LArShape" + +if 'OutTagSuffix' not in dir(): + OutTagSuffix="_mu_20-repro-2012" + +if doShape and 'OutShapeTagSuffix' not in dir(): + OutShapeTagSuffix="_mu_20-repro-2012" + +if 'OutputPoolFile' not in dir(): + OutputPoolFile="LArOFC_5s_from_4s_"+str(beginRun)+".pool.root" + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('data') +globalflags.InputFormat.set_Value_and_Lock('bytestream') +globalflags.DatabaseInstance.set_Value_and_Lock('CONDBR2') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-21-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() #Switched off to avoid geometry +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping +include( "LArConditionsCommon/LArIdMap_comm_jobOptions.py" ) + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + +conddb.addFolder("",""+InputDB+""+InputKey+""+InputFolder+""+join(split(InputFolder, '/'),'')+InTagSuffix+"") +if doShape: + conddb.addFolder("",""+InputDB+""+InputShapeKey+""+InputShapeFolder+""+join(split(InputShapeFolder, '/'),'')+InShapeTagSuffix+"") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArConditionsTest.LArConditionsTestConf import LArOFCtoOFC +theLArOFCtoOFC=LArOFCtoOFC(OutputLevel=DEBUG) +theLArOFCtoOFC.inKey = InputKey +theLArOFCtoOFC.outKey = OutputKey +if doShape: + theLArOFCtoOFC.doShape=doShape + theLArOFCtoOFC.inShapeKey=InputShapeKey + theLArOFCtoOFC.outShapeKey=OutputShapeKey + +theLArOFCtoOFC.ShiftHEC = HECShift +theLArOFCtoOFC.NullsAdded = NullsToAdd +topSequence+=theLArOFCtoOFC + +theApp.EvtMax = 1 + +svcMgr.IOVDbSvc.GlobalTag = "CONDBR2-BLKPA-2015-18" +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutObjects=["LArOFCComplete#"+OutputKey+"#"+OutputFolder] +OutTags=[join(split(OutputFolder, '/'),'') +OutTagSuffix] +if doShape: + OutObjects+=["LArShapeComplete#"+OutputShapeKey+"#"+OutputShapeFolder] + OutTags+=[join(split(OutputShapeFolder, '/'),'') +OutShapeTagSuffix] + +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg",OutputPoolFile, OutObjects,OutTags, True) + +OutputConditionsAlg.Run1 = beginRun + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False +svcMgr.IOVDbSvc.dbConnection = OutputDB + +svcMgr.DetectorStore.Dump=True diff --git a/LArCalorimeter/LArCondTools/share/LArShapeToShapeSC.py b/LArCalorimeter/LArCondTools/share/LArShapeToShapeSC.py new file mode 100644 index 0000000000000000000000000000000000000000..251f9419634b25c440605c95adaf262fd464e6d0 --- /dev/null +++ b/LArCalorimeter/LArCondTools/share/LArShapeToShapeSC.py @@ -0,0 +1,84 @@ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +######################################################################### + +include( "AthenaCommon/Atlas_Gen.UnixStandardJob.py" ) + +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.Luminosity.set_Value_and_Lock('zero') +globalflags.DataSource.set_Value_and_Lock('geant4') +globalflags.InputFormat.set_Value_and_Lock('pool') + +from AthenaCommon.JobProperties import jobproperties +jobproperties.Global.DetDescrVersion = "ATLAS-GEO-20-00-00" + +from AthenaCommon.DetFlags import DetFlags +DetFlags.Calo_setOff() #Switched off to avoid geometry +DetFlags.ID_setOff() +DetFlags.Muon_setOff() +DetFlags.Truth_setOff() +DetFlags.LVL1_setOff() +DetFlags.digitize.all_setOff() + +#Set up GeoModel (not really needed but crashes without) +from AtlasGeoModel import SetGeometryVersion +from AtlasGeoModel import GeoModelInit + +#Get identifier mapping +include( "LArConditionsCommon/LArIdMap_MC_jobOptions.py" ) + +if 'runNumber' not in dir(): + runNumber=2147483647 + +if not 'beginRun' in dir(): + beginRun=0 + + +from McEventSelector.McEventSelectorConf import McEventSelector +svcMgr += McEventSelector("EventSelector") +svcMgr.EventSelector.RunNumber = runNumber +svcMgr.EventSelector.EventsPerRun = 1 +svcMgr.EventSelector.FirstEvent = 0 +svcMgr.EventSelector.InitialTimeStamp = 0 +svcMgr.EventSelector.TimeStampInterval = 1 + + +conddb.addFolder("LAR_OFL","/LAR/ElecCalibMC/Shape") +conddb.addFolder("LAR_OFL","/LAR/IdentifierOfl/OnOffIdMap_SCLARIdentifierOflOnOffIdMap_SC-000") + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) + +from LArConditionsTest.LArConditionsTestConf import LArShapeToSCShape +topSequence+=LArShapeToSCShape(OutputLevel=DEBUG) + +theApp.EvtMax = 1 + +svcMgr.IOVDbSvc.GlobalTag = "OFLCOND-MC12-SIM-08" + +from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg +OutputConditionsAlg=OutputConditionsAlg("OutputConditionsAlg","dummy.pool.root", + ["CondAttrListCollection#/LAR/ElecCalibSC/Shape"], + ["LARElecCalibSCShape-000"], + True) + +OutputConditionsAlg.Run1 = beginRun + + +from RegistrationServices.RegistrationServicesConf import IOVRegistrationSvc +svcMgr += IOVRegistrationSvc() +svcMgr.IOVRegistrationSvc.OutputLevel = DEBUG +svcMgr.IOVRegistrationSvc.RecreateFolders = True +svcMgr.IOVRegistrationSvc.SVFolder = False + +svcMgr.IOVRegistrationSvc.OverrideNames += ["Shape","ShapeDer","TimeOffset" ] +types=[] +for i in range(len(svcMgr.IOVRegistrationSvc.OverrideNames)): + types.append("Blob16M"); +svcMgr.IOVRegistrationSvc.OverrideTypes += types; +svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=LArSCShapes.db;dbname=OFLP200" + +svcMgr.DetectorStore.Dump=True diff --git a/LArCalorimeter/LArCondTools/src/FixLArElecCalib.cxx b/LArCalorimeter/LArCondTools/src/FixLArElecCalib.cxx new file mode 100755 index 0000000000000000000000000000000000000000..552c7b84cbb7ef28779752c96ad37e57f8fac6ff --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/FixLArElecCalib.cxx @@ -0,0 +1,2304 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +/** + @class FixLArElecCalib + @author Hong Ma + @brief fix electronic calibration constants for MC. + + Purpose: read in the LAr electronic calib data, and fix them + ready to be written out again as a new version. + + This should be used with FixLArElecCalib_jobOptions.py to write a new + POOL file. + + Implemented fixes: + + 1. Flag = 1 + Replacing values for barrel in LArDAC2uAMC + Input barrel_dac2ua_oct06.txt + + 2. Flag=2 + fix FCAL conditions data for new mapping in release 13. + + 3. Flag=3 + replace fsampl for 4.8.2 + June 13,2007: FCAL numbers updated by P. Krieger. + Junly 10, 2007: updated the number for 13.0.20 + + 4. Flag=4 + replace uA2MeV DAC2uA with that in dac2ua_ua2mev_rel13.txt + + 5. Flag=5 + replace FCAL noise and minbiasRMS from Sven Menke's new number + for release 13. + + 6 Flag=6 + replace All FCAL noise and ADC2DAC, uA2MeV and DAC2uA. + = 9.96 +/- 0.01 + = 9.67 +/- 0.01 + + 7 Flag=7 + replace sampling fraction for QGSP_BERT from 13.0.30. + + 8 Flag=8 + replace EM/HEC autoCorr, noise, dac2ua, mphys, ramp, shape, ua2mev + + 9 Flag=9 + fix FCAL AutoCorr + + 10 Flag=10 + fix FCAL ramp. The scaling factor were inverted. + Ramp_M = Ramp_H*9.96 + Ramp_L = Ramp_H*9.96*9.67 + + 11 Flag=11 + Update HEC Ramp + + 12 Flag=12 + Fill the LArMinBiasMC and LArMinBiasAverageMC from ntuple created by LArMinBiasAlg (in CaloCondPhysAlgs) + 13 Flag=13 + Filling the OnlOflMap for SC + + 14 Flag=14 + Fill the LArMinBiasAverageMC type in LArPileupAverage folder for BCID correction from ntuple created by LArMinBiasAlg (in CaloCondPhysAlgs) + + 15 Flag=15 + Scale the MinBiasAverage by constant + + 16 Flag=16 + Fix the EMEC-A FT 7 slot 11 OnOfIdMap cable swap + + 17 Flag=17 + replace All shape + + 18 Flag=18 + Fix the calib. line mapping for the EMF, where all channels in EMB-A FT 0 has CL=channel + +**/ + + +#include "FixLArElecCalib.h" +#include "Gaudi/Property.h" +#include "GaudiKernel/IToolSvc.h" + +#include "StoreGate/StoreGateSvc.h" +#include "LArIdentifier/LArOnlineID.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/CaloCell_SuperCell_ID.h" + +#include "LArRawConditions/LArDAC2uAMC.h" +#include "LArRawConditions/LArShape32MC.h" +#include "LArRawConditions/LAruA2MeVMC.h" +#include "LArRawConditions/LArfSamplMC.h" +#include "LArRawConditions/LArMinBiasMC.h" +#include "LArRawConditions/LArMinBiasAverageMC.h" +#include "LArRawConditions/LArNoiseMC.h" +#include "LArRawConditions/LArRampMC.h" +#include "LArRawConditions/LArAutoCorrMC.h" + +#include "CaloDetDescr/ICaloSuperCellIDTool.h" + +#include +#include "TTree.h" +#include "TFile.h" + +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + +FixLArElecCalib::FixLArElecCalib(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name,pSvcLocator), + m_fixFlag(0), + m_em_idhelper(0), + m_hec_idhelper(0), + m_fcal_idhelper(0), + m_online_idhelper(0), + m_sem_idhelper(0), + m_shec_idhelper(0), + m_sfcal_idhelper(0), + m_sonline_idhelper(0), + m_scell_idhelper(0) +{ + + declareProperty("FixFlag", m_fixFlag); + declareProperty("G4Phys", m_g4Phys); + declareProperty("InputFile", m_infile=""); + +} + +StatusCode FixLArElecCalib::initialize() { + ATH_MSG_INFO ( " in initialize " ); + + ATH_CHECK( detStore()->retrieve(m_em_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_hec_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_fcal_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sem_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_shec_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sfcal_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_online_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sonline_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_scell_idhelper) ); + + ATH_CHECK( m_cablingKey.initialize() ); + ATH_CHECK( m_CLKey.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::execute() { + + const EventContext& ctx = Gaudi::Hive::currentContext(); + + SG::ReadCondHandle cablingHdl{m_cablingKey, ctx}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_WARNING( "Do not have cabling mapping from key " << m_cablingKey.key() ); + } + if(m_fixFlag==13) + return fix13(cabling); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::stop() { + + ATH_MSG_INFO ( " in stop " ); + + const EventContext& ctx = Gaudi::Hive::currentContext(); + + SG::ReadCondHandle cablingHdl{m_cablingKey, ctx}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_WARNING( "Do not have cabling mapping from key " << m_cablingKey.key() ); + } + SG::ReadCondHandle clHdl{m_CLKey, ctx}; + const LArCalibLineMapping *clCont {*clHdl}; + if(!clCont) { + ATH_MSG_ERROR( "Do not have calib line mapping !!!" ); + return StatusCode::FAILURE; + } + + + if(m_fixFlag==1) + return fix1(cabling); + if(m_fixFlag==2) + return fix2(cabling); + if(m_fixFlag==3) + return fix3(cabling); + if(m_fixFlag==4) + return fix4(cabling); + if(m_fixFlag==5) + return fix5(cabling); + if(m_fixFlag==6) + return fix6(cabling); + if(m_fixFlag==7) + return fix7(cabling); + if(m_fixFlag==8) + return fix8(cabling); + if(m_fixFlag==9) + return fix9(cabling); + if(m_fixFlag==10) + return fix10(cabling); + if(m_fixFlag==11) + return fix11(cabling); + if(m_fixFlag==12) + return fix12(cabling); + if(m_fixFlag==13) + return fix13(cabling); + if(m_fixFlag==14) + return fix14(cabling); + if(m_fixFlag==15) + return fix15(); + if(m_fixFlag==16) + return fix16(); + if(m_fixFlag==17) + return fix17(cabling); + if(m_fixFlag==18) + return fix18(clCont); + + return StatusCode::SUCCESS; + +} + +StatusCode FixLArElecCalib::fix1(const LArOnOffIdMapping *cabling) { + + ATH_MSG_INFO ( " in fix1() " ); + + // Fix1 is for updating the EM DAC2uA, assuming symmetry. + // Input should be MC Conditions data with DetDescrVersion=ATLAS-DC3-05 + + // Pointer to StoreGate + const LArEM_ID* em_idhelper = nullptr; + ATH_CHECK( detStore()->retrieve(em_idhelper) ); + + const LArOnlineID* online_idhelper = nullptr; + ATH_CHECK( detStore()->retrieve(online_idhelper) ); + + // retrieve DetDescrManager + const IToolSvc* toolSvc = nullptr; + ATH_CHECK( service("ToolSvc", toolSvc) ); + + LArDAC2uAMC * dac2ua = nullptr; + ATH_CHECK( detStore()->retrieve(dac2ua) ); + + // read in the file + + std::ifstream infile("barrel_dac2ua_oct06.txt") ; + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "); + return StatusCode::FAILURE; + } + + + int det,samp,reg,eta; + float value ; + int n = 0; + while ( infile>>det>>samp>>reg>>eta>>value ) + { + ++n; + ATH_MSG_DEBUG(" det,samp,reg,eta,value=" + <disc_channel_id(det,samp,reg,eta,0); + }else + id = em_idhelper->channel_id(det,samp,reg,eta,0); + + HWIdentifier hid = cabling->createSignalChannelID(id); + LArDAC2uAComplete::LArCondObj & t = dac2ua->get(hid,0); + ATH_MSG_DEBUG(" online id = "<print_to_string(hid)); + + if( t.isEmpty() ) + { + ATH_MSG_WARNING(" No existing conditions data " ); + continue ; + } + ATH_MSG_DEBUG(" Old DAC2uA = "<< t.m_data<< " " ); + + t.m_data = value ; + + const LArDAC2uAComplete::LArCondObj & t3 = dac2ua->get(hid,0); + ATH_MSG_DEBUG(" New DAC2uA = "<< t3.m_data << " " ); + + } + + ATH_MSG_DEBUG(" Number of entries changes = " <retrieve(fcal_idhelper) ); + + const LArOnlineID* online_idhelper = nullptr; + ATH_CHECK( detStore()->retrieve(online_idhelper) ); + + // retrieve DetDescrManager + IToolSvc* toolSvc = nullptr; + ATH_CHECK( service("ToolSvc", toolSvc) ); + + LArDAC2uAMC * dac2ua = nullptr; + ATH_CHECK( detStore()->retrieve(dac2ua) ); + + LAruA2MeVMC * ua2mev = nullptr; + ATH_CHECK( detStore()->retrieve(ua2mev) ); + + LArRampMC * ramp = nullptr; + ATH_CHECK( detStore()->retrieve(ramp) ); + + LArShape32MC * shape = nullptr; + ATH_CHECK( detStore()->retrieve(shape) ); + + LArNoiseMC * noise = nullptr; + ATH_CHECK( detStore()->retrieve(noise) ); + + LArfSamplMC * fsampl = nullptr; + ATH_CHECK( detStore()->retrieve(fsampl) ); + + LArMinBiasMC * minbias = nullptr; + ATH_CHECK( detStore()->retrieve(minbias) ); + + LArAutoCorrMC * ac = nullptr; + ATH_CHECK( detStore()->retrieve(ac) ); + + + for( unsigned int gain=0;gain<3;++gain) + { + // loop over all the old data + LArRampMC::ConditionsMapIterator it = ramp->begin(gain); + LArRampMC::ConditionsMapIterator it_e = ramp->end(gain); + + int n=0; + for (; it!=it_e;++it) + { + HWIdentifier hid = it.channelId(); + if( (*it).isEmpty() ) continue; + if(cabling->isOnlineConnected(hid)){ + continue; + }else + { + ATH_MSG_DEBUG(" unconnected channel" + << online_idhelper->print_to_string(hid) ); + ac->get(hid,gain) = LArAutoCorrComplete::LArCondObj(); + ramp->get(hid,gain) = LArRampComplete::LArCondObj(); + shape->get(hid,gain) = LArShape32MC::LArCondObj(); + noise->get(hid,gain) = LArNoiseComplete::LArCondObj(); + if(gain==0){ + dac2ua->get(hid,gain) = LArDAC2uAComplete::LArCondObj(); + ua2mev->get(hid,gain) = LAruA2MeVComplete::LArCondObj(); + fsampl->get(hid,gain) = LArfSamplComplete::LArCondObj(); + minbias->get(hid,gain) = LArMinBiasComplete::LArCondObj(); + } + ++n ; + } + + } + ATH_MSG_DEBUG(" Gain="<print_to_string(hid) ); + ATH_MSG_DEBUG ( fcal_idhelper->print_to_string(id) ); + ATH_MSG_DEBUG ( "module = "<get(hid_mod[module],gain) ; + ramp->setPdata(hid,ramp_std,gain); + + LArAutoCorrComplete::LArCondObj ac_std = ac->get(hid_mod[module],gain) ; + ac->setPdata(hid,ac_std,gain); + + LArShape32MC::LArCondObj shape_std = shape->get(hid_mod[module],gain) ; + shape->setPdata(hid,shape_std,gain); + + LArNoiseComplete::LArCondObj noise_std = noise->get(hid_mod[module],gain) ; + noise->setPdata(hid,noise_std,gain); + + if(gain==0){ + + LAruA2MeVComplete::LArCondObj ua2mev_std = ua2mev->get(hid_mod[module],gain) ; + ua2mev->setPdata(hid,ua2mev_std,gain); + + LArDAC2uAComplete::LArCondObj dac2ua_std = dac2ua->get(hid_mod[module],gain) ; + dac2ua->setPdata(hid,dac2ua_std,gain); + + LArfSamplComplete::LArCondObj fsampl_std = fsampl->get(hid_mod[module],gain) ; + fsampl->setPdata(hid,fsampl_std,gain); + + LArMinBiasComplete::LArCondObj minbias_std = minbias->get(hid_mod[module],gain) ; + minbias->setPdata(hid,minbias_std,gain); + + } + + } + } + + ATH_MSG_DEBUG( " Number of entries fixed " <retrieve(fsampl_c) ); + + LArfSamplMC* fsampl = const_cast(fsampl_c); + + // loop over all the old data + LArfSamplMC::ConditionsMapIterator it = fsampl->begin(0); + LArfSamplMC::ConditionsMapIterator it_e = fsampl->end(0); + int n_hec=0; + int n_fcal=0; + + for (; it!=it_e;++it){ + + HWIdentifier hid = it.channelId(); + if( (*it).isEmpty() ) continue; + if(!cabling->isOnlineConnected(hid)){ + continue; + } + + LArfSamplComplete::LArCondObj& t2 = const_cast(*it); + + Identifier id = cabling->cnvToIdentifier(hid); + + + if(m_hec_idhelper->is_lar_hec(id)){ + ATH_MSG_INFO(" HEC Old fsampl = "<< t2.m_fSampl<< " " ); + int sam = m_hec_idhelper->sampling(id); + + if(sam<=1){ + t2.m_fSampl = fsampl_hec1; + }else + { + t2.m_fSampl = fsampl_hec2; + } + + const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0); + ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " ); + + ++n_hec; + } + if(m_fcal_idhelper->is_lar_fcal(id)){ + ATH_MSG_INFO(" FCAL Old fsampl = "<< t2.m_fSampl<< " " ); + int sam = m_fcal_idhelper->module(id); + + if(sam==1){ + t2.m_fSampl = fsampl_fcal1; + }else + if(sam==2){ + t2.m_fSampl = fsampl_fcal2; + }else + { + t2.m_fSampl = fsampl_fcal3; + } + + const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0); + ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " ); + + ++n_fcal; + } + + } + + ATH_MSG_INFO(" number of hec cells "<retrieve(fsampl_c) ); + LArfSamplMC* fsampl = const_cast(fsampl_c); + + // read in the file + + ATH_MSG_INFO(" opening file "<< filename ); + std::ifstream infile( filename.c_str() ); + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "); + return StatusCode::FAILURE; + } + int det,samp,reg,eta; + float value ; + int n = 0; + while ( infile>>det>>samp>>reg>>eta>>value ) + { + ++n; + ATH_MSG_INFO(" det,samp,reg,eta,value=" + <disc_channel_id(det,samp,reg,eta,0); + }else + id = m_em_idhelper->channel_id(det,samp,reg,eta,0); + + HWIdentifier hid = cabling->createSignalChannelID(id); + const LArfSamplComplete::LArCondObj & t = fsampl->get(hid,0); + std::string id_str = m_online_idhelper->print_to_string(hid); + ATH_MSG_INFO(" online id = "<print_to_string(id) ); + // return StatusCode::FAILURE ; + continue ; + } + ATH_MSG_INFO(" Old fsampl = "<< t.m_fSampl<< " " ); + + LArfSamplComplete::LArCondObj& t2 = const_cast(t); + t2.m_fSampl = value ; + + const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0); + ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " ); + } + + ATH_MSG_INFO(" Number of entries changes = " <retrieve(dac2ua_c) ); + LArDAC2uAMC* dac2uaMC = const_cast(dac2ua_c); + + const LAruA2MeVMC * ua2mev_c = nullptr; + ATH_CHECK( detStore()->retrieve(ua2mev_c) ); + LAruA2MeVMC* ua2mevMC = const_cast(ua2mev_c); + + std::ifstream infile(filename.c_str() ) ; + + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "); + return StatusCode::FAILURE; + } + + + char s[200]; + infile.getline(s,200); + ATH_MSG_INFO(" first line of the file "<>det>>samp>>reg>>eta>> + dac2ua0>>ua2mev0>>attenuation>>dac2ua>>ua2mev ) + { + ++n; + ATH_MSG_DEBUG(" det,samp,reg,eta,values=" + <disc_channel_id(det,samp,reg,eta,0); + }else + id = m_em_idhelper->channel_id(det,samp,reg,eta,0); + + HWIdentifier hid = cabling->createSignalChannelID(id); + + const LArDAC2uAComplete::LArCondObj & t = dac2uaMC->get(hid,0); + std::string id_str = m_online_idhelper->print_to_string(hid); + std::string id_str_off = m_em_idhelper->print_to_string(id); + ATH_MSG_DEBUG(" online id = "<(t); + t2.m_data= dac2ua ; + + const LArDAC2uAComplete::LArCondObj & t3 = dac2uaMC->get(hid,0); + ATH_MSG_DEBUG(" New DAC2uA = "<< t3.m_data<< " " ); + + /**************************/ + + const LAruA2MeVComplete::LArCondObj & u = ua2mevMC->get(hid,0); + + if( u.isEmpty() ) + { + ATH_MSG_ERROR(" No existing conditions data " ); + // return StatusCode::FAILURE ; + continue ; + } + ATH_MSG_DEBUG(" Old uA2MeV = "<< u.m_data<< " " ); + + LAruA2MeVComplete::LArCondObj& u2 = const_cast(u); + u2.m_data = ua2mev ; + + const LAruA2MeVComplete::LArCondObj & u3 = ua2mevMC->get(hid,0); + ATH_MSG_DEBUG(" New uA2MeV = "<< u3.m_data<< " " ); + + } + + ATH_MSG_DEBUG(" Number of entries changes = " <retrieve(noise_c) ); + LArNoiseMC* noise = const_cast(noise_c); + + const LArMinBiasMC * minbias_c = nullptr; + ATH_CHECK( detStore()->retrieve(minbias_c) ); + LArMinBiasMC* minbias = const_cast(minbias_c); + + int ndisc=0; + int nconn=0; + for( unsigned int gain=0;gain<3;++gain) + { + // loop over all the old data + LArNoiseMC::ConditionsMapIterator it = noise->begin(gain); + LArNoiseMC::ConditionsMapIterator it_e = noise->end(gain); + + for (; it!=it_e;++it) + { + HWIdentifier hid = it.channelId(); + if( (*it).isEmpty() ) continue; + + Identifier id = cabling->cnvToIdentifier(hid); + if(!m_fcal_idhelper->is_lar_fcal(id)) continue; + + if(cabling->isOnlineConnected(hid)){ + ++nconn; + }else { + ATH_MSG_ERROR(" unconnected channel" + << m_online_idhelper->print_to_string(hid) ); + + ++ndisc ; + } + + } + + ATH_MSG_INFO(" Gain="<>str_id >>vol>>noise_p>>noise_h>>noise_m>>noise_l ) + { + const char* ch_id = str_id.c_str(); + if(str_id.find("A")!=0){ + ATH_MSG_DEBUG(" skipping string"<7){ + ATH_MSG_DEBUG(" skipping phi"<channel_id(2,mod,eta,phi); + HWIdentifier hid = cabling->createSignalChannelID(id); + + const LArMinBiasComplete::LArCondObj& t1 = minbias->get(hid,0) ; + LArMinBiasComplete::LArCondObj& t2 = const_cast(t1); + ATH_MSG_INFO(" minBiasRMS, old new "<(noise->get(hid,0)); + if(u0.m_Noise!=noise_h) + ATH_MSG_INFO(" noise, old new "<(noise->get(hid,1)); + if(u1.m_Noise!=noise_m) + ATH_MSG_INFO(" noise, old new "<(noise->get(hid,2)); + if(u2.m_Noise!=noise_l) + ATH_MSG_INFO(" noise, old new "<>lar>>tp>>det>>samp>>reg>>eta>>phi>>value ) + { + ++n; + ATH_MSG_INFO(" det,samp,reg,eta,value=" + <disc_channel_id(det,samp,reg,eta,0); + }else + { + if (tp==1){ + id = m_em_idhelper->channel_id(det,samp,reg,eta,0); + }else + if(tp==2) + { + id = m_hec_idhelper->channel_id(det,samp,reg,eta,0); + } + else + { + ATH_MSG_ERROR(" unknown type "<createSignalChannelID(id); + const LArMinBiasComplete::LArCondObj & t = minbias->get(hid,0); + ATH_MSG_INFO(" online id = "<print_to_string(hid)); + + if( t.isEmpty() ) + { + ATH_MSG_ERROR(" No existing conditions data " ); + ATH_MSG_ERROR( m_em_idhelper->print_to_string(id) ); + // return StatusCode::FAILURE ; + continue ; + } + ATH_MSG_INFO(" Old MinBias = "<< t.m_MinBiasRMS<< " " ); + + LArMinBiasComplete::LArCondObj& t2 = const_cast(t); + t2.m_MinBiasRMS = value ; + + const LArMinBiasComplete::LArCondObj & t3 = minbias->get(hid,0); + ATH_MSG_INFO(" New MinBias = "<< t3.m_MinBiasRMS<< " " ); + + } + + ATH_MSG_INFO(" Number of entries changes = " <retrieve(noise_c) ); + LArNoiseMC* noise = const_cast(noise_c); + + const LArRampMC * ramp_c = nullptr; + ATH_CHECK( detStore()->retrieve(ramp_c) ); + LArRampMC* ramp = const_cast(ramp_c); + + const LAruA2MeVMC * ua2MeV_c = nullptr; + ATH_CHECK( detStore()->retrieve(ua2MeV_c) ); + LAruA2MeVMC* ua2MeV = const_cast(ua2MeV_c); + + const LArDAC2uAMC * dac2uA_c = nullptr; + ATH_CHECK( detStore()->retrieve(dac2uA_c) ); + LArDAC2uAMC* dac2uA = const_cast(dac2uA_c); + + int ndisc=0; + int nconn=0; + for( unsigned int gain=0;gain<3;++gain) + { + // loop over all the old data + LArNoiseMC::ConditionsMapIterator it = noise->begin(gain); + LArNoiseMC::ConditionsMapIterator it_e = noise->end(gain); + + for (; it!=it_e;++it) + { + HWIdentifier hid = it.channelId(); + if( (*it).isEmpty() ) continue; + + Identifier id = cabling->cnvToIdentifier(hid); + if(!m_fcal_idhelper->is_lar_fcal(id)) continue; + + if(cabling->isOnlineConnected(hid)){ + ++nconn; + continue; + }else + { + ATH_MSG_ERROR(" unconnected channel" + << m_online_idhelper->print_to_string(hid) ); + + ++ndisc ; + } + + } + + ATH_MSG_INFO(" Gain="<>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l + >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val ) + { + const char* ch_id = str_id.c_str(); + + if(str_id.substr(0,1)!=std::string("A")){ + ATH_MSG_INFO(" skipping string"<7){ + ATH_MSG_INFO(" skipping phi"<channel_id(2,mod,eta,phi); + HWIdentifier hid = cabling->createSignalChannelID(id); + + const LArNoiseComplete::LArCondObj& noise0 = noise->get(hid,0) ; + LArNoiseComplete::LArCondObj& u0 = const_cast(noise0); + if(u0.m_Noise!=noise_h) + ATH_MSG_INFO(" noise, old new "<get(hid,1) ; + LArNoiseComplete::LArCondObj& u1 = const_cast(noise1); + if(u1.m_Noise!=noise_m) + ATH_MSG_INFO(" noise, old new "<get(hid,2) ; + LArNoiseComplete::LArCondObj& u2 = const_cast(noise2); + if(u2.m_Noise!=noise_l) + ATH_MSG_INFO(" noise, old new "<(ramp->get(hid,0)); + LArRampComplete::LArCondObj& ramp1 = const_cast(ramp->get(hid,1)); + LArRampComplete::LArCondObj& ramp2 = const_cast(ramp->get(hid,2)); + + ramp0.m_vRamp={0., ramp_val}; + + ramp1.m_vRamp={0., ramp_val/(float)9.96}; + + ramp2.m_vRamp={0., ramp_val/(float)9.96/(float)9.67}; + + LAruA2MeVComplete::LArCondObj& ua2MeV0 = const_cast(ua2MeV->get(hid,0)); + ua2MeV0.m_data=ua2MeV_val; + + LArDAC2uAComplete::LArCondObj& dac2ua0 = const_cast(dac2uA->get(hid,0)); + dac2ua0.m_data = dac2uA_val; + + } + + ATH_MSG_INFO(" number of channels in file ="<("noise_em.txt","noise_hec.txt", cabling, true, 1 ) ); + ATH_CHECK( update_EM_HEC("","autocorr_hec.txt", cabling, true, 4 ) ); + + ATH_CHECK( update_EM_HEC("autocorr_em.txt","", cabling, true,5) ); + ATH_CHECK( update_EM_HEC("ramp_em.txt","ramp_hec.txt", cabling, true, 1 ) ); + ATH_CHECK( update_EM_HEC("ua2mev_em.txt","ua2mev_hec.txt", cabling, false, 1 ) ); + ATH_CHECK( update_EM_HEC("dac2ua_em.txt","dac2ua_hec.txt", cabling, false, 1 ) ); + ATH_CHECK( update_EM_HEC("shape_em.txt","shape_hec.txt", cabling, true, 64 ) ); + ATH_CHECK( update_EM_HEC("mphys_em.txt","", cabling, true, 1 ) ); + + // additional fix for LArDAC2uA and LAruA2MeV + ATH_CHECK( fixDACuAMeV() ); + return StatusCode::SUCCESS; +} + + +StatusCode FixLArElecCalib::ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar ) { + + std::ifstream infile(filename.c_str() ) ; + + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "<>first ) + { + if (EM) { + det = first; + infile>>samp>>reg>>eta; + }else + { + samp=first; + infile>>reg>>eta; + } + + int gain=0; + if(withGain) infile>>gain ; + std::vector vfl; + float x; + + for (int i=0;i>x; + vfl.push_back(x); + } + ++n; + ATH_MSG_DEBUG(" det,samp,reg,eta,values=" + <channel_id(det,samp,reg,eta,0); + }else //HEC + { + id = m_hec_idhelper->channel_id(2,samp,reg,eta,0); + } + HWIdentifier hid = cabling->createSignalChannelID(id); + + if (gain >= 0 && gain < 3) + m_cache[gain].push_back(ROW_t(hid,vfl)); + } + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar ) { + + std::ifstream infile(filename.c_str() ) ; + + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "<>first>>samp>>reg>>eta ) { + Identifier id ; + int gain=0; + float x; + if(first <= 2) { // Calo 0,1,2 is EM + det = first+1; + if ( det==1 && samp==1 && reg==0 && eta==0 ){ + // eta=0 for strip, not connected, but keep it + // Removed disconnected channels: 03/2016 RDS + ATH_MSG_DEBUG(" disconnected strip "); + // id = m_em_idhelper->disc_channel_id(det,samp,reg,eta,0); + }else + id = m_em_idhelper->channel_id(det,samp,reg,eta,0); + } else if (first == 3) { // HEC + id = m_hec_idhelper->channel_id(2,samp,reg,eta,0); + } else if (first == 4) { // FCAL + id = m_fcal_idhelper->channel_id(2,samp+1,eta,0); + } else { + ATH_MSG_WARNING(" Wrong calo number "<>gain ; + for (int i=0;i>x; + continue; + } + if(withGain) infile>>gain ; + std::vector vfl; + + for (int i=0;i>x; + vfl.push_back(x); + } + ++n; + ATH_MSG_DEBUG(" first, det,samp,reg,eta,values=" + <createSignalChannelID(id); + + if (gain >= 0 && gain < 3) m_cache[gain].push_back(ROW_t(hid,vfl)); + else { + ATH_MSG_WARNING(" Wrong gain " <& v ) +{ + if (v.size()!=1) + { + ATH_MSG_ERROR ("for LArNoiseMC, size of vector = "<< v.size() <<" differs from one"); + return ; + } + obj.m_Noise = v[0]; + return; +} + +void FixLArElecCalib::print_object(const std::string& s, const LArAutoCorrMC::LArCondObj& obj) +{ + if( obj.isEmpty()){ + ATH_MSG_INFO(" LArAutoCorrMC " << s << " is empty" ); + }else + { + msg()<& v ) +{ + if (v.size()<4 ) + { + ATH_MSG_ERROR( "for LArAutoCorrMC, size of vector = "<< v.size()<<" is less then 4" ); + return ; + } + + obj.m_vAutoCorr.resize(4); + std::copy_n(v.begin(), 4, obj.m_vAutoCorr.begin()); + return; +} + +void FixLArElecCalib::print_object(const std::string& s, const LArRampMC::LArCondObj& obj) +{ + if( obj.isEmpty()){ + ATH_MSG_INFO(" LArRampMC " << s << " is empty" ); + }else + { + msg()<& v ) +{ + if (v.size()!=1 ) + { + ATH_MSG_ERROR ("for LArRampMC, size of vector = "<< v.size()); + return ; + } + obj.m_vRamp.resize(3); + obj.m_vRamp[0]=0; + obj.m_vRamp[1]=v[0]; + obj.m_vRamp[2]=0; + + return; +} + +void FixLArElecCalib::print_object(const std::string& s, const LArShape32MC::LArCondObj& obj) +{ + if( obj.isEmpty()){ + ATH_MSG_INFO(" LArShape32MC " << s << " is empty" ); + }else + { + msg()<& v ) +{ + + if (v.size()!=64 && v.size()!=32 ) + { + ATH_MSG_ERROR ("for LArShape32MC, size of vector = "<< v.size()); + return ; + } + + unsigned int size = 32; + obj.m_vShape.resize(size); + obj.m_vShapeDer.resize(size); + + for(unsigned int i=0;i& v ) +{ + if (v.size()!=1) + { + ATH_MSG_ERROR( "for LArSingleFloatP, size of vector = "<< v.size() ); + return ; + } + obj.m_data = v[0]; + return; +} + + + + +StatusCode FixLArElecCalib::addMphysOverMcal(const LArOnOffIdMapping *cabling) { + // add the contain to DetStore. + // fill 1 for all FCAL/HEC channels + + ATH_MSG_INFO ( " addMphysOverMcal() " ); + // create LArMphysOverMcal with FCAL numbers = 1. + + std::unique_ptr mphys = std::make_unique(); + mphys->setGroupingType(LArConditionsContainerBase::SingleGroup); + ATH_CHECK( mphys->initialize() ); + + int n=0; + + std::string filename("FCal_noise_minbias_adc2mev.txt"); + + std::ifstream infile(filename.c_str() ) ; + + if(! infile.good() ) + { + ATH_MSG_ERROR(" fail to open file "<>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l + >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val ) + { + const char* ch_id = str_id.c_str(); + + if(str_id.substr(0,1)!=std::string("A")){ + ATH_MSG_INFO(" skipping string"<7){ + ATH_MSG_INFO(" skipping phi"<channel_id(2,mod,eta,phi); + HWIdentifier hid = cabling->createSignalChannelID(id); + + LArMphysOverMcalMC::LArCondObj t; + t.m_data =1. ; + mphys->setPdata(hid,t,0); + mphys->setPdata(hid,t,1); + mphys->setPdata(hid,t,2); + } + + ATH_MSG_INFO(" MphysOverMcal added "<setPdata(hid,t,0); + mphys->setPdata(hid,t,1); + mphys->setPdata(hid,t,2); + ++n; + + } + + ATH_CHECK( detStore()->record(std::move(mphys),"LArMphysOverMcal") ); + ILArMphysOverMcal* imphys=nullptr; + ATH_CHECK (detStore()->symLink(mphys.get(),imphys) ); + + ATH_MSG_ERROR(" Number of HEC channel added "<retrieve(dac2ua_c) ); + LArDAC2uAMC* dac2uaMC = const_cast(dac2ua_c); + + const LAruA2MeVMC * ua2mev_c = nullptr; + ATH_CHECK( detStore()->retrieve(ua2mev_c) ); + LAruA2MeVMC* ua2mevMC = const_cast(ua2mev_c); + + int n=0; + + LAruA2MeVMC::ConditionsMapIterator it = ua2mevMC->begin(0); + LAruA2MeVMC::ConditionsMapIterator it_e = ua2mevMC->end(0); + + for(;it!=it_e;++it){ + HWIdentifier hid = it.channelId(); + const LAruA2MeVComplete::LArCondObj & u = (*it); + + if( u.m_data> -990) + { + ATH_MSG_DEBUG(" ua2MeV channel OK "<(u); + u2.m_data= ILAruA2MeV::ERRORCODE ; + + const LAruA2MeVComplete::LArCondObj & u3 = ua2mevMC->get(hid,0); + ATH_MSG_DEBUG(" New uA2MeV = "<< u3.m_data<< " " ); + + ++n; + } + + ATH_MSG_DEBUG(" Number of uA2MeV entries changes = " <begin(igain); + LArDAC2uAMC::ConditionsMapIterator it_e = dac2uaMC->end(igain); + + n=0; + for( ;it!=it_e;++it){ + HWIdentifier hid = it.channelId(); + const LArDAC2uAMC::LArCondObj & u = (*it); + + if( u.m_data> -990.) + { + ATH_MSG_DEBUG(" DAC2uA channel OK "<(u); + u2.m_data = ILArDAC2uA::ERRORCODE ; + + const LArDAC2uAMC::LArCondObj & u3 = dac2uaMC->get(hid,igain); + ATH_MSG_DEBUG(" New DACuA2 = "<< u3.m_data << " " ); + ++n; + } + + } + + ATH_MSG_DEBUG(" Number of DAC2uA entries changes = " < fcal_autoCorr[3][3] ; //[module][gain] + fcal_autoCorr[0][0] = {-0.01, -0.30, -0.09, 0.08}; + fcal_autoCorr[0][1] = { 0.01, -0.07, -0.01, 0.03}; + fcal_autoCorr[0][2] = { 0.2, 0.2, 0.2, 0.2}; + fcal_autoCorr[1][0] = { -0.02, -0.31, -0.06, 0.06}; + fcal_autoCorr[1][1] = { 0.0, -0.08, -0.01, 0.02}; + fcal_autoCorr[1][2] = { 0.02, 0.01, 0.02, 0.02}; + fcal_autoCorr[2][0] = { -0.03, -0.31, -0.05, 0.07}; + fcal_autoCorr[2][1] = { 0.01, -0.07, -0.01, 0.02}; + fcal_autoCorr[2][2] = { 0.02, 0.02, 0.02, 0.02}; + + // Fix9 is for updating the FCAL AutoCorr conditions data + // Input should be MC Conditions data with DetDescrVersion=ATLAS-CSC-02-00-00 + + const LArAutoCorrMC * ac_c = nullptr; + ATH_CHECK( detStore()->retrieve(ac_c) ); + LArAutoCorrMC* ac = const_cast(ac_c); + + + for( unsigned int gain=0;gain<3;++gain) + { + // loop over all the old data + LArAutoCorrMC::ConditionsMapIterator it = ac->begin(gain); + LArAutoCorrMC::ConditionsMapIterator it_e = ac->end(gain); + + int n=0; + for (; it!=it_e;++it) + { + HWIdentifier hid = it.channelId(); + const LArAutoCorrMC::LArCondObj & u = (*it); + if( (*it).isEmpty() ) continue; + + Identifier id = cabling->cnvToIdentifier(hid); + if(! m_fcal_idhelper->is_lar_fcal(id)) continue ; + int module = m_fcal_idhelper->module(id) - 1; + + ATH_MSG_DEBUG("module= " << module << " Old AutoCorr = " + << u.m_vAutoCorr[0]<< " " + << u.m_vAutoCorr[1]<< " " + << u.m_vAutoCorr[2]<< " " + << u.m_vAutoCorr[3]<< " " ); + + LArAutoCorrMC::LArCondObj& u2 = const_cast(u); + u2.m_vAutoCorr = fcal_autoCorr[module][gain] ; + + const LArAutoCorrMC::LArCondObj & u3 = ac->get(hid,gain); + ATH_MSG_DEBUG(" New AutoCorr = " + << u3.m_vAutoCorr[0]<< " " + << u3.m_vAutoCorr[1]<< " " + << u3.m_vAutoCorr[2]<< " " + << u3.m_vAutoCorr[3]<< " " ); + ++n; + + } + ATH_MSG_DEBUG(" Gain="<retrieve(ramp_c) ); + LArRampMC* ramp = const_cast(ramp_c); + + LArRampMC::ConditionsMapIterator it = ramp->begin(0); + LArRampMC::ConditionsMapIterator it_e = ramp->end(0); + + int n=0; + int ndisc=0; + for (; it!=it_e;++it) + { + HWIdentifier hid = it.channelId(); + if( (*it).isEmpty() ) continue; + + Identifier id = cabling->cnvToIdentifier(hid); + if(!m_fcal_idhelper->is_lar_fcal(id)) continue; + + if( ! cabling->isOnlineConnected(hid)){ + ATH_MSG_ERROR(" unconnected channel" + << m_online_idhelper->print_to_string(hid) ); + ++ndisc ; + continue ; + } + + + const LArRampComplete::LArCondObj& ramp0_c = ramp->get(hid,0) ; + const LArRampComplete::LArCondObj& ramp1_c = ramp->get(hid,1) ; + const LArRampComplete::LArCondObj& ramp2_c = ramp->get(hid,2) ; + LArRampComplete::LArCondObj& ramp0 = const_cast(ramp0_c); + LArRampComplete::LArCondObj& ramp1 = const_cast(ramp1_c); + LArRampComplete::LArCondObj& ramp2 = const_cast(ramp2_c); + + float ramp_high = ramp0.m_vRamp[1]; + + std::vector v_m ; + v_m.push_back(0); + v_m.push_back(ramp_high*9.96); + ramp1.m_vRamp=v_m; + + std::vector v_l ; + v_l.push_back(0); + v_l.push_back(ramp_high*9.96*9.67); + ramp2.m_vRamp=v_l; + ++n; + + ATH_MSG_DEBUG(" ramp hi,med,low"<< ramp0.m_vRamp[1]<< " "<("","ramp_hec_june2008.txt", cabling, true, 1 ) ); + return StatusCode::SUCCESS; +} + + +StatusCode FixLArElecCalib::fix13(const LArOnOffIdMapping *cabling) { + + ATH_MSG_INFO ( " in fix13() " ); + // update EM/HEC 7 data objects. + + ToolHandle scidtool("CaloSuperCellIDTool"); + if ( scidtool.retrieve().isFailure() ) { + ATH_MSG_ERROR ( " Could not retrieve scitool " ); + } + + std::set scidset; + std::map sslot_schannel_idx; + std::vector OrderOnlHash_OffID; + std::vector OrderOffHash_OnlID; + OrderOnlHash_OffID.resize(40000,0); + OrderOffHash_OnlID.resize(40000,0); + + Identifier::size_type channel_size = m_em_idhelper->channel_hash_max(); + unsigned int min_onl_hash = 999999; + unsigned int max_onl_hash = 0; + unsigned int min_off_hash = 999999; + unsigned int max_off_hash = 0; + std::ofstream hashes("AllHashChannels_All.txt"); + std::ofstream of("AllChannels_EM.txt"); + + for(size_t i = 0; i < channel_size ; i++) { + Identifier chid = m_em_idhelper->channel_id(i); + bool isEM = ( m_em_idhelper->is_em_barrel( chid ) || m_em_idhelper->is_em_endcap( chid ) ) ; + if ( ! isEM ) continue; + Identifier SCID = scidtool->offlineToSuperCellID(chid); + if ( scidset.find(SCID) == scidset.end() && (m_scell_idhelper->calo_cell_hash( SCID ).value() < 99999) ) + scidset.insert(SCID); + else continue; + HWIdentifier hwid = cabling->createSignalChannelID(chid); + if ( i == 0 ){ + of << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl; + } + of << chid.get_identifier32().get_compact() << "\t0x" << + SCID.get_identifier32().get_compact() << "\t0x" << + hwid.get_identifier32().get_compact() ; + Identifier regId = m_em_idhelper->region_id( chid ); + int reg = m_em_idhelper->region( chid ); + IdentifierHash regHash = m_em_idhelper->region_hash( regId ); + int samp = m_em_idhelper->sampling( chid ); + int feedthrough = m_online_idhelper->feedthrough( hwid ); + int bar_ec = m_online_idhelper->barrel_ec( hwid ); + int pos_neg = m_online_idhelper->pos_neg( hwid ); + int slot = m_online_idhelper->slot( hwid ); + float etaG = m_em_idhelper->etaGranularity(regHash); + float phiG = m_em_idhelper->phiGranularity(regHash); + float eta0 = m_em_idhelper->eta0(regHash); + float phi0 = m_em_idhelper->phi0(regHash); + float eta = etaG*m_em_idhelper->eta( chid ) + eta0; + float phi = phiG*m_em_idhelper->phi( chid ) + phi0; + char etaChar[10]; + char phiChar[10]; + sprintf(etaChar,"%5.4f",eta); + sprintf(phiChar,"%5.4f",phi); + of << std::dec << "\t" << feedthrough << "\t" << slot; + of << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t"; + of << etaChar << " " << phiChar << "\t0x"; + HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid); + int sslot=1; + bool InSlot= m_em_idhelper->is_em_endcap_inner ( chid ); + bool OutSlot= m_em_idhelper->is_em_endcap_outer ( chid ) ; + bool secondOutSlot=false; + if ( OutSlot ) { + if ( (samp==1) && (reg==5) ) secondOutSlot=true; + if ( (samp==2) && (reg==1) && ( m_em_idhelper->eta( chid )>=39 ) ) + secondOutSlot=true; + if ( (samp==3) && (reg==0) && ( m_em_idhelper->eta( chid )>=18 ) ) + secondOutSlot=true; + } + HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot); + + if ( InSlot ) { + sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough-1,sslot+1); + } + if ( secondOutSlot ) { + sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1); + } + if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() ) + sslot_schannel_idx[sfeb_id]=0; + else sslot_schannel_idx[sfeb_id]++; + HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]); + unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value(); + if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash; + if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash; + unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value(); + if ( off_hash > max_off_hash ) max_off_hash = off_hash; + if ( off_hash < min_off_hash ) min_off_hash = off_hash; + of << std::hex; + of << feb_id.get_identifier32().get_compact(); + of << "\t0x" << shwid.get_identifier32().get_compact(); + of << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid); + of << std::dec; + of << " " << onl_hash << " " << off_hash; + of << std::endl; + + if ( m_scell_idhelper->calo_cell_hash( SCID ).value() < 40000 ) + OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact(); + if ( m_sonline_idhelper->channel_Hash( shwid ).value() < 40000 ) + OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact(); + } + of << "Hash check. Onl : " << min_onl_hash << " " << max_onl_hash; + of << "; Off : " << min_off_hash << " " << max_off_hash << std::endl;; + of.close(); + + channel_size = m_hec_idhelper->channel_hash_max(); + min_onl_hash = 999999; + max_onl_hash = 0; + min_off_hash = 999999; + max_off_hash = 0; + std::ofstream of1("AllChannels_HEC.txt"); + + of1 << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl; + for(size_t i = 0; i < channel_size ; i++) { + Identifier chid = m_hec_idhelper->channel_id(i); + if ( ! ( m_hec_idhelper->is_lar_hec( chid ) ) ) continue; + Identifier SCID = scidtool->offlineToSuperCellID(chid); + if ( scidset.find(SCID) == scidset.end() ) + scidset.insert(SCID); + else continue; + HWIdentifier hwid = cabling->createSignalChannelID(chid); + of1 << chid.get_identifier32().get_compact() << "\t0x" << + SCID.get_identifier32().get_compact() << "\t0x" << + hwid.get_identifier32().get_compact() ; + Identifier regId = m_hec_idhelper->region_id( chid ); + IdentifierHash regHash = m_hec_idhelper->region_hash( regId ); + int samp = m_hec_idhelper->sampling( chid ); + int feedthrough = m_online_idhelper->feedthrough( hwid ); + int bar_ec = m_online_idhelper->barrel_ec( hwid ); + int pos_neg = m_online_idhelper->pos_neg( hwid ); + int slot = m_online_idhelper->slot( hwid ); + float etaG = m_hec_idhelper->etaGranularity(regHash); + float phiG = m_hec_idhelper->phiGranularity(regHash); + float eta0 = m_hec_idhelper->eta0(regHash); + float phi0 = m_hec_idhelper->phi0(regHash); + float eta = etaG*m_hec_idhelper->eta( chid ) + eta0; + float phi = phiG*m_hec_idhelper->phi( chid ) + phi0; + char etaChar[10]; + char phiChar[10]; + sprintf(etaChar,"%5.4f",eta); + sprintf(phiChar,"%5.4f",phi); + of1 << std::dec << "\t" << feedthrough << "\t" << slot; + of1 << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t"; + of1 << etaChar << " " << phiChar << "\t0x"; + HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid); + int sslot=1; + int subtract=0; + HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot); + if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() ) + sslot_schannel_idx[sfeb_id]=0; + else sslot_schannel_idx[sfeb_id]++; + if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) { + sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1); + subtract=192; + } + HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]-subtract); + unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value(); + if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash; + if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash; + unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value(); + if ( off_hash > max_off_hash ) max_off_hash = off_hash; + if ( off_hash < min_off_hash ) min_off_hash = off_hash; + of1 << std::hex; + of1 << feb_id.get_identifier32().get_compact(); + of1 << "\t0x" << shwid.get_identifier32().get_compact(); + of1 << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid); + of1 << std::dec; + of1 << " " << onl_hash << " " << off_hash; + of1 << std::endl; + + OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact(); + OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact(); + } + + channel_size = m_fcal_idhelper->channel_hash_max(); + min_onl_hash = 999999; + max_onl_hash = 0; + min_off_hash = 999999; + max_off_hash = 0; + std::ofstream of3("AllChannels_FCAL.txt"); + + of3 << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl; + for(size_t i = 0; i < channel_size ; i++) { + Identifier chid = m_fcal_idhelper->channel_id(i); + if ( ! ( m_fcal_idhelper->is_lar_fcal( chid ) ) ) continue; + Identifier SCID = scidtool->offlineToSuperCellID(chid); + if ( scidset.find(SCID) == scidset.end() ) + scidset.insert(SCID); + else continue; + HWIdentifier hwid = cabling->createSignalChannelID(chid); + of3 << chid.get_identifier32().get_compact() << "\t0x" << + SCID.get_identifier32().get_compact() << "\t0x" << + hwid.get_identifier32().get_compact() ; + int samp = 0; + int feedthrough = m_online_idhelper->feedthrough( hwid ); + int bar_ec = m_online_idhelper->barrel_ec( hwid ); + int pos_neg = m_online_idhelper->pos_neg( hwid ); + int slot = m_online_idhelper->slot( hwid ); + of3 << std::dec << "\t" << feedthrough << "\t" << slot; + of3 << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t"; + HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid); + int sslot=1; + HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot); + if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) { + sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1); + } + if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() ) + sslot_schannel_idx[sfeb_id]=0; + else sslot_schannel_idx[sfeb_id]++; + HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]); + unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value(); + if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash; + if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash; + unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value(); + if ( off_hash > max_off_hash ) max_off_hash = off_hash; + if ( off_hash < min_off_hash ) min_off_hash = off_hash; + of3 << std::hex; + of3 << feb_id.get_identifier32().get_compact(); + of3 << "\t0x" << shwid.get_identifier32().get_compact(); + of3 << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid); + of3 << std::dec; + of3 << " " << onl_hash << " " << off_hash; + of3 << std::endl; + + OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact(); + OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact(); + } + + of3 << "Hash check. Onl : " << min_onl_hash << " " << max_onl_hash; + of3 << "; Off : " << min_off_hash << " " << max_off_hash << std::endl;; + of3.close(); + + + + const uint32_t onlHashMax=m_sonline_idhelper->channelHashMax(); + coral::AttributeListSpecification *spec_onOff = new coral::AttributeListSpecification(); + spec_onOff->extend("OnlineHashToOfflineId", "blob"); + spec_onOff->extend("version"); + std::unique_ptr al_onOff = std::make_unique(*spec_onOff); + coral::Blob& blobOnOff=(*al_onOff)["OnlineHashToOfflineId"].data(); + (*al_onOff)["version"].setValue(0U); + blobOnOff.resize(onlHashMax*sizeof(uint32_t)); + uint32_t* pBlobOnOff=static_cast(blobOnOff.startingAddress()); + unsigned nConn=0; + + const uint32_t emptyId=Identifier().get_identifier32().get_compact(); + for(size_t ii=0;ii minbias = std::make_unique(); + ATH_CHECK( minbias->setGroupingType("Single", msg()) ); + ATH_CHECK( minbias->initialize() ); + std::unique_ptr minbias_av = std::make_unique(); + ATH_CHECK( minbias_av->setGroupingType("Single", msg()) ); + ATH_CHECK( minbias_av->initialize() ); + // + std::unique_ptr fin= std::make_unique("ntuple_av.root"); + TTree *tin=dynamic_cast(fin->Get("m_tree")); + int ncell; + int identifier[2862]; + int layer[2862]; + int region[2862]; + int ieta[2862]; + float eta[2862]; + double average[2862]; + double rms[2862]; + TBranch *b_ncell; //! + TBranch *b_identifier; //! + TBranch *b_layer; //! + TBranch *b_region; //! + TBranch *b_ieta; //! + TBranch *b_eta; //! + TBranch *b_average; //! + TBranch *b_rms; //! + tin->SetMakeClass(1); + tin->SetBranchAddress("ncell", &ncell, &b_ncell); + tin->SetBranchAddress("identifier", identifier, &b_identifier); + tin->SetBranchAddress("layer", layer, &b_layer); + tin->SetBranchAddress("region", region, &b_region); + tin->SetBranchAddress("ieta", ieta, &b_ieta); + tin->SetBranchAddress("eta", eta, &b_eta); + tin->SetBranchAddress("average", average, &b_average); + tin->SetBranchAddress("rms", rms, &b_rms); + tin->GetEntry(0); + + + for(int icell=0; icellcreateSignalChannelID(id); + + minbias->set(hid, rms[icell]); + minbias_av->set(hid, average[icell]); + + } + + ATH_MSG_INFO(" number of channels in intuple ="<record(std::move(minbias),"LArMinBias") ); + ATH_CHECK( detStore()->symLink(minbias.get(), dynamic_cast(minbias.get())) ); + ATH_MSG_INFO ( "Stored container " << minbias->totalNumberOfConditions() << " conditions, key LArMinBias " ); + ATH_CHECK( detStore()->record(std::move(minbias_av),"LArMinBiasAverage") ); + ATH_CHECK( detStore()->symLink(minbias_av.get(), dynamic_cast(minbias_av.get())) ); + ATH_MSG_INFO ( "Stored container " << minbias_av->totalNumberOfConditions() << " conditions, key LArMinBiasAverage " ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::fix14(const LArOnOffIdMapping *cabling) { + + ATH_MSG_INFO ( " in fix14() " ); + + // Fix14 is for filling the LArPileupAverage from ntuple + + const ILArfSampl* larfSampl = nullptr; + ATH_CHECK( detStore()->retrieve(larfSampl,"") ); + // Will try to regenerate from scratch + // Create new container + std::unique_ptr minbias_av = std::make_unique(); + ATH_CHECK( minbias_av->setGroupingType("Single", msg()) ); + ATH_CHECK( minbias_av->initialize() ); + // + std::unique_ptr fin= std::make_unique("ntuple_av.root"); + TTree *tin=dynamic_cast(fin->Get("m_tree")); + int ncell; + int identifier[2862]; + int layer[2862]; + int region[2862]; + int ieta[2862]; + float eta[2862]; + double average[2862]; + double rms[2862]; + TBranch *b_ncell; //! + TBranch *b_identifier; //! + TBranch *b_layer; //! + TBranch *b_region; //! + TBranch *b_ieta; //! + TBranch *b_eta; //! + TBranch *b_average; //! + TBranch *b_rms; //! + tin->SetMakeClass(1); + tin->SetBranchAddress("ncell", &ncell, &b_ncell); + tin->SetBranchAddress("identifier", identifier, &b_identifier); + tin->SetBranchAddress("layer", layer, &b_layer); + tin->SetBranchAddress("region", region, &b_region); + tin->SetBranchAddress("ieta", ieta, &b_ieta); + tin->SetBranchAddress("eta", eta, &b_eta); + tin->SetBranchAddress("average", average, &b_average); + tin->SetBranchAddress("rms", rms, &b_rms); + tin->GetEntry(0); + + + for(int icell=0; icellcreateSignalChannelID(id); + float fsampl = larfSampl->FSAMPL(hid); + minbias_av->set(hid, 6.31*average[icell]/fsampl); + + } + + ATH_MSG_INFO(" number of channels in intuple ="<record(std::move(minbias_av),"LArPileupAverage") ); + ATH_CHECK( detStore()->symLink(minbias_av.get(), dynamic_cast(minbias_av.get())) ); + ATH_MSG_INFO ( "Stored container " << minbias_av->totalNumberOfConditions() << " conditions, key LArPileupAverage " ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::fix15() { + + ATH_MSG_INFO ( " in fix15 " ); + + // this method updates the EM MinBias + // input is the text file. + + const LArMinBiasAverageMC * minbias_c = nullptr; + ATH_CHECK( detStore()->retrieve(minbias_c,"LArPileupAverage") ); + LArMinBiasAverageMC* minbias = const_cast(minbias_c); + + + // here some iterator loop is needed + int n=0; + + LArMinBiasAverageMC::ConditionsMapIterator it = minbias->begin(0); + LArMinBiasAverageMC::ConditionsMapIterator it_e = minbias->end(0); + + for(;it!=it_e;++it){ + HWIdentifier hid = it.channelId(); + const LArMinBiasAverageComplete::LArCondObj & u = (*it); + + ATH_MSG_INFO(" Old pileup = "<< u.m_MinBiasAverage<< " " ); + + LArMinBiasAverageComplete::LArCondObj& u2 = const_cast(u); + + u2.m_MinBiasAverage *= 1.0838; // correction value + + + const LArMinBiasAverageComplete::LArCondObj & t3 = minbias->get(hid,0); + ATH_MSG_INFO(" New Pileup = "<< t3.m_MinBiasAverage<< " " ); + + } + + ATH_MSG_INFO(" Number of entries changes = " <retrieve(attrOnOff,onOffIdKey); + if (sc.isFailure()) { + ATH_MSG_ERROR("Failed to read AthenaAttributeList with key " << onOffIdKey); + return StatusCode::FAILURE; + } + const coral::Blob& blobOnOff=(*attrOnOff)["OnlineHashToOfflineId"].data(); + unsigned nChan=blobOnOff.size()/sizeof(uint32_t); + uint32_t* pBlobOnOff=const_cast(static_cast(blobOnOff.startingAddress())); + + + if (nChan!=m_online_idhelper->channelHashMax()) { + ATH_MSG_WARNING("Number of channels read from DB (" << nChan << ") does not match online hash max (" + <channelHashMax() << ")"); + nChan=std::min(nChan,static_cast(m_online_idhelper->channelHashMax())); + } + std::vector > swapindex(8, std::make_pair(nChan+10,nChan+10)); // here we store, which indexes to swap + // loop over all online hashes + for (unsigned i=0;ichannel_Id(IdentifierHash(i)); + if(m_online_idhelper->isEMECchannel(hwid) && m_online_idhelper->pos_neg(hwid) == 1 && m_online_idhelper->feedthrough(hwid) == 7 && m_online_idhelper->slot(hwid) == 11) { //EMEC-A FT 7, Slot 11 + if(m_online_idhelper->channel(hwid)>=96 && m_online_idhelper->channel(hwid)<=103) swapindex[m_online_idhelper->channel(hwid)-96].first=i; + if(m_online_idhelper->channel(hwid)>=112 && m_online_idhelper->channel(hwid)<=129) swapindex[m_online_idhelper->channel(hwid)-112].second=i; + } + } + for(unsigned i=0; i<8; ++i) { + } + // now do swaping + for(unsigned i=0; i<8; ++i) { + // check consistency of swapindex + if (swapindex[i].first > nChan || swapindex[i].second > nChan ) { + ATH_MSG_ERROR("Problem in swapindex: "<< i << " : " << swapindex[i].first << " " << swapindex[i].second); + return StatusCode::FAILURE; + } + uint32_t id = pBlobOnOff[swapindex[i].first]; + pBlobOnOff[swapindex[i].first] = pBlobOnOff[swapindex[i].second]; + pBlobOnOff[swapindex[i].second] = id; + } + // and now record the changed blob to SG + ATH_CHECK(detStore()->record(const_cast(attrOnOff),"/LAR/Identifier/OnOffIdMapNew")); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::fix17(const LArOnOffIdMapping *cabling) { + + ATH_MSG_INFO ( " in fix17() " ); + + // withGain , nvar + ATH_CHECK( update_All(m_infile, cabling, true, 32 ) ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecCalib::fix18(const LArCalibLineMapping *cabling) { + + ATH_MSG_INFO ( " in fix18() " ); + + const uint32_t onlHashMax=m_online_idhelper->channelHashMax(); + + coral::AttributeListSpecification* spec_calib = new coral::AttributeListSpecification(); + spec_calib->extend("OnlineHashToCalibIds", "blob"); + spec_calib->extend("version"); + std::unique_ptr al_calib = std::make_unique(*spec_calib); + coral::Blob& blobCalib=(*al_calib)["OnlineHashToCalibIds"].data(); + (*al_calib)["version"].setValue(0U); + blobCalib.resize(onlHashMax*sizeof(uint32_t)*4); //Bigger than necessary + + spec_calib->release(); + // cppcheck-suppress memleak + spec_calib = nullptr; + + uint32_t* pBlobCalib=static_cast(blobCalib.startingAddress()); + size_t calibIndex=0; + + + // loop over all online hashes + for (unsigned i=0;ichannel_Id(IdentifierHash(i)); + + const std::vector& calibIDs=cabling->calibSlotLine(hwid); + const size_t nCalibLines=calibIDs.size(); + + if (m_online_idhelper->isEMBchannel(hwid) && m_online_idhelper->pos_neg(hwid) == 1 && m_online_idhelper->feedthrough(hwid) == 0 ) { // EMB-A FT 0 + if(nCalibLines > 1) { //should not be in our channels + ATH_MSG_ERROR("Wrong number of CL in our channels"); + return StatusCode::FAILURE; + } + if(nCalibLines==0) { + pBlobCalib[calibIndex++]=0; + } else { + const HWIdentifier cmodule = m_online_idhelper->calib_module_Id(calibIDs[0]); + const HWIdentifier newcl = m_online_idhelper->calib_channel_Id(cmodule, m_online_idhelper->channel(hwid) ); + if(!m_online_idhelper->isCalibration(newcl)) { + ATH_MSG_ERROR("Something wrong, new CL not a calibration"); + ATH_MSG_ERROR("Channel: "<record(std::move(al_calib),"/LAR/Identifier/CalibIdMap_EMF")); + + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArCondTools/src/FixLArElecCalib.h b/LArCalorimeter/LArCondTools/src/FixLArElecCalib.h new file mode 100755 index 0000000000000000000000000000000000000000..c8b64576d3212a9a71c902c8a4aa2026297bdac3 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/FixLArElecCalib.h @@ -0,0 +1,273 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FIXLARELECCALIB_H +#define FIXLARELECCALIB_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "Identifier/HWIdentifier.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArCalibLineMapping.h" +#include + +class LArEM_ID ; +class LArHEC_ID; +class LArFCAL_ID; +class LArOnlineID; +class LArOnline_SuperCellID; +class CaloCell_SuperCell_ID; +class LArOnOffIdMapping; + +#include "LArRawConditions/LArDAC2uAMC.h" +#include "LArRawConditions/LArShape32MC.h" +#include "LArRawConditions/LAruA2MeVMC.h" +#include "LArRawConditions/LArfSamplMC.h" +#include "LArRawConditions/LArMinBiasMC.h" +#include "LArRawConditions/LArNoiseMC.h" +#include "LArRawConditions/LArRampMC.h" +#include "LArRawConditions/LArAutoCorrMC.h" +#include "LArRawConditions/LArMphysOverMcalMC.h" + +// this class is collection of various fixes, applied to LAr conditions, +// when some bug was found. +// should serve mainly as example, in case yet another problem will need a fix +class FixLArElecCalib : public AthAlgorithm +{ + public: + FixLArElecCalib(const std::string& name,ISvcLocator* pSvcLocator); + virtual ~FixLArElecCalib() = default; + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override {return StatusCode::SUCCESS;} + virtual StatusCode stop() override; + + StatusCode fix1(const LArOnOffIdMapping *cabling); + StatusCode fix2(const LArOnOffIdMapping *cabling); + StatusCode fix3(const LArOnOffIdMapping *cabling); + StatusCode fix4(const LArOnOffIdMapping *cabling); + StatusCode fix5(const LArOnOffIdMapping *cabling); + StatusCode fix6(const LArOnOffIdMapping *cabling); + StatusCode fix7(const LArOnOffIdMapping *cabling); + StatusCode fix8(const LArOnOffIdMapping *cabling); + StatusCode fix9(const LArOnOffIdMapping *cabling); + StatusCode fix10(const LArOnOffIdMapping *cabling); + StatusCode fix11(const LArOnOffIdMapping *cabling); + StatusCode fix12(const LArOnOffIdMapping *cabling); + StatusCode fix13(const LArOnOffIdMapping *cabling); + StatusCode fix14(const LArOnOffIdMapping *cabling); + StatusCode fix15(); + StatusCode fix16(); + StatusCode fix17(const LArOnOffIdMapping *cabling); + StatusCode fix18(const LArCalibLineMapping *clmap); + + private: + + SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_CLKey{this, "SCCalibLineKey", "LArCalibLineMap", "SG calib line key"}; + + StatusCode ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar ); + StatusCode ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar ); + + StatusCode update_DAC2uA(const std::string& em_filename,const std::string& hec_filename); + // FIXME: for future round of developments: + // StatusCode update_uA2MeV(const std::string& em_filename,const std::string& hec_filename); + // StatusCode update_AC(const std::string& em_filename,const std::string& hec_filename); + //StatusCode update_Noise(const std::string& em_filename,const std::string& hec_filename); + //StatusCode update_Mphys(const std::string& em_filename,const std::string& hec_filename); + //StatusCode update_Ramp(const std::string& em_filename,const std::string& hec_filename); + //StatusCode update_Shape(const std::string& em_filename,const std::string& hec_filename); + + template + StatusCode update_EM_HEC(const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling, + bool withGain, int nvar); + template + StatusCode update_All(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar); + + void print_object(const std::string& msg, const LArNoiseMC::LArCondObj& obj); + void set_object(LArNoiseMC::LArCondObj& obj, const std::vector& v ); + + void print_object(const std::string& msg, const LArAutoCorrMC::LArCondObj& obj); + void set_object(LArAutoCorrMC::LArCondObj& obj, const std::vector& v ); + + void print_object(const std::string& msg, const LArRampMC::LArCondObj& obj); + void set_object(LArRampMC::LArCondObj& obj, const std::vector& v ); + + //void print_object(const std::string& msg, const LAruA2MeVMC::LArCondObj& obj); + //void set_object(LAruA2MeVMC::LArCondObj& obj, std::vector& v ); + + void print_object(const std::string& msg, const LArShape32MC::LArCondObj& obj); + void set_object(LArShape32MC::LArCondObj& obj, const std::vector& v ); + + void print_object(const std::string& msg, const LArSingleFloatP& obj); + void set_object(LArSingleFloatP& obj, const std::vector& v ); + + // void print_object(const std::string& msg, const LArDAC2uAMC::LArCondObj& obj); + //void set_object(LArDAC2uAMC::LArCondObj& obj, std::vector& v ); + + StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling) ; // add new one with default for FCAL + + StatusCode fixDACuAMeV() ; // remove -100000000 + + + StatusCode updateEMfSampl(const std::string& filename, const LArOnOffIdMapping *cabling); + StatusCode updateMinBias(const std::string& filename, const LArOnOffIdMapping *cabling); + StatusCode updateEM_DACuAMeV(const std::string& filename, const LArOnOffIdMapping *cabling); + StatusCode updateHADfSampl(const LArOnOffIdMapping *cabling); + + int m_fixFlag ; + std::string m_g4Phys; + std::string m_infile; + + const LArEM_ID* m_em_idhelper; + const LArHEC_ID* m_hec_idhelper; + const LArFCAL_ID* m_fcal_idhelper; + const LArOnlineID* m_online_idhelper; + const LArEM_SuperCell_ID* m_sem_idhelper; + const LArHEC_SuperCell_ID* m_shec_idhelper; + const LArFCAL_SuperCell_ID* m_sfcal_idhelper; + const LArOnline_SuperCellID* m_sonline_idhelper; + const CaloCell_SuperCell_ID* m_scell_idhelper; + + + + + typedef std::pair > ROW_t ; + typedef std::vector VROW_t; + + VROW_t m_cache[3] ; + + +}; + +template + StatusCode FixLArElecCalib::update_EM_HEC(const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar) +{ + // read in the file + + const T * container_c = nullptr; + ATH_CHECK( detStore()->retrieve(container_c) ); + + T* container = const_cast(container_c); + + typedef typename T::LArCondObj CONDOBJ ; + + for (int i=0; i<2;++i) + { // EM and HEC + if( i==0 ) + { + if ( em_filename == "") continue ; + bool EM=true; + ATH_CHECK( ReadFile(em_filename,cabling,EM,withGain,nvar) ); + } + if( i==1 ) + { + if ( hec_filename == "") continue ; + bool EM=false ; + ATH_CHECK( ReadFile(hec_filename,cabling,EM,withGain,nvar) ); + } + + + int ngain=1; + if (withGain) ngain=3; + for (int igain = 0;igainget(hid,igain); + + if( u.isEmpty() ) + { + ATH_MSG_WARNING(" No existing conditions data, adding new one " ); + CONDOBJ t ; + set_object(t,(*it).second) ; + container->setPdata(hid,t,igain); + } + else + { + print_object(" Old object = ",u); + + CONDOBJ& u2 = const_cast(u); + set_object(u2,(*it).second) ; + } + + const CONDOBJ& u3 = container->get(hid,igain); + print_object(" New object = ",u3); + + ++n; + } + ATH_MSG_INFO( " done for gain ="< + StatusCode FixLArElecCalib::update_All(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar) +{ + // read in the file + + const T * container_c = nullptr; + ATH_CHECK( detStore()->retrieve(container_c) ); + + T* container = const_cast(container_c); + + typedef typename T::LArCondObj CONDOBJ ; + + if ( filename == "") { ATH_MSG_ERROR("No input filename "); return StatusCode::FAILURE; } + ATH_CHECK( ReadFileAll(filename, cabling, withGain,nvar) ); + + int ngain=1; + if (withGain) ngain=3; + for (int igain = 0;igainget(hid,igain); + + if( u.isEmpty() ) { + ATH_MSG_WARNING(" Not existing conditions data, adding new one " ); + CONDOBJ t ; + set_object(t,(*it).second) ; + container->setPdata(hid,t,igain); + } else { + print_object(" Old object = ",u); + + CONDOBJ& u2 = const_cast(u); + set_object(u2,(*it).second) ; + } + + const CONDOBJ& u3 = container->get(hid,igain); + print_object(" New object = ",u3); + + ++n; + } + ATH_MSG_INFO( " done for gain ="< + @brief fix electronic calibration constants for SC + + This should be used with FixLArElecSCCalib_jobOptions.py to write a new + POOL file. + + Implemented fixes: + + 1. Flag = 1 + scale values for Pedestals and Ramps by factor + 2. Flag = 2 + create calib. line mapping for SC + + +**/ + + +#include "FixLArElecSCCalib.h" +#include "Gaudi/Property.h" +#include "GaudiKernel/IToolSvc.h" + +#include "StoreGate/StoreGateSvc.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/CaloCell_SuperCell_ID.h" +#include "CaloIdentifier/CaloCell_Base_ID.h" +#include "CaloIdentifier/CaloGain.h" + +#include "LArCOOLConditions/LArPedestalSC.h" +#include "LArCOOLConditions/LArRampSC.h" + +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + +#include + +FixLArElecSCCalib::FixLArElecSCCalib(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name,pSvcLocator), + m_fixFlag(0), + m_em_idhelper(0), + m_hec_idhelper(0), + m_fcal_idhelper(0), + m_online_idhelper(0), + m_sem_idhelper(0), + m_shec_idhelper(0), + m_sfcal_idhelper(0), + m_sonline_idhelper(0), + m_scell_idhelper(0) +{ + + declareProperty("FixFlag", m_fixFlag); + declareProperty("FixFactor", m_fixFactor); + +} + +FixLArElecSCCalib::~FixLArElecSCCalib() +{ } + +StatusCode FixLArElecSCCalib::initialize() { + ATH_MSG_INFO ( " in initialize " ); + + ATH_CHECK( detStore()->retrieve(m_em_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_hec_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_fcal_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sem_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_shec_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sfcal_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_online_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_sonline_idhelper) ); + ATH_CHECK( detStore()->retrieve(m_scell_idhelper) ); + + ATH_CHECK( m_cablingKeySC.initialize() ); + ATH_CHECK( m_CLKeySC.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecSCCalib::execute() { + + ATH_MSG_INFO ( " in execute " ); + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecSCCalib::stop() { + + ATH_MSG_INFO ( " in stop " ); + + switch(m_fixFlag) { + case 1: return fix1(); + case 2: { + SG::ReadCondHandle cablingHdl{m_cablingKeySC}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKeySC.key() ); + return StatusCode::FAILURE; + } + SG::ReadCondHandle clHdl{m_CLKeySC}; + const LArCalibLineMapping *clCont {*clHdl}; + if(!clCont) { + ATH_MSG_ERROR( "Do not have calib line mapping !!!" ); + return StatusCode::FAILURE; + } + return fix2(cabling, clCont); + } + default: return StatusCode::SUCCESS; + } +} + +StatusCode FixLArElecSCCalib::fix1() { + + ATH_MSG_INFO ( " in fix1() " ); + + // Fix1 is for scaling the Pedestals and Rams + int n=0; + + const LArPedestalSC *ped = nullptr; + CHECK(detStore()->retrieve(ped, "Pedestal_orig")); + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("Pedestal", "blob"); + spec->extend("PedestalRMS", "blob"); + spec->extend("version"); + + CondAttrListCollection* collPed=new CondAttrListCollection(true); + + unsigned gain=0; + unsigned hashMax=m_sonline_idhelper->channelHashMax(); + coral::AttributeList* attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blobPed=(*attrList)["Pedestal"].data(); + coral::Blob& blobRMS=(*attrList)["PedestalRMS"].data(); + blobPed.resize(hashMax*sizeof(float)); + blobRMS.resize(hashMax*sizeof(float)); + float* pblobPed=static_cast(blobPed.startingAddress()); + float* pblobRMS=static_cast(blobRMS.startingAddress()); + + for (unsigned hs=0;hschannel_Id(hs); + float p=ped->pedestal(chid,gain); + float rms=ped->pedestalRMS(chid,gain); + + pblobPed[hs]=p*m_fixFactor; + pblobRMS[hs]=rms; + ++n; + }//end loop over hash ids + collPed->add(gain,*attrList); + + StatusCode sc=detStore()->record(collPed,"/LAR/ElecCalibMCSC/Pedestal"); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Failed to record CondAttrListCollection for pedestal " ); + return sc; + } + + ATH_MSG_DEBUG(" Number of entries changes in pedestals = " <retrieve(ramp, "Ramp_orig")); + + spec = new coral::AttributeListSpecification(); + spec->extend("RampVec", "blob"); + spec->extend("nPoints"); + spec->extend("version"); + CondAttrListCollection* coll=new CondAttrListCollection(true); + + + std::vector defaultRamp={0.0,1.0}; + + gain=0; + + unsigned nPoints=0; + unsigned nDefault=0; + for (unsigned hs=0;hschannel_Id(hs); + const ILArRamp::RampRef_t rampref= ramp->ADC2DAC(chid,gain); + nPoints=rampref.size(); + } + if (nPoints==0) { + ATH_MSG_ERROR( "All input Ramps for gain " << gain << " have 0 points!" ); + return StatusCode::FAILURE; + } + + defaultRamp.resize(nPoints,0.0); //fill remaining points if needed + ATH_MSG_DEBUG( "Gain " << gain << ": Found a ramp polynom of degree " << nPoints << " in input data" ); + attrList = new coral::AttributeList(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blobRamp=(*attrList)["RampVec"].data(); + (*attrList)["nPoints"].setValue(nPoints); + blobRamp.resize(hashMax*sizeof(float)*nPoints); + float* pblobRamp=static_cast(blobRamp.startingAddress()); + + for (unsigned hs=0;hschannel_Id(hs); + std::vector rampVec(ramp->ADC2DAC(chid,gain).asVector()); + + if (rampVec.size()>=nPoints) { + for (size_t i=0;iadd(gain,*attrList); + + sc=detStore()->record(coll,"/LAR/ElecCalibMCSC/Ramp"); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Failed to record CondAttrListCollection for ramp " ); + return StatusCode::FAILURE; + } + + ATH_MSG_INFO( "Converted Ramps to inline storage. Total number of channels " << n ); + ATH_MSG_INFO( "Number of channels filled with default ramp {0,1} " << nDefault << " (including disconnected)" ); + + return StatusCode::SUCCESS; +} + +StatusCode FixLArElecSCCalib::fix2(const LArOnOffIdMapping *cabling, const LArCalibLineMapping *cl) { + + ATH_MSG_INFO ( " in fix2() " ); + + const uint32_t onlHashMax=m_sonline_idhelper->channelHashMax(); // all SC cells + + coral::AttributeListSpecification* spec_calib = new coral::AttributeListSpecification(); + spec_calib->extend("OnlineHashToCalibIds", "blob"); + spec_calib->extend("version"); + AthenaAttributeList* al_calib = new AthenaAttributeList(*spec_calib); + coral::Blob& blobCalib=(*al_calib)["OnlineHashToCalibIds"].data(); + (*al_calib)["version"].setValue(0U); + blobCalib.resize(onlHashMax*sizeof(uint32_t)*5); //Bigger than necessary + ATH_MSG_DEBUG("blobCalib size: "<release(); + spec_calib = nullptr; + + uint32_t* pBlobCalib=static_cast(blobCalib.startingAddress()); + + size_t calibIndex=0; + + std::vector calibHist(17,0); + unsigned calibHistMax=0; + + std::ofstream outfile("SCIdentifiers.txt"); + + outfile << "hash id bec pn FT SL chan id calo pn sampl reg eta phi calib" << std::endl; + + for (uint32_t onlHash=0;onlHashchannel_Id(onlHash); + + const std::vector& calibIDs_tmp=cl->calibSlotLine(hwid); + std::vector calibIDs; + for (unsigned i=0; iisOnlineConnected(hwid)) { + *id=cabling->cnvToIdentifier(hwid); + print(hwid,dynamic_cast(m_sonline_idhelper), dynamic_cast(m_scell_idhelper), + id,&calibIDs,outfile); + } else { + print(hwid,dynamic_cast(m_sonline_idhelper), dynamic_cast(m_scell_idhelper), + nullptr,&calibIDs,outfile); + } + const size_t nCalibLines=calibIDs.size(); + if (nCalibLines > calibHistMax ) calibHistMax=nCalibLines; + if(calibHistMax > 17) { + ATH_MSG_ERROR( "Too much calib lines, adjust please !!!" << calibHistMax); + return StatusCode::FAILURE; + } + (calibHist[nCalibLines])++; + pBlobCalib[calibIndex++]=nCalibLines; + for(uint32_t iCalib=0;iCalibrecord(al_calib,"/LAR/IdentifierOfl/CalibIdMap_SC")); + + return StatusCode::SUCCESS; +} + +void FixLArElecSCCalib::print (const HWIdentifier& hwid, const LArOnlineID_Base* onlineID, const CaloCell_Base_ID* caloCellID, + const Identifier *id, std::vector* calibIDs, std::ostream& out) { + const IdentifierHash hwid_hash=onlineID->channel_Hash(hwid); + out << hwid_hash << " " << std::hex << "0x" << hwid.get_identifier32().get_compact() << std::dec << " " + << onlineID->barrel_ec(hwid) << " " + << onlineID->pos_neg(hwid) << " " + << onlineID->feedthrough(hwid) << " " + << onlineID->slot(hwid) << " " + << onlineID->channel(hwid) << " : "; + if (id) { + out << std::hex << "0x" << id->get_identifier32().get_compact() << std::dec << " " + << caloCellID->sub_calo(*id) << " " + << caloCellID->pos_neg(*id) << " " + << caloCellID->sampling(*id) << " " + << caloCellID->region(*id) << " " + << caloCellID->eta(*id) << " " + << caloCellID->phi(*id) << " "; + } + else + out << " disconnected "; + + if(calibIDs){ + for (size_t i=0;isize();++i) { + out << std::hex << "0x" << calibIDs->at(i).get_identifier32().get_compact() << " "; + } + } else + out << " no calib "; + + out << std::dec << std::endl; +} diff --git a/LArCalorimeter/LArCondTools/src/FixLArElecSCCalib.h b/LArCalorimeter/LArCondTools/src/FixLArElecSCCalib.h new file mode 100755 index 0000000000000000000000000000000000000000..eb2354a32a1753d331f45c48db4661851161f279 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/FixLArElecSCCalib.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FIXLARELECSCCALIB_H +#define FIXLARELECSCCALIB_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "Identifier/HWIdentifier.h" +#include "StoreGate/StoreGateSvc.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArCalibLineMapping.h" +#include + +class LArEM_ID ; +class LArHEC_ID; +class LArFCAL_ID; +class LArOnlineID_Base; +class LArOnlineID; +class LArOnline_SuperCellID; +class CaloCell_SuperCell_ID; + +#include "LArRawConditions/LArRampComplete.h" +#include "LArRawConditions/LArPedestalComplete.h" + +// class to collect fixes, needed for SuperCells conditions +// mainly to record, what was done, and as example, if other problems will need a fix +class FixLArElecSCCalib : public AthAlgorithm +{ + public: + FixLArElecSCCalib(const std::string& name,ISvcLocator* pSvcLocator); + virtual ~FixLArElecSCCalib(); + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override {return StatusCode::SUCCESS;} + virtual StatusCode stop() override; + + void print (const HWIdentifier& hwid, const LArOnlineID_Base* onlineID, const CaloCell_Base_ID* caloCellID, + const Identifier *id = nullptr, std::vector* calibIDs=nullptr,std::ostream& out=std::cout); + + StatusCode fix1(); + StatusCode fix2(const LArOnOffIdMapping *cabling, const LArCalibLineMapping *cl); + + private: + + SG::ReadCondHandleKey m_cablingKeySC{this,"SCCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_CLKeySC{this, "SCCalibLineKey", "LArCalibLineMapSC", "SG calib line key"}; + + + int m_fixFlag ; + double m_fixFactor; + + std::string m_infile; + + const LArEM_ID* m_em_idhelper; + const LArHEC_ID* m_hec_idhelper; + const LArFCAL_ID* m_fcal_idhelper; + const LArOnlineID* m_online_idhelper; + const LArEM_SuperCell_ID* m_sem_idhelper; + const LArHEC_SuperCell_ID* m_shec_idhelper; + const LArFCAL_SuperCell_ID* m_sfcal_idhelper; + const LArOnline_SuperCellID* m_sonline_idhelper; + const CaloCell_SuperCell_ID* m_scell_idhelper; +}; + +#endif // FixLArElecSCCalib diff --git a/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.cxx b/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.cxx new file mode 100644 index 0000000000000000000000000000000000000000..14addb19dfe4b3d5c32c593b476a0d56ca9c985c --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArFebRodMapConvert.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + +#include + +LArFebRodMapConvert::LArFebRodMapConvert( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ), + m_onlineID(nullptr) +{ + +} + +LArFebRodMapConvert::~LArFebRodMapConvert() + +{} + +StatusCode LArFebRodMapConvert::initialize() { + + ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID")); + + ATH_CHECK( m_cablingKey.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode LArFebRodMapConvert::finalize() +{ + + return StatusCode::SUCCESS; +} + + +StatusCode LArFebRodMapConvert::execute() { + + const uint32_t onlHashMax=m_onlineID-> febHashMax(); + + coral::AttributeListSpecification* spec_febrod = new coral::AttributeListSpecification(); + spec_febrod->extend("FebHashToRODs", "blob"); + spec_febrod->extend("version"); + AthenaAttributeList* al_febrod = new AthenaAttributeList(*spec_febrod); + (*al_febrod)["version"].setValue(0U); + coral::Blob& blobFebRod=(*al_febrod)["FebHashToRODs"].data(); + blobFebRod.resize(onlHashMax*sizeof(uint32_t)); + uint32_t* pBlobFebRod=static_cast(blobFebRod.startingAddress()); + + spec_febrod->release(); + // cppcheck-suppress memleak + spec_febrod = nullptr; + + size_t index=0; + + std::ofstream outfile("febrod.txt"); + if(!outfile.good()) { + ATH_MSG_ERROR("Could not open output file febrod.txt"); + return StatusCode::FAILURE; + } + + outfile << "hash id rodid" << std::endl; + + SG::ReadCondHandle cablingHdl{m_cablingKey}; + const LArFebRodMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() ); + return StatusCode::FAILURE; + } + + for (uint32_t onlHash=0;onlHashfeb_Id(onlHash); +#ifdef LARREADOUTMODULEID_H //Old version + const uint32_t rodid=cabling->getReadoutModuleID(hwid).id(); +#else //New version, LArReadoutModuleID replaced my HWIdentifier + const uint32_t rodid=cabling->getReadoutModuleID(hwid).get_identifier32().get_compact(); +#endif + pBlobFebRod[index++]=rodid; + outfile << onlHash << " 0x" << std:: hex << hwid.get_compact() << " 0x"<< rodid << std::dec << std::endl; + } + + outfile.close(); + + ATH_MSG_INFO("BlobSize OnOffId:" << index); + + ATH_CHECK(detStore()->record(al_febrod,"/LAR/Identifier/FebRodMap")); + + return StatusCode::SUCCESS; +} + diff --git a/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.h b/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.h new file mode 100644 index 0000000000000000000000000000000000000000..81ee58e7a6acf47e15a07eddae3742734ae018b4 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArFebRodMapConvert.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARCONDITIONSTEST_LARFEBRODMAPCONVERT_H +#define LARCONDITIONSTEST_LARFEBRODMAPCONVERT_H + +// STL includes +#include + +// FrameWork includes +#include "AthenaBaseComps/AthAlgorithm.h" +#include "LArRecConditions/LArFebRodMapping.h" +#include "StoreGate/ReadCondHandleKey.h" + +#include "CaloIdentifier/CaloCell_ID.h" +#include "LArIdentifier/LArOnlineID.h" + +#include + +class LArFebRodMapConvert + : public ::AthAlgorithm +{ + + public: + + /// Constructor with parameters: + LArFebRodMapConvert( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArFebRodMapConvert(); + + // Athena algorithm's Hooks + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + + SG::ReadCondHandleKey m_cablingKey{this,"RodCablingKey","ArFebRodMap","SG Key of ROD mapping object"}; + + /// Default constructor: + LArFebRodMapConvert(); + + const LArOnlineID* m_onlineID; + + +}; + +#endif //> !LARCONDITIONSTEST_LARIDMAPCONVERT_H diff --git a/LArCalorimeter/LArCondTools/src/LArFlatFromFile.cxx b/LArCalorimeter/LArCondTools/src/LArFlatFromFile.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dd7f429cca1879bd809bde03ca40cd68b010b7f8 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArFlatFromFile.cxx @@ -0,0 +1,272 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArFlatFromFile.h" +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "LArCOOLConditions/LArOFCFlat.h" + +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + +#include + +LArFlatFromFile::LArFlatFromFile( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ), + m_hashMax(0), + m_onlineID(0), m_onlineSCID(0) +{ + +} + +StatusCode LArFlatFromFile::initialize() +{ + ATH_CHECK(m_cablingKey.initialize()); + return StatusCode::SUCCESS; +} + + + +void LArFlatFromFile::singleFloatFlat(const char* blobName, const std::string& input, + const std::string& outputName, const unsigned nGain) { + + unsigned nChannels=0; + unsigned nCopiedEMPS=0; + unsigned nDefault=0; + + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend(blobName, "blob"); + spec->extend("version"); + std::unique_ptr coll= std::make_unique(true); + // we expect line per channel with Id, hash and value + std::ifstream myfile(input); + unsigned long id; + unsigned hash; + std::string line; + while (std::getline(myfile, line)) { + for (unsigned gain=0;gain(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& blob=(*attrList)[blobName].data(); + blob.resize(m_hashMax*sizeof(float)); + float* pblob=static_cast(blob.startingAddress()); + for (unsigned hs=0;hschannel_Id(hs); + float value; + std::stringstream st(line); + st>>std::hex>>id>>std::dec>>hash>>value; + if (value < 0) { + errIfConnected(chid,gain,blobName); + value=1.0; //Default vaue is 1.0, since these are multiplicative constants + ++nDefault; + } + pblob[hs]=value; + ++nChannels; + } + unsigned coolChan=gain; + //Special case: Store single-gain constant in channel 1 + //To avoid AttrList vs AttrListCollection confusion in Athena DB infrastructure + if (nGain==1) coolChan=1; + + coll->add(coolChan,*attrList.release()); + } + } + + ATH_MSG_INFO( "Converted " << blobName << " to inline storage. Total number of channels=" << nChannels ); + ATH_MSG_INFO( "Number of channels filled with default value (1.0) " << nDefault << " (including disconnected)" ); + if (nCopiedEMPS) + ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS ); + StatusCode sc=detStore()->record(std::move(coll),outputName); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Failed to record CondAttrListCollection with key" << outputName ); + return; + } + return; +} + + +void LArFlatFromFile::ofcFlat(const std::string& input, const std::string& outputName) { + + ATH_MSG_INFO("LArFlatFromFile::ofcFlat, starting"); + // parsing the file, fill OFC arrays + std::vector > > vofc_a; //[ngain][nchannel][nsamples] + std::vector > > vofc_b; + vofc_a.resize(m_ngain); + vofc_b.resize(m_ngain); + for (unsigned i=0; i>std::hex>>id>>std::dec>>hash; + std::stringstream st1(line1); + st>>std::hex>>id1>>std::dec>>hash1; + // check equality of Id and has in both lines + if(id != id1 || hash != hash1) { + ATH_MSG_ERROR("Different input id or hash: "<>mychar; + st1>>mychar1; + if(mychar != 'a' || mychar1 != 'b') { + ATH_MSG_ERROR("Wrong OFC type: "<extend("OFCa", "blob"); + spec->extend("OFCb", "blob"); + spec->extend("TimeOffset","blob"); + spec->extend("nSamples"); + spec->extend("version"); + auto collOFC = std::make_unique(true); + + float timeOffset=0.; + + for (unsigned gain=0;gain(*spec); + (*attrList)["version"].setValue(0U); + coral::Blob& ofcaBlob=(*attrList)["OFCa"].data(); + coral::Blob& ofcbBlob=(*attrList)["OFCb"].data(); + coral::Blob& toBlob=(*attrList)["TimeOffset"].data(); + + (*attrList)["nSamples"].setValue(m_nsample); + + ofcaBlob.resize(m_hashMax*sizeof(float)*m_nsample); + ofcbBlob.resize(m_hashMax*sizeof(float)*m_nsample); + toBlob.resize(m_hashMax*sizeof(float)); + float* pOfca=static_cast(ofcaBlob.startingAddress()); + float* pOfcb=static_cast(ofcbBlob.startingAddress()); + float* pTimeOffset=static_cast(toBlob.startingAddress()); + for (unsigned hs=0;hschannel_Id(hs); + LArOFCFlat::OFCRef_t ofca(vofc_a[gain][hs]); + LArOFCFlat::OFCRef_t ofcb(vofc_b[gain][hs]); + + if (ofca.size()==m_nsample) { + for (unsigned i=0;iadd(gain,*(attrList.release())); + }//end loop over gains + + StatusCode sc=detStore()->record(std::move(collOFC),outputName);//"/LAR/ElecCalibFlat/OFC"); + if (sc.isFailure()) { + ATH_MSG_ERROR( "Failed to record CondAttrListCollection OFC with key " << outputName ); + return; + } + + ATH_MSG_INFO( "Converted OFCs to inline storage. Total number of channels=" << nChannels ); + ATH_MSG_INFO( "Number of channels filled with default OFCs {1,1,1,1} " << nDefault << " (including disconnected)" ); + return; +} + + + +StatusCode LArFlatFromFile::stop() { + + + ATH_CHECK( detStore()->retrieve(m_onlineID)); + ATH_CHECK( detStore()->retrieve(m_onlineSCID)); + + if(m_isSC) + m_hashMax=m_onlineSCID->channelHashMax(); + else + m_hashMax=m_onlineID->channelHashMax(); + + + + //OFC: + if (m_OFCInput.size()) { + std::ifstream myfile(m_OFCInput); + // new lines will be skipped unless we stop it from happening: + myfile.unsetf(std::ios_base::skipws); + + // count the newlines with an algorithm specialized for counting: + unsigned line_count = std::count( std::istream_iterator(myfile), + std::istream_iterator(), '\n'); + myfile.close(); + if (2*m_hashMax != line_count) { + ATH_MSG_ERROR( "Failed to check file with OFCs" ); + return StatusCode::FAILURE; + } else { + if(m_isSC) + ofcFlat(m_OFCInput,"/LAR/ElecCalibSC/OFC"); + else + ofcFlat(m_OFCInput,"/LAR/ElecCalibFlat/OFC"); + } + }//end have m_OFCInput + + + return StatusCode::SUCCESS; +} + + + + + +void LArFlatFromFile::errIfConnected(const HWIdentifier chid, const int gain, const std::string& objName, const std::string& message) const{ + + SG::ReadCondHandle cablingHdl{m_cablingKey}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() ); + return; + } + + if (cabling->isOnlineConnected(chid)) { + if (! (gain==2 && m_onlineID->isEMBPS(chid))) { //No LG Presampler calibration + ATH_MSG_ERROR( "No valid " << objName << " found for channel " << m_onlineID->channel_name(chid) << ", gain " << gain << ". "); + if (message.size()>0) ATH_MSG_ERROR( message ); + ATH_MSG_ERROR( " Filling with default value." ); + } + } + return; +} diff --git a/LArCalorimeter/LArCondTools/src/LArFlatFromFile.h b/LArCalorimeter/LArCondTools/src/LArFlatFromFile.h new file mode 100644 index 0000000000000000000000000000000000000000..b378757cf87aaac78d74dbef6099c625d17f2620 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArFlatFromFile.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef LARFLATFROMFILE_H +#define LARFLATFROMFILE_H 1 + +#include +#include "AthenaBaseComps/AthAlgorithm.h" +#include "LArRawConditions/LArSingleFloatP.h" +#include "LArCabling/LArOnOffIdMapping.h" +#include "StoreGate/ReadCondHandleKey.h" + +class LArOnlineID; +class LArOnline_SuperCellID; +class AthenaAttributeList; + +class LArFlatFromFile: public AthAlgorithm +{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + /// Constructor with parameters: + LArFlatFromFile( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArFlatFromFile()=default; + + // Athena algorithm's Hooks + virtual StatusCode initialize() override; + virtual StatusCode execute() override {return StatusCode::SUCCESS;} + virtual StatusCode finalize() override {return StatusCode::SUCCESS;} + virtual StatusCode stop() override; + + private: + /// Default constructor: + LArFlatFromFile(); + + + void singleFloatFlat(const char* blobName, const std::string& input, + const std::string& outputName, const unsigned nGain); + void ofcFlat(const std::string& input, const std::string& outputName); + + + void errIfConnected(const HWIdentifier chid, const int gain, const std::string& objName, const std::string& message=0) const; + + unsigned m_hashMax; + const LArOnlineID* m_onlineID; + const LArOnline_SuperCellID* m_onlineSCID; + + + SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + + ///Input files + Gaudi::Property m_OFCInput{this, "OFCInput","","Input file name"}; + + // SC switch + Gaudi::Property m_isSC{this,"SuperCells",false,"Run for SC ?"}; + Gaudi::Property m_ngain{this,"NGains",1,"Number of gains to process"}; + Gaudi::Property m_nsample{this,"NSamples",4,"Number of samples to process"}; + + bool m_forceStop; +}; + +#endif diff --git a/LArCalorimeter/LArCondTools/src/LArIdMapConvert.cxx b/LArCalorimeter/LArCondTools/src/LArIdMapConvert.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ac14ac017a84d6d969c5780c6a14728863978fa9 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArIdMapConvert.cxx @@ -0,0 +1,170 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArIdMapConvert.h" + +#include "LArIdentifier/LArOnlineID.h" +#include "AthenaPoolUtilities/AthenaAttributeList.h" +#include "CoralBase/Blob.h" + +#include + +LArIdMapConvert::LArIdMapConvert( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ), + m_onlineID(nullptr), + m_caloCellID(nullptr) +{ + +} + +LArIdMapConvert::~LArIdMapConvert() + +{} + +StatusCode LArIdMapConvert::initialize() { + + ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID")); + + ATH_CHECK(detStore()->retrieve(m_caloCellID, "CaloCell_ID")); + + ATH_CHECK( m_cablingKey.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode LArIdMapConvert::finalize() +{ + + return StatusCode::SUCCESS; +} + + +StatusCode LArIdMapConvert::execute() { + + const uint32_t onlHashMax=m_onlineID->channelHashMax(); + + SG::ReadCondHandle cablingHdl{m_cablingKey}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() ); + return StatusCode::FAILURE; + } + SG::ReadCondHandle clHdl{m_CLKey}; + const LArCalibLineMapping *clCont {*clHdl}; + if(!clCont) { + ATH_MSG_ERROR( "Do not have calib line mapping !!!" ); + return StatusCode::FAILURE; + } + + coral::AttributeListSpecification* spec_onOff = new coral::AttributeListSpecification(); + spec_onOff->extend("OnlineHashToOfflineId", "blob"); + spec_onOff->extend("version"); + AthenaAttributeList* al_onOff = new AthenaAttributeList(*spec_onOff); + coral::Blob& blobOnOff=(*al_onOff)["OnlineHashToOfflineId"].data(); + (*al_onOff)["version"].setValue(0U); + blobOnOff.resize(onlHashMax*sizeof(uint32_t)); + + spec_onOff->release(); + // cppcheck-suppress memleak + spec_onOff = nullptr; + + coral::AttributeListSpecification* spec_calib = new coral::AttributeListSpecification(); + spec_calib->extend("OnlineHashToCalibIds", "blob"); + spec_calib->extend("version"); + AthenaAttributeList* al_calib = new AthenaAttributeList(*spec_calib); + coral::Blob& blobCalib=(*al_calib)["OnlineHashToCalibIds"].data(); + (*al_calib)["version"].setValue(0U); + blobCalib.resize(onlHashMax*sizeof(uint32_t)*3); //Bigger than necessary + + spec_calib->release(); + // cppcheck-suppress memleak + spec_calib = nullptr; + + uint32_t* pBlobOnOff=static_cast(blobOnOff.startingAddress()); + uint32_t* pBlobCalib=static_cast(blobCalib.startingAddress()); + + size_t index=0; + size_t calibIndex=0; + + std::vector calibHist(5,0); + + std::ofstream outfile("identifiers.txt"); + + outfile << "hash id bec pn FT SL chan id calo pn sampl reg eta phi calib" << std::endl; + + for (uint32_t onlHash=0;onlHashchannel_Id(onlHash); + print(hwid,outfile); + const Identifier id=cabling->cnvToIdentifierFromHash(onlHash); + pBlobOnOff[index++]=id.get_identifier32().get_compact(); + + const std::vector& calibIDs=clCont->calibSlotLine(hwid); + const size_t nCalibLines=calibIDs.size(); + (calibHist[nCalibLines])++; + pBlobCalib[calibIndex++]=nCalibLines; + for(uint32_t iCalib=0;iCalibrecord(al_onOff,"/LAR/Identifier/OnOffIdMap")); + + ATH_CHECK(detStore()->record(al_calib,"/LAR/Identifier/CalibIdMap")); + + return StatusCode::SUCCESS; +} + + +void LArIdMapConvert::print (const HWIdentifier& hwid, std::ostream& out) { + const IdentifierHash hwid_hash=m_onlineID->channel_Hash(hwid); + SG::ReadCondHandle cablingHdl{m_cablingKey}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() ); + return; + } + SG::ReadCondHandle clHdl{m_CLKey}; + const LArCalibLineMapping *clCont {*clHdl}; + if(!clCont) { + ATH_MSG_ERROR( "Do not have calib line mapping !!!" ); + return; + } + out << hwid_hash << " " << std::hex << "0x" << hwid.get_identifier32().get_compact() << std::dec << " " + << m_onlineID->barrel_ec(hwid) << " " + << m_onlineID->pos_neg(hwid) << " " + << m_onlineID->feedthrough(hwid) << " " + << m_onlineID->slot(hwid) << " " + << m_onlineID->channel(hwid) << " : "; + if (cabling->isOnlineConnected(hwid)) { + const Identifier id=cabling->cnvToIdentifier(hwid); + out << std::hex << "0x" << id.get_identifier32().get_compact() << std::dec << " " + << m_caloCellID->sub_calo(id) << " " + << m_caloCellID->pos_neg(id) << " " + << m_caloCellID->sampling(id) << " " + << m_caloCellID->region(id) << " " + << m_caloCellID->eta(id) << " " + << m_caloCellID->phi(id) << " "; + } + else + out << " disconnected "; + + const std::vector& calibIDs=clCont->calibSlotLine(hwid); + for (size_t i=0;i + +// FrameWork includes +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "LArCabling/LArOnOffIdMapping.h" +#include "LArRecConditions/LArCalibLineMapping.h" +#include "StoreGate/ReadCondHandleKey.h" + +#include "CaloIdentifier/CaloCell_ID.h" +#include "LArIdentifier/LArOnlineID.h" + +#include + +class LArIdMapConvert + : public ::AthAlgorithm +{ + + public: + + /// Constructor with parameters: + LArIdMapConvert( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArIdMapConvert(); + + // Athena algorithm's Hooks + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + + SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_CLKey{this, "SCCalibLineKey", "LArCalibLineMapSC", "SG calib line key"}; + + /// Default constructor: + LArIdMapConvert(); + void print (const HWIdentifier& hwid, std::ostream& out=std::cout); + + const LArOnlineID* m_onlineID; + const CaloCell_ID* m_caloCellID; + + +}; + +#endif //> !LARCONDITIONSTEST_LARIDMAPCONVERT_H diff --git a/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.cxx b/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5abc4cf16f16ef3cbb57e9ae875bd6d4a183ae70 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.cxx @@ -0,0 +1,195 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArOFCtoOFC.h" +#include "LArRawConditions/LArOFCComplete.h" +#include "LArRawConditions/LArShapeComplete.h" +#include "CaloIdentifier/CaloGain.h" +#include "LArIdentifier/LArOnlineID.h" +#include "LArElecCalib/LArCalibErrorCode.h" + +#include "AthenaKernel/errorcheck.h" + +#include "Gaudi/Property.h" + + + +LArOFCtoOFC::LArOFCtoOFC( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ) +{ + // + // Property declaration + // + declareProperty("inKey",m_inKey="LArOFC_4_3_picked"); + declareProperty("inShapeKey",m_inShapeKey="LArShape_4_3_picked"); + declareProperty("outKey",m_outKey="LArOFC"); + declareProperty("outShapeKey",m_outShapeKey="LArShape"); + declareProperty("ShiftHEC",m_HECshift=true); + declareProperty("doShape",m_doShape=false); + declareProperty("NullsAdded",m_numAdd=1); + + + +} + + +StatusCode LArOFCtoOFC::stop() +{ + ATH_MSG_DEBUG ("in stop " << name() << "..."); + + + //Retrieve OFC computed + const LArOFCComplete* cellOFC; + CHECK(detStore()->retrieve(cellOFC,m_inKey)); + + //Retrive online id + const LArOnlineID* onlID; + CHECK(detStore()->retrieve(onlID)); + + //Retrieve shape + const LArShapeComplete* cellShape; + if(m_doShape) { + CHECK(detStore()->retrieve(cellShape,m_inShapeKey)); + } + + std::unique_ptr ofc_cont(new LArOFCComplete()); + ofc_cont->setGroupingType(LArConditionsContainerBase::ExtendedSubDetGrouping); + ATH_CHECK( ofc_cont->initialize() ); + + //LArShapeComplete *shape_cont = nullptr; + std::unique_ptr shape_cont; + if(m_doShape) { + shape_cont = std::unique_ptr(new LArShapeComplete()); + shape_cont->setGroupingType(LArConditionsContainerBase::ExtendedSubDetGrouping); + ATH_CHECK( shape_cont->initialize() ); + } + + unsigned count=0, countsh=0; + for(unsigned int gain = CaloGain::LARHIGHGAIN; gain < CaloGain::LARNGAIN; ++gain) { + LArOFCComplete::ConstConditionsMapIterator it=cellOFC->begin(gain); + LArOFCComplete::ConstConditionsMapIterator it_e=cellOFC->end(gain); + for(; it!=it_e;++it){ + LArOFCComplete::ConstReference ofc=(*it); + const HWIdentifier id = it.channelId() ; + const int nPhases=ofc.OFC_aSize(); + const float timeOffset=ofc.timeOffset(); + const float timeBinWidth=ofc.timeBinWidth(); + if (nPhases==0) { + ATH_MSG_DEBUG("Got empty OFC object for channel " << onlID->channel_name(id) << " (disconnected?)"); + continue; + } + count++; + + std::vector > OFC_a; + std::vector > OFC_b; + for(int phase=0; phasechannel_name(id) ); + }else if ( vOFC_a.size() != vOFC_b.size() ) { // different size of OFCs + ATH_MSG_WARNING( "OFC a (" << vOFC_a.size() << ") and b (" << vOFC_b.size() << ") are not the same size for channel " << onlID->channel_name(id) ); + ATH_MSG_WARNING( "Will be not exported !!!" ); + } else { // we have OFCs + if(m_numAdd > 0) { // save in new container, adding 0 appropriatly + std::vector newOFCa=vOFC_a.asVector(); + std::vector newOFCb=vOFC_b.asVector(); + if(m_HECshift && onlID->isHECchannel(id)) { // in this case put 0 to front + for(unsigned i=0; iisEMBPS(id)) || gain != CaloGain::LARMEDIUMGAIN ) continue; + OFC_a.push_back(vOFC_a.asVector()); + OFC_b.push_back(vOFC_b.asVector()); + + } + } + } // over phases + if(m_numAdd > 0) ofc_cont->set(id,(int)gain,OFC_a,OFC_b,timeOffset,timeBinWidth); + else if(OFC_a.size() > 0) ofc_cont->set(id,CaloGain::LARLOWGAIN,OFC_a,OFC_b,timeOffset,timeBinWidth); + } // over channels + + if(m_doShape) { // if also shape needed + LArShapeComplete::ConstConditionsMapIterator its=cellShape->begin(gain); + LArShapeComplete::ConstConditionsMapIterator its_e=cellShape->end(gain); + for(; its!=its_e;++its){ + LArShapeComplete::ConstReference shape=(*its); + const HWIdentifier id = its.channelId() ; + const int nPhases=shape.shapeSize(); + const float timeOffset=shape.timeOffset(); + const float timeBinWidth=shape.timeBinWidth(); + if (nPhases==0) { + ATH_MSG_DEBUG("Got empty Shape object for channel " << onlID->channel_name(id) << " (disconnected?)"); + continue; + } + countsh++; + + std::vector > Shape; + std::vector > ShapeDer; + for(int phase=0; phasechannel_name(id) ); + }else if ( vShape.size() != vShapeDer.size() ) { + ATH_MSG_WARNING( "Shape (" << vShape.size() << ") and ShapeDer (" << vShapeDer.size() << ") are not the same size for channel " << onlID->channel_name(id) ); + ATH_MSG_WARNING( "Will be not exported !!!" ); + } else { + if(m_numAdd > 0) {// save in new container, adding 0 appropriatly + std::vector newShape=vShape.asVector(); + std::vector newShapeDer=vShapeDer.asVector(); + if(m_HECshift && onlID->isHECchannel(id)) { // in this case put 0 to front + for(unsigned i=0; iisEMBPS(id)) || gain != CaloGain::LARMEDIUMGAIN ) continue; + Shape.push_back(vShape.asVector()); + ShapeDer.push_back(vShapeDer.asVector()); + } + } + } // over phases + if(m_numAdd > 0) { + shape_cont->set(id,(int)gain,Shape,ShapeDer,timeOffset,timeBinWidth); + } else { + if(Shape.size() > 0) shape_cont->set(id,CaloGain::LARLOWGAIN,Shape,ShapeDer,timeOffset,timeBinWidth); + } + } // over channels + } // if m_doShape + + } // over gains + + ATH_MSG_INFO( "Total number of Cell x gains:" << count ); + LArOFCComplete *ofcptr = ofc_cont.get(); + CHECK(detStore()->record(std::move(ofc_cont),m_outKey)); + CHECK(detStore()->symLink(ofcptr,dynamic_cast(ofcptr))); + if(m_doShape){ + LArShapeComplete *shapeptr = shape_cont.get(); + CHECK(detStore()->record(std::move(shape_cont),m_outShapeKey)); + CHECK(detStore()->symLink(shapeptr,dynamic_cast(shapeptr))); + } + + return StatusCode::SUCCESS; +} + diff --git a/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.h b/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.h new file mode 100644 index 0000000000000000000000000000000000000000..0e22d2d661705cc50c9ca7110b3e92fe06442a4c --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArOFCtoOFC.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARCONDITIONSTEST_LAROFCTOOFC_H +#define LARCONDITIONSTEST_LAROFCTOOFC_H 1 + +// STL includes +#include + +#include "AthenaBaseComps/AthAlgorithm.h" + + +class LArOFCtoOFC + : public ::AthAlgorithm +{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + /// Constructor with parameters: + LArOFCtoOFC( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArOFCtoOFC(){}; + + virtual StatusCode initialize() override {return StatusCode::SUCCESS;}; + virtual StatusCode execute() override {return StatusCode::SUCCESS;}; + virtual StatusCode stop() override; + + private: + + /// Default constructor: + LArOFCtoOFC(); + + std::string m_inKey; + std::string m_inShapeKey; + std::string m_outKey; + std::string m_outShapeKey; + bool m_HECshift; // add 0 in front for HEC ? + bool m_doShape; // fill also the shape ? + unsigned m_numAdd; // How many 0 to add + +}; + +#endif //> !LARCONDITIONSTEST_LArOFCtoOFC_H diff --git a/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.cxx b/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5ae397b8abc1d828d3bbf37ff646294ffddf166d --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.cxx @@ -0,0 +1,188 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArShapeToSCShape.h" +#include "CaloDetDescr/ICaloSuperCellIDTool.h" +#include "LArElecCalib/ILArShape.h" +#include "LArCOOLConditions/LArShapeSC.h" +#include "CaloIdentifier/CaloCell_SuperCell_ID.h" + +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "LArElecCalib/LArCalibErrorCode.h" + +#include "AthenaPoolUtilities/CondAttrListCollection.h" +#include "CoralBase/Blob.h" + +#include "AthenaKernel/errorcheck.h" + +// FrameWork includes +#include "Gaudi/Property.h" + + + +/////////////////////////////////////////////////////////////////// +// Public methods: +/////////////////////////////////////////////////////////////////// + +// Constructors +//////////////// +LArShapeToSCShape::LArShapeToSCShape( const std::string& name, + ISvcLocator* pSvcLocator ) : + ::AthAlgorithm( name, pSvcLocator ) +{ +} + +// Destructor +/////////////// +LArShapeToSCShape::~LArShapeToSCShape() +{} + +// Athena Algorithm's Hooks +//////////////////////////// +StatusCode LArShapeToSCShape::initialize() +{ + + ATH_CHECK(m_scidTool.retrieve()); + ATH_CHECK(m_cablingKeySC.initialize()); + ATH_CHECK(m_cablingKey.initialize()); + ATH_MSG_DEBUG ("Initializing " << name() << "..."); + + + + return StatusCode::SUCCESS; +} + + +StatusCode LArShapeToSCShape::execute() +{ + ATH_MSG_DEBUG ("Executing " << name() << "..."); + + + //Retrieve shape for regular cells + const ILArShape* cellShape; + CHECK(detStore()->retrieve(cellShape,"LArShape")); + + //Retrieve SuperCell id + const CaloCell_SuperCell_ID* caloSCID; + CHECK(detStore()->retrieve(caloSCID)); + + //Retrive SuperCell online id + const LArOnline_SuperCellID* onlSCID; + CHECK(detStore()->retrieve(onlSCID)); + + const EventContext& ctx = Gaudi::Hive::currentContext(); + + SG::ReadCondHandle cablingHdl{m_cablingKey, ctx}; + const LArOnOffIdMapping* cabling{*cablingHdl}; + if(!cabling) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() ); + return StatusCode::FAILURE; + } + + SG::ReadCondHandle cablingHdlSC{m_cablingKeySC, ctx}; + const LArOnOffIdMapping* cablingSC{*cablingHdlSC}; + if(!cablingSC) { + ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKeySC.key() ); + return StatusCode::FAILURE; + } + + const unsigned hashMax=onlSCID->channelHashMax(); + ATH_MSG_DEBUG("SuperCell online hash max: " << hashMax); + + //Set up AttributeListCollection + coral::AttributeListSpecification* spec = new coral::AttributeListSpecification(); + spec->extend("Shape", "blob"); + spec->extend("ShapeDer", "blob"); + spec->extend("TimeOffset","blob"); + spec->extend("nSamples"); + spec->extend("version"); + + unsigned nSamples=32; //Assumption.... + + const unsigned blobSize=hashMax*nSamples; + ATH_MSG_DEBUG("Shape blob has size " << blobSize); + + coral::AttributeList attrList(*spec); + attrList["version"].setValue(0U); + coral::Blob& shapeBlob=attrList["Shape"].data(); + coral::Blob& shapeDerBlob=attrList["ShapeDer"].data(); + coral::Blob& toBlob=attrList["TimeOffset"].data(); + + spec->release(); + // cppcheck-suppress memleak + spec = nullptr; + + attrList["nSamples"].setValue(nSamples); + shapeBlob.resize(blobSize*sizeof(float)); + shapeDerBlob.resize(blobSize*sizeof(float)); + toBlob.resize(hashMax*sizeof(float)); + + float *pShape=static_cast(shapeBlob.startingAddress()); + float *pShapeDer=static_cast(shapeDerBlob.startingAddress()); + float *pTimeOffset=static_cast(toBlob.startingAddress()); + + + //Initialize blobs to ERRORCODE + for (unsigned i=0;icell_begin(); + auto scIt_e=caloSCID->cell_end(); + for (;scIt!=scIt_e;++scIt) { + ++nTotalIds; + const Identifier scId=*scIt; + if (caloSCID->is_tile(scId)) { + ++nTileIds; + continue; + } + //const IdentifierHash scHash=caloSCID->calo_cell_hash(scId); + const std::vector &cellIds=m_scidTool->superCellToOfflineID(scId); + if (cellIds.empty()) { + ATH_MSG_WARNING("Got empty vector of cell ids for super cell id 0x" + << std::hex << scId.get_compact()); + } + const Identifier cellId=cellIds[0]; + + //Get online hash (via online identifier): + const HWIdentifier scOnlId=cablingSC->createSignalChannelID(scId); + const IdentifierHash scOnlHash=onlSCID->channel_Hash(scOnlId); + + auto shape=cellShape->Shape(cabling->createSignalChannelID(cellId),0); + auto shapeDer=cellShape->ShapeDer(cabling->createSignalChannelID(cellId),0); + //consistency check + if (nSamples!=shape.size() || nSamples!=shapeDer.size()) { + ATH_MSG_ERROR("Inconsistent number of samples!"); + ATH_MSG_ERROR("Expected" << nSamples << ", Shape:" << shape.size() << ", ShapeDer:" << shapeDer.size()); + return StatusCode::FAILURE; + } + for (unsigned i=0;irecord(coll,"/LAR/ElecCalibSC/Shape")); + coll->add(0,attrList); + + ATH_MSG_INFO("Total number of SuperCells:" << nTotalIds << ", Tile:" << nTileIds + << ", LAr: " << nTotalIds-nTileIds); + LArShapeSC* scShape=new LArShapeSC(coll); + CHECK(detStore()->record(scShape,"ShapeSC")); + + return StatusCode::SUCCESS; +} + diff --git a/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.h b/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.h new file mode 100644 index 0000000000000000000000000000000000000000..bdeed100578a8e9d3da641e1ae9617037e576210 --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/LArShapeToSCShape.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARCONDITIONSTEST_LARSHAPETOSCSHAPE_H +#define LARCONDITIONSTEST_LARSHAPETOSCSHAPE_H 1 + +// STL includes +#include + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "CaloDetDescr/ICaloSuperCellIDTool.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "LArCabling/LArOnOffIdMapping.h" + +#include "GaudiKernel/ToolHandle.h" + +class LArShapeToSCShape + : public ::AthAlgorithm +{ + + /////////////////////////////////////////////////////////////////// + // Public methods: + /////////////////////////////////////////////////////////////////// + public: + + /// Constructor with parameters: + LArShapeToSCShape( const std::string& name, ISvcLocator* pSvcLocator ); + + /// Destructor: + virtual ~LArShapeToSCShape(); + + // Assignment operator: + //LArShapeToSCShape &operator=(const LArShapeToSCShape &alg); + + // Athena algorithm's Hooks + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + + private: + + SG::ReadCondHandleKey m_cablingKeySC{this,"SCCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}; + SG::ReadCondHandleKey m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}; + /// Default constructor: + LArShapeToSCShape(); + + ToolHandle m_scidTool{this, "CaloSuperCellIDTool", "CaloSuperCellIDTool"}; + + + +}; + +#endif //> !LARCONDITIONSTEST_LARSHAPETOSCSHAPE_H diff --git a/LArCalorimeter/LArCondTools/src/components/LArCondTools_entries.cxx b/LArCalorimeter/LArCondTools/src/components/LArCondTools_entries.cxx new file mode 100755 index 0000000000000000000000000000000000000000..b93a21298d5d9902c3c5499b3bfd1c24dd324c8e --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/components/LArCondTools_entries.cxx @@ -0,0 +1,16 @@ +#include "../FixLArElecCalib.h" +#include "../FixLArElecSCCalib.h" +#include "../LArIdMapConvert.h" +#include "../LArFebRodMapConvert.h" +#include "../LArShapeToSCShape.h" +#include "../LArOFCtoOFC.h" +#include "../LArFlatFromFile.h" + +DECLARE_COMPONENT( FixLArElecCalib ) +DECLARE_COMPONENT( FixLArElecSCCalib ) +DECLARE_COMPONENT ( LArIdMapConvert ) +DECLARE_COMPONENT ( LArFebRodMapConvert ) +DECLARE_COMPONENT ( LArShapeToSCShape ) +DECLARE_COMPONENT ( LArOFCtoOFC ) +DECLARE_COMPONENT ( LArFlatFromFile ) + diff --git a/LArCalorimeter/LArCondTools/src/components/LArCondTools_load.cxx b/LArCalorimeter/LArCondTools/src/components/LArCondTools_load.cxx new file mode 100755 index 0000000000000000000000000000000000000000..6e3d40c3c9cbd976fea382b8b66e7025208b4b9b --- /dev/null +++ b/LArCalorimeter/LArCondTools/src/components/LArCondTools_load.cxx @@ -0,0 +1,3 @@ +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(LArConditionsTest) diff --git a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Delay_OFC_Cali_jobOptions.py b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Delay_OFC_Cali_jobOptions.py index b8de2c1220d207d5e80a63173cef5f299f288ad1..410bc48b87ae4a53627626518b1756b3ed1ef2aa 100644 --- a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Delay_OFC_Cali_jobOptions.py +++ b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Delay_OFC_Cali_jobOptions.py @@ -109,11 +109,11 @@ if not 'allCells' in dir(): if not 'usePatt' in dir(): usePatt = -1 -if not 'numPatt' in dir(): - if 'EMB' in Partition: - numPatt = 16 - else: - numPatt = 14 +if 'useParams' not in dir(): + useParams = False + +if useParams and 'paramsFile' not in dir(): + paramsFile = 'LArCalibProcessing/LArCalib_CalibrationPatterns.py' ####################################################### # Monitoring properties @@ -393,6 +393,8 @@ DelayOFCLog.info( " ======================================================== " ) include ("LArConditionsCommon/LArMinimalSetup.py") from LArCabling.LArCablingAccess import LArOnOffIdMapping LArOnOffIdMapping() +from LArCabling.LArCablingAccess import LArCalibIdMapping +LArCalibIdMapping() if SuperCells: from LArCabling.LArCablingAccess import LArOnOffIdMappingSC,LArCalibIdMappingSC,LArLATOMEMappingSC LArOnOffIdMappingSC() @@ -599,7 +601,7 @@ if (SubtractPed): PedestalTagSpec = LArCalibFolderTag (PedestalFolder,PedLArCalibFolderTag) PedChannelSelection=ChannelSelection - conddb.addFolder("",PedestalFolder+""+PedestalTagSpec+""+""+InputDBConnectionPed+""+PedChannelSelection) + conddb.addFolder("",PedestalFolder+""+PedestalTagSpec+""+""+InputDBConnectionPed+""+PedChannelSelection,className="LArPedestalComplete") else: if 'InputPedPoolFileName' in dir(): DelayOFCLog.info( "Read Pedestal from POOL file") @@ -651,7 +653,9 @@ LArCaliWaveBuilder.UseDacAndIsPulsedIndex = False # should have an impact only f LArCaliWaveBuilder.RecAllCells = RecAllCells LArCaliWaveBuilder.isSC = SuperCells LArCaliWaveBuilder.UsePattern = usePatt -LArCaliWaveBuilder.NumPattern = numPatt +LArCaliWaveBuilder.UseParams = useParams +if useParams: + include(paramsFile) if StripsXtalkCorr: LArCaliWaveBuilder.ADCsaturation = 0 diff --git a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_PedestalAutoCorr_jobOptions.py b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_PedestalAutoCorr_jobOptions.py index d4e9e5c9eb0c7d82e935ce3b4cd2cd9e496084b2..ce85eb2cc2bc6298d27d6576dc2b54d20a1bb8d8 100644 --- a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_PedestalAutoCorr_jobOptions.py +++ b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_PedestalAutoCorr_jobOptions.py @@ -16,8 +16,10 @@ import subprocess if not "SuperCells" in dir(): SuperCells=False -#if not 'SC_SampleShift' in dir(): -# SC_SampleShift=0 + +if not "realGeometry" in dir(): + realGeometry=False + if not SuperCells: include("LArCalibProcessing/LArCalib_Flags.py") if SuperCells: include("LArCalibProcessing/LArCalib_FlagsSC.py") @@ -370,6 +372,8 @@ else: theLArRawCalibDataReadingAlg=LArRawCalibDataReadingAlg() theLArRawCalibDataReadingAlg.LArAccDigitKey=Gain theLArRawCalibDataReadingAlg.LArFebHeaderKey="LArFebHeader" + #temporarily + theLArRawCalibDataReadingAlg.FailOnCorruption=False topSequence+=theLArRawCalibDataReadingAlg @@ -695,6 +699,9 @@ if ( WriteNtuple ) : if SuperCells: LArPedestals2Ntuple.CablingKey = "LArOnOffIdMapSC" LArPedestals2Ntuple.CalibMapKey = "LArCalibIdMapSC" + if realGeometry: + LArPedestals2Ntuple.RealGeometry = True + LArPedestals2Ntuple.OffId = True topSequence += LArPedestals2Ntuple @@ -710,6 +717,10 @@ if ( WriteNtuple ) : if SuperCells: LArAutoCorr2Ntuple.CablingKey = "LArOnOffIdMapSC" LArAutoCorr2Ntuple.CalibMapKey = "LArCalibIdMapSC" + if realGeometry: + LArAutoCorr2Ntuple.RealGeometry = True + LArAutoCorr2Ntuple.OffId = True + topSequence += LArAutoCorr2Ntuple theApp.HistogramPersistency = "ROOT" diff --git a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Ramp_jobOptions.py b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Ramp_jobOptions.py index fb7329c314f51cfcc8faa1ebdeeab6a2db19fad0..06928e1158502e45c74650591b873d2ac02a72c2 100644 --- a/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Ramp_jobOptions.py +++ b/LArCalorimeter/LArExample/LArCalibProcessing/share/LArCalib_Ramp_jobOptions.py @@ -163,7 +163,7 @@ if not 'IOVEnd' in dir(): IOVEnd = LArCalib_Flags.IOVEnd if not 'DBConnectionCOOL' in dir(): - DBConnectionCOOL = "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_LAR;dbname=CONDBR2;" + DBConnectionCOOL = "COOLOFL_LAR/CONDBR2" ## HEC map if not 'ReadHECMapFromCOOL' in dir(): @@ -308,8 +308,8 @@ if ( PeakOF and ReadOFCFromCOOL ): RampLog.info( " InputDBConnectionOFC = "+InputDBConnectionOFC ) elif ( PeakOF) : RampLog.info( " InputOFCPoolFileName = "+InputOFCPoolFileName ) -if 'OFCLArCalibFolderTag' in dir() : - RampLog.info( " OFCLArCalibFolderTag = "+OFCLArCalibFolderTag ) +if 'LArCaliOFCFolderTag' in dir() : + RampLog.info( " LArCaliOFCFolderTag = "+LArCaliOFCFolderTag ) RampLog.info( " OutputRampRootFullFileName = "+OutputRampRootFileDir+"/"+OutputRampRootFileName ) RampLog.info( " OutputRampPoolFullFileName = "+OutputRampPoolFileDir+"/"+OutputRampPoolFileName ) RampLog.info( " OutputObjectSpecRamp = "+OutputObjectSpecRamp ) @@ -477,7 +477,7 @@ if CheckBadEvents: if SuperCells: - conddb.addFolder("","/LAR/IdentifierOfl/OnOffIdMap_SCCOOLOFL_LAR/OFLP200LARIdentifierOflOnOffIdMap_SC-000") + conddb.addFolder("","/LAR/IdentifierOfl/OnOffIdMap_SCCOOLOFL_LAR/OFLP200LARIdentifierOflOnOffIdMap_SC-000",className="AthenaAttributeList") ## define the DB Gobal Tag : ServiceMgr.IOVDbSvc.GlobalTag = LArCalib_Flags.globalFlagDB @@ -513,7 +513,7 @@ ServiceMgr.PoolSvc.ReadCatalog += larCalibCatalogs if ( doLArCalibDataQuality ) : ## The reference is the Oracle DB - conddb.addFolder("LAR_ONL","/LAR/ElecCalibOnl/RampLArRampRef"+ChannelSelection) + conddb.addFolder("LAR_ONL","/LAR/ElecCalibOnl/RampLArRampRef"+ChannelSelection,className="LArRampComplete") #if (CorrectBadChannels or StripsXtalkCorr): # conddb.addFolder("LAR","/LAR/BadChannelsOfl/BadChannels") @@ -529,9 +529,9 @@ if (isHEC): if ( ReadHECMapFromCOOL ): HECMapFolder = "/LAR/ElecCalibOfl/HecPAMap" if "HECMapTagSpec" in dir(): - conddb.addFolder("",HECMapFolder+""+HECMapTagSpec+""+""+InputDBConnectionHECMap+"") + conddb.addFolder("",HECMapFolder+""+HECMapTagSpec+""+""+InputDBConnectionHECMap+"",className="LArRinjComplete") else : - conddb.addFolder("",HECMapFolder+""+InputDBConnectionHECMap+"") + conddb.addFolder("",HECMapFolder+""+InputDBConnectionHECMap+"",className="LArRinjComplete") else: if 'InputHECMapPoolFileName' in dir(): @@ -557,6 +557,7 @@ if ( ReadPedFromCOOL ): if (CorrectBias or StripsXtalkCorr or PeakOF): PedestalFolder = LArCalib_Flags.LArPedestalFolder PedestalTagSpec = LArCalibFolderTag(PedestalFolder,PedLArCalibFolderTag) + #RampLog.info("Ped. folder:",PedestalFolder," ",PedestalTagSpec," ",InputDBConnectionPed) conddb.addFolder("",PedestalFolder+""+PedestalTagSpec+""+""+InputDBConnectionPed+""+ChannelSelection,className="LArPedestalComplete") else: @@ -571,7 +572,7 @@ if ( ReadOFCFromCOOL ): if PeakOF: if not 'CaliOFCTagSpec' in dir(): CaliOFCTagSpec = LArCalibFolderTag(CaliOFCFolder,LArCaliOFCFolderTag) - conddb.addFolder("",CaliOFCFolder+""+CaliOFCTagSpec+""+""+InputDBConnectionOFC+""+ChannelSelection) + conddb.addFolder("",CaliOFCFolder+""+CaliOFCTagSpec+""+""+InputDBConnectionOFC+""+ChannelSelection, className="LArOFCComplete") else: if 'InputOFCPoolFileName' in dir(): diff --git a/LArCalorimeter/LArExample/LArConditionsCommon/share/LArMinimalSetup.py b/LArCalorimeter/LArExample/LArConditionsCommon/share/LArMinimalSetup.py index f8b1f33282a8163fbf0eaa47c98f94f808d550a2..68e456f4cd36522fb0a6c85a128600911ca06754 100644 --- a/LArCalorimeter/LArExample/LArConditionsCommon/share/LArMinimalSetup.py +++ b/LArCalorimeter/LArExample/LArConditionsCommon/share/LArMinimalSetup.py @@ -19,7 +19,10 @@ from AthenaCommon.JobProperties import jobproperties jobproperties.Global.DetDescrVersion = "ATLAS-R2-2016-01-00-01" from AthenaCommon.DetFlags import DetFlags -DetFlags.Calo_setOn() #Switched back geometry +if 'realGeometry' in dir() and realGeometry: + DetFlags.Calo_setOn() +else: + DetFlags.Calo_setOff() #Switched off to avoid geometry DetFlags.ID_setOff() DetFlags.Muon_setOff() DetFlags.Truth_setOff() diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCalibParams.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCalibParams.h index ce4bd9094034bc9970ff679a17e37cb6a4e52c12..02507d23104923b2dc82fce5f8b74e69afcfd1cd 100755 --- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArCalibParams.h +++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArCalibParams.h @@ -52,6 +52,8 @@ class LArCalibParams { unsigned getNumberConfig(const HWIdentifier calibModuleID) const; + unsigned getNumberPatterns(const HWIdentifier calibModuleID) const; + //const CalibBoard& getCalibBoardParams(const HWIdentifier calibModuleID) const; class CalibBoard { diff --git a/LArCalorimeter/LArRawConditions/src/LArCalibParams.cxx b/LArCalorimeter/LArRawConditions/src/LArCalibParams.cxx index 7faa6807dc4f81f8e9df5e74c08db4ea072a6b09..6df15eb6cf266753be3c7316a14f353638e62331 100755 --- a/LArCalorimeter/LArRawConditions/src/LArCalibParams.cxx +++ b/LArCalorimeter/LArRawConditions/src/LArCalibParams.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "LArRawConditions/LArCalibParams.h" @@ -16,7 +16,6 @@ LArCalibParams::LArCalibParams(): StatusCode LArCalibParams::initialize() { - //std::cout << "Initialize of LArCalibParams" << std::endl; //Get online Helper via DetectorStore ISvcLocator* svcLoc = Gaudi::svcLocator( ); StoreGateSvc* detStore; @@ -39,7 +38,6 @@ StatusCode LArCalibParams::initialize() } - LArCalibParams::~LArCalibParams() { //std::cout << "Destructor of LArCalibParams" << std::endl; @@ -129,7 +127,7 @@ unsigned LArCalibParams::CalibBoard::DAC(const unsigned event) const unsigned LArCalibParams::Delay(const unsigned event, const HWIdentifier calibLineID) const {if (calibLineID.get_compact()==0) return 0; //Disconnected channel - if (m_uniqueConfig && m_mCalibBoards.size()==1) + if (m_uniqueConfig && m_mCalibBoards.size()>=1) return m_mCalibBoards.begin()->second.Delay(event); else { if (!m_onlineHelper) { @@ -148,7 +146,7 @@ unsigned LArCalibParams::Delay(const unsigned event, const HWIdentifier calibLin unsigned LArCalibParams::DAC(const unsigned event, const HWIdentifier calibLineID) const {if (calibLineID.get_compact()==0) return 0; //Disconnected channel - if (m_uniqueConfig && m_mCalibBoards.size()==1) + if (m_uniqueConfig && m_mCalibBoards.size()>=1) return m_mCalibBoards.begin()->second.DAC(event); else { if (!m_onlineHelper) { @@ -167,14 +165,15 @@ unsigned LArCalibParams::DAC(const unsigned event, const HWIdentifier calibLineI bool LArCalibParams::isPulsed(const unsigned event, const HWIdentifier calibLineID) const -{if (calibLineID.get_compact()==0) return false; //Disconnected channel +{ + if (calibLineID.get_compact()==0) return false; //Disconnected channel if (!m_onlineHelper) { MsgStream log(Athena::getMessageSvc(), "LArCalibParams::isPulsed"); log << MSG::ERROR << "LArOnlineID not defined! Can't determine isPulsed value." << endmsg; return false; } const int line=m_onlineHelper->channel(calibLineID); - if (m_uniqueConfig && m_mCalibBoards.size()==1) + if (m_uniqueConfig && m_mCalibBoards.size()>=1) return m_mCalibBoards.begin()->second.isPulsed(event, line); else {const HWIdentifier calibModuleID=m_onlineHelper->calib_module_Id(calibLineID); @@ -190,7 +189,7 @@ bool LArCalibParams::isPulsed(const unsigned event, const HWIdentifier calibLine unsigned LArCalibParams::getNumberConfig(const HWIdentifier calibModuleID) const { //Number of configurations is nDAC*nDelay*nPattern - if (m_uniqueConfig && m_mCalibBoards.size()==1) { + if (m_uniqueConfig && m_mCalibBoards.size()>=1) { const unsigned nConfig=m_mCalibBoards.begin()->second.m_DAC.size()* m_mCalibBoards.begin()->second.m_Delay.size()*m_mCalibBoards.begin()->second.m_Pattern.size()/4; return nConfig; @@ -211,7 +210,7 @@ unsigned LArCalibParams::getNumberConfig(const HWIdentifier calibModuleID) const unsigned LArCalibParams::NTrigger(const HWIdentifier calibModuleID) const { - if (m_uniqueConfig && m_mCalibBoards.size()==1) + if (m_uniqueConfig && m_mCalibBoards.size()>=1) return m_mCalibBoards.begin()->second.m_nTrigger; else { const std::map::const_iterator map_it=m_mCalibBoards.find(calibModuleID); @@ -230,3 +229,23 @@ const CalibBoard& LArCalibParams::getCalibBoardParams(const HWIdentifier calibMo return m_mCalibBoards[calibModuleID]; //Find would be better.... } */ + +unsigned LArCalibParams::getNumberPatterns(const HWIdentifier calibModuleID) const +{ //Number of configurations is nDAC*nDelay*nPattern + if ((m_uniqueConfig && m_mCalibBoards.size()==1) || // one calib board configured + calibModuleID == HWIdentifier(0)) { // assuming equal config for all b. boards configured + const unsigned nPatt = m_mCalibBoards.begin()->second.m_Pattern.size()/4; + return nPatt; + } + else { + const std::map::const_iterator map_it=m_mCalibBoards.find(calibModuleID); + if (map_it==m_mCalibBoards.end()) + return 0; //Can't find Board configuration -> Assume board is not configured. + else { + const unsigned nPatt = map_it->second.m_Pattern.size()/4; + return nPatt; + } + } +} + + diff --git a/LArCalorimeter/LArRecUtils/LArRecUtils/LArOFPeakRecoTool.h b/LArCalorimeter/LArRecUtils/LArRecUtils/LArOFPeakRecoTool.h index 75e2ad83137c68123f4f74aca98715c15dd83a70..490574496f8c933a35414d76ebea260f839ac862 100755 --- a/LArCalorimeter/LArRecUtils/LArRecUtils/LArOFPeakRecoTool.h +++ b/LArCalorimeter/LArRecUtils/LArRecUtils/LArOFPeakRecoTool.h @@ -31,18 +31,6 @@ class LArOFPeakRecoTool: public AthAlgTool { public: - /* - struct Result{ - Result(): valid(false),converged(false) {} - bool valid; - bool converged; - float amplitude; //in ADC counts - float tau; //in ns - float quality; - float delay; //in ns - unsigned peakSample; - } ; - */ typedef LArOFIterResults Result; // constructor LArOFPeakRecoTool(const std::string& type,