From 53ddce646438c79e3138af7e7b268392d1da741f Mon Sep 17 00:00:00 2001 From: Soshi Tsuno <soshi.tsuno@cern.ch> Date: Fri, 2 Oct 2020 12:41:13 +0000 Subject: [PATCH] Delete PixelCoralClientUtiles and some cleanup (ATLASRECTS-5653) --- .../PixelCalibAlgs/CMakeLists.txt | 49 +- .../PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY | 0 .../DepletionDepthCalibration.h | 0 .../PixelCalibAlgs/LorentzAngleCalibration.h | 0 .../PixelCalibAlgs/NoiseMapBuilder.h | 0 .../PixelCalibAlgs/OfflineCalibrationLoop.h | 0 .../PixelCalibAlgs/PixMapDBWriter.h | 0 .../PixelCalibAlgs/PixMapOverlayWriter.h | 0 .../PixelCalibAlgs/PixelBarrelSurvey.h | 0 .../PixelCalibAlgs/PixelBarrelSurveyUtils.h | 0 .../PixelClusterOnTrackErrorPlot.h | 0 .../{ => run2}/PixelCalibAlgs/PixelConvert.h | 0 .../{ => run2}/PixelCalibAlgs/PixelRIOs.h | 0 .../src/DepletionDepthCalibration.cxx | 0 .../src/LorentzAngleCalibration.cxx | 0 .../{ => run2}/src/NoiseMapBuilder.cxx | 0 .../{ => run2}/src/OfflineCalibrationLoop.cxx | 0 .../{ => run2}/src/PixMapDBWriter.cxx | 0 .../{ => run2}/src/PixMapOverlayWriter.cxx | 0 .../{ => run2}/src/PixelBarrelSurvey.cxx | 0 .../{ => run2}/src/PixelBarrelSurveyUtils.cxx | 0 .../src/PixelClusterOnTrackErrorPlot.cxx | 0 .../{ => run2}/src/PixelConvert.cxx | 0 .../{ => run2}/src/PixelRIOs.cxx | 0 .../PixelCalibAlgs/share/NoiseMapBuilder.py | 1 - .../src/components/PixelCalibAlgs_entries.cxx | 8 - .../PixelConditionsAlgorithms/CMakeLists.txt | 8 +- .../python/PixelConditionsConfig.py | 14 - .../src/PixelChargeCalibCondAlg.cxx | 4 +- .../src/PixelChargeLUTCalibCondAlg.cxx | 4 +- .../src/PixelConfigCondAlg.cxx | 13 +- .../src/PixelConfigCondAlg.h | 21 - .../src/PixelDCSCondHVAlg.cxx | 25 +- .../src/PixelDCSCondStateAlg.cxx | 34 +- .../src/PixelDCSCondStateAlg.h | 8 +- .../src/PixelDCSCondStatusAlg.cxx | 35 +- .../src/PixelDCSCondStatusAlg.h | 8 +- .../src/PixelDCSCondTempAlg.cxx | 22 +- .../src/PixelDeadMapCondAlg.cxx | 8 +- .../src/PixelDeadMapCondAlg.h | 6 +- .../src/PixelTDAQCondAlg.cxx | 8 +- .../src/PixelTDAQCondAlg.h | 8 +- .../PixelConditionsData/CMakeLists.txt | 9 +- .../PixelConditionsData/PixelModuleData.h | 30 +- .../PixelConditionsData/SpecialPixelMap.h | 104 - .../src/PixelModuleData.cxx | 23 +- .../src/SpecialPixelMap.cxx | 412 --- .../ISpecialPixelMapSvc.h | 77 - .../PixelCoralClientUtils/CMakeLists.txt | 76 - .../ATLAS_CHECK_THREAD_SAFETY | 1 - .../AnalysisResultList_t.hh | 213 -- .../PixelCoralClientUtils/CoralClient.hh | 188 -- .../IPixResultsDbListener.hh | 25 - .../PixelCoralClientUtils/PCDDb.h | 47 - .../PixelCoralClientUtils/PCDio.h | 46 - .../PixelCoralClientUtils/PCDkr.h | 42 - .../PixCalibCoralCoolDb.h | 34 - .../PixCalibKnowledgeDb.h | 50 - .../PixResultsException.hh | 24 - .../PixelCoralClientUtils/PixelCalibData.hh | 400 --- .../PixelCoralClientUtils/PixelMap.h | 31 - .../PixelCoralClientUtils/SpecialPixelMap.hh | 363 --- .../PixelCoralClientUtils/cmt/pcd.sh | 156 -- .../PixelCoralClientUtils/cmt/probe_fill.src | 8 - .../cmt/talkToPCDDb_example.sh | 12 - .../cmt/talkToPCDkr_example.sh | 15 - .../example/calibDbInterface_example.sh | 12 - .../PixelCoralClientUtils/src/CORAL-create.cc | 53 - .../PixelCoralClientUtils/src/CORAL-fill.cc | 86 - .../src/CORAL-listVariables.cc | 102 - .../PixelCoralClientUtils/src/CORAL-read.cc | 125 - .../PixelCoralClientUtils/src/CoralClient.cc | 2224 ----------------- .../PixelCoralClientUtils/src/PCDDb.cxx | 227 -- .../PixelCoralClientUtils/src/PCDio.cc | 566 ----- .../PixelCoralClientUtils/src/PCDkr.cc | 211 -- .../src/PixCalibCoralCoolDb.cc | 270 -- .../src/PixCalibKnowledgeDb.cc | 275 -- .../src/SpecialPixelMap.cc | 1751 ------------- .../src/calibDbInterface.cc | 94 - .../src/extractAnalysis.cc | 462 ---- .../PixelCoralClientUtils/src/extractSPM.cc | 87 - .../PixelCoralClientUtils/src/fixTimewalk.cc | 132 - .../PixelCoralClientUtils/src/talkToPCDDb.cc | 68 - .../PixelCoralClientUtils/src/talkToPCDkr.cc | 84 - .../test/calibDbInterface_example.sh | 17 - .../python/FastSiDigitizationConfig.py | 23 +- .../share/PixelDigitization_jobOptions.py | 32 +- .../python/PixelDigitizationConfig.py | 8 - .../python/PixelDigitizationConfigNew.py | 9 +- .../share/InDetDxAOD.py | 5 +- .../share/InDetRecConditionsAccess.py | 33 +- .../share/postInclude.SLHC_Rec.py | 20 +- .../python/InDetTrigConfigConditions.py | 24 +- .../python/InDetTrigConfigRecPreProcessing.py | 4 +- .../python/TrackSummaryToolWorkaround.py | 9 +- .../SCT_Monitoring/share/strippedDown.py | 3 - .../share/SiSPSeededTracksStandalone.py | 23 +- .../SiSPSeededTracksStandaloneFromESD.py | 22 +- .../SiClusterizationTool/ClusterMakerTool.h | 6 +- .../PixelClusteringToolBase.h | 1 - .../src/ClusterMakerTool.cxx | 111 +- .../src/MergedPixelsTool.cxx | 2 +- .../src/PixelClusteringToolBase.cxx | 2 +- .../share/jobOptions_RecExCommon_masking.py | 3 - .../TrigInDetConfig/python/InDetSetup.py | 3 - .../TrigInDetConfig/python/TrigInDetConfig.py | 10 +- 106 files changed, 267 insertions(+), 9602 deletions(-) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/DepletionDepthCalibration.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/LorentzAngleCalibration.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/NoiseMapBuilder.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/OfflineCalibrationLoop.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixMapDBWriter.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixMapOverlayWriter.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixelBarrelSurvey.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixelBarrelSurveyUtils.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixelClusterOnTrackErrorPlot.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixelConvert.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/PixelCalibAlgs/PixelRIOs.h (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/DepletionDepthCalibration.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/LorentzAngleCalibration.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/NoiseMapBuilder.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/OfflineCalibrationLoop.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixMapDBWriter.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixMapOverlayWriter.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixelBarrelSurvey.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixelBarrelSurveyUtils.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixelClusterOnTrackErrorPlot.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixelConvert.cxx (100%) rename InnerDetector/InDetCalibAlgs/PixelCalibAlgs/{ => run2}/src/PixelRIOs.cxx (100%) delete mode 100755 InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/SpecialPixelMap.h delete mode 100755 InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx delete mode 100755 InnerDetector/InDetConditions/PixelConditionsTools/PixelConditionsTools/ISpecialPixelMapSvc.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/CMakeLists.txt delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/ATLAS_CHECK_THREAD_SAFETY delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/AnalysisResultList_t.hh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/CoralClient.hh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/IPixResultsDbListener.hh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDDb.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDio.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDkr.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibCoralCoolDb.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibKnowledgeDb.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixResultsException.hh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelCalibData.hh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelMap.h delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/SpecialPixelMap.hh delete mode 100755 InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/pcd.sh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/probe_fill.src delete mode 100755 InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDDb_example.sh delete mode 100755 InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDkr_example.sh delete mode 100755 InnerDetector/InDetConditions/PixelCoralClientUtils/example/calibDbInterface_example.sh delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-create.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-fill.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-listVariables.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-read.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/CoralClient.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDDb.cxx delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDio.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDkr.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibCoralCoolDb.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibKnowledgeDb.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/SpecialPixelMap.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/calibDbInterface.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractAnalysis.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractSPM.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/fixTimewalk.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDDb.cc delete mode 100644 InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDkr.cc delete mode 100755 InnerDetector/InDetConditions/PixelCoralClientUtils/test/calibDbInterface_example.sh diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/CMakeLists.txt b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/CMakeLists.txt index 3826852f22e..b4e35e65d4e 100644 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/CMakeLists.txt +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/CMakeLists.txt @@ -14,7 +14,6 @@ atlas_depends_on_subdirs( InnerDetector/InDetRecEvent/InDetPrepRawData PRIVATE Database/AthenaPOOL/AthenaPoolUtilities - Database/CoralDB DetectorDescription/DetDescrCond/DetDescrConditions DetectorDescription/Identifier Event/EventInfo @@ -32,7 +31,6 @@ atlas_depends_on_subdirs( # External dependencies: find_package( CLHEP ) -find_package( CORAL COMPONENTS CoralBase ) find_package( ROOT COMPONENTS Graf Core Tree MathCore Hist RIO MathMore Physics Matrix Gpad ) @@ -41,57 +39,14 @@ atlas_add_library( PixelCalibAlgsLib PixelCalibAlgs/*.h src/*.cxx PUBLIC_HEADERS PixelCalibAlgs INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps CxxUtils GaudiKernel InDetPrepRawData InDetConditionsSummaryService PixelCablingLib - PRIVATE_LINK_LIBRARIES ${CORAL_LIBRARIES} AthenaPoolUtilities CoralDB + PRIVATE_LINK_LIBRARIES AthenaPoolUtilities DetDescrConditions Identifier EventInfo PixelConditionsData InDetIdentifier - InDetReadoutGeometry PixelReadoutGeometry InDetRawData PathResolver PixelGeoModelLib PixelConditionsToolsLib CoralDB ) + InDetReadoutGeometry PixelReadoutGeometry InDetRawData PathResolver PixelGeoModelLib PixelConditionsToolsLib ) atlas_add_component( PixelCalibAlgs src/components/*.cxx LINK_LIBRARIES GaudiKernel InDetByteStreamErrors PixelConditionsData PixelCalibAlgsLib ) -# Executables in the package: -atlas_add_executable( doPixelOfflineCalib - Application/doPixelOfflineCalib.cxx - LINK_LIBRARIES PixelCalibAlgsLib ) - -atlas_add_executable( doPixelOfflineCalibG4 - Application/doPixelOfflineCalibG4.cxx - LINK_LIBRARIES PixelCalibAlgsLib ) - -atlas_add_executable( PlotChargeSharingConstants - Application/PlotChargeSharingConstants.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -atlas_add_executable( PlotPixelClusterOnTrackErrors - Application/PlotPixelClusterOnTrackErrors.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -atlas_add_executable( updateNoiseMaps - Application/updateNoiseMaps.C - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -atlas_add_executable( updateDeadMaps - Application/updateDeadMaps.C - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -atlas_add_executable( createDeadModuleList - Application/createDeadModuleList.C - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -atlas_add_executable( hackNoiseMapsForStudyCP - Application/hackNoiseMapsForStudyCP.C - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} PixelConditionsData PixelCalibAlgsLib ) - -# Install files from the package: -atlas_install_joboptions( share/*.py ) -atlas_install_runtime( share/*.txt share/*.sh share/*.dat ) diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/ATLAS_CHECK_THREAD_SAFETY diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/DepletionDepthCalibration.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/DepletionDepthCalibration.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/DepletionDepthCalibration.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/DepletionDepthCalibration.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/LorentzAngleCalibration.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/LorentzAngleCalibration.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/LorentzAngleCalibration.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/LorentzAngleCalibration.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/NoiseMapBuilder.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/NoiseMapBuilder.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/NoiseMapBuilder.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/OfflineCalibrationLoop.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/OfflineCalibrationLoop.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/OfflineCalibrationLoop.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/OfflineCalibrationLoop.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixMapDBWriter.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixMapDBWriter.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixMapDBWriter.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixMapDBWriter.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixMapOverlayWriter.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixMapOverlayWriter.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixMapOverlayWriter.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixMapOverlayWriter.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelBarrelSurvey.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelBarrelSurvey.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelBarrelSurvey.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelBarrelSurvey.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelBarrelSurveyUtils.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelBarrelSurveyUtils.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelBarrelSurveyUtils.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelBarrelSurveyUtils.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelClusterOnTrackErrorPlot.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelClusterOnTrackErrorPlot.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelClusterOnTrackErrorPlot.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelClusterOnTrackErrorPlot.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelConvert.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelConvert.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelConvert.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelConvert.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelRIOs.h b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelRIOs.h similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/PixelCalibAlgs/PixelRIOs.h rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/PixelCalibAlgs/PixelRIOs.h diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/DepletionDepthCalibration.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/DepletionDepthCalibration.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/DepletionDepthCalibration.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/DepletionDepthCalibration.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/LorentzAngleCalibration.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/LorentzAngleCalibration.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/LorentzAngleCalibration.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/LorentzAngleCalibration.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/NoiseMapBuilder.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/NoiseMapBuilder.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/NoiseMapBuilder.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/OfflineCalibrationLoop.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/OfflineCalibrationLoop.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/OfflineCalibrationLoop.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/OfflineCalibrationLoop.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixMapDBWriter.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixMapDBWriter.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixMapDBWriter.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixMapDBWriter.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixMapOverlayWriter.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixMapOverlayWriter.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixMapOverlayWriter.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixMapOverlayWriter.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelBarrelSurvey.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelBarrelSurvey.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelBarrelSurvey.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelBarrelSurvey.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelBarrelSurveyUtils.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelBarrelSurveyUtils.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelBarrelSurveyUtils.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelBarrelSurveyUtils.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelClusterOnTrackErrorPlot.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelClusterOnTrackErrorPlot.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelClusterOnTrackErrorPlot.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelClusterOnTrackErrorPlot.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelConvert.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelConvert.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelConvert.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelConvert.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelRIOs.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelRIOs.cxx similarity index 100% rename from InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/PixelRIOs.cxx rename to InnerDetector/InDetCalibAlgs/PixelCalibAlgs/run2/src/PixelRIOs.cxx diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/share/NoiseMapBuilder.py b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/share/NoiseMapBuilder.py index 67a11a30b79..3575f64eed6 100755 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/share/NoiseMapBuilder.py +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/share/NoiseMapBuilder.py @@ -137,7 +137,6 @@ else : from PixelConditionsServices.PixelConditionsServicesConf import PixelConditionsSummarySvc ServiceMgr += PixelConditionsSummarySvc() -ServiceMgr.PixelConditionsSummarySvc.UseSpecialPixelMap = False ServiceMgr.PixelConditionsSummarySvc.UseDCS = False ServiceMgr.PixelConditionsSummarySvc.UseByteStream = True diff --git a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/components/PixelCalibAlgs_entries.cxx b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/components/PixelCalibAlgs_entries.cxx index bee47e765f6..0c751525b68 100644 --- a/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/components/PixelCalibAlgs_entries.cxx +++ b/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/src/components/PixelCalibAlgs_entries.cxx @@ -1,12 +1,4 @@ -#include "PixelCalibAlgs/PixelBarrelSurvey.h" -#include "PixelCalibAlgs/NoiseMapBuilder.h" -#include "PixelCalibAlgs/PixMapDBWriter.h" -#include "PixelCalibAlgs/PixMapOverlayWriter.h" #include "PixelCalibAlgs/PixelChargeToTConversion.h" -DECLARE_COMPONENT( PixelBarrelSurvey ) -DECLARE_COMPONENT( NoiseMapBuilder ) -DECLARE_COMPONENT( PixMapDBWriter ) -DECLARE_COMPONENT( PixMapOverlayWriter ) DECLARE_COMPONENT( PixelChargeToTConversion ) diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/CMakeLists.txt b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/CMakeLists.txt index 3b8fbef05ef..ee236f632a4 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/CMakeLists.txt +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/CMakeLists.txt @@ -8,8 +8,6 @@ atlas_subdir( PixelConditionsAlgorithms ) # External dependencies: find_package( CLHEP ) find_package( COOL COMPONENTS CoolKernel ) -find_package( CORAL COMPONENTS CoralBase ) -find_package( ROOT COMPONENTS Core Hist RIO ) # Component(s) in the package: atlas_add_library( PixelConditionsAlgorithmsLib @@ -21,11 +19,9 @@ atlas_add_library( PixelConditionsAlgorithmsLib atlas_add_component( PixelConditionsAlgorithms src/*.h src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} ${COOL_LIBRARIES} - ${CLHEP_LIBRARIES} CommissionEvent AthenaBaseComps AthenaKernel AthenaPoolUtilities - GaudiKernel PixelConditionsData SGTools StoreGateLib CoralDB + LINK_LIBRARIES ${COOL_LIBRARIES} ${CLHEP_LIBRARIES} CommissionEvent AthenaBaseComps AthenaKernel AthenaPoolUtilities + GaudiKernel PixelConditionsData SGTools StoreGateLib GeoModelUtilities Identifier InDetIdentifier InDetReadoutGeometry PixelReadoutGeometry PixelCablingLib PixelConditionsAlgorithmsLib PathResolver ) diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/python/PixelConditionsConfig.py b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/python/PixelConditionsConfig.py index 45a1de73d1b..4c3ded75774 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/python/PixelConditionsConfig.py +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/python/PixelConditionsConfig.py @@ -16,16 +16,6 @@ def PixelConfigCondAlgCfg(flags, name="PixelConfigCondAlg", **kwargs): # FIXME commented properties are not currently accepted by PixelConfigCondAlg CondArgs = {} - # Switch parameters - CondArgs.update( - UseCalibConditions=True, - UseDeadmapConditions=True, - UseDCSStateConditions=(not flags.Input.isMC and flags.InDet.usePixelDCS), - UseDCSStatusConditions=(not flags.Input.isMC and flags.InDet.usePixelDCS), - UseDCSHVConditions=True, - UseDCSTemperatureConditions=True, - UseTDAQConditions=False, - ) if flags.Beam.Type == "cosmics": CondArgs.update( UseComTime=True, @@ -375,8 +365,6 @@ def PixelDCSCondHVAlgCfg(flags, name="PixelDCSCondHVAlg", **kwargs): acc.merge(addFolders(flags, "/PIXEL/HLT/DCS/HV", "PIXEL_ONL", className="CondAttrListCollection")) else: acc.merge(addFolders(flags, "/PIXEL/DCS/HV", "DCS_OFL", className="CondAttrListCollection")) - kwargs.setdefault("PixelModuleData", "PixelModuleData") - kwargs.setdefault("ReadKey", "/PIXEL/DCS/HV") kwargs.setdefault("WriteKey", "PixelDCSHVCondData") acc.addCondAlgo(CompFactory.PixelDCSCondHVAlg(name, **kwargs)) return acc @@ -389,7 +377,6 @@ def PixelDCSCondStateAlgCfg(flags, name="PixelDCSCondStateAlg", **kwargs): kwargs.setdefault("ReadKeyState", "/PIXEL/DCS/FSMSTATE") else: kwargs.setdefault("ReadKeyState", "") - kwargs.setdefault("PixelModuleData", "PixelModuleData") kwargs.setdefault("WriteKeyState", "PixelDCSStateCondData") acc.addCondAlgo(CompFactory.PixelDCSCondStateAlg(name, **kwargs)) return acc @@ -402,7 +389,6 @@ def PixelDCSCondStatusAlgCfg(flags, name="PixelDCSCondStatusAlg", **kwargs): kwargs.setdefault("ReadKeyStatus", "/PIXEL/DCS/FSMSTATUS") else: kwargs.setdefault("ReadKeyStatus", "") - kwargs.setdefault("PixelModuleData", "PixelModuleData") kwargs.setdefault("WriteKeyStatus", "PixelDCSStatusCondData") acc.addCondAlgo(CompFactory.PixelDCSCondStatusAlg(name, **kwargs)) return acc diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeCalibCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeCalibCondAlg.cxx index 5c98e6946f4..40513629ff8 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeCalibCondAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeCalibCondAlg.cxx @@ -22,7 +22,7 @@ StatusCode PixelChargeCalibCondAlg::initialize() { ATH_CHECK(m_pixelDetEleCollKey.initialize()); ATH_CHECK(m_condSvc.retrieve()); ATH_CHECK(m_configKey.initialize()); - ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_readKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -56,7 +56,7 @@ StatusCode PixelChargeCalibCondAlg::execute(const EventContext& ctx) const { const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; EventIDRange rangeW{start, stop}; - if (configData->getUseCalibConditions()) { + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeLUTCalibCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeLUTCalibCondAlg.cxx index 62ae68d35b0..5d03579142f 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeLUTCalibCondAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelChargeLUTCalibCondAlg.cxx @@ -22,7 +22,7 @@ StatusCode PixelChargeLUTCalibCondAlg::initialize() { ATH_CHECK(m_pixelDetEleCollKey.initialize()); ATH_CHECK(m_condSvc.retrieve()); ATH_CHECK(m_configKey.initialize()); - ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_readKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -56,7 +56,7 @@ StatusCode PixelChargeLUTCalibCondAlg::execute(const EventContext& ctx) const { const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; EventIDRange rangeW{start, stop}; - if (configData->getUseCalibConditions()) { + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx index b6fbbaa61fb..8a098f76b99 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.cxx @@ -29,9 +29,7 @@ StatusCode PixelConfigCondAlg::initialize() { } ATH_CHECK(m_condSvc.retrieve()); - - if (m_useDeadmapConditions) { ATH_CHECK(m_readDeadMapKey.initialize()); } - + ATH_CHECK(m_readDeadMapKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -62,7 +60,7 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const { // Set dead map //============== EventIDRange rangeDeadMap{start, stop}; - if (m_useDeadmapConditions) { + if (!m_readDeadMapKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readDeadMapKey, ctx); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { @@ -111,13 +109,6 @@ StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const { } // Switch parameters - writeCdo -> setUseCalibConditions(m_useCalibConditions); - writeCdo -> setUseDeadmapConditions(m_useDeadmapConditions); - writeCdo -> setUseDCSStateConditions(m_useDCSStateConditions); - writeCdo -> setUseDCSStatusConditions(m_useDCSStatusConditions); - writeCdo -> setUseDCSHVConditions(m_useDCSHVConditions); - writeCdo -> setUseDCSTemperatureConditions(m_useDCSTemperatureConditions); - writeCdo -> setUseTDAQConditions(m_useTDAQConditions); writeCdo -> setUseCablingConditions(m_useCablingConditions); // Digitization parameters diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h index 597e8a2bf12..5852fd614ed 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelConfigCondAlg.h @@ -37,27 +37,6 @@ class PixelConfigCondAlg : public AthReentrantAlgorithm { {this, "WriteKey", "PixelModuleData", "Output key of pixel module data"}; // Switch parameters - Gaudi::Property<bool> m_useCalibConditions - {this, "UseCalibConditions", true, "Use conditions DB for charge calibration"}; - - Gaudi::Property<bool> m_useDeadmapConditions - {this, "UseDeadmapConditions", true, "Use conditions DB for pixel deadmap module/FE"}; - - Gaudi::Property<bool> m_useDCSStateConditions - {this, "UseDCSStateConditions", false, "Use DCSState conditions DB"}; - - Gaudi::Property<bool> m_useDCSStatusConditions - {this, "UseDCSStatusConditions", false, "Use DCSStatus conditions DB"}; - - Gaudi::Property<bool> m_useDCSHVConditions - {this, "UseDCSHVConditions", true, "Use DCS HV conditions DB"}; - - Gaudi::Property<bool> m_useDCSTemperatureConditions - {this, "UseDCSTemperatureConditions", true, "Use DCS temperature conditions DB"}; - - Gaudi::Property<bool> m_useTDAQConditions - {this, "UseTDAQConditions", false, "Use TDAQ conditions DB (NOTE only valid in RUN-1)"}; - Gaudi::Property<bool> m_useCablingConditions {this, "UseCablingConditions", true, "Use cabling map conditions DB"}; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondHVAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondHVAlg.cxx index 1dc57b344ff..a331b71c5ad 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondHVAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondHVAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelDCSCondHVAlg.h" @@ -18,7 +18,7 @@ StatusCode PixelDCSCondHVAlg::initialize() { ATH_CHECK(m_condSvc.retrieve()); ATH_CHECK(m_moduleDataKey.initialize()); - ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_readKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -35,28 +35,33 @@ StatusCode PixelDCSCondHVAlg::execute(const EventContext& ctx) const { ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order."); return StatusCode::SUCCESS; } - - SG::ReadCondHandle<PixelModuleData> modDataHdl(m_moduleDataKey,ctx); const PixelModuleData* modData=(*modDataHdl); - writeHandle.addDependency(modDataHdl); ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange()); // Construct the output Cond Object and fill it in std::unique_ptr<PixelDCSHVData> writeCdo(std::make_unique<PixelDCSHVData>()); - //if (SG::ReadCondHandle<PixelModuleData>(m_moduleDataKey,ctx)->getUseDCSHVConditions()) { - if (modData->getUseDCSHVConditions()) { + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + + EventIDRange rangeW{start, stop}; + + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); - writeHandle.addDependency(readHandle); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); return StatusCode::FAILURE; } + // Get the validitiy range + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); - ATH_MSG_INFO("Range of DCS input is " << readHandle.getRange()); + ATH_MSG_INFO("Range of DCS input is " << rangeW); // Read HV info std::string param("HV"); @@ -84,7 +89,7 @@ StatusCode PixelDCSCondHVAlg::execute(const EventContext& ctx) const { } } - if (writeHandle.record(std::move(writeCdo)).isFailure()) { + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { ATH_MSG_FATAL("Could not record PixelDCSHVData " << writeHandle.key() << " with EventRange " << writeHandle.getRange() << " into Conditions Store"); return StatusCode::FAILURE; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.cxx index 4d904b38231..bd17f3802aa 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelDCSCondStateAlg.h" @@ -17,9 +17,7 @@ StatusCode PixelDCSCondStateAlg::initialize() { ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID")); ATH_CHECK(m_condSvc.retrieve()); - - ATH_CHECK(m_moduleDataKey.initialize()); - ATH_CHECK(m_readKeyState.initialize(!m_readKeyState.empty())); + ATH_CHECK(m_readKeyState.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKeyState.initialize()); if (m_condSvc->regHandle(this, m_writeKeyState).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKeyState.fullKey() << " with CondSvc"); @@ -40,24 +38,26 @@ StatusCode PixelDCSCondStateAlg::execute(const EventContext& ctx) const { // Construct the output Cond Object and fill it in std::unique_ptr<PixelDCSStateData> writeCdoState(std::make_unique<PixelDCSStateData>()); - - - SG::ReadCondHandle<PixelModuleData> modDataHdl(m_moduleDataKey,ctx); - const PixelModuleData* modData=(*modDataHdl); - writeHandleState.addDependency(modDataHdl); - ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange()); + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; - if (modData->getUseDCSStateConditions()) { - SG::ReadCondHandle<CondAttrListCollection> readHandleState(m_readKeyState, ctx); - writeHandleState.addDependency(readHandleState); - const CondAttrListCollection* readCdoState(*readHandleState); + EventIDRange rangeW{start, stop}; + + if (!m_readKeyState.empty()) { + SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKeyState, ctx); + const CondAttrListCollection* readCdoState(*readHandle); if (readCdoState==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object (state)"); return StatusCode::FAILURE; } - ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleState.fullKey() << " readCdo->size()= " << readCdoState->size()); - ATH_MSG_INFO("Range of state input is " << readHandleState.getRange()); + // Get the validitiy range + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdoState->size()); + ATH_MSG_INFO("Range of state input is " << rangeW); // Read state info std::string paramState = "FSM_state"; @@ -82,7 +82,7 @@ StatusCode PixelDCSCondStateAlg::execute(const EventContext& ctx) const { for (int i=0; i<(int)m_pixelID->wafer_hash_max(); i++) { writeCdoState->setModuleStatus(i,PixelDCSStateData::DCSModuleState::READY); } } - if (writeHandleState.record(std::move(writeCdoState)).isFailure()) { + if (writeHandleState.record(rangeW, std::move(writeCdoState)).isFailure()) { ATH_MSG_FATAL("Could not record PixelDCSStateData " << writeHandleState.key() << " with EventRange " << writeHandleState.getRange() << " into Conditions Store"); return StatusCode::FAILURE; } diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.h index 6555a6287ca..56b2658eef3 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.h +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStateAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** * @file PixelConditionsAlgorithms/PixelDCSCondStatusAlg.h @@ -17,7 +17,6 @@ #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "StoreGate/WriteCondHandleKey.h" -#include "PixelConditionsData/PixelModuleData.h" #include "PixelConditionsData/PixelDCSStateData.h" #include "InDetIdentifier/PixelID.h" @@ -38,11 +37,8 @@ class PixelDCSCondStateAlg : public AthReentrantAlgorithm { ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; - SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey - {this, "PixelModuleData", "PixelModuleData", "Pixel module data"}; - SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyState - {this, "ReadKeyState", "/PIXEL/DCS/FSMSTATE", "Key of input DCS state conditions folder"}; + {this, "ReadKeyState", "", "Key of input DCS state conditions folder"}; SG::WriteCondHandleKey<PixelDCSStateData> m_writeKeyState {this, "WriteKeyState", "PixelDCSStateCondData", "Key of output DCS state data"}; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.cxx index a6b31994a94..7ea2c958167 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelDCSCondStatusAlg.h" @@ -17,15 +17,12 @@ StatusCode PixelDCSCondStatusAlg::initialize() { ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID")); ATH_CHECK(m_condSvc.retrieve()); - - ATH_CHECK(m_moduleDataKey.initialize()); - ATH_CHECK(m_readKeyStatus.initialize(!m_readKeyStatus.empty())); + ATH_CHECK(m_readKeyStatus.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKeyStatus.initialize()); if (m_condSvc->regHandle(this, m_writeKeyStatus).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKeyStatus.fullKey() << " with CondSvc"); return StatusCode::FAILURE; } - return StatusCode::SUCCESS; } @@ -41,23 +38,25 @@ StatusCode PixelDCSCondStatusAlg::execute(const EventContext& ctx) const { // Construct the output Cond Object and fill it in std::unique_ptr<PixelDCSStatusData> writeCdoStatus(std::make_unique<PixelDCSStatusData>()); - - SG::ReadCondHandle<PixelModuleData> modDataHdl(m_moduleDataKey,ctx); - const PixelModuleData* modData=(*modDataHdl); - writeHandleStatus.addDependency(modDataHdl); - ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange()); - + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + + EventIDRange rangeW{start, stop}; - if (modData->getUseDCSStatusConditions()) { - SG::ReadCondHandle<CondAttrListCollection> readHandleStatus(m_readKeyStatus, ctx); - const CondAttrListCollection* readCdoStatus(*readHandleStatus); + if (!m_readKeyStatus.empty()) { + SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKeyStatus, ctx); + const CondAttrListCollection* readCdoStatus(*readHandle); if (readCdoStatus==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object (state)"); return StatusCode::FAILURE; } - writeHandleStatus.addDependency(readHandleStatus); - ATH_MSG_INFO("Size of CondAttrListCollection " << readHandleStatus.fullKey() << " readCdo->size()= " << readCdoStatus->size()); - ATH_MSG_INFO("Range of state input is " << readHandleStatus.getRange()); + // Get the validitiy range + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdoStatus->size()); + ATH_MSG_INFO("Range of state input is " << rangeW); // Read state info const std::string paramStatus = "FSM_status"; @@ -83,7 +82,7 @@ StatusCode PixelDCSCondStatusAlg::execute(const EventContext& ctx) const { } } - if (writeHandleStatus.record(std::move(writeCdoStatus)).isFailure()) { + if (writeHandleStatus.record(rangeW, std::move(writeCdoStatus)).isFailure()) { ATH_MSG_FATAL("Could not record PixelDCSStatusData " << writeHandleStatus.key() << " with EventRange " << writeHandleStatus.getRange() << " into Conditions Store"); return StatusCode::FAILURE; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.h index c50e26c24fc..e28c76bf19b 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.h +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondStatusAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** * @file PixelConditionsAlgorithms/PixelDCSCondStatusAlg.h @@ -17,7 +17,6 @@ #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "StoreGate/WriteCondHandleKey.h" -#include "PixelConditionsData/PixelModuleData.h" #include "PixelConditionsData/PixelDCSStatusData.h" #include "InDetIdentifier/PixelID.h" @@ -38,11 +37,8 @@ class PixelDCSCondStatusAlg : public AthReentrantAlgorithm { ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; - SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey - {this, "PixelModuleData", "PixelModuleData", "Pixel module data"}; - SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyStatus - {this, "ReadKeyStatus", "/PIXEL/DCS/FSMSTATUS", "Key of input DCS status conditions folder"}; + {this, "ReadKeyStatus", "", "Key of input DCS status conditions folder"}; SG::WriteCondHandleKey<PixelDCSStatusData> m_writeKeyStatus {this, "WriteKeyStatus", "PixelDCSStatusCondData", "Key of output DCS status data"}; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondTempAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondTempAlg.cxx index f8a6f8447e5..ffc6988e44b 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondTempAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDCSCondTempAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelDCSCondTempAlg.h" @@ -20,7 +20,7 @@ StatusCode PixelDCSCondTempAlg::initialize() { ATH_CHECK(m_condSvc.retrieve()); ATH_CHECK(m_moduleDataKey.initialize()); - ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_readKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this, m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -44,19 +44,27 @@ StatusCode PixelDCSCondTempAlg::execute(const EventContext& ctx) const { SG::ReadCondHandle<PixelModuleData> modDataHdl(m_moduleDataKey,ctx); const PixelModuleData* modData=(*modDataHdl); - writeHandle.addDependency(modDataHdl); ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange()); - if (modData->getUseDCSTemperatureConditions()) { + const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; + + EventIDRange rangeW{start, stop}; + + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); const CondAttrListCollection* readCdo(*readHandle); if (readCdo==nullptr) { ATH_MSG_FATAL("Null pointer to the read conditions object"); return StatusCode::FAILURE; } - writeHandle.addDependency(readHandle); + // Get the validitiy range + if (not readHandle.range(rangeW)) { + ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key()); + return StatusCode::FAILURE; + } ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size()); - ATH_MSG_INFO("Range of input is " << readHandle.getRange()); + ATH_MSG_INFO("Range of input is " << rangeW); // Read temperature info const std::string param{"temperature"}; @@ -84,7 +92,7 @@ StatusCode PixelDCSCondTempAlg::execute(const EventContext& ctx) const { } } - if (writeHandle.record(std::move(writeCdo)).isFailure()) { + if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) { ATH_MSG_FATAL("Could not record PixelDCSTempData " << writeHandle.key() << " with EventRange " << writeHandle.getRange() << " into Conditions Store"); return StatusCode::FAILURE; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.cxx index 4421fc4c34b..54b4ac53309 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelDeadMapCondAlg.h" @@ -16,8 +16,7 @@ StatusCode PixelDeadMapCondAlg::initialize() { ATH_MSG_DEBUG("PixelDeadMapCondAlg::initialize()"); ATH_CHECK(m_condSvc.retrieve()); - ATH_CHECK(m_moduleDataKey.initialize()); - ATH_CHECK(m_readKey.initialize()); + ATH_CHECK(m_readKey.initialize(SG::AllowEmpty)); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { ATH_MSG_FATAL("unable to register WriteCondHandle " << m_writeKey.fullKey() << " with CondSvc"); @@ -44,8 +43,7 @@ StatusCode PixelDeadMapCondAlg::execute(const EventContext& ctx) const { EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; EventIDRange rangeW{start, stop}; - - if (SG::ReadCondHandle<PixelModuleData>(m_moduleDataKey,ctx)->getUseDeadmapConditions()) { + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.h index c4e2ff1b5a6..470e57f4e65 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.h +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelDeadMapCondAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** * @file PixelConditionsAlgorithms/PixelDeadMapCondAlg.h @@ -17,7 +17,6 @@ #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "StoreGate/WriteCondHandleKey.h" -#include "PixelConditionsData/PixelModuleData.h" #include "PixelConditionsData/PixelDeadMapCondData.h" #include "GaudiKernel/ICondSvc.h" @@ -33,9 +32,6 @@ class PixelDeadMapCondAlg : public AthReentrantAlgorithm { private: ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; - SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey - {this, "PixelModuleData", "PixelModuleData", "Pixel module data"}; - SG::ReadCondHandleKey<CondAttrListCollection> m_readKey {this, "ReadKey", "/PIXEL/PixelModuleFeMask", "Input deadmap folder"}; diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.cxx b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.cxx index 2f76d4d8628..2ea72a0ad17 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelTDAQCondAlg.h" @@ -16,10 +16,7 @@ StatusCode PixelTDAQCondAlg::initialize() { ATH_MSG_INFO("PixelTDAQCondAlg::initialize()"); ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID")); - ATH_CHECK(m_condSvc.retrieve()); - - ATH_CHECK(m_moduleDataKey.initialize()); ATH_CHECK(m_readKey.initialize(!m_readKey.empty())); ATH_CHECK(m_writeKey.initialize()); if (m_condSvc->regHandle(this,m_writeKey).isFailure()) { @@ -46,8 +43,7 @@ StatusCode PixelTDAQCondAlg::execute(const EventContext& ctx) const { EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM}; EventIDRange rangeW{start, stop}; - - if (SG::ReadCondHandle<PixelModuleData>(m_moduleDataKey,ctx)->getUseTDAQConditions()) { + if (!m_readKey.empty()) { SG::ReadCondHandle<CondAttrListCollection> readHandle(m_readKey, ctx); const CondAttrListCollection* readCdo = *readHandle; if (readCdo==nullptr) { diff --git a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.h b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.h index 77e01c616b8..1b682def006 100644 --- a/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.h +++ b/InnerDetector/InDetConditions/PixelConditionsAlgorithms/src/PixelTDAQCondAlg.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** * @file PixelConditionsAlgorithms/PixelTDAQCondAlg.h @@ -17,7 +17,6 @@ #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "StoreGate/WriteCondHandleKey.h" -#include "PixelConditionsData/PixelModuleData.h" #include "PixelConditionsData/PixelTDAQData.h" #include "InDetIdentifier/PixelID.h" @@ -37,11 +36,8 @@ class PixelTDAQCondAlg : public AthReentrantAlgorithm { const PixelID* m_pixelID{nullptr}; ServiceHandle<ICondSvc> m_condSvc{this, "CondSvc", "CondSvc"}; - SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey - {this, "PixelModuleData", "PixelModuleData", "Pixel module data"}; - SG::ReadCondHandleKey<CondAttrListCollection> m_readKey - {this, "ReadKey", "/TDAQ/Resources/ATLAS/PIXEL/Modules", "Input key of TDAQ deadmap conditions folder"}; + {this, "ReadKey", "", "Input key of TDAQ deadmap conditions folder"}; SG::WriteCondHandleKey<PixelTDAQData> m_writeKey {this, "WriteKey", "PixelTDAQCondData", "Output key of pixel module data"}; diff --git a/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt b/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt index f2a96745d49..7f6ce0a55b2 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt +++ b/InnerDetector/InDetConditions/PixelConditionsData/CMakeLists.txt @@ -13,21 +13,20 @@ atlas_depends_on_subdirs( DetectorDescription/GeoPrimitives Database/AthenaPOOL/AthenaPoolUtilities InnerDetector/InDetConditions/InDetByteStreamErrors - InnerDetector/InDetConditions/PixelCoralClientUtils PRIVATE Control/AthenaKernel GaudiKernel ) # External dependencies: find_package( CLHEP ) -find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_library( PixelConditionsData src/*.cxx PUBLIC_HEADERS PixelConditionsData - PRIVATE_INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + PRIVATE_INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES CxxUtils Identifier GeoPrimitives PixelCoralClientUtils - PRIVATE_LINK_LIBRARIES ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel AthenaPoolUtilities GaudiKernel ) + LINK_LIBRARIES CxxUtils Identifier GeoPrimitives + PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} ${ROOT_LIBRARIES} AthenaKernel AthenaPoolUtilities GaudiKernel ) diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h index f9a0e096c39..677b4c1d46a 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h +++ b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/PixelModuleData.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** * @file PixelConditionsData/PixelModuleData.h @@ -28,27 +28,6 @@ class PixelModuleData { int getChipStatus(const int chanNum) const; // Switch parameters - void setUseCalibConditions(bool UseCalibConditions); - bool getUseCalibConditions() const; - - void setUseDeadmapConditions(bool UseDeadmapConditions); - bool getUseDeadmapConditions() const; - - void setUseDCSStateConditions(bool UseDCSStateConditions); - bool getUseDCSStateConditions() const; - - void setUseDCSStatusConditions(bool UseDCSStatusConditions); - bool getUseDCSStatusConditions() const; - - void setUseDCSHVConditions(bool UseDCSHVConditions); - bool getUseDCSHVConditions() const; - - void setUseDCSTemperatureConditions(bool UseDCSTemperatureConditions); - bool getUseDCSTemperatureConditions() const; - - void setUseTDAQConditions(bool UseTDAQConditions); - bool getUseTDAQConditions() const; - void setUseCablingConditions(bool UseCablingConditions); bool getUseCablingConditions() const; @@ -213,13 +192,6 @@ class PixelModuleData { typedef std::map<int, std::vector<float>> chipCharge; - bool m_useCalibConditions; - bool m_useDeadmapConditions; - bool m_useDCSStateConditions; - bool m_useDCSStatusConditions; - bool m_useDCSHVConditions; - bool m_useDCSTemperatureConditions; - bool m_useTDAQConditions; bool m_useCablingConditions; double m_bunchSpace; diff --git a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/SpecialPixelMap.h b/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/SpecialPixelMap.h deleted file mode 100755 index 7afe6762b2b..00000000000 --- a/InnerDetector/InDetConditions/PixelConditionsData/PixelConditionsData/SpecialPixelMap.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCONDITIONSDATA_SPECIALPIXELMAP_H -#define PIXELCONDITIONSDATA_SPECIALPIXELMAP_H - -#include "PixelCoralClientUtils/SpecialPixelMap.hh" - -#include "AthenaKernel/CLASS_DEF.h" -#include "AthenaKernel/CondCont.h" -#include "CxxUtils/checker_macros.h" -#include<map> -#include<string> - - -/** - * Classes to hold data about special pixels in the detector store and make it - * accessible to athena components. - * - * ruwiedel@physik.uni-bonn.de - * - */ - - -namespace coral{ - class Blob; -} -class IdentifierHash; -class ModuleSpecialPixelMap; - -/** A class for a map of special pixels for the whole pixel detector - or any subgroup of modules. A DetectorSpecialPixelMap is an std::vector - of pointers to ModuleSpecialPixelMaps which hold the actual pixel - status codes. A ModuleSpecialPixelMap is accessed by its IdentifierHash. - */ - -class DetectorSpecialPixelMap : public PixelCoralClientUtils::DetectorSpecialPixelMap{ - - public: - DetectorSpecialPixelMap(); - DetectorSpecialPixelMap(const DetectorSpecialPixelMap& dspm); //!< construct a copy - DetectorSpecialPixelMap(const std::vector<ModuleSpecialPixelMap*>& modules); //!< construct from contents - ~DetectorSpecialPixelMap(); - - DetectorSpecialPixelMap& operator=(const DetectorSpecialPixelMap& spm); - DetectorSpecialPixelMap& operator+=(const DetectorSpecialPixelMap& spm); //!< merge two pixel maps into one - - const ModuleSpecialPixelMap* module(IdentifierHash moduleHash) const; //!< const access to a ModuleSpecialPixelMap* - -}; - -/** A class for a map of special pixels for a single module of the pixel - detector. A ModuleSpecialPixelMap is an std::map of the status codes - (unsigned integers) for all pixels with special properties on a module. - The possible status codes are explained on the wiki page - https://twiki.cern.ch/twiki/bin/view/Atlas/PixelCOOLoffline#Dead_and_special_pixels_map - - The status for a pixel can be retrieved with pixelStatus(pixelID). - The pixel ID can be calculated with encodePixelID. In addition to - pixelStatus, several accessors for individual status bits are provided. - */ - - -class ModuleSpecialPixelMap : public PixelCoralClientUtils::ModuleSpecialPixelMap{ - - public: - ModuleSpecialPixelMap(); - ModuleSpecialPixelMap(const ModuleSpecialPixelMap& mspm); - //!< construct a copy - ModuleSpecialPixelMap(const char* filename, unsigned int mchips); - //!< construct from text file (for details on the format see the README file in PixelConditionsServices/doc) - ModuleSpecialPixelMap(const std::string& clob, unsigned int mchips); - //!< construct from string - ModuleSpecialPixelMap(const coral::Blob& blob, unsigned int mchips); - //!< construct from blob - ModuleSpecialPixelMap(const std::map<unsigned int, unsigned int>& pixels, - unsigned int module_status, - std::vector<unsigned int> chip_status, - std::vector<std::vector<unsigned int> > column_pair_status, unsigned int mchips); - //!< construct from contents - ~ModuleSpecialPixelMap(); - - ModuleSpecialPixelMap& operator=(const ModuleSpecialPixelMap& mspm); - ModuleSpecialPixelMap& operator+=(ModuleSpecialPixelMap mspm); - //!< merge two pixel maps into one - - void print(int component, unsigned int layer, unsigned int phi, int eta, - bool verbosePixelID = true, bool binaryPixelStatus = true) const; - //!< print map to screen - - StatusCode fill_from_string(const std::string& clob); - //!< fills the map from a string, used for conversion of data from the database - StatusCode fill_from_blob(const coral::Blob& blob); - //!< fills the map from a blob, used for conversion of data from the database -}; - -CLASS_DEF(DetectorSpecialPixelMap, 203854058, 1) -CLASS_DEF(ModuleSpecialPixelMap, 84153642, 1) - -CONDCONT_DEF( DetectorSpecialPixelMap, 70046420); -CONDCONT_DEF( ModuleSpecialPixelMap, 153445648); - -#endif diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx index 8418d74e105..0c605f097e8 100644 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx +++ b/InnerDetector/InDetConditions/PixelConditionsData/src/PixelModuleData.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "PixelConditionsData/PixelModuleData.h" @@ -35,27 +35,6 @@ int PixelModuleData::getChipStatus(const int chanNum) const { } // Switch parameters -void PixelModuleData::setUseCalibConditions(bool UseCalibConditions) { m_useCalibConditions = UseCalibConditions; } -bool PixelModuleData::getUseCalibConditions() const { return m_useCalibConditions; } - -void PixelModuleData::setUseDeadmapConditions(bool UseDeadmapConditions) { m_useDeadmapConditions = UseDeadmapConditions; } -bool PixelModuleData::getUseDeadmapConditions() const { return m_useDeadmapConditions; } - -void PixelModuleData::setUseDCSStateConditions(bool UseDCSStateConditions) { m_useDCSStateConditions = UseDCSStateConditions; } -bool PixelModuleData::getUseDCSStateConditions() const { return m_useDCSStateConditions; } - -void PixelModuleData::setUseDCSStatusConditions(bool UseDCSStatusConditions) { m_useDCSStatusConditions = UseDCSStatusConditions; } -bool PixelModuleData::getUseDCSStatusConditions() const { return m_useDCSStatusConditions; } - -void PixelModuleData::setUseDCSHVConditions(bool UseDCSHVConditions) { m_useDCSHVConditions = UseDCSHVConditions; } -bool PixelModuleData::getUseDCSHVConditions() const { return m_useDCSHVConditions; } - -void PixelModuleData::setUseDCSTemperatureConditions(bool UseDCSTemperatureConditions) { m_useDCSTemperatureConditions = UseDCSTemperatureConditions; } -bool PixelModuleData::getUseDCSTemperatureConditions() const { return m_useDCSTemperatureConditions; } - -void PixelModuleData::setUseTDAQConditions(bool UseTDAQConditions) { m_useTDAQConditions = UseTDAQConditions; } -bool PixelModuleData::getUseTDAQConditions() const { return m_useTDAQConditions; } - void PixelModuleData::setUseCablingConditions(bool UseCablingConditions) { m_useCablingConditions = UseCablingConditions; } bool PixelModuleData::getUseCablingConditions() const { return m_useCablingConditions; } diff --git a/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx b/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx deleted file mode 100755 index c8296aaf9b9..00000000000 --- a/InnerDetector/InDetConditions/PixelConditionsData/src/SpecialPixelMap.cxx +++ /dev/null @@ -1,412 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelConditionsData/SpecialPixelMap.h" - -// Athena/Gaudi -#include "GaudiKernel/MsgStream.h" -#include "AthenaKernel/getMessageSvc.h" - -#include "CoralBase/Blob.h" -#include "Identifier/IdentifierHash.h" - -// standard library -#include<fstream> -#include<sstream> -#include<string> -#include<iomanip> - - -//***** DetectorSpecialPixelMap *****// -const int nmtype(5); -static const unsigned int columnsPerFEIX[5]={18,80,132,80,132}; // number of columns per FEI3, 4, 50, 51, 52 -//static unsigned int rowsPerFEIX[5]={164, 336, 672, 339, 678}; // number of rows per FEI3, 4, 50, 51, 52 -//static unsigned int rowsRdoPerFEIX[5]={160, 336, 672, 336, 672}; // number of rows readout per FEI3, 4, 50, 51, 52 - - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(){} - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(const DetectorSpecialPixelMap& spm) : - PixelCoralClientUtils::DetectorSpecialPixelMap(){ - - for(DetectorSpecialPixelMap::const_iterator module = spm.begin(); module != spm.end(); ++module){ - - push_back(new ModuleSpecialPixelMap( dynamic_cast<ModuleSpecialPixelMap&>(**module))); - - } -} - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(const std::vector<ModuleSpecialPixelMap*>& modules){ - - for(std::vector<ModuleSpecialPixelMap*>::const_iterator module = modules.begin(); module != modules.end(); ++module){ - - push_back(new ModuleSpecialPixelMap(**module)); - - } -} - -DetectorSpecialPixelMap::~DetectorSpecialPixelMap(){} - - -const ModuleSpecialPixelMap* DetectorSpecialPixelMap::module(IdentifierHash moduleHash) const{ - return dynamic_cast<const ModuleSpecialPixelMap*>(PixelCoralClientUtils::DetectorSpecialPixelMap::module(moduleHash)); -} - - -DetectorSpecialPixelMap& DetectorSpecialPixelMap::operator=(const DetectorSpecialPixelMap& spm){ - if(this !=&spm){ - *this = dynamic_cast<DetectorSpecialPixelMap&>(PixelCoralClientUtils::DetectorSpecialPixelMap::operator=(spm)); - } - return (*this); -} - -DetectorSpecialPixelMap& DetectorSpecialPixelMap::operator+=(const DetectorSpecialPixelMap& spm){ - return dynamic_cast<DetectorSpecialPixelMap&>(PixelCoralClientUtils::DetectorSpecialPixelMap::operator+=(spm)); -} - - - -//***** ModuleSpecialPixelMap *****// - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(){} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const ModuleSpecialPixelMap& mspm) : - PixelCoralClientUtils::ModuleSpecialPixelMap(mspm){} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const char* filename, unsigned int mchips) : - PixelCoralClientUtils::ModuleSpecialPixelMap(filename, mchips){} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const std::string& clob, unsigned int mchips) : - PixelCoralClientUtils::ModuleSpecialPixelMap(clob, mchips){} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const coral::Blob& blob, unsigned int mchips) : - PixelCoralClientUtils::ModuleSpecialPixelMap(blob, mchips){} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const std::map<unsigned int, unsigned int>& pixels, - unsigned int module_status, - std::vector<unsigned int> chip_status, - std::vector<std::vector<unsigned int> > column_pair_status, - unsigned int mchips) : - PixelCoralClientUtils::ModuleSpecialPixelMap(pixels, module_status, chip_status, column_pair_status, mchips){} - -ModuleSpecialPixelMap::~ModuleSpecialPixelMap(){} - - -ModuleSpecialPixelMap& ModuleSpecialPixelMap::operator=(const ModuleSpecialPixelMap& mspm){ - if(this !=&mspm){ - *this =dynamic_cast<ModuleSpecialPixelMap&>(PixelCoralClientUtils::ModuleSpecialPixelMap::operator=(mspm)); - } - return (*this); -} - -ModuleSpecialPixelMap& ModuleSpecialPixelMap::operator+=(ModuleSpecialPixelMap mspm){ - return dynamic_cast<ModuleSpecialPixelMap&>(PixelCoralClientUtils::ModuleSpecialPixelMap::operator+=(mspm)); -} - -void ModuleSpecialPixelMap::print(int component, - unsigned int layer, - unsigned int phi, - int eta, - bool verbosePixelID, - bool binaryPixelStatus) const{ - - MsgStream log(Athena::getMessageSvc(), "ModuleSpecialPixelMap"); - - unsigned int system, subSystem; - system = 2; - subSystem = 1; - - int itype = (int)m_chipsPerModule%10; - if(itype>(nmtype-1))itype=nmtype-1; - int mch = (int)m_chipsPerModule/10; - int mcolumns = columnsPerFEIX[itype]; // set protection here - - int moduleID = itype==0 ? ( ((component + 2) / 2) << 25 ) + ( layer << 23 ) + ( phi << 17 ) + ( (eta + 6) << 13 ) : -1; - - //print header - - log << MSG::INFO << " " << endmsg; - if(moduleID>-1)log << MSG::INFO << "ModuleSpecialPixelMap for module " << moduleID << ":" << endmsg; - log << MSG::INFO << "Offline ID [system,subsystem,endcap/barrel,layer/disk,phi,eta] : [" - << system << ',' << subSystem << ',' << component << ',' << layer << ',' << phi << ',' << eta << ']' << endmsg; - log << MSG::INFO << "Module status: "; - log.width(10); - log << m_module_status << endmsg; - log << MSG::INFO << " " << endmsg; - - bool print_chip_status = false; - bool print_column_pair_status = false; - - for(int i = 0; i < mch; i++){ - if(m_chip_status.size() != 0 && m_chip_status[i] != 0){ - print_chip_status = true; - } - for(int j = 0; j < mcolumns/2; j++){ - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0 - && m_column_pair_status[i][j] != 0){ - print_chip_status = true; - print_column_pair_status = true; - } - } - } - if(mch>2){ - if(print_chip_status){ - log <<MSG::INFO << "Chip number: "; - for(int i = mch-1; i>mch/2-1; i--)log<<i<<" "; - log<< endmsg; - - log << MSG::INFO << "Chip status: "; - for(int i = mch-1; i > mch/2-1; i--){ - log.width(10); - if(m_chip_status.size() != 0){ - log << m_chip_status[i] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - log << MSG::INFO << " " << endmsg; - - if(print_column_pair_status){ - log << MSG::INFO << "Column pairs: "; - for(int i = mch-1; i > mch/2-1; i--){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][0] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - log << MSG::INFO << "pairs 0 to "<<mch/2<<" "; - for(int i = mch-1; i > mch/2-1; i--){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][1] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - for(int j = 2; j < mcolumns/2; j++){ - log << MSG::INFO << " "; - for(int i = mch-1; i > mch/2-1; i--){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][j] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - } - log << MSG::INFO << " " << endmsg; - - - log << MSG::INFO << "Column pairs: "; - for(int i = 0; i < mch/2; i++){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][0] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - log << MSG::INFO << "pairs 0 to "<<mch/2<<" "; - for(int i = 0; i < mch/2; i++){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][1] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - for(int j = 2; j < mcolumns/2; j++){ - log << MSG::INFO << " "; - for(int i = 0; i < mch/2; i++){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][j] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - } - log << MSG::INFO << " " << endmsg; - } - else{ - log << MSG::INFO << "No special column pairs on this module" << endmsg; - log << MSG::INFO << " " << endmsg; - } - - log << MSG::INFO << "Chip status: "; - for(int i = 0; i < mch/2; i++){ - log.width(10); - if(m_chip_status.size() != 0){ - log << m_chip_status[i] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - log << MSG::INFO << "Chip number: "; - for(int i = 0; i<mch/2; ++i)log<<i<<" "; - log<< endmsg; - log << MSG::INFO << " " << endmsg; - log << MSG::INFO << " " << endmsg; - } - else{ - log << MSG::INFO << "No special chips and/or column pairs on this module" << endmsg; - log << MSG::INFO << " " << endmsg; - } - - //print map - - for(const_iterator pixel = begin(); pixel != end(); ++pixel){ - if(verbosePixelID){ - unsigned int pixelID = pixel->first; - unsigned int chip = pixelID % 16; - unsigned int column = (itype==0) ? ((pixelID / 16) % 32) : ((pixelID / 16) % 256); - unsigned int row = (itype==0) ? (pixelID / 512) : (pixelID / 4096); - log << "Pixel (chip/column/row) "; - log << ' '; - log << chip << "/"; - log << ' '; - - log << column << "/"; - - log << ' '; - log << row; - } - else{ - log << MSG::INFO << "Pixel " << pixel->first; - } - if(binaryPixelStatus){ - unsigned int pixelStatus = pixel->second; - log << " status: "; - for(int i = 31; i >= 0; i--){ - bool statusBit = pixelStatus & (1 << i); - log << statusBit; - if(!(i%4)) log << ' '; - } - log << endmsg; - } - else{ - log << " status: " << pixel->second << endmsg; - } - } - } - else{// IBL FEI4 module - // - if(print_chip_status){ - log<<MSG::INFO << "Chip number: "; - for(int i =0; i<mch; ++i)log<<i<<" "; - log<<endmsg; - log <<MSG::INFO << "Chip status: "; - for(int i = 0; i < (int)mch; i++){ - log.width(10); - if(m_chip_status.size() != 0){ - log << m_chip_status[i] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - log <<MSG::INFO << " " << endmsg; - - if(print_column_pair_status){ - log <<MSG::INFO <<"Column pairs 0 to "<<mcolumns/2<<" "; - log << endmsg; - for(int j = 0; j<mcolumns/2; ++j){ - for(int i = 0; i < (int)mch; i++){ - log.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - log << m_column_pair_status[i][j] << " "; - } - else{ - log << 0 << " "; - } - } - log << endmsg; - } - - log << " " << endmsg; - - } - else{ - log << "No special column pairs on this module" << endmsg; - log << " " << endmsg; - } - } - else{ - log << "No special chips and/or column pairs on this module" << endmsg; - log << " " << endmsg; - } - //print map - - for(const_iterator pixel = begin(); pixel != end(); ++pixel){ - if(verbosePixelID){ - unsigned int pixelID = pixel->first; - unsigned int chip = pixelID % 16; - unsigned int column = (itype==0) ? ((pixelID / 16) % 32) : ((pixelID / 16) % 256); - unsigned int row = (itype==0) ? (pixelID / 512) : (pixelID / 4096); - - log << "Pixel (chip/column/row) "; - log << ' '; - log << chip << "/"; - log <<' '; - log << column << "/"; - log << ' '; - log << row; - } - else{ - log << MSG::INFO <<"Pixel " << pixel->first; - } - if(binaryPixelStatus){ - unsigned int pixelStatus = pixel->second; - log << " status: "; - for(int i = 31; i >= 0; i--){ - bool statusBit = pixelStatus & (1 << i); - log << statusBit; - if(!(i%4)) log << ' '; - } - log << endmsg; - } - else{ - log << " status: " << pixel->second << endmsg; - } - } - // - } - - return; -} - -StatusCode ModuleSpecialPixelMap::fill_from_string(const std::string& clob){ - if( PixelCoralClientUtils::ModuleSpecialPixelMap::fill_from_string(clob) ){ - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} - -StatusCode ModuleSpecialPixelMap::fill_from_blob(const coral::Blob& blob){ - if( PixelCoralClientUtils::ModuleSpecialPixelMap::fill_from_blob(blob) ){ - return StatusCode::FAILURE; - } - - return StatusCode::SUCCESS; -} diff --git a/InnerDetector/InDetConditions/PixelConditionsTools/PixelConditionsTools/ISpecialPixelMapSvc.h b/InnerDetector/InDetConditions/PixelConditionsTools/PixelConditionsTools/ISpecialPixelMapSvc.h deleted file mode 100755 index 6aa5773afa1..00000000000 --- a/InnerDetector/InDetConditions/PixelConditionsTools/PixelConditionsTools/ISpecialPixelMapSvc.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCONDITIONSTOOLS_ISPECIALPIXELMAPSERVICE_H -#define PIXELCONDITIONSTOOLS_ISPECIALPIXELMAPSERVICE_H - - -#include "GaudiKernel/IInterface.h" -#include "AthenaKernel/IOVSvcDefs.h" - -#include "AthenaPoolUtilities/CondAttrListCollection.h" -#include "PixelConditionsData/SpecialPixelMap.h" - - - -/** - * Abstract interface for SpecialPixelMapSvc - * - * Creates and manages a set of special pixel map objects in the detector store. If not explicitly switched - * off in the job options, a callback funtion is registered that creates the special pixel map objects in the - * detector store and automatically keeps them up to date for the current run/lumi block. By default all - * special pixel maps are merged into one map which is stored in place of the first map in the list of - * StoreGate keys. - * - * In addition to the callback function the following functions are provided: A special pixel map object can - * be created explicitly with the create method. This method can be configured to either use the data from - * the offline COOL database or from text files. The contents of maps for selected modules can be printed to - * the screen with print(). The number of maps managed can be retrieved with getNPixelMaps(), and the maps - * can be retrieved with getPixelMap(unsigned int index). - * - * ruwiedel@physik.uni-bonn.de - * - */ - - -class ISpecialPixelMapSvc: virtual public IInterface{ - -public: - virtual ~ISpecialPixelMapSvc(){} - - static const InterfaceID& interfaceID(); - - /** automatically creates and updates pixel map objects in the detector store for the current run/lumi block */ - virtual StatusCode IOVCallBack(IOVSVC_CALLBACK_ARGS) = 0; //!< callback function registered in initialize() - - virtual StatusCode createFromTextfiles(bool fillMissing = true) const = 0; - //!< create special pixel map objects using data read from text files (for details see the README file in the doc directory) - virtual StatusCode createFromDetectorStore(const std::string condAttrListCollectionKey, const std::string pixelMapKey, - bool fillMissing = true ) const = 0; - //!< create special pixel map from CondAttrListCollection at key - virtual StatusCode createFromDetectorStore(bool fillMissing = true) const = 0; - //!< create special pixel map objects using data from the offline COOL database - virtual StatusCode create() const = 0; - //!< create special pixel map objects using the data source specified in the job options - virtual StatusCode print() const = 0; - //!< print pixel maps for the modules specified in the job options to the screen - - virtual unsigned int getNPixelMaps() const = 0; - //!< returns the number of special pixel map objects managed by the SpecialPixelMapSvc - virtual const DetectorSpecialPixelMap *getPixelMap(unsigned int index) const = 0; - //!< returns a const pointer to the index'th special pixel map - - virtual unsigned int getChips(const unsigned int & index) const = 0; - //!< returns the number of chips and type of module as 10*mchips+i - - virtual StatusCode registerCondAttrListCollection(const DetectorSpecialPixelMap* spm) const = 0; - //!< convert spm to CondAttrListCollection and register in the detector store - //!< used when preparing database write -}; - -inline const InterfaceID& ISpecialPixelMapSvc::interfaceID(){ - static const InterfaceID IID_ISpecialPixelMapSvc("ISpecialPixelMapSvc", 1, 0); - return IID_ISpecialPixelMapSvc; -} - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/CMakeLists.txt b/InnerDetector/InDetConditions/PixelCoralClientUtils/CMakeLists.txt deleted file mode 100644 index e683f06057c..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -################################################################################ -# Package: PixelCoralClientUtils -################################################################################ - -# Declare the package name: -atlas_subdir( PixelCoralClientUtils ) - -# Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC - Control/CxxUtils - Database/CoraCool ) - -# External dependencies: -find_package( COOL COMPONENTS CoolKernel ) -find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) -find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) - -# Component(s) in the package: -atlas_add_library( PixelCoralClientUtils - src/CoralClient.cc - src/PCDio.cc - src/SpecialPixelMap.cc - src/PCDDb.cxx - src/PixCalibCoralCoolDb.cc - src/PixCalibKnowledgeDb.cc - PUBLIC_HEADERS PixelCoralClientUtils - INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} CxxUtils CoraCool - PRIVATE_LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ) - -atlas_add_executable( CORAL-read - src/CORAL-read.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( CORAL-create - src/CORAL-create.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( CORAL-fill - src/CORAL-fill.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( CORAL-listVariables - src/CORAL-listVariables.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( extractAnalysis - src/extractAnalysis.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( fixTimewalk - src/fixTimewalk.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( extractSPM - src/extractSPM.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( talkToPCDDb - src/talkToPCDDb.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - -atlas_add_executable( calibDbInterface - src/calibDbInterface.cc - INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} CxxUtils CoraCool PixelCoralClientUtils ) - diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/ATLAS_CHECK_THREAD_SAFETY b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/ATLAS_CHECK_THREAD_SAFETY deleted file mode 100644 index 67cfcbd2e28..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/ATLAS_CHECK_THREAD_SAFETY +++ /dev/null @@ -1 +0,0 @@ -InnerDetector/InDetConditions/PixelCoralClientUtils diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/AnalysisResultList_t.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/AnalysisResultList_t.hh deleted file mode 100644 index 6e6b7fde0cd..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/AnalysisResultList_t.hh +++ /dev/null @@ -1,213 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_ANALYSISRESULTLIST_T_HH -#define PIXELCORALCLIENTUTILS_ANALYSISRESULTLIST_T_HH - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/PixResultsException.hh" -#include <map> -#include <vector> -#include <sstream> -#include "PixelMap.h" - -namespace CAN { - - class AnalysisResultList_t; - - class AnalysisResultValueNotFound : public CAN::PixResultsException - { - friend class AnalysisResultList_t; - protected: - AnalysisResultValueNotFound(const std::string &function_name, - const std::string &message) - : CAN::PixResultsException("ANAVAL_NOTEXISTING "+function_name+": "+message) - {} - - }; - - class AverageResult_t - { - public: - AverageResult_t(const unsigned int n, const float mean, const float rms, const float lower99, const float upper99) - : m_n(n) - { - m_values[kMean]=mean; - m_values[kRMS]=rms; - m_values[kLower99]=lower99; - m_values[kUpper99]=upper99; - } - - AverageResult_t() - : m_n(0) - { - for(unsigned int i=0; i<kNValues; ++i) { - m_values[i]=0; - } - } - - enum EValues {kMean, kRMS, kLower99, kUpper99, kNValues}; - float value(int i) const {return m_values[i];}; - unsigned int n() const {return m_n;}; - - private: - unsigned int m_n; - float m_values[kNValues]; - }; - - - /** Container for analysis results. - * Can store : - * <ul> - * <li>unsigned ints<li/> - * <li>bools<li/> - * <li>average value given by : n, meam, rms, lower 99% and upper 99% bounds.<li/> - * </ul> - * Each value is assigned to a variable name and a connectivity name. - * The values are stored by <tt>analysis_results.addValue<unsigned int>("a_value","ROD_C1_S11",1)<tt>, - * they are retrieved by <tt>unsignd int a_value = analysis_results.value<unsigned int>("a_value","ROD_C1_S11")<tt>, - * or one can iteratre over all stored values. The iterators can be obtained by <tt>analysis_results.begin<unsigned int>()</tt> - * and <tt>analysis_results.end<unsigned int>()</tt>. - */ - class AnalysisResultList_t { - public: - -// void addValue(const std::string &name, const float value) { -// m_floatValues.insert(std::make_pair(name, value)); -// } - - protected: - template <class T> - std::map<std::string, std::map<std::string, T> > &getMap(); - - template <class T> - const std::map<std::string, std::map<std::string, T> > &getMap() const; - - void throwValueDoesNotExist(const std::string &var_name, const std::string& conn_name) const { - std::stringstream message; - message << "No value of name " << var_name << " for connectivity object " << conn_name << "."; - throw AnalysisResultValueNotFound("AnalysisResultList_t::value<T>",message.str()); - } - - public: - template <class T> - void insertValue(const std::string &var_name, const std::string &conn_name, const T &value) { - getMap<T>()[var_name].insert(std::make_pair(conn_name,value)); - } - - template <class T> - void addValue(const std::string &var_name, const std::string &conn_name, const T &value) { - getMap<T>()[var_name][conn_name]=value; - } - - template <class T> - const T &value(const std::string &var_name, const std::string &conn_name) const { - typename std::map< std::string, std::map<std::string, T> >::const_iterator iter=getMap<T>().find(var_name); - if (iter == getMap<T>().end()) { - throwValueDoesNotExist(var_name,conn_name); - } - typename std::map<std::string, T>::const_iterator val_iter=iter->second.find(conn_name); - if (val_iter == iter->second.end()) { - throwValueDoesNotExist(var_name,conn_name); - } - return val_iter->second; - } - - template <class T> - bool has(const std::string &var_name, const std::string &conn_name) const { - typename std::map< std::string, std::map<std::string, T> >::const_iterator iter=getMap<T>().find(var_name); - if (iter != getMap<T>().end()) { - typename std::map<std::string, T>::const_iterator val_iter=iter->second.find(conn_name); - if (val_iter != iter->second.end()) { - return true; - } - } - return false; - } - - int nPixelMaps() { return m_pixelMap.size(); }; - - template <class T> - typename std::map< std::string, std::map<std::string, T> >::iterator begin() - { return getMap<T>().begin(); } - - template <class T> - typename std::map< std::string, std::map<std::string, T> >::const_iterator begin () const - { return getMap<T>().begin(); } - - template <class T> - typename std::map< std::string, std::map<std::string, T> >::const_iterator end () const - { return getMap<T>().end(); } - - protected: - std::map<std::string, std::map<std::string, bool> > m_boolValues; - std::map<std::string, std::map<std::string, unsigned int> > m_uintValues; - std::map<std::string, std::map<std::string, float> > m_floatValues; //CLA - std::map<std::string, std::map<std::string, AverageResult_t> > m_avValues; - std::map<std::string, std::map<std::string, PixelMap_t> > m_pixelMap; //CLA - }; - - - template <> inline - std::map<std::string, std::map<std::string, bool> > & - AnalysisResultList_t::getMap<bool>() { return AnalysisResultList_t::m_boolValues; } - - template <> inline - const std::map<std::string, std::map<std::string, bool> > & - AnalysisResultList_t::getMap<bool>() const { return AnalysisResultList_t::m_boolValues; } - - template <> inline - std::map<std::string, std::map<std::string, unsigned int> > & - AnalysisResultList_t::getMap<unsigned int>() { return AnalysisResultList_t::m_uintValues; } - - template <> inline - const std::map<std::string, std::map<std::string, unsigned int> > & - AnalysisResultList_t::getMap<unsigned int>() const { return AnalysisResultList_t::m_uintValues; } - - template <> inline - std::map<std::string, std::map<std::string, float> > & - AnalysisResultList_t::getMap<float>() { return AnalysisResultList_t::m_floatValues; } //CLA - - template <> inline - const std::map<std::string, std::map<std::string, float> > & - AnalysisResultList_t::getMap<float>() const { return AnalysisResultList_t::m_floatValues; } //CLA - - template <> inline - std::map<std::string, std::map<std::string, AverageResult_t> > & - AnalysisResultList_t::getMap<AverageResult_t>() { return AnalysisResultList_t::m_avValues; } - - template <> inline - const std::map<std::string, std::map<std::string, AverageResult_t> > & - AnalysisResultList_t::getMap<AverageResult_t>() const { return AnalysisResultList_t::m_avValues; } - - template <> inline - std::map<std::string, std::map<std::string, PixelMap_t> > & - AnalysisResultList_t::getMap<PixelMap_t>() { return AnalysisResultList_t::m_pixelMap; } - - template <> inline - const std::map<std::string, std::map<std::string, PixelMap_t> > & - AnalysisResultList_t::getMap<PixelMap_t>() const { return AnalysisResultList_t::m_pixelMap; } - - // example: - // - // inline void test() { - // AnalysisResultList_t a; - // a.addValue<unsigned int>("test","ROD_C1_S11",1); - // unsigned int a_value = a.value<unsigned int>("test","ROD_C1_S11"); - // - // for (std::map<std::string, std::map<std::string, unsigned int > >::const_iterator iter=a.begin<unsigned int>(); - // iter != a.end<unsigned int>(); - // iter ++) { - // - // for (std::map<std::string, unsigned int >::const_iterator val_iter=iter->second.begin(); - // val_iter != iter->second.end(); - // val_iter ++) { - // unsigned int b=val_iter->second; - // } - // } - // } - -} - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/CoralClient.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/CoralClient.hh deleted file mode 100644 index dc5285d607b..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/CoralClient.hh +++ /dev/null @@ -1,188 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CORALCLIENT -#define CORALCLIENT - -// GENERIC C++/C headers -#include <time.h> -#include <sys/time.h> -#include <iostream> -#include <fstream> -#include <string> -#include <set> -#include <cstdio> - -#include "PixelCoralClientUtils/IPixResultsDbListener.hh" -#include "PixelCoralClientUtils/AnalysisResultList_t.hh" - -// same definitions are done by seal and omni - -#ifdef HAVE_NAMESPACES -# undef HAVE_NAMESPACES -#endif -#ifdef HAVE_BOOL -# undef HAVE_BOOL -#endif -#ifdef HAVE_DYNAMIC_CAST -# undef HAVE_DYNAMIC_CAST -#endif - -// CORAL API -#include "CoralKernel/Context.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/AttributeListException.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/IConnectionServiceConfiguration.h" -#include "RelationalAccess/AccessMode.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ITransaction.h" - -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDescription.h" -#include "RelationalAccess/IColumn.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/IQuery.h" -#include "RelationalAccess/TableDescription.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/ITableSchemaEditor.h" -#include "RelationalAccess/IBulkOperation.h" -#include "RelationalAccess/SchemaException.h" - -// COOL API: database service bootstrap -//#include "CoolApplication/Application.h" -//#include "CoolApplication/DatabaseSvcFactory.h" -#include <CoralBase/TimeStamp.h> - - -//using namespace cool; - -namespace CAN { - // Added typedef to remove dependency on idl (PixCalibDbCoral/Common.idl) -#ifdef __x86_64__ - typedef unsigned int SerialNumber_t; -#else - typedef unsigned long SerialNumber_t; -#endif - class AverageResult_t; -} - -// added -- A.X. -namespace PixelCalib { - class PixelCalibData; -} - -class PixCoralClient { - -private: - std::string m_connString; - coral::AccessMode m_accessMode; - - coral::IHandle<coral::IConnectionService> m_connectionService; - coral::ISessionProxy *m_session; - - std::string m_pixeltable; - bool m_verbose; - - void connect(); - static coral::IHandle<coral::IConnectionService> connectionService(bool verbose=false); - -protected: - - void transactionStartReadOnly(); - void transactionStartUpdate(); - void transactionCommit(); - -public: - // added table name -- A.X. - PixCoralClient(const std::string& id1, - bool verbose = false, coral::AccessMode access_mode = coral::Update, const char* tableName = "CALIB_ANAL"); - PixCoralClient(bool verbose = false, coral::AccessMode access_mode = coral::Update, const char* tableName = "CALIB_ANAL"); - ~PixCoralClient(); - - void disconnect(); - - void printTables(const char* option = 0); // added option -- A.X. - void printTableDesc(const std::string& tableName); - void printTableContent(const std::string& tableName); - void createTables(const char* option = 0); // added option -- A.X. - template <typename T> void createTable(); - template <typename T> int fillTable(long long fk, CAN::AnalysisResultList_t *results); - // added -- A.X. - int fillTablePixelCalibData(long long fk, const char* option); - void dropTables(); - void fillTables(CAN::SerialNumber_t id, CAN::AnalysisResultList_t *results); - // fill pcd table -- A.X. - void fillTables(const char* option); - - //PVSS methods - double get_value_from_PVSSarch(const std::string&,const coral::TimeStamp &,const coral::TimeStamp &); - double get_values_from_PVSSarch(const std::string&,const coral::TimeStamp &,const coral::TimeStamp &); - void get_alias_from_PVSSarch(); - - void queryTable(CAN::SerialNumber_t anal_id, const std::string& varname="", const std::string& connName=""); - CAN::AnalysisResultList_t getAnalysisResultsFromDB(CAN::SerialNumber_t anal_id, const std::string& varname="", const std::string& connName=""); - CAN::AnalysisResultList_t getAnalysisResultsFromDB(CAN::SerialNumber_t anal_id, const std::vector<std::string> &connName, const std::string& varname=""); - - /** Get analysis results for a list of connectivity objects. - * @param analysis_id list of analysis serial numbers, - * @param connName list of connectivity names for which the values should be retrieved - * @param listener object which will be notified about new variables. - */ - void getAnalysisResultsFromDB(std::vector<CAN::SerialNumber_t> analysis_id, - const std::vector<std::string> &connName, - IPixResultsDbListener &listener); - - /** Get analysis results for a list of connectivity objects. - * @param analysis_id the analysis serial number, - * @param connName list of connectivity names for which the values should be retrieved - * @param listener object which will be notified about new variables. - */ - void getAnalysisResultsFromDB(CAN::SerialNumber_t analysis_id, const std::vector<std::string> &connName, IPixResultsDbListener &listener) { - std::vector<CAN::SerialNumber_t> temp; - temp.push_back(analysis_id); - getAnalysisResultsFromDB(temp,connName,listener); - } - - // get PCD -- A.X. - void getCalibrationDataFromDB(const char* option); - - void createAuxTables(); - long long updateKey(); - void verboseOutput(bool verbose) {m_verbose = verbose;}; - - /** Get the chip number from the column and row - */ - static int chip(int col, int row) { - int FE = -1; - if ((int)row/160 == 0) FE = (int)col/18; - if ((int)row/160 == 1) FE = 8 + (int)(143-col)/18; - return FE; - } - - static std::string PixelMapToCLOB(const PixelMap_t & pixmap); - static PixelMap_t CLOBtoPixelMap(const std::string & clob); - - - // Convert local time t to GMT (UTC) - std::time_t LocalToGMTTime (std::time_t t) { - std::time_t rawtime = t ? t : time(0); - struct tm result; - tm * ptm; - ptm = gmtime_r(&rawtime, &result); - return mktime(ptm); - } - // Get current time in GMT (UTC) - std::time_t GMTCurrentTime() { return LocalToGMTTime(0); } // Thread unsafe LocalToGMTTime method is used. - // Convert GMT (UTC) time to local time - std::time_t GMTtoLocalTime (std::time_t gmttime) { // Thread unsafe gmtime is used. - struct tm result; - return 2*gmttime - mktime (gmtime_r(&gmttime, &result)); - } -}; - - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/IPixResultsDbListener.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/IPixResultsDbListener.hh deleted file mode 100644 index 8c58c62589b..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/IPixResultsDbListener.hh +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _IPIXRESULTSDBLISTENER_ -#define _IPIXRESULTSDBLISTENER_ - -#include <string> -#include "PixelCoralClientUtils/PixelMap.h" - -namespace CAN { - class AverageResult_t; -} - -class IPixResultsDbListener { - public: - virtual ~IPixResultsDbListener() {} - virtual void newValue(const std::string &var_name, const std::string &conn_name, bool value) = 0; - virtual void newValue(const std::string &var_name, const std::string &conn_name, unsigned int value) = 0; - virtual void newValue(const std::string &var_name, const std::string &conn_name, float value) = 0 ; - virtual void newValue(const std::string &var_name, const std::string &conn_name, const CAN::AverageResult_t &value) = 0 ; - virtual void newValue(const std::string &var_name, const std::string &conn_name, const PixelMap_t &value) = 0 ; -}; - -#endif // _IPIXRESULTSDBLISTENER_ diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDDb.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDDb.h deleted file mode 100644 index 88282cd0e4e..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDDb.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_PCDDB_H -#define PIXELCORALCLIENTUTILS_PCDDB_H - -#include <string> - -namespace PixelCoralClientUtils { - class PixelCalibData; -} - -namespace coral { - class ISessionProxy; - class IQuery; - class ICursor; -} - -class PCDDb -{ - public: - PCDDb(const std::string& connString, - const std::string& tableName, - bool verbose, bool load_text); - ~PCDDb(); - - bool init(const std::string& tag, int revision); - int next(); - bool set(int idmod_cur, PixelCoralClientUtils::PixelCalibData& pcd); - - private: - bool m_verbose; - coral::ISessionProxy *m_session; - std::string m_connString; - std::string m_pixeltable; - - coral::IQuery* m_query; - coral::IQuery* m_query_2; - coral::ICursor* m_cursor; - - void transactionStartReadOnly(); - void transactionStartUpdate(); - void transactionCommit(); -}; - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDio.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDio.h deleted file mode 100644 index ca3bfa03d27..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDio.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_PCDIO_H -#define PIXELCORALCLIENTUTILS_PCDIO_H - -#include "CxxUtils/checker_macros.h" -#include "RelationalAccess/AccessMode.h" - -#include <string> - -namespace coral { - class ISessionProxy; -} - -class PCDio -{ - public: - PCDio(const std::string& connString, - const std::string& tableName, - int verbose); - ~PCDio(); - - void init(coral::AccessMode access_mode); - void load(const std::string& tag, int revision); - void save(const std::string& tag, int revision, const std::string& sources); - - private: - std::string m_connString; - std::string m_pixeltable; - int m_verbose; - coral::ISessionProxy *m_session; - - void createTable(); - void createAuxTables(); - void createHeaderTable(); - void createDataTable(); - long long updateKey(); - - void transactionStartReadOnly(); - void transactionStartUpdate(); - void transactionCommit(); -}; - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDkr.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDkr.h deleted file mode 100644 index 7b72f5cee19..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PCDkr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_PCDKR_H -#define PIXELCORALCLIENTUTILS_PCDKR_H - -#include "RelationalAccess/AccessMode.h" - -#include <string> - -namespace coral { - class ISessionProxy; -} - -class PCDkr -{ - public: - PCDkr(const std::string& connString, - const std::string& tableName, - int verbose); - ~PCDkr(); - - void init(coral::AccessMode access_mode); - void load(); - void save(cosnt std::string& tag, const std::string& cid); - void validate(const std::string& tag); - - private: - std::string m_connString; - std::string m_pixeltable; - int m_verbose; - coral::ISessionProxy *m_session; - - void createTable(); - - void transactionStartReadOnly(); - void transactionStartUpdate(); - void transactionCommit(); -}; - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibCoralCoolDb.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibCoralCoolDb.h deleted file mode 100644 index a94d8339ec6..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibCoralCoolDb.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_PIXCALIBCORALCOOLDB_H -#define PIXELCORALCLIENTUTILS_PIXCALIBCORALCOOLDB_H - -#include "CoraCool/CoraCoolDatabase.h" -#include "CxxUtils/checker_macros.h" - -#include <string> - -class ATLAS_NOT_THREAD_SAFE PixCalibCoralCoolDb // Use of singleton databaseService -{ - public: - PixCalibCoralCoolDb(const std::string& dbString, int verbose); - ~PixCalibCoralCoolDb(); - - bool init(); - bool load(cool::ValidityKey vk); - -/* bool save(cool::ValidityKey vk1, */ -/* cool::ValidityKey vk2); */ - - bool saveCalibData(std::string textfile, long long FK); - bool referenceToRunInterval(long long FK, cool::ValidityKey vk1, cool::ValidityKey vk2, const std::string& tagname ); - - private: - std::string m_dbstring; - - CoraCoolDatabasePtr m_coradb; -}; - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibKnowledgeDb.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibKnowledgeDb.h deleted file mode 100644 index 2d94ce1e405..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixCalibKnowledgeDb.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef PIXELCORALCLIENTUTILS_PIXCALIBKNOWLEDGEDB_H -#define PIXELCORALCLIENTUTILS_PIXCALIBKNOWLEDGEDB_H - -#include "RelationalAccess/AccessMode.h" - -#include <string> - -namespace coral { - class ISessionProxy; -} - -class PixCalibKnowledgeDb -{ - public: - PixCalibKnowledgeDb(const std::string& connString, - const std::string& tableName, - int verbose); - ~PixCalibKnowledgeDb(); - - void init(coral::AccessMode access_mode); - //long long findFK(std::string tag); - - void saveCorrespondingConfig(long int UnixTimeInSeconds, long int RunNumber, const std::string& calibtags_in_string, const std::string& idTag, const std::string& connTag, const std::string& cfgTag, const std::string& cfgModTag ); - - void readCorrespondingCalibTag(long int Utime); - - private: - std::string m_connString; - std::string m_pixeltable; - int m_verbose; - coral::ISessionProxy *m_session; - //std::string findTag(long long fk); - - void createTable(); - void createAuxTables(); - // void createHeaderTable(); - void createConfigurationTable(); - // void createDataTable(); - long long updateKey(); - - void transactionStartReadOnly(); - void transactionStartUpdate(); - void transactionCommit(); -}; - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixResultsException.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixResultsException.hh deleted file mode 100644 index 506523b82bf..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixResultsException.hh +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _CAN_PixResultsException_hh_ -#define _CAN_PixResultsException_hh_ - -#include <exception> -#include <string> - -namespace CAN { - -class PixResultsException : public std::exception { -public: - PixResultsException(const std::string& msg) : m_msg(msg) {} - ~PixResultsException() throw() {} - const char* what() const throw() { return m_msg.c_str(); } - -private: - std::string m_msg; -}; -} // namespace CAN - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelCalibData.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelCalibData.hh deleted file mode 100644 index 7a5fad1ad34..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelCalibData.hh +++ /dev/null @@ -1,400 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelCalibData.hh, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef PIXELCALIBDATA_HH -#define PIXELCALIBDATA_HH - -#include <string> -#include <vector> -#include <iostream> -#include <algorithm> -#include <cmath> - -/** @class PixelCalibData - - The PixelCalibData is a class that designed to hold the calibration data for each module that contains - 16 FE PixelChipSummaryData. The calibration data consist of threshold, timewalk information and Time over - threshold calibration that averages per FE chip. The details can be found at - https://twiki.cern.ch/twiki/bin/view/Atlas/PixelCOOLoffline#Calibrations - . - - @author Weiming Yao <WMYAO@LBL.GOV> -*/ - -namespace PixelCoralClientUtils { - - -class PixelCalibData{ - - public: - /** Constructor:*/ - PixelCalibData(); - PixelCalibData(unsigned int ident,int nmax); - - /** default destructor */ - ~PixelCalibData () = default; - - const static int nPixelChipSummaryDataMax = 16; /** maximum number of chips per module */ - /** embedded class PixelChipSummaryData holds all the calibration data for a chip */ - - class PixelChipSummaryData { - - public: - PixelChipSummaryData(); - ~PixelChipSummaryData() = default; - - /** Methods to access the calibration data */ - int getChipID() const { return (int)m_chip; } //<! get the chip id inside a module from 0 to 15 - int getThreshold(int type) const; //<! get threshold for type=0/1/2 for standard,long and ganged pixels - int getThresholdSigma(int type) const; //<! get threshold sigma - int getNoise(int type) const; //<! get noise - int getTimeWalk(int type) const; //<! get time walk - float getQ2TotA(int type) const; //<! get charge to tot conversion constants A with Tot=A(Q+E)/(Q+C) - float getQ2TotE(int type) const; //<! get constants E - float getQ2TotC(int type) const; //<! get constants C - float getQ2Tot(int type, float Q) const; //<! conver Q to tot - float getTotP1() const; //<! get P1 parameter that parametrized the tot resolution sigma=P1 +p2*tot - float getTotP2() const; //<! get P2 parameter for tot resolution - float getTotRes(float Q) const; //<! get tot resolution for charge Q - - /** Methods to set the calibration data */ - void setChipID(int ichip); //<! set chip id - void setThreshold(int type, int thres, int sigma, int noise, int timewalk); //<! set threshold with inputs as int. - void setThreshold(int type, float thres, float sigma, float noise, float timewalk);//<! set threshold with inputs as float. - void setQ2Tot(int type, float A, float E, float C); //<! set charge to tot conversion constants - void setTotRes(float p1, float p2); //<! set tot resolution dependent constants - - // for packed format db, this has to be public -- A.X. - private: - char m_chip; //<! 0-15 which chip number - char m_threshold[4]; //<! one Word(thres, sigma, Noise,TW): - char m_thresholdlong[4]; //<! one Word(thres, sigma, Noise,TW) for long pixel - char m_thresholdganged[4]; //<! one Word(thres, sigma, Noise,TW) for ganged pixel - float m_q2tot[3]; //<! a,c,e for standard pixel and long - float m_q2totganged[3]; //<! a,b,c for ganged - char m_totres[2]; //<! for (p1, p2) each chip - - // alternative to public chip data -- A.X. - //friend int PixCoralClient::fillTablePixelCalibData(long long fk, const char* option); - //friend void PixCoralClient::getCalibrationDataFromDB(const char* option); - }; - - /** define const iterator defination */ - typedef std::vector<PixelChipSummaryData>::const_iterator PixelChipSummaryData_citer; - int size() const; - PixelChipSummaryData_citer cbegin() const; - PixelChipSummaryData_citer cend() const; - - /** define non-const iterator defination */ - typedef std::vector<PixelChipSummaryData>::iterator PixelChipSummaryData_iter; - PixelChipSummaryData_iter begin(); - PixelChipSummaryData_iter end(); - - /** return pointer to particular module */ - PixelChipSummaryData_citer findChipID(int ichip) const; - PixelChipSummaryData_iter findChipID(int ichip); - - /** return pointer to the identifier */ - unsigned int getModuleID() const; - int getNFEIX() const ; - - /** add a new member to the PixelCalibData */ - void add(const PixelChipSummaryData& idat); - bool update(const PixelChipSummaryData& idat); - void sortv(); - void print() const; - const PixelChipSummaryData* getPixelChipSummaryData(int circ) const; //<! get the pointer to iith PixelChipSummaryData - - protected: - unsigned int m_ident; //<! module identifier - int m_nfeix; // number of FEIX chips per module - std::vector<PixelChipSummaryData> m_vec; //<! data vector contains 0-15 PixelChipSummarydata per module -}; - -//CLASS_DEF(PixelCalibData, 27089939, 1) - -inline int PixelCalibData::PixelChipSummaryData::getThreshold(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==1){ return m_thresholdlong[0]*30+3500;} - else if(type==2){ return m_thresholdganged[0]*30+3500;} - else{ return m_threshold[0]*30+3500;} -} - -inline int PixelCalibData::PixelChipSummaryData::getThresholdSigma(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==1){ return m_thresholdlong[1]*3+300;} - else if(type==2){ return m_thresholdganged[1]*3+300;} - else{ return m_threshold[1]*3+300;} - } - - inline int PixelCalibData::PixelChipSummaryData::getNoise(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==1){ return m_thresholdlong[2]*3+300;} - else if(type==2){ return m_thresholdganged[2]*3+300;} - else{ return m_threshold[2]*3+300;} - } - - inline int PixelCalibData::PixelChipSummaryData::getTimeWalk(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==1){ return m_thresholdlong[3]*30+5000;} - else if(type==2){ return m_thresholdganged[3]*30+5000;} - else{ return m_threshold[3]*30+5000;} - } - - inline float PixelCalibData::PixelChipSummaryData::getQ2TotA(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==2){ return m_q2totganged[0];} - else{ return m_q2tot[0];} - } - - inline float PixelCalibData::PixelChipSummaryData::getQ2TotE(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==2){ return m_q2totganged[1];} - else{ return m_q2tot[1];} - } - - inline float PixelCalibData::PixelChipSummaryData::getQ2TotC(int type) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==2){ return m_q2totganged[2];} - else{ return m_q2tot[2];} - } - - inline float PixelCalibData::PixelChipSummaryData::getQ2Tot(int type, float Q) const{ - // type=0/1/2 for standard, long and ganged pixels - if(type==2){ return m_q2totganged[0]*(Q+m_q2totganged[1])/(Q+m_q2totganged[2]);} - else{ return m_q2tot[0]*(Q+m_q2tot[1])/(Q+m_q2tot[2]);} - } - - inline float PixelCalibData::PixelChipSummaryData::getTotP1() const{ return m_totres[0]* (1/100.); } - - inline float PixelCalibData::PixelChipSummaryData::getTotP2() const{ return m_totres[1]*(1./1000.); } - - inline float PixelCalibData::PixelChipSummaryData::getTotRes(float Q) const{ - float p1 = m_totres[0]*(1/100.0); - float p2 = m_totres[1]*(1/1000.0); - return p1+p2*Q; - } - - //Set Methods - inline void PixelCalibData::PixelChipSummaryData::setChipID(int ichip){ - m_chip = (char)ichip; } - - inline void PixelCalibData::PixelChipSummaryData::setThreshold(int type, float thres, float sigma, float noise, float timewalk){ - using std::abs; - int ax0 = ((int)thres-3500)/30; - if(abs(ax0)>127) ax0 = 127*ax0/abs(ax0); - int ax1 = ((int)sigma-300)/3; - if(abs(ax1)>127) ax1 = 127*ax1/abs(ax1); - int ax2 = ((int)noise-300)/3; - if(abs(ax2)>127) ax2 = 127*ax2/abs(ax2); - int ax3 = ((int)timewalk-5000)/30; - if(abs(ax3)>127) ax3 = 127*ax3/abs(ax3); - - if(type==0) { - m_threshold[0] = (char)ax0; - m_threshold[1] = (char)ax1; - m_threshold[2] = (char)ax2; - m_threshold[3] = (char)ax3; - } - if(type==1){ - m_thresholdlong[0] = (char)ax0; - m_thresholdlong[1] = (char)ax1; - m_thresholdlong[2] = (char)ax2; - m_thresholdlong[3] = (char)ax3; - } - if(type==2){ - m_thresholdganged[0] = (char)ax0; - m_thresholdganged[1] = (char)ax1; - m_thresholdganged[2] = (char)ax2; - m_thresholdganged[3] = (char)ax3; - } - } - - inline void PixelCalibData::PixelChipSummaryData::setThreshold(int type, int thres, int sigma, int noise, int timewalk){ - using std::abs; - int ax0 = (thres-3500)/30; - if(abs(ax0)>127) ax0 = 127*ax0/abs(ax0); - int ax1 = (sigma-300)/3; - if(abs(ax1)>127) ax1 = 127*ax1/abs(ax1); - int ax2 = (noise-300)/3; - if(abs(ax2)>127) ax2 = 127*ax2/abs(ax2); - int ax3 = (timewalk-5000)/30; - if(abs(ax3)>127) ax3 = 127*ax3/abs(ax3); - - if(type==0) { - m_threshold[0] = (char)ax0; - m_threshold[1] = (char)ax1; - m_threshold[2] = (char)ax2; - m_threshold[3] = (char)ax3; - } - if(type==1){ - m_thresholdlong[0] = (char)ax0; - m_thresholdlong[1] = (char)ax1; - m_thresholdlong[2] = (char)ax2; - m_thresholdlong[3] = (char)ax3; - } - if(type==2){ - m_thresholdganged[0] = (char)ax0; - m_thresholdganged[1] = (char)ax1; - m_thresholdganged[2] = (char)ax2; - m_thresholdganged[3] = (char)ax3; - } - } - - - - -inline void PixelCalibData::PixelChipSummaryData::setQ2Tot(int type, float A, float E, float C){ - if(type==0||type==1){ - m_q2tot[0] = A; - m_q2tot[1] = E; - m_q2tot[2] = C; - } - if(type==2){ - m_q2totganged[0] = A; - m_q2totganged[1] = E; - m_q2totganged[2] = C; - } -} - -inline void PixelCalibData::PixelChipSummaryData::setTotRes(float p1, float p2){ - - // careful with rounding -- A.X. - using std::abs; - int p1x = (int)roundf(p1*100); - if (p1x > 127) p1x = 127; - else if (p1x < -127) p1x = -127; - int p2x = (int)roundf(p2*1000); - if (p2x > 127) p2x = 127; - else if (p2x < -127) p2x = -127; - - m_totres[0] = (char)p1x; - m_totres[1] = (char)p2x; -} - - inline bool operator< (const PixelCalibData::PixelChipSummaryData& lhs, - const PixelCalibData::PixelChipSummaryData& rhs){ - - return lhs.getChipID()<rhs.getChipID(); -} - - inline PixelCalibData::PixelCalibData() - : m_ident(-1), m_nfeix(0), m_vec() -{ - m_vec.reserve(PixelCalibData::nPixelChipSummaryDataMax); -} - - inline PixelCalibData::PixelCalibData(unsigned int ident,int nmax ) - : - m_ident(ident), m_nfeix(nmax),m_vec() - { - m_vec.reserve(PixelCalibData::nPixelChipSummaryDataMax); - } - -inline void PixelCalibData::add(const PixelChipSummaryData& idat){ - m_vec.push_back(idat); - } - -inline bool PixelCalibData::update(const PixelChipSummaryData& idat){ - PixelChipSummaryData_iter it = findChipID(idat.getChipID()); - if(it==m_vec.end()) return false; - it->setThreshold(0,idat.getThreshold(0),idat.getThresholdSigma(0),idat.getNoise(0),idat.getTimeWalk(0)); - it->setThreshold(1,idat.getThreshold(1),idat.getThresholdSigma(1),idat.getNoise(1),idat.getTimeWalk(1)); - it->setThreshold(2,idat.getThreshold(2),idat.getThresholdSigma(2),idat.getNoise(2),idat.getTimeWalk(2)); - it->setQ2Tot(0, idat.getQ2TotA(0),idat.getQ2TotE(0),idat.getQ2TotC(0)); - it->setQ2Tot(2, idat.getQ2TotA(2),idat.getQ2TotE(2),idat.getQ2TotC(2)); - it->setTotRes(idat.getTotP1(), idat.getTotP2()); - return true; - } - -inline void PixelCalibData::print() const { - std::cout<< "PixelCalibData::print tagname:"<< m_ident<<" vector size "<<m_vec.size()<<std::endl; - // print out the calibration data for each chip - int i = 0; - for(PixelChipSummaryData_citer cit=cbegin(); cit !=cend(); ++cit){ - std::cout<<" Item: "<< i++<<" ChipId: "<<cit->getChipID() - <<" TotP1: "<<cit->getTotP1()<<" TotP2: "<<cit->getTotP2()<<std::endl - <<" Standard Pixel Threshold: "<<cit->getThreshold(0)<<" sigma: " - <<cit->getThresholdSigma(0)<<" noise:"<<cit->getNoise(0)<<" TimeWalk: " - <<cit->getTimeWalk(0)<<" Q2TotA: "<<cit->getQ2TotA(0)<<" Q2TotE: " - <<cit->getQ2TotE(0)<<" Q2TotC: "<<cit->getQ2TotC(0)<<std::endl - <<" Long Pixel Threshold: "<<cit->getThreshold(1)<<" sigma: " - <<cit->getThresholdSigma(1)<<" noise:"<<cit->getNoise(1)<<" TimeWalk: " - <<cit->getTimeWalk(1)<<" Q2TotA: "<<cit->getQ2TotA(1)<<" Q2TotE: " - <<cit->getQ2TotE(1)<<" Q2TotC: "<<cit->getQ2TotC(1)<<std::endl - <<" Ganged Pixel Threshold: "<<cit->getThreshold(2)<<" sigma: " - <<cit->getThresholdSigma(2)<<" noise:"<<cit->getNoise(2)<<" TimeWalk: " - <<cit->getTimeWalk(2)<<" Q2TotA: "<<cit->getQ2TotA(2)<<" Q2TotE: " - <<cit->getQ2TotE(2)<<" Q2TotC: "<<cit->getQ2TotC(2)<<std::endl; - } - } - -inline PixelCalibData::PixelChipSummaryData::PixelChipSummaryData(){ - // initialised to zero for all members - m_chip=0; - for(int i = 0; i<4; ++i){ - m_threshold[i] = 0; - m_thresholdlong[i] = 0; - m_thresholdganged[i] = 0; - if(i<3){ - m_q2tot[i] = 0.; - m_q2totganged[i] = 0.; - } - if(i<2)m_totres[i] = 0.; - } -} - - -inline int PixelCalibData::size() const - { return (int)m_vec.size();} - -inline PixelCalibData::PixelChipSummaryData_citer PixelCalibData::cbegin() const -{ return m_vec.begin();} - -inline PixelCalibData::PixelChipSummaryData_citer PixelCalibData::cend() const -{ return m_vec.end();} - -inline PixelCalibData::PixelChipSummaryData_iter PixelCalibData::begin() -{ return m_vec.begin();} - -inline PixelCalibData::PixelChipSummaryData_iter PixelCalibData::end() -{ return m_vec.end();} - -inline PixelCalibData::PixelChipSummaryData_citer -PixelCalibData::findChipID(int ichip) const{ - PixelCalibData::PixelChipSummaryData obj; - obj.setChipID(ichip); - PixelCalibData::PixelChipSummaryData_citer rc =std::lower_bound(m_vec.begin(),m_vec.end(),obj); - if(rc !=m_vec.end()&&rc->getChipID()!=ichip) rc = m_vec.end(); - return rc; -} - -inline PixelCalibData::PixelChipSummaryData_iter -PixelCalibData::findChipID(int ichip) { - PixelCalibData::PixelChipSummaryData obj; - obj.setChipID(ichip); - PixelCalibData::PixelChipSummaryData_iter rc =std::lower_bound(m_vec.begin(),m_vec.end(),obj); - if(rc !=m_vec.end()&&rc->getChipID()!=ichip) rc = m_vec.end(); - return rc; -} - -inline unsigned int PixelCalibData::getModuleID() const { return m_ident;} - -inline int PixelCalibData::getNFEIX() const { return m_nfeix;} - -inline void PixelCalibData::sortv(){ - sort(m_vec.begin(), m_vec.end()); } - -inline const PixelCalibData::PixelChipSummaryData* PixelCalibData::getPixelChipSummaryData(int circ) const{ // ith chip - if(circ>=(int)m_vec.size())return 0; - return &m_vec[circ]; -} - - -} -#endif // PIXELCALIBDATA_HH diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelMap.h b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelMap.h deleted file mode 100644 index 4ee5f1ff0b4..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/PixelMap.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _PIXELMAP_hh_ -#define _PIXELMAP_hh_ - -#include <vector> -#include <map> - -/* class Pixel_t */ -/* { */ -/* public: */ -/* Pixel_t(const unsigned int row, const unsigned int column, */ -/* const unsigned int status) */ -/* : m_row(row), m_column(column), m_status(status) */ -/* {} */ -/* const unsigned int row() const { return m_row; } */ -/* const unsigned int column() const { return m_column; } */ -/* const unsigned int status() const { return m_status; } */ -/* private: */ -/* unsigned int m_row; */ -/* unsigned int m_column; */ -/* unsigned int m_status; */ -/* }; */ - -//typedef std::vector< Pixel_t > PixelMap_t; - -typedef std::map< std::pair<int, int>, unsigned int > PixelMap_t; // mapping 2D index (col,row) to status - -#endif diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/SpecialPixelMap.hh b/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/SpecialPixelMap.hh deleted file mode 100644 index b857b789885..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/PixelCoralClientUtils/SpecialPixelMap.hh +++ /dev/null @@ -1,363 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//**************************************************************************** -// SpecialPixelMap.hh -// -// Classes to hold data about special pixels in the detector store and make it -// accessible to athena components. -// -// author Christoph Ruwiedel <ruwiedel@physik.uni-bonn.de> -// - -#ifndef SPECIALPIXELMAP_HH -#define SPECIALPIXELMAP_HH - -#include "CoralBase/Blob.h" -#include "CxxUtils/checker_macros.h" - -#include<map> -#include<vector> -#include<string> -#include<iostream> - -class ModuleSpecialPixelMap; -class SpecialPixelMapSvc; - -namespace PixelCoralClientUtils { - - //static unsigned int columnsPerFEI3 = 18; // number of columns per FEI3 - //static unsigned int rowsPerFEI3 = 164; // number of rows per FEI3 - //static unsigned int FEI3sPerModule = 16; // number of FEI3s in a row - //static unsigned int columnsPerFEI4 = 80; // number of columns per FEI4 - //static unsigned int rowsPerFEI4 = 336; // number of rows per FEI4 - const unsigned int nmtype(5); - static const unsigned int columnsPerFEIX[5]={18,80,132,80,132}; // number of columns per FEI3, 4, 50, 51, 52 - static const unsigned int rowsPerFEIX[5]={164, 336, 672, 339, 678}; // number of rows per FEI3, 4, 50, 51, 52 - static const unsigned int rowsRdoPerFEIX[5]={160, 336, 672, 336, 672}; // number of rows readout per FEI3, 4, 50, 51, 52 - -class ModuleSpecialPixelMap; - -/** A class for a map of special pixels for the whole pixel detector, - or any subgroup of modules. A DetectorSpecialPixelMap is - std::vector of pointers to ModuleSpecialPixelMaps which hold the - actual pixel status codes. A ModuleSpecialPixelMap is accessed by - its IdentifierHash. -*/ - -class DetectorSpecialPixelMap : public std::vector<ModuleSpecialPixelMap*>{ - - public: - DetectorSpecialPixelMap(); - DetectorSpecialPixelMap(const DetectorSpecialPixelMap& dspm); //!< construct a copy - DetectorSpecialPixelMap(const std::vector<ModuleSpecialPixelMap*>& modules); //!< construct from contents - virtual ~DetectorSpecialPixelMap(); - - DetectorSpecialPixelMap& operator=(const DetectorSpecialPixelMap& spm); - DetectorSpecialPixelMap& operator+=(const DetectorSpecialPixelMap& spm); //!< merge two pixel maps into one - void merge(const DetectorSpecialPixelMap* spm); //!< operation equivalent to operator+=, but more convenient for pointers - - const ModuleSpecialPixelMap* module(unsigned int moduleHash) const; //!< const access to a ModuleSpecialPixelMap* - - void markSpecialRegions(); - //!< automatically identify regions of pixels with the same status and mark them - void setNeighbourFlags(); - //!< fill the information about special neighbouring pixels, bits 25 - 28 - - void clear(); - - private: - void erase(iterator); - void erase(iterator, iterator); - -}; - -/** A class for a map of special pixels for a single module of the - pixel detector. A ModuleSpecialPixelMap is a std::map of the - status codes (unsigned integers) for all pixels with special - properties on a module. The possible status codes are explained on - a wiki page: - https://twiki.cern.ch/twiki/bin/view/Atlas/PixelCOOLoffline#Dead_and_special_pixels_map - - The status for a pixel can be retrieved with - pixelStatus(pixelID). The pixel ID can be calculated with - encodePixelID. In addition to pixelStatus, several accessors for - individual status bits are provided. - - NOTE: pixelid = row*128*2 + column*2 + chip for FEI4 - unsigned int hashID = ( ((m_pixelID->barrel_ec(moduleID) + 4) / 2) << 26 ) + - ( m_pixelID->layer_disk(moduleID) << 24) + - ( m_pixelID->phi_module(moduleID) << 18) + - ( (m_pixelID->eta_module(moduleID) + 10) << 13); - - pixelid = row*32*16 + column*16 + chip for FEI3 - - unsigned int hashID = ( ((m_pixelID->barrel_ec(moduleID) + 2) / 2) << 25 ) + - ( m_pixelID->layer_disk(moduleID) << 23) + - ( m_pixelID->phi_module(moduleID) << 17) + - ( (m_pixelID->eta_module(moduleID) + 6) << 13); - -**/ - -class ModuleSpecialPixelMap : private std::map<unsigned int, unsigned int>{ - - public: - friend class ::ModuleSpecialPixelMap; - friend class ::SpecialPixelMapSvc; - - ModuleSpecialPixelMap(); - ModuleSpecialPixelMap(const ModuleSpecialPixelMap& mspm); - //!< construct a copy - ModuleSpecialPixelMap(const char* filename, unsigned int mchips); - //!< construct from text file (for details on the format see the README file in PixelConditionsServices/doc) - ModuleSpecialPixelMap(const std::string& clob, unsigned int mchips); - //!< construct from string - ModuleSpecialPixelMap(const coral::Blob& blob, unsigned int mchips); - //!< construct from blob - ModuleSpecialPixelMap(const std::map<unsigned int, unsigned int>& pixels, - unsigned int module_status, - const std::vector<unsigned int>& chip_status, - const std::vector<std::vector<unsigned int> >& column_pair_status,unsigned int mchips = 16); - //!< construct from contents - virtual ~ModuleSpecialPixelMap(); - - ModuleSpecialPixelMap& operator=(const ModuleSpecialPixelMap& mspm); - ModuleSpecialPixelMap& operator+=(ModuleSpecialPixelMap mspm); - //!< merge two pixel maps into one - - void merge(const ModuleSpecialPixelMap* mspm); //!< operation equivalent to operator+=, but more convenient for pointers - - unsigned int pixelStatus(unsigned int pixelID) const; //!< retrieve pixel status as unsigned int - bool pixelStatusBit(unsigned int pixelID, unsigned int bit) const; //!< retrieve a single status bit - bool pixelUseful(unsigned int pixelID) const; //!< retrieve negation of bit 0 (pixel useful or not) - bool pixelNoisy(unsigned int pixelID) const; //!< retrieve content of bit 15 (pixel noisy or not) - - /** only different from 0 if all pixels on the module have the same status and special regions have been marked */ - unsigned int moduleStatus() const; //!< retrieve module status as unsigned int - /** only different from 0 if all pixels on the chip have the same status and special regions have been marked */ - unsigned int chipStatus(unsigned int chip) const; //!< retrieve chip status as unsigned int - /** only different from 0 if all pixels in the column pair have the same status and special regions have been marked */ - unsigned int columnPairStatus(unsigned int chip, unsigned int column_pair) const; //!< retrieve column pair status as unsigned int - - std::string to_string() const; - //!< convert pixel map to string, used when preparing database write - coral::Blob* to_blob() const; - //!< convert pixel map to blob, used when preparing database write - virtual void print(int component, unsigned int layer, unsigned int phi, int eta, - bool verbosePixelID = true, bool binaryPixelStatus = true) const; - //!< print map to screen - - static unsigned int pixelType(unsigned int column, unsigned int row, unsigned int mchips = 16); - //static unsigned int pixelType(unsigned int column, unsigned int row); - - //!< returns pixel type (normal, long etc.) -- global - static std::vector<unsigned int> decodePixelID(unsigned int pixelID, unsigned int type); - static unsigned int encodePixelID(unsigned int chip, unsigned int column, unsigned int row, unsigned int mchips); - static unsigned int encodePixelID(unsigned int chip, unsigned int column, unsigned int row); - - //!< returns pixel ID to be used in accessors - static unsigned int encodePixelID(int component, unsigned int module_phi_index, - unsigned int pixel_eta_index, unsigned int pixel_phi_index, unsigned int mchips); - // static unsigned int encodePixelID(int component, unsigned int module_phi_index, - // unsigned int pixel_eta_index, unsigned int pixel_phi_index); - - //!< returns pixel ID to be used in accessors - - void setPixelStatus(unsigned int pixelID, unsigned int status); - void setPixelStatusBit(unsigned int pixelID, unsigned int bit); - void clearPixelStatusBit(unsigned int pixelID, unsigned int bit); - void setPixelNotUseful(unsigned int pixelID); //!< set pixel status bit 0 - void setPixelUseful(unsigned int pixelID); //!< clear pixel status bit 0 - void setPixelNoisy(unsigned int pixelID); //!< set pixel status bit 15 - void setPixelNotNoisy(unsigned int pixelID); //!< clear pixel status bit 15 - - void setModuleStatus(unsigned int status); - //!< set module status, clears single pixel information if argument != 0 - void setChipStatus(unsigned int chip, unsigned int status); - //!< set chip status, clears single pixel information if argument != 0 - void setColumnPairStatus(unsigned int chip, unsigned int column_pair, unsigned int status); - //!< set column pair status, clears single pixel information if argument != 0 - - bool fill_from_string(const std::string& clob); - //!< fills the map from a string, used for conversion of data from the database - bool fill_from_blob(const coral::Blob& blob); - //!< fills the map from a blob, used for conversion of data from the database - - bool validPixelID(unsigned int chip, unsigned int column, unsigned int row) const; - //!< checks whether the pixel ID is in the allowed range - bool validPixelID(unsigned int pixel_eta_index, unsigned int pixel_phi_index) const; - //!< checks whether the pixel ID is in the allowed range - bool validPixelID(unsigned int pixelID) const; - //!< checks whether the pixel ID is in the allowed range - - void markSpecialRegions(); - //!< automatically identify regions of pixels with the same status and mark them - void setNeighbourFlags(); - //!< fill the information about special neighbouring pixels, bits 25 - 28 - - typedef std::map<unsigned int, unsigned int>::iterator iterator; - //!< std::map iterators are forwarded for access to all special pixels on a module - //!< These iterate *only* over the special pixels that are *not* in a special region, one has to check special regions independently - typedef std::map<unsigned int, unsigned int>::const_iterator const_iterator; - //!< std::map iterators are forwarded for access to all special pixels on a module - //!< These iterate *only* over the special pixels that are *not* in a special region, one has to check special regions independently - - typedef std::map<unsigned int, unsigned int>::size_type size_type; - - size_type size() const; - //!< only for special pixels that are not in a special region - bool empty() const; - //!< only for special pixels that are not in a special region - - iterator begin(); - //!< only for special pixels that are not in a special region, need to check special regions separately - const_iterator begin() const; - //!< only for special pixels that are not in a special region, need to check special regions separately - - iterator end(); - //!< only for special pixels that are not in a special region, need to check special regions separately - const_iterator end() const; - //!< only for special pixels that are not in a special region, need to check special regions separately - - unsigned int chipsPerModule() const; - unsigned int chipType() const; - - void setchipsPerModule(unsigned int chipsPerModule); - unsigned int columnsPerChip() const; - unsigned int rowsPerChip() const; - unsigned int rowsrdoPerChip() const; - - - bool hasSpecialChips() const; - //!< true if there are any special frontends on the module - bool hasSpecialColumnPairs() const; - //!< true if there are any special column pairs on the module - bool hasSpecialColumnPairs(unsigned int chip) const; - //!< true if there are any special column pairs on frontend 'chip' - - private: - unsigned int m_chipsPerModule; // decoded the number of chips*10 + chip type(0=FEI3, 1=FEI4, 2=FEI50, 3=FEI51, 4=FEI52) - unsigned int m_module_status; - std::vector<unsigned int> m_chip_status; - std::vector<std::vector<unsigned int> > m_column_pair_status; - - void resetSpecialRegions(); - void condResetSpecialRegions(unsigned int pixelID, unsigned status); - -}; - - - -// inline functions - -inline bool ModuleSpecialPixelMap::pixelUseful(unsigned int pixelID) const{ - return !pixelStatusBit(pixelID, 0); -} - -inline bool ModuleSpecialPixelMap::pixelNoisy(unsigned int pixelID) const{ - return pixelStatusBit(pixelID, 15); -} - -inline unsigned int ModuleSpecialPixelMap::moduleStatus() const{ - return m_module_status; -} - -inline unsigned int ModuleSpecialPixelMap::chipStatus(unsigned int chip) const{ - if(chip < m_chipsPerModule/10){ - if(m_chip_status.size() != 0){ - return m_chip_status[chip]; - } - else{ - return 0; - } - } - else{ - std::cout << "In ModuleSpecialPixelMap::chipStatus(unsigned int): Chip number "<<chip<< " > "<<m_chipsPerModule<< " requested " << std::endl; - return 0; - } -} - -inline unsigned int ModuleSpecialPixelMap::columnPairStatus(unsigned int chip, unsigned int column_pair) const{ - unsigned int itype = std::min(m_chipsPerModule%10,nmtype-1); - if(chip < (m_chipsPerModule/10) && column_pair < (columnsPerFEIX[itype]/2)){ - if(m_column_pair_status.size() != 0 && m_column_pair_status[chip].size() != 0){ - return m_column_pair_status[chip][column_pair]; - } - else{ - return 0; - } - } - else{ - std::cout << "Invalid chip/column pair combination requested" << std::endl; - return 0; - } -} - -inline void ModuleSpecialPixelMap::setPixelNotUseful(unsigned int pixelID){ - setPixelStatusBit(pixelID, 0); - return; -} - -inline void ModuleSpecialPixelMap::setPixelUseful(unsigned int pixelID){ - clearPixelStatusBit(pixelID, 0); - return; -} - -inline void ModuleSpecialPixelMap::setPixelNoisy(unsigned int pixelID){ - setPixelStatusBit(pixelID, 15); - return; -} - -inline void ModuleSpecialPixelMap::setPixelNotNoisy(unsigned int pixelID){ - clearPixelStatusBit(pixelID, 15); - return; -} - -inline bool ModuleSpecialPixelMap::validPixelID(unsigned int pixelID) const{ - int i = m_chipsPerModule%10; - return i==0 ? validPixelID(pixelID % 16, (pixelID & (31 << 4))/16, pixelID/512): validPixelID(pixelID % 16, (pixelID & (255 << 4))/16, pixelID/4096); -} - -inline bool ModuleSpecialPixelMap::validPixelID(unsigned int chip, unsigned int column, unsigned int row) const{ - unsigned int itype = std::min(m_chipsPerModule%10,nmtype-1); - return (chip<(m_chipsPerModule/10)&&column<columnsPerFEIX[itype]&&row<rowsPerFEIX[itype]) ? true : false; -} - -inline bool ModuleSpecialPixelMap::validPixelID(unsigned int pixel_eta_index, unsigned int pixel_phi_index) const{ - unsigned int i = std::min(m_chipsPerModule%10,nmtype-1); - int m = m_chipsPerModule/10; - unsigned int rowsMax = m>2 ? 2*rowsPerFEIX[i] : rowsPerFEIX[i]; - unsigned int columnsMax = m>2 ? m/2*columnsPerFEIX[i] : m*columnsPerFEIX[i]; - return (pixel_eta_index<columnsMax&&pixel_phi_index<rowsMax)?true:false; -} - -inline unsigned int ModuleSpecialPixelMap::chipsPerModule() const{ - return m_chipsPerModule/10; -} - -inline unsigned int ModuleSpecialPixelMap::chipType() const{ - return m_chipsPerModule%10; -} - -inline void ModuleSpecialPixelMap::setchipsPerModule(unsigned int chipsPerModule){ - m_chipsPerModule = chipsPerModule; -} - -inline unsigned int ModuleSpecialPixelMap::columnsPerChip() const{ - unsigned int itype = std::min(m_chipsPerModule%10,nmtype-1); - return columnsPerFEIX[itype]; -} - -inline unsigned int ModuleSpecialPixelMap::rowsPerChip() const{ - unsigned int itype = std::min(m_chipsPerModule%10,nmtype-1); - return rowsPerFEIX[itype]; -} - -inline unsigned int ModuleSpecialPixelMap::rowsrdoPerChip() const{ - unsigned int itype = std::min(m_chipsPerModule%10,nmtype-1); - return rowsRdoPerFEIX[itype]; -} - -} // namespace PixelCoralClientUtils -#endif // SPECIALPIXELMAP_HH diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/pcd.sh b/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/pcd.sh deleted file mode 100755 index cae295a9a6b..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/pcd.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/bash -# -# PCDio wrapper -# - -err () { - echo '*' commands: - echo - echo $0 init tag[:rev] [filename] - echo '*' create a new calibration tag=tag, revision=rev, origin=file:filename from the text file filename. By default rev=1, filename=pcd.dat . - echo - echo $0 copy tag[:rev] oldtag[:oldrev] - echo '*' create a new calibration tag=tag, revision=rev, origin=\"oldtag:oldrev\" from existing calibration tag=oldtag, revision=oldrev. By default rev=1, oldrev=largest available revision for tag oldtag. - echo - echo $0 update tag[:rev] analid [opt] - echo '*' take the calibration tag=tag, revision=rev, apply analisys analid, and create a new calibration tag=tag, revision=largest available revision + 1, origin=\"tag:rev:analid\". By default rev=largest available revision. opt=option accepted by extractAnalysis. - echo - #echo $0 list [tag] - #echo '*' list calibrations which exist for tag tag. By default, list all existing calibrations. - #echo - echo $0 dump tag[:rev] [filename] - echo '*' dump calibration tag=tag, revision=rev to the text file filename. By default rev=largest available revision, filename=pcd.dat . - exit 1 -} - -# -# tag:rev parser -# - -parse_tagrev () { - have_rev=yes - tag=${tagrev%:*} - rev=${tagrev#*:} - if [[ $tag == $tagrev ]]; then - have_rev=no - rev=1 - fi -} - -# -# main switch -# - -if [[ $# -lt 1 ]]; then - err -fi - -case $1 in -init) - if [[ $# -lt 2 ]]; then - err - fi - - filename= - if [[ $# -ge 3 ]]; then - filename=$3 - if [[ -e $filename ]]; then - cp $filename pcd.dat - else - echo file $filename does not exist - exit 1 - fi - fi - - tagrev=$2 - parse_tagrev - - echo talkToPCDDb -s $tag $rev file:$filename - talkToPCDDb -s $tag $rev file:$filename - ;; - -copy) - if [[ $# -lt 3 ]]; then - err - fi - - tagrev=$2 - parse_tagrev - newtag=$tag - newrev=$rev - - tagrev=$3 - parse_tagrev - - if [[ $have_rev == yes ]]; then - talkToPCDDb -r $tag $rev - else - talkToPCDDb -r $tag - rev=`cat pcd.rev` - fi - mv pcd.sav pcd.dat - echo talkToPCDDb -s $newtag $newrev $tag:$rev - talkToPCDDb -s $newtag $newrev $tag:$rev - ;; - -update) - if [[ $# -lt 3 ]]; then - err - fi - - tagrev=$2 - parse_tagrev - talkToPCDDb -r $tag - newrev=`cat pcd.rev` - if [[ $have_rev == yes ]]; then - talkToPCDDb -r $tag $rev - fi - newrev=$[$newrev + 1] - mv pcd.sav pcd.dat - - analid=$3 - opt= - if [[ $# -ge 4 ]]; then - opt=$4 - fi - - temp=$CAN_CALIB_DB - export CAN_CALIB_DB=oracle://ATLAS_COOLPROD/ATLAS_COOLONL_PIXEL - echo extractAnalysis $opt $analid - extractAnalysis $opt $analid - export CAN_CALIB_DB=$temp - mv pcd.sav pcd.dat - echo talkToPCDDb -s $tag $newrev $tag:$rev:$analid - talkToPCDDb -s $tag $newrev $tag:$rev:$analid - ;; - -list) - ;; - -dump) - if [[ $# -lt 2 ]]; then - err - fi - - tagrev=$2 - parse_tagrev - if [[ $have_rev == yes ]]; then - talkToPCDDb -r $tag $rev - else - talkToPCDDb -r $tag - fi - mv pcd.sav pcd.dat - - if [[ $# -ge 3 ]]; then - filename=$3 - cp pcd.dat $filename - fi - ;; - -*) - echo pcd: unrecognized command $1 - err - -esac - -exit 0 diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/probe_fill.src b/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/probe_fill.src deleted file mode 100644 index 8719dab0c79..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/probe_fill.src +++ /dev/null @@ -1,8 +0,0 @@ -rm -rf testdb.sql -export CAN_CALIB_DB="sqlite_file:testdb.sql" -CORAL-fill 1 "tag:mytag revision:1234 sources:Offline:0 file:pixelcalibsvc_dump.txt" -CORAL-fill 1 "tag:mytag1 revision:5678 sources:Offline:0 file:pixelcalibsvc_dump_assembly_02.txt" -echo "========= reading first calibration =========" -CORAL-read 1 "tag:mytag revision:1234" -echo "========= reading second calibration =========" -CORAL-read 1 "tag:mytag1 revision:5678" diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDDb_example.sh b/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDDb_example.sh deleted file mode 100755 index 56a637c51b6..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDDb_example.sh +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -#!/bin/sh -############################################################################### - -rm -f testdb.sql - -export CAN_CALIB_DB="sqlite_file:testdb.sql" -#export CAN_CALIB_DB=oracle://devdb10/atlas_pixel_khanov - -./pcd.sh init mytag pixelcalibsvc_dump_assembly_02.txt -./pcd.sh update mytag 5620 -t -./pcd.sh copy mytag1 mytag diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDkr_example.sh b/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDkr_example.sh deleted file mode 100755 index 0c53d5d732e..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/cmt/talkToPCDkr_example.sh +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -#!/bin/sh -############################################################################### - -rm -f testdb.sql - -export CAN_CALIB_DB="sqlite_file:testdb.sql" -#export CAN_CALIB_DB=oracle://devdb10/atlas_pixel_khanov - -talkToPCDkr -s hello/world mytag -talkToPCDkr -s hello/again mytag1 -talkToPCDkr -s hello/oncemore mytag2 -talkToPCDkr -r -talkToPCDkr -v hello/again -talkToPCDkr -r diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/example/calibDbInterface_example.sh b/InnerDetector/InDetConditions/PixelCoralClientUtils/example/calibDbInterface_example.sh deleted file mode 100755 index ba29a85ee30..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/example/calibDbInterface_example.sh +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -#!/bin/sh -############################################################################### - -export PATH=$PATH:$PWD/../i686-slc5-gcc43-opt/calibDbInterface.exe - -export PIXEL_CAL_KNOWLEDGE="oracle://INTR/ATLAS_MLIMPER" -#export PIXEL_CAL_KNOWLEDGE="oracle://DEVDB10/ATLAS_COOL_MLIMPER" -#export PIXEL_CAL_KNOWLEDGE="sqlite_file:/detpriv/pix/data/PixCalibDataOffline/pcd_knowledge.db" - -#store the latest updated calibration strings -calibDbInterface.exe -s PixCalib-BLKP-UPD4-000-01 string2 string3 diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-create.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-create.cc deleted file mode 100644 index 8648d4f79c9..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-create.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" - -int main (int argc, char **argv){ -//printf("COOL-create starting \n"); - - - // -------------------------------------------------- - // Main part - // -------------------------------------------------- - - try { - - // Start CORAL client - printf("CORAL-create starting \n"); -// PixCoralClient coralClient(coralConnStr,app.context()); - const char* tableName = argc>1 ? "CALIB_DATA" : "CALIB_ANAL"; - PixCoralClient coralClient(true, coral::Update, tableName); - - //coralClient.dropTables(); - if (argc>1) { - coralClient.createTables(argv[1]); - } else { - coralClient.createTables(); - } - // coralClient.fillCoralTables(); - std::cout << "DONE" << std::endl; - } - - // COOL, CORAL POOL exceptions inherit from std exceptions: catching - // std::exception will catch all errors from COOL, CORAL and POOL - - catch ( std::exception& e ) { - std::cout << "std::exception caught: " << e.what() << std::endl; - return -1; - } - - catch (...) { - std::cout << "Unknown exception caught!" << std::endl; - return -1; - } - - return 0; - -} - - - - diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-fill.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-fill.cc deleted file mode 100644 index 9d232774da8..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-fill.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" - -int main (int argc, char **argv){ - //printf("CORAL-fill starting \n"); - - CAN::SerialNumber_t anal_id = 123456789; - if (argc > 1) anal_id = atoi(argv[1]); - - - // -------------------------------------------------- - // Main part - // -------------------------------------------------- - - try { - - // Start CORAL client - printf("CORAL-fill starting \n"); -// PixCoralClient coralClient(coralConnStr,app.context()); - const char* tableName = argc>2 ? "CALIB_DATA" : "CALIB_ANAL"; - PixCoralClient coralClient(true, coral::Update, tableName); - - if (argc>2) { - coralClient.fillTables(argv[2]); - } else { - CAN::AnalysisResultList_t results; - results.addValue("a_value","ROD_test",false); - results.addValue("Status","Some module",true); - results.addValue("Status","Other module",false); - results.addValue<float>("aFloat","Other module",111); - results.addValue<unsigned int>("Myint","New module",43); - CAN::AverageResult_t avRes(3,13.4,2.3,2,50.2); - results.addValue("FirstAv","AV module",avRes); - - PixelMap_t pixelmap; - pixelmap[std::make_pair(2,3)]=4; //CLA - pixelmap[std::make_pair(3,3)]=4; - pixelmap[std::make_pair(3,23)]=4; -// special column pairs -// for (int i=0; i<160; ++i) { -// pixelmap.push_back(CAN::Pixel_t(i,0,3)); -// pixelmap.push_back(CAN::Pixel_t(i,1,3)); -// pixelmap.push_back(CAN::Pixel_t(i,24,5)); -// pixelmap.push_back(CAN::Pixel_t(i,25,5)); -// } -// special chip -// for (int i=160; i<320; ++i) { -// for (int j=36; j<54; ++j) { -// pixelmap.push_back(CAN::Pixel_t(i,j,6)); -// } -// } -// special module -// for (int i=0; i<320; ++i) { -// for (int j=0; j<144; ++j) { -// pixelmap.push_back(CAN::Pixel_t(i,j,7)); -// } -// } - results.addValue("Map","this module",pixelmap); - coralClient.fillTables(anal_id, &results); - } - - } - - // COOL, CORAL POOL exceptions inherit from std exceptions: catching - // std::exception will catch all errors from COOL, CORAL and POOL - catch ( std::exception& e ) { - std::cout << "std::exception caught: " << e.what() << std::endl; - return -1; - } - - catch (...) { - std::cout << "Unknown exception caught!" << std::endl; - return -1; - } - - return 0; - -} - - - - diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-listVariables.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-listVariables.cc deleted file mode 100644 index c6299af2182..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-listVariables.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" -#include <string> -#include <vector> -#include <cstring> - - - class DummyCoralClientListener : public IPixResultsDbListener { - public: - - protected: - void newValue(const std::string &var_name, const std::string &conn_name, bool value) { - std::cout << "INFO [DummyCoralClientListener::newValue<bool>] var_name = " << var_name << ", conn_name = " << conn_name - << " value = " << (value ? "true" : "false") << std::endl; - } - void newValue(const std::string &var_name, const std::string &conn_name, unsigned int value) { - std::cout << "INFO [DummyCoralClientListener::newValue<unsigned int>] var_name = " << var_name << ", conn_name = " << conn_name - << " value = " << value << std::endl; - } - void newValue(const std::string &var_name, const std::string &conn_name, float value) { - std::cout << "INFO [DummyCoralClientListener::newValue<float>] var_name = " << var_name << ", conn_name = " << conn_name - << " value = " << value << std::endl; - } - void newValue(const std::string &var_name, const std::string &conn_name, const CAN::AverageResult_t &value) { - std::cout << "INFO [DummyCoralClientListener::newValue<AverageResult_t>] var_name = " << var_name << ", conn_name = " << conn_name - << " value = " << value.value(CAN::AverageResult_t::kLower99) - << " < " << value.value(CAN::AverageResult_t::kMean) << " +- " << value.value(CAN::AverageResult_t::kRMS) - << " < " << value.value(CAN::AverageResult_t::kUpper99) - << std::endl; - } - void newValue(const std::string &var_name, const std::string &conn_name, const PixelMap_t & value) { - std::cout << "INFO [DummyCoralClientListener::newValue<PixelMap_t>] var_name = " << var_name << ", conn_name = " << conn_name<< std::endl; - std::cout<< " row/column status"<< std::endl; - for (PixelMap_t::const_iterator it=value.begin(); it != value.end(); ++it) - std::cout<<" "<<(*it).first.second<<"/"<<(*it).first.first<<" "<<(*it).second<< std::endl;//CLA - } - }; - - -int main (int argc, char **argv){ - - CAN::SerialNumber_t analysis_id = 0; - std::vector<std::string> connectivity_name; - bool error=false; - - for (int arg_i=1; arg_i<argc; arg_i++) { - if (strcmp(argv[arg_i],"-s")==0 && arg_i+1<argc && argv[arg_i+1][0]!='-') { - analysis_id = atoi(argv[++arg_i]); - } - else if (strcmp(argv[arg_i],"-c")==0 && arg_i+1<argc && argv[arg_i+1][0]!='-') { - arg_i++; - do { - - connectivity_name.push_back( argv[arg_i] ); - - } while ( ++arg_i<argc && argv[arg_i][0]!='-' ); - - } - else { - std::cout << "ERROR [" << argv[0] << ":main] unsupported argument : " << argv[arg_i] << "." << std::endl; - error=true; - break; - } - } - if (analysis_id<=0 || error) { - std::cout << "USAGE " << argv[0] << " -s analysis-serial-number [-c connectivity-name ... ]" << std::endl; - return -1; - } - - - // -------------------------------------------------- - // Main part - // -------------------------------------------------- - - try { - - PixCoralClient coralClient(true); - DummyCoralClientListener listener; - - coralClient.getAnalysisResultsFromDB(analysis_id,connectivity_name, listener); - - } catch ( std::exception& e ) { - std::cout << "std::exception caught: " << e.what() << std::endl; - return -1; - } - - catch (...) { - std::cout << "Unknown exception caught!" << std::endl; - return -1; - } - - return 0; - -} - - - - diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-read.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-read.cc deleted file mode 100644 index 20e95f217f9..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CORAL-read.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" - -int main (int argc, char **argv){ - //printf("CORAL-create starting \n"); - - CAN::SerialNumber_t anal_id = 123456789; - if (argc > 1) anal_id = atoi(argv[1]); - - - // -------------------------------------------------- - // Main part - // -------------------------------------------------- - - try { - - // Start CORAL client - printf("CORAL-read starting \n"); -// PixCoralClient coralClient(coralConnStr,app.context()); - const char* tableName = argc>2 ? "CALIB_DATA" : "CALIB_ANAL"; - PixCoralClient coralClient(true, coral::ReadOnly, tableName); - - if (argc>2) { - - // ------------------------------------------------ - // read PCD table -- A.X. - // ------------------------------------------------ - - // Show the structure of the master table - try { - coralClient.printTableDesc("CALIB_DATA"); - coralClient.printTableContent("CALIB_DATA"); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - // Get all results for given tag/revision - try { - coralClient.getCalibrationDataFromDB(argv[2]); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - } else { - - // ------------------------------------------------ - // old functionality -- A.X. - // ------------------------------------------------ - - // Show the structure of the master table - try { - coralClient.printTableDesc("CALIB_ANAL"); - coralClient.printTableContent("CALIB_ANAL"); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - // Get all results for analysis anal_id - try { - // Print content on the screen -// coralClient.queryTable(anal_id); - // Return a CAN::AnalysisResultList_t object - coralClient.getAnalysisResultsFromDB(anal_id); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - // Get results for variable FirstAv and analysis anal_id - try { - // Print content on the screen -// coralClient.queryTable(anal_id,"FirstAv"); - // Return a CAN::AnalysisResultList_t object - coralClient.getAnalysisResultsFromDB(anal_id,"FirstAv"); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - // Get results for module L0_B08_S1_A6_M6A, variable Status - // and analysis anal_id - try { - // Print content on the screen -// coralClient.queryTable(anal_id,"Status","L0_B08_S1_A6_M6A"); - // Return a CAN::AnalysisResultList_t object - coralClient.getAnalysisResultsFromDB(anal_id,"Status","L0_B08_S1_A6_M6A"); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - // Get results for vector of modules, variable ASpecialPixelMap - // and analysis anal_id - try { - // Return a CAN::AnalysisResultList_t object - std::vector<std::string> mods; - mods.push_back("L2_B25_S2_C6_M4C"); - mods.push_back("L2_B25_S1_C7_M2C"); - coralClient.getAnalysisResultsFromDB(anal_id,mods,"ASpecialPixelMap"); - } catch (coral::TableNotExistingException& err) { - std::cout<<"TableNotExistingException: "<<err.what()<<std::endl; - } - - } // endif -- A.X. - - // COOL, CORAL POOL exceptions inherit from std exceptions: catching - // std::exception will catch all errors from COOL, CORAL and POOL - } catch ( std::exception& e ) { - std::cout << "std::exception caught: " << e.what() << std::endl; - return -1; - } - - catch (...) { - std::cout << "Unknown exception caught!" << std::endl; - return -1; - } - - return 0; - -} - - - - diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CoralClient.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CoralClient.cc deleted file mode 100644 index 3d8d54d390e..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/CoralClient.cc +++ /dev/null @@ -1,2224 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -////////////////////////////////////////////////// -/// -/** @file Coralclient.cpp - -C++ class for creating the calibration DB schema, -fill the DB, read it back - -*/ -/////////////////////////////////////////////////// - -#include "PixelCoralClientUtils/CoralClient.hh" -#include "PixelCoralClientUtils/SpecialPixelMap.hh" -#include "PixelCoralClientUtils/PixelCalibData.hh" - -#include <assert.h> -#include <cstring> -#include <string> - -// definition of table types -enum ETableTypeId {kBoolType, kUIntType, kFloatType, kAvresType, kPixelMapType, kCalibData, kNTableTypes}; -const std::string s_tableTypeName[kNTableTypes]={"BOOL","UINT","FLOAT","AVRES","SPECIALPIXELS","CALIBDATA"}; - -/** Returns the string used to identify a particular type - */ -template <typename T> -ETableTypeId variableType(); - - -template <> ETableTypeId variableType<float>() { - return kFloatType; -} - -template <> ETableTypeId variableType<bool>() { - return kBoolType; -} - -template <> ETableTypeId variableType<unsigned int>() { - return kUIntType; -} - -template <> ETableTypeId variableType<CAN::AverageResult_t>() { - return kAvresType; -} - -template <> ETableTypeId variableType<PixelMap_t>() { - return kPixelMapType; -} - -template <> ETableTypeId variableType<PixelCoralClientUtils::PixelCalibData>() { - return kCalibData; -} - -template <class T> inline std::string tableTypeName() { - return s_tableTypeName[ variableType<T>() ]; -} - -/** Create the RCDConnectionService - */ -coral::IHandle<coral::IConnectionService> PixCoralClient::connectionService(bool verbose) -{ - if(verbose) std::cout << "Creating Connection Service"<<std::endl; - - // Instantiate connection service - coral::Context* context = &coral::Context::instance(); - - // Load CORAL connection service - coral::IHandle<coral::IConnectionService> lookSvcH = context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - context->loadComponent( "CORAL/Services/ConnectionService" ); - lookSvcH = context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw std::runtime_error( "Could not locate the connection service" ); - } - return lookSvcH; -} - - -std::string connectionString(const std::string &connection_string_in) { - if (connection_string_in.empty()) { - char * ctmp = getenv("CAN_CALIB_DB"); - if (ctmp != NULL) { - return ctmp; - } - } - return connection_string_in; -} - - -//--------------------------------------------------------------------------- -/** Constructor. - Open a database identified by the connection string. -*/ -PixCoralClient::PixCoralClient(const std::string& id1, - bool verbose, coral::AccessMode access_mode, const char* tableName) - : m_connString(connectionString(id1)), - m_accessMode(access_mode), - m_connectionService(connectionService(verbose)), - m_session(0), - m_pixeltable(tableName), - m_verbose(verbose) -{ -} - - -//--------------------------------------------------------------------------- -/** Constructor. - Open the default database and seal context. -*/ -PixCoralClient::PixCoralClient(bool verbose, coral::AccessMode access_mode, const char* tableName) - : m_connString(connectionString("")), - m_accessMode(access_mode), - m_connectionService(connectionService(verbose)), - m_session(0), - m_pixeltable(tableName), - m_verbose(verbose) -{ -} - - -void PixCoralClient::disconnect() { - if (m_verbose) { - std::cout << "INFO [PixCoralClient::disconnect] disconnect from " << m_connString << "." << std::endl; - } - delete m_session; - m_session=NULL; -} - -void PixCoralClient::connect() { - if (!m_session) { - if (m_verbose) { - std::cout << "INFO [PixCoralClient::connect] Try to connect to " << m_connString << "." << std::endl; - } - m_session = m_connectionService->connect( m_connString, m_accessMode ); - } -} - - -//--------------------------------------------------------------------------- -/** Destructor. - Close the connection -*/ -PixCoralClient::~PixCoralClient() { - disconnect(); - try { - m_connectionService->purgeConnectionPool(); - } - catch (coral::Exception & ex) { - std::cout << "INFO [PixCoralClient::~PixCoralClien] Exception caught in purging connection pool. " <<std::endl; - std::cout << ex.what() <<std::endl; - } -} - - - - -//--------------------------------------------------------------------------- -/** Get the list of tables on the database and print it on stdout. - */ -void PixCoralClient::printTables(const char* /* option */) -{ - if (m_verbose) std::cout << "\nCOOLCORAL Client: list of tables" << std::endl; - - transactionStartReadOnly(); - - std::set<std::string> tables = m_session->nominalSchema().listTables(); - transactionCommit(); - for ( std::set<std::string>::iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - std::cout << "\t" << *tName << std::endl; - } -} - - - - -//-------------------------------------------------------------------------- -/** Get the description of a table identified by an input string on the database and print it on stdout. - */ -void PixCoralClient::printTableDesc(const std::string& tableName) -{ - if (m_verbose) std::cout << "\nCOOLCORAL Client: " << tableName <<" Table description" << std::endl; - - transactionStartReadOnly(); - - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(tableName).description(); - std::string Name = tableDesc.name(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<std::string> colName; colName.resize(NumCol); - std::vector<std::string> colType; colType.resize(NumCol); - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - } - - transactionCommit(); - - std::cout << "\nName : "<< Name << std::endl; - //std::cout << "\nType :"<< Type << std::endl; - printf(" Num of cols : %d",NumCol); - std::cout << "\n Columns :"<< std::endl; - for(int i=0; i<NumCol; ++i) - std::cout <<" "<< colName[i] <<" ("<< colType[i]<<")"<< std::endl; -} - - - - -//--------------------------------------------------------------------------- -/** Get the content of a table identified by an input string on the - database and print its number of lines. - */ -void PixCoralClient::printTableContent(const std::string& tableName){ - if (m_verbose) std::cout << "\nCOOLCORAL Client: " << tableName - <<" Table content"<< std::endl; - - transactionStartReadOnly(); - - coral::IQuery* query = m_session->nominalSchema().tableHandle(tableName).newQuery(); - coral::ICursor& cursor = query->execute(); - int nRows = 0; - while ( cursor.next() ) { - ++nRows; - } - delete query; - - transactionCommit(); - - printf("Total %d records\n", nRows); -} - - - - - -//--------------------------------------------------------------------------- -/** Create CORAL tables - */ -void PixCoralClient::createTables(const char* option) -{ - if (m_verbose) { - std::cout << "\nCOOLCORAL Client: Create tables"; - if (option) std::cout << " with option " << option; - std::cout << std::endl; - } - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - createAuxTables(); - - transactionStartUpdate(); - - // std::cout << " Deleting the old table: " << m_pixeltable << std::endl; - // m_session->nominalSchema().dropIfExistsTable(m_pixeltable); - - if (!m_session->nominalSchema().existsTable(m_pixeltable)) { - if (m_verbose) std::cout << " Creating table: " << m_pixeltable << std::endl; - coral::TableDescription pixel_columns( "SchemaDefinition_PIXEL" ); - pixel_columns.setName( m_pixeltable ); - // modified -- A.X. - if (option==0) { - pixel_columns.insertColumn( "ANAL_ID", - coral::AttributeSpecification::typeNameForType<CAN::SerialNumber_t>()); - } else { - pixel_columns.insertColumn("TAG", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - pixel_columns.insertColumn("REVISION", coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("SOURCES", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - } - pixel_columns.insertColumn( "DATE", - coral::AttributeSpecification::typeNameForType<time_t>()); - pixel_columns.insertColumn( "FK", - coral::AttributeSpecification::typeNameForType<long long>()); - - // modified -- A.X. - if (option==0) { - pixel_columns.createIndex("ANAL_ID_IDX", "ANAL_ID"); - pixel_columns.setNotNullConstraint ("ANAL_ID"); - } - pixel_columns.setUniqueConstraint("FK","FK_UNIQ"); - - // Create the actual table - try { - m_session->nominalSchema().createTable( pixel_columns ); - } catch (coral::TableAlreadyExistingException & ex) { - //Must have been created in parallel - } - } - - transactionCommit(); - - // modified -- A.X. - if (option==0) { - createTable<bool>(); - createTable<unsigned int>(); - createTable<float>(); - createTable<CAN::AverageResult_t>(); - createTable<PixelMap_t>(); - } else { - createTable<PixelCoralClientUtils::PixelCalibData>(); - } - - // measuring elapsed time - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; -} - - - - - -//--------------------------------------------------------------------------- -/** Drop CORAL tables - */ -void PixCoralClient::dropTables(){ - if (m_verbose) std::cout << "\nCOOLCORAL Client: Drop tables" << std::endl; - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - - transactionStartUpdate(); - - std::set<std::string> tables = m_session->nominalSchema().listTables(); - - if (tables.size() > 0) - if (m_verbose) std::cout << "Deleting the old tables: " << std::endl; - for ( std::set<std::string>::reverse_iterator tName = tables.rbegin(); - tName != tables.rend(); ++tName ){ - if ((*tName).find(m_pixeltable) != std::string::npos) { - if (m_verbose) std::cout << "\t" << *tName << std::endl; - m_session->nominalSchema().dropTable(*tName); - } - } - - transactionCommit(); - - // measuring elapsed time - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << "Total time was " << total_usecs << " usec" << std::endl; -} - - - - -//--------------------------------------------------------------------------- -/** Fill analysis result tables - */ -void PixCoralClient::fillTables(CAN::SerialNumber_t serialNumber, - CAN::AnalysisResultList_t *results){ - if (m_verbose) std::cout << "\nCOOLCORAL Client: Fill tables" << std::endl; - - // get a new foreign key - long long fk = updateKey(); - - transactionStartUpdate(); - - // Create if not yet there - if (!m_session->nominalSchema().existsTable(m_pixeltable)) { - createTables(); - transactionStartUpdate(); - } - - // Find bool variables - if (results->begin<bool>() != results->end<bool>()) { - if (!m_session->nominalSchema().existsTable(m_pixeltable+"_BOOL")) { - createTable<bool>(); - transactionStartUpdate(); - } - } - - // Find unsigned int variables - if (results->begin<unsigned int>() != results->end<unsigned int>()) { - if (!m_session->nominalSchema().existsTable(m_pixeltable+"_UINT")) { - createTable<unsigned int>(); - transactionStartUpdate(); - } - } - - // Find float variables - if (results->begin<float>() != results->end<float>()) { - if (!m_session->nominalSchema().existsTable(m_pixeltable+"_FLOAT")) { - createTable<float>(); - transactionStartUpdate(); - } - } - - // Find AverageResult_t variables - if (results->begin<CAN::AverageResult_t>() != results->end<CAN::AverageResult_t>()) { - if (!m_session->nominalSchema().existsTable(m_pixeltable+"_AVRES")) { - createTable<CAN::AverageResult_t>(); - transactionStartUpdate(); - } - } - - // Find special pixel map variables - if (results->begin<PixelMap_t>() != results->end<PixelMap_t>()) { - if (!m_session->nominalSchema().existsTable(m_pixeltable+"_SPECIALPIXELS")) { - createTable<PixelMap_t>(); - transactionStartUpdate(); - } - } - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - if (m_verbose) std::cout << " Filling table " << m_pixeltable << " for analysis "<< serialNumber << std::endl; - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle(m_pixeltable ).dataEditor(); - coral::AttributeList pixel_row ATLAS_THREAD_SAFE; // Not shared, ok - - //unsigned int id = serialNumber; - time_t date = time(0); - - struct timeval nunc_time; - gettimeofday(&nunc_time, NULL); - - int run = 0; - - pixel_row.extend<CAN::SerialNumber_t>("ANAL_ID"); - pixel_row.extend<time_t>("DATE"); - pixel_row.extend<long long>("FK"); - pixel_row["ANAL_ID"].data<CAN::SerialNumber_t>() = serialNumber; - pixel_row["DATE"].data<time_t>() = LocalToGMTTime(date); - pixel_row["FK"].data<long long>() = fk; - pixel_editor.insertRow(pixel_row); - - transactionCommit(); - - run += fillTable<bool>(fk,results); - run += fillTable<unsigned int>(fk,results); - run += fillTable<float>(fk,results); - run += fillTable<CAN::AverageResult_t>(fk,results); - run += fillTable<PixelMap_t>(fk,results); - - if (m_verbose) printf("\n Total: %d rows\n",run); - - // measuring elapsed time - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; - -} - -/** fill PCD table -- A.X. - */ -void PixCoralClient::fillTables(const char* option){ - - if (option==NULL || !strlen(option)) { return; } - - if (m_verbose) { - std::cout << "\nCOOLCORAL Client: Fill tables"; - if (option) std::cout << " with option " << option; - std::cout << std::endl; - } - - // get a new foreign key - long long fk = updateKey(); - - transactionStartUpdate(); - - - // Create if not yet there - if (!m_session->nominalSchema().existsTable(m_pixeltable)) { - createTables(option); - transactionStartUpdate(); - } - - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - if (m_verbose) std::cout << " Filling table " << m_pixeltable << std::endl; - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle(m_pixeltable ).dataEditor(); - coral::AttributeList pixel_row ATLAS_THREAD_SAFE; // Not shared, ok - - //unsigned int id = serialNumber; - time_t date = time(0); - - struct timeval nunc_time; - gettimeofday(&nunc_time, NULL); - - int run = 0; - - pixel_row.extend<std::string>("TAG"); - pixel_row.extend<int>("REVISION"); - pixel_row.extend<std::string>("SOURCES"); - pixel_row.extend<time_t>("DATE"); - pixel_row.extend<long long>("FK"); - - // parse option -- A.X. - std::string tag(""); - std::string revision(""); - std::string sources(""); - std::string delimiters(", "); - std::string str(option); - std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); - std::string::size_type pos = str.find_first_of(delimiters, lastPos); - while (std::string::npos != pos || std::string::npos != lastPos) { - if (str.substr(lastPos,4)=="tag:") - tag = str.substr(lastPos+4, pos-lastPos-4); - if (str.substr(lastPos,9)=="revision:") - revision = str.substr(lastPos+9, pos-lastPos-9); - if (str.substr(lastPos,8)=="sources:") - sources = str.substr(lastPos+8, pos-lastPos-8); - lastPos = str.find_first_not_of(delimiters, pos); - pos = str.find_first_of(delimiters, lastPos); - } - if (m_verbose) { - std::cout << "TAG: " << tag << std::endl; - std::cout << "REVISION: " << atoi(revision.c_str()) << std::endl; - std::cout << "SOURCES: " << sources << std::endl; - } - - pixel_row["TAG"].data<std::string>() = tag; - pixel_row["REVISION"].data<int>() = atoi(revision.c_str()); - pixel_row["SOURCES"].data<std::string>() = sources; - pixel_row["DATE"].data<time_t>() = LocalToGMTTime(date); - pixel_row["FK"].data<long long>() = fk; - - pixel_editor.insertRow(pixel_row); - - transactionCommit(); - - run += fillTablePixelCalibData(fk, option); - - if (m_verbose) printf("\n Total: %d rows\n",run); - - // measuring elapsed time - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; - -} - - - -//--------------------------------------------------------------------------- -/** Get results for a particular analysis ID - Optionally get only variable "varname" and/or connectivity object connName - */ -void PixCoralClient::queryTable(CAN::SerialNumber_t anal_id, const std::string& varname, const std::string& connName){ - - std::cout << "\n COOLCORAL Client: " << m_pixeltable <<" Putting table content in AnalysisResultList for analysis " << anal_id; - if (varname != "") std::cout<<", variable " << varname; - if (connName != "") std::cout<<", object " << connName; - std::cout<< std::endl; - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - transactionStartReadOnly(); - - // Get all entries for anal_id - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - query->addToOutputList("ANAL_ID"); - query->defineOutputType("ANAL_ID",coral::AttributeSpecification::typeNameForType<CAN::SerialNumber_t>()); - query->addToOutputList("DATE"); - query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - query->addToOutputList("FK"); - std::string pixel_cond = m_pixeltable+".ANAL_ID = :analid"; - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData.extend<CAN::SerialNumber_t>( "analid" ); - query->setCondition( pixel_cond, pixel_condData); - pixel_condData[0].data<CAN::SerialNumber_t>() = anal_id; - coral::ICursor& cursor = query->execute(); - - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - std::time_t timet = GMTtoLocalTime(row0[1].data<time_t>()); - char buf[32]; - std::string time = ctime_r(&timet, buf); - std::cout << " ANAL_ID = " << row0[0].data<CAN::SerialNumber_t>() - << " DATE = " << time.substr(0,time.size()-1) - << " FK = " << row0[2].data<long long>() << std::endl; - //row0.toOutputStream(std::cout)<<endl; - ++nRows; - // Show the variables - std::set<std::string> tables = m_session->nominalSchema().listTables(); - for ( std::set<std::string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - if ((*tName).find(m_pixeltable+"_") != std::string::npos) { - coral::IQuery* query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<std::string> colName; colName.resize(NumCol); - std::vector<std::string> colType; colType.resize(NumCol); - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - query_2->addToOutputList(colDesc.name()); - //if (m_verbose) std::cout <<" "<<i<<": "<< colName[i] <<" ("<< colType[i]<<")"<< std::endl; - } - - // Second query to get entries in each table - std::string pixel_cond_2 = (*tName)+".FK = :analfk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>( "analfk" ); - pixel_condData_2[0].data<long long>() = row0[2].data<long long>(); - if (varname != "") { - pixel_cond_2 += " AND "+(*tName)+".VARIABLE = :var"; - pixel_condData_2.extend<std::string>("var"); - pixel_condData_2["var"].data<std::string>() = varname; - } - if (connName != "") { - pixel_cond_2 += " AND "+(*tName)+".CONNECTIVITY = :conn"; - pixel_condData_2.extend<std::string>("conn"); - pixel_condData_2["conn"].data<std::string>() = connName; - } - query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = query_2->execute(); - while ( cursor_2.next() ) { - const coral::AttributeList &row0_2 = cursor_2.currentRow(); - std::cout << " conn = " << row0_2[1].data<std::string>(); - std::cout<< " ("<<colType[3]<<")"<<row0_2[2].data<std::string>()<<"="; - // If only I could use colType[i] and pass it to the template somehow - for(int i=3; i<NumCol; ++i){ - if (colType[i] == "float") - std::cout<< " ("<<colType[i]<<")"<<colName[i]<<"=" << row0_2[i].data<float>(); - else if (colType[i] == "int") - std::cout<< " ("<<colType[i]<<")"<<colName[i]<<"=" << row0_2[i].data<int>(); - else if (colType[i] == "long long") - std::cout<< " ("<<colType[i]<<")"<<colName[i]<<"=" << row0_2[i].data<long long>(); - else if (colType[i] == "bool") - std::cout<< " ("<<colType[i]<<")"<<colName[i]<<"=" << row0_2[i].data<bool>(); - } - std::cout<< std::endl; - } - delete query_2; - } - } - } - delete query; - - transactionCommit(); - - if (m_verbose) printf(" Total %d analyses\n", nRows); - - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; -} - - - - -//-------------------------------------------------------------------------- -/** Create and fill the CALIB_KEYGEN key generation table - */ -void PixCoralClient::createAuxTables(){ - std::string FK_TABLE = "CALIB_KEYGEN"; - transactionStartUpdate(); - - // std::cout << "Deleting the old table: " << FK_TABLE << std::endl; - // m_session->nominalSchema().dropIfExistsTable(FK_TABLE); - - if (!m_session->nominalSchema().existsTable(FK_TABLE)) { - if (m_verbose) std::cout << "Creating table: " <<FK_TABLE << std::endl; - coral::TableDescription key_columns( "SchemaDefinition_KEY" ); - key_columns.setName( FK_TABLE ); - key_columns.insertColumn( "KEY", - coral::AttributeSpecification::typeNameForType<long long>()); - key_columns.createIndex ("KEY_INDEX", "KEY"); - // Create the actual table - try { - m_session->nominalSchema().createTable( key_columns ); - // Fill the first key - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - coral::AttributeList rowBuffer ATLAS_THREAD_SAFE; // Not shared, ok - rowBuffer.extend<long long>( "KEY" ); - long long& key = rowBuffer[ "KEY" ].data<long long>(); - key = 1000; - keyeditor.insertRow( rowBuffer ); - } catch (coral::TableAlreadyExistingException & ex) { - //Must have been created in parallel - } - } - transactionCommit(); -} - - - - -//--------------------------------------------------------------------------- -/** Method to update the key in the KEYGEN table - */ -long long PixCoralClient::updateKey(){ - if (m_verbose) std::cout << "\nCOOLCORAL Client: Update Key" << std::endl; - std::string FK_TABLE = "CALIB_KEYGEN"; - transactionStartUpdate(); - if (!m_session->nominalSchema().existsTable(FK_TABLE)) { - createAuxTables(); - transactionStartUpdate(); - } - - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - std::string updateAction = "KEY = KEY + :offset"; - coral::AttributeList updateData ATLAS_THREAD_SAFE; // Not shared, ok - updateData.extend<long long>("offset"); - updateData[0].data<long long>() = 1; - //long rowsUpdated = - keyeditor.updateRows( updateAction, "", updateData ); - //std::cout << " Updated " << rowsUpdated << " rows" << std::endl; - - coral::IQuery* query = m_session->nominalSchema().tableHandle(FK_TABLE).newQuery(); - query->addToOutputList("KEY"); - coral::ICursor& cursor = query->execute(); - long long key = -1; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - key = row0[0].data<long long>(); - if (m_verbose) std::cout << " KEY = " << key << std::endl; - } - transactionCommit(); - return key; -} - - - - - -/** Template to create a table for variable columnName. - Works only for simple types (one value to save) -*/ -template <typename T> -void PixCoralClient::createTable(){ - - transactionStartUpdate(); - - std::string PIXEL_TABLE_DATA=m_pixeltable+"_"+tableTypeName<T>(); - - if (!m_session->nominalSchema().existsTable(PIXEL_TABLE_DATA)) { - if (m_verbose) { - std::cout << "\nCOOLCORAL Client: Creating table: " << PIXEL_TABLE_DATA <<" for "; - try { - std::cout <<tableTypeName<T>() << std::endl; - } catch (const coral::AttributeListException&) { - std::cout <<typeid(T).name() << std::endl; - } - } - - // Create the table - coral::TableDescription pixel_columns( "SchemaDefinition_PIXEL" ); - pixel_columns.setName( PIXEL_TABLE_DATA ); - pixel_columns.insertColumn("FK", coral::AttributeSpecification::typeNameForType<long long>()); - pixel_columns.insertColumn("CONNECTIVITY", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 100, /*fixed_size=*/ false); - pixel_columns.insertColumn("VARIABLE", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 100, /*fixed_size=*/ false); - - if (typeid(T)==typeid(CAN::AverageResult_t)) { - pixel_columns.insertColumn("N", coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("MEAN", coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("RMS", coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("LOW99", coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("UP99", coral::AttributeSpecification::typeNameForType<float>()); - } else if (typeid(T)==typeid(PixelMap_t)) { - // A size > 4000 triggers the use of a CLOB object - pixel_columns.insertColumn("VALUE", coral::AttributeSpecification::typeNameForType<std::string>(), /*size = */ 4001, /*fixed_size=*/ false); - // added -- A.X. - } else if (typeid(T)==typeid(PixelCoralClientUtils::PixelCalibData)) { - pixel_columns.insertColumn("IDMOD",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("CHIP",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLD1",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLD2",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLD3",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLD4",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDLONG1",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDLONG2",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDLONG3",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDLONG4",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDGANGED1",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDGANGED2",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDGANGED3",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("THRESHOLDGANGED4",coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("Q2TOT1",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("Q2TOT2",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("Q2TOT3",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("Q2TOTGANGED1",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("Q2TOTGANGED2",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("Q2TOTGANGED3",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("TOTRES1",coral::AttributeSpecification::typeNameForType<float>()); - pixel_columns.insertColumn("TOTRES2",coral::AttributeSpecification::typeNameForType<float>()); - } else { - pixel_columns.insertColumn("VALUE", coral::AttributeSpecification::typeNameForType<T>()); - } - - //set the foreign key - pixel_columns.createForeignKey(tableTypeName<T>()+"_FK","FK",m_pixeltable,"FK"); - // create indices - pixel_columns.createIndex(tableTypeName<T>()+"_CONNECTIVITY_IDX", "CONNECTIVITY"); - pixel_columns.createIndex(tableTypeName<T>()+"_VARIABLE_IDX", "VARIABLE"); - pixel_columns.setNotNullConstraint ( "CONNECTIVITY" ); - pixel_columns.setNotNullConstraint ( "VARIABLE" ); - - // Create the actual table - try { - //coral::ITable& table = - m_session->nominalSchema().createTable( pixel_columns ); - } catch (coral::TableAlreadyExistingException & ex) { - //Must have been created in parallel - } - } - - transactionCommit(); -} - -template <class T> -std::string valueQuote() { - return std::string(); -} - -template <> -std::string valueQuote<std::string>() { - return std::string("'"); -} - -template <class T> -void createCondition(const std::vector<T> &search_list, - const std::string &table_name, - const std::string &var_name, - const std::string &bind_name, - coral::AttributeList &attribut_list, - std::string &condition, - bool use_attr_list=false) -{ - if (!search_list.empty()) { - condition += table_name; - condition += "."; - condition += var_name; - - if (search_list.size()==1) { - attribut_list.extend< T >( bind_name ); - assert(attribut_list.size()>0); - attribut_list[attribut_list.size()-1].setValue( search_list.back() ); - condition += " = :"; - condition += bind_name; - } - else { - if (use_attr_list) { - - condition += " in ("; - - std::string sep=":"; - std::string sep2=",:"; - - std::stringstream a_var_name; - unsigned int counter=attribut_list.size(); - for(typename std::vector<T>::const_iterator iter=search_list.begin(); - iter != search_list.end(); - ++iter, ++counter) { - - a_var_name.clear(); - a_var_name << bind_name << counter; - attribut_list.extend< T >( a_var_name.str() ); - attribut_list[counter].setValue< T >( *iter ); - - condition += sep; - condition += a_var_name.str(); - sep = sep2; - } - condition += ")"; - } - else { - condition += " in ("; - typename std::vector<T>::const_iterator iter=search_list.begin(); - - std::string quote(valueQuote<T>()); - condition += quote; - condition += *iter; - condition += quote; - for(; - iter != search_list.end(); - ++iter) { - condition += ','; - condition += quote; - condition += *iter; - condition += quote; - } - condition += ")"; - } - } - } -} - - -enum EValueType {kValFloat,kValInt, kValUInt, kValBool, kValString, kValExtendedAverageValue, kValAverageValue, kNValueTypes}; -//--------------------------------------------------------------------------- -void PixCoralClient::getAnalysisResultsFromDB(std::vector<CAN::SerialNumber_t> analysis_id, - const std::vector<std::string> &connName, - IPixResultsDbListener &listener) { - - if (analysis_id.empty()) return; - struct timeval start_time, end_time; - int total_usecs; - unsigned int n_rows=0; - - if (m_verbose) { - std::cout << "\n COOLCORAL Client: " << m_pixeltable <<" Putting table content in AnalysisResultList for:"; - std::cout<<"\n analysis :" ; - for (std::vector<CAN::SerialNumber_t>::const_iterator iter = analysis_id.begin(); - iter != analysis_id.end(); - ++iter) { - std::cout << *iter; - } - std::cout << std::endl; - gettimeofday(&start_time, NULL); - } - - char *test=getenv("CANRESULTS_USE_ATTRL"); - bool use_attr_list=false; - if (test && strcmp(test,"y")==0) { - use_attr_list=true; - } - - transactionStartReadOnly(); - - // want to produce query : - // select t1.ANAL_ID, t2.CONNECTIVITY, t2.VARIABLE, t2.VALUE from - // (select ANAL_ID,FK from CALIB_ANAL where ANAL_ID = 1394 ) t1, - // CALIB_ANAL_FLOAT t2 where (t2.FK=t1.FK); - - std::set<std::string> tables = m_session->nominalSchema().listTables(); - for ( std::set<std::string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - - if ((*tName).find(m_pixeltable+"_") != std::string::npos) { - // only consider tables CALIB_ANAL_FLOAT etc. not CALIB_ANAL. - - // define output columns depending on the table type : - // first identify table type - std::string col_type; - EValueType value_type=kNValueTypes; - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - - try { - const coral::IColumn& colDesc = tableDesc.columnDescription("VALUE"); - - col_type= colDesc.type(); - value_type=kNValueTypes; - if (col_type == "float") { - value_type = kValFloat; - } - else if (col_type == "int") { - value_type=kValInt; - } - else if (col_type == "unsigned int") { - value_type=kValUInt; - } - else if (col_type == "bool") { - value_type=kValBool; - } - else if (col_type == "string") { - value_type=kValString; - } - } - catch(coral::InvalidColumnNameException &) { - - try { - // check whether the columns exist - tableDesc.columnDescription("N"); - tableDesc.columnDescription("MEAN"); - tableDesc.columnDescription("RMS"); - value_type = kValAverageValue; - } - catch(coral::InvalidColumnNameException &) { - } - - try { - // check whether the columns exist - tableDesc.columnDescription("LOW99"); - tableDesc.columnDescription("UP99"); - value_type = kValExtendedAverageValue; - } - catch(coral::InvalidColumnNameException &) { - } - - } - if (value_type>=kNValueTypes) { - std::cerr << "ERROR [CoralClient::getAnalysisResultsFromDB] Failed to identify value type for " << *tName << "."<< std::endl; - continue; - } - - // now define output columns - std::unique_ptr<coral::IQuery> query( m_session->nominalSchema().newQuery() ); - if (!query.get()) { - std::cerr << "ERROR [CoralClient::getAnalysisResultsFromDB] Failed to create queries for table " << *tName << "."<< std::endl; - continue; - } - query->addToTableList(*tName, "V"); - - query->addToOutputList("V.CONNECTIVITY"); - query->addToOutputList("V.VARIABLE"); - - switch (value_type) { - case kValAverageValue: { - std::cerr << "ERROR [CoralClient::getAnalysisResultsFromDB] unsupported table " << *tName << std::endl; - return; - } - case kValExtendedAverageValue: { - query->addToOutputList("V.N"); - query->addToOutputList("V.MEAN"); - query->addToOutputList("V.RMS"); - query->addToOutputList("V.LOW99"); - query->addToOutputList("V.UP99"); - break; - } - default: { - query->addToOutputList("V.VALUE"); - } - } - - query->setRowCacheSize(2000); - - // select all entries which match the serial number and return the rod list key - coral::IQueryDefinition& rod_list_query = query->defineSubQuery( "R" ); - rod_list_query.addToOutputList( "I.FK" ,"FK"); - rod_list_query.addToTableList("CALIB_ANAL","I"); - - coral::AttributeList analysis_id_condition_inputs ATLAS_THREAD_SAFE; // Not shared, ok - std::string analysis_id_condition; - createCondition<CAN::SerialNumber_t>(analysis_id, "I","ANAL_ID","id",analysis_id_condition_inputs,analysis_id_condition,use_attr_list); - rod_list_query.setCondition(analysis_id_condition, analysis_id_condition_inputs); - query->addToTableList( "R" ); - - // Get the list of columns - - // prepare the query condition - coral::AttributeList condition_inputs ATLAS_THREAD_SAFE; // Not shared, ok - std::string condition; - condition = "R.FK = V.FK"; - if (!connName.empty() ) { - condition+= " AND "; - createCondition<std::string>(connName, "V","CONNECTIVITY","conn",condition_inputs, condition,use_attr_list); - } - query->setCondition(condition, condition_inputs); - coral::ICursor& cursor = query->execute(); - - while ( cursor.next() ) { - - const coral::AttributeList &row = cursor.currentRow(); - const std::string &conn = row[0].data<std::string>(); - const std::string &the_var_name (row[1].data<std::string>()); - n_rows++; - if (m_verbose) std::cout<< " ("<<col_type << " -> " << value_type <<") ="; - - switch (value_type) { - case kValFloat: { - if (m_verbose) std::cout << row[2].data<float>(); - listener.newValue( the_var_name, conn, row[2].data<float>() ); - break; - } - case kValInt: { - if (m_verbose) std::cout << row[2].data<int>(); - listener.newValue( the_var_name, conn, static_cast<unsigned int>(row[2].data<int>()) ); - break; - } - case kValUInt: { - if (m_verbose) std::cout << row[2].data<unsigned int>(); - listener.newValue( the_var_name, conn, static_cast<unsigned int>(row[2].data<unsigned int>()) ); - break; - } - case kValBool: { - if (m_verbose) std::cout << row[2].data<bool>(); - listener.newValue( the_var_name, conn, row[2].data<bool>() ); - break; - } - case kValString: { - if (m_verbose) std::cout << row[2].data<std::string>(); - listener.newValue( the_var_name, conn,CLOBtoPixelMap(row[2].data<std::string>())); - break; - } - case kValExtendedAverageValue: { - if (m_verbose) { - std::cout<<" (avres)" - << the_var_name - <<"="<<row[2].data<int>() - <<"/"<<row[3].data<float>() - <<"/"<<row[4].data<float>() - <<"/"<<row[5].data<float>() - <<"/"<<row[6].data<float>(); - } - - CAN::AverageResult_t avres(row[2].data<int>(),row[3].data<float>(),row[4].data<float>(),row[5].data<float>(),row[6].data<float>()); - listener.newValue( the_var_name, conn, avres ); - break; - } - default: - std::cerr << "ERROR [CoralClient::getAnalysisResultsFromDB] Unsupported column type " << col_type << std::endl; - } - if (m_verbose) std::cout<< std::endl; - } - } - } - - transactionCommit(); - - if (m_verbose) { - std::cout << " Total " << n_rows << " analyses" << std::endl; - - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - std::cout << " Total time was " << total_usecs << " usec" << std::endl; - } -} - -// helper function to store values into table rows. - -// all types -template <typename T> inline void addValueToRow(coral::AttributeList &attribute_list, const T &value) { - attribute_list["VALUE"].data<T>() = value; -} - -template <typename T> inline void extendAttributeList(coral::AttributeList &attribute_list) { - attribute_list.extend<T>("VALUE"); -} - - -// special handling for AverageResult -template <> inline void addValueToRow<CAN::AverageResult_t>(coral::AttributeList &attribute_list, const CAN::AverageResult_t &value) { - attribute_list["N"].setValue((int)value.n()); - attribute_list["MEAN"].setValue(value.value(CAN::AverageResult_t::kMean)); - attribute_list["RMS"].setValue(value.value(CAN::AverageResult_t::kRMS)); - attribute_list["LOW99"].setValue(value.value(CAN::AverageResult_t::kLower99)); - attribute_list["UP99"].setValue(value.value(CAN::AverageResult_t::kUpper99)); -} - -template <> inline void extendAttributeList<CAN::AverageResult_t>(coral::AttributeList &attribute_list) { - attribute_list.extend<int>("N"); - attribute_list.extend<float>("MEAN"); - attribute_list.extend<float>("RMS"); - attribute_list.extend<float>("LOW99"); - attribute_list.extend<float>("UP99"); -} - - -// special handling for PixelMap_t -template <> inline void addValueToRow<PixelMap_t> (coral::AttributeList &attribute_list, const PixelMap_t &value) { - attribute_list["VALUE"].setValue(PixCoralClient::PixelMapToCLOB(value)); -} - -template <> inline void extendAttributeList<PixelMap_t>(coral::AttributeList &attribute_list) { - attribute_list.extend<std::string>("VALUE"); -} - - -// type name helper functions -template <typename T> inline std::string typeName() { - return coral::AttributeSpecification::typeNameForType<T>(); -} - -template <> inline std::string typeName<CAN::AverageResult_t>() { - return std::string("CAN::AverageResult_t"); -} - -template <> inline std::string typeName<PixelMap_t>() { - return std::string("PixelMap_t"); -} - -void emptyNamesErrorMessage(unsigned int empty_var_names, unsigned int empty_conn_names, const std::string &table_name) -{ - if (empty_conn_names>0 || empty_var_names>0) { - std::cerr << "ERROR [PixCoralClient::fillTable] Tried to fill "; - if (empty_var_names>0) { - std::cerr << empty_var_names << " result(s) without variable name "; - if (empty_conn_names>0) { - std::cerr << "and "; - } - } - if (empty_conn_names>0) { - std::cerr << empty_conn_names << " result(s) without connectivity name "; - } - std::cerr << " into " << table_name << std::endl; - } -} - -/** Template to fill a table with analysis results. - Works only for simple types (one value to save) -*/ -template <typename T> -int PixCoralClient::fillTable(long long fk, CAN::AnalysisResultList_t *results){ - - if (m_verbose) std::cout << "\nCOOLCORAL Client: fill table for type "<< tableTypeName<T>() << std::endl; - - transactionStartUpdate(); - - int nrows = 0; - - std::string table_name = m_pixeltable+"_"+tableTypeName<T>(); - unsigned int empty_var_names=0; - unsigned int empty_conn_names=0; - for (typename std::map<std::string, std::map<std::string, T> >::const_iterator iter=results->begin<T>(); - iter != results->end<T>(); - ++iter) { - - if (iter->first.empty()) { - empty_var_names++; - continue; - } - - std::string tname = iter->first; - if (m_verbose) std::cout << " Filling table " << table_name << " for variable " << tname << std::endl; - coral::ITableDataEditor& pixel_editor_2 = m_session->nominalSchema().tableHandle(table_name).dataEditor(); - coral::AttributeList pixel_row_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_row_2.extend<long long>("FK"); - pixel_row_2.extend<std::string>("CONNECTIVITY"); - pixel_row_2.extend<std::string>("VARIABLE"); - // pixel_row_2.extend<T>("VALUE"); - extendAttributeList<T>(pixel_row_2); - { - std::unique_ptr<coral::IBulkOperation> pixel_bulk_2(pixel_editor_2.bulkInsert(pixel_row_2,iter->second.size())); - for (typename std::map<std::string, T >::const_iterator val_iter=iter->second.begin(); - val_iter != iter->second.end(); - ++val_iter) { - - if (val_iter->first.empty()) { - empty_conn_names++; - continue; - } - - pixel_row_2["FK"].data<long long>() = fk; - pixel_row_2["CONNECTIVITY"].data<std::string>() = val_iter->first; - pixel_row_2["VARIABLE"].data<std::string>() = tname; - // pixel_row_2["VALUE"].data<T>() = val_iter->second; - addValueToRow(pixel_row_2, val_iter->second); - ++nrows; - pixel_bulk_2->processNextIteration(); - } - pixel_bulk_2->flush(); - } - } - - if (empty_conn_names>0 || empty_var_names>0) { - emptyNamesErrorMessage(empty_var_names, empty_conn_names, table_name); - } - - transactionCommit(); - return nrows; -} - - - -// /** Fill a table with analysis results of type AverageResult_t. -// Couldn't use the templated fillTable<T> above because the object -// structure is different... -// */ -// int PixCoralClient::fillTableAverageResult(long long fk, CAN::AnalysisResultList_t *results){ -// if (m_verbose) std::cout << "\nCOOLCORAL Client: fill table for CAN::AverageResult_t" << std::endl; -// int nrows = 0; -// transactionStartUpdate(); -// for (std::map<std::string, std::map<std::string, CAN::AverageResult_t> >::const_iterator iter=results->begin<CAN::AverageResult_t>(); -// iter != results->end<CAN::AverageResult_t>(); -// iter ++) { -// if (m_verbose) std::cout << " Filling table " << m_pixeltable+"_AVRES" << std::endl; -// coral::ITableDataEditor& pixel_editor_2 = m_session->nominalSchema().tableHandle(m_pixeltable+"_AVRES").dataEditor(); -// coral::AttributeList pixel_row_2; -// pixel_editor_2.rowBuffer(pixel_row_2); -// coral::IBulkOperation* pixel_bulk_2= pixel_editor_2.bulkInsert(pixel_row_2,iter->second.size()); -// for (std::map<std::string, CAN::AverageResult_t >::const_iterator val_iter=iter->second.begin(); -// val_iter != iter->second.end(); -// val_iter ++) { -// pixel_row_2["FK"].setValue <long long> (fk); -// pixel_row_2["CONNECTIVITY"].setValue <std::string> (val_iter->first); -// pixel_row_2["VARIABLE"].setValue <std::string> (iter->first); -// pixel_row_2["N"].setValue((int)val_iter->second.n()); -// pixel_row_2["MEAN"].setValue(val_iter->second.value(CAN::AverageResult_t::kMean)); -// pixel_row_2["RMS"].setValue(val_iter->second.value(CAN::AverageResult_t::kRMS)); -// pixel_row_2["LOW99"].setValue(val_iter->second.value(CAN::AverageResult_t::kLower99)); -// pixel_row_2["UP99"].setValue(val_iter->second.value(CAN::AverageResult_t::kUpper99)); -// ++nrows; -// pixel_bulk_2->processNextIteration(); -// } -// pixel_bulk_2->flush(); -// delete pixel_bulk_2; -// } -// transactionCommit(); -// return nrows; -// } - - - -// /** Fill a table with analysis results of type PixelMap_t. -// Couldn't use the templated fillTable<T> above because the CLOB -// has to be constructed first. -// */ -// int PixCoralClient::fillTableSpecialPixelMap(long long fk, CAN::AnalysisResultList_t *results){ -// if (m_verbose) std::cout << "\nCOOLCORAL Client: fill table for PixelMap_t" << std::endl; -// int nrows = 0; -// transactionStartUpdate(); -// for (std::map<std::string, std::map<std::string, PixelMap_t> >::const_iterator iter=results->begin<PixelMap_t>(); -// iter != results->end<PixelMap_t>(); -// iter ++) { -// if (m_verbose) std::cout << " Filling table " << m_pixeltable+"_SPECIALPIXELS" << std::endl; -// coral::ITableDataEditor& pixel_editor_2 = m_session->nominalSchema().tableHandle(m_pixeltable+"_SPECIALPIXELS").dataEditor(); -// coral::AttributeList pixel_row_2; -// pixel_editor_2.rowBuffer(pixel_row_2); -// coral::IBulkOperation* pixel_bulk_2= pixel_editor_2.bulkInsert(pixel_row_2,iter->second.size()); -// for (std::map<std::string, PixelMap_t >::const_iterator val_iter=iter->second.begin(); -// val_iter != iter->second.end(); -// val_iter ++) { -// pixel_row_2["FK"].setValue <long long> (fk); -// pixel_row_2["CONNECTIVITY"].setValue <std::string> (val_iter->first); -// pixel_row_2["VARIABLE"].setValue <std::string> (iter->first); -// pixel_row_2["VALUE"].setValue(PixelMapToCLOB(val_iter->second)); -// ++nrows; -// pixel_bulk_2->processNextIteration(); -// } -// pixel_bulk_2->flush(); -// delete pixel_bulk_2; -// } -// transactionCommit(); -// return nrows; -// } - - - -/** Fill a table with PixelCalibData -- A.X. - Couldn't use the templated fillTable<T> above because the object - structure is different... -*/ -int PixCoralClient::fillTablePixelCalibData(long long fk, const char* option){ - if (m_verbose) std::cout << "\nCOOLCORAL Client: fill table for PixelCoralClientUtils::PixelCalibData" << std::endl; - - const char* filename = strstr(option,"file:"); - if (filename==0) { - std::cout << "incorrect option (no file:)" << std::endl; - return 0; - } - - std::ifstream in(filename+5); - if (!in.is_open()) { - std::cout << "could not open calibration file" << std::endl; - return 0; - } - - int nrows = 0; - transactionStartUpdate(); - - { - coral::ITableDataEditor& pixel_editor_2 = m_session->nominalSchema().tableHandle(m_pixeltable+"_PCD").dataEditor(); - coral::AttributeList pixel_row_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_editor_2.rowBuffer(pixel_row_2); - int mysize = 1; - coral::IBulkOperation* pixel_bulk_2= pixel_editor_2.bulkInsert(pixel_row_2,mysize); - - while (in) { - int idmod; in >> idmod; - if (in.eof()) break; - - bool ok = true; - for (int i = 0; i<16; ++i) { - char dummy; in >> dummy; - if (dummy!='I') { ok = false; break; } - int idchip; in >> idchip; - if (idchip!=i) { ok = false; break; } - - pixel_row_2["FK"].setValue <long long> (fk); - pixel_row_2["IDMOD"].setValue <int> (idmod); - pixel_row_2["CHIP"].setValue <int> (idchip); - int thres, sigma, noise, timewalk; - in >> thres >> sigma >> noise >> timewalk; - pixel_row_2["THRESHOLD1"].setValue <int> (thres); - pixel_row_2["THRESHOLD2"].setValue <int> (sigma); - pixel_row_2["THRESHOLD3"].setValue <int> (noise); - pixel_row_2["THRESHOLD4"].setValue <int> (timewalk); - in >> thres >> sigma >> noise >> timewalk; - pixel_row_2["THRESHOLDLONG1"].setValue <int> (thres); - pixel_row_2["THRESHOLDLONG2"].setValue <int> (sigma); - pixel_row_2["THRESHOLDLONG3"].setValue <int> (noise); - pixel_row_2["THRESHOLDLONG4"].setValue <int> (timewalk); - in >> thres >> sigma >> noise >> timewalk; - pixel_row_2["THRESHOLDGANGED1"].setValue <int> (thres); - pixel_row_2["THRESHOLDGANGED2"].setValue <int> (sigma); - pixel_row_2["THRESHOLDGANGED3"].setValue <int> (noise); - pixel_row_2["THRESHOLDGANGED4"].setValue <int> (timewalk); - float A, E, C; - in >> A >> E >> C; - pixel_row_2["Q2TOT1"].setValue <float> (A); - pixel_row_2["Q2TOT2"].setValue <float> (E); - pixel_row_2["Q2TOT3"].setValue <float> (C); - in >> A >> E >> C; - pixel_row_2["Q2TOTGANGED1"].setValue <float> (A); - pixel_row_2["Q2TOTGANGED2"].setValue <float> (E); - pixel_row_2["Q2TOTGANGED3"].setValue <float> (C); - float p1, p2; - in >> p1 >> p2; - pixel_row_2["TOTRES1"].setValue <float> (p1); - pixel_row_2["TOTRES2"].setValue <float> (p2); - - ++nrows; - pixel_bulk_2->processNextIteration(); - } - if (!ok) break; - } - if (m_verbose) std::cout << "PixelCalibData: loaded " << nrows << " chips" << std::endl; - - pixel_bulk_2->flush(); - delete pixel_bulk_2; - } - transactionCommit(); - return nrows; -} - - - -//--------------------------------------------------------------------------- -/** Get results for a particular analysis ID - and fill an AnalysisResultList_t container - Optionally get only variable "varname" and/or connectivity object connName - */ -CAN::AnalysisResultList_t PixCoralClient::getAnalysisResultsFromDB(CAN::SerialNumber_t anal_id, const std::string& varname, const std::string& connName){ - - if (m_verbose) { - std::cout << "\n COOLCORAL Client: " << m_pixeltable <<" Putting table content in AnalysisResultList for analysis " << anal_id; - if (varname != "") std::cout<<", variable " << varname; - if (connName != "") std::cout<<", object " << connName; - std::cout<< std::endl; - } - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - transactionStartReadOnly(); - - CAN::AnalysisResultList_t anal_results; - - // Get all entries for anal_id - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - query->addToOutputList("ANAL_ID"); - query->defineOutputType("ANAL_ID",coral::AttributeSpecification::typeNameForType<CAN::SerialNumber_t>()); - query->addToOutputList("DATE"); - query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - query->addToOutputList("FK"); - std::string pixel_cond = m_pixeltable+".ANAL_ID = :analid"; - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData.extend<CAN::SerialNumber_t>( "analid" ); - query->setCondition( pixel_cond, pixel_condData); - pixel_condData[0].data<CAN::SerialNumber_t>() = anal_id; - coral::ICursor& cursor = query->execute(); - - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - std::time_t timet = GMTtoLocalTime(row0[1].data<time_t>()); - char buf[32]; - std::string time = ctime_r(&timet, buf); - std::cout << " ANAL_ID = " << row0[0].data<CAN::SerialNumber_t>() - << " DATE = " << time.substr(0,time.size()-1) - << " FK = " << row0[2].data<long long>() << std::endl; - } - //row0.toOutputStream(std::cout)<<endl; - ++nRows; - // Show the variables - std::set<std::string> tables = m_session->nominalSchema().listTables(); - for ( std::set<std::string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - if ((*tName).find(m_pixeltable+"_") != std::string::npos) { - coral::IQuery* query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<std::string> colName; colName.resize(NumCol); - std::vector<std::string> colType; colType.resize(NumCol); - //if (m_verbose) std::cout << "\n Name: "<< *tName << std::endl; - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - query_2->addToOutputList(colDesc.name()); - //if (m_verbose) std::cout <<" "<<i<<": "<< colName[i] <<" ("<< colType[i]<<")"<< std::endl; - } - - // Second query to get entries in each table - std::string pixel_cond_2 = (*tName)+".FK = :analfk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>( "analfk" ); - pixel_condData_2[0].data<long long>() = row0[2].data<long long>(); - if (varname != "") { - pixel_cond_2 += " AND "+(*tName)+".VARIABLE = :var"; - pixel_condData_2.extend<std::string>("var"); - pixel_condData_2["var"].data<std::string>() = varname; - } - if (connName != "") { - pixel_cond_2 += " AND "+(*tName)+".CONNECTIVITY = :conn"; - pixel_condData_2.extend<std::string>("conn"); - pixel_condData_2["conn"].data<std::string>() = connName; - } - query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = query_2->execute(); - while ( cursor_2.next() ) { - const coral::AttributeList &row0_2 = cursor_2.currentRow(); - const std::string conn = row0_2[1].data<std::string>(); - if (m_verbose) std::cout << " conn = " << conn; - if (NumCol == 4) { // single value - if (m_verbose) std::cout<< " ("<<colType[3]<<")"<<row0_2[2].data<std::string>()<<"="; - if (colType[3] == "float") { - if (m_verbose) std::cout << row0_2[3].data<float>(); - anal_results.addValue<float>(row0_2[2].data<std::string>(),conn,row0_2[3].data<float>()); - } else if (colType[3] == "int") { - if (m_verbose) std::cout << row0_2[3].data<int>(); - anal_results.addValue<unsigned int>(row0_2[2].data<std::string>(),conn,row0_2[3].data<int>()); - } else if (colType[3] == "bool") { - if (m_verbose) std::cout << row0_2[3].data<bool>(); - anal_results.addValue<bool>(row0_2[2].data<std::string>(),conn,row0_2[3].data<bool>()); - } else if (colType[3] == "string") { - if (m_verbose) std::cout << row0_2[3].data<std::string>(); - anal_results.addValue<PixelMap_t>(row0_2[2].data<std::string>(),conn,CLOBtoPixelMap(row0_2[3].data<std::string>())); - } - - } else { //AverageResult_t - if (m_verbose) std::cout<<" (avres)"<<row0_2[2].data<std::string>()<<"="<<row0_2[3].data<int>()<<"/"<<row0_2[4].data<float>()<<"/"<<row0_2[5].data<float>()<<"/"<<row0_2[6].data<float>()<<"/"<<row0_2[7].data<float>(); - CAN::AverageResult_t avres(row0_2[3].data<int>(),row0_2[4].data<float>(),row0_2[5].data<float>(),row0_2[6].data<float>(),row0_2[7].data<float>()); - anal_results.addValue<CAN::AverageResult_t>(row0_2[2].data<std::string>(),conn,avres); - } - if (m_verbose) std::cout<< std::endl; - } - delete query_2; - } - } - } - delete query; - - transactionCommit(); - - if (m_verbose) printf(" Total %d analyses\n", nRows); - - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; - return anal_results; -} - - - - - - -//--------------------------------------------------------------------------- -/** Get results for a particular analysis ID and a vector of connectivity - objects connName and fill an AnalysisResultList_t container - Optionally get only variable "varname" - */ -CAN::AnalysisResultList_t PixCoralClient::getAnalysisResultsFromDB(CAN::SerialNumber_t anal_id, const std::vector<std::string> &connName, const std::string& varname){ - - if (m_verbose) { - std::cout << "\n COOLCORAL Client: " << m_pixeltable <<" Putting table content in AnalysisResultList for analysis " << anal_id; - if (varname != "") std::cout<<", variable " << varname; - if (!connName.empty()) { - std::cout<<", objects "; - for (std::vector<std::string>::const_iterator it=connName.begin(); - it != connName.end(); ++it) - std::cout << *it <<", "; - } - std::cout<< std::endl; - } - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - transactionStartReadOnly(); - - CAN::AnalysisResultList_t anal_results; - - // Get all entries for anal_id - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - query->addToOutputList("ANAL_ID"); - query->defineOutputType("ANAL_ID",coral::AttributeSpecification::typeNameForType<CAN::SerialNumber_t>()); - query->addToOutputList("DATE"); - query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - query->addToOutputList("FK"); - std::string pixel_cond = m_pixeltable+".ANAL_ID = :analid"; - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData.extend<CAN::SerialNumber_t>( "analid" ); - query->setCondition( pixel_cond, pixel_condData); - pixel_condData[0].data<CAN::SerialNumber_t>() = anal_id; - coral::ICursor& cursor = query->execute(); - - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - std::time_t timet = GMTtoLocalTime(row0[1].data<time_t>()); - char buf[32]; - std::string time = ctime_r(&timet, buf); - std::cout << " ANAL_ID = " << row0[0].data<CAN::SerialNumber_t>() - << " DATE = " << time.substr(0,time.size()-1) - << " FK = " << row0[2].data<long long>() << std::endl; - } - //row0.toOutputStream(std::cout)<<endl; - ++nRows; - // Show the variables - std::set<std::string> tables = m_session->nominalSchema().listTables(); - for ( std::set<std::string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - if ((*tName).find(m_pixeltable+"_") != std::string::npos) { - coral::IQuery* query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<std::string> colName; colName.resize(NumCol); - std::vector<std::string> colType; colType.resize(NumCol); - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - query_2->addToOutputList(colDesc.name()); - //if (m_verbose) std::cout <<" "<<i<<": "<< colName[i] <<" ("<< colType[i]<<")"<< std::endl; - } - - // Second query to get entries in each table - std::string pixel_cond_2 = (*tName)+".FK = :analfk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>( "analfk" ); - pixel_condData_2[0].data<long long>() = row0[2].data<long long>(); - if (varname != "") { - pixel_cond_2 += " AND "+(*tName)+".VARIABLE = :var"; - pixel_condData_2.extend<std::string>("var"); - pixel_condData_2["var"].data<std::string>() = varname; - } - if (!connName.empty()) { - // now restrict to certain connectivity names. - pixel_cond_2 += " AND ("; - for (std::vector<std::string>::const_iterator conn_iter=connName.begin(); - conn_iter != connName.end(); - ++conn_iter) { - unsigned int counter=pixel_condData_2.size(); - std::stringstream var_name; - var_name << "conn" << counter; - pixel_condData_2.extend<std::string>( var_name.str() ); - assert( pixel_condData_2.size() > counter ); // sanity check - pixel_condData_2[counter].data<std::string>() = *conn_iter; - - pixel_cond_2 += *tName; - pixel_cond_2 += ".CONNECTIVITY = :"; - pixel_cond_2 += var_name.str(); - if (connName.end()-conn_iter > 1 ) { - pixel_cond_2 += " OR "; - } - } - pixel_cond_2 += ")"; - } - query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = query_2->execute(); - while ( cursor_2.next() ) { - const coral::AttributeList &row0_2 = cursor_2.currentRow(); - const std::string conn = row0_2[1].data<std::string>(); - if (m_verbose) std::cout << " conn = " << conn; - if (NumCol == 4) { // single value - if (m_verbose) std::cout<< " ("<<colType[3]<<")"<<row0_2[2].data<std::string>()<<"="; - if (colType[3] == "float") { - if (m_verbose) std::cout << row0_2[3].data<float>(); - anal_results.addValue<float>(row0_2[2].data<std::string>(),conn,row0_2[3].data<float>()); - } else if (colType[3] == "int") { - if (m_verbose) std::cout << row0_2[3].data<int>(); - anal_results.addValue<unsigned int>(row0_2[2].data<std::string>(),conn,row0_2[3].data<int>()); - } else if (colType[3] == "bool") { - if (m_verbose) std::cout << row0_2[3].data<bool>(); - anal_results.addValue<bool>(row0_2[2].data<std::string>(),conn,row0_2[3].data<bool>()); - } else if (colType[3] == "string") { - if (m_verbose) std::cout << row0_2[3].data<std::string>(); - anal_results.addValue<PixelMap_t>(row0_2[2].data<std::string>(),conn,CLOBtoPixelMap(row0_2[3].data<std::string>())); - } - - } else { //AverageResult_t - if (m_verbose) std::cout<<" (avres)"<<row0_2[2].data<std::string>()<<"="<<row0_2[3].data<int>()<<"/"<<row0_2[4].data<float>()<<"/"<<row0_2[5].data<float>()<<"/"<<row0_2[6].data<float>()<<"/"<<row0_2[7].data<float>(); - CAN::AverageResult_t avres(row0_2[3].data<int>(),row0_2[4].data<float>(),row0_2[5].data<float>(),row0_2[6].data<float>(),row0_2[7].data<float>()); - anal_results.addValue<CAN::AverageResult_t>(row0_2[2].data<std::string>(),conn,avres); - } - if (m_verbose) std::cout<< std::endl; - } - delete query_2; - } - } - } - delete query; - - transactionCommit(); - - if (m_verbose) printf(" Total %d analyses\n", nRows); - - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; - return anal_results; -} - - -/** access calibration data using tag / revision -- A.X. - */ -void PixCoralClient::getCalibrationDataFromDB(const char* option){ - if (m_verbose) { - std::cout << "\n COOLCORAL Client: " << m_pixeltable << " loading calibration data using option " << option << std::endl; - } - - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - transactionStartReadOnly(); - - // Get all entries for anal_id - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - - query->addToOutputList("TAG"); - query->defineOutputType("TAG",coral::AttributeSpecification::typeNameForType<std::string>()); - query->addToOutputList("REVISION"); - query->defineOutputType("REVISION",coral::AttributeSpecification::typeNameForType<int>()); - query->addToOutputList("SOURCES"); - query->defineOutputType("SOURCES",coral::AttributeSpecification::typeNameForType<std::string>()); - query->addToOutputList("DATE"); - query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - query->addToOutputList("FK"); - - // parse option - std::string tag(""); - std::string revision(""); - std::string sources(""); - std::string delimiters(", "); - std::string str(option); - std::string::size_type lastPos = str.find_first_not_of(delimiters, 0); - std::string::size_type pos = str.find_first_of(delimiters, lastPos); - while (std::string::npos != pos || std::string::npos != lastPos) { - if (str.substr(lastPos,4)=="tag:") - tag = str.substr(lastPos+4, pos-lastPos-4); - if (str.substr(lastPos,9)=="revision:") - revision = str.substr(lastPos+9, pos-lastPos-9); - if (str.substr(lastPos,8)=="sources:") - sources = str.substr(lastPos+8, pos-lastPos-8); - lastPos = str.find_first_not_of(delimiters, pos); - pos = str.find_first_of(delimiters, lastPos); - } - - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok - std::string pixel_cond = m_pixeltable+".TAG = :tag"; - pixel_condData.extend<std::string>( "tag" ); - pixel_condData[0].data<std::string>() = tag; - // can make it conditional (e.g. if revision!="") - pixel_cond += " AND "+m_pixeltable+".REVISION = :revision"; - pixel_condData.extend<int>( "revision" ); - pixel_condData["revision"].data<int>() = atoi(revision.c_str()); - query->setCondition( pixel_cond, pixel_condData); - coral::ICursor& cursor = query->execute(); - - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - std::time_t timet = GMTtoLocalTime(row0[3].data<time_t>()); - char buf[32]; - std::string time = ctime_r(&timet, buf); - std::cout << " TAG = " << row0[0].data<std::string>() - << " REVISION = " << row0[1].data<int>() - << " SOURCES = " << row0[2].data<std::string>() - << " DATE = " << time.substr(0,time.size()-1) - << " FK = " << row0[4].data<long long>() << std::endl; - } - //row0.toOutputStream(std::cout)<<endl; - ++nRows; - // Show the variables - std::set<std::string> tables = m_session->nominalSchema().listTables(); - for ( std::set<std::string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - if ((*tName).find(m_pixeltable+"_") != std::string::npos) { - if (m_verbose) { - std::cout << "found table " << (*tName) << std::endl; - } - - coral::IQuery* query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<std::string> colName; colName.resize(NumCol); - std::vector<std::string> colType; colType.resize(NumCol); - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - query_2->addToOutputList(colDesc.name()); - if (m_verbose) std::cout <<" "<<i<<": "<< colName[i] <<" ("<< colType[i]<<")"<< std::endl; - } - - // Second query to get entries in each table - std::string pixel_cond_2 = (*tName)+".FK = :fk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>( "fk" ); - pixel_condData_2[0].data<long long>() = row0[4].data<long long>(); - query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = query_2->execute(); - // TO BE FIXED: the whole thing should not go to a single pcd :) - PixelCoralClientUtils::PixelCalibData pcd; - while ( cursor_2.next() ) { - const coral::AttributeList &row0_2 = cursor_2.currentRow(); - //int ix = 3; - //int idmod = row0_2[ix++].data<int>(); - int ix = 4; - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData pcsd; - int idchip = row0_2[ix++].data<int>(); - pcsd.setChipID(idchip); - int iv[4]; - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(0,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(1,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(2,iv[0],iv[1],iv[2],iv[3]); - float fv[3]; - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(0,fv[0],fv[1],fv[2]); - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(2,fv[0],fv[1],fv[2]); - for (int m=0; m<2; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setTotRes(fv[0],fv[1]); - pcd.add(pcsd); - } - if (m_verbose) { - pcd.print(); - } - delete query_2; - } - } - } - delete query; - - transactionCommit(); - - if (m_verbose) printf(" Total %d analyses\n", nRows); - - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) std::cout << " Total time was " << total_usecs << " usec" << std::endl; -} - - - -/** CORAL helper to start a transaction in readonly mode - */ -void PixCoralClient::transactionStartReadOnly(){ - connect(); - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(true /*ReadOnly*/); -} - - - -/** CORAL helper to start a transaction in update mode - */ -void PixCoralClient::transactionStartUpdate(){ - connect(); - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(false /*update*/); -} - - - -/** CORAL helper to commit changes at the end of a transaction - */ -void PixCoralClient::transactionCommit(){ - if (m_session->transaction().isActive()) m_session->transaction().commit(); -} - -namespace PixA { - /** Translate between chip and module coordinates. - * copied from PixelDataContainer - * - * @authors Joern Grosse-Knetter <joern.grosse-knetter@uni-bonn.de> - */ - class PixelCoord_t - { - public: - static const int s_nChip = 16; - static const int s_nPix = 2880; - static const int s_nSpecialPix = 448; - static const int s_nCol = 18; - static const int s_nRow = 160; - - PixelCoord_t(int xval, int yval) { - if(yval<s_nRow){ // chips 0-7 - m_row = yval; - m_col = xval%s_nCol; - m_chip = xval/s_nCol; - } else{ - m_row = 2*s_nRow-1- yval; - m_col = s_nCol-1 - xval%s_nCol; - m_chip = s_nChip-1 - xval/s_nCol; - } - } - - PixelCoord_t(int chip, int col, int row) : m_chip(chip), m_col(col), m_row(row) {} - - int chip() const {return m_chip;} - int col() const {return m_col;} - int row() const {return m_row;} - - int pixel() const { return chip()*s_nPix+row()+s_nRow*col(); } - - int x() const { - - if(m_chip<s_nChip/2) { - return m_chip*s_nCol+m_col; - } - else { - return (s_nCol-1-m_col + s_nCol*(s_nChip-1-m_chip)); - } - - } - - int y() const { - if (m_chip<s_nChip/2) { - return m_row; - } - else { - return 2*s_nRow-1-m_row; - } - } - - private: - int m_chip; - int m_col; - int m_row; - }; - - - - unsigned int encodePixelID (unsigned int mod_column, unsigned int mod_row) { - unsigned int chip = 0, column = 0, row = 0; - - PixelCoord_t pix(mod_column, mod_row); - chip = pix.chip(); - column = pix.col(); - row = pix.row(); - - return PixelCoralClientUtils::ModuleSpecialPixelMap::encodePixelID(chip,column,row); - - } - -} - -/** - Converts a CAN::PixelMap_t object to a CLOB compatible with - ModuleSpecialPixelMap -*/ -std::string PixCoralClient::PixelMapToCLOB(const PixelMap_t & pixmap) { - std::map<unsigned int, unsigned int> pixels; - for (PixelMap_t::const_iterator it=pixmap.begin(); it != pixmap.end(); ++it) { - pixels[PixA::encodePixelID((*it).first.first,(*it).first.second)] = (*it).second; - } - unsigned int module_status = 0; - std::vector<unsigned int> chip_status; - std::vector<std::vector<unsigned int> > column_pair_status; - PixelCoralClientUtils::ModuleSpecialPixelMap special = PixelCoralClientUtils::ModuleSpecialPixelMap(pixels,module_status,chip_status,column_pair_status); - special.markSpecialRegions(); - //std::cout<<"CLOB: "<<special.to_string()<<std::endl;; - return special.to_string(); -} - -/** - Converts a CLOB compatible with ModuleSpecialPixelMap to a - CAN::PixelMap_t object -*/ -PixelMap_t PixCoralClient::CLOBtoPixelMap(const std::string & clob) { - PixelCoralClientUtils::ModuleSpecialPixelMap special; - special.fill_from_string(clob); - PixelMap_t pixels; - //std::cout<<"CLOB content: "<<std::endl; - unsigned int fe, col, row; - for (PixelCoralClientUtils::ModuleSpecialPixelMap::const_iterator it=special.begin(); it != special.end(); ++it) { - //std::cout<<" "<<it->first<<" "<<it->second<<" "; - fe = it->first%16; - col = (it->first >> 4)%32; - row = (it->first>>9); - //std::cout<<fe<<" "<<col<<"/"<<row<<std::endl; - PixA::PixelCoord_t pixel_coord(fe, col, row); - pixels[std::make_pair(pixel_coord.x(), pixel_coord.y())] = it->second;//CLA - } - if (special.moduleStatus() != 0) { - unsigned int status = special.moduleStatus(); - // if (m_verbose) std::cout<<"Special module with status "<<status<<std::endl; - for (unsigned int chip=0; chip<16; ++chip) { - for (unsigned int c=0; c<18; ++c) { - for (unsigned int r=0; r<160; ++r) { - PixA::PixelCoord_t pixel_coord(chip, c, r); - pixels[std::make_pair(pixel_coord.x(), pixel_coord.y())] = status; - - } - } - } - } else if (special.hasSpecialChips()) { - for (unsigned int chip=0; chip<16; ++chip) { - unsigned int status = special.chipStatus(chip); - if (status != 0) { - //if (m_verbose) std::cout<<"Special chip "<<chip<<" with status "<<status<<std::endl; - for (unsigned int c=0; c<18; ++c) { - for (unsigned int r=0; r<160; ++r) { - PixA::PixelCoord_t pixel_coord(chip, c, r); - pixels[std::make_pair(pixel_coord.x(), pixel_coord.y())] = status; - } - } - } - } - } - if (special.hasSpecialColumnPairs()) { - for (unsigned int chip=0; chip<16; ++chip) { - if (special.hasSpecialColumnPairs(chip)) { - for (unsigned int pair=0; pair<9; ++pair) { - unsigned int status = special.columnPairStatus(chip,pair); - if (status != 0) { - // if (m_verbose) std::cout<<"Special pair "<<pair<<" on chip "<<chip<<" with status "<<status<<std::endl; - for (int i=0; i<160; ++i) { - PixA::PixelCoord_t pixel_coord(chip, pair*2, i); - pixels[std::make_pair(pixel_coord.x(),pixel_coord.y())] = status; - PixA::PixelCoord_t pixel_coord2(chip, pair*2+1, i); - pixels[std::make_pair(pixel_coord2.x(),pixel_coord2.y())] = status; - } - } - } - } - } - } - - return pixels; -} - - - -//------------------------------------------------ -/// Get value from PVSS archive -//------------------------------------------------ -double PixCoralClient::get_value_from_PVSSarch(const std::string& element_name, const coral::TimeStamp &since, const coral::TimeStamp &until) -{ - double result=0; - - transactionStartReadOnly(); - - // Perform a query involving a subquery. - - coral::IQuery* query = m_session->nominalSchema().newQuery(); - query->addToOutputList( "A.ELEMENT_NAME", "NAME" ); - query->addToOutputList( "A.ALIAS", "ALIAS" ); - query->addToOutputList( "B.TS", "TS" ); - query->addToOutputList( "B.VALUE_NUMBER", "VALUE" ); - - coral::IQueryDefinition& subQuery1 = query->defineSubQuery( "A" ); - subQuery1.addToOutputList( "ELEMENT_ID" ); - subQuery1.addToOutputList( "ELEMENT_NAME" ); - subQuery1.addToOutputList( "ALIAS" ); - subQuery1.addToTableList( "ELEMENTS" ); - coral::AttributeList cond1 ATLAS_THREAD_SAFE; // Not shared, ok - cond1.extend<std::string>( "el_name" ); - subQuery1.setCondition( "ELEMENT_NAME = :el_name", cond1 ); - query->addToTableList( "A" ); - - coral::IQueryDefinition& subQuery2 = query->defineSubQuery( "B" ); - subQuery2.addToOutputList( "ELEMENT_ID" ); - subQuery2.addToOutputList( "TS" ); - subQuery2.addToOutputList( "VALUE_NUMBER"); - subQuery2.addToTableList( "EVENTHISTORY" ); - query->addToTableList( "B" ); - - coral::AttributeList time ATLAS_THREAD_SAFE; // Not shared, ok - time.extend<coral::TimeStamp>( "since" ); - time.extend<coral::TimeStamp>( "until" ); - - query->setCondition( "A.ELEMENT_ID = B.ELEMENT_ID AND B.TS > :since AND B.TS < :until" , time); - query ->addToOrderList("B.TS DESC"); - - - cond1[0].data<std::string>() = element_name; - time[0].data<coral::TimeStamp>() = since; - time[1].data<coral::TimeStamp>() = until; - - coral::ICursor& cursor = query->execute(); - coral::AttributeList sel ATLAS_THREAD_SAFE; // Not shared, ok - if ( cursor.next() ){ sel = cursor.currentRow(); - - result = sel[3].data<double>(); - std::cout << "Element name = " << sel[0].data<std::string>() << std::endl; - std::cout << "Alias = " << sel[1].data<std::string>() << std::endl; - std::cout << "Value = " << result << std::endl; - -} - // cursor.currentRow().toOutputStream( std::cout ) << std::endl; - - std::cout << "Result = " << result << std::endl; - - delete query; - transactionCommit(); - - return result; - -} - -//------------------------------------------------ -/// Get value from PVSS archive -//------------------------------------------------ -double PixCoralClient::get_values_from_PVSSarch(const std::string& element_name, const coral::TimeStamp &since, const coral::TimeStamp &until){ - - double result=0; - - transactionStartReadOnly(); - - // Perform a query involving a subquery. - - coral::IQuery* query = m_session->nominalSchema().newQuery(); - query->addToOutputList( "A.ELEMENT_NAME", "NAME" ); - query->addToOutputList( "B.TS", "TS" ); - query->addToOutputList( "B.VALUE_NUMBER", "VALUE" ); - - coral::IQueryDefinition& subQuery1 = query->defineSubQuery( "A" ); - subQuery1.addToOutputList( "ELEMENT_ID" ); - subQuery1.addToOutputList( "ELEMENT_NAME" ); - subQuery1.addToTableList( "ELEMENTS" ); - coral::AttributeList cond1 ATLAS_THREAD_SAFE; // Not shared, ok - cond1.extend<std::string>( "el_name" ); - subQuery1.setCondition( "ELEMENT_NAME = :el_name", cond1 ); - query->addToTableList( "A" ); - - coral::IQueryDefinition& subQuery2 = query->defineSubQuery( "B" ); - subQuery2.addToOutputList( "ELEMENT_ID" ); - subQuery2.addToOutputList( "TS" ); - subQuery2.addToOutputList( "VALUE_NUMBER"); - subQuery2.addToTableList( "EVENTHISTORY" ); - query->addToTableList( "B" ); - - coral::AttributeList time ATLAS_THREAD_SAFE; // Not shared, ok - time.extend<coral::TimeStamp>( "since" ); - time.extend<coral::TimeStamp>( "until" ); - - query->setCondition( "A.ELEMENT_ID = B.ELEMENT_ID AND B.TS > :since AND B.TS < :until" , time); - query ->addToOrderList("B.TS DESC"); - - - cond1[0].data<std::string>() = element_name; - time[0].data<coral::TimeStamp>() = since; - time[1].data<coral::TimeStamp>() = until; - - coral::ICursor& cursor = query->execute(); - coral::AttributeList sel ATLAS_THREAD_SAFE; // Not shared, ok - // if ( cursor.next() ){ - while ( cursor.next() ){ - sel = cursor.currentRow(); - result = sel[2].data<double>(); - // cursor.currentRow().toOutputStream( std::cout ) << std::endl; - std::cout << "Result = " << result << std::endl; - } - - delete query; - transactionCommit(); - - return result; - } - -//------------------------------------------------ -/// Get value from PVSS archive -//------------------------------------------------ -void PixCoralClient::get_alias_from_PVSSarch(){ - - transactionStartReadOnly(); - - // Perform a query involving a subquery. - - coral::IQuery* query = m_session->nominalSchema().tableHandle("ELEMENTS").newQuery(); - query->addToOutputList( "ELEMENT_NAME"); - query->addToOutputList( "ALIAS"); - - // query->setCondition( "A.ELEMENT_ID = B.ELEMENT_ID AND B.TS > :since AND B.TS < :until" , time); - // query ->addToOrderList("B.TS DESC"); - - -// cond1[0].data<std::string>() = element_name; -// time[0].data<coral::TimeStamp>() = since; -// time[1].data<coral::TimeStamp>() = until; - - coral::ICursor& cursor = query->execute(); - coral::AttributeList sel ATLAS_THREAD_SAFE; // Not shared, ok - // if ( cursor.next() ){ - std::cout << "NAME\t\t\t ALIAS" << std::endl; - while ( cursor.next() ){ - sel = cursor.currentRow(); - std::string elname = sel[0].data<std::string>(); - std::string elalias = sel[1].data<std::string>(); - - - std::cout << elname << "\t\t\t " << elalias << std::endl; - } - - delete query; - transactionCommit(); - - // return result; -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDDb.cxx b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDDb.cxx deleted file mode 100644 index eece038f893..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDDb.cxx +++ /dev/null @@ -1,227 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PCDDb.h" -#include "PixelCoralClientUtils/PixelCalibData.hh" - -// CORAL API -#include "CoralKernel/Context.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/AttributeListException.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/IConnectionServiceConfiguration.h" -#include "RelationalAccess/AccessMode.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ITransaction.h" - -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDescription.h" -#include "RelationalAccess/IColumn.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/IQuery.h" -#include "RelationalAccess/TableDescription.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/ITableSchemaEditor.h" -#include "RelationalAccess/IBulkOperation.h" -#include "RelationalAccess/SchemaException.h" - -#include "CxxUtils/checker_macros.h" - -// std lib -#include <fstream> -#include <iostream> -#include <vector> -#include <set> -using namespace std; - -//--------------------------------------------------------------------------- -/** Constructor. - Open the default database and seal context. -*/ -PCDDb::PCDDb(const std::string& connString, - const std::string& tableName, - bool verbose, bool /*load_text*/) : - m_verbose(verbose), - m_session(0), m_connString(connString), m_pixeltable(tableName), - m_query(0), m_query_2(0), m_cursor(0) -{ - //char* ctmp = getenv("CAN_CALIB_DB"); - //if (ctmp) m_connString = ctmp; - // Create the RCDConnectionService - if (m_verbose) cout << "Creating Connection Service to \"" << m_connString << "\"" << endl; - - // Instantiate connection service - coral::Context* context = &coral::Context::instance(); - - // Load CORAL connection service - coral::IHandle<coral::IConnectionService> lookSvcH = context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - context->loadComponent( "CORAL/Services/ConnectionService" ); - lookSvcH = context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw std::runtime_error( "Could not locate the connection service" ); - } - /// connection to CORAL - m_session = lookSvcH->connect( m_connString, coral::Update ); -} - -PCDDb::~PCDDb() -{ - if (m_session) { - bool was_there = m_query!=0; - - // cleanup - delete m_query_2; // ok if m_query_2==0 - delete m_query; // ditto - if (was_there) transactionCommit(); - - if (m_verbose) cout << "Disconnecting \"" << m_connString << "\"" << endl; - delete m_session; - } -} - -bool PCDDb::init (const std::string& tag, int revision) -{ - if (m_verbose) cout << "PCDDb::init(" << tag << ", " << revision << ")" << endl; - - transactionStartReadOnly(); - m_query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - - m_query->addToOutputList("TAG"); - m_query->defineOutputType("TAG",coral::AttributeSpecification::typeNameForType<std::string>()); - m_query->addToOutputList("REVISION"); - m_query->defineOutputType("REVISION",coral::AttributeSpecification::typeNameForType<int>()); - m_query->addToOutputList("SOURCES"); - m_query->defineOutputType("SOURCES",coral::AttributeSpecification::typeNameForType<std::string>()); - m_query->addToOutputList("DATE"); - m_query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - m_query->addToOutputList("FK"); - - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok - std::string pixel_cond = m_pixeltable+".TAG = :tag"; - pixel_condData.extend<string>( "tag" ); - pixel_condData[0].data<string>() = tag; - pixel_cond += " AND "+m_pixeltable+".REVISION = :revision"; - pixel_condData.extend<int>( "revision" ); - pixel_condData["revision"].data<int>() = revision; - m_query->setCondition( pixel_cond, pixel_condData); - coral::ICursor& cursor = m_query->execute(); - - while (cursor.next()) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - time_t timet = row0[3].data<time_t>(); - char buf[32]; - string time = ctime_r(&timet, buf); - cout << " TAG = " << row0[0].data<string>() - << " REVISION = " << row0[1].data<int>() - << " SOURCES = " << row0[2].data<string>() - << " TIME = " << time.substr(0,time.size()-1) - << " FK = " << row0[4].data<long long>() << endl; - } - std::set<string> tables = m_session->nominalSchema().listTables(); - for (std::set<string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName) { - if ((*tName).find(m_pixeltable+"_") != string::npos) { - if (m_verbose) cout << "found table " << *tName << endl; - m_query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - std::vector<string> colName; colName.resize(NumCol); - std::vector<string> colType; colType.resize(NumCol); - for(int i = 0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - m_query_2->addToOutputList(colDesc.name()); - if (m_verbose) cout << " " << i << ": " << colName[i] <<" ("<< colType[i] << ")" << endl; - } - - // Second query to get entries - string pixel_cond_2 = (*tName)+".FK = :fk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>( "fk" ); - pixel_condData_2[0].data<long long>() = row0[4].data<long long>(); - m_query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = m_query_2->execute(); - - // .. and keep the cursor for data extraction - m_cursor = &cursor_2; - - // success - return true; - } - } - } - - // table not found - return false; -} - -int PCDDb::next() -{ - if (!m_cursor->next()) return 0; - const coral::AttributeList& row0_2 = m_cursor->currentRow(); - int idmod = row0_2[1].data<int>(); - return idmod; -} - -bool PCDDb::set(int idmod_cur, PixelCoralClientUtils::PixelCalibData& pcd) -{ - const coral::AttributeList& row0_2 = m_cursor->currentRow(); - int ix = 1; - int idmod = row0_2[ix++].data<int>(); - if (idmod != idmod_cur) return false; - - for (int i = 0; i<16; ++i) { - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData pcsd; - pcsd.setChipID(i); - int iv[4]; - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(0,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(1,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(2,iv[0],iv[1],iv[2],iv[3]); - float fv[3]; - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(0,fv[0],fv[1],fv[2]); - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(2,fv[0],fv[1],fv[2]); - for (int m=0; m<2; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setTotRes(fv[0],fv[1]); - pcd.add(pcsd); - } - - return true; -} - -/** CORAL helper to start a transaction in readonly mode - */ -void PCDDb::transactionStartReadOnly(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(true /*ReadOnly*/); -} - - - -/** CORAL helper to start a transaction in update mode - */ -void PCDDb::transactionStartUpdate(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(false /*update*/); -} - - - -/** CORAL helper to commit changes at the end of a transaction - */ -void PCDDb::transactionCommit(){ - if (m_session->transaction().isActive()) m_session->transaction().commit(); -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDio.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDio.cc deleted file mode 100644 index 3f30e34ab25..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDio.cc +++ /dev/null @@ -1,566 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PCDio.h" -#include "PixelCoralClientUtils/PixelCalibData.hh" - -// CORAL API -#include "CoralKernel/Context.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/AttributeListException.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/IConnectionServiceConfiguration.h" -#include "RelationalAccess/AccessMode.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ITransaction.h" - -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDescription.h" -#include "RelationalAccess/IColumn.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/IQuery.h" -#include "RelationalAccess/TableDescription.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/ITableSchemaEditor.h" -#include "RelationalAccess/IBulkOperation.h" -#include "RelationalAccess/SchemaException.h" - -// std lib -#include <fstream> -#include <iostream> -#include <vector> -#include <set> -#include <sys/time.h> -using namespace std; - -//--------------------------------------------------------------------------- -/** Constructor. - Open the default database and seal context. - */ -PCDio::PCDio(const std::string& connString, - const std::string& tableName, - int verbose) : - m_connString(connString), m_pixeltable(tableName), - m_verbose(verbose), m_session(0) {} - -PCDio::~PCDio() -{ - if (m_verbose) cout << "Disconnecting \"" << m_connString << "\"" << endl; - delete m_session; -} - -/** initialize connection - */ -void PCDio::init(coral::AccessMode access_mode) -{ - if (m_verbose) cout << "Creating Connection Service to \"" << m_connString << "\"" << endl; - - coral::Context* context = &coral::Context::instance(); - coral::IHandle<coral::IConnectionService> lookSvcH = context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - context->loadComponent("CORAL/Services/ConnectionService"); - lookSvcH = context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw runtime_error("Could not locate the connection service"); - } - - m_session = lookSvcH->connect(m_connString, access_mode); - if (m_verbose) cout << "Connection established" << endl; -} - -/** DB -> pcd.sav - */ -void PCDio::load(const std::string& tag, int revision) -{ - // start timer - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - -//// TEMP - - transactionStartReadOnly(); - set<string> tables = m_session->nominalSchema().listTables(); - transactionCommit(); - - for (set<string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - cout << "Table: <" << *tName << ">"; - - transactionStartReadOnly(); - coral::IQuery* query = m_session->nominalSchema().tableHandle(*tName).newQuery(); - coral::ICursor& cursor = query->execute(); - int nRows = 0; - while ( cursor.next() ) { - ++nRows; - } - delete query; - transactionCommit(); - - cout << ", Rows = " << nRows << endl; - - } - - transactionStartReadOnly(); -//// - - // build a query - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - - query->addToOutputList("TAG"); - query->defineOutputType("TAG",coral::AttributeSpecification::typeNameForType<string>()); - query->addToOutputList("REVISION"); - query->defineOutputType("REVISION",coral::AttributeSpecification::typeNameForType<int>()); - query->addToOutputList("SOURCES"); - query->defineOutputType("SOURCES",coral::AttributeSpecification::typeNameForType<string>()); - query->addToOutputList("DATE"); - query->defineOutputType("DATE",coral::AttributeSpecification::typeNameForType<time_t>()); - query->addToOutputList("FK"); - - // construct query condition - coral::AttributeList pixel_condData ATLAS_THREAD_SAFE; // Not shared, ok. - string pixel_cond = m_pixeltable+".TAG = :tag"; - pixel_condData.extend<string>("tag"); - pixel_condData[0].data<string>() = tag; - if (revision>0) { - pixel_cond += " AND "+m_pixeltable+".REVISION = :revision"; - pixel_condData.extend<int>("revision"); - pixel_condData["revision"].data<int>() = revision; - } - query->setCondition( pixel_cond, pixel_condData); - coral::ICursor& cursor = query->execute(); - - int loaded_revision = 0; - - // go through the list of found tables - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - //time_t timet = GMTtoLocalTime(row0[3].data<time_t>()); - time_t timet = row0[3].data<time_t>(); - char buf[32]; - string time = ctime_r(&timet, buf); - cout << " TAG = " << row0[0].data<string>() - << " REVISION = " << row0[1].data<int>() - << " SOURCES = " << row0[2].data<string>() - << " DATE = " << time.substr(0,time.size()-1) - << " FK = " << row0[4].data<long long>() << endl; - } - int current_revision = row0[1].data<int>(); - //row0.toOutputStream(cout)<<endl; - ++nRows; - // Show the variables - set<string> tables = m_session->nominalSchema().listTables(); - for (set<string>::const_iterator tName = tables.begin(); - tName != tables.end(); ++tName ){ - if ((*tName).find(m_pixeltable+"_") != string::npos) { - if (m_verbose) { - cout << "found table " << (*tName) << endl; - } - - // open the output text file - ofstream* outPtr = 0; - if (loaded_revision<current_revision) { - loaded_revision = current_revision; - outPtr = new ofstream("pcd.sav"); - } - - coral::IQuery* query_2 = m_session->nominalSchema().tableHandle(*tName).newQuery(); - - // Get the list of columns - const coral::ITableDescription& tableDesc = - m_session->nominalSchema().tableHandle(*tName).description(); - int NumCol = tableDesc.numberOfColumns(); - vector<string> colName; colName.resize(NumCol); - vector<string> colType; colType.resize(NumCol); - for(int i=0; i<NumCol; ++i){ - const coral::IColumn& colDesc = tableDesc.columnDescription(i); - colName[i] = colDesc.name(); - colType[i] = colDesc.type(); - query_2->addToOutputList(colDesc.name()); - } - - // Second query to get entries in each table - string pixel_cond_2 = (*tName)+".FK = :fk"; - coral::AttributeList pixel_condData_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_condData_2.extend<long long>("fk"); - pixel_condData_2[0].data<long long>() = row0[4].data<long long>(); - query_2->setCondition( pixel_cond_2, pixel_condData_2); - coral::ICursor& cursor_2 = query_2->execute(); - while ( cursor_2.next() ) { - // populate PixelChipSummaryData - const coral::AttributeList &row0_2 = cursor_2.currentRow(); - PixelCoralClientUtils::PixelCalibData pcd; - int ix = 1; - int idmod = row0_2[ix++].data<int>(); - for (int i = 0; i<16; ++i) { - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData pcsd; - pcsd.setChipID(i); - int iv[4]; - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(0,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(1,iv[0],iv[1],iv[2],iv[3]); - for (int m=0; m<4; ++m) iv[m] = row0_2[ix++].data<int>(); - pcsd.setThreshold(2,iv[0],iv[1],iv[2],iv[3]); - float fv[3]; - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(0,fv[0],fv[1],fv[2]); - for (int m=0; m<3; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setQ2Tot(2,fv[0],fv[1],fv[2]); - for (int m=0; m<2; ++m) fv[m] = row0_2[ix++].data<float>(); - pcsd.setTotRes(fv[0],fv[1]); - pcd.add(pcsd); - } - - if (outPtr) { - // print out PixelChipSummaryData - for (int i = 0; i<16; ++i) { - const PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.getPixelChipSummaryData(i); - ofstream& out = *outPtr; - if (pcsd.getChipID()==0) out << idmod << endl; - out << "I" << pcsd.getChipID() - << " " << pcsd.getThreshold(0) - << " " << pcsd.getThresholdSigma(0) - << " " << pcsd.getNoise(0) - << " " << pcsd.getTimeWalk(0) - << " " << pcsd.getThreshold(1) - << " " << pcsd.getThresholdSigma(1) - << " " << pcsd.getNoise(1) - << " " << pcsd.getTimeWalk(1) - << " " << pcsd.getThreshold(2) - << " " << pcsd.getThresholdSigma(2) - << " " << pcsd.getNoise(2) - << " " << pcsd.getTimeWalk(2) - << " " << pcsd.getQ2TotA(0) - << " " << pcsd.getQ2TotE(0) - << " " << pcsd.getQ2TotC(0) - << " " << pcsd.getQ2TotA(2) - << " " << pcsd.getQ2TotE(2) - << " " << pcsd.getQ2TotC(2) - << " " << pcsd.getTotP1() - << " " << pcsd.getTotP2() << endl; - } - } - } - delete query_2; - if (outPtr) { - outPtr->close(); - outPtr = 0; - } - } - } - } - delete query; - - transactionCommit(); - - if (m_verbose) cout << "Total analyses: " << nRows << endl; - - if (revision==0) { - if (m_verbose) cout << "Loaded revision: " << loaded_revision << endl; - // save loaded revision number to a file - ofstream outr("pcd.rev"); - outr << loaded_revision << endl; - outr.close(); - } - - // stop timer - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) cout << " Total time was " << total_usecs << " usec" << endl; -} - -/** pcd.dat -> DB - */ -void PCDio::save(const std::string& tag, int revision, const std::string& sources) -{ - // start timer - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - // create tables if needed - createTable(); - - // get a new foreign key - long long fk = updateKey(); - - transactionStartUpdate(); - - // fill header - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle(m_pixeltable ).dataEditor(); - - coral::AttributeList pixel_row ATLAS_THREAD_SAFE; // Not shared, ok. - pixel_row.extend<std::string>("TAG"); - pixel_row.extend<int>("REVISION"); - pixel_row.extend<std::string>("SOURCES"); - pixel_row.extend<time_t>("DATE"); - pixel_row.extend<long long>("FK"); - - pixel_row["TAG"].data<std::string>() = tag; - pixel_row["REVISION"].data<int>() = revision; - pixel_row["SOURCES"].data<std::string>() = sources; - pixel_row["DATE"].data<time_t>() = time(0); - pixel_row["FK"].data<long long>() = fk; - - pixel_editor.insertRow(pixel_row); - transactionCommit(); - - // fill pcd - transactionStartUpdate(); - { - coral::ITableDataEditor& pixel_editor_2 = m_session->nominalSchema().tableHandle(m_pixeltable+"_PCD").dataEditor(); - coral::AttributeList pixel_row_2 ATLAS_THREAD_SAFE; // Not shared, ok - pixel_editor_2.rowBuffer(pixel_row_2); - int mysize = 1; - coral::IBulkOperation* pixel_bulk_2= pixel_editor_2.bulkInsert(pixel_row_2,mysize); - - int nRows = 0; - - ifstream in("pcd.dat"); - while (in) { - int idmod; in >> idmod; - if (in.eof()) break; - - pixel_row_2["FK"].setValue <long long> (fk); - pixel_row_2["IDMOD"].setValue <int> (idmod); - - bool ok = true; - for (int i = 0; i<16; ++i) { - char dummy; in >> dummy; - if (dummy!='I') { ok = false; break; } - int idchip; in >> idchip; - if (idchip!=i) { ok = false; break; } - - char buf[256]; - int thres, sigma, noise, timewalk; - in >> thres >> sigma >> noise >> timewalk; - sprintf(buf,"THRESHOLD1I%d",i); - pixel_row_2[buf].setValue <int> (thres); - sprintf(buf,"THRESHOLD2I%d",i); - pixel_row_2[buf].setValue <int> (sigma); - sprintf(buf,"THRESHOLD3I%d",i); - pixel_row_2[buf].setValue <int> (noise); - sprintf(buf,"THRESHOLD4I%d",i); - pixel_row_2[buf].setValue <int> (timewalk); - - in >> thres >> sigma >> noise >> timewalk; - sprintf(buf,"THRESHOLDLONG1I%d",i); - pixel_row_2[buf].setValue <int> (thres); - sprintf(buf,"THRESHOLDLONG2I%d",i); - pixel_row_2[buf].setValue <int> (sigma); - sprintf(buf,"THRESHOLDLONG3I%d",i); - pixel_row_2[buf].setValue <int> (noise); - sprintf(buf,"THRESHOLDLONG4I%d",i); - pixel_row_2[buf].setValue <int> (timewalk); - - in >> thres >> sigma >> noise >> timewalk; - sprintf(buf,"THRESHOLDGANGED1I%d",i); - pixel_row_2[buf].setValue <int> (thres); - sprintf(buf,"THRESHOLDGANGED2I%d",i); - pixel_row_2[buf].setValue <int> (sigma); - sprintf(buf,"THRESHOLDGANGED3I%d",i); - pixel_row_2[buf].setValue <int> (noise); - sprintf(buf,"THRESHOLDGANGED4I%d",i); - pixel_row_2[buf].setValue <int> (timewalk); - - float A, E, C; - in >> A >> E >> C; - sprintf(buf,"Q2TOT1I%d",i); - pixel_row_2[buf].setValue <float> (A); - sprintf(buf,"Q2TOT2I%d",i); - pixel_row_2[buf].setValue <float> (E); - sprintf(buf,"Q2TOT3I%d",i); - pixel_row_2[buf].setValue <float> (C); - - in >> A >> E >> C; - sprintf(buf,"Q2TOTGANGED1I%d",i); - pixel_row_2[buf].setValue <float> (A); - sprintf(buf,"Q2TOTGANGED2I%d",i); - pixel_row_2[buf].setValue <float> (E); - sprintf(buf,"Q2TOTGANGED3I%d",i); - pixel_row_2[buf].setValue <float> (C); - - float p1, p2; - in >> p1 >> p2; - sprintf(buf,"TOTRES1I%d",i); - pixel_row_2[buf].setValue <float> (p1); - sprintf(buf,"TOTRES2I%d",i); - pixel_row_2[buf].setValue <float> (p2); - } - - ++nRows; - pixel_bulk_2->processNextIteration(); - if (!ok) break; - } - if (m_verbose) cout << "PixelCalibData: loaded " << nRows << " chips" << endl; - - pixel_bulk_2->flush(); - delete pixel_bulk_2; - } - transactionCommit(); - - // stop timer - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) cout << " Total time was " << total_usecs << " usec" << endl; -} - -/** part of save(): create new tables - */ -void PCDio::createTable() -{ - createAuxTables(); - createHeaderTable(); - createDataTable(); -} - -/** part of save(): create header table - */ -void PCDio::createHeaderTable() -{ - // create header - transactionStartUpdate(); - if (!m_session->nominalSchema().existsTable(m_pixeltable)) { - if (m_verbose) cout << "creating " << m_pixeltable << endl; - coral::TableDescription pixel_columns( "SchemaDefinition_PIXEL" ); - pixel_columns.setName( m_pixeltable ); - pixel_columns.insertColumn("TAG", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - pixel_columns.insertColumn("REVISION", coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.insertColumn("SOURCES", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - pixel_columns.insertColumn( "DATE", coral::AttributeSpecification::typeNameForType<time_t>()); - pixel_columns.insertColumn( "FK", coral::AttributeSpecification::typeNameForType<long long>()); - pixel_columns.setUniqueConstraint("FK","FK_UNIQ"); - m_session->nominalSchema().createTable( pixel_columns ); - } - transactionCommit(); -} - -/** part of save(): create data table - */ -void PCDio::createDataTable() -{ - transactionStartUpdate(); - string PIXEL_TABLE_DATA = m_pixeltable + "_PCD"; - if (!m_session->nominalSchema().existsTable(PIXEL_TABLE_DATA)) { - if (m_verbose) cout << "creating " << PIXEL_TABLE_DATA << endl; - coral::TableDescription pixel_columns( "SchemaDefinition_PIXEL" ); - pixel_columns.setName(PIXEL_TABLE_DATA); - pixel_columns.insertColumn("FK", coral::AttributeSpecification::typeNameForType<long long>()); - pixel_columns.insertColumn("IDMOD",coral::AttributeSpecification::typeNameForType<int>()); - char buf[256]; - for (int i = 0; i<16; ++i) { - for (int j = 1; j<=4; ++j) { - sprintf(buf,"THRESHOLD%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<int>()); - } - for (int j = 1; j<=4; ++j) { - sprintf(buf,"THRESHOLDLONG%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<int>()); - } - for (int j = 1; j<=4; ++j) { - sprintf(buf,"THRESHOLDGANGED%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<int>()); - } - for (int j = 1; j<=3; ++j) { - sprintf(buf,"Q2TOT%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<float>()); - } - for (int j = 1; j<=3; ++j) { - sprintf(buf,"Q2TOTGANGED%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<float>()); - } - for (int j = 1; j<=2; ++j) { - sprintf(buf,"TOTRES%dI%d",j,i); - pixel_columns.insertColumn(buf,coral::AttributeSpecification::typeNameForType<float>()); - } - } - - pixel_columns.createForeignKey("PCD_FK","FK",m_pixeltable,"FK"); - //pixel_columns.createIndex("PCD_CONNECTIVITY_IDX", "CONNECTIVITY"); - //pixel_columns.createIndex("PCD_VARIABLE_IDX", "VARIABLE"); - //pixel_columns.setNotNullConstraint ( "CONNECTIVITY" ); - //pixel_columns.setNotNullConstraint ( "VARIABLE" ); - - m_session->nominalSchema().createTable( pixel_columns ); - } - transactionCommit(); -} - -/** part of save(): create key table - */ -void PCDio::createAuxTables() -{ - transactionStartUpdate(); - string FK_TABLE = "CALIB_KEYGEN"; - if (!m_session->nominalSchema().existsTable(FK_TABLE)) { - coral::TableDescription key_columns( "SchemaDefinition_KEY" ); - key_columns.setName( FK_TABLE ); - key_columns.insertColumn( "KEY", coral::AttributeSpecification::typeNameForType<long long>()); - key_columns.createIndex ("KEY_INDEX", "KEY"); - m_session->nominalSchema().createTable( key_columns ); - // fill the first key - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - coral::AttributeList rowBuffer ATLAS_THREAD_SAFE; // Not shared, ok - rowBuffer.extend<long long>( "KEY" ); - long long& key = rowBuffer[ "KEY" ].data<long long>(); - key = 1000; - keyeditor.insertRow( rowBuffer ); - } - transactionCommit(); -} - -/** part of save(): update the key - */ -long long PCDio::updateKey() -{ - std::string FK_TABLE = "CALIB_KEYGEN"; - transactionStartUpdate(); - - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - std::string updateAction = "KEY = KEY + :offset"; - coral::AttributeList updateData ATLAS_THREAD_SAFE; // Not shared, ok - updateData.extend<long long>("offset"); - updateData[0].data<long long>() = 1; - keyeditor.updateRows( updateAction, "", updateData ); - - coral::IQuery* query = m_session->nominalSchema().tableHandle(FK_TABLE).newQuery(); - query->addToOutputList("KEY"); - coral::ICursor& cursor = query->execute(); - long long key = -1; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - key = row0[0].data<long long>(); - if (m_verbose) std::cout << " KEY = " << key << std::endl; - } - transactionCommit(); - return key; -} - -/** CORAL helper to start a transaction in readonly mode - */ -void PCDio::transactionStartReadOnly(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(true /*ReadOnly*/); -} - -/** CORAL helper to start a transaction in update mode - */ -void PCDio::transactionStartUpdate(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(false /*update*/); -} - -/** CORAL helper to commit changes at the end of a transaction - */ -void PCDio::transactionCommit(){ - if (m_session->transaction().isActive()) m_session->transaction().commit(); -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDkr.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDkr.cc deleted file mode 100644 index 8acd6984d1c..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PCDkr.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PCDkr.h" -#include "PixelCoralClientUtils/PixelCalibData.hh" - -// CORAL API -#include "CoralKernel/Context.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/AttributeListException.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/IConnectionServiceConfiguration.h" -#include "RelationalAccess/AccessMode.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ITransaction.h" - -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDescription.h" -#include "RelationalAccess/IColumn.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/IQuery.h" -#include "RelationalAccess/TableDescription.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/ITableSchemaEditor.h" -#include "RelationalAccess/IBulkOperation.h" -#include "RelationalAccess/SchemaException.h" - -// std lib -#include <iostream> -using namespace std; - -//--------------------------------------------------------------------------- -/** Constructor. - Open the default database and seal context. - */ -PCDkr::PCDkr(const std::string& connString, - const std::string& tableName, - int verbose) : - m_connString(connString), m_pixeltable(tableName), - m_verbose(verbose), m_session(0) {} - -PCDkr::~PCDkr() -{ - if (m_verbose) cout << "Disconnecting \"" << m_connString << "\"" << endl; - delete m_session; -} - -/** initialize connection - */ -void PCDkr::init(coral::AccessMode access_mode) -{ - if (m_verbose) cout << "Creating Connection Service to \"" << m_connString << "\"" << endl; - - coral::Context* context = &coral::Context::instance(); - coral::IHandle<coral::IConnectionService> lookSvcH = context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - context->loadComponent("CORAL/Services/ConnectionService"); - lookSvcH = context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw runtime_error("Could not locate the connection service"); - } - - m_session = lookSvcH->connect(m_connString, access_mode); - if (m_verbose) cout << "Connection established" << endl; -} - -/** dump DB - */ -void PCDkr::load() -{ - // start timer - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - transactionStartReadOnly(); - - // build a query - coral::IQuery* query = m_session->nominalSchema().tableHandle(m_pixeltable).newQuery(); - - query->addToOutputList("TAG"); - query->defineOutputType("TAG",coral::AttributeSpecification::typeNameForType<string>()); - query->addToOutputList("CID"); - query->defineOutputType("CID",coral::AttributeSpecification::typeNameForType<string>()); - query->addToOutputList("VALID"); - query->defineOutputType("VALID",coral::AttributeSpecification::typeNameForType<int>()); - - coral::ICursor& cursor = query->execute(); - - // go through the list of found tables - int nRows = 0; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - if (m_verbose) { - cout << " TAG = " << row0[0].data<string>() - << " CID = " << row0[1].data<string>() - << " VALID = " << row0[2].data<int>() << endl; - } - ++nRows; - } - delete query; - - transactionCommit(); - - if (m_verbose) cout << "Total configurations: " << nRows << endl; - - // stop timer - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) cout << " Total time was " << total_usecs << " usec" << endl; -} - -/** add a new record to DB - */ -void PCDkr::save(const std::string& tag, const std::string& cid) -{ - // start timer - struct timeval start_time, end_time; - int total_usecs; - gettimeofday(&start_time, NULL); - - // create tables if needed - createTable(); - - transactionStartUpdate(); - - // fill header - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle(m_pixeltable ).dataEditor(); - - coral::AttributeList pixel_row; - pixel_row.extend<std::string>("TAG"); - pixel_row.extend<std::string>("CID"); - pixel_row.extend<int>("VALID"); - - pixel_row["TAG"].data<std::string>() = tag; - pixel_row["CID"].data<std::string>() = cid; - pixel_row["VALID"].data<int>() = 0; - - pixel_editor.insertRow(pixel_row); - transactionCommit(); - - // stop timer - gettimeofday(&end_time, NULL); - total_usecs = (end_time.tv_sec-start_time.tv_sec) * 1000000 + - (end_time.tv_usec-start_time.tv_usec); - if (m_verbose) cout << " Total time was " << total_usecs << " usec" << endl; -} - -/** part of save(): create the table - */ -void PCDkr::createTable() -{ - // create header - transactionStartUpdate(); - if (!m_session->nominalSchema().existsTable(m_pixeltable)) { - if (m_verbose) cout << "creating " << m_pixeltable << endl; - coral::TableDescription pixel_columns( "SchemaDefinition_KR" ); - pixel_columns.setName( m_pixeltable ); - pixel_columns.insertColumn("TAG", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - pixel_columns.insertColumn("CID", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - pixel_columns.insertColumn( "VALID", coral::AttributeSpecification::typeNameForType<int>()); - pixel_columns.setPrimaryKey("TAG"); - m_session->nominalSchema().createTable( pixel_columns ); - } - transactionCommit(); -} - -/** validate a record - example: Integration_Basic/src/DmlOperations.cpp - */ -void PCDkr::validate(const std::string& tag) -{ - transactionStartUpdate(); - - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle(m_pixeltable ).dataEditor(); - - string updateAction = "VALID = 1"; - string updateCondition = "TAG = :tvalue"; - coral::AttributeList updateData; - updateData.extend<std::string>("tvalue"); - updateData[0].data<std::string>() = tag; - - int nRows = pixel_editor.updateRows(updateAction,updateCondition,updateData); - cout << "Updated rows: " << nRows << endl; - transactionCommit(); -} - -/** CORAL helper to start a transaction in readonly mode - */ -void PCDkr::transactionStartReadOnly(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(true /*ReadOnly*/); -} - -/** CORAL helper to start a transaction in update mode - */ -void PCDkr::transactionStartUpdate(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(false /*update*/); -} - -/** CORAL helper to commit changes at the end of a transaction - */ -void PCDkr::transactionCommit(){ - if (m_session->transaction().isActive()) m_session->transaction().commit(); -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibCoralCoolDb.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibCoralCoolDb.cc deleted file mode 100644 index 0fcfe824b3e..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibCoralCoolDb.cc +++ /dev/null @@ -1,270 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PixCalibCoralCoolDb.h" - -// CoraCool stuff -- A.X. -#include "CoraCool/CoraCoolDatabaseSvcFactory.h" -#include "CoraCool/CoraCoolDatabaseSvc.h" -#include "CoolKernel/IDatabaseSvc.h" -#include "CoolKernel/ChannelSelection.h" -#include "CoraCool/CoraCoolFolder.h" -#include "CoraCool/CoraCoolObjectIter.h" -#include "CoraCool/CoraCoolObject.h" - -#include "CxxUtils/checker_macros.h" - -// std lib -#include <fstream> -#include <iostream> -#include <sstream> -#include <vector> -using namespace std; - -// -// this code is based on CoraCoolExample by R. Hawkings -// -PixCalibCoralCoolDb::PixCalibCoralCoolDb(const std::string& dbString, - int /*verbose*/) : - m_dbstring(dbString) -{ - - CoraCoolDatabaseSvc& corasvc=CoraCoolDatabaseSvcFactory::databaseService(); - - //std::cout << "Done the CoraCool initialisation" << std::endl; - - // open the CORAL database connection which implicitly opens - // the corresponding COOL connection - // you can also pass in the COOL connection explicitly - // std::cout << "Opening CORAL database" << std::endl; - try { - m_coradb=corasvc.openDatabase(m_dbstring,false); - //std::cout << "Database connections open OK" << std::endl; - } - catch (std::exception&e) { - std::cout << "Problem opening CORAL database: " << e.what() << std::endl; - } - //std::cout << "Done the database opening" << std::endl; - -} - -PixCalibCoralCoolDb::~PixCalibCoralCoolDb() -{ -} - -bool PixCalibCoralCoolDb::init() -{ - // open the database connection, move to constructor - // if (m_verbose) cout << "HEY HEY Connecting to " << m_dbstring << endl; - // CoraCoolDatabaseSvc& corasvc=CoraCoolDatabaseSvcFactory::databaseService(); - // try { - // m_coradb = corasvc.openDatabase(m_dbstring, readonly); - // } - // catch (std::exception& e) { - // cout << "problem opening database: " << e.what() << endl; - // return false; - // } - // if (m_verbose) cout << "Connection established" << endl; - - return true; -} - -bool PixCalibCoralCoolDb::load(cool::ValidityKey vkx) -{ - CoraCoolFolderPtr folder; - string folderName("/PIXEL/PixCalibData"); - - try { - folder = m_coradb->getFolder(folderName); - } - catch (cool::Exception& e) { - cout << "problem getting folder: " << e.what() << endl; - return false; - } - - // open text file for output - ofstream out("pcd.sav"); - int nload = 0; - - CoraCoolObjectIterPtr itr = folder->browseObjects(vkx, cool::ChannelSelection::all()); - while (itr->hasNext()) { - CoraCoolObjectPtr obj = itr->next(); - for (CoraCoolObject::const_iterator payitr = obj->begin(); - payitr != obj->end(); ++payitr) { - const coral::Blob& blob = (*payitr)["data"].data<coral::Blob>(); - const char* p = static_cast<const char*>(blob.startingAddress()); - unsigned int len = blob.size(); - for (unsigned int i = 0; i!=len; ++i) out << *p++; - } - ++nload; - } - out.close(); - cout << "loaded " << nload << " channels" << endl; - - return true; -} - -bool PixCalibCoralCoolDb::saveCalibData ( string textfile , long long FK ) -{ - cool::RecordSpecification payloadspec; - // primary / foreign keys - payloadspec.extend("PrimKey",cool::StorageType::Int32); - payloadspec.extend("ForeignKey",cool::StorageType::Int64); - // other data members - payloadspec.extend("data",cool::StorageType::Blob64k); - - cool::RecordSpecification fkspec; - fkspec.extend("CoolKey",cool::StorageType::Int64); - - string desc="<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"55403898\" /></addrHeader><typeName>AthenaAttributeList</typeName>"; - - string folderName("/PIXEL/PixCalibData"); - string cfolderName("PixCalibData"); - - CoraCoolFolderPtr folder; - - // delete existing folder, if any - bool do_delete = false; - if (do_delete && m_coradb->existsFolder(folderName)) { - try { - m_coradb->deleteFolder(folderName); - } - catch (cool::Exception& e) { - cout << "problem deleting folder: " << e.what() << endl; - return false; - } - } - - // create new folder or get the old one, if any - if (!m_coradb->existsFolder(folderName)) { - try { - folder = m_coradb->createFolder(folderName, cfolderName, - fkspec, payloadspec, "ForeignKey", "PrimKey", desc, - cool::FolderVersioning::MULTI_VERSION, true); - } - catch (cool::Exception& e) { - cout << "problem creating folder: " << e.what() << endl; - return false; - } - } else { - folder = m_coradb->getFolder(folderName); - } - - std::cout << "Succesfully opened/created folders!" << std::endl; - - // open text file for input - ifstream in(textfile.c_str() ); - if( !(in.is_open() ) ){ - cout << "calib-data file: " << textfile << " not found!" << endl; - return false; - } - //return error if textfile not found! - - string s; - int nsave = 0; - - string dataString; - while (in) { - getline(in,s); - if (in.eof()) break; - dataString += s + '\n'; - - for (int i = 0; i<16; ++i) { - getline(in,s); - dataString += s + '\n'; - } - ++nsave; - } - cout << "read " << nsave << " channels" << endl; - - // prepare data to save in the payload - // No sharing, ok. - coral::AttributeList data ATLAS_THREAD_SAFE = folder->emptyAttrList(); - data["PrimKey"].data<int>() = 0; - data["ForeignKey"].data<long long>() = FK; - coral::Blob& blob = data["data"].data<coral::Blob>(); - unsigned int len = dataString.size(); - blob.resize(len); - char* p = static_cast<char*>(blob.startingAddress()); - for (unsigned int i = 0; i!=len; ++i) *p++ = dataString[i]; - - vector<coral::AttributeList> datavec; - datavec.reserve(1); - datavec.push_back(data); - - try { - //store object and range of run-number - //folder->storeObject(vk1, vk2, datavec.begin(), datavec.end(), chan); - - //just add payload - folder->addPayload(datavec.begin(), datavec.end()); - } - catch (cool::Exception& e) { - cout << "problem writing data: " << e.what() << endl; - return false; - } - - return true; -} - -bool PixCalibCoralCoolDb::referenceToRunInterval(long long FK, cool::ValidityKey vk1,cool::ValidityKey vk2, const std::string& tagname) -{ - cool::RecordSpecification payloadspec; - // primary / foreign keys - payloadspec.extend("CoolKey",cool::StorageType::Int64); - payloadspec.extend("PrimKey",cool::StorageType::Int32); - // payloadspec.extend("ModuleID",cool::StorageType::Int64); - payloadspec.extend("data",cool::StorageType::String16M); - - cool::RecordSpecification fkspec; - fkspec.extend("CoolKey",cool::StorageType::Int64); - - string desc="<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"55403898\" /></addrHeader><typeName>AthenaAttributeList</typeName>"; - - string folderName("/PIXEL/PixCalibData"); - string cfolderName("PixCalibData"); - - CoraCoolFolderPtr folder; - - // delete existing folder, if any - bool do_delete = false; - if (do_delete && m_coradb->existsFolder(folderName)) { - try { - m_coradb->deleteFolder(folderName); - } - catch (cool::Exception& e) { - cout << "problem deleting folder: " << e.what() << endl; - return false; - } - } - - // create new folder or get the old one, if any - if (!m_coradb->existsFolder(folderName)) { - try { - folder = m_coradb->createFolder(folderName, cfolderName, - fkspec, payloadspec, "ForeignKey", "PrimKey", desc, - cool::FolderVersioning::MULTI_VERSION, true); - } - catch (cool::Exception& e) { - cout << "problem creating folder: " << e.what() << endl; - return false; - } - } else { - folder = m_coradb->getFolder(folderName); - } - - //set the run-interval for the given foreign-key... - cool::ChannelId chan(0); - try { - folder->referenceObject(vk1, vk2, FK, chan, tagname); - } - catch (cool::Exception& e) { - cout << "problem when associating run-interval : " << e.what() << endl; - return false; - } - - cout << "saved runInterval (FK=" << FK << ") " << endl; - - return true; -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibKnowledgeDb.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibKnowledgeDb.cc deleted file mode 100644 index e30b2e2f114..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/PixCalibKnowledgeDb.cc +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PixCalibKnowledgeDb.h" - -#include "CxxUtils/checker_macros.h" - -// CORAL API -#include "CoralKernel/Context.h" -#include "CoralBase/Attribute.h" -#include "CoralBase/AttributeList.h" -#include "CoralBase/AttributeListException.h" -#include "RelationalAccess/IConnectionService.h" -#include "RelationalAccess/IConnectionServiceConfiguration.h" -#include "RelationalAccess/AccessMode.h" -#include "RelationalAccess/ISessionProxy.h" -#include "RelationalAccess/ISchema.h" -#include "RelationalAccess/ITransaction.h" - -#include "RelationalAccess/ITable.h" -#include "RelationalAccess/ITableDescription.h" -#include "RelationalAccess/IColumn.h" -#include "RelationalAccess/ICursor.h" -#include "RelationalAccess/IQuery.h" -#include "RelationalAccess/TableDescription.h" -#include "RelationalAccess/ITableDataEditor.h" -#include "RelationalAccess/ITableSchemaEditor.h" -#include "RelationalAccess/IBulkOperation.h" -#include "RelationalAccess/SchemaException.h" - -// std lib -#include <fstream> -#include <iostream> -#include <vector> -#include <set> -using namespace std; - -//--------------------------------------------------------------------------- -/** Constructor. - Open the default database and seal context. - */ -PixCalibKnowledgeDb::PixCalibKnowledgeDb(const std::string& connString, - const std::string& tableName, - int verbose) : - m_connString(connString), m_pixeltable(tableName), - m_verbose(verbose), m_session(0) {} - -PixCalibKnowledgeDb::~PixCalibKnowledgeDb() -{ - if (m_verbose) cout << "Disconnecting \"" << m_connString << "\"" << endl; - delete m_session; -} - -/** initialize connection - */ -void PixCalibKnowledgeDb::init(coral::AccessMode access_mode) -{ - if (m_verbose) cout << "Creating Connection Service to \"" << m_connString << "\"" << endl; - coral::Context* context = &coral::Context::instance(); - coral::IHandle<coral::IConnectionService> lookSvcH = context->query<coral::IConnectionService>(); - if (!lookSvcH.isValid()) { - context->loadComponent("CORAL/Services/ConnectionService"); - lookSvcH = context->query<coral::IConnectionService>(); - } - if (!lookSvcH.isValid()) { - throw runtime_error("Could not locate the connection service"); - } - - m_session = lookSvcH->connect(m_connString, access_mode); - if (m_verbose) cout << "Connection established" << endl; -} - -void PixCalibKnowledgeDb::saveCorrespondingConfig -(long int UNIXTimeInSeconds, long int RunNumber, const std::string& calibtags_in_string, const std::string& idTag, const std::string& connTag, const std::string& cfgTag, const std::string& cfgModTag ) -{ - - // create tables if needed - createTable(); - - // get a new unique foreign key - long long fk = updateKey(); - if( fk == -1 ) std::cout << "failed to get unique key?!" << std::endl; - - transactionStartUpdate(); - - //fill config - transactionStartUpdate(); - - coral::ITableDataEditor& pixel_editor = m_session->nominalSchema().tableHandle("CALIB_TAGS").dataEditor(); - - coral::AttributeList pixel_row ATLAS_THREAD_SAFE; // Not shared, ok. - pixel_row.extend<long int>("UNIXTimeInSeconds"); - pixel_row.extend<long int>("RunNumber"); - pixel_row.extend<std::string>("calibrationTags"); - pixel_row.extend<std::string>("idTag"); - pixel_row.extend<std::string>("connTag"); - pixel_row.extend<std::string>("cfgTag"); - pixel_row.extend<std::string>("cfgModTag"); - pixel_row.extend<long long>("FK"); - - // string idtag = "PIXEL"; - // string conntag = "PIT-ALL-V36"; - // string cfgTag = "PIT-20C-OLD"; - // int cfgRev = 0; - // string cfgModTag = "PIT_MOD_MIXED_3000e"; - // int cfgModRev = 0; - - pixel_row["UNIXTimeInSeconds"].data<long int>() = UNIXTimeInSeconds; - pixel_row["RunNumber"].data<long int>() = RunNumber; - pixel_row["calibrationTags"].data<std::string>() = calibtags_in_string; - pixel_row["idTag"].data<std::string>() = idTag; - pixel_row["connTag"].data<std::string>() = connTag; - pixel_row["cfgTag"].data<std::string>() = cfgTag; - pixel_row["cfgModTag"].data<std::string>() = cfgModTag; - pixel_row["FK"].data<long long>() = fk; - - pixel_editor.insertRow(pixel_row); - transactionCommit(); - std::cout << "done saving corresponding config" << std::endl; -} - -//for reading back calibrationTags corresponding to a given time, not sure if this is needed -void PixCalibKnowledgeDb::readCorrespondingCalibTag (long int Utime){ - - transactionStartReadOnly(); - //build a query - coral::IQuery* query = m_session->nominalSchema().tableHandle("CALIB_TAGS").newQuery(); - - query->addToOutputList("UNIXTimeInSeconds"); - query->defineOutputType("UNIXTimeInSeconds",coral::AttributeSpecification::typeNameForType<long int>()); - query->addToOutputList("calibrationTags"); - query->defineOutputType("calibrationTags",coral::AttributeSpecification::typeNameForType<string>()); - - coral::AttributeList pixel_knowledgeData ATLAS_THREAD_SAFE; // Not shared, ok - string pixel_knowledge = "CALIB_TAGS.UNIXTimeInSeconds <= :Utime"; - pixel_knowledgeData.extend<long int>("Utime"); - pixel_knowledgeData[0].data<long int>() = Utime; - - query->setCondition( pixel_knowledge, pixel_knowledgeData); - - coral::ICursor& cursor = query->execute(); - - // long long foreignkey = -1; - string calibtags = "" ; - long int Utime_h = -99999999; - - // go through list of found tables, highest Utime has the correct calibTag-set - - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - long int UNIXTimeInSeconds = row0[0].data<long int>(); - string calibrationTags = row0[1].data<string>(); - if( Utime_h <= UNIXTimeInSeconds ){ -// cout << " UNIXTimeInSeconds = " << UNIXTimeInSeconds -// << " calibrationTags = " << calibrationTags << endl; - Utime_h = UNIXTimeInSeconds; - calibtags = calibrationTags; - } - } - delete query; - - // if( foreignkey != -1 ) calibtag = findTag(foreignkey); - - if( calibtags == "" ){ - cout << " corresponding calibration-tags not found!" << endl; - } - else { - std::cout << "UNIXTimeInSeconds " << Utime << " corresponds to the following calibration-tags:\n" << calibtags << std::endl; - } - transactionCommit(); - -} - -/** part of save(): create new tables - */ -void PixCalibKnowledgeDb::createTable () -{ - createConfigurationTable(); - createAuxTables(); -} - -/** part of save(): create config-tags table - */ -void PixCalibKnowledgeDb::createConfigurationTable() -{ - // create header - transactionStartUpdate(); - string PIXEL_TABLE_CFG = "CALIB_TAGS"; - if (!m_session->nominalSchema().existsTable(PIXEL_TABLE_CFG)) { - if (m_verbose) cout << "creating " << PIXEL_TABLE_CFG << endl; - coral::TableDescription cfg_columns( "SchemaDefinition_PIXEL_CFG" ); - cfg_columns.setName( PIXEL_TABLE_CFG ); - cfg_columns.insertColumn("UNIXTimeInSeconds", coral::AttributeSpecification::typeNameForType<long int>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn( "RunNumber", coral::AttributeSpecification::typeNameForType<long long>()); - cfg_columns.insertColumn("calibrationTags", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn("idTag", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn("connTag", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn("cfgTag", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn("cfgModTag", coral::AttributeSpecification::typeNameForType<std::string>(), /*size in BYTES = */ 1000, /*fixed_size=*/ false); - cfg_columns.insertColumn( "FK", coral::AttributeSpecification::typeNameForType<long long>()); - m_session->nominalSchema().createTable( cfg_columns ); - } - transactionCommit(); -} - -/** part of save(): create key table - */ -void PixCalibKnowledgeDb::createAuxTables() -{ - transactionStartUpdate(); - string FK_TABLE = "CALIB_KEYGEN"; - if (!m_session->nominalSchema().existsTable(FK_TABLE)) { - coral::TableDescription key_columns( "SchemaDefinition_KEY" ); - key_columns.setName( FK_TABLE ); - key_columns.insertColumn( "KEY", coral::AttributeSpecification::typeNameForType<long long>()); - key_columns.createIndex ("KEY_INDEX", "KEY"); - m_session->nominalSchema().createTable( key_columns ); - // fill the first key - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - coral::AttributeList rowBuffer ATLAS_THREAD_SAFE; // Not shared, ok. - rowBuffer.extend<long long>( "KEY" ); - long long& key = rowBuffer[ "KEY" ].data<long long>(); - key = 1000; - keyeditor.insertRow( rowBuffer ); - } - transactionCommit(); -} - -/** part of save(): update the key - */ -long long PixCalibKnowledgeDb::updateKey() -{ - std::string FK_TABLE = "CALIB_KEYGEN"; - transactionStartUpdate(); - - coral::ITableDataEditor& keyeditor = m_session->nominalSchema().tableHandle( FK_TABLE ).dataEditor(); - std::string updateAction = "KEY = KEY + :offset"; - coral::AttributeList updateData ATLAS_THREAD_SAFE; // Not shared, ok. - updateData.extend<long long>("offset"); - updateData[0].data<long long>() = 1; - keyeditor.updateRows( updateAction, "", updateData ); - - coral::IQuery* query = m_session->nominalSchema().tableHandle(FK_TABLE).newQuery(); - query->addToOutputList("KEY"); - coral::ICursor& cursor = query->execute(); - long long key = -1; - while ( cursor.next() ) { - const coral::AttributeList &row0 = cursor.currentRow(); - key = row0[0].data<long long>(); - if (m_verbose) std::cout << " KEY = " << key << std::endl; - } - transactionCommit(); - return key; -} - -/** CORAL helper to start a transaction in readonly mode - */ -void PixCalibKnowledgeDb::transactionStartReadOnly(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(true /*ReadOnly*/); -} - -/** CORAL helper to start a transaction in update mode - */ -void PixCalibKnowledgeDb::transactionStartUpdate(){ - if (m_session->transaction().isActive()) m_session->transaction().rollback(); - m_session->transaction().start(false /*update*/); -} - -/** CORAL helper to commit changes at the end of a transaction - */ -void PixCalibKnowledgeDb::transactionCommit(){ - if (m_session->transaction().isActive()) m_session->transaction().commit(); -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/SpecialPixelMap.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/SpecialPixelMap.cc deleted file mode 100644 index 4107349e998..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/SpecialPixelMap.cc +++ /dev/null @@ -1,1751 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -//**************************************************************************** -// SpecialPixelMap.cxx -// -// Classes to hold data about special pixels in the detector store and make it -// accessible to athena components. -// -// author Christoph Ruwiedel <ruwiedel@physik.uni-bonn.de> -// updated to be comptible with IBL and phase II: -- Wei-Ming Yao <wmyao@lbl.gov> - - -#include "PixelCoralClientUtils/SpecialPixelMap.hh" - -#include<fstream> -#include<sstream> -#include<string> -#include<iomanip> -#include<stdint.h> -#include<cmath> - - -namespace PixelCoralClientUtils { - -//***** DetectorSpecialPixelMap *****// - -//===== Constructors, Destructor =====// - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(){} - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(const DetectorSpecialPixelMap& spm) : - std::vector<ModuleSpecialPixelMap*>(){ - - for(DetectorSpecialPixelMap::const_iterator module = spm.begin(); module != spm.end(); ++module){ - - push_back(new ModuleSpecialPixelMap(**module)); - - } -} - -DetectorSpecialPixelMap::DetectorSpecialPixelMap(const std::vector<ModuleSpecialPixelMap*>& modules){ - - for(std::vector<ModuleSpecialPixelMap*>::const_iterator module = modules.begin(); module != modules.end(); ++module){ - - push_back(new ModuleSpecialPixelMap(**module)); - - } -} - -void DetectorSpecialPixelMap::clear(){ - - for(const_iterator module = begin(); module != end(); ++module){ - delete *module; - } - std::vector<ModuleSpecialPixelMap*>::clear(); -} - -DetectorSpecialPixelMap::~DetectorSpecialPixelMap(){ - for(const_iterator module = begin(); module != end(); ++module){ - delete *module; - } -} - - -//===== member functions =====// - -const ModuleSpecialPixelMap* DetectorSpecialPixelMap::module(unsigned int moduleHash) const{ - return (*this)[moduleHash]; -} - - -DetectorSpecialPixelMap& DetectorSpecialPixelMap::operator=(const DetectorSpecialPixelMap& spm){ - if(&spm != this){ - for(const_iterator module = begin(); module != end(); ++module){ - delete *module; - } - - resize(spm.size()); - - for(DetectorSpecialPixelMap::const_iterator module = spm.begin(); module != spm.end(); ++module){ - (*this)[module - spm.begin()] = new ModuleSpecialPixelMap(**module); - } - } - return *this; -} - -DetectorSpecialPixelMap& DetectorSpecialPixelMap::operator+=(const DetectorSpecialPixelMap& spm){ - if(&spm != this){ - - if(size() != spm.size()){ - std::cout << "Unable to merge special pixel maps: sizes do not match" << std::endl; - - return *this; - } - - for(DetectorSpecialPixelMap::const_iterator module = spm.begin(); module != spm.end(); ++module){ - if( (*this)[module - spm.begin()] == 0 && (*module) != 0 ){ - (*this)[module - spm.begin()] = new ModuleSpecialPixelMap( **module ); - } - else if( (*module) != 0 ){ - (*this)[module - spm.begin()]->merge(*module); - } - } - } - return *this; -} - -void DetectorSpecialPixelMap::merge(const DetectorSpecialPixelMap* spm){ - (*this) += (*spm); - return; -} - -void DetectorSpecialPixelMap::markSpecialRegions(){ - for(DetectorSpecialPixelMap::iterator module = begin(); module != end(); ++module){ - (*module)->markSpecialRegions(); - } - return; -} - -void DetectorSpecialPixelMap::setNeighbourFlags(){ - for(DetectorSpecialPixelMap::iterator module = begin(); module != end(); ++module){ - (*module)->setNeighbourFlags(); - } - return; -} - - - -//***** ModuleSpecialPixelMap *****// - -//===== Constructors, Destructor =====// - -ModuleSpecialPixelMap::ModuleSpecialPixelMap() : - m_chipsPerModule(0), - m_module_status(0) -{} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const ModuleSpecialPixelMap& mspm) : - std::map<unsigned int, unsigned int>(mspm), - m_chipsPerModule(mspm.m_chipsPerModule), - m_module_status(mspm.m_module_status), - m_chip_status(mspm.m_chip_status), - m_column_pair_status(mspm.m_column_pair_status) -{} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const char* filename, unsigned int mchips) : - m_chipsPerModule(mchips), - m_module_status(0) -{ - std::ifstream in(filename, std::ios_base::in); - //std::string ssink; - //std::getline(in, ssink); - - while(in.good()){ - unsigned int chip, column, row, status; - in >> chip >> column >> row >> status; - - if(in.good()){ - if(validPixelID(chip, column, row)){ - //do not record pixels that are listed as "unknown dead" and nothing else - if((status & ~((15 << 25) + (1 << 16))) != 0){ - //mark pixels as "unknown dead" if they are dead but we don't know why - if((status % 2 == 1) && ((status & (255 << 8)) == 0)){ - setPixelStatus(encodePixelID(chip, column, row, m_chipsPerModule), status |= (1 << 16)); - } - else{ - setPixelStatus(encodePixelID(chip, column, row, m_chipsPerModule), status); - } - } - } - else{ - std::cout << "In ModuleSpecialPixelMap::ModuleSpecialPixelMap(const char*) :" - << " Invalid pixel ID read from text file" << std::endl; - } - } - } - - setNeighbourFlags(); -} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const std::string& clob, unsigned int mchips) : - m_chipsPerModule(mchips), - m_module_status(0) -{ - bool statuscode = fill_from_string(clob); - if( statuscode ){ - std::cout << "In ModuleSpecialPixelMap::ModuleSpecialPixelMap(const std::string&) :" - << " Construction from clob failed" << std::endl; - } -} - - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const coral::Blob& blob, unsigned int mchips) : - m_chipsPerModule(mchips), - m_module_status(0) -{ - bool statuscode = fill_from_blob(blob); - if(statuscode){ - std::cout << "In ModuleSpecialPixelMap::ModuleSpecialPixelMap(const coral::Blob&) :" - << " Construction from blob failed" << std::endl; - } -} - -ModuleSpecialPixelMap::ModuleSpecialPixelMap(const std::map<unsigned int, unsigned int>& pixels, - unsigned int module_status, - const std::vector<unsigned int>& chip_status, - const std::vector<std::vector<unsigned int> >& column_pair_status, - unsigned int mchips) : - std::map<unsigned int, unsigned int>(pixels), - m_chipsPerModule(mchips), - m_module_status(module_status), - m_chip_status(chip_status), - m_column_pair_status(column_pair_status) -{ -} - -ModuleSpecialPixelMap::~ModuleSpecialPixelMap(){} - - -//===== public member functions =====// - - -ModuleSpecialPixelMap& ModuleSpecialPixelMap::operator=(const ModuleSpecialPixelMap& mspm){ - if(&mspm != this){ - std::map<unsigned int, unsigned int>::operator=(mspm); - m_module_status = mspm.m_module_status; - m_chip_status = mspm.m_chip_status; - m_column_pair_status = mspm.m_column_pair_status; - m_chipsPerModule = mspm.m_chipsPerModule; - } - return *this; -} - -ModuleSpecialPixelMap& ModuleSpecialPixelMap::operator+=(ModuleSpecialPixelMap mspm){ - - if(mspm.moduleStatus() != 0 || mspm.hasSpecialChips() || mspm.hasSpecialColumnPairs() || !mspm.empty()){ - - mspm.resetSpecialRegions(); - resetSpecialRegions(); - - for(ModuleSpecialPixelMap::const_iterator pixel = mspm.begin(); pixel != mspm.end(); ++pixel){ - (*this)[(*pixel).first] |= (*pixel).second; - } - - markSpecialRegions(); - setNeighbourFlags(); - } - - return *this; -} - -void ModuleSpecialPixelMap::merge(const ModuleSpecialPixelMap* mspm){ - (*this) += (*mspm); - return; -} - -unsigned int ModuleSpecialPixelMap::pixelStatus(unsigned int pixelID) const{ - int i = (int)chipType(); - int mch = (int)chipsPerModule(); - int mcolumns =(int)columnsPerChip(); - int mrowsrdo = (int)rowsrdoPerChip(); - - int chip = pixelID % 16; - int column = (i==0) ? ((pixelID / 16) % 32) : ((pixelID / 16) % 256); - int row = (i==0) ? (pixelID / 512) : (pixelID / 4096); - - if(mch>2){ - - if(m_module_status != 0){ - unsigned int status = m_module_status; - if(column != 0 || (chip != 0 && chip != mch/2)){ // left - status |= (1 << 27); - } - if(column != (mcolumns -1) || (chip != (mch/2 - 1) && chip != (mch - 1))){ // right - status |= (1 << 28); - } - status |= (1 << 26); // top - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(m_chip_status.size() != 0 && m_chip_status[chip] != 0){ - - unsigned int status = m_chip_status[chip]; - ModuleSpecialPixelMap::const_iterator pixel; - - if(column != 0){ // left - status |= (1 << 27); - } - else if(column == 0 && chip != 0 && chip != mch/2){ - pixel = find(encodePixelID(chip - 1, (mcolumns-1), row, m_chipsPerModule)); - if(m_chip_status[chip-1] != 0){ - status |= (1 << 27); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip - 1].size() != 0 - && m_column_pair_status[chip - 1][mcolumns/2 - 1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - - if(column != (mcolumns -1)){ // right - status |= (1 << 28); - } - else if(column == (mcolumns-1) && chip != (mch/2 - 1) && chip != (mch - 1)){ - pixel = find(encodePixelID(chip + 1, 0, row, m_chipsPerModule)); - if(m_chip_status[chip + 1] != 0){ - status |= (1 << 28); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip + 1].size() != 0 - && m_column_pair_status[chip + 1][0] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - - if(row != (mrowsrdo - 1)){ // top - status |= (1 << 26); - } - else if(row == (mrowsrdo - 1)){ - pixel = find(encodePixelID(mch-1- chip, mcolumns-1- column, row, m_chipsPerModule)); - if(m_chip_status[mch-1 - chip] != 0){ - status |= (1 << 26); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[mch - 1 - chip].size() != 0 - && m_column_pair_status[mch - 1 - chip][(mcolumns - 1 - column) / 2] != 0){ - status |= (1 << 26); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 26); - } - } - } - - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip].size() != 0 - && m_column_pair_status[chip][column / 2] != 0){ - unsigned int status = m_column_pair_status[chip][column / 2]; - ModuleSpecialPixelMap::const_iterator pixel; - - if(column % 2 != 0){ // left - status |= (1 << 27); - } - else if(column % 2 == 0 && column != 0){ - pixel = find(encodePixelID(chip, column - 1, row, m_chipsPerModule)); - if(m_column_pair_status[chip][column / 2 - 1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - else if(column == 0 && chip != 0 && chip != mch/2){ - pixel = find(encodePixelID(chip - 1, mcolumns - 1, row, m_chipsPerModule)); - if(m_chip_status.size() != 0 && m_chip_status[chip - 1] != 0){ - status |= (1 << 27); - } - else if(m_column_pair_status[chip - 1].size() != 0 - && m_column_pair_status[chip - 1][mcolumns/2 - 1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - - if(column % 2 == 0){ // right - status |= (1 << 28); - } - else if(column % 2 != 0 && column != (mcolumns -1)){ - pixel = find(encodePixelID(chip, column + 1, row, m_chipsPerModule)); - if(m_column_pair_status[chip][(column / 2) + 1] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - else if(column == (mcolumns-1) && chip != (mch/2-1) && chip != (mch-1)){ - pixel = find(encodePixelID(chip + 1, 0, row, m_chipsPerModule)); - if(m_chip_status.size() != 0 && m_chip_status[chip + 1] != 0){ - status |= (1 << 28); - } - else if(m_column_pair_status[chip + 1].size() != 0 - &&m_column_pair_status[chip + 1][0] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - - if(row != (mrowsrdo - 1)){ // top - status |= (1 << 26); - } - else if(row == (mrowsrdo-1)){ - pixel = find(encodePixelID(mch-1 - chip, mcolumns-1 - column, mrowsrdo-1, m_chipsPerModule)); - if(m_chip_status.size() != 0 && m_chip_status[mch-1 - chip] != 0){ - status |= (1 << 26); - } - else if(m_column_pair_status[mch-1 - chip].size() != 0 - && m_column_pair_status[mch-1 - chip][(mcolumns-1 - column) / 2] != 0){ - status |= (1 << 26); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 26); - } - } - } - - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(empty()){ - return 0; - } - else{ - const_iterator pixel = find(pixelID); - if(pixel == end()){ - return 0; - } - else{ - return (*pixel).second; - } - } - } - else { // IBL modules - - if(m_module_status != 0){ - unsigned int status = m_module_status; - if(column != 0 || (chip != 0)){ // left - status |= (1 << 27); - } - if(column != (mcolumns-1) || (chip != 1&&mch==2)){ // right - status |= (1 << 28); - } - if(row != (mrowsrdo-1))status |= (1 << 26); // top - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(m_chip_status.size() != 0 && m_chip_status[chip] != 0){ - - unsigned int status = m_chip_status[chip]; - ModuleSpecialPixelMap::const_iterator pixel; - - if(column != 0){ // left - status |= (1 << 27); - } - else if(column == 0 && chip != 0&&mch==2){ - pixel = find(encodePixelID(chip - 1, mcolumns-1, row, m_chipsPerModule)); - if(m_chip_status[chip-1] != 0){ - status |= (1 << 27); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip - 1].size() != 0 - && m_column_pair_status[chip - 1][mcolumns/2 - 1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - - if(column != (mcolumns - 1) ){ // right - status |= (1 << 28); - } - else if(column == (mcolumns - 1) && chip != 1 &&mch==2){ - pixel = find(encodePixelID(chip + 1, 0, row,m_chipsPerModule)); - if(m_chip_status[chip + 1] != 0){ - status |= (1 << 28); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip + 1].size() != 0 - && m_column_pair_status[chip + 1][0] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - - if(row != (mrowsrdo-1)){ // top - status |= (1 << 26); - } - - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip].size() != 0 - && m_column_pair_status[chip][column / 2] != 0){ - unsigned int status = m_column_pair_status[chip][column / 2]; - ModuleSpecialPixelMap::const_iterator pixel; - - if(column % 2 != 0){ // left - status |= (1 << 27); - } - else if(column % 2 == 0 && column != 0){ - pixel = find(encodePixelID(chip, column - 1, row, m_chipsPerModule)); - if(m_column_pair_status[chip][(column / 2) - 1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - else if(column == 0 && chip != 0 && mch==2){ - pixel = find(encodePixelID(chip - 1, (mcolumns-1), row, m_chipsPerModule)); - if(m_chip_status.size() != 0 && m_chip_status[chip - 1] != 0){ - status |= (1 << 27); - } - else if(m_column_pair_status[chip - 1].size() != 0 - && m_column_pair_status[chip - 1][mcolumns/2-1] != 0){ - status |= (1 << 27); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 27); - } - } - } - - if(column % 2 == 0){ // right - status |= (1 << 28); - } - else if(column % 2 != 0 && column != (mcolumns-1)){ - pixel = find(encodePixelID(chip, column + 1, row, m_chipsPerModule)); - if(m_column_pair_status[chip][(column / 2) + 1] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - else if(column == (mcolumns-1) && chip != 1 && mch==2){ - pixel = find(encodePixelID(chip + 1, 0, row, m_chipsPerModule)); - if(m_chip_status.size() != 0 && m_chip_status[chip + 1] != 0){ - status |= (1 << 28); - } - else if(m_column_pair_status[chip + 1].size() != 0 - &&m_column_pair_status[chip + 1][0] != 0){ - status |= (1 << 28); - } - else if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - status |= (1 << 28); - } - } - } - - if(row != (mrowsrdo-1)){ // top - status |= (1 << 26); - } - if(row != 0){ // bottom - status |= (1 << 25); - } - return status; - } - else if(empty()){ - return 0; - } - else{ - const_iterator pixel = find(pixelID); - if(pixel == end()){ - return 0; - } - else{ - return (*pixel).second; - } - } - } -} - -bool ModuleSpecialPixelMap::pixelStatusBit(unsigned int pixelID, unsigned int bit) const{ - if(bit < 32){ - unsigned int status = pixelStatus(pixelID); - return static_cast<bool>(status & (1u << bit)); - } - else { - std::cout << "Requested bit " << bit << " out of range ([0,31] allowed)" << std::endl; - } - return false; -} - -std::string ModuleSpecialPixelMap::to_string() const{ - - std::ostringstream clob(std::ios::binary); - - clob << m_module_status << ' '; - - unsigned int specialRegionsStatus = 0; - int mch =(int)chipsPerModule(); - int mcolumns = (int)columnsPerChip()/2; - - for(int i = 0; i < mch; i++){ - if(m_chip_status.size() != 0 && m_chip_status[i] != 0){ - specialRegionsStatus |= (1 << i); - } - for(int j = 0; j < mcolumns; j++){ - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0 - && m_column_pair_status[i][j] != 0){ - specialRegionsStatus |= (1 << (i+mch)); - } - } - } - - clob << specialRegionsStatus << ' '; - - for(int i = 0; i < mch; i++){ - if((specialRegionsStatus & (1 << i)) != 0){ - clob << m_chip_status[i] << ' '; - } - if((specialRegionsStatus & (1 << (i+mch))) != 0){ - for(int j = 0; j < mcolumns; j++){ - clob << m_column_pair_status[i][j] << ' '; - } - } - } - - for(const_iterator mi = begin(); mi != end(); ++mi){ - clob << mi->first << ' ' << mi->second << ' '; - } - return clob.str(); -} - - -coral::Blob* ModuleSpecialPixelMap::to_blob() const{ - - unsigned int specialRegionsStatus = 0; - unsigned int specialRegionsSize = 0; - int mch =(int)chipsPerModule(); - int mcolumns = (int)columnsPerChip()/2; - - for(int i = 0; i < mch; i++){ - if(m_chip_status.size() != 0 && m_chip_status[i] != 0){ - specialRegionsStatus |= (1 << i); - ++specialRegionsSize; - } - for(int j = 0; j < mcolumns; j++){ - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0 - && m_column_pair_status[i][j] != 0){ - - if( (specialRegionsStatus & (1 << (i+mch)) ) == 0){ - specialRegionsSize += mcolumns; - } - - specialRegionsStatus |= (1 << (i+mch)); - } - } - } - - coral::Blob* blob = new coral::Blob( (2 + specialRegionsSize + 2 * size()) * sizeof(uint32_t) ); - - uint32_t* p = static_cast<uint32_t*>(blob->startingAddress()); - - *p = m_module_status; - ++p; - *p = specialRegionsStatus; - - for(int i = 0; i < mch; i++){ - if((specialRegionsStatus & (1 << i)) != 0){ - ++p; - *p = m_chip_status[i]; - } - if((specialRegionsStatus & (1 << (i+mch))) != 0){ - for(int j = 0; j < mcolumns; j++){ - ++p; - *p = m_column_pair_status[i][j]; - } - } - } - - for(const_iterator mi = begin(); mi != end(); ++mi){ - ++p; - *p = mi->first; - ++p; - *p = mi->second; - } - - return blob; -} - -void ModuleSpecialPixelMap::print(int component, - unsigned int layer, - unsigned int phi, - int eta, - bool verbosePixelID, - bool binaryPixelStatus) const{ - - unsigned int system, subSystem; - system = 2; - subSystem = 1; - - int itype = (int)chipType(); - int mch = (int)chipsPerModule(); - int mcolumns =(int)columnsPerChip(); - - // check what to do with moduleID ? - int moduleID = itype==0 ? ( ( ((component + 2) / 2) << 25 ) + - ( layer << 23 ) + ( phi << 17 ) + ( (eta + 6) << 13 )): -1; - - //print header - - std::cout << " " << std::endl; - if(moduleID>-1)std::cout << "ModuleSpecialPixelMap for module " << moduleID << ":" << std::endl; - std::cout << "Offline ID [system,subsystem,endcap/barrel,layer/disk,phi,eta] : [" - << system << ',' << subSystem << ',' << component << ',' << layer << ',' << phi << ',' << eta << ']' << std::endl; - std::cout << "Module status: "; - std::cout.width(10); - std::cout << m_module_status << std::endl; - std::cout << " " << std::endl; - - bool print_chip_status = false; - bool print_column_pair_status = false; - - for(int i = 0; i < mch; i++){ - if(m_chip_status.size() != 0 && m_chip_status[i] != 0){ - print_chip_status = true; - } - for(int j = 0; j < mcolumns/2; j++){ - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0 - && m_column_pair_status[i][j] != 0){ - print_chip_status = true; - print_column_pair_status = true; - } - } - } - - if(mch>2){ - if(print_chip_status){ - std::cout << "Chip number: "; - for(int i = mch-1; i>mch/2-1; i--)std::cout<<i<<" "; - std::cout<< std::endl; - std::cout << "Chip status: "; - for(int i = mch-1; i > mch/2-1; i--){ - std::cout.width(10); - if(m_chip_status.size() != 0){ - std::cout << m_chip_status[i] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - std::cout << " " << std::endl; - - if(print_column_pair_status){ - std::cout << "Column pairs: "; - for(int i = mch-1; i > mch/2-1; i--){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][0] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - std::cout << "pairs 0 to "<<mch/2<<" "; - for(int i = mch-1; i > mch/2-1; i--){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][1] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - for(int j = 2; j < mcolumns/2; j++){ - std::cout << " "; - for(int i = mch-1; i > mch/2-1; i--){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][j] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - } - std::cout << " " << std::endl; - - - std::cout << "Column pairs: "; - for(int i = 0; i < mch/2; i++){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][0] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - std::cout << "pairs 0 to "<<mch/2<<" "; - for(int i = 0; i < mch/2; i++){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][1] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - for(int j = 2; j < mcolumns/2; j++){ - std::cout << " "; - for(int i = 0; i < mch/2; i++){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][j] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - } - std::cout << " " << std::endl; - } - else{ - std::cout << "No special column pairs on this module" << std::endl; - std::cout << " " << std::endl; - } - - std::cout << "Chip status: "; - for(int i = 0; i < mch/2; i++){ - std::cout.width(10); - if(m_chip_status.size() != 0){ - std::cout << m_chip_status[i] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - std::cout << "Chip number: "; - for(int i = 0; i<mch/2; ++i)std::cout<<i<<" "; - std::cout<< std::endl; - std::cout << " " << std::endl; - std::cout << " " << std::endl; - } - else{ - std::cout << "No special chips and/or column pairs on this module" << std::endl; - std::cout << " " << std::endl; - } - - //print map - - for(const_iterator pixel = begin(); pixel != end(); ++pixel){ - if(verbosePixelID){ - unsigned int pixelID = pixel->first; - unsigned int chip = pixelID % 16; - unsigned int column = (itype==0) ? ((pixelID / 16) % 32) : ((pixelID / 16) % 256); - unsigned int row = (itype==0) ? (pixelID / 512) : (pixelID / 4096); - std::cout << "Pixel (chip/column/row) "; - std::cout << ' '; - std::cout << chip << "/"; - std::cout << ' '; - std::cout << column << "/"; - std::cout << ' '; - std::cout << row; - } - else{ - std::cout << "Pixel " << pixel->first; - } - if(binaryPixelStatus){ - unsigned int pixelStatus = pixel->second; - std::cout << " status: "; - for(int i = 31; i >= 0; i--){ - bool statusBit = pixelStatus & (1u << i); - std::cout << statusBit; - if(!(i%4)) std::cout << ' '; - } - std::cout << std::endl; - } - else{ - std::cout << " status: " << pixel->second << std::endl; - } - } - } - else{ // IBL FEI4 module - // - if(print_chip_status){ - std::cout << "Chip number: "; - for(int i =0; i<mch; ++i)std::cout<<i<<" "; - std::cout<< std::endl; - - std::cout << "Chip status: "; - for(int i = 0; i < (int)mch; i++){ - std::cout.width(10); - if(m_chip_status.size() != 0){ - std::cout << m_chip_status[i] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - std::cout << " " << std::endl; - - if(print_column_pair_status){ - std::cout << "Column pairs 0 to "<<mcolumns/2<<" "; - std::cout << std::endl; - for(int j = 0; j<mcolumns/2; ++j){ - for(int i = 0; i < mch; i++){ - std::cout.width(10); - if(m_column_pair_status.size() != 0 && m_column_pair_status[i].size() != 0){ - std::cout << m_column_pair_status[i][j] << " "; - } - else{ - std::cout << 0 << " "; - } - } - std::cout << std::endl; - } - - std::cout << " " << std::endl; - - } - else{ - std::cout << "No special column pairs on this module" << std::endl; - std::cout << " " << std::endl; - } - } - else{ - std::cout << "No special chips and/or column pairs on this module" << std::endl; - std::cout << " " << std::endl; - } - - //print map - - for(const_iterator pixel = begin(); pixel != end(); ++pixel){ - if(verbosePixelID){ - unsigned int pixelID = pixel->first; - unsigned int chip = pixelID % 16; - unsigned int column = (itype==0) ? ((pixelID / 16) % 32) : ((pixelID / 16) % 256); - unsigned int row = (itype==0) ? (pixelID / 512) : (pixelID / 4096); - - std::cout << "Pixel (chip/column/row) "; - std::cout <<' '; - std::cout << chip << "/"; - std::cout <<' '; - std::cout << column << "/"; - std::cout <<' '; - std::cout << row; - } - else{ - std::cout << "Pixel " << pixel->first; - } - if(binaryPixelStatus){ - unsigned int pixelStatus = pixel->second; - std::cout << " status: "; - for(int i = 31; i >= 0; i--){ - bool statusBit = pixelStatus & (1u << i); - std::cout << statusBit; - if(!(i%4)) std::cout << ' '; - } - std::cout << std::endl; - } - else{ - std::cout << " status: " << pixel->second << std::endl; - } - } - // - } - return; -} - -void ModuleSpecialPixelMap::setPixelStatus(unsigned int pixelID, unsigned int status){ - if(validPixelID(pixelID)){ - condResetSpecialRegions(pixelID, status); - - unsigned int chip = pixelID % 16; - unsigned int column = chipType()==0 ? ((pixelID / 16) % 32): ((pixelID / 16) % 256); - - if(status == 0){ - erase(pixelID); - } - else{ - if(m_module_status == 0 && (m_chip_status.size() == 0 || m_chip_status[chip] == 0) - && (m_column_pair_status.size() == 0 || m_column_pair_status[chip].size() == 0 - || m_column_pair_status[chip][column/ 2] == 0)){ - (*this)[pixelID] = status; - } - } - } - else{ - std::cout << "Invalid pixel ID requested"; - } - return; -} - -void ModuleSpecialPixelMap::setPixelStatusBit(unsigned int pixelID, unsigned int bit){ - unsigned int chip = pixelID % 16; - unsigned int column = (chipType())==0 ? ((pixelID / 16) % 32): ((pixelID / 16) % 256); - - if(validPixelID(pixelID)){ - if((pixelStatus(pixelID) & (1 << bit)) == 0){ - condResetSpecialRegions(pixelID, pixelStatus(pixelID) | (1 << bit)); - } - if(bit < 32){ - if(m_module_status == 0 && (m_chip_status.size() == 0 || m_chip_status[chip] == 0) - && (m_column_pair_status.size() == 0 || m_column_pair_status[chip].size() == 0 - || m_column_pair_status[chip][column / 2] == 0)){ - (*this)[pixelID] |= (1 << bit); - } - } - else { - std::cout << "Requested bit " << bit << " out of range ([0,31] allowed)" << std::endl; - } - } - else{ - std::cout << "Invalid pixel ID requested" << std::endl; - } - return; -} - -void ModuleSpecialPixelMap::clearPixelStatusBit(unsigned int pixelID, unsigned int bit){ - unsigned int chip = pixelID % 16; - unsigned int column = chipType()==0 ? ((pixelID / 16) % 32): ((pixelID /16) % 256); - - if(validPixelID(pixelID)){ - if((pixelStatus(pixelID) & (1 << bit)) != 0){ - condResetSpecialRegions(pixelID, pixelStatus(pixelID) & ~(1 << bit)); - } - if(bit < 32){ - if(!empty()){ - if(find(pixelID) != end()){ - if(m_module_status == 0 && (m_chip_status.size() == 0 || m_chip_status[chip] == 0) - && (m_column_pair_status.size() == 0 || m_column_pair_status[chip].size() == 0 - || m_column_pair_status[chip][column / 2] == 0)){ - (*this)[pixelID] &= ~(1 << bit); - if(((*this)[pixelID] & ~(15 << 25)) == 0){ - erase(pixelID); - } - } - } - } - } - else{ - std::cout << "Requested bit " << bit << " out of range ([0,31] allowed)" << std::endl; - } - } - else { - std::cout << "Invalid pixel ID requested" << std::endl; - } - return; -} - -void ModuleSpecialPixelMap::condResetSpecialRegions(unsigned int pixelID, unsigned status){ - - // reset module/chip/column pair status if necessary - unsigned int ix = chipType(); - unsigned int mcolumns = columnsPerChip()/2; - unsigned int mrows = rowsrdoPerChip(); - int mch = (int)chipsPerModule(); - unsigned int chip = pixelID % 16; - unsigned int column = (ix==0) ? ((pixelID / 16) % 32): ((pixelID /16) % 256); - - if(m_module_status != 0 && m_module_status != (status & ~(15 << 25))){ - m_chip_status.resize(mch); - for(int i = 0; i < mch; i++){ - m_chip_status[i] = m_module_status; - } - m_module_status = 0; - } - - if(m_chip_status.size() != 0 && m_chip_status[chip] != 0 - && m_chip_status[chip] != (status & ~(15 << 25))){ - m_column_pair_status.resize(mch); - m_column_pair_status[chip].resize(mcolumns); - for(int j = 0; j < (int)mcolumns; j++){ - m_column_pair_status[chip][j] = m_chip_status[chip]; - } - m_chip_status[chip] = 0; - } - - if(m_column_pair_status.size() != 0 && m_column_pair_status[chip].size() != 0 - && m_column_pair_status[chip][column / 2] != 0 - && m_column_pair_status[chip][column / 2] != (status & ~(15 << 25))){ - for(int i = 0; i < 2; i++){ - for(int row = 0; row < (int)mrows; row++){ - (*this)[encodePixelID(chip, (column / 2) * 2 + i, row, m_chipsPerModule)] - = m_column_pair_status[chip][column / 2]; - } - } - m_column_pair_status[chip][column / 2] = 0; - setNeighbourFlags(); - } - - return; -} - -void ModuleSpecialPixelMap::resetSpecialRegions(){ - unsigned int mcolumns = columnsPerChip()/2; - unsigned int mrows = rowsrdoPerChip(); - int mch = (int)chipsPerModule(); - - // reset module/chip/column pair status - - if(m_module_status != 0){ - m_chip_status.resize(mch); - for(int chip = 0; chip < mch; chip++){ - m_chip_status[chip] = m_module_status; - } - m_module_status = 0; - } - - if(m_chip_status.size() != 0){ - for(int chip = 0; chip < mch; chip++){ - if(m_chip_status[chip] != 0){ - m_column_pair_status.resize(mch); - m_column_pair_status[chip].resize(mcolumns); - for(int column_pair = 0; column_pair < (int)mcolumns; column_pair++){ - m_column_pair_status[chip][column_pair] = m_chip_status[chip]; - } - } - } - m_chip_status.resize(0); - } - - if(m_column_pair_status.size() != 0){ - for(int chip = 0; chip < mch; chip++){ - if(m_column_pair_status[chip].size() != 0){ - for(int column_pair = 0; column_pair < (int)mcolumns; column_pair++){ - if(m_column_pair_status[chip][column_pair] != 0){ - for(int i = 0; i < 2; i++){ - for(int row = 0; row < (int)mrows; row++){ - (*this)[encodePixelID(chip, 2*column_pair + i, row, m_chipsPerModule)] - = m_column_pair_status[chip][column_pair]; - } - } - } - } - } - } - m_column_pair_status.resize(0); - setNeighbourFlags(); - } - return; -} - -bool ModuleSpecialPixelMap::fill_from_string(const std::string& clob){ - unsigned int mcolumns = columnsPerChip()/2; - int mch = (int)chipsPerModule(); - int mkey = (int)pow(2, mch) -1; - - unsigned int pixelID, status; - std::istringstream input_string(clob, std::ios::binary); - input_string >> m_module_status; - - unsigned int specialRegionsStatus = 0; - - input_string >> specialRegionsStatus; - - if((specialRegionsStatus & mkey) != 0){ - m_chip_status.resize(mch); - } - if((specialRegionsStatus & (mkey << mch)) != 0){ - m_column_pair_status.resize(mch); - } - - for(int i = 0; i < mch; i++){ - if((specialRegionsStatus & (1 << i)) != 0){ - input_string >> m_chip_status[i]; - } - if((specialRegionsStatus & (1 << (i+mch))) != 0){ - m_column_pair_status[i].resize(mcolumns); - for(int j = 0; j < (int)mcolumns; j++){ - input_string >> m_column_pair_status[i][j]; - } - } - } - - input_string >> pixelID >> status; - while(input_string.good()){ - setPixelStatus(pixelID, status); - input_string >> pixelID >> status; - } - return false; -} - - -bool ModuleSpecialPixelMap::fill_from_blob(const coral::Blob& blob){ - unsigned int mcolumns = columnsPerChip()/2; - int mch = (int)chipsPerModule(); - int mkey = (int)pow(2, mch) -1; - - unsigned int pixelID, status; - - const uint32_t* p = static_cast<const uint32_t*>(blob.startingAddress()); - - m_module_status = *p; - - ++p; - unsigned int specialRegionsStatus = *p; - unsigned int integersRead = 2; - - if((specialRegionsStatus & mkey) != 0){ - m_chip_status.resize(mch); - } - if((specialRegionsStatus & (mkey << mch)) != 0){ - m_column_pair_status.resize(mch); - } - - for(int i = 0; i < mch; i++){ - if((specialRegionsStatus & (1 << i)) != 0){ - ++p; - ++integersRead; - m_chip_status[i] = *p; - } - if((specialRegionsStatus & (1 << (i+mch))) != 0){ - m_column_pair_status[i].resize(mcolumns); - for(int j = 0; j < (int)mcolumns; j++){ - ++p; - ++integersRead; - m_column_pair_status[i][j] = *p; - } - } - } - - while( static_cast<int>(integersRead * sizeof(unsigned int)) < blob.size() ){ - ++p; - ++integersRead; - pixelID = *p; - ++p; - ++integersRead; - status = *p; - setPixelStatus(pixelID, status); - } - - return false; -} - -unsigned int ModuleSpecialPixelMap::pixelType(unsigned int column, unsigned int row, unsigned int mchips){ - unsigned int i = std::min(mchips%10, nmtype-1); - int mch = (int)mchips/10; - unsigned int mcolumns = columnsPerFEIX[i]; - unsigned int mrowsrdo = rowsRdoPerFEIX[i]; - unsigned int mrows = rowsPerFEIX[i]; - int ng = (int)(mrows - mrowsrdo); - - if(mch>2){ - if(column > 0 && column < mcolumns-1 && row < mrowsrdo){ - if(ng>0){ - for(int k = 0; k<ng; ++k){ - if(row==(mrowsrdo-2-2*k))return 5; // inter-ganged - if(row==(mrowsrdo-1-2*k)) return 2; // ganged - } - } - return 0; // normal - } - else if((column == 0 || column == mcolumns-1) && row < mrowsrdo){ - if(ng>0){ - for(int k = 0; k<ng; ++k){ - if(row==(mrowsrdo-2-2*k))return 6; // long inter-ganged - if(row==(mrowsrdo-1-2*k)) return 3; // long ganged - } - } - return 1; //long - } - else return 8; //invalid row/column pair - } - else { // IBL FEI4 - if( row<mrows&&column<mcolumns ){ - if( mch==2 && (column ==0 || column==(mcolumns-1)) ){ - return 1; //long - } - else{ - return 0; // normal - } - } - else return 8; //invalid row/column pair - } -} - -/* -unsigned int ModuleSpecialPixelMap::pixelType(unsigned int column, unsigned int row){ - unsigned int mchips = 16; - return pixelType(column, row, mchips); -} -*/ - - -std::vector<unsigned int> ModuleSpecialPixelMap::decodePixelID(unsigned int pixelID, unsigned int typeFE){ - - unsigned int chip = (pixelID & 0xF); - pixelID >>=4; - unsigned int column = (pixelID & 0x1F); - (typeFE == 0) ? pixelID >>=5 : pixelID >>=8; //typeFE = 0 for FEI3 and 1 for FEI4 - unsigned int row = pixelID; - - std::vector<unsigned int> ChipColRow; - ChipColRow.push_back(chip); - ChipColRow.push_back(column); - ChipColRow.push_back(row); - - return ChipColRow; - -} - - -unsigned int ModuleSpecialPixelMap::encodePixelID(unsigned int chip, unsigned int column, unsigned int row, unsigned int mchips){ - int i = mchips%10; // type of module - unsigned int pixelID = row; - pixelID = (i==0) ? pixelID << 5 : pixelID << 8; - pixelID += column; - pixelID = pixelID << 4; - pixelID += chip; - return pixelID; -} - - -unsigned int ModuleSpecialPixelMap::encodePixelID(unsigned int chip, unsigned int column, unsigned int row ){ - - unsigned int mchips = 16*10; - return encodePixelID(chip, column, row, mchips); -} - - -unsigned int ModuleSpecialPixelMap::encodePixelID(int component, unsigned int module_phi_index, - unsigned int pixel_eta_index, unsigned int pixel_phi_index, unsigned int mchips){ - unsigned int i = std::min(mchips%10, nmtype-1); - int mch = (int)mchips/10; - unsigned int mcolumns = columnsPerFEIX[i]; - unsigned int mrowsrdo = rowsRdoPerFEIX[i]; - unsigned int mrows = rowsPerFEIX[i]; - int ng = (int)(mrows - mrowsrdo); - - unsigned int chip = 0, column = 0, row = 0; - // - if(std::abs(component)!=2) { //not endcap - if(mch>2){ - if(pixel_phi_index < mrows){ - chip = pixel_eta_index / mcolumns + mch/2; - column = pixel_eta_index % mcolumns; - if(pixel_phi_index < mrowsrdo)row = pixel_phi_index; - else if(ng>0){ - for(int k=0; k<ng; ++k){ - if(pixel_phi_index ==(mrowsrdo+k))row = mrowsrdo+1 -2*(ng-k); - } - } - } - else if(pixel_phi_index >= mrows && pixel_phi_index < 2*mrows){ - chip = mch/2 - (1 + pixel_eta_index / mcolumns); - column = mcolumns - (1+pixel_eta_index % mcolumns); - if(pixel_phi_index > (mrows+ng-1))row = 2*mrows-1 - pixel_phi_index; - else if(ng>0){ - for(int k = 0; k<ng; ++k){ - if(pixel_phi_index ==(mrows+k))row =mrowsrdo-1-2*k; - } - } - } - } - else{ - row = (mrows-1) - pixel_phi_index; - column = mcolumns-(1 + pixel_eta_index%mcolumns); - chip = mch==1 ? 0: 1-pixel_eta_index/mcolumns; - } - } - else{ //disks - if(module_phi_index % 2 == 0){ //even modules - if(pixel_phi_index < mrows){ - chip = mch/2 - (1+pixel_eta_index / mcolumns); - column = mcolumns - (1+pixel_eta_index % mcolumns); - if(pixel_phi_index < mrowsrdo)row = pixel_phi_index; - else if(ng>0){ - for(int k=0; k<ng; ++k){ - if(pixel_phi_index ==(mrowsrdo+k)) row = mrowsrdo+1 -2*(ng-k); - } - } - } - else if(pixel_phi_index > (mrows-1) && pixel_phi_index < 2*mrows){ - chip = pixel_eta_index / mcolumns + mch/2; - column = pixel_eta_index % mcolumns; - if(pixel_phi_index > (mrows+ng-1))row = 2*mrows - 1 - pixel_phi_index; - else if(ng>0){ - for(int k = 0; k<ng; ++k){ - if(pixel_phi_index ==(mrows+k))row =mrowsrdo-1-2*k; - } - } - } - } - else if(module_phi_index % 2 == 1){ //odd modules - if(pixel_phi_index > (mrows+ng-1) && pixel_phi_index < 2*mrows){ - chip = mch/2 -(1 + pixel_eta_index / mcolumns); - column = mcolumns - (1 + pixel_eta_index % mcolumns); - row = 2*mrows - 1 - pixel_phi_index; - } - else if(pixel_phi_index < mrows){ - chip = pixel_eta_index / mcolumns + mch/2; - column = pixel_eta_index % mcolumns; - if(pixel_phi_index < mrowsrdo)row = pixel_phi_index; - else if(ng>0){ - for(int k=0; k<ng; ++k){ - if(pixel_phi_index ==(mrowsrdo+k)) row = mrowsrdo+1 -2*(ng-k); - } - } - } - } - } - unsigned int pixelID = row; - pixelID = (i==0) ? pixelID << 5 : pixelID << 8; - pixelID += column; - pixelID = pixelID << 4; - pixelID += chip; - - return pixelID; -} - -/* -unsigned int ModuleSpecialPixelMap::encodePixelID(int component, unsigned int module_phi_index, - unsigned int pixel_eta_index, unsigned int pixel_phi_index){ - unsigned int mchips = 16; - return encodePixelID(component, module_phi_index, - pixel_eta_index, pixel_phi_index,mchips); -} - -*/ - -void ModuleSpecialPixelMap::markSpecialRegions(){ - - // start with column pairs - unsigned int mcolumns = columnsPerChip()/2; - unsigned int mrows = rowsrdoPerChip(); - - for(int chip = 0; chip < (int)chipsPerModule(); chip++){ - for(int column_pair = 0; column_pair < (int)mcolumns; column_pair++){ - int i = 0, row = 0; - unsigned int column_pair_status = (pixelStatus(encodePixelID(chip, 2*column_pair, row,m_chipsPerModule)) & ~(15 << 25)); - - if(column_pair_status != 0){ - while(i < 2 && (pixelStatus(encodePixelID(chip, 2*column_pair + i, row, m_chipsPerModule)) & ~(15 << 25)) == column_pair_status){ - row++; - if(row == (int)mrows){ - i++; - row = 0; - } - } - if(i == 2){ - setColumnPairStatus(chip, column_pair, column_pair_status); - } - } - } - } - - // then mark special chips - - if(m_column_pair_status.size() != 0){ - for(int chip = 0; chip < (int)chipsPerModule(); chip++){ - if(m_column_pair_status[chip].size() != 0){ - unsigned int chip_status = (m_column_pair_status[chip][0] & ~(15 << 25)); - int i = 1; - while(i < (int)mcolumns && ((m_column_pair_status[chip][i] & ~(15 << 25)) == chip_status)){ - i++; - } - if(i == (int)mcolumns){ - setChipStatus(chip, chip_status); - m_column_pair_status[chip].resize(0); - } - else{ - setChipStatus(chip, 0); - } - } - } - int j = 0; - while(j < (int)chipsPerModule() && m_column_pair_status[j].size() == 0){ - j++; - } - if(j == (int)chipsPerModule()){ - m_column_pair_status.resize(0); - } - } - - // finally see whether the whole module is special - - if(m_chip_status.size() != 0){ - unsigned int module_status = (m_chip_status[0] & ~(15 << 25)); - int i = 1; - while(i < (int)chipsPerModule() && (m_chip_status[i] & ~(15 << 25)) == module_status){ - i++; - } - if(i == (int)chipsPerModule()){ - setModuleStatus(module_status); - m_chip_status.resize(0); - m_column_pair_status.resize(0); - } - else{ - setModuleStatus(0); - } - } - return; -} - -void ModuleSpecialPixelMap::setModuleStatus(unsigned int module_status){ - if(module_status != 0){ - clear(); - } - m_module_status = (module_status & ~(15 << 25)); - return; -} - -void ModuleSpecialPixelMap::setChipStatus(unsigned int chip, unsigned int chip_status){ - unsigned int mcolumns = columnsPerChip(); - unsigned int mrows = rowsrdoPerChip(); - - if(chip_status != 0){ - for(int column = 0; column < (int)mcolumns; column++){ - for(int row = 0; row < (int)mrows; row ++){ - erase(encodePixelID(chip, column, row, m_chipsPerModule)); - } - } - m_chip_status.resize(chipsPerModule()); - m_chip_status[chip] = chip_status; - } - else if(m_chip_status.size() != 0){ - m_chip_status[chip] = (chip_status & ~(15 << 25)); - } - - return; -} - -void ModuleSpecialPixelMap::setColumnPairStatus(unsigned int chip, unsigned int column_pair, unsigned int column_pair_status){ - unsigned int mcolumns = columnsPerChip()/2; - unsigned int mrows = rowsrdoPerChip(); - - if(column_pair_status != 0){ - for(int i = 0; i < 2; i++){ - for(int row = 0; row < (int)mrows; row++){ - erase(encodePixelID(chip, 2*column_pair + i, row, m_chipsPerModule)); - } - } - m_column_pair_status.resize(chipsPerModule()); - m_column_pair_status[chip].resize(mcolumns); - m_column_pair_status[chip][column_pair] = (column_pair_status & ~(15 << 25)); - } - else if(m_column_pair_status.size() != 0 && m_column_pair_status[chip].size() != 0){ - m_column_pair_status[chip][column_pair] = column_pair_status; - } - - return; -} - -void ModuleSpecialPixelMap::setNeighbourFlags(){ - if(empty()){ - return; - } - else{ - //loop - int mch = (int)chipsPerModule(); - int mco =mch>2? mch/2:mch; - for(int chip = 0; chip < mch; chip++){ - for(int column = 0; column < (int)columnsPerChip(); column++){ - for(int row = 0; row < (int)rowsrdoPerChip(); row++){ - - //if this pixel is special... - const_iterator pixel = find(encodePixelID(chip, column, row, m_chipsPerModule)); - if(pixel != end()){ - if(((*pixel).second & ~(15 << 25)) != 0){ - - //see if left neighbour is also special - if(column != 0 && - (pixelStatus(encodePixelID(chip, column-1, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 27); - } - else if(mch>2&&column == 0 && chip != 0 && chip != mco && - (pixelStatus(encodePixelID(chip-1, columnsPerChip()-1, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 27); - } - else if(mch==2&&column == 0 && chip != 0 && - (pixelStatus(encodePixelID(chip-1, columnsPerChip()-1, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 27); - } - else{ - clearPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 27); - } - - //see if right neighbour is special - if(column != (int)(columnsPerChip()-1) && - (pixelStatus(encodePixelID(chip, column+1, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 28); - } - else if(mch>2&&column == (int)(columnsPerChip()-1) && chip != (mco-1) && chip != (mch-1) && - (pixelStatus(encodePixelID(chip+1, 0, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 28); - } - else if(mch==2&&column == (int)(columnsPerChip()-1) && chip != 1 && - (pixelStatus(encodePixelID(chip+1, 0, row, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 28); - } - else{ - clearPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 28); - } - - //see if top neighbour is special - if(row != (int)(rowsrdoPerChip()-1) && - (pixelStatus(encodePixelID(chip, column, row+1, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 26); - } - else if(mch>2&&row == (int)(rowsrdoPerChip()-1) && - (pixelStatus(encodePixelID((mch-1-chip), (columnsPerChip()-1-column),(rowsrdoPerChip()-1), m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 26); - } - else{ - clearPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 26); - } - - //see if bottom neighbour is special - if(row != 0 && - (pixelStatus(encodePixelID(chip, column, row-1, m_chipsPerModule)) & ~(15 << 25)) != 0){ - setPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 25); - } - else{ - clearPixelStatusBit(encodePixelID(chip, column, row, m_chipsPerModule), 25); - } - } - } - } - } - } - return; - } -} - - -ModuleSpecialPixelMap::size_type ModuleSpecialPixelMap::size() const{ - return std::map<unsigned int, unsigned int>::size(); -} - -bool ModuleSpecialPixelMap::empty() const{ - return std::map<unsigned int, unsigned int>::empty(); -} - -ModuleSpecialPixelMap::iterator ModuleSpecialPixelMap::begin(){ - return std::map<unsigned int, unsigned int>::begin(); -} - -ModuleSpecialPixelMap::const_iterator ModuleSpecialPixelMap::begin() const{ - return std::map<unsigned int, unsigned int>::begin(); -} - -ModuleSpecialPixelMap::iterator ModuleSpecialPixelMap::end(){ - return std::map<unsigned int, unsigned int>::end(); -} - -ModuleSpecialPixelMap::const_iterator ModuleSpecialPixelMap::end() const{ - return std::map<unsigned int, unsigned int>::end(); -} - -bool ModuleSpecialPixelMap::hasSpecialChips() const{ - if(m_chip_status.size() == 0){ - return false; - } - else{ - for(std::vector<unsigned int>::const_iterator chip = m_chip_status.begin(); chip != m_chip_status.end(); ++chip){ - if(*chip != 0){ - return true; - } - } - } - - return false; -} - -bool ModuleSpecialPixelMap::hasSpecialColumnPairs() const{ - if(m_column_pair_status.size() == 0){ - return false; - } - else{ - - for(std::vector<std::vector<unsigned int> >::const_iterator chip = m_column_pair_status.begin(); - chip != m_column_pair_status.end(); ++chip){ - - for(std::vector<unsigned int>::const_iterator column_pair = - m_column_pair_status[chip - m_column_pair_status.begin()].begin(); - column_pair != m_column_pair_status[chip - m_column_pair_status.begin()].end(); - ++column_pair){ - - if((*column_pair) != 0){ - return true; - } - } - } - } - - return false; - -} - -bool ModuleSpecialPixelMap::hasSpecialColumnPairs(unsigned int chip) const{ - - if(m_column_pair_status.size() == 0){ - return false; - } - else if(chip >= chipsPerModule()){ - std::cout << "Chip index " << chip << " out of range" << std::endl; - return false; - } - else{ - for(std::vector<unsigned int>::const_iterator column_pair = m_column_pair_status[chip].begin(); - column_pair != m_column_pair_status[chip].end(); ++column_pair){ - - if((*column_pair) != 0){ - return true; - } - } - } - - return false; -} - -} // namespace PixelCoralClientUtils diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/calibDbInterface.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/calibDbInterface.cc deleted file mode 100644 index f060d999fdb..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/calibDbInterface.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PixCalibKnowledgeDb.h" -#include "PixelCoralClientUtils/PixCalibCoralCoolDb.h" - -#include "CoolKernel/ValidityKey.h" - -#include<iostream> -#include<string> -#include<cstdlib> -#include <sys/time.h> - -using namespace std; - -int main(int argc, char **argv) -{ - if (argc<2 || argv[1][0]!='-') { - cout << argv[0] << ": tool to talk to pixel coral database." << endl; - cout << "options:" << endl; - cout << "\t-s idTag connTag cfgTag cfgModTag calibtag calibTag1 calibTag2 calibTag3 etc" << endl; - cout << "\t store a list of calibration tags corresponding to a certain idTag connTag cfgTag cfgModTag in knowledge db"<< endl; - cout << "\t-r UNIXTimeInSeconds" << endl; - cout << "\t Find the list of calibration-tags valid for a certain UNIX-time in seconds" << endl; - return 1; - } - - string tableName("CALIB_DATA"); - - string connString("sqlite_file:pcd_knowledge.db"); - char* ctmp = getenv("PIXEL_CAL_KNOWLEDGE"); - if (ctmp) connString = ctmp; - - int c = argv[1][1]; - - switch (c) { - case 's': - { - if(argc > 2 && c==115) { - - //first 5 arguments relate to run-conditions - long int runNumber = atol(argv[2]); - string idTag = argv[3]; - string connTag = argv[4]; - string cfgTag = argv[5]; - string cfgModTag = argv[6]; - - string calibtags_in_string = ""; - for(int i=7;i<argc;i++){ - if(i!=7) calibtags_in_string = calibtags_in_string+","+argv[i]; - else calibtags_in_string = argv[i]; - } - - std::cout << "Store a reference that currently the latest calibration-tags are defined by: " << std::endl; - std::cout << calibtags_in_string << std::endl; - - std::cout << "Associated to the following run-conditions: " << std::endl; - std::cout << "runNumber " << runNumber << std::endl; - std::cout << "idTag: " << idTag << std::endl; - std::cout << "connTag: " << connTag << std::endl; - std::cout << "cfgTag: " << cfgTag << std::endl; - std::cout << "cfgModTag: " << cfgModTag << std::endl; - - struct timeval UNIXTime; - gettimeofday(&UNIXTime,NULL); - std::cout << "UNIXTime at moment of storing tags: " << UNIXTime.tv_sec << std::endl; - - PixCalibKnowledgeDb knowledgeDB(connString, tableName, 1); - knowledgeDB.init(coral::Update); - knowledgeDB.saveCorrespondingConfig(UNIXTime.tv_sec,runNumber,calibtags_in_string,idTag,connTag,cfgTag,cfgModTag); - } - } - break; - case 'r': - { - if(argc > 2 && argc < 4 && c==114) { - - long int Utime = atol(argv[2]); - - std::cout << "Read calibration-Tags valid for UNIXTimeInSeconds " << Utime << std::endl; - - PixCalibKnowledgeDb knowledgeDB(connString, tableName, 1); - knowledgeDB.init(coral::Update); - knowledgeDB.readCorrespondingCalibTag(Utime); - } - } - break; - default: - cout << "unknown option " << argv[1] << endl; - } - - return 0; -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractAnalysis.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractAnalysis.cc deleted file mode 100644 index 031445abcd6..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractAnalysis.cc +++ /dev/null @@ -1,462 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" -#include "PixelCoralClientUtils/PixelCalibData.hh" - -#include<string> -#include<cstring> -#include<map> -#include<set> -#include<fstream> -using namespace std; - -int main (int argc, char **argv){ - - int iarg = 1; - bool verbose = false; - if (argc>iarg && strcmp(argv[iarg],"-v")==0) { - verbose = true; - ++iarg; - } - - enum OPTION { THRESHOLDS, TIMEWALK, TOT }; - - OPTION option = TOT; - if (argc>iarg && strcmp(argv[iarg],"-t")==0) { - option = THRESHOLDS; - ++iarg; - } - if (argc>iarg && strcmp(argv[iarg],"-w")==0) { - option = TIMEWALK; - ++iarg; - } - - if (iarg>=argc) { - cout << "Usage: extractAnalysis [-v] [-t|-w] anal_id" << endl; - return 1; - } - - CAN::SerialNumber_t anal_id = atoi(argv[iarg]); - - cout << "--> Summary for anal_id " << anal_id << endl; - - // - // load pcd from text file - // - - map<unsigned int, PixelCoralClientUtils::PixelCalibData> pcdmap; - ifstream in("pcd.dat"); - if (!in.is_open()) return 1; - - while (in) { - unsigned int idmod; in >> idmod; - if (in.eof()) break; - - PixelCoralClientUtils::PixelCalibData pcd; - - for (int i = 0; i<16; ++i) { - char dummy; in >> dummy; - if (dummy!='I') break; - int idchip; in >> idchip; - if (idchip!=i) break; - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData pcsd; - pcsd.setChipID(idchip); - int thres, sigma, noise, timewalk; - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(0, thres, sigma, noise, timewalk); - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(1, thres, sigma, noise, timewalk); - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(2, thres, sigma, noise, timewalk); - float A, E, C; - in >> A >> E >> C; - pcsd.setQ2Tot(0, A, E, C); - in >> A >> E >> C; - pcsd.setQ2Tot(2, A, E, C); - float p1, p2; - in >> p1 >> p2; - pcsd.setTotRes(p1, p2); - pcd.add(pcsd); - } - - pcdmap.insert(make_pair(idmod,pcd)); - } - cout << "pix cal data size: " << pcdmap.size() << endl; - - // - // load module->hashid lookup table - // - - map<string, unsigned int> lookup; - ifstream in_lookup("aliases.dat"); - if (!in_lookup.is_open()) return 1; - - string s; - while (getline(in_lookup, s)) { - if (s.find("HASHID") != string::npos) { - istringstream ss(s); - unsigned int idmod; - string s1, s2; - ss >> idmod >> s1 >> s2; - lookup.insert(make_pair(s2,idmod)); - } - } - cout << "lookup table size: " << lookup.size() << endl; - - map<string, unsigned int> lookup_errors; - - // - // connect to analysis data base - // - - try { - - // Start CORAL client - const char* tableName = "CALIB_ANAL"; - PixCoralClient coralClient(verbose, coral::ReadOnly, tableName); - - // Show the structure of the master table - if (verbose) { - coralClient.printTableDesc(tableName); - coralClient.printTableContent(tableName); - } - - // Return a CAN::AnalysisResultList_t object - CAN::AnalysisResultList_t a = coralClient.getAnalysisResultsFromDB(anal_id); - - if (option!=TOT) { - // - // threshold/timewalk calibration - // - - // load bool parameters - set<unsigned int> passed_idmod; - set<unsigned int> failed_idmod; - if (verbose) cout << "looking at bools" << endl; - for (map<string, map<string, bool> >::const_iterator iter = a.begin<bool>(); - iter != a.end<bool>(); ++iter) { - const string& s = iter->first; - if (verbose) cout << s << endl; - // figure out if we need it - if (s != "Status") continue; - for (map<string, bool>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - bool value = val_iter->second; - // convert connectivity to module id - unsigned int idmod = lookup[ss]; - if (value) passed_idmod.insert(idmod); - else failed_idmod.insert(idmod); - } - } - cout << "good " << passed_idmod.size() << ", bad " << failed_idmod.size() << endl; - - // load float parameters - // verify if the scan is good - for (map<string, map<string, float> >::const_iterator iter = a.begin<float>(); - iter != a.end<float>(); ++iter) { - const string& s = iter->first; - if (s != "number of bad pixels") continue; - for (map<string, float>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - // convert connectivity to module id - unsigned int idmod = lookup[ss]; - float value = val_iter->second; - const float maxBadPixels = 20000; - if (value>=maxBadPixels) { - if (verbose) cout << s << "-> " << ss << " (" << idmod << "): too many bad pixels = " << value << endl; - failed_idmod.insert(idmod); - } - } - } - // proceed with loading - set<unsigned int> used_idmod; - set<unsigned int> rejected_idmod; - if (verbose) cout << "looking at floats" << endl; - for (map<string, map<string, float> >::const_iterator iter = a.begin<float>(); - iter != a.end<float>(); ++iter) { - const string& s = iter->first; - if (verbose) cout << s << endl; - // figure out if we need it - const int nvar = 5; - string svar[nvar] = { - "average threshold", - "threshold RMS", - "average noise for normal pixel", - "average noise for long pixel", - "average noise for ganged pixel" - }; - if (option==TIMEWALK) svar[0] = "Average_threshold"; - int jvar = -1; - for (int ivar = 0; ivar<nvar; ++ivar) { - if (s == svar[ivar]) { - jvar = ivar; - break; - } - } - if (jvar<0) continue; - if (option==TIMEWALK && jvar>0) continue; - for (map<string, float>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - // convert connectivity to module id - unsigned int idmod = lookup[ss]; - if (verbose) cout << s << "-> " << ss << " (" << idmod << ")"; - // check whether the scans are good - if (failed_idmod.find(idmod)!=failed_idmod.end()) { - rejected_idmod.insert(idmod); - if (verbose) cout << ": bad scan" << endl; - continue; - } - used_idmod.insert(idmod); - // find corresponding PixelCalibData - map<unsigned int, PixelCoralClientUtils::PixelCalibData>::iterator ipcd = pcdmap.find(idmod); - //if (ipcd == pcdmap.end()) throw std::runtime_error("Invalid module ID"); - if (ipcd == pcdmap.end()) { - lookup_errors.insert(make_pair(ss, idmod)); - if (verbose) cout << ": lookup error" << endl; - continue; - } - PixelCoralClientUtils::PixelCalibData& pcd = ipcd->second; - float value = val_iter->second; - // use the same value for all FE - for (int idchip = 0; idchip<16; ++idchip) { - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.findChipID(idchip); - // replace the parameter in the table - int v[12]; - for (int type = 0; type<3; ++type) { - v[type*4 ] = pcsd.getThreshold(type); - v[type*4+1] = pcsd.getThresholdSigma(type); - v[type*4+2] = pcsd.getNoise(type); - v[type*4+3] = pcsd.getTimeWalk(type); - } - bool verbose1 = verbose && idchip==0; - if (verbose1) cout << svar[jvar] << "="; - if (option==THRESHOLDS) { - if (jvar==0) { // average threshold - if (verbose1) cout << v[0] << "," << v[4] << "," << v[8]; - v[0] = v[4] = v[8] = (int)value; - } else if (jvar==1) { // threshold RMS - if (verbose1) cout << v[1] << "," << v[5] << "," << v[9]; - v[1] = v[5] = v[9] = (int)value; - } else { // average noise - int type = jvar-2; - if (verbose1) cout << v[type*4+2]; - v[type*4+2] = (int)value; - } - } else { // timewalk, jvar is always 0 - if (verbose1) cout << v[3] << "," << v[7] << "," << v[11]; - v[3] = v[7] = v[11] = (int)value; - } - if (verbose1) cout << " replaced by " << value << endl; - for (int type = 0; type<3; ++type) { - pcsd.setThreshold(type, v[type*4], v[type*4+1], v[type*4+2], v[type*4+3]); - } - } - } - } - cout << "modified modules: " << used_idmod.size() << endl; - cout << "rejected modules: " << rejected_idmod.size() << endl; - - } else { - - // - // ToT calibration - // - - // load bool parameters - set<unsigned int> passed_n_id; - set<unsigned int> passed_g_id; - set<unsigned int> failed_n_id; - set<unsigned int> failed_g_id; - if (verbose) cout << "looking at bools" << endl; - for (map<string, map<string, bool> >::const_iterator iter = a.begin<bool>(); - iter != a.end<bool>(); ++iter) { - const string& s = iter->first; - if (verbose) cout << s << endl; - // figure out if we need it - if (s.compare(0, 6, "passed")) continue; - // determine chip id - int ix = s.find("FE") + 2; - int idchip = atoi(s.substr(ix).c_str()); - // determine pixel type - int itype = -1; - if (s.find("non_ganged_pix") != string::npos) itype = 0; - else if (s.find("ganged_pix") != string::npos) itype = 2; - if (itype<0) continue; - for (map<string, bool>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - bool value = val_iter->second; - // convert connectivity to module id - unsigned int idmod = lookup[ss]; - unsigned int id = (idmod<<4) | idchip; - if (itype==0) { - if (value) passed_n_id.insert(id); - else failed_n_id.insert(id); - } - else if (itype==2) { - if (value) passed_g_id.insert(id); - else failed_g_id.insert(id); - } - } - } - cout << "non_ganged_pixels: good " << passed_n_id.size() << ", bad " << failed_n_id.size() << endl; - cout << "ganged_pixels: good " << passed_g_id.size() << ", bad " << failed_g_id.size() << endl; - - // load float parameters - set<unsigned int> used_id; - set<unsigned int> rejected_id; - if (verbose) cout << "looking at floats" << endl; - for (map<string, map<string, float> >::const_iterator iter = a.begin<float>(); - iter != a.end<float>(); ++iter) { - const string& s = iter->first; - if (verbose) cout << s << endl; - // figure out if we need it - const int nvar = 5; - const string svar[nvar] = { - "tot_p0_FE", "tot_p1_FE", "tot_p2_FE", - "disp_p0_FE", "disp_p1_FE" - }; - int jvar = -1; - for (int ivar = 0; ivar<nvar; ++ivar) { - if (s.compare(0, svar[ivar].length(), svar[ivar])==0) { - jvar = ivar; - break; - } - } - if (jvar<0) continue; - // determine chip id - int ix = s.find("FE") + 2; - int idchip = atoi(s.substr(ix).c_str()); - // determine pixel type - int itype = -1; - if (s.find("non_ganged_pix") != string::npos) itype = 0; - else if (s.find("ganged_pix") != string::npos) itype = 2; - // obsolete names, used for A5082 - //if (s.find("normal_pix") != string::npos) itype = 0; - //else if (s.find("special-non-ganged_pix") != string::npos) itype = 1; - //else if (s.find("ganged_pix") != string::npos) itype = 2; - if (itype<0) continue; - for (map<string, float>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - // convert connectivity to module id - unsigned int idmod = lookup[ss]; - if (verbose) cout << s << "-> " << ss << ":" << idchip << " (" << idmod << ")"; - // check whether the scans are good - unsigned int id = (idmod<<4) | idchip; - if (failed_n_id.find(id)!=failed_n_id.end() || - failed_g_id.find(id)!=failed_g_id.end()) { - rejected_id.insert(id); - if (verbose) cout << ": bad scan" << endl; - continue; - } - used_id.insert(id); - // find corresponding PixelCalibData - map<unsigned int, PixelCoralClientUtils::PixelCalibData>::iterator ipcd = pcdmap.find(idmod); - //if (ipcd == pcdmap.end()) throw std::runtime_error("Invalid module ID"); - if (ipcd == pcdmap.end()) { - lookup_errors.insert(make_pair(ss, idmod)); - if (verbose) cout << ": lookup error" << endl; - continue; - } - PixelCoralClientUtils::PixelCalibData& pcd = ipcd->second; - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.findChipID(idchip); - float value = val_iter->second; - // replace the parameter in the table - if (s.compare(0,5,"tot_p")==0) { - float v[3]; - v[0] = pcsd.getQ2TotA(itype); - v[1] = pcsd.getQ2TotE(itype); - v[2] = pcsd.getQ2TotC(itype); - int j = s[5]-'0'; if (j<0 || j>2) continue; - if (verbose) { - cout << ", "; - if (j==0) cout << "A"; else if (j==1) cout << "E"; else cout << "C"; - cout << "=" << v[j] << " replaced by " << value << endl; - } - v[j] = value; - pcsd.setQ2Tot(itype, v[0], v[1], v[2]); - } else if (s.compare(0,6,"disp_p")==0) { - float v[2]; - v[0] = pcsd.getTotP1(); - v[1] = pcsd.getTotP2(); - int j = s[6]-'0'; if (j<0 || j>1) continue; - if (verbose) { - cout << ", "; - cout << "p" << j+1 << "=" << v[j] << " replaced by " << value << endl; - } - v[j] = value; - pcsd.setTotRes(v[0], v[1]); - } else { - if (verbose) cout << endl; - } - } - } - cout << "modified chips: " << used_id.size() << endl; - cout << "rejected chips: " << rejected_id.size() << endl; - cout << "total modules: " << (used_id.size()+rejected_id.size())/16 << endl; - } - - if (!lookup_errors.empty()) { - cout << "module ids not found in the lookup table:" << endl; - for (map<string, unsigned int>::const_iterator il = lookup_errors.begin(); - il != lookup_errors.end(); ++il) { - cout << il->first << " " << il->second << endl; - } - } - - } catch ( exception& e ) { - cout << "exception caught: " << e.what() << endl; - return -1; - } - - catch (...) { - cout << "Unknown exception caught!" << endl; - return -1; - } - - // - // save pcd back to text file - // - - ofstream out("pcd.sav"); - for (map<unsigned int, PixelCoralClientUtils::PixelCalibData>::const_iterator ipcd = pcdmap.begin(); - ipcd != pcdmap.end(); ++ipcd) { - out << ipcd->first << endl; - const PixelCoralClientUtils::PixelCalibData& pcd = ipcd->second; - for (int i = 0; i<16; ++i) { - const PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.getPixelChipSummaryData(i); - out << "I" << pcsd.getChipID() - << " " << pcsd.getThreshold(0) - << " " << pcsd.getThresholdSigma(0) - << " " << pcsd.getNoise(0) - << " " << pcsd.getTimeWalk(0) - << " " << pcsd.getThreshold(1) - << " " << pcsd.getThresholdSigma(1) - << " " << pcsd.getNoise(1) - << " " << pcsd.getTimeWalk(1) - << " " << pcsd.getThreshold(2) - << " " << pcsd.getThresholdSigma(2) - << " " << pcsd.getNoise(2) - << " " << pcsd.getTimeWalk(2) - << " " << pcsd.getQ2TotA(0) - << " " << pcsd.getQ2TotE(0) - << " " << pcsd.getQ2TotC(0) - << " " << pcsd.getQ2TotA(2) - << " " << pcsd.getQ2TotE(2) - << " " << pcsd.getQ2TotC(2) - << " " << pcsd.getTotP1() - << " " << pcsd.getTotP2() << endl; - } - } - out.close(); - - return 0; - -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractSPM.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractSPM.cc deleted file mode 100644 index 7cae1b18478..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/extractSPM.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/CoralClient.hh" -#include "PixelCoralClientUtils/SpecialPixelMap.hh" - -#include<string> -#include<cstring> -#include<map> -#include<set> -#include<fstream> -using namespace std; - -int main (int argc, char **argv){ - - int iarg = 1; - bool verbose = false; - if (argc>iarg && strcmp(argv[iarg],"-v")==0) { - verbose = true; - ++iarg; - } - - if (iarg>=argc) { - cout << "Usage: extractSPM [-v] anal_id" << endl; - return 1; - } - - CAN::SerialNumber_t anal_id = atoi(argv[iarg]); - - cout << "--> Summary for anal_id " << anal_id << endl; - - // - // connect to analysis data base - // - - try { - - // Start CORAL client - const char* tableName = "CALIB_ANAL"; - PixCoralClient coralClient(verbose, coral::ReadOnly, tableName); - - // Show the structure of the master table - if (verbose) { - coralClient.printTableDesc(tableName); - coralClient.printTableContent(tableName); - } - - // Return a CAN::AnalysisResultList_t object - CAN::AnalysisResultList_t a = coralClient.getAnalysisResultsFromDB(anal_id); - - // load pixel maps - int npm = 0; - for (map<string, map<string, PixelMap_t> >::const_iterator iter = a.begin<PixelMap_t>(); - iter != a.end<PixelMap_t>(); ++iter) { - ++npm; - const string& s = iter->first; - if (verbose) cout << s << endl; - for (map<string, PixelMap_t>::const_iterator val_iter = iter->second.begin(); - val_iter != iter->second.end(); ++val_iter) { - const string& ss = val_iter->first; - PixelMap_t value = val_iter->second; - if (verbose) { - cout << ss << endl; - for (PixelMap_t::const_iterator pm = value.begin(); - pm != value.end(); ++pm) { - cout << "col=" << pm->first.first << ", row=" << pm->first.second << ", status=" << pm->second << endl; - } - } - } - } - cout << "found pixel maps: " << npm << endl; - - } catch ( exception& e ) { - cout << "exception caught: " << e.what() << endl; - return -1; - } - - catch (...) { - cout << "Unknown exception caught!" << endl; - return -1; - } - - return 0; - -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/fixTimewalk.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/fixTimewalk.cc deleted file mode 100644 index e7cc99d363d..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/fixTimewalk.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PixelCalibData.hh" - -#include<string> -#include<map> -#include<fstream> -using namespace std; - -int load_pcd(map<unsigned int, PixelCoralClientUtils::PixelCalibData>& pcdmap, - const char* filename) -{ - ifstream in(filename); - if (!in.is_open()) return 1; - - while (in) { - unsigned int idmod; in >> idmod; - if (in.eof()) break; - - PixelCoralClientUtils::PixelCalibData pcd; - - for (int i = 0; i<16; ++i) { - char dummy; in >> dummy; - if (dummy!='I') break; - int idchip; in >> idchip; - if (idchip!=i) break; - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData pcsd; - pcsd.setChipID(idchip); - int thres, sigma, noise, timewalk; - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(0, thres, sigma, noise, timewalk); - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(1, thres, sigma, noise, timewalk); - in >> thres >> sigma >> noise >> timewalk; - pcsd.setThreshold(2, thres, sigma, noise, timewalk); - float A, E, C; - in >> A >> E >> C; - pcsd.setQ2Tot(0, A, E, C); - in >> A >> E >> C; - pcsd.setQ2Tot(2, A, E, C); - float p1, p2; - in >> p1 >> p2; - pcsd.setTotRes(p1, p2); - pcd.add(pcsd); - } - - pcdmap.insert(make_pair(idmod,pcd)); - } - - return 0; -} - -//int main(int argc, char **argv){ -int main(int, char **){ - - // - // load pcd from text file - // - - map<unsigned int, PixelCoralClientUtils::PixelCalibData> pcdmap_old; - if (load_pcd(pcdmap_old, "pcd_old.dat")) return 1; - map<unsigned int, PixelCoralClientUtils::PixelCalibData> pcdmap; - if (load_pcd(pcdmap, "pcd.dat")) return 1; - - cout << "pix cal data size: " << pcdmap_old.size() << "/" << pcdmap.size() << endl; - - // - // recalculate timewalk according to the formula - // new_timewalk = old_timewalk - old_threshold + new_threshold - // - - for (map<unsigned int, PixelCoralClientUtils::PixelCalibData>::iterator ipcd = pcdmap.begin(); - ipcd != pcdmap.end(); ++ipcd) { - PixelCoralClientUtils::PixelCalibData& pcd = ipcd->second; - PixelCoralClientUtils::PixelCalibData& pcd_old = pcdmap_old[ipcd->first]; - for (int i = 0; i<16; ++i) { - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.findChipID(i); - PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd_old = *pcd_old.findChipID(i); - // replace the parameter in the table - for (int type = 0; type<3; ++type) { - int old_threshold = pcsd_old.getThreshold(type); - int new_threshold = pcsd.getThreshold(type); - int sigma = pcsd.getThresholdSigma(type); - int noise = pcsd.getNoise(type); - int old_timewalk = pcsd_old.getTimeWalk(type); - int new_timewalk = old_timewalk - old_threshold + new_threshold; - pcsd.setThreshold(type, new_threshold, sigma, noise, new_timewalk); - } - } - } - - // - // save pcd back to text file - // - - ofstream out("pcd.sav"); - for (map<unsigned int, PixelCoralClientUtils::PixelCalibData>::const_iterator ipcd = pcdmap.begin(); - ipcd != pcdmap.end(); ++ipcd) { - out << ipcd->first << endl; - const PixelCoralClientUtils::PixelCalibData& pcd = ipcd->second; - for (int i = 0; i<16; ++i) { - const PixelCoralClientUtils::PixelCalibData::PixelChipSummaryData& pcsd = *pcd.getPixelChipSummaryData(i); - out << "I" << pcsd.getChipID() - << " " << pcsd.getThreshold(0) - << " " << pcsd.getThresholdSigma(0) - << " " << pcsd.getNoise(0) - << " " << pcsd.getTimeWalk(0) - << " " << pcsd.getThreshold(1) - << " " << pcsd.getThresholdSigma(1) - << " " << pcsd.getNoise(1) - << " " << pcsd.getTimeWalk(1) - << " " << pcsd.getThreshold(2) - << " " << pcsd.getThresholdSigma(2) - << " " << pcsd.getNoise(2) - << " " << pcsd.getTimeWalk(2) - << " " << pcsd.getQ2TotA(0) - << " " << pcsd.getQ2TotE(0) - << " " << pcsd.getQ2TotC(0) - << " " << pcsd.getQ2TotA(2) - << " " << pcsd.getQ2TotE(2) - << " " << pcsd.getQ2TotC(2) - << " " << pcsd.getTotP1() - << " " << pcsd.getTotP2() << endl; - } - } - out.close(); - - return 0; - -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDDb.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDDb.cc deleted file mode 100644 index b2b75fe350f..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDDb.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CxxUtils/checker_macros.h" -#include "PixelCoralClientUtils/PCDio.h" -////#include "PixelCoralClientUtils/PixelCalibData.hh" - -#include<iostream> -#include<string> -#include<cstdlib> - -using namespace std; - -int main (int argc, char **argv) -{ - if (argc<3 || argv[1][0]!='-') { - cout << argv[0] << ": tool to talk to pixel coral database." << endl; - cout << "options:" << endl; - cout << "\t-r tag [revision]" << endl; - cout << "\t\tread existing table from the database to pcd.sav" << endl; - cout << "\t-s tag revision sources" << endl; - cout << "\t\tsave pcd.dat to the database" << endl; - return 1; - } - - string tableName("CALIB_DATA"); - - string connString(""); - char* ctmp = getenv("CAN_CALIB_DB"); - if (ctmp) connString = ctmp; - - int c = argv[1][1]; - switch (c) { - case 'r': - { - string tag(argv[2]); - int revision = 0; - if (argc>=4) revision = atoi(argv[3]); - cout << "loading pcd from " << tableName << " at " << connString << endl; - cout << "tag \"" << tag << "\", revision " << revision << endl; - - PCDio io(connString, tableName, 1); - io.init(coral::ReadOnly); - io.load(tag, revision); - } - break; - - case 's': - { - string tag(argv[2]); - int revision(atoi(argv[3])); - string sources(argv[4]); - cout << "saving pcd to " << tableName << " at " << connString << endl; - cout << "tag \"" << tag << "\", revision " << revision << endl; - - PCDio io(connString, tableName, 1); - io.init(coral::Update); - io.save(tag, revision, sources); - } - break; - - default: - cout << "unknown option " << argv[1] << endl; - } - - return 0; -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDkr.cc b/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDkr.cc deleted file mode 100644 index 8e890d09b7f..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/src/talkToPCDkr.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelCoralClientUtils/PCDkr.h" -////#include "PixelCoralClientUtils/PixelCalibData.hh" - -#include<iostream> -#include<string> -#include<cstdlib> - -using namespace std; - -int main(int argc, char **argv) -{ - if (argc<2 || argv[1][0]!='-') { - cout << argv[0] << ": tool to talk to knowledge repository." << endl; - cout << "options:" << endl; - cout << "\t-s tr cid" << endl; - cout << "\t\tcreate a new record with configuration tag/revision tr\n\t\tand calibration identifier cid" << endl; - cout << "\t-v tr" << endl; - cout << "\t\tvalidate configuration tag/revision tr" << endl; - cout << "\t-r" << endl; - cout << "\t\tdump the table" << endl; - return 1; - } - - string tableName("CALIB_KR"); - - string connString(""); - char* ctmp = getenv("CAN_CALIB_DB"); - if (ctmp) connString = ctmp; - - int c = argv[1][1]; - switch (c) { - case 'r': - { - cout << "dumping table " << tableName << " at " << connString << endl; - - PCDkr io(connString, tableName, 1); - io.init(coral::ReadOnly); - io.load(); - } - break; - - case 's': - { - if (argc<3) { - cout << "usage: " << argv[0] << " -s tag cid" << endl; - return 1; - } - string tag(argv[2]); - string cid(argv[3]); - cout << "saving configuration to " << tableName << " at " << connString << endl; - cout << "configuration \"" << tag << "\", cid \"" << cid << "\"" << endl; - - PCDkr io(connString, tableName, 1); - io.init(coral::Update); - io.save(tag, cid); - } - break; - - case 'v': - { - if (argc<2) { - cout << "usage: " << argv[0] << " -v tag" << endl; - return 1; - } - string tag(argv[2]); - cout << "validating configuration in " << tableName << " at " << connString << endl; - cout << "configuration \"" << tag << "\"" << endl; - - PCDkr io(connString, tableName, 1); - io.init(coral::Update); - io.validate(tag); - } - break; - - default: - cout << "unknown option " << argv[1] << endl; - } - - return 0; -} diff --git a/InnerDetector/InDetConditions/PixelCoralClientUtils/test/calibDbInterface_example.sh b/InnerDetector/InDetConditions/PixelCoralClientUtils/test/calibDbInterface_example.sh deleted file mode 100755 index 72ab135f25b..00000000000 --- a/InnerDetector/InDetConditions/PixelCoralClientUtils/test/calibDbInterface_example.sh +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -#!/bin/sh -############################################################################### - -export PATH=$PATH:$PWD/../i686-slc5-gcc43-opt/calibDbInterface.exe - -export PIXEL_CAL_KNOWLEDGE="oracle://INTR/ATLAS_MLIMPER" -#export PIXEL_CAL_KNOWLEDGE="oracle://DEVDB10/ATLAS_COOL_MLIMPER" -#export PIXEL_CAL_KNOWLEDGE="sqlite_file:pcd_knowledge.db" - -#store the latest updated calibration strings (final argument) along with RunNumber (arg1) idTag (arg2) connTag (arg3) cfgTag (arg4) cfgModTag (arg5) -calibDbInterface.exe -s 183905 IDTAG1 CONNTAG1 CFGTAG1 CFGMODTAG1 PixCalib-BLKP-UPD4-000-01 CalibString2 CalibString3 - -#associate calibtag with specific run interval and tag=bla (cool is multi-tag) -#this step should be done by PixRCDCoolAgent, just here for demonstration... -# does not work anymore! -#calibDbInterface -c dummycalib_0 2 3 bla diff --git a/InnerDetector/InDetDigitization/FastSiDigitization/python/FastSiDigitizationConfig.py b/InnerDetector/InDetDigitization/FastSiDigitization/python/FastSiDigitizationConfig.py index 4d4e8759b29..8aa56707880 100644 --- a/InnerDetector/InDetDigitization/FastSiDigitization/python/FastSiDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/FastSiDigitization/python/FastSiDigitizationConfig.py @@ -41,6 +41,7 @@ def FastClusterMakerTool(name="FastClusterMakerTool", **kwargs): # Module status # ################# useNewChargeFormat = False + useNewDeadmapFormat = False if not hasattr(condSeq, "PixelConfigCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg @@ -72,17 +73,27 @@ def FastClusterMakerTool(name="FastClusterMakerTool", **kwargs): IdMappingDat="PixelCabling/Pixels_Atlas_IdMapping_Run2.dat" condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=False, - UseDCSStateConditions=False, - UseDCSStatusConditions=False, - UseTDAQConditions=False, - UseCalibConditions=True, + ReadDeadMapKey = "", UseCablingConditions=False, CablingMapFileName=IdMappingDat) + if useNewDeadmapFormat: + if not hasattr(condSeq, "PixelDeadMapCondAlg"): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg + condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg",ReadKey="") + #FIXME: at some point we should move away from being dependent on the experimentalDigi flags. if 'doFastSCT_Digi' in digitizationFlags.experimentalDigi() and not 'doFastPixelDigi' in digitizationFlags.experimentalDigi(): - PixelConfigCondAlg.UseCalibConditions=False + # Set empty Folder + if not useNewChargeFormat: + if not hasattr(condSeq, 'PixelChargeCalibCondAlg'): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeCalibCondAlg + condSeq += PixelChargeCalibCondAlg(name="PixelChargeCalibCondAlg", ReadKey="") + else: + if not hasattr(condSeq, 'PixelChargeLUTCalibCondAlg'): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeLUTCalibCondAlg + condSeq += PixelChargeLUTCalibCondAlg(name="PixelChargeLUTCalibCondAlg", ReadKey="") + else: ##################### # Calibration Setup # diff --git a/InnerDetector/InDetDigitization/FastSiDigitization/share/PixelDigitization_jobOptions.py b/InnerDetector/InDetDigitization/FastSiDigitization/share/PixelDigitization_jobOptions.py index 779edc32d41..5273dfdd56e 100644 --- a/InnerDetector/InDetDigitization/FastSiDigitization/share/PixelDigitization_jobOptions.py +++ b/InnerDetector/InDetDigitization/FastSiDigitization/share/PixelDigitization_jobOptions.py @@ -27,21 +27,33 @@ from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") if not hasattr(condSeq, 'PixelConfigCondAlg'): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=False, - ReadDeadMapKey="/PIXEL/PixMapOverlay", - UseCalibConditions=True) + condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg",ReadDeadMapKey="") + + +useNewChargeFormat = False +useNewDeadmapFormat = False + +if useNewDeadmapFormat: + if not hasattr(condSeq, "PixelDeadMapCondAlg"): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg + condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg",ReadKey="") ##################### # Calibration setup # ##################### from IOVDbSvc.CondDB import conddb -if not conddb.folderRequested("/PIXEL/PixCalib"): - conddb.addFolder("PIXEL_OFL", "/PIXEL/PixCalib", className="CondAttrListCollection") - -if not hasattr(condSeq, 'PixelChargeCalibCondAlg'): - from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeCalibCondAlg - condSeq += PixelChargeCalibCondAlg(name="PixelChargeCalibCondAlg", ReadKey="/PIXEL/PixCalib") +if not useNewChargeFormat: + if not conddb.folderRequested("/PIXEL/PixCalib"): + conddb.addFolder("PIXEL_OFL", "/PIXEL/PixCalib", className="CondAttrListCollection") + if not hasattr(condSeq, 'PixelChargeCalibCondAlg'): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeCalibCondAlg + condSeq += PixelChargeCalibCondAlg(name="PixelChargeCalibCondAlg", ReadKey="/PIXEL/PixCalib") +else: + if not conddb.folderRequested("/PIXEL/ChargeCalibration"): + conddb.addFolder("PIXEL_OFL", "/PIXEL/ChargeCalibration", className="CondAttrListCollection") + if not hasattr(condSeq, 'PixelChargeLUTCalibCondAlg'): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeLUTCalibCondAlg + condSeq += PixelChargeLUTCalibCondAlg(name="PixelChargeLUTCalibCondAlg", ReadKey="/PIXEL/ChargeCalibration") from PixelConditionsTools.PixelConditionsToolsConf import PixelRecoDbTool ToolSvc += PixelRecoDbTool() diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py index 9fda804bfb2..e21bc177cd5 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfig.py @@ -126,14 +126,6 @@ def BasicPixelDigitizationTool(name="PixelDigitizationTool", **kwargs): if not hasattr(condSeq, 'PixelConfigCondAlg'): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg - - PixelConfigCondAlg.UseCalibConditions=True - PixelConfigCondAlg.UseDeadmapConditions=True - PixelConfigCondAlg.UseDCSStateConditions=False - PixelConfigCondAlg.UseDCSStatusConditions=False - PixelConfigCondAlg.UseDCSHVConditions=True - PixelConfigCondAlg.UseDCSTemperatureConditions=True - PixelConfigCondAlg.UseTDAQConditions=False PixelConfigCondAlg.UseCablingConditions=False from AthenaCommon.BeamFlags import jobproperties diff --git a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigNew.py b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigNew.py index b133d30a5f7..d01cd5f28bc 100644 --- a/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigNew.py +++ b/InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigNew.py @@ -149,14 +149,7 @@ def PixelDigitizationBasicToolCfg(flags, name="PixelDigitizationBasicTool", **kw acc = PixelGeometryCfg(flags) # module parameters - acc.merge(PixelConfigCondAlgCfg(flags, - UseCalibConditions=True, - UseDeadmapConditions=True, - UseDCSStateConditions=False, - UseDCSStatusConditions=False, - UseDCSHVConditions=True, - UseDCSTemperatureConditions=True, - UseTDAQConditions=False)) + acc.merge(PixelConfigCondAlgCfg(flags)) # charge calibration acc.merge(PixelChargeCalibCondAlgCfg(flags)) # NEW FOR RUN3 acc.merge(PixelChargeLUTCalibCondAlgCfg(flags)) diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py index 04b4239fa98..42c8280920a 100644 --- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py +++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py @@ -424,10 +424,7 @@ if dumpPixInfo: condSeq = AthSequencer("AthCondSeq") if not hasattr(condSeq, "PixelConfigCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDCSStateConditions=True, - UseDCSStatusConditions=True) - + condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg") if not hasattr(condSeq, "PixelDCSCondStateAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDCSCondStateAlg condSeq += PixelDCSCondStateAlg(name="PixelDCSCondStateAlg") diff --git a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py index 335ae6e7d84..80ec30c3f5f 100644 --- a/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py +++ b/InnerDetector/InDetExample/InDetRecExample/share/InDetRecConditionsAccess.py @@ -105,23 +105,24 @@ if DetFlags.pixel_on(): else: IdMappingDat="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=(not athenaCommonFlags.isOnline()), - UseDCSStateConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseDCSStatusConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseTDAQConditions=athenaCommonFlags.isOnline(), - UseCalibConditions=True, - UseCablingConditions=useCablingConditions, - CablingMapFileName=IdMappingDat) + alg = PixelConfigCondAlg(name="PixelConfigCondAlg", + UseCablingConditions=useCablingConditions, + CablingMapFileName=IdMappingDat) + if athenaCommonFlags.isOnline(): + alg.ReadDeadMapKey = "" + condSeq += alg if useNewDeadmapFormat: if not conddb.folderRequested("/PIXEL/PixelModuleFeMask"): conddb.addFolder("PIXEL_OFL", "/PIXEL/PixelModuleFeMask", className="CondAttrListCollection") if not hasattr(condSeq, "PixelDeadMapCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg - condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + alg = PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + if athenaCommonFlags.isOnline(): + alg.ReadKey = "" + condSeq += alg - if not athenaCommonFlags.isOnline(): + if globalflags.DataSource=='data' and InDetFlags.usePixelDCS(): if not conddb.folderRequested("/PIXEL/DCS/FSMSTATE"): conddb.addFolder("DCS_OFL", "/PIXEL/DCS/FSMSTATE", className="CondAttrListCollection") if not conddb.folderRequested("/PIXEL/DCS/FSMSTATUS"): @@ -228,7 +229,17 @@ if DetFlags.pixel_on(): PixeldEdxAlg.CalibrationFile="dtpar_signed_234.txt" else: PixeldEdxAlg.CalibrationFile="mcpar_signed_234.txt" - + + ################ + # RUN-1 legacy # + ################ + if commonGeoFlags.Run()=="RUN1" and athenaCommonFlags.isOnline(): + if not conddb.folderRequested("/TDAQ/Resources/ATLAS/PIXEL/Modules"): + conddb.addFolder("TDAQ_ONL", "/TDAQ/Resources/ATLAS/PIXEL/Modules", className="CondAttrListCollection") + if not hasattr(condSeq, "PixelTDAQCondAlg"): + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelTDAQCondAlg + condSeq += PixelTDAQCondAlg(name="PixelTDAQCondAlg", ReadKey="/TDAQ/Resources/ATLAS/PIXEL/Modules") + # # --- Load SCT Conditions Services # diff --git a/InnerDetector/InDetExample/InDetSLHC_Example/share/postInclude.SLHC_Rec.py b/InnerDetector/InDetExample/InDetSLHC_Example/share/postInclude.SLHC_Rec.py index 27da800e153..cf08dcad681 100644 --- a/InnerDetector/InDetExample/InDetSLHC_Example/share/postInclude.SLHC_Rec.py +++ b/InnerDetector/InDetExample/InDetSLHC_Example/share/postInclude.SLHC_Rec.py @@ -38,10 +38,22 @@ if rec.doWriteESD() or rec.doWriteAOD() or ('doWriteESD' in dir() and doWriteESD printfunc ('===> OVERWRITTEN TOOL SETTINGS ................') # --- turn off cluster calibration from DB, does not exist for IBL - from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg - PixelConfigCondAlg.UseCalibConditions = False - PixelConfigCondAlg.UseDeadmapConditions = False - + useNewChargeFormat = False + if not useNewChargeFormat: + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeCalibCondAlg + PixelChargeCalibCondAlg.ReadKey="" + else: + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeLUTCalibCondAlg + PixelChargeLUTCalibCondAlg.ReadKey="" + + useNewDeadmapFormat = False + if not useNewDeadmapFormat: + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg + PixelConfigCondAlg.ReadDeadMapKey = "" + else: + from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg + PixelDeadMapCondAlg.ReadKey = "" + # --- switch alignment for IBL geometry off (gives WARNING) from PixelGeoModel.PixelGeoModelConf import PixelDetectorTool pixelTool = PixelDetectorTool() diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py index 56fda0c7da4..b6b92a9c868 100644 --- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py +++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigConditions.py @@ -126,15 +126,12 @@ class PixelConditionsServicesSetup: else: IdMappingDat="PixelCabling/Pixels_Atlas_IdMapping_344494.dat" - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=self.usePixMap, - UseDCSStateConditions=self.useDCS, - UseDCSStatusConditions=self.useDCS, - UseTDAQConditions=self.useTDAQ, # should be false. This is only valid in RUN-1. - UseCalibConditions=True, - UseCablingConditions=useCablingConditions, - CablingMapFileName=IdMappingDat) - + alg = PixelConfigCondAlg(name="PixelConfigCondAlg", + UseCablingConditions=useCablingConditions, + CablingMapFileName=IdMappingDat) + if not self.usePixMap: + alg.ReadDeadMapKey = "" + condSeq += alg ######################### # Deadmap Setup (RUN-3) # @@ -144,7 +141,10 @@ class PixelConditionsServicesSetup: conddb.addFolder("PIXEL_OFL", "/PIXEL/PixelModuleFeMask", className="CondAttrListCollection") if not hasattr(condSeq, "PixelDeadMapCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg - condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + alg = PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + if not self.usePixMap: + alg.ReadKey = "" + condSeq += alg ######################## # DCS Conditions Setup # @@ -163,8 +163,8 @@ class PixelConditionsServicesSetup: conddb.addFolder(PixelDBInstance, PixelHVFolder, className="CondAttrListCollection") if not conddb.folderRequested(PixelTempFolder): conddb.addFolder(PixelDBInstance, PixelTempFolder, className="CondAttrListCollection") - - if not self.onlineMode: #this is only for testing in offline like setup + + if not self.onlineMode and self.useDCS: #this is only for testing in offline like setup if not conddb.folderRequested("/PIXEL/DCS/FSMSTATE"): conddb.addFolder("DCS_OFL", "/PIXEL/DCS/FSMSTATE", className="CondAttrListCollection") if not conddb.folderRequested("/PIXEL/DCS/FSMSTATUS"): diff --git a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecPreProcessing.py b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecPreProcessing.py index b22d5446699..af432f10d02 100755 --- a/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecPreProcessing.py +++ b/InnerDetector/InDetExample/InDetTrigRecExample/python/InDetTrigConfigRecPreProcessing.py @@ -79,8 +79,8 @@ class PixelClustering_EF( InDet__Pixel_TrgClusterization ): InDetTrigMergedPixelsTool = InDet__MergedPixelsTool( name = "InDetTrigMergedPixelsTool", globalPosAlg = InDetTrigClusterMakerTool, PixelConditionsSummaryTool = InDetTrigPixelConditionsSummaryTool, - #UseSpecialPixelMap = False #simpler setup for EFID - UseSpecialPixelMap = True) + #UsePixelModuleMap = False #simpler setup for EFID + UsePixelModuleMap = True) # Enable duplcated RDO check for data15 because duplication mechanism was used. from RecExConfig.RecFlags import rec if len(rec.projectName())>=6 and rec.projectName()[:6]=="data15": diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/python/TrackSummaryToolWorkaround.py b/InnerDetector/InDetMonitoring/SCT_Monitoring/python/TrackSummaryToolWorkaround.py index a66b8c0877b..94ec785dcd3 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/python/TrackSummaryToolWorkaround.py +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/python/TrackSummaryToolWorkaround.py @@ -17,14 +17,7 @@ def TrackSummaryToolWorkaround(flags): # Taken from InnerDetector/InDetDigitization/PixelDigitization/python/PixelDigitizationConfigNew.py from PixelConditionsAlgorithms.PixelConditionsConfig import PixelConfigCondAlgCfg - result.merge(PixelConfigCondAlgCfg(flags, - UseCalibConditions=True, - UseDeadmapConditions=True, - UseDCSStateConditions=(not flags.Input.isMC and flags.InDet.usePixelDCS), - UseDCSStatusConditions=(not flags.Input.isMC and flags.InDet.usePixelDCS), - UseDCSHVConditions=True, - UseDCSTemperatureConditions=True, - UseTDAQConditions=False)) + result.merge(PixelConfigCondAlgCfg(flags)) from PixelConditionsTools.PixelConditionsSummaryConfig import PixelConditionsSummaryCfg InDetPixelConditionsSummaryTool = result.popToolsAndMerge(PixelConditionsSummaryCfg(flags)) diff --git a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/strippedDown.py b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/strippedDown.py index 9893bb89370..8e01402e827 100644 --- a/InnerDetector/InDetMonitoring/SCT_Monitoring/share/strippedDown.py +++ b/InnerDetector/InDetMonitoring/SCT_Monitoring/share/strippedDown.py @@ -62,9 +62,6 @@ elif globalflags.InputFormat() == 'bytestream': #-------------------------------------------------------------- # include SCT Clusterization #-------------------------------------------------------------- -from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg -PixelConfigCondAlg.UseCalibConditions = False - from SiClusterizationTool.SiClusterizationToolConf import InDet__ClusterMakerTool InDetClusterMakerTool = InDet__ClusterMakerTool(name = "InDetClusterMakerTool") ToolSvc += InDetClusterMakerTool diff --git a/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandalone.py b/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandalone.py index 3698aa44f90..c341ea7820e 100644 --- a/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandalone.py +++ b/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandalone.py @@ -247,24 +247,24 @@ if doPixel: else: IdMappingDat="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=(not athenaCommonFlags.isOnline()), - UseDCSStateConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseDCSStatusConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseTDAQConditions=athenaCommonFlags.isOnline(), - ReadDeadMapKey="/PIXEL/PixMapOverlay", - UseCalibConditions=True, - UseCablingConditions=useCablingConditions, - CablingMapFileName=IdMappingDat) + alg = PixelConfigCondAlg(name="PixelConfigCondAlg", + UseCablingConditions=useCablingConditions, + CablingMapFileName=IdMappingDat) + if athenaCommonFlags.isOnline(): + alg.ReadDeadMapKey = '' + condSeq += alg if useNewDeadmapFormat: if not conddb.folderRequested("/PIXEL/PixelModuleFeMask"): conddb.addFolder("PIXEL_OFL", "/PIXEL/PixelModuleFeMask", className="CondAttrListCollection") if not hasattr(condSeq, "PixelDeadMapCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg - condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + alg = PixelDeadMapCondAlg(name="PixelDeadMapCondAlg",ReadKey="/PIXEL/PixelModuleFeMask") + if athenaCommonFlags.isOnline(): + alg.ReadKey = '' + condSeq += alg - if not athenaCommonFlags.isOnline(): + if globalflags.DataSource=='data' and InDetFlags.usePixelDCS(): if not conddb.folderRequested("/PIXEL/DCS/FSMSTATE"): conddb.addFolder("DCS_OFL", "/PIXEL/DCS/FSMSTATE", className="CondAttrListCollection") if not conddb.folderRequested("/PIXEL/DCS/FSMSTATUS"): @@ -442,7 +442,6 @@ if doPixel: InDetClusterMakerTool.PixelLorentzAngleTool = ToolSvc.PixelLorentzAngleTool else: InDetClusterMakerTool.PixelCablingSvc = None - InDetClusterMakerTool.PixelModuleData = "" InDetClusterMakerTool.PixelChargeCalibCondData = "" InDetClusterMakerTool.PixelLorentzAngleTool = None InDetClusterMakerTool.PixelOfflineCalibData = "" diff --git a/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandaloneFromESD.py b/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandaloneFromESD.py index aa539246a6d..b67519fa878 100644 --- a/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandaloneFromESD.py +++ b/InnerDetector/InDetRecAlgs/SiSPSeededTrackFinder/share/SiSPSeededTracksStandaloneFromESD.py @@ -234,24 +234,24 @@ if doPixel: else: IdMappingDat="PixelCabling/Pixels_Atlas_IdMapping_May08.dat" - condSeq += PixelConfigCondAlg(name="PixelConfigCondAlg", - UseDeadmapConditions=(not athenaCommonFlags.isOnline()), - UseDCSStateConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseDCSStatusConditions=(globalflags.DataSource=='data') and InDetFlags.usePixelDCS(), - UseTDAQConditions=athenaCommonFlags.isOnline(), - ReadDeadMapKey="/PIXEL/PixMapOverlay", - UseCalibConditions=True, - UseCablingConditions=useCablingConditions, - CablingMapFileName=IdMappingDat) + alg = PixelConfigCondAlg(name="PixelConfigCondAlg", + UseCablingConditions=useCablingConditions, + CablingMapFileName=IdMappingDat) + if athenaCommonFlags.isOnline(): + alg.ReadDeadMapKey = "" + condSeq += alg if useNewDeadmapFormat: if not conddb.folderRequested("/PIXEL/PixelModuleFeMask"): conddb.addFolder("PIXEL_OFL", "/PIXEL/PixelModuleFeMask", className="CondAttrListCollection") if not hasattr(condSeq, "PixelDeadMapCondAlg"): from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg - condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + alg = PixelDeadMapCondAlg(name="PixelDeadMapCondAlg") + if athenaCommonFlags.isOnline(): + alg.ReadKey = "" + condSeq += alg - if not athenaCommonFlags.isOnline(): + if globalflags.DataSource=='data' and InDetFlags.usePixelDCS(): if not conddb.folderRequested("/PIXEL/DCS/FSMSTATE"): conddb.addFolder("DCS_OFL", "/PIXEL/DCS/FSMSTATE", className="CondAttrListCollection") if not conddb.folderRequested("/PIXEL/DCS/FSMSTATUS"): diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/ClusterMakerTool.h b/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/ClusterMakerTool.h index 28e8514b8c0..3ab17002ada 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/ClusterMakerTool.h +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/ClusterMakerTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -23,7 +23,6 @@ #include "GeoPrimitives/GeoPrimitives.h" #include "InDetCondTools/ISiLorentzAngleTool.h" #include "PixelCabling/IPixelCablingSvc.h" -#include "PixelConditionsData/PixelModuleData.h" #include "PixelConditionsData/PixelChargeCalibCondData.h" #include "PixelConditionsData/PixelOfflineCalibData.h" #include "StoreGate/ReadCondHandleKey.h" @@ -146,9 +145,6 @@ private: ServiceHandle<IPixelCablingSvc> m_pixelCabling {this, "PixelCablingSvc", "PixelCablingSvc", "Pixel cabling service"}; - SG::ReadCondHandleKey<PixelModuleData> m_moduleDataKey - {this, "PixelModuleData", "PixelModuleData", "Pixel module data"}; - SG::ReadCondHandleKey<PixelChargeCalibCondData> m_chargeDataKey {this, "PixelChargeCalibCondData", "PixelChargeCalibCondData", "Pixel charge calibration data"}; diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/PixelClusteringToolBase.h b/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/PixelClusteringToolBase.h index e573c219c09..9de15c22262 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/PixelClusteringToolBase.h +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/SiClusterizationTool/PixelClusteringToolBase.h @@ -68,7 +68,6 @@ protected: IntegerProperty m_splitClusters{this, "splitClusters", 0}; ToolHandle<IInDetConditionsTool> m_summaryTool{this, "PixelConditionsSummaryTool", "PixelConditionsSummaryTool", "Tool to retrieve Pixel Conditions summary"}; BooleanProperty m_useModuleMap{this, "UsePixelModuleMap", true, "Use bad modules map"}; - BooleanProperty m_usePixelMap{this, "UseSpecialPixelMap", true, "Use bad pixel map"}; }; diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/src/ClusterMakerTool.cxx b/InnerDetector/InDetRecTools/SiClusterizationTool/src/ClusterMakerTool.cxx index e08afbcac13..8b3d9b25883 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/src/ClusterMakerTool.cxx +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/src/ClusterMakerTool.cxx @@ -60,12 +60,7 @@ StatusCode ClusterMakerTool::initialize(){ if (not m_pixelCabling.empty()) { ATH_CHECK(m_pixelCabling.retrieve()); } - if (not m_moduleDataKey.empty()) { - ATH_CHECK(m_moduleDataKey.initialize()); - } - if (not m_chargeDataKey.empty()) { - ATH_CHECK(m_chargeDataKey.initialize()); - } + ATH_CHECK(m_chargeDataKey.initialize(SG::AllowEmpty)); if (not m_pixelLorentzAngleTool.empty()) { ATH_CHECK(m_pixelLorentzAngleTool.retrieve()); @@ -136,13 +131,11 @@ PixelCluster* ClusterMakerTool::pixelCluster( return nullptr; } - SG::ReadCondHandle<PixelModuleData> moduleData(m_moduleDataKey); - SG::ReadCondHandle<PixelChargeCalibCondData> calibData(m_chargeDataKey); - if ( errorStrategy==2 && m_forceErrorStrategy1A ) errorStrategy=1; // Fill vector of charges std::vector<float> chargeList; - if (moduleData->getUseCalibConditions()) { + if (!m_chargeDataKey.empty()) { + SG::ReadCondHandle<PixelChargeCalibCondData> calibData(m_chargeDataKey); int nRDO=rdoList.size(); chargeList.reserve(nRDO); for (int i=0; i<nRDO; i++) { @@ -283,9 +276,6 @@ PixelCluster* ClusterMakerTool::pixelCluster( } if ( errorStrategy==2 && m_forceErrorStrategy1B ) errorStrategy=1; - SG::ReadCondHandle<PixelModuleData> moduleData(m_moduleDataKey); - SG::ReadCondHandle<PixelChargeCalibCondData> calibData(m_chargeDataKey); - // Fill vector of charges and compute charge balance const InDetDD::PixelModuleDesign* design = (dynamic_cast<const InDetDD::PixelModuleDesign*>(&element->design())); if (not design){ @@ -300,51 +290,60 @@ PixelCluster* ClusterMakerTool::pixelCluster( float qColMin = 0; float qColMax = 0; std::vector<float> chargeList; int nRDO=rdoList.size(); - if (moduleData->getUseCalibConditions()) { chargeList.reserve(nRDO); } + if (!m_chargeDataKey.empty()) { + chargeList.reserve(nRDO); + SG::ReadCondHandle<PixelChargeCalibCondData> calibData(m_chargeDataKey); + for (int i=0; i<nRDO; i++) { + Identifier pixid=rdoList[i]; + int ToT=totList[i]; + + float charge = ToT; + Identifier moduleID = pixelID.wafer_id(pixid); + IdentifierHash moduleHash = pixelID.wafer_hash(moduleID); // wafer hash + int circ = m_pixelCabling->getFE(&pixid,moduleID); + int type = m_pixelCabling->getPixelType(pixid); + charge = calibData->getCharge((int)moduleHash, circ, type, 1.0*ToT); + if (moduleHash<12 || moduleHash>2035) { + charge = ToT/8.0*(8000.0-1200.0)+1200.0; + } + chargeList.push_back(charge); + } + } + for (int i=0; i<nRDO; i++) { - Identifier pixid=rdoList[i]; - int ToT=totList[i]; - - float charge = ToT; - if (moduleData->getUseCalibConditions()) { - - Identifier moduleID = pixelID.wafer_id(pixid); - IdentifierHash moduleHash = pixelID.wafer_hash(moduleID); // wafer hash - int circ = m_pixelCabling->getFE(&pixid,moduleID); - int type = m_pixelCabling->getPixelType(pixid); - charge = calibData->getCharge((int)moduleHash, circ, type, 1.0*ToT); - if (moduleHash<12 || moduleHash>2035) { - charge = ToT/8.0*(8000.0-1200.0)+1200.0; - } - - chargeList.push_back(charge); - } - // std::cout << "tot, charge = " << ToT << " " << charge << std::endl; - int row = pixelID.phi_index(pixid); - int col = pixelID.eta_index(pixid); - if (row == rowMin) qRowMin += charge; - if (row < rowMin){ - rowMin = row; - qRowMin = charge; - } - - if (row == rowMax) qRowMax += charge; - if (row > rowMax){ - rowMax = row; - qRowMax = charge; - } - if (col == colMin) qColMin += charge; - if (col < colMin){ - colMin = col; - qColMin = charge; - } - - if (col == colMax) qColMax += charge; - if (col > colMax){ - colMax = col; - qColMax = charge; - } + Identifier pixid=rdoList[i]; + int ToT=totList[i]; + + float charge = ToT; + if (!m_chargeDataKey.empty()) { charge=chargeList[i]; } + + // std::cout << "tot, charge = " << ToT << " " << charge << std::endl; + int row = pixelID.phi_index(pixid); + int col = pixelID.eta_index(pixid); + if (row == rowMin) qRowMin += charge; + if (row < rowMin){ + rowMin = row; + qRowMin = charge; + } + + if (row == rowMax) qRowMax += charge; + if (row > rowMax){ + rowMax = row; + qRowMax = charge; + } + if (col == colMin) qColMin += charge; + if (col < colMin){ + colMin = col; + qColMin = charge; + } + + if (col == colMax) qColMax += charge; + if (col > colMax){ + colMax = col; + qColMax = charge; + } } + Identifier newClusterID = pixelID.pixel_id(pixelID.wafer_id(clusterID),rowMin,colMin); // Compute omega for charge interpolation correction (if required) // Two pixels may have charge=0 (very rarely, hopefully) diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx b/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx index 0f0d077f699..c9f25be8043 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/src/MergedPixelsTool.cxx @@ -341,7 +341,7 @@ namespace InDet { std::unordered_set<Identifier> setOfIdentifiers{}; for(const auto & rdo : collection) { const Identifier rdoID= rdo->identify(); - if (m_usePixelMap and !(m_summaryTool->isGood(idHash,rdoID))) continue; + if (m_useModuleMap and !(m_summaryTool->isGood(idHash,rdoID))) continue; //check for duplication: //add to set of existing identifiers. If it fails (.second = false) then skip it. if (not setOfIdentifiers.insert(rdoID).second) continue; diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/src/PixelClusteringToolBase.cxx b/InnerDetector/InDetRecTools/SiClusterizationTool/src/PixelClusteringToolBase.cxx index 55700087730..3a1462a88e6 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/src/PixelClusteringToolBase.cxx +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/src/PixelClusteringToolBase.cxx @@ -39,7 +39,7 @@ namespace InDet StatusCode sc = m_summaryTool.retrieve(); if (sc.isFailure() || !m_summaryTool) { ATH_MSG_WARNING(m_summaryTool.type() << " not found! "); - if ( m_usePixelMap || m_useModuleMap ) { + if (m_useModuleMap ) { ATH_MSG_FATAL(m_summaryTool.type() << " is compulsory with this tool configuration"); return StatusCode::FAILURE; } diff --git a/InnerDetector/InDetValidation/InDetExperimentalReco/share/jobOptions_RecExCommon_masking.py b/InnerDetector/InDetValidation/InDetExperimentalReco/share/jobOptions_RecExCommon_masking.py index 771d5e3bb8d..0cd2a14338c 100755 --- a/InnerDetector/InDetValidation/InDetExperimentalReco/share/jobOptions_RecExCommon_masking.py +++ b/InnerDetector/InDetValidation/InDetExperimentalReco/share/jobOptions_RecExCommon_masking.py @@ -208,9 +208,6 @@ from IOVDbSvc.CondDB import conddb conddb.addOverride ('/SCT/Manual/BadModules', 'SCTManualBadModules-000-00') -ServiceMgr.SpecialPixelMapSvc.MaskLayers = True -ServiceMgr.SpecialPixelMapSvc.LayersToMask = [0] - #ServiceMgr.InDetSCT_ModuleVetoSvc.MaskLayers = True #ServiceMgr.InDetSCT_ModuleVetoSvc.MaskSide = -1 #ServiceMgr.InDetSCT_ModuleVetoSvc.DisksToMask = [-9] diff --git a/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py b/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py index 45598f45729..6360e4a324d 100644 --- a/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py +++ b/Trigger/TrigTools/TrigInDetConfig/python/InDetSetup.py @@ -161,9 +161,6 @@ def makeInDetAlgs( whichSignature='', separateTrackParticleCreator='', rois = 'E #Pixel clusterisation from InDetTrigRecExample.InDetTrigConfigRecLoadTools import TrigPixelLorentzAngleTool, TrigSCTLorentzAngleTool - from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg - PixelConfigCondAlg.UseCalibConditions = False - from SiClusterizationTool.SiClusterizationToolConf import InDet__ClusterMakerTool InDetClusterMakerTool = InDet__ClusterMakerTool(name = "InDetClusterMakerTool_" + signature, SCTLorentzAngleTool = TrigSCTLorentzAngleTool, diff --git a/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py b/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py index b8bb91cab32..7c246bbeebf 100644 --- a/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py +++ b/Trigger/TrigTools/TrigInDetConfig/python/TrigInDetConfig.py @@ -387,15 +387,7 @@ def TrigInDetCondCfg( flags ): from PixelCabling.PixelCablingConfigNew import PixelCablingSvcCfg # module parameters - acc.merge(PixelConfigCondAlgCfg(flags, - UseCalibConditions=False, - UseDeadmapConditions=True, - UseDCSStateConditions=False, - UseDCSStatusConditions=False, - UseDCSHVConditions=True, - UseDCSTemperatureConditions=True, - UseTDAQConditions=False)) - + acc.merge(PixelConfigCondAlgCfg(flags)) # charge calibration acc.merge(PixelChargeCalibCondAlgCfg(flags)) # NEW FOR RUN3 acc.merge(PixelChargeLUTCalibCondAlgCfg(flags)) -- GitLab